@threadlabs/looma 0.28.10 → 0.28.12
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-editor-chip-editor/ui-editor-chip-editor.html +32 -0
- package/components/ui-editor-chip-editor/ui-editor-chip-editor.js +33 -0
- package/components/ui-radio-group/ui-radio-group.html +13 -1
- package/components/ui-swatch/ui-swatch.html +69 -0
- package/dist/index.js +38 -37
- package/editor/block-actions.d.ts +9 -0
- package/editor/extensions/table-commands.d.ts +7 -1
- package/package.json +1 -1
- package/styles/ui-editor-chip-editor.css +1 -0
- package/styles/ui-radio-group.css +9 -0
- package/styles/ui-swatch.css +76 -0
- package/vanilla/UiEditorChipEditor.d.ts +18 -0
- package/vanilla/UiEditorChipEditor.js +45 -0
- package/vanilla/UiRadioGroup.d.ts +1 -0
- package/vanilla/UiRadioGroup.js +18 -13
- package/vanilla/UiSwatch.d.ts +14 -0
- package/vanilla/UiSwatch.js +54 -0
- package/vanilla/index.js +2 -0
- package/vue/UiEditorChipEditor.d.ts +45 -0
- package/vue/UiEditorChipEditor.js +2 -0
- package/vue/UiEditorChipEditor.vue +163 -0
- package/vue/UiRadioGroup.d.ts +9 -0
- package/vue/UiRadioGroup.vue +44 -2
- package/vue/UiSwatch.d.ts +16 -0
- package/vue/UiSwatch.js +2 -0
- package/vue/UiSwatch.vue +150 -0
- package/vue/chunks/UiEditorChipEditor.js +157 -0
- package/vue/chunks/UiEditorImageToolbar.js +2 -2
- package/vue/chunks/UiEditorLinkCard.js +1 -1
- package/vue/chunks/UiEditorLinkForm.js +2 -2
- package/vue/chunks/UiRadioGroup.js +26 -3
- package/vue/chunks/UiSwatch.js +78 -0
- package/vue/components.css +461 -443
- package/vue/editor/index.js +148 -105
- package/vue/editor/primitives.d.ts +9 -1
- package/vue/index.d.ts +2 -0
- package/vue/index.js +6 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<link rel="component" href="../ui-stack/ui-stack.html">
|
|
2
|
+
<link rel="component" href="../ui-input/ui-input.html">
|
|
3
|
+
<link rel="component" href="../ui-radio-group/ui-radio-group.html">
|
|
4
|
+
<link rel="component" href="../ui-swatch/ui-swatch.html">
|
|
5
|
+
<template component="ui-editor-chip-editor" controller="./ui-editor-chip-editor.js">
|
|
6
|
+
<defs>
|
|
7
|
+
<prop name="label" type="string" default="">The chip's text, shown in the field as the reader edits it.</prop>
|
|
8
|
+
<prop name="color" type="keyword" values="neutral, blue, green, yellow, red, purple" default="neutral">The chip's colour, checked among the swatches.</prop>
|
|
9
|
+
<event name="label" type="object">
|
|
10
|
+
<prop name="label" required type="string"></prop>
|
|
11
|
+
The chip's text changed.
|
|
12
|
+
</event>
|
|
13
|
+
<event name="color" type="object">
|
|
14
|
+
<prop name="color" required type="keyword" values="neutral, blue, green, yellow, red, purple"></prop>
|
|
15
|
+
A colour was chosen.
|
|
16
|
+
</event>
|
|
17
|
+
<event name="done" type="object">Enter or Escape was pressed in the text field, to close the editor and return to the chip.</event>
|
|
18
|
+
</defs>
|
|
19
|
+
<div role="dialog" aria-label="Edit chip">
|
|
20
|
+
<ui-stack gap="s">
|
|
21
|
+
<ui-input data-chip-label size="sm" placeholder="Set a label" aria-label="Chip text" from:value="$label"></ui-input>
|
|
22
|
+
<ui-radio-group label="Chip color" label-visibility="sr-only" from:value="$color">
|
|
23
|
+
<ui-swatch tone="neutral"></ui-swatch>
|
|
24
|
+
<ui-swatch tone="blue"></ui-swatch>
|
|
25
|
+
<ui-swatch tone="green"></ui-swatch>
|
|
26
|
+
<ui-swatch tone="yellow"></ui-swatch>
|
|
27
|
+
<ui-swatch tone="red"></ui-swatch>
|
|
28
|
+
<ui-swatch tone="purple"></ui-swatch>
|
|
29
|
+
</ui-radio-group>
|
|
30
|
+
</ui-stack>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Reports the chip's text and colour as they change, and Enter or Escape in the text field as done.
|
|
2
|
+
// A colour chosen with the pointer returns focus to the text; the arrow keys stay among the swatches.
|
|
3
|
+
function connect(host) {
|
|
4
|
+
const element = host.element;
|
|
5
|
+
const text = () => element.querySelector("[data-chip-label]");
|
|
6
|
+
const onInput = (event) => {
|
|
7
|
+
if (event.target === text()) host.dispatch("label", { label: event.target.value });
|
|
8
|
+
};
|
|
9
|
+
// The radio group reports a choice as select; a text selection in the field is a native select without a value.
|
|
10
|
+
const onSelect = (event) => {
|
|
11
|
+
if (event.target === element || typeof event.detail?.value !== "string") return;
|
|
12
|
+
host.dispatch("color", { color: event.detail.value });
|
|
13
|
+
if (event.detail.trigger === "pointer") text()?.focus();
|
|
14
|
+
};
|
|
15
|
+
const onKeyDown = (event) => {
|
|
16
|
+
if (event.target !== text() || (event.key !== "Enter" && event.key !== "Escape")) return;
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
host.dispatch("done", {});
|
|
19
|
+
};
|
|
20
|
+
element.addEventListener("input", onInput);
|
|
21
|
+
element.addEventListener("select", onSelect);
|
|
22
|
+
element.addEventListener("keydown", onKeyDown);
|
|
23
|
+
return () => {
|
|
24
|
+
element.removeEventListener("input", onInput);
|
|
25
|
+
element.removeEventListener("select", onSelect);
|
|
26
|
+
element.removeEventListener("keydown", onKeyDown);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Keep DOM setup and its cleanup tied to each connection, including reconnects. */
|
|
31
|
+
export default function controller(host) {
|
|
32
|
+
host.on("connect", () => connect(host));
|
|
33
|
+
}
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
the radios together, so set it when the choice submits with a form.</prop>
|
|
9
9
|
<prop name="label" type="string" default="Options"
|
|
10
10
|
>The group's legend, shown above the radios and announced as the group's name. Phrase it as the question the radios answer.</prop>
|
|
11
|
+
<prop name="labelVisibility" type="keyword" values="visible, sr-only" default="visible"
|
|
12
|
+
>visible shows the legend; sr-only hides it visually but keeps it as the group's accessible name. Use sr-only only when the surrounding layout already makes
|
|
13
|
+
the choice clear, as with a row of colour swatches.</prop>
|
|
11
14
|
<prop name="orientation" type="keyword" values="horizontal, vertical" default="horizontal"
|
|
12
15
|
>horizontal lays the radios out in a row; vertical stacks them in a column. The arrow keys move between radios either way.</prop>
|
|
13
16
|
<prop name="disabled" type="boolean" default="false"
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
</event>
|
|
32
35
|
</defs>
|
|
33
36
|
<fieldset role="radiogroup" from:aria-required="$required" from:aria-invalid="$invalid" from:disabled="$disabled">
|
|
34
|
-
<legend>{$label}</legend>
|
|
37
|
+
<legend class:sr-only="$labelVisibility = 'sr-only'">{$label}</legend>
|
|
35
38
|
<slot></slot>
|
|
36
39
|
</fieldset>
|
|
37
40
|
<style>
|
|
@@ -64,6 +67,15 @@
|
|
|
64
67
|
clear: both;
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
legend.sr-only {
|
|
71
|
+
position: absolute;
|
|
72
|
+
inline-size: 1px;
|
|
73
|
+
block-size: 1px;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
clip-path: inset(50%);
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
:host([invalid]) legend {
|
|
68
80
|
color: var(--_ui-radio-group-invalid-text);
|
|
69
81
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template component="ui-swatch">
|
|
2
|
+
<defs>
|
|
3
|
+
<prop name="tone" type="keyword" values="neutral, blue, green, yellow, red, purple" default="neutral"
|
|
4
|
+
>The swatch's colour, on the same tokens as editor chips. It is also the radio's value and, by name, its label.</prop>
|
|
5
|
+
<computed name="toneName" from="{ neutral: 'Neutral', blue: 'Blue', green: 'Green', yellow: 'Yellow', red: 'Red', purple: 'Purple' }[$tone]"></computed>
|
|
6
|
+
</defs>
|
|
7
|
+
<input type="radio" from:value="$tone" from:aria-label="$toneName">
|
|
8
|
+
<style>
|
|
9
|
+
@property --ui-swatch-size {
|
|
10
|
+
syntax: "*";
|
|
11
|
+
inherits: false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* A native radio drawn as a round dot. Inside a ui-radio-group the group names it, applies its
|
|
15
|
+
value, and moves between swatches with the arrow keys. */
|
|
16
|
+
:host {
|
|
17
|
+
--_surface: var(--ui-surface-subtle);
|
|
18
|
+
--_text: var(--ui-text-secondary);
|
|
19
|
+
|
|
20
|
+
appearance: none;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
flex: 0 0 auto;
|
|
23
|
+
inline-size: var(--ui-swatch-size, 1.65rem);
|
|
24
|
+
block-size: var(--ui-swatch-size, 1.65rem);
|
|
25
|
+
margin: 0;
|
|
26
|
+
border: var(--ui-border-width) solid color-mix(in srgb, var(--_surface) 75%, var(--_text) 25%);
|
|
27
|
+
border-radius: 50%;
|
|
28
|
+
background: var(--_surface);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host([tone="blue"]) {
|
|
33
|
+
--_surface: var(--ui-info-soft);
|
|
34
|
+
--_text: var(--ui-info-subtle-text);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([tone="green"]) {
|
|
38
|
+
--_surface: var(--ui-success-soft);
|
|
39
|
+
--_text: var(--ui-success-subtle-text);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([tone="yellow"]) {
|
|
43
|
+
--_surface: var(--ui-warning-soft);
|
|
44
|
+
--_text: var(--ui-warning-subtle-text);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([tone="red"]) {
|
|
48
|
+
--_surface: var(--ui-danger-soft);
|
|
49
|
+
--_text: var(--ui-danger-subtle-text);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host([tone="purple"]) {
|
|
53
|
+
--_surface: var(--ui-accent-soft);
|
|
54
|
+
--_text: var(--ui-accent-subtle-text);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* The chosen swatch and the focused one share one ring at the focus width (2px by default), in
|
|
58
|
+
the tone or the focus colour. */
|
|
59
|
+
:host(:checked) {
|
|
60
|
+
outline: var(--ui-focus-width) solid var(--_text);
|
|
61
|
+
outline-offset: var(--ui-focus-width);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host(:focus-visible) {
|
|
65
|
+
outline: var(--ui-focus-width) solid var(--ui-focus-ring, var(--ui-accent-solid));
|
|
66
|
+
outline-offset: var(--ui-focus-width);
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
69
|
+
</template>
|