@vadem/ui 0.0.0-stage → 0.0.1
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/LICENSE-lucide.txt +43 -0
- package/README.md +19 -2
- package/fesm2022/vadem-ui-accordion.mjs +139 -0
- package/fesm2022/vadem-ui-accordion.mjs.map +1 -0
- package/fesm2022/vadem-ui-active-filters.mjs +355 -0
- package/fesm2022/vadem-ui-active-filters.mjs.map +1 -0
- package/fesm2022/vadem-ui-alert-dialog.mjs +433 -0
- package/fesm2022/vadem-ui-alert-dialog.mjs.map +1 -0
- package/fesm2022/vadem-ui-alert.mjs +266 -0
- package/fesm2022/vadem-ui-alert.mjs.map +1 -0
- package/fesm2022/vadem-ui-autocomplete.mjs +715 -0
- package/fesm2022/vadem-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/vadem-ui-avatar.mjs +219 -0
- package/fesm2022/vadem-ui-avatar.mjs.map +1 -0
- package/fesm2022/vadem-ui-badge.mjs +86 -0
- package/fesm2022/vadem-ui-badge.mjs.map +1 -0
- package/fesm2022/vadem-ui-breadcrumbs.mjs +61 -0
- package/fesm2022/vadem-ui-breadcrumbs.mjs.map +1 -0
- package/fesm2022/vadem-ui-button.mjs +220 -0
- package/fesm2022/vadem-ui-button.mjs.map +1 -0
- package/fesm2022/vadem-ui-calendar.mjs +1314 -0
- package/fesm2022/vadem-ui-calendar.mjs.map +1 -0
- package/fesm2022/vadem-ui-card.mjs +271 -0
- package/fesm2022/vadem-ui-card.mjs.map +1 -0
- package/fesm2022/vadem-ui-character-count.mjs +269 -0
- package/fesm2022/vadem-ui-character-count.mjs.map +1 -0
- package/fesm2022/vadem-ui-chart.mjs +1984 -0
- package/fesm2022/vadem-ui-chart.mjs.map +1 -0
- package/fesm2022/vadem-ui-checkbox.mjs +67 -0
- package/fesm2022/vadem-ui-checkbox.mjs.map +1 -0
- package/fesm2022/vadem-ui-color-picker.mjs +815 -0
- package/fesm2022/vadem-ui-color-picker.mjs.map +1 -0
- package/fesm2022/vadem-ui-command.mjs +735 -0
- package/fesm2022/vadem-ui-command.mjs.map +1 -0
- package/fesm2022/vadem-ui-copy-button.mjs +375 -0
- package/fesm2022/vadem-ui-copy-button.mjs.map +1 -0
- package/fesm2022/vadem-ui-date-range-picker.mjs +1011 -0
- package/fesm2022/vadem-ui-date-range-picker.mjs.map +1 -0
- package/fesm2022/vadem-ui-description-list.mjs +59 -0
- package/fesm2022/vadem-ui-description-list.mjs.map +1 -0
- package/fesm2022/vadem-ui-dialog.mjs +587 -0
- package/fesm2022/vadem-ui-dialog.mjs.map +1 -0
- package/fesm2022/vadem-ui-dropzone.mjs +176 -0
- package/fesm2022/vadem-ui-dropzone.mjs.map +1 -0
- package/fesm2022/vadem-ui-editable-text.mjs +641 -0
- package/fesm2022/vadem-ui-editable-text.mjs.map +1 -0
- package/fesm2022/vadem-ui-empty-state.mjs +175 -0
- package/fesm2022/vadem-ui-empty-state.mjs.map +1 -0
- package/fesm2022/vadem-ui-expandable-text.mjs +244 -0
- package/fesm2022/vadem-ui-expandable-text.mjs.map +1 -0
- package/fesm2022/vadem-ui-field.mjs +583 -0
- package/fesm2022/vadem-ui-field.mjs.map +1 -0
- package/fesm2022/vadem-ui-file-preview.mjs +532 -0
- package/fesm2022/vadem-ui-file-preview.mjs.map +1 -0
- package/fesm2022/vadem-ui-file-size.mjs +83 -0
- package/fesm2022/vadem-ui-file-size.mjs.map +1 -0
- package/fesm2022/vadem-ui-form-error-summary.mjs +201 -0
- package/fesm2022/vadem-ui-form-error-summary.mjs.map +1 -0
- package/fesm2022/vadem-ui-icon.mjs +303 -0
- package/fesm2022/vadem-ui-icon.mjs.map +1 -0
- package/fesm2022/vadem-ui-input.mjs +120 -0
- package/fesm2022/vadem-ui-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-kbd.mjs +286 -0
- package/fesm2022/vadem-ui-kbd.mjs.map +1 -0
- package/fesm2022/vadem-ui-keyboard.mjs +105 -0
- package/fesm2022/vadem-ui-keyboard.mjs.map +1 -0
- package/fesm2022/vadem-ui-locale.mjs +443 -0
- package/fesm2022/vadem-ui-locale.mjs.map +1 -0
- package/fesm2022/vadem-ui-menu.mjs +637 -0
- package/fesm2022/vadem-ui-menu.mjs.map +1 -0
- package/fesm2022/vadem-ui-navigation-list.mjs +130 -0
- package/fesm2022/vadem-ui-navigation-list.mjs.map +1 -0
- package/fesm2022/vadem-ui-number-input.mjs +264 -0
- package/fesm2022/vadem-ui-number-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-otp-input.mjs +86 -0
- package/fesm2022/vadem-ui-otp-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-pagination.mjs +353 -0
- package/fesm2022/vadem-ui-pagination.mjs.map +1 -0
- package/fesm2022/vadem-ui-password-input.mjs +213 -0
- package/fesm2022/vadem-ui-password-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-popover.mjs +178 -0
- package/fesm2022/vadem-ui-popover.mjs.map +1 -0
- package/fesm2022/vadem-ui-progress.mjs +331 -0
- package/fesm2022/vadem-ui-progress.mjs.map +1 -0
- package/fesm2022/vadem-ui-radio.mjs +39 -0
- package/fesm2022/vadem-ui-radio.mjs.map +1 -0
- package/fesm2022/vadem-ui-range-slider.mjs +561 -0
- package/fesm2022/vadem-ui-range-slider.mjs.map +1 -0
- package/fesm2022/vadem-ui-rating.mjs +404 -0
- package/fesm2022/vadem-ui-rating.mjs.map +1 -0
- package/fesm2022/vadem-ui-relative-time.mjs +217 -0
- package/fesm2022/vadem-ui-relative-time.mjs.map +1 -0
- package/fesm2022/vadem-ui-reorder-list.mjs +601 -0
- package/fesm2022/vadem-ui-reorder-list.mjs.map +1 -0
- package/fesm2022/vadem-ui-scroll-area.mjs +65 -0
- package/fesm2022/vadem-ui-scroll-area.mjs.map +1 -0
- package/fesm2022/vadem-ui-search-input.mjs +307 -0
- package/fesm2022/vadem-ui-search-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-segmented.mjs +297 -0
- package/fesm2022/vadem-ui-segmented.mjs.map +1 -0
- package/fesm2022/vadem-ui-select.mjs +1462 -0
- package/fesm2022/vadem-ui-select.mjs.map +1 -0
- package/fesm2022/vadem-ui-sidebar.mjs +493 -0
- package/fesm2022/vadem-ui-sidebar.mjs.map +1 -0
- package/fesm2022/vadem-ui-skeleton.mjs +106 -0
- package/fesm2022/vadem-ui-skeleton.mjs.map +1 -0
- package/fesm2022/vadem-ui-slider.mjs +60 -0
- package/fesm2022/vadem-ui-slider.mjs.map +1 -0
- package/fesm2022/vadem-ui-splitter.mjs +438 -0
- package/fesm2022/vadem-ui-splitter.mjs.map +1 -0
- package/fesm2022/vadem-ui-stat.mjs +369 -0
- package/fesm2022/vadem-ui-stat.mjs.map +1 -0
- package/fesm2022/vadem-ui-stepper.mjs +483 -0
- package/fesm2022/vadem-ui-stepper.mjs.map +1 -0
- package/fesm2022/vadem-ui-switch.mjs +45 -0
- package/fesm2022/vadem-ui-switch.mjs.map +1 -0
- package/fesm2022/vadem-ui-table.mjs +593 -0
- package/fesm2022/vadem-ui-table.mjs.map +1 -0
- package/fesm2022/vadem-ui-tabs.mjs +405 -0
- package/fesm2022/vadem-ui-tabs.mjs.map +1 -0
- package/fesm2022/vadem-ui-tag-input.mjs +685 -0
- package/fesm2022/vadem-ui-tag-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-text-highlight.mjs +126 -0
- package/fesm2022/vadem-ui-text-highlight.mjs.map +1 -0
- package/fesm2022/vadem-ui-time-input.mjs +430 -0
- package/fesm2022/vadem-ui-time-input.mjs.map +1 -0
- package/fesm2022/vadem-ui-timeline.mjs +313 -0
- package/fesm2022/vadem-ui-timeline.mjs.map +1 -0
- package/fesm2022/vadem-ui-toast.mjs +397 -0
- package/fesm2022/vadem-ui-toast.mjs.map +1 -0
- package/fesm2022/vadem-ui-toolbar.mjs +396 -0
- package/fesm2022/vadem-ui-toolbar.mjs.map +1 -0
- package/fesm2022/vadem-ui-tooltip.mjs +218 -0
- package/fesm2022/vadem-ui-tooltip.mjs.map +1 -0
- package/fesm2022/vadem-ui-tree.mjs +551 -0
- package/fesm2022/vadem-ui-tree.mjs.map +1 -0
- package/fesm2022/vadem-ui-upload-list.mjs +408 -0
- package/fesm2022/vadem-ui-upload-list.mjs.map +1 -0
- package/fesm2022/vadem-ui.mjs +4 -0
- package/fesm2022/vadem-ui.mjs.map +1 -0
- package/fonts/jetbrains-mono/OFL.txt +93 -0
- package/fonts/jetbrains-mono/jetbrains-mono-cyrillic.woff2 +0 -0
- package/fonts/jetbrains-mono/jetbrains-mono-latin.woff2 +0 -0
- package/fonts/manrope/OFL.txt +93 -0
- package/fonts/manrope/manrope-cyrillic.woff2 +0 -0
- package/fonts/manrope/manrope-latin.woff2 +0 -0
- package/package.json +306 -3
- package/styles/base.css +160 -0
- package/styles/components/accordion.css +130 -0
- package/styles/components/active-filters.css +42 -0
- package/styles/components/alert-dialog.css +34 -0
- package/styles/components/alert.css +159 -0
- package/styles/components/autocomplete.css +97 -0
- package/styles/components/avatar.css +90 -0
- package/styles/components/badge.css +91 -0
- package/styles/components/breadcrumbs.css +94 -0
- package/styles/components/button.css +174 -0
- package/styles/components/calendar.css +186 -0
- package/styles/components/card.css +206 -0
- package/styles/components/character-count.css +41 -0
- package/styles/components/chart.css +308 -0
- package/styles/components/checkbox.css +115 -0
- package/styles/components/color-picker.css +158 -0
- package/styles/components/command.css +175 -0
- package/styles/components/copy-button.css +58 -0
- package/styles/components/date-range-picker.css +153 -0
- package/styles/components/description-list.css +69 -0
- package/styles/components/dialog.css +334 -0
- package/styles/components/dropzone.css +89 -0
- package/styles/components/editable-text.css +58 -0
- package/styles/components/empty-state.css +72 -0
- package/styles/components/expandable-text.css +24 -0
- package/styles/components/field.css +148 -0
- package/styles/components/file-preview.css +65 -0
- package/styles/components/form-error-summary.css +71 -0
- package/styles/components/icon.css +38 -0
- package/styles/components/index.css +80 -0
- package/styles/components/input.css +171 -0
- package/styles/components/kbd.css +42 -0
- package/styles/components/menu.css +168 -0
- package/styles/components/multi-select.css +156 -0
- package/styles/components/navigation-list.css +147 -0
- package/styles/components/number-input.css +33 -0
- package/styles/components/otp-input.css +26 -0
- package/styles/components/pagination.css +127 -0
- package/styles/components/password-input.css +20 -0
- package/styles/components/popover.css +93 -0
- package/styles/components/progress-ring.css +112 -0
- package/styles/components/progress.css +162 -0
- package/styles/components/radio.css +117 -0
- package/styles/components/range-slider.css +158 -0
- package/styles/components/rating.css +100 -0
- package/styles/components/reorder-list.css +143 -0
- package/styles/components/scroll-area.css +39 -0
- package/styles/components/search-input.css +25 -0
- package/styles/components/segmented.css +136 -0
- package/styles/components/select.css +257 -0
- package/styles/components/sidebar.css +105 -0
- package/styles/components/skeleton.css +83 -0
- package/styles/components/slider.css +132 -0
- package/styles/components/splitter.css +83 -0
- package/styles/components/stat.css +62 -0
- package/styles/components/stepper.css +236 -0
- package/styles/components/switch.css +107 -0
- package/styles/components/table.css +195 -0
- package/styles/components/tabs.css +198 -0
- package/styles/components/tag-input.css +138 -0
- package/styles/components/text-highlight.css +22 -0
- package/styles/components/time-input.css +96 -0
- package/styles/components/timeline.css +182 -0
- package/styles/components/toast.css +146 -0
- package/styles/components/toolbar.css +72 -0
- package/styles/components/tooltip.css +93 -0
- package/styles/components/tree.css +88 -0
- package/styles/components/upload-list.css +113 -0
- package/styles/fonts.css +67 -0
- package/styles/index.css +14 -0
- package/styles/reset.css +57 -0
- package/styles/tokens/primitives.css +364 -0
- package/styles/tokens/semantic.css +233 -0
- package/types/vadem-ui-accordion.d.ts +43 -0
- package/types/vadem-ui-active-filters.d.ts +73 -0
- package/types/vadem-ui-alert-dialog.d.ts +87 -0
- package/types/vadem-ui-alert.d.ts +64 -0
- package/types/vadem-ui-autocomplete.d.ts +156 -0
- package/types/vadem-ui-avatar.d.ts +59 -0
- package/types/vadem-ui-badge.d.ts +25 -0
- package/types/vadem-ui-breadcrumbs.d.ts +22 -0
- package/types/vadem-ui-button.d.ts +52 -0
- package/types/vadem-ui-calendar.d.ts +327 -0
- package/types/vadem-ui-card.d.ts +58 -0
- package/types/vadem-ui-character-count.d.ts +71 -0
- package/types/vadem-ui-chart.d.ts +452 -0
- package/types/vadem-ui-checkbox.d.ts +20 -0
- package/types/vadem-ui-color-picker.d.ts +171 -0
- package/types/vadem-ui-command.d.ts +145 -0
- package/types/vadem-ui-copy-button.d.ts +90 -0
- package/types/vadem-ui-date-range-picker.d.ts +216 -0
- package/types/vadem-ui-description-list.d.ts +15 -0
- package/types/vadem-ui-dialog.d.ts +174 -0
- package/types/vadem-ui-dropzone.d.ts +73 -0
- package/types/vadem-ui-editable-text.d.ts +141 -0
- package/types/vadem-ui-empty-state.d.ts +34 -0
- package/types/vadem-ui-expandable-text.d.ts +52 -0
- package/types/vadem-ui-field.d.ts +180 -0
- package/types/vadem-ui-file-preview.d.ts +108 -0
- package/types/vadem-ui-file-size.d.ts +18 -0
- package/types/vadem-ui-form-error-summary.d.ts +46 -0
- package/types/vadem-ui-icon.d.ts +152 -0
- package/types/vadem-ui-input.d.ts +31 -0
- package/types/vadem-ui-kbd.d.ts +66 -0
- package/types/vadem-ui-keyboard.d.ts +61 -0
- package/types/vadem-ui-locale.d.ts +241 -0
- package/types/vadem-ui-menu.d.ts +132 -0
- package/types/vadem-ui-navigation-list.d.ts +28 -0
- package/types/vadem-ui-number-input.d.ts +39 -0
- package/types/vadem-ui-otp-input.d.ts +15 -0
- package/types/vadem-ui-pagination.d.ts +96 -0
- package/types/vadem-ui-password-input.d.ts +36 -0
- package/types/vadem-ui-popover.d.ts +48 -0
- package/types/vadem-ui-progress.d.ts +95 -0
- package/types/vadem-ui-radio.d.ts +11 -0
- package/types/vadem-ui-range-slider.d.ts +136 -0
- package/types/vadem-ui-rating.d.ts +95 -0
- package/types/vadem-ui-relative-time.d.ts +58 -0
- package/types/vadem-ui-reorder-list.d.ts +120 -0
- package/types/vadem-ui-scroll-area.d.ts +13 -0
- package/types/vadem-ui-search-input.d.ts +58 -0
- package/types/vadem-ui-segmented.d.ts +76 -0
- package/types/vadem-ui-select.d.ts +303 -0
- package/types/vadem-ui-sidebar.d.ts +70 -0
- package/types/vadem-ui-skeleton.d.ts +28 -0
- package/types/vadem-ui-slider.d.ts +17 -0
- package/types/vadem-ui-splitter.d.ts +99 -0
- package/types/vadem-ui-stat.d.ts +101 -0
- package/types/vadem-ui-stepper.d.ts +108 -0
- package/types/vadem-ui-switch.d.ts +10 -0
- package/types/vadem-ui-table.d.ts +172 -0
- package/types/vadem-ui-tabs.d.ts +101 -0
- package/types/vadem-ui-tag-input.d.ts +170 -0
- package/types/vadem-ui-text-highlight.d.ts +27 -0
- package/types/vadem-ui-time-input.d.ts +47 -0
- package/types/vadem-ui-timeline.d.ts +54 -0
- package/types/vadem-ui-toast.d.ts +104 -0
- package/types/vadem-ui-toolbar.d.ts +80 -0
- package/types/vadem-ui-tooltip.d.ts +71 -0
- package/types/vadem-ui-tree.d.ts +123 -0
- package/types/vadem-ui-upload-list.d.ts +70 -0
- package/types/vadem-ui.d.ts +1 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, afterRenderEffect, booleanAttribute, computed, inject, input, model, output, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { NgControl } from "@angular/forms";
|
|
4
|
+
import { FormField } from "@angular/forms/signals";
|
|
5
|
+
import { VD_FIELD, vdNgControlState, vdUniqueId } from "@vadem/ui/field";
|
|
6
|
+
import { VdIcon } from "@vadem/ui/icon";
|
|
7
|
+
import { VdPopover } from "@vadem/ui/popover";
|
|
8
|
+
import { VdButton } from "@vadem/ui/button";
|
|
9
|
+
import { vdTexts } from "@vadem/ui/locale";
|
|
10
|
+
function vdNormalizeHex(value) {
|
|
11
|
+
if (typeof value !== "string") return null;
|
|
12
|
+
const raw = value.trim().replace(/^#/, "");
|
|
13
|
+
if (!/^(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(raw)) return null;
|
|
14
|
+
return "#" + (raw.length === 3 ? [...raw].map((char) => char + char).join("") : raw).toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
function vdColorInk(value) {
|
|
17
|
+
const hex = vdNormalizeHex(value);
|
|
18
|
+
if (!hex) return "#000000";
|
|
19
|
+
const luminance = [
|
|
20
|
+
1,
|
|
21
|
+
3,
|
|
22
|
+
5
|
|
23
|
+
].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4).reduce((sum, c, i) => sum + c * [
|
|
24
|
+
.2126,
|
|
25
|
+
.7152,
|
|
26
|
+
.0722
|
|
27
|
+
][i], 0);
|
|
28
|
+
return (luminance + .05) / .05 >= 1.05 / (luminance + .05) ? "#000000" : "#FFFFFF";
|
|
29
|
+
}
|
|
30
|
+
function vdColorPaletteKey(index, count, key, rtl) {
|
|
31
|
+
if (!count) return null;
|
|
32
|
+
if (key === "Home") return 0;
|
|
33
|
+
if (key === "End") return count - 1;
|
|
34
|
+
const delta = key === "ArrowDown" ? 1 : key === "ArrowUp" ? -1 : key === "ArrowRight" ? rtl ? -1 : 1 : key === "ArrowLeft" ? rtl ? 1 : -1 : 0;
|
|
35
|
+
return delta ? (index + delta + count) % count : null;
|
|
36
|
+
}
|
|
37
|
+
var VdColorPicker = class VdColorPicker {
|
|
38
|
+
value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
39
|
+
swatches = input([], ...ngDevMode ? [{ debugName: "swatches" }] : /* istanbul ignore next */ []);
|
|
40
|
+
size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
41
|
+
disabled = input(false, {
|
|
42
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
43
|
+
transform: booleanAttribute
|
|
44
|
+
});
|
|
45
|
+
readonly = input(false, {
|
|
46
|
+
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
47
|
+
transform: booleanAttribute
|
|
48
|
+
});
|
|
49
|
+
invalid = input(false, {
|
|
50
|
+
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
51
|
+
transform: booleanAttribute
|
|
52
|
+
});
|
|
53
|
+
touched = input(false, {
|
|
54
|
+
...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
|
|
55
|
+
transform: booleanAttribute
|
|
56
|
+
});
|
|
57
|
+
required = input(false, {
|
|
58
|
+
...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
|
|
59
|
+
transform: booleanAttribute
|
|
60
|
+
});
|
|
61
|
+
ariaLabel = input(void 0, {
|
|
62
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
63
|
+
alias: "aria-label"
|
|
64
|
+
});
|
|
65
|
+
ariaLabelledby = input(void 0, {
|
|
66
|
+
...ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {},
|
|
67
|
+
alias: "aria-labelledby"
|
|
68
|
+
});
|
|
69
|
+
placeholder = input(...ngDevMode ? [void 0, { debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
70
|
+
pickerLabel = input(...ngDevMode ? [void 0, { debugName: "pickerLabel" }] : /* istanbul ignore next */ []);
|
|
71
|
+
hexLabel = input(...ngDevMode ? [void 0, { debugName: "hexLabel" }] : /* istanbul ignore next */ []);
|
|
72
|
+
paletteLabel = input(...ngDevMode ? [void 0, { debugName: "paletteLabel" }] : /* istanbul ignore next */ []);
|
|
73
|
+
applyLabel = input(...ngDevMode ? [void 0, { debugName: "applyLabel" }] : /* istanbul ignore next */ []);
|
|
74
|
+
errorLabel = input(...ngDevMode ? [void 0, { debugName: "errorLabel" }] : /* istanbul ignore next */ []);
|
|
75
|
+
t = vdTexts("colorPicker", {
|
|
76
|
+
placeholder: this.placeholder,
|
|
77
|
+
pickerLabel: this.pickerLabel,
|
|
78
|
+
hexLabel: this.hexLabel,
|
|
79
|
+
paletteLabel: this.paletteLabel,
|
|
80
|
+
applyLabel: this.applyLabel,
|
|
81
|
+
errorLabel: this.errorLabel
|
|
82
|
+
});
|
|
83
|
+
touch = output();
|
|
84
|
+
controlId = vdUniqueId("vd-color-picker");
|
|
85
|
+
hexId = `${this.controlId}-hex`;
|
|
86
|
+
errorId = `${this.controlId}-error`;
|
|
87
|
+
color = computed(() => vdNormalizeHex(this.value()), ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
|
|
88
|
+
draft = signal("", ...ngDevMode ? [{ debugName: "draft" }] : /* istanbul ignore next */ []);
|
|
89
|
+
draftColor = computed(() => vdNormalizeHex(this.draft()), ...ngDevMode ? [{ debugName: "draftColor" }] : /* istanbul ignore next */ []);
|
|
90
|
+
draftError = signal(false, ...ngDevMode ? [{ debugName: "draftError" }] : /* istanbul ignore next */ []);
|
|
91
|
+
open = signal(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
92
|
+
ink = vdColorInk;
|
|
93
|
+
palette = computed(() => {
|
|
94
|
+
const seen = /* @__PURE__ */ new Set();
|
|
95
|
+
return this.swatches().flatMap((swatch) => {
|
|
96
|
+
const value = vdNormalizeHex(swatch.value);
|
|
97
|
+
if (!value || seen.has(value)) return [];
|
|
98
|
+
seen.add(value);
|
|
99
|
+
return [{
|
|
100
|
+
value,
|
|
101
|
+
label: swatch.label.trim() || value
|
|
102
|
+
}];
|
|
103
|
+
});
|
|
104
|
+
}, ...ngDevMode ? [{ debugName: "palette" }] : /* istanbul ignore next */ []);
|
|
105
|
+
paletteEntry = computed(() => Math.max(0, this.palette().findIndex((swatch) => swatch.value === this.draftColor())), ...ngDevMode ? [{ debugName: "paletteEntry" }] : /* istanbul ignore next */ []);
|
|
106
|
+
popup = viewChild.required(VdPopover, ...ngDevMode ? [{ debugName: "popup" }] : /* istanbul ignore next */ []);
|
|
107
|
+
trigger = viewChild.required("trigger", ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
|
|
108
|
+
hex = viewChild.required("hex", ...ngDevMode ? [{ debugName: "hex" }] : /* istanbul ignore next */ []);
|
|
109
|
+
host = inject(ElementRef).nativeElement;
|
|
110
|
+
field = inject(VD_FIELD, { optional: true });
|
|
111
|
+
injector = inject(Injector);
|
|
112
|
+
destroyRef = inject(DestroyRef);
|
|
113
|
+
formBound = signal(false, ...ngDevMode ? [{ debugName: "formBound" }] : /* istanbul ignore next */ []);
|
|
114
|
+
ngSource = signal(null, ...ngDevMode ? [{ debugName: "ngSource" }] : /* istanbul ignore next */ []);
|
|
115
|
+
ngState = computed(() => this.ngSource()?.() ?? {
|
|
116
|
+
invalid: false,
|
|
117
|
+
touched: false,
|
|
118
|
+
disabled: false,
|
|
119
|
+
required: false
|
|
120
|
+
}, ...ngDevMode ? [{ debugName: "ngState" }] : /* istanbul ignore next */ []);
|
|
121
|
+
isDisabled = computed(() => this.disabled() || this.ngState().disabled, ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
122
|
+
locked = computed(() => this.isDisabled() || this.readonly(), ...ngDevMode ? [{ debugName: "locked" }] : /* istanbul ignore next */ []);
|
|
123
|
+
isRequired = computed(() => this.required() || this.ngState().required, ...ngDevMode ? [{ debugName: "isRequired" }] : /* istanbul ignore next */ []);
|
|
124
|
+
showInvalid = computed(() => this.invalid() && (!this.formBound() || this.touched()) || this.ngState().invalid && this.ngState().touched, ...ngDevMode ? [{ debugName: "showInvalid" }] : /* istanbul ignore next */ []);
|
|
125
|
+
wasOpen = null;
|
|
126
|
+
lastValue;
|
|
127
|
+
constructor() {
|
|
128
|
+
const control = {
|
|
129
|
+
id: signal(this.controlId),
|
|
130
|
+
invalid: this.showInvalid,
|
|
131
|
+
required: this.isRequired,
|
|
132
|
+
disabled: this.isDisabled
|
|
133
|
+
};
|
|
134
|
+
this.field?.register(control);
|
|
135
|
+
this.destroyRef.onDestroy(() => this.field?.unregister(control));
|
|
136
|
+
afterNextRender(() => {
|
|
137
|
+
const anchor = `--${this.popup().id}`;
|
|
138
|
+
this.trigger().nativeElement.style.setProperty("anchor-name", anchor);
|
|
139
|
+
this.popup().el.style.setProperty("position-anchor", anchor);
|
|
140
|
+
});
|
|
141
|
+
afterRenderEffect(() => {
|
|
142
|
+
const value = this.value();
|
|
143
|
+
if (this.locked() || this.lastValue !== void 0 && this.lastValue !== value) this.popup().hide();
|
|
144
|
+
this.lastValue = value;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
ngOnInit() {
|
|
148
|
+
const ng = this.injector.get(NgControl, null, {
|
|
149
|
+
self: true,
|
|
150
|
+
optional: true
|
|
151
|
+
});
|
|
152
|
+
this.formBound.set(!!ng || !!this.injector.get(FormField, null, {
|
|
153
|
+
self: true,
|
|
154
|
+
optional: true
|
|
155
|
+
}));
|
|
156
|
+
this.ngSource.set(vdNgControlState(ng, this.destroyRef));
|
|
157
|
+
}
|
|
158
|
+
rememberState() {
|
|
159
|
+
this.wasOpen = this.popup().el.matches(":popover-open");
|
|
160
|
+
}
|
|
161
|
+
toggle() {
|
|
162
|
+
const wasOpen = this.wasOpen ?? this.popup().el.matches(":popover-open");
|
|
163
|
+
this.wasOpen = null;
|
|
164
|
+
if (this.locked()) return;
|
|
165
|
+
if (wasOpen) {
|
|
166
|
+
this.popup().hide();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.draft.set(this.color() ?? "");
|
|
170
|
+
this.draftError.set(false);
|
|
171
|
+
this.popup().el.showPopover({ source: this.trigger().nativeElement });
|
|
172
|
+
}
|
|
173
|
+
triggerKey(event) {
|
|
174
|
+
if (event.altKey && event.key === "ArrowDown" && !this.popup().el.matches(":popover-open")) {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
this.wasOpen = false;
|
|
177
|
+
this.toggle();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
onToggle(event) {
|
|
181
|
+
const opened = event.newState === "open";
|
|
182
|
+
this.open.set(opened);
|
|
183
|
+
if (opened && !this.locked()) {
|
|
184
|
+
this.hex().nativeElement.focus();
|
|
185
|
+
this.hex().nativeElement.select();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
edit(event) {
|
|
189
|
+
this.draft.set(event.target.value);
|
|
190
|
+
this.draftError.set(false);
|
|
191
|
+
}
|
|
192
|
+
validateOnBlur() {
|
|
193
|
+
if (this.draft() && !this.draftColor()) this.draftError.set(true);
|
|
194
|
+
}
|
|
195
|
+
apply(event) {
|
|
196
|
+
event?.preventDefault();
|
|
197
|
+
const value = this.draftColor();
|
|
198
|
+
if (!value) {
|
|
199
|
+
this.draftError.set(true);
|
|
200
|
+
this.hex().nativeElement.focus();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.commit(value);
|
|
204
|
+
}
|
|
205
|
+
commit(value) {
|
|
206
|
+
if (this.locked()) return;
|
|
207
|
+
this.value.set(value);
|
|
208
|
+
this.popup().hide();
|
|
209
|
+
this.trigger().nativeElement.focus();
|
|
210
|
+
}
|
|
211
|
+
paletteKey(event, index) {
|
|
212
|
+
if (this.locked() || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
213
|
+
const next = vdColorPaletteKey(index, this.palette().length, event.key, this.host.matches(":dir(rtl)"));
|
|
214
|
+
if (next === null) return;
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
this.draft.set(this.palette()[next].value);
|
|
217
|
+
this.draftError.set(false);
|
|
218
|
+
this.popup().el.querySelectorAll("[role=radio]")[next]?.focus();
|
|
219
|
+
}
|
|
220
|
+
leavePopup(event) {
|
|
221
|
+
const next = event.relatedTarget;
|
|
222
|
+
if (next && !this.popup().el.contains(next)) this.popup().hide();
|
|
223
|
+
}
|
|
224
|
+
onFocusOut(event) {
|
|
225
|
+
if (!event.relatedTarget || !this.host.contains(event.relatedTarget)) this.touch.emit();
|
|
226
|
+
}
|
|
227
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
228
|
+
minVersion: "12.0.0",
|
|
229
|
+
version: "22.2.1",
|
|
230
|
+
ngImport: i0,
|
|
231
|
+
type: VdColorPicker,
|
|
232
|
+
deps: [],
|
|
233
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
234
|
+
});
|
|
235
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
236
|
+
minVersion: "17.0.0",
|
|
237
|
+
version: "22.2.1",
|
|
238
|
+
type: VdColorPicker,
|
|
239
|
+
isStandalone: true,
|
|
240
|
+
selector: "vd-color-picker",
|
|
241
|
+
inputs: {
|
|
242
|
+
value: {
|
|
243
|
+
classPropertyName: "value",
|
|
244
|
+
publicName: "value",
|
|
245
|
+
isSignal: true,
|
|
246
|
+
isRequired: false,
|
|
247
|
+
transformFunction: null
|
|
248
|
+
},
|
|
249
|
+
swatches: {
|
|
250
|
+
classPropertyName: "swatches",
|
|
251
|
+
publicName: "swatches",
|
|
252
|
+
isSignal: true,
|
|
253
|
+
isRequired: false,
|
|
254
|
+
transformFunction: null
|
|
255
|
+
},
|
|
256
|
+
size: {
|
|
257
|
+
classPropertyName: "size",
|
|
258
|
+
publicName: "size",
|
|
259
|
+
isSignal: true,
|
|
260
|
+
isRequired: false,
|
|
261
|
+
transformFunction: null
|
|
262
|
+
},
|
|
263
|
+
disabled: {
|
|
264
|
+
classPropertyName: "disabled",
|
|
265
|
+
publicName: "disabled",
|
|
266
|
+
isSignal: true,
|
|
267
|
+
isRequired: false,
|
|
268
|
+
transformFunction: null
|
|
269
|
+
},
|
|
270
|
+
readonly: {
|
|
271
|
+
classPropertyName: "readonly",
|
|
272
|
+
publicName: "readonly",
|
|
273
|
+
isSignal: true,
|
|
274
|
+
isRequired: false,
|
|
275
|
+
transformFunction: null
|
|
276
|
+
},
|
|
277
|
+
invalid: {
|
|
278
|
+
classPropertyName: "invalid",
|
|
279
|
+
publicName: "invalid",
|
|
280
|
+
isSignal: true,
|
|
281
|
+
isRequired: false,
|
|
282
|
+
transformFunction: null
|
|
283
|
+
},
|
|
284
|
+
touched: {
|
|
285
|
+
classPropertyName: "touched",
|
|
286
|
+
publicName: "touched",
|
|
287
|
+
isSignal: true,
|
|
288
|
+
isRequired: false,
|
|
289
|
+
transformFunction: null
|
|
290
|
+
},
|
|
291
|
+
required: {
|
|
292
|
+
classPropertyName: "required",
|
|
293
|
+
publicName: "required",
|
|
294
|
+
isSignal: true,
|
|
295
|
+
isRequired: false,
|
|
296
|
+
transformFunction: null
|
|
297
|
+
},
|
|
298
|
+
ariaLabel: {
|
|
299
|
+
classPropertyName: "ariaLabel",
|
|
300
|
+
publicName: "aria-label",
|
|
301
|
+
isSignal: true,
|
|
302
|
+
isRequired: false,
|
|
303
|
+
transformFunction: null
|
|
304
|
+
},
|
|
305
|
+
ariaLabelledby: {
|
|
306
|
+
classPropertyName: "ariaLabelledby",
|
|
307
|
+
publicName: "aria-labelledby",
|
|
308
|
+
isSignal: true,
|
|
309
|
+
isRequired: false,
|
|
310
|
+
transformFunction: null
|
|
311
|
+
},
|
|
312
|
+
placeholder: {
|
|
313
|
+
classPropertyName: "placeholder",
|
|
314
|
+
publicName: "placeholder",
|
|
315
|
+
isSignal: true,
|
|
316
|
+
isRequired: false,
|
|
317
|
+
transformFunction: null
|
|
318
|
+
},
|
|
319
|
+
pickerLabel: {
|
|
320
|
+
classPropertyName: "pickerLabel",
|
|
321
|
+
publicName: "pickerLabel",
|
|
322
|
+
isSignal: true,
|
|
323
|
+
isRequired: false,
|
|
324
|
+
transformFunction: null
|
|
325
|
+
},
|
|
326
|
+
hexLabel: {
|
|
327
|
+
classPropertyName: "hexLabel",
|
|
328
|
+
publicName: "hexLabel",
|
|
329
|
+
isSignal: true,
|
|
330
|
+
isRequired: false,
|
|
331
|
+
transformFunction: null
|
|
332
|
+
},
|
|
333
|
+
paletteLabel: {
|
|
334
|
+
classPropertyName: "paletteLabel",
|
|
335
|
+
publicName: "paletteLabel",
|
|
336
|
+
isSignal: true,
|
|
337
|
+
isRequired: false,
|
|
338
|
+
transformFunction: null
|
|
339
|
+
},
|
|
340
|
+
applyLabel: {
|
|
341
|
+
classPropertyName: "applyLabel",
|
|
342
|
+
publicName: "applyLabel",
|
|
343
|
+
isSignal: true,
|
|
344
|
+
isRequired: false,
|
|
345
|
+
transformFunction: null
|
|
346
|
+
},
|
|
347
|
+
errorLabel: {
|
|
348
|
+
classPropertyName: "errorLabel",
|
|
349
|
+
publicName: "errorLabel",
|
|
350
|
+
isSignal: true,
|
|
351
|
+
isRequired: false,
|
|
352
|
+
transformFunction: null
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
outputs: {
|
|
356
|
+
value: "valueChange",
|
|
357
|
+
touch: "touch"
|
|
358
|
+
},
|
|
359
|
+
host: {
|
|
360
|
+
listeners: { "focusout": "onFocusOut($event)" },
|
|
361
|
+
properties: {
|
|
362
|
+
"attr.data-size": "size()",
|
|
363
|
+
"attr.data-open": "open() ? \"\" : null",
|
|
364
|
+
"attr.data-disabled": "isDisabled() ? \"\" : null",
|
|
365
|
+
"attr.data-readonly": "readonly() ? \"\" : null",
|
|
366
|
+
"attr.data-invalid": "showInvalid() ? \"\" : null",
|
|
367
|
+
"attr.aria-label": "null",
|
|
368
|
+
"attr.aria-labelledby": "null"
|
|
369
|
+
},
|
|
370
|
+
classAttribute: "vd-color-picker"
|
|
371
|
+
},
|
|
372
|
+
viewQueries: [
|
|
373
|
+
{
|
|
374
|
+
propertyName: "popup",
|
|
375
|
+
first: true,
|
|
376
|
+
predicate: VdPopover,
|
|
377
|
+
descendants: true,
|
|
378
|
+
isSignal: true
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
propertyName: "trigger",
|
|
382
|
+
first: true,
|
|
383
|
+
predicate: ["trigger"],
|
|
384
|
+
descendants: true,
|
|
385
|
+
isSignal: true
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
propertyName: "hex",
|
|
389
|
+
first: true,
|
|
390
|
+
predicate: ["hex"],
|
|
391
|
+
descendants: true,
|
|
392
|
+
isSignal: true
|
|
393
|
+
}
|
|
394
|
+
],
|
|
395
|
+
ngImport: i0,
|
|
396
|
+
template: `
|
|
397
|
+
<button
|
|
398
|
+
#trigger
|
|
399
|
+
type="button"
|
|
400
|
+
class="vd-input vd-color-picker__trigger"
|
|
401
|
+
[id]="controlId"
|
|
402
|
+
[attr.data-size]="size()"
|
|
403
|
+
[disabled]="isDisabled()"
|
|
404
|
+
[attr.aria-disabled]="readonly() || null"
|
|
405
|
+
aria-haspopup="dialog"
|
|
406
|
+
[attr.aria-expanded]="open()"
|
|
407
|
+
[attr.aria-controls]="popup.id"
|
|
408
|
+
[attr.aria-label]="ariaLabel() ?? null"
|
|
409
|
+
[attr.aria-labelledby]="ariaLabelledby() ?? null"
|
|
410
|
+
[attr.aria-describedby]="field?.describedBy() ?? null"
|
|
411
|
+
[attr.aria-invalid]="showInvalid() || null"
|
|
412
|
+
[attr.data-invalid]="showInvalid() ? '' : null"
|
|
413
|
+
(pointerdown)="rememberState()"
|
|
414
|
+
(click)="toggle()"
|
|
415
|
+
(keydown)="triggerKey($event)"
|
|
416
|
+
>
|
|
417
|
+
<span
|
|
418
|
+
class="vd-color-picker__preview"
|
|
419
|
+
aria-hidden="true"
|
|
420
|
+
[attr.data-empty]="color() ? null : ''"
|
|
421
|
+
[style.--vd-color-picker-value]="color()"
|
|
422
|
+
></span>
|
|
423
|
+
<span class="vd-color-picker__value" [attr.data-placeholder]="color() ? null : ''">{{
|
|
424
|
+
color() || t().placeholder
|
|
425
|
+
}}</span>
|
|
426
|
+
<vd-icon name="chevron-down" />
|
|
427
|
+
</button>
|
|
428
|
+
<div
|
|
429
|
+
vdPopover
|
|
430
|
+
#popup="vdPopover"
|
|
431
|
+
class="vd-color-picker__popup"
|
|
432
|
+
[attr.aria-label]="t().pickerLabel"
|
|
433
|
+
(toggle)="onToggle($event)"
|
|
434
|
+
(focusout)="leavePopup($event)"
|
|
435
|
+
>
|
|
436
|
+
<div class="vd-color-picker__draft">
|
|
437
|
+
<span
|
|
438
|
+
class="vd-color-picker__preview"
|
|
439
|
+
aria-hidden="true"
|
|
440
|
+
[attr.data-empty]="draftColor() || color() ? null : ''"
|
|
441
|
+
[style.--vd-color-picker-value]="draftColor() || color()"
|
|
442
|
+
></span>
|
|
443
|
+
<label class="vd-color-picker__hex-label" [for]="hexId">{{ t().hexLabel }}</label>
|
|
444
|
+
</div>
|
|
445
|
+
<input
|
|
446
|
+
#hex
|
|
447
|
+
class="vd-input vd-color-picker__hex"
|
|
448
|
+
type="text"
|
|
449
|
+
[id]="hexId"
|
|
450
|
+
[value]="draft()"
|
|
451
|
+
autocomplete="off"
|
|
452
|
+
spellcheck="false"
|
|
453
|
+
autocapitalize="characters"
|
|
454
|
+
dir="ltr"
|
|
455
|
+
[disabled]="locked()"
|
|
456
|
+
[attr.aria-invalid]="draftError() || null"
|
|
457
|
+
[attr.data-invalid]="draftError() ? '' : null"
|
|
458
|
+
[attr.aria-describedby]="draftError() ? errorId : null"
|
|
459
|
+
(input)="edit($event)"
|
|
460
|
+
(blur)="validateOnBlur()"
|
|
461
|
+
(keydown.enter)="apply($event)"
|
|
462
|
+
/>
|
|
463
|
+
@if (palette().length) {
|
|
464
|
+
<div
|
|
465
|
+
class="vd-color-picker__palette"
|
|
466
|
+
role="radiogroup"
|
|
467
|
+
[attr.aria-label]="t().paletteLabel"
|
|
468
|
+
>
|
|
469
|
+
@for (swatch of palette(); track swatch.value; let i = $index) {
|
|
470
|
+
<button
|
|
471
|
+
type="button"
|
|
472
|
+
class="vd-color-picker__swatch"
|
|
473
|
+
role="radio"
|
|
474
|
+
[disabled]="locked()"
|
|
475
|
+
[attr.aria-label]="swatch.label"
|
|
476
|
+
[attr.aria-checked]="draftColor() === swatch.value"
|
|
477
|
+
[attr.tabindex]="i === paletteEntry() ? 0 : -1"
|
|
478
|
+
[style.--vd-color-picker-value]="swatch.value"
|
|
479
|
+
[style.--vd-color-picker-ink]="ink(swatch.value)"
|
|
480
|
+
(keydown)="paletteKey($event, i)"
|
|
481
|
+
(click)="commit(swatch.value)"
|
|
482
|
+
>
|
|
483
|
+
<span class="vd-color-picker__chip" aria-hidden="true"><vd-icon name="check" /></span>
|
|
484
|
+
</button>
|
|
485
|
+
}
|
|
486
|
+
</div>
|
|
487
|
+
}
|
|
488
|
+
@if (draftError()) {
|
|
489
|
+
<p class="vd-color-picker__error" [id]="errorId">
|
|
490
|
+
<vd-icon name="alert-circle" />{{ t().errorLabel }}
|
|
491
|
+
</p>
|
|
492
|
+
}
|
|
493
|
+
<button vdButton type="button" [disabled]="locked()" (click)="apply()">
|
|
494
|
+
{{ t().applyLabel }}
|
|
495
|
+
</button>
|
|
496
|
+
</div>
|
|
497
|
+
`,
|
|
498
|
+
isInline: true,
|
|
499
|
+
dependencies: [
|
|
500
|
+
{
|
|
501
|
+
kind: "component",
|
|
502
|
+
type: VdIcon,
|
|
503
|
+
selector: "vd-icon",
|
|
504
|
+
inputs: ["name", "label"]
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
kind: "directive",
|
|
508
|
+
type: VdPopover,
|
|
509
|
+
selector: "[vdPopover]",
|
|
510
|
+
inputs: ["placement"],
|
|
511
|
+
exportAs: ["vdPopover"]
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
kind: "component",
|
|
515
|
+
type: VdButton,
|
|
516
|
+
selector: "button[vdButton], a[vdButton]",
|
|
517
|
+
inputs: [
|
|
518
|
+
"variant",
|
|
519
|
+
"size",
|
|
520
|
+
"disabled",
|
|
521
|
+
"loading",
|
|
522
|
+
"iconOnly",
|
|
523
|
+
"type"
|
|
524
|
+
]
|
|
525
|
+
}
|
|
526
|
+
],
|
|
527
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
528
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
532
|
+
minVersion: "12.0.0",
|
|
533
|
+
version: "22.2.1",
|
|
534
|
+
ngImport: i0,
|
|
535
|
+
type: VdColorPicker,
|
|
536
|
+
decorators: [{
|
|
537
|
+
type: Component,
|
|
538
|
+
args: [{
|
|
539
|
+
selector: "vd-color-picker",
|
|
540
|
+
imports: [
|
|
541
|
+
VdIcon,
|
|
542
|
+
VdPopover,
|
|
543
|
+
VdButton
|
|
544
|
+
],
|
|
545
|
+
template: `
|
|
546
|
+
<button
|
|
547
|
+
#trigger
|
|
548
|
+
type="button"
|
|
549
|
+
class="vd-input vd-color-picker__trigger"
|
|
550
|
+
[id]="controlId"
|
|
551
|
+
[attr.data-size]="size()"
|
|
552
|
+
[disabled]="isDisabled()"
|
|
553
|
+
[attr.aria-disabled]="readonly() || null"
|
|
554
|
+
aria-haspopup="dialog"
|
|
555
|
+
[attr.aria-expanded]="open()"
|
|
556
|
+
[attr.aria-controls]="popup.id"
|
|
557
|
+
[attr.aria-label]="ariaLabel() ?? null"
|
|
558
|
+
[attr.aria-labelledby]="ariaLabelledby() ?? null"
|
|
559
|
+
[attr.aria-describedby]="field?.describedBy() ?? null"
|
|
560
|
+
[attr.aria-invalid]="showInvalid() || null"
|
|
561
|
+
[attr.data-invalid]="showInvalid() ? '' : null"
|
|
562
|
+
(pointerdown)="rememberState()"
|
|
563
|
+
(click)="toggle()"
|
|
564
|
+
(keydown)="triggerKey($event)"
|
|
565
|
+
>
|
|
566
|
+
<span
|
|
567
|
+
class="vd-color-picker__preview"
|
|
568
|
+
aria-hidden="true"
|
|
569
|
+
[attr.data-empty]="color() ? null : ''"
|
|
570
|
+
[style.--vd-color-picker-value]="color()"
|
|
571
|
+
></span>
|
|
572
|
+
<span class="vd-color-picker__value" [attr.data-placeholder]="color() ? null : ''">{{
|
|
573
|
+
color() || t().placeholder
|
|
574
|
+
}}</span>
|
|
575
|
+
<vd-icon name="chevron-down" />
|
|
576
|
+
</button>
|
|
577
|
+
<div
|
|
578
|
+
vdPopover
|
|
579
|
+
#popup="vdPopover"
|
|
580
|
+
class="vd-color-picker__popup"
|
|
581
|
+
[attr.aria-label]="t().pickerLabel"
|
|
582
|
+
(toggle)="onToggle($event)"
|
|
583
|
+
(focusout)="leavePopup($event)"
|
|
584
|
+
>
|
|
585
|
+
<div class="vd-color-picker__draft">
|
|
586
|
+
<span
|
|
587
|
+
class="vd-color-picker__preview"
|
|
588
|
+
aria-hidden="true"
|
|
589
|
+
[attr.data-empty]="draftColor() || color() ? null : ''"
|
|
590
|
+
[style.--vd-color-picker-value]="draftColor() || color()"
|
|
591
|
+
></span>
|
|
592
|
+
<label class="vd-color-picker__hex-label" [for]="hexId">{{ t().hexLabel }}</label>
|
|
593
|
+
</div>
|
|
594
|
+
<input
|
|
595
|
+
#hex
|
|
596
|
+
class="vd-input vd-color-picker__hex"
|
|
597
|
+
type="text"
|
|
598
|
+
[id]="hexId"
|
|
599
|
+
[value]="draft()"
|
|
600
|
+
autocomplete="off"
|
|
601
|
+
spellcheck="false"
|
|
602
|
+
autocapitalize="characters"
|
|
603
|
+
dir="ltr"
|
|
604
|
+
[disabled]="locked()"
|
|
605
|
+
[attr.aria-invalid]="draftError() || null"
|
|
606
|
+
[attr.data-invalid]="draftError() ? '' : null"
|
|
607
|
+
[attr.aria-describedby]="draftError() ? errorId : null"
|
|
608
|
+
(input)="edit($event)"
|
|
609
|
+
(blur)="validateOnBlur()"
|
|
610
|
+
(keydown.enter)="apply($event)"
|
|
611
|
+
/>
|
|
612
|
+
@if (palette().length) {
|
|
613
|
+
<div
|
|
614
|
+
class="vd-color-picker__palette"
|
|
615
|
+
role="radiogroup"
|
|
616
|
+
[attr.aria-label]="t().paletteLabel"
|
|
617
|
+
>
|
|
618
|
+
@for (swatch of palette(); track swatch.value; let i = $index) {
|
|
619
|
+
<button
|
|
620
|
+
type="button"
|
|
621
|
+
class="vd-color-picker__swatch"
|
|
622
|
+
role="radio"
|
|
623
|
+
[disabled]="locked()"
|
|
624
|
+
[attr.aria-label]="swatch.label"
|
|
625
|
+
[attr.aria-checked]="draftColor() === swatch.value"
|
|
626
|
+
[attr.tabindex]="i === paletteEntry() ? 0 : -1"
|
|
627
|
+
[style.--vd-color-picker-value]="swatch.value"
|
|
628
|
+
[style.--vd-color-picker-ink]="ink(swatch.value)"
|
|
629
|
+
(keydown)="paletteKey($event, i)"
|
|
630
|
+
(click)="commit(swatch.value)"
|
|
631
|
+
>
|
|
632
|
+
<span class="vd-color-picker__chip" aria-hidden="true"><vd-icon name="check" /></span>
|
|
633
|
+
</button>
|
|
634
|
+
}
|
|
635
|
+
</div>
|
|
636
|
+
}
|
|
637
|
+
@if (draftError()) {
|
|
638
|
+
<p class="vd-color-picker__error" [id]="errorId">
|
|
639
|
+
<vd-icon name="alert-circle" />{{ t().errorLabel }}
|
|
640
|
+
</p>
|
|
641
|
+
}
|
|
642
|
+
<button vdButton type="button" [disabled]="locked()" (click)="apply()">
|
|
643
|
+
{{ t().applyLabel }}
|
|
644
|
+
</button>
|
|
645
|
+
</div>
|
|
646
|
+
`,
|
|
647
|
+
host: {
|
|
648
|
+
class: "vd-color-picker",
|
|
649
|
+
"[attr.data-size]": "size()",
|
|
650
|
+
"[attr.data-open]": "open() ? \"\" : null",
|
|
651
|
+
"[attr.data-disabled]": "isDisabled() ? \"\" : null",
|
|
652
|
+
"[attr.data-readonly]": "readonly() ? \"\" : null",
|
|
653
|
+
"[attr.data-invalid]": "showInvalid() ? \"\" : null",
|
|
654
|
+
"[attr.aria-label]": "null",
|
|
655
|
+
"[attr.aria-labelledby]": "null",
|
|
656
|
+
"(focusout)": "onFocusOut($event)"
|
|
657
|
+
},
|
|
658
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
659
|
+
encapsulation: ViewEncapsulation.None
|
|
660
|
+
}]
|
|
661
|
+
}],
|
|
662
|
+
ctorParameters: () => [],
|
|
663
|
+
propDecorators: {
|
|
664
|
+
value: [{
|
|
665
|
+
type: i0.Input,
|
|
666
|
+
args: [{
|
|
667
|
+
isSignal: true,
|
|
668
|
+
alias: "value",
|
|
669
|
+
required: false
|
|
670
|
+
}]
|
|
671
|
+
}, {
|
|
672
|
+
type: i0.Output,
|
|
673
|
+
args: ["valueChange"]
|
|
674
|
+
}],
|
|
675
|
+
swatches: [{
|
|
676
|
+
type: i0.Input,
|
|
677
|
+
args: [{
|
|
678
|
+
isSignal: true,
|
|
679
|
+
alias: "swatches",
|
|
680
|
+
required: false
|
|
681
|
+
}]
|
|
682
|
+
}],
|
|
683
|
+
size: [{
|
|
684
|
+
type: i0.Input,
|
|
685
|
+
args: [{
|
|
686
|
+
isSignal: true,
|
|
687
|
+
alias: "size",
|
|
688
|
+
required: false
|
|
689
|
+
}]
|
|
690
|
+
}],
|
|
691
|
+
disabled: [{
|
|
692
|
+
type: i0.Input,
|
|
693
|
+
args: [{
|
|
694
|
+
isSignal: true,
|
|
695
|
+
alias: "disabled",
|
|
696
|
+
required: false
|
|
697
|
+
}]
|
|
698
|
+
}],
|
|
699
|
+
readonly: [{
|
|
700
|
+
type: i0.Input,
|
|
701
|
+
args: [{
|
|
702
|
+
isSignal: true,
|
|
703
|
+
alias: "readonly",
|
|
704
|
+
required: false
|
|
705
|
+
}]
|
|
706
|
+
}],
|
|
707
|
+
invalid: [{
|
|
708
|
+
type: i0.Input,
|
|
709
|
+
args: [{
|
|
710
|
+
isSignal: true,
|
|
711
|
+
alias: "invalid",
|
|
712
|
+
required: false
|
|
713
|
+
}]
|
|
714
|
+
}],
|
|
715
|
+
touched: [{
|
|
716
|
+
type: i0.Input,
|
|
717
|
+
args: [{
|
|
718
|
+
isSignal: true,
|
|
719
|
+
alias: "touched",
|
|
720
|
+
required: false
|
|
721
|
+
}]
|
|
722
|
+
}],
|
|
723
|
+
required: [{
|
|
724
|
+
type: i0.Input,
|
|
725
|
+
args: [{
|
|
726
|
+
isSignal: true,
|
|
727
|
+
alias: "required",
|
|
728
|
+
required: false
|
|
729
|
+
}]
|
|
730
|
+
}],
|
|
731
|
+
ariaLabel: [{
|
|
732
|
+
type: i0.Input,
|
|
733
|
+
args: [{
|
|
734
|
+
isSignal: true,
|
|
735
|
+
alias: "aria-label",
|
|
736
|
+
required: false
|
|
737
|
+
}]
|
|
738
|
+
}],
|
|
739
|
+
ariaLabelledby: [{
|
|
740
|
+
type: i0.Input,
|
|
741
|
+
args: [{
|
|
742
|
+
isSignal: true,
|
|
743
|
+
alias: "aria-labelledby",
|
|
744
|
+
required: false
|
|
745
|
+
}]
|
|
746
|
+
}],
|
|
747
|
+
placeholder: [{
|
|
748
|
+
type: i0.Input,
|
|
749
|
+
args: [{
|
|
750
|
+
isSignal: true,
|
|
751
|
+
alias: "placeholder",
|
|
752
|
+
required: false
|
|
753
|
+
}]
|
|
754
|
+
}],
|
|
755
|
+
pickerLabel: [{
|
|
756
|
+
type: i0.Input,
|
|
757
|
+
args: [{
|
|
758
|
+
isSignal: true,
|
|
759
|
+
alias: "pickerLabel",
|
|
760
|
+
required: false
|
|
761
|
+
}]
|
|
762
|
+
}],
|
|
763
|
+
hexLabel: [{
|
|
764
|
+
type: i0.Input,
|
|
765
|
+
args: [{
|
|
766
|
+
isSignal: true,
|
|
767
|
+
alias: "hexLabel",
|
|
768
|
+
required: false
|
|
769
|
+
}]
|
|
770
|
+
}],
|
|
771
|
+
paletteLabel: [{
|
|
772
|
+
type: i0.Input,
|
|
773
|
+
args: [{
|
|
774
|
+
isSignal: true,
|
|
775
|
+
alias: "paletteLabel",
|
|
776
|
+
required: false
|
|
777
|
+
}]
|
|
778
|
+
}],
|
|
779
|
+
applyLabel: [{
|
|
780
|
+
type: i0.Input,
|
|
781
|
+
args: [{
|
|
782
|
+
isSignal: true,
|
|
783
|
+
alias: "applyLabel",
|
|
784
|
+
required: false
|
|
785
|
+
}]
|
|
786
|
+
}],
|
|
787
|
+
errorLabel: [{
|
|
788
|
+
type: i0.Input,
|
|
789
|
+
args: [{
|
|
790
|
+
isSignal: true,
|
|
791
|
+
alias: "errorLabel",
|
|
792
|
+
required: false
|
|
793
|
+
}]
|
|
794
|
+
}],
|
|
795
|
+
touch: [{
|
|
796
|
+
type: i0.Output,
|
|
797
|
+
args: ["touch"]
|
|
798
|
+
}],
|
|
799
|
+
popup: [{
|
|
800
|
+
type: i0.ViewChild,
|
|
801
|
+
args: [i0.forwardRef(() => VdPopover), { isSignal: true }]
|
|
802
|
+
}],
|
|
803
|
+
trigger: [{
|
|
804
|
+
type: i0.ViewChild,
|
|
805
|
+
args: ["trigger", { isSignal: true }]
|
|
806
|
+
}],
|
|
807
|
+
hex: [{
|
|
808
|
+
type: i0.ViewChild,
|
|
809
|
+
args: ["hex", { isSignal: true }]
|
|
810
|
+
}]
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
export { VdColorPicker };
|
|
814
|
+
|
|
815
|
+
//# sourceMappingURL=vadem-ui-color-picker.mjs.map
|