@dumiflex/wp-kit 0.3.0 → 0.5.0
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/CHANGELOG.md +92 -51
- package/LICENSE +674 -674
- package/README.md +73 -76
- package/package.json +78 -77
- package/src/Avatar.vue +83 -83
- package/src/Badge.vue +97 -97
- package/src/Banner.vue +118 -118
- package/src/BookmarkButton.vue +27 -27
- package/src/BundleMeta.vue +51 -51
- package/src/Button.vue +103 -103
- package/src/Card.vue +68 -68
- package/src/Checkbox.vue +109 -107
- package/src/Chip.vue +163 -97
- package/src/ChoiceCards.vue +133 -133
- package/src/CloseButton.vue +69 -69
- package/src/CodeBlock.vue +146 -119
- package/src/ColorField.vue +188 -206
- package/src/ColorPicker.vue +201 -201
- package/src/Combobox.vue +331 -334
- package/src/ConfirmDialog.vue +165 -163
- package/src/ConfirmModal.vue +147 -147
- package/src/ConstraintMatrixPreview.vue +708 -708
- package/src/ContextMenu.vue +386 -379
- package/src/CopyButton.vue +156 -156
- package/src/DataTable.vue +293 -292
- package/src/DatePicker.vue +234 -234
- package/src/DescriptionList.vue +73 -73
- package/src/DiffView.vue +68 -68
- package/src/Disclosure.vue +166 -166
- package/src/DragHandle.vue +49 -49
- package/src/Drawer.vue +131 -131
- package/src/DropZone.vue +196 -196
- package/src/DropdownMenu.vue +72 -72
- package/src/EmptyState.vue +111 -111
- package/src/Field.vue +28 -28
- package/src/HsvPicker.vue +208 -208
- package/src/Icon.vue +39 -39
- package/src/IconPicker.vue +209 -209
- package/src/ImageGrid.vue +127 -125
- package/src/InlineEdit.vue +183 -183
- package/src/Input.vue +99 -99
- package/src/Kbd.vue +56 -56
- package/src/Lightbox.vue +176 -173
- package/src/ListFilter.vue +85 -85
- package/src/ListRow.vue +204 -204
- package/src/LoadingMark.vue +217 -161
- package/src/Logo.vue +60 -60
- package/src/Modal.vue +78 -76
- package/src/ModalShell.vue +109 -107
- package/src/Pagination.vue +106 -106
- package/src/Popover.vue +180 -171
- package/src/PostCard.vue +210 -211
- package/src/ProgressBar.vue +90 -90
- package/src/RadioGroup.vue +177 -177
- package/src/RangeSlider.vue +183 -183
- package/src/RelativeDate.vue +35 -35
- package/src/ResizeHandle.vue +143 -143
- package/src/SearchInput.vue +192 -199
- package/src/Select.vue +644 -641
- package/src/Separator.vue +54 -54
- package/src/Skeleton.vue +98 -82
- package/src/Slider.vue +198 -198
- package/src/SortableList.vue +260 -260
- package/src/SplitPane.vue +68 -68
- package/src/StarButton.vue +40 -40
- package/src/Stepper.vue +141 -141
- package/src/SupportLinks.vue +93 -93
- package/src/TagInput.vue +297 -300
- package/src/Textarea.vue +57 -57
- package/src/Timeline.vue +92 -92
- package/src/ToastCard.vue +119 -119
- package/src/ToastHost.vue +40 -40
- package/src/Toggle.vue +36 -36
- package/src/TokenizedValue.vue +310 -310
- package/src/Toolbar.vue +110 -110
- package/src/VirtualList.vue +87 -87
- package/src/VisuallyHidden.vue +29 -29
- package/src/WpButton.vue +75 -75
- package/src/WpCheck.vue +104 -102
- package/src/WpIconButton.vue +107 -107
- package/src/WpImageZoom.vue +544 -544
- package/src/WpNumber.vue +178 -183
- package/src/WpSegmented.vue +175 -175
- package/src/WpSelect.vue +93 -89
- package/src/WpSwitch.vue +163 -163
- package/src/WpTabs.vue +188 -188
- package/src/_modal-motion.css +33 -33
- package/src/_skeleton.css +50 -50
- package/src/axis-color.ts +42 -42
- package/src/button.css +169 -169
- package/src/calendar.ts +59 -59
- package/src/clipboard.ts +50 -50
- package/src/colour-presets.ts +12 -12
- package/src/diff.ts +51 -51
- package/src/drop-zone.ts +41 -41
- package/src/field.css +50 -0
- package/src/flip.ts +237 -237
- package/src/floating-layer.ts +48 -0
- package/src/floating.ts +99 -99
- package/src/highlight.ts +199 -0
- package/src/hsv.ts +100 -100
- package/src/icon-catalog.ts +52 -52
- package/src/image-zoom.ts +93 -93
- package/src/kind-colour.ts +28 -0
- package/src/loading-mark-motion.ts +249 -0
- package/src/logo-paths.ts +21 -21
- package/src/matrix-axis.ts +91 -91
- package/src/pagination.ts +27 -27
- package/src/platform-keys.ts +29 -29
- package/src/rich-tokenize.ts +357 -357
- package/src/select-types.ts +32 -32
- package/src/slider-math.ts +45 -45
- package/src/sortable.ts +22 -22
- package/src/theme/fonts/OFL-Fraunces.txt +93 -93
- package/src/theme/fonts/OFL-JetBrainsMono.txt +93 -93
- package/src/theme/fonts/OFL-Manrope.txt +93 -93
- package/src/theme/looks.css +428 -428
- package/src/theme/palettes.css +254 -254
- package/src/theme/tokens.css +2896 -2894
- package/src/tokens.ts +56 -56
- package/src/tooltip.css +43 -43
- package/src/tooltip.ts +146 -146
- package/src/useDialogFocus.ts +73 -73
- package/src/useGrowableField.ts +357 -357
- package/src/useModalKeyShield.ts +116 -116
- package/src/useToast.ts +48 -48
- package/src/wp-logo.svg +14 -14
- package/src/ChipToggle.vue +0 -92
- package/src/KindChip.vue +0 -53
- package/src/RatingBadge.vue +0 -42
package/src/ColorField.vue
CHANGED
|
@@ -1,206 +1,188 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* A colour swatch that opens a picker: the colour square, a hex box, and
|
|
4
|
-
* (with `alpha`) an opacity number, or (with `allowNone`) a "None" choice.
|
|
5
|
-
* The value is a hex string, `#rrggbb` or `#rrggbbaa` once it is
|
|
6
|
-
* see-through, or `none`. Other text (a colour name typed in a workflow) is
|
|
7
|
-
* kept and shown as it is until a pick replaces it. Sits on the kit Popover,
|
|
8
|
-
* so it follows the swatch on scroll and closes on Escape or a click
|
|
9
|
-
* outside. Works on the canvas (`size="sm"`) and in the manager.
|
|
10
|
-
*
|
|
11
|
-
* <ColorField v-model="labelColor" alpha allow-none size="sm" aria-label="Label band" />
|
|
12
|
-
*/
|
|
13
|
-
import { computed, ref, watch } from "vue";
|
|
14
|
-
import HsvPicker from "./HsvPicker.vue";
|
|
15
|
-
import Popover from "./Popover.vue";
|
|
16
|
-
import WpNumber from "./WpNumber.vue";
|
|
17
|
-
import WpButton from "./WpButton.vue";
|
|
18
|
-
import { rgbToHex } from "./hsv";
|
|
19
|
-
|
|
20
|
-
const props = withDefaults(defineProps<{
|
|
21
|
-
modelValue: string;
|
|
22
|
-
/** Offer an opacity number (writes `#rrggbbaa`). */
|
|
23
|
-
alpha?: boolean | undefined;
|
|
24
|
-
/** Offer "None" (writes `none`). */
|
|
25
|
-
allowNone?: boolean | undefined;
|
|
26
|
-
size?: "sm" | "md" | undefined;
|
|
27
|
-
ariaLabel?: string | undefined;
|
|
28
|
-
disabled?: boolean | undefined;
|
|
29
|
-
dataTest?: string | undefined;
|
|
30
|
-
}>(), { alpha: false, allowNone: false, size: "sm", ariaLabel: "Colour", disabled: false, dataTest: undefined });
|
|
31
|
-
|
|
32
|
-
const emit = defineEmits<{ "update:modelValue": [value: string] }>();
|
|
33
|
-
|
|
34
|
-
const HEX = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
35
|
-
|
|
36
|
-
/** `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` → `{ rgb: "#rrggbb", alpha: 0-255 }`. */
|
|
37
|
-
function parse(value: string): { rgb: string; alpha: number } | null {
|
|
38
|
-
const v = value.trim();
|
|
39
|
-
if (!HEX.test(v)) return null;
|
|
40
|
-
let h = v.slice(1).toLowerCase();
|
|
41
|
-
if (h.length <= 4) h = h.split("").map((c) => c + c).join("");
|
|
42
|
-
return { rgb: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6), 16) : 255 };
|
|
43
|
-
}
|
|
44
|
-
function compose(rgb: string, alpha: number): string {
|
|
45
|
-
const a = Math.max(0, Math.min(255, Math.round(alpha)));
|
|
46
|
-
return a >= 255 ? rgb : `${rgb}${a.toString(16).padStart(2, "0")}`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const open = ref(false);
|
|
50
|
-
const isNone = computed(() => props.modelValue.trim().toLowerCase() === "none");
|
|
51
|
-
const parsed = computed(() => parse(props.modelValue));
|
|
52
|
-
const BLACK = rgbToHex({ r: 0, g: 0, b: 0 });
|
|
53
|
-
const rgb = computed(() => parsed.value?.rgb ?? BLACK);
|
|
54
|
-
const alphaValue = computed(() => (parsed.value ? parsed.value.alpha : 255));
|
|
55
|
-
const opacity = computed(() => Math.round((alphaValue.value / 255) * 100));
|
|
56
|
-
|
|
57
|
-
const shown = computed(() => (isNone.value ? "none" : props.modelValue.trim() || "none"));
|
|
58
|
-
const swatch = computed(() => {
|
|
59
|
-
if (isNone.value) return "transparent";
|
|
60
|
-
const p = parsed.value;
|
|
61
|
-
if (!p) return props.modelValue;
|
|
62
|
-
return `rgba(${parseInt(p.rgb.slice(1, 3), 16)}, ${parseInt(p.rgb.slice(3, 5), 16)}, ${parseInt(p.rgb.slice(5, 7), 16)}, ${p.alpha / 255})`;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const draft = ref(props.modelValue);
|
|
66
|
-
watch(() => props.modelValue, (v) => { draft.value = v; });
|
|
67
|
-
watch(open, (v) => { if (v) draft.value = props.modelValue; });
|
|
68
|
-
|
|
69
|
-
function onHsv(hex: string): void {
|
|
70
|
-
emit("update:modelValue", compose(hex, props.alpha ? alphaValue.value : 255));
|
|
71
|
-
}
|
|
72
|
-
function onOpacity(pct: number | null): void {
|
|
73
|
-
if (pct === null) return;
|
|
74
|
-
emit("update:modelValue", compose(rgb.value, (pct / 100) * 255));
|
|
75
|
-
}
|
|
76
|
-
function onDraft(ev: Event): void {
|
|
77
|
-
const v = (ev.target as HTMLInputElement).value.trim();
|
|
78
|
-
draft.value = v;
|
|
79
|
-
const p = parse(v);
|
|
80
|
-
if (p) emit("update:modelValue", compose(p.rgb, props.alpha ? p.alpha : 255));
|
|
81
|
-
}
|
|
82
|
-
function pickNone(): void {
|
|
83
|
-
emit("update:modelValue", "none");
|
|
84
|
-
open.value = false;
|
|
85
|
-
}
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<template>
|
|
89
|
-
<Popover v-model:open="open" :label="ariaLabel">
|
|
90
|
-
<template #trigger="{ props: triggerProps }">
|
|
91
|
-
<button
|
|
92
|
-
v-bind="triggerProps"
|
|
93
|
-
type="button"
|
|
94
|
-
class="wp-color-field"
|
|
95
|
-
:class="[`wp-color-field--${size}`, { 'is-none': isNone }]"
|
|
96
|
-
:disabled="disabled"
|
|
97
|
-
:aria-label="`${ariaLabel}: ${shown}`"
|
|
98
|
-
:data-test="dataTest"
|
|
99
|
-
>
|
|
100
|
-
<span class="wp-color-field__chip" aria-hidden="true">
|
|
101
|
-
<span class="wp-color-field__fill" :style="{ background: swatch }" />
|
|
102
|
-
</span>
|
|
103
|
-
<span class="wp-color-field__value" aria-hidden="true">{{ shown }}</span>
|
|
104
|
-
</button>
|
|
105
|
-
</template>
|
|
106
|
-
<div class="wp-color-field__panel" @keydown.stop>
|
|
107
|
-
<HsvPicker :model-value="rgb" :aria-label="ariaLabel" @update:model-value="onHsv" />
|
|
108
|
-
<div class="wp-color-field__row">
|
|
109
|
-
<input
|
|
110
|
-
class="wp-color-field__hex"
|
|
111
|
-
:value="draft"
|
|
112
|
-
:aria-label="`${ariaLabel} hex`"
|
|
113
|
-
spellcheck="false"
|
|
114
|
-
:data-test="dataTest ? `${dataTest}-hex` : undefined"
|
|
115
|
-
@change="onDraft"
|
|
116
|
-
@keydown.enter="onDraft"
|
|
117
|
-
>
|
|
118
|
-
<WpNumber
|
|
119
|
-
v-if="alpha"
|
|
120
|
-
class="wp-color-field__alpha"
|
|
121
|
-
:model-value="isNone ? 0 : opacity"
|
|
122
|
-
:min="0"
|
|
123
|
-
:max="100"
|
|
124
|
-
suffix="%"
|
|
125
|
-
size="sm"
|
|
126
|
-
:aria-label="`${ariaLabel} opacity`"
|
|
127
|
-
:data-test="dataTest ? `${dataTest}-alpha` : undefined"
|
|
128
|
-
@update:model-value="onOpacity"
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
<WpButton
|
|
132
|
-
v-if="allowNone"
|
|
133
|
-
size="sm"
|
|
134
|
-
variant="ghost"
|
|
135
|
-
icon="pi-ban"
|
|
136
|
-
:pressed="isNone"
|
|
137
|
-
:data-test="dataTest ? `${dataTest}-none` : undefined"
|
|
138
|
-
@click="pickNone"
|
|
139
|
-
>None</WpButton>
|
|
140
|
-
</div>
|
|
141
|
-
</Popover>
|
|
142
|
-
</template>
|
|
143
|
-
|
|
144
|
-
<style scoped>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
.wp-color-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
padding: 0;
|
|
190
|
-
}
|
|
191
|
-
.wp-color-field__row { display: flex; gap: 6px; align-items: center; }
|
|
192
|
-
.wp-color-field__hex {
|
|
193
|
-
flex: 1;
|
|
194
|
-
min-width: 0;
|
|
195
|
-
height: var(--wp-control-h-sm, 24px);
|
|
196
|
-
padding: 0 6px;
|
|
197
|
-
background: var(--wp-bg-1);
|
|
198
|
-
color: var(--wp-text);
|
|
199
|
-
border: 1px solid var(--wp-border);
|
|
200
|
-
border-radius: min(4px, var(--wp-radius-cap, 999px));
|
|
201
|
-
font: 11px var(--wp-font-mono, monospace);
|
|
202
|
-
outline: none;
|
|
203
|
-
}
|
|
204
|
-
.wp-color-field__hex:focus { border-color: var(--wp-border-focus); }
|
|
205
|
-
.wp-color-field__alpha { width: 72px; flex: none; }
|
|
206
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A colour swatch that opens a picker: the colour square, a hex box, and
|
|
4
|
+
* (with `alpha`) an opacity number, or (with `allowNone`) a "None" choice.
|
|
5
|
+
* The value is a hex string, `#rrggbb` or `#rrggbbaa` once it is
|
|
6
|
+
* see-through, or `none`. Other text (a colour name typed in a workflow) is
|
|
7
|
+
* kept and shown as it is until a pick replaces it. Sits on the kit Popover,
|
|
8
|
+
* so it follows the swatch on scroll and closes on Escape or a click
|
|
9
|
+
* outside. Works on the canvas (`size="sm"`) and in the manager.
|
|
10
|
+
*
|
|
11
|
+
* <ColorField v-model="labelColor" alpha allow-none size="sm" aria-label="Label band" />
|
|
12
|
+
*/
|
|
13
|
+
import { computed, ref, watch } from "vue";
|
|
14
|
+
import HsvPicker from "./HsvPicker.vue";
|
|
15
|
+
import Popover from "./Popover.vue";
|
|
16
|
+
import WpNumber from "./WpNumber.vue";
|
|
17
|
+
import WpButton from "./WpButton.vue";
|
|
18
|
+
import { rgbToHex } from "./hsv";
|
|
19
|
+
|
|
20
|
+
const props = withDefaults(defineProps<{
|
|
21
|
+
modelValue: string;
|
|
22
|
+
/** Offer an opacity number (writes `#rrggbbaa`). */
|
|
23
|
+
alpha?: boolean | undefined;
|
|
24
|
+
/** Offer "None" (writes `none`). */
|
|
25
|
+
allowNone?: boolean | undefined;
|
|
26
|
+
size?: "sm" | "md" | undefined;
|
|
27
|
+
ariaLabel?: string | undefined;
|
|
28
|
+
disabled?: boolean | undefined;
|
|
29
|
+
dataTest?: string | undefined;
|
|
30
|
+
}>(), { alpha: false, allowNone: false, size: "sm", ariaLabel: "Colour", disabled: false, dataTest: undefined });
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits<{ "update:modelValue": [value: string] }>();
|
|
33
|
+
|
|
34
|
+
const HEX = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
35
|
+
|
|
36
|
+
/** `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` → `{ rgb: "#rrggbb", alpha: 0-255 }`. */
|
|
37
|
+
function parse(value: string): { rgb: string; alpha: number } | null {
|
|
38
|
+
const v = value.trim();
|
|
39
|
+
if (!HEX.test(v)) return null;
|
|
40
|
+
let h = v.slice(1).toLowerCase();
|
|
41
|
+
if (h.length <= 4) h = h.split("").map((c) => c + c).join("");
|
|
42
|
+
return { rgb: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6), 16) : 255 };
|
|
43
|
+
}
|
|
44
|
+
function compose(rgb: string, alpha: number): string {
|
|
45
|
+
const a = Math.max(0, Math.min(255, Math.round(alpha)));
|
|
46
|
+
return a >= 255 ? rgb : `${rgb}${a.toString(16).padStart(2, "0")}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const open = ref(false);
|
|
50
|
+
const isNone = computed(() => props.modelValue.trim().toLowerCase() === "none");
|
|
51
|
+
const parsed = computed(() => parse(props.modelValue));
|
|
52
|
+
const BLACK = rgbToHex({ r: 0, g: 0, b: 0 });
|
|
53
|
+
const rgb = computed(() => parsed.value?.rgb ?? BLACK);
|
|
54
|
+
const alphaValue = computed(() => (parsed.value ? parsed.value.alpha : 255));
|
|
55
|
+
const opacity = computed(() => Math.round((alphaValue.value / 255) * 100));
|
|
56
|
+
|
|
57
|
+
const shown = computed(() => (isNone.value ? "none" : props.modelValue.trim() || "none"));
|
|
58
|
+
const swatch = computed(() => {
|
|
59
|
+
if (isNone.value) return "transparent";
|
|
60
|
+
const p = parsed.value;
|
|
61
|
+
if (!p) return props.modelValue;
|
|
62
|
+
return `rgba(${parseInt(p.rgb.slice(1, 3), 16)}, ${parseInt(p.rgb.slice(3, 5), 16)}, ${parseInt(p.rgb.slice(5, 7), 16)}, ${p.alpha / 255})`;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const draft = ref(props.modelValue);
|
|
66
|
+
watch(() => props.modelValue, (v) => { draft.value = v; });
|
|
67
|
+
watch(open, (v) => { if (v) draft.value = props.modelValue; });
|
|
68
|
+
|
|
69
|
+
function onHsv(hex: string): void {
|
|
70
|
+
emit("update:modelValue", compose(hex, props.alpha ? alphaValue.value : 255));
|
|
71
|
+
}
|
|
72
|
+
function onOpacity(pct: number | null): void {
|
|
73
|
+
if (pct === null) return;
|
|
74
|
+
emit("update:modelValue", compose(rgb.value, (pct / 100) * 255));
|
|
75
|
+
}
|
|
76
|
+
function onDraft(ev: Event): void {
|
|
77
|
+
const v = (ev.target as HTMLInputElement).value.trim();
|
|
78
|
+
draft.value = v;
|
|
79
|
+
const p = parse(v);
|
|
80
|
+
if (p) emit("update:modelValue", compose(p.rgb, props.alpha ? p.alpha : 255));
|
|
81
|
+
}
|
|
82
|
+
function pickNone(): void {
|
|
83
|
+
emit("update:modelValue", "none");
|
|
84
|
+
open.value = false;
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<Popover v-model:open="open" :label="ariaLabel">
|
|
90
|
+
<template #trigger="{ props: triggerProps }">
|
|
91
|
+
<button
|
|
92
|
+
v-bind="triggerProps"
|
|
93
|
+
type="button"
|
|
94
|
+
class="wp-color-field wp-field-box"
|
|
95
|
+
:class="[`wp-color-field--${size}`, `wp-field-box--${size}`, { 'is-none': isNone }]"
|
|
96
|
+
:disabled="disabled"
|
|
97
|
+
:aria-label="`${ariaLabel}: ${shown}`"
|
|
98
|
+
:data-test="dataTest"
|
|
99
|
+
>
|
|
100
|
+
<span class="wp-color-field__chip" aria-hidden="true">
|
|
101
|
+
<span class="wp-color-field__fill" :style="{ background: swatch }" />
|
|
102
|
+
</span>
|
|
103
|
+
<span class="wp-color-field__value" aria-hidden="true">{{ shown }}</span>
|
|
104
|
+
</button>
|
|
105
|
+
</template>
|
|
106
|
+
<div class="wp-color-field__panel" @keydown.stop>
|
|
107
|
+
<HsvPicker :model-value="rgb" :aria-label="ariaLabel" @update:model-value="onHsv" />
|
|
108
|
+
<div class="wp-color-field__row">
|
|
109
|
+
<input
|
|
110
|
+
class="wp-color-field__hex wp-field-box wp-field-box--sm"
|
|
111
|
+
:value="draft"
|
|
112
|
+
:aria-label="`${ariaLabel} hex`"
|
|
113
|
+
spellcheck="false"
|
|
114
|
+
:data-test="dataTest ? `${dataTest}-hex` : undefined"
|
|
115
|
+
@change="onDraft"
|
|
116
|
+
@keydown.enter="onDraft"
|
|
117
|
+
>
|
|
118
|
+
<WpNumber
|
|
119
|
+
v-if="alpha"
|
|
120
|
+
class="wp-color-field__alpha"
|
|
121
|
+
:model-value="isNone ? 0 : opacity"
|
|
122
|
+
:min="0"
|
|
123
|
+
:max="100"
|
|
124
|
+
suffix="%"
|
|
125
|
+
size="sm"
|
|
126
|
+
:aria-label="`${ariaLabel} opacity`"
|
|
127
|
+
:data-test="dataTest ? `${dataTest}-alpha` : undefined"
|
|
128
|
+
@update:model-value="onOpacity"
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
<WpButton
|
|
132
|
+
v-if="allowNone"
|
|
133
|
+
size="sm"
|
|
134
|
+
variant="ghost"
|
|
135
|
+
icon="pi-ban"
|
|
136
|
+
:pressed="isNone"
|
|
137
|
+
:data-test="dataTest ? `${dataTest}-none` : undefined"
|
|
138
|
+
@click="pickNone"
|
|
139
|
+
>None</WpButton>
|
|
140
|
+
</div>
|
|
141
|
+
</Popover>
|
|
142
|
+
</template>
|
|
143
|
+
|
|
144
|
+
<style scoped src="./field.css"></style>
|
|
145
|
+
|
|
146
|
+
<style scoped>
|
|
147
|
+
.wp-color-field {
|
|
148
|
+
display: inline-flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 6px;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
height: var(--wp-field-h);
|
|
153
|
+
padding: 0 8px 0 3px;
|
|
154
|
+
font-family: var(--wp-font-mono, monospace);
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
}
|
|
157
|
+
.wp-color-field__chip {
|
|
158
|
+
position: relative;
|
|
159
|
+
flex: none;
|
|
160
|
+
width: 16px;
|
|
161
|
+
height: 16px;
|
|
162
|
+
overflow: hidden;
|
|
163
|
+
border: 1px solid var(--wp-border-strong);
|
|
164
|
+
border-radius: min(3px, var(--wp-radius-cap, 999px));
|
|
165
|
+
/* Checks show through a see-through colour. */
|
|
166
|
+
background: repeating-conic-gradient(var(--wp-bg-4) 0 25%, var(--wp-bg-1) 0 50%) 0 0 / 8px 8px;
|
|
167
|
+
}
|
|
168
|
+
.wp-color-field__fill { position: absolute; inset: 0; }
|
|
169
|
+
.wp-color-field.is-none .wp-color-field__chip::after {
|
|
170
|
+
content: "";
|
|
171
|
+
position: absolute;
|
|
172
|
+
inset: 0;
|
|
173
|
+
background: linear-gradient(to top right, transparent calc(50% - 1px), var(--wp-danger) 50%, transparent calc(50% + 1px));
|
|
174
|
+
}
|
|
175
|
+
.wp-color-field__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
176
|
+
.wp-color-field.is-none .wp-color-field__value { color: var(--wp-text-dim); font-family: var(--wp-font-sans, sans-serif); }
|
|
177
|
+
|
|
178
|
+
.wp-color-field__panel {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
gap: 8px;
|
|
182
|
+
width: 200px;
|
|
183
|
+
padding: 0;
|
|
184
|
+
}
|
|
185
|
+
.wp-color-field__row { display: flex; gap: 6px; align-items: center; }
|
|
186
|
+
.wp-color-field__hex { flex: 1; min-width: 0; height: var(--wp-field-h); padding: 0 6px; font-family: var(--wp-font-mono, monospace); }
|
|
187
|
+
.wp-color-field__alpha { width: 72px; flex: none; }
|
|
188
|
+
</style>
|