@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,353 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ViewEncapsulation, booleanAttribute, computed, input, model, numberAttribute } from "@angular/core";
|
|
3
|
+
import { VdIcon } from "@vadem/ui/icon";
|
|
4
|
+
import { vdTexts } from "@vadem/ui/locale";
|
|
5
|
+
function vdPageRange(page, count, siblings = 1, boundaries = 1) {
|
|
6
|
+
if (count <= 0) return [];
|
|
7
|
+
const current = Math.min(Math.max(1, page), count);
|
|
8
|
+
if (count <= boundaries * 2 + siblings * 2 + 3) return range(1, count);
|
|
9
|
+
const start = Math.max(Math.min(current - siblings, count - boundaries - siblings * 2 - 1), boundaries + 2);
|
|
10
|
+
const end = Math.min(Math.max(current + siblings, boundaries + siblings * 2 + 2), count - boundaries - 1);
|
|
11
|
+
return [
|
|
12
|
+
...range(1, boundaries),
|
|
13
|
+
start > boundaries + 2 ? "ellipsis" : boundaries + 1,
|
|
14
|
+
...range(start, end),
|
|
15
|
+
end < count - boundaries - 1 ? "ellipsis" : count - boundaries,
|
|
16
|
+
...range(count - boundaries + 1, count)
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function range(from, to) {
|
|
20
|
+
return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);
|
|
21
|
+
}
|
|
22
|
+
var VdPagination = class VdPagination {
|
|
23
|
+
page = model(1, ...ngDevMode ? [{ debugName: "page" }] : /* istanbul ignore next */ []);
|
|
24
|
+
pageCount = input.required({
|
|
25
|
+
...ngDevMode ? { debugName: "pageCount" } : /* istanbul ignore next */ {},
|
|
26
|
+
transform: numberAttribute
|
|
27
|
+
});
|
|
28
|
+
size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
29
|
+
siblings = input(1, {
|
|
30
|
+
...ngDevMode ? { debugName: "siblings" } : /* istanbul ignore next */ {},
|
|
31
|
+
transform: numberAttribute
|
|
32
|
+
});
|
|
33
|
+
compact = input(false, {
|
|
34
|
+
...ngDevMode ? { debugName: "compact" } : /* istanbul ignore next */ {},
|
|
35
|
+
transform: booleanAttribute
|
|
36
|
+
});
|
|
37
|
+
label = input(...ngDevMode ? [void 0, { debugName: "label" }] : /* istanbul ignore next */ []);
|
|
38
|
+
previousLabel = input(...ngDevMode ? [void 0, { debugName: "previousLabel" }] : /* istanbul ignore next */ []);
|
|
39
|
+
nextLabel = input(...ngDevMode ? [void 0, { debugName: "nextLabel" }] : /* istanbul ignore next */ []);
|
|
40
|
+
pageLabel = input(...ngDevMode ? [void 0, { debugName: "pageLabel" }] : /* istanbul ignore next */ []);
|
|
41
|
+
t = vdTexts("pagination", {
|
|
42
|
+
label: this.label,
|
|
43
|
+
previousLabel: this.previousLabel,
|
|
44
|
+
nextLabel: this.nextLabel,
|
|
45
|
+
pageLabel: this.pageLabel
|
|
46
|
+
});
|
|
47
|
+
current = computed(() => Math.min(Math.max(1, this.page()), Math.max(1, this.pageCount())), ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
|
|
48
|
+
isFirst = computed(() => this.current() <= 1, ...ngDevMode ? [{ debugName: "isFirst" }] : /* istanbul ignore next */ []);
|
|
49
|
+
isLast = computed(() => this.current() >= this.pageCount(), ...ngDevMode ? [{ debugName: "isLast" }] : /* istanbul ignore next */ []);
|
|
50
|
+
items = computed(() => vdPageRange(this.current(), this.pageCount(), this.siblings()), ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
51
|
+
revealFocused(event) {
|
|
52
|
+
event.target.scrollIntoView?.({
|
|
53
|
+
block: "nearest",
|
|
54
|
+
inline: "nearest"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
go(page) {
|
|
58
|
+
if (page < 1 || page > this.pageCount() || page === this.current()) return;
|
|
59
|
+
this.page.set(page);
|
|
60
|
+
}
|
|
61
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
62
|
+
minVersion: "12.0.0",
|
|
63
|
+
version: "22.2.1",
|
|
64
|
+
ngImport: i0,
|
|
65
|
+
type: VdPagination,
|
|
66
|
+
deps: [],
|
|
67
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
68
|
+
});
|
|
69
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
70
|
+
minVersion: "17.0.0",
|
|
71
|
+
version: "22.2.1",
|
|
72
|
+
type: VdPagination,
|
|
73
|
+
isStandalone: true,
|
|
74
|
+
selector: "vd-pagination",
|
|
75
|
+
inputs: {
|
|
76
|
+
page: {
|
|
77
|
+
classPropertyName: "page",
|
|
78
|
+
publicName: "page",
|
|
79
|
+
isSignal: true,
|
|
80
|
+
isRequired: false,
|
|
81
|
+
transformFunction: null
|
|
82
|
+
},
|
|
83
|
+
pageCount: {
|
|
84
|
+
classPropertyName: "pageCount",
|
|
85
|
+
publicName: "pageCount",
|
|
86
|
+
isSignal: true,
|
|
87
|
+
isRequired: true,
|
|
88
|
+
transformFunction: null
|
|
89
|
+
},
|
|
90
|
+
size: {
|
|
91
|
+
classPropertyName: "size",
|
|
92
|
+
publicName: "size",
|
|
93
|
+
isSignal: true,
|
|
94
|
+
isRequired: false,
|
|
95
|
+
transformFunction: null
|
|
96
|
+
},
|
|
97
|
+
siblings: {
|
|
98
|
+
classPropertyName: "siblings",
|
|
99
|
+
publicName: "siblings",
|
|
100
|
+
isSignal: true,
|
|
101
|
+
isRequired: false,
|
|
102
|
+
transformFunction: null
|
|
103
|
+
},
|
|
104
|
+
compact: {
|
|
105
|
+
classPropertyName: "compact",
|
|
106
|
+
publicName: "compact",
|
|
107
|
+
isSignal: true,
|
|
108
|
+
isRequired: false,
|
|
109
|
+
transformFunction: null
|
|
110
|
+
},
|
|
111
|
+
label: {
|
|
112
|
+
classPropertyName: "label",
|
|
113
|
+
publicName: "label",
|
|
114
|
+
isSignal: true,
|
|
115
|
+
isRequired: false,
|
|
116
|
+
transformFunction: null
|
|
117
|
+
},
|
|
118
|
+
previousLabel: {
|
|
119
|
+
classPropertyName: "previousLabel",
|
|
120
|
+
publicName: "previousLabel",
|
|
121
|
+
isSignal: true,
|
|
122
|
+
isRequired: false,
|
|
123
|
+
transformFunction: null
|
|
124
|
+
},
|
|
125
|
+
nextLabel: {
|
|
126
|
+
classPropertyName: "nextLabel",
|
|
127
|
+
publicName: "nextLabel",
|
|
128
|
+
isSignal: true,
|
|
129
|
+
isRequired: false,
|
|
130
|
+
transformFunction: null
|
|
131
|
+
},
|
|
132
|
+
pageLabel: {
|
|
133
|
+
classPropertyName: "pageLabel",
|
|
134
|
+
publicName: "pageLabel",
|
|
135
|
+
isSignal: true,
|
|
136
|
+
isRequired: false,
|
|
137
|
+
transformFunction: null
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
outputs: { page: "pageChange" },
|
|
141
|
+
host: {
|
|
142
|
+
attributes: { "role": "navigation" },
|
|
143
|
+
listeners: { "focusin": "revealFocused($event)" },
|
|
144
|
+
properties: {
|
|
145
|
+
"attr.aria-label": "t().label",
|
|
146
|
+
"attr.data-size": "size()"
|
|
147
|
+
},
|
|
148
|
+
classAttribute: "vd-pagination"
|
|
149
|
+
},
|
|
150
|
+
ngImport: i0,
|
|
151
|
+
template: `
|
|
152
|
+
<button
|
|
153
|
+
type="button"
|
|
154
|
+
class="vd-pagination__step"
|
|
155
|
+
[attr.aria-label]="t().previousLabel"
|
|
156
|
+
[attr.aria-disabled]="isFirst() || null"
|
|
157
|
+
(click)="go(current() - 1)"
|
|
158
|
+
>
|
|
159
|
+
<vd-icon name="chevron-left" />
|
|
160
|
+
</button>
|
|
161
|
+
|
|
162
|
+
@if (compact()) {
|
|
163
|
+
<span class="vd-pagination__status">{{ current() }} / {{ pageCount() }}</span>
|
|
164
|
+
} @else {
|
|
165
|
+
<ul class="vd-pagination__pages" role="list">
|
|
166
|
+
@for (item of items(); track item === 'ellipsis' ? 'e' + $index : item) {
|
|
167
|
+
<li>
|
|
168
|
+
@if (item === 'ellipsis') {
|
|
169
|
+
<span class="vd-pagination__ellipsis" aria-hidden="true">…</span>
|
|
170
|
+
} @else {
|
|
171
|
+
<button
|
|
172
|
+
type="button"
|
|
173
|
+
class="vd-pagination__page"
|
|
174
|
+
[attr.aria-current]="item === current() ? 'page' : null"
|
|
175
|
+
[attr.aria-label]="t().pageLabel(item)"
|
|
176
|
+
(click)="go(item)"
|
|
177
|
+
>
|
|
178
|
+
{{ item }}
|
|
179
|
+
</button>
|
|
180
|
+
}
|
|
181
|
+
</li>
|
|
182
|
+
}
|
|
183
|
+
</ul>
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
class="vd-pagination__step"
|
|
189
|
+
[attr.aria-label]="t().nextLabel"
|
|
190
|
+
[attr.aria-disabled]="isLast() || null"
|
|
191
|
+
(click)="go(current() + 1)"
|
|
192
|
+
>
|
|
193
|
+
<vd-icon name="chevron-right" />
|
|
194
|
+
</button>
|
|
195
|
+
`,
|
|
196
|
+
isInline: true,
|
|
197
|
+
dependencies: [{
|
|
198
|
+
kind: "component",
|
|
199
|
+
type: VdIcon,
|
|
200
|
+
selector: "vd-icon",
|
|
201
|
+
inputs: ["name", "label"]
|
|
202
|
+
}],
|
|
203
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
204
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
208
|
+
minVersion: "12.0.0",
|
|
209
|
+
version: "22.2.1",
|
|
210
|
+
ngImport: i0,
|
|
211
|
+
type: VdPagination,
|
|
212
|
+
decorators: [{
|
|
213
|
+
type: Component,
|
|
214
|
+
args: [{
|
|
215
|
+
selector: "vd-pagination",
|
|
216
|
+
imports: [VdIcon],
|
|
217
|
+
template: `
|
|
218
|
+
<button
|
|
219
|
+
type="button"
|
|
220
|
+
class="vd-pagination__step"
|
|
221
|
+
[attr.aria-label]="t().previousLabel"
|
|
222
|
+
[attr.aria-disabled]="isFirst() || null"
|
|
223
|
+
(click)="go(current() - 1)"
|
|
224
|
+
>
|
|
225
|
+
<vd-icon name="chevron-left" />
|
|
226
|
+
</button>
|
|
227
|
+
|
|
228
|
+
@if (compact()) {
|
|
229
|
+
<span class="vd-pagination__status">{{ current() }} / {{ pageCount() }}</span>
|
|
230
|
+
} @else {
|
|
231
|
+
<ul class="vd-pagination__pages" role="list">
|
|
232
|
+
@for (item of items(); track item === 'ellipsis' ? 'e' + $index : item) {
|
|
233
|
+
<li>
|
|
234
|
+
@if (item === 'ellipsis') {
|
|
235
|
+
<span class="vd-pagination__ellipsis" aria-hidden="true">…</span>
|
|
236
|
+
} @else {
|
|
237
|
+
<button
|
|
238
|
+
type="button"
|
|
239
|
+
class="vd-pagination__page"
|
|
240
|
+
[attr.aria-current]="item === current() ? 'page' : null"
|
|
241
|
+
[attr.aria-label]="t().pageLabel(item)"
|
|
242
|
+
(click)="go(item)"
|
|
243
|
+
>
|
|
244
|
+
{{ item }}
|
|
245
|
+
</button>
|
|
246
|
+
}
|
|
247
|
+
</li>
|
|
248
|
+
}
|
|
249
|
+
</ul>
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
<button
|
|
253
|
+
type="button"
|
|
254
|
+
class="vd-pagination__step"
|
|
255
|
+
[attr.aria-label]="t().nextLabel"
|
|
256
|
+
[attr.aria-disabled]="isLast() || null"
|
|
257
|
+
(click)="go(current() + 1)"
|
|
258
|
+
>
|
|
259
|
+
<vd-icon name="chevron-right" />
|
|
260
|
+
</button>
|
|
261
|
+
`,
|
|
262
|
+
host: {
|
|
263
|
+
class: "vd-pagination",
|
|
264
|
+
role: "navigation",
|
|
265
|
+
"[attr.aria-label]": "t().label",
|
|
266
|
+
"[attr.data-size]": "size()",
|
|
267
|
+
"(focusin)": "revealFocused($event)"
|
|
268
|
+
},
|
|
269
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
270
|
+
encapsulation: ViewEncapsulation.None
|
|
271
|
+
}]
|
|
272
|
+
}],
|
|
273
|
+
propDecorators: {
|
|
274
|
+
page: [{
|
|
275
|
+
type: i0.Input,
|
|
276
|
+
args: [{
|
|
277
|
+
isSignal: true,
|
|
278
|
+
alias: "page",
|
|
279
|
+
required: false
|
|
280
|
+
}]
|
|
281
|
+
}, {
|
|
282
|
+
type: i0.Output,
|
|
283
|
+
args: ["pageChange"]
|
|
284
|
+
}],
|
|
285
|
+
pageCount: [{
|
|
286
|
+
type: i0.Input,
|
|
287
|
+
args: [{
|
|
288
|
+
isSignal: true,
|
|
289
|
+
alias: "pageCount",
|
|
290
|
+
required: true
|
|
291
|
+
}]
|
|
292
|
+
}],
|
|
293
|
+
size: [{
|
|
294
|
+
type: i0.Input,
|
|
295
|
+
args: [{
|
|
296
|
+
isSignal: true,
|
|
297
|
+
alias: "size",
|
|
298
|
+
required: false
|
|
299
|
+
}]
|
|
300
|
+
}],
|
|
301
|
+
siblings: [{
|
|
302
|
+
type: i0.Input,
|
|
303
|
+
args: [{
|
|
304
|
+
isSignal: true,
|
|
305
|
+
alias: "siblings",
|
|
306
|
+
required: false
|
|
307
|
+
}]
|
|
308
|
+
}],
|
|
309
|
+
compact: [{
|
|
310
|
+
type: i0.Input,
|
|
311
|
+
args: [{
|
|
312
|
+
isSignal: true,
|
|
313
|
+
alias: "compact",
|
|
314
|
+
required: false
|
|
315
|
+
}]
|
|
316
|
+
}],
|
|
317
|
+
label: [{
|
|
318
|
+
type: i0.Input,
|
|
319
|
+
args: [{
|
|
320
|
+
isSignal: true,
|
|
321
|
+
alias: "label",
|
|
322
|
+
required: false
|
|
323
|
+
}]
|
|
324
|
+
}],
|
|
325
|
+
previousLabel: [{
|
|
326
|
+
type: i0.Input,
|
|
327
|
+
args: [{
|
|
328
|
+
isSignal: true,
|
|
329
|
+
alias: "previousLabel",
|
|
330
|
+
required: false
|
|
331
|
+
}]
|
|
332
|
+
}],
|
|
333
|
+
nextLabel: [{
|
|
334
|
+
type: i0.Input,
|
|
335
|
+
args: [{
|
|
336
|
+
isSignal: true,
|
|
337
|
+
alias: "nextLabel",
|
|
338
|
+
required: false
|
|
339
|
+
}]
|
|
340
|
+
}],
|
|
341
|
+
pageLabel: [{
|
|
342
|
+
type: i0.Input,
|
|
343
|
+
args: [{
|
|
344
|
+
isSignal: true,
|
|
345
|
+
alias: "pageLabel",
|
|
346
|
+
required: false
|
|
347
|
+
}]
|
|
348
|
+
}]
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
export { VdPagination, vdPageRange };
|
|
352
|
+
|
|
353
|
+
//# sourceMappingURL=vadem-ui-pagination.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vadem-ui-pagination.mjs","names":[],"sources":["../../../projects/ui/pagination/src/core/range.ts","../../../projects/ui/pagination/src/pagination.ts"],"sourcesContent":["export type VdPageItem = number | 'ellipsis';\n\n/**\n * Page items to render: first/last `boundaries` pages, `siblings` around the current page,\n * and 'ellipsis' for gaps. The length stays constant while paging (no jumping layout), and an\n * ellipsis never hides a single page (that page is shown instead).\n *\n * vdPageRange(6, 12) -> [1, 'ellipsis', 5, 6, 7, 'ellipsis', 12]\n */\nexport function vdPageRange(\n page: number,\n count: number,\n siblings = 1,\n boundaries = 1,\n): VdPageItem[] {\n if (count <= 0) return [];\n const current = Math.min(Math.max(1, page), count);\n // boundaries on both sides + siblings + current + 2 ellipsis slots\n const slots = boundaries * 2 + siblings * 2 + 3;\n if (count <= slots) return range(1, count);\n\n const start = Math.max(\n Math.min(current - siblings, count - boundaries - siblings * 2 - 1),\n boundaries + 2,\n );\n const end = Math.min(\n Math.max(current + siblings, boundaries + siblings * 2 + 2),\n count - boundaries - 1,\n );\n\n return [\n ...range(1, boundaries),\n start > boundaries + 2 ? 'ellipsis' : boundaries + 1,\n ...range(start, end),\n end < count - boundaries - 1 ? 'ellipsis' : count - boundaries,\n ...range(count - boundaries + 1, count),\n ];\n}\n\nfunction range(from: number, to: number): number[] {\n return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n booleanAttribute,\n computed,\n input,\n model,\n numberAttribute,\n} from '@angular/core';\nimport { VdIcon } from '@vadem/ui/icon';\nimport { vdPageRange } from './core/range';\nimport { vdTexts } from '@vadem/ui/locale';\n\nexport type VdPaginationSize = 'sm' | 'md';\n\n/**\n * Page navigation for paged lists and tables. Buttons (not links): the consumer loads the page.\n * Spec: specs/pagination.md\n */\n@Component({\n selector: 'vd-pagination',\n imports: [VdIcon],\n template: `\n <button\n type=\"button\"\n class=\"vd-pagination__step\"\n [attr.aria-label]=\"t().previousLabel\"\n [attr.aria-disabled]=\"isFirst() || null\"\n (click)=\"go(current() - 1)\"\n >\n <vd-icon name=\"chevron-left\" />\n </button>\n\n @if (compact()) {\n <span class=\"vd-pagination__status\">{{ current() }} / {{ pageCount() }}</span>\n } @else {\n <ul class=\"vd-pagination__pages\" role=\"list\">\n @for (item of items(); track item === 'ellipsis' ? 'e' + $index : item) {\n <li>\n @if (item === 'ellipsis') {\n <span class=\"vd-pagination__ellipsis\" aria-hidden=\"true\">…</span>\n } @else {\n <button\n type=\"button\"\n class=\"vd-pagination__page\"\n [attr.aria-current]=\"item === current() ? 'page' : null\"\n [attr.aria-label]=\"t().pageLabel(item)\"\n (click)=\"go(item)\"\n >\n {{ item }}\n </button>\n }\n </li>\n }\n </ul>\n }\n\n <button\n type=\"button\"\n class=\"vd-pagination__step\"\n [attr.aria-label]=\"t().nextLabel\"\n [attr.aria-disabled]=\"isLast() || null\"\n (click)=\"go(current() + 1)\"\n >\n <vd-icon name=\"chevron-right\" />\n </button>\n `,\n host: {\n class: 'vd-pagination',\n role: 'navigation',\n '[attr.aria-label]': 't().label',\n '[attr.data-size]': 'size()',\n '(focusin)': 'revealFocused($event)',\n },\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class VdPagination {\n /** Current page, 1-based (two-way). */\n readonly page = model(1);\n readonly pageCount = input.required({ transform: numberAttribute });\n readonly size = input<VdPaginationSize>('md');\n /** Pages shown on each side of the current one. */\n readonly siblings = input(1, { transform: numberAttribute });\n /** \"3 / 12\" instead of page buttons (narrow spaces). */\n readonly compact = input(false, { transform: booleanAttribute });\n /** Landmark name; name each pagination on a page differently. */\n readonly label = input<string>();\n readonly previousLabel = input<string>();\n readonly nextLabel = input<string>();\n readonly pageLabel = input<(page: number) => string>();\n /** Text inputs resolved against the active VD_LOCALE. */\n protected readonly t = vdTexts('pagination', {\n label: this.label,\n previousLabel: this.previousLabel,\n nextLabel: this.nextLabel,\n pageLabel: this.pageLabel,\n });\n\n protected readonly current = computed(() =>\n Math.min(Math.max(1, this.page()), Math.max(1, this.pageCount())),\n );\n protected readonly isFirst = computed(() => this.current() <= 1);\n protected readonly isLast = computed(() => this.current() >= this.pageCount());\n protected readonly items = computed(() =>\n vdPageRange(this.current(), this.pageCount(), this.siblings()),\n );\n\n /** Native focus scrolling can leave a partially visible button clipped. */\n protected revealFocused(event: FocusEvent): void {\n (event.target as HTMLElement).scrollIntoView?.({ block: 'nearest', inline: 'nearest' });\n }\n\n /** Disabled steps use aria-disabled (they keep focus at the edges), so guard here. */\n protected go(page: number): void {\n if (page < 1 || page > this.pageCount() || page === this.current()) return;\n this.page.set(page);\n }\n}\n"],"mappings":";;;;AASA,SAAgB,YACd,MACA,OACA,WAAW,GACX,aAAa,GAAC;CAEd,IAAI,SAAS,GAAG,OAAO,CAAA;CACvB,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,KAAK;CAGjD,IAAI,SADU,aAAa,IAAI,WAAW,IAAI,GAC1B,OAAO,MAAM,GAAG,KAAK;CAEzC,MAAM,QAAQ,KAAK,IACjB,KAAK,IAAI,UAAU,UAAU,QAAQ,aAAa,WAAW,IAAI,CAAC,GAClE,aAAa,CAAC;CAEhB,MAAM,MAAM,KAAK,IACf,KAAK,IAAI,UAAU,UAAU,aAAa,WAAW,IAAI,CAAC,GAC1D,QAAQ,aAAa,CAAC;CAGxB,OAAO;EACL,GAAG,MAAM,GAAG,UAAU;EACtB,QAAQ,aAAa,IAAI,aAAa,aAAa;EACnD,GAAG,MAAM,OAAO,GAAG;EACnB,MAAM,QAAQ,aAAa,IAAI,aAAa,QAAQ;EACpD,GAAG,MAAM,QAAQ,aAAa,GAAG,KAAK;CACvC;AACH;AAEA,SAAS,MAAM,MAAc,IAAU;CACrC,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,KAAK,OAAO,CAAC,EAAC,IAAK,GAAG,MAAM,OAAO,CAAC;AAC9E;ACqCA,IAAa,eAAb,MAAa,aAAY;CAEd,OAAO,MAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CACf,YAAY,MAAM,SAAQ;EAAA,GAAA,YAAA,EAAA,WAAA,YAAA,+BAAA,CAAA;EAAG,WAAW;CAAe,CAAA;CACvD,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A,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,MAAA,aAAA;EAAA,MAAA;GAAA,YAAA,EAAA,QAAA,aAAA;GAAA,WAAA,EAAA,WAAA,wBAAA;GAAA,YAAA;IAAA,mBAAA;IAAA,kBAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UAvDb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CT,UAAA;EAAA,cAAA,CAAA;GAAA,MAAA;GAAA,MA7CS;GAAM,UAAA;GAAA,QAAA,CAAA,QAAA,OAAA;EAAA,CAAA;EAAA,iBAAA,GAAA,wBAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAwDL,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EA1DxB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,SAAS,CAAC,MAAM;GAChB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CV,MAAM;IACJ,OAAO;IACP,MAAM;IACN,qBAAqB;IACrB,oBAAoB;IACpB,aAAa;GACd;GACD,iBAAiB,wBAAwB;GACzC,eAAe,kBAAkB;EAClC,CAAA"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, Directive, ElementRef, ViewEncapsulation, afterEveryRender, contentChild, inject, input, signal } from "@angular/core";
|
|
4
|
+
import { VdButton } from "@vadem/ui/button";
|
|
5
|
+
import { VdIcon } from "@vadem/ui/icon";
|
|
6
|
+
import { VdInput } from "@vadem/ui/input";
|
|
7
|
+
import { vdTexts } from "@vadem/ui/locale";
|
|
8
|
+
var VdPasswordInput = class VdPasswordInput extends VdInput {
|
|
9
|
+
element = inject(ElementRef).nativeElement;
|
|
10
|
+
document = inject(DOCUMENT);
|
|
11
|
+
visible = signal(false, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
|
|
12
|
+
revealed = this.visible.asReadonly();
|
|
13
|
+
unavailable = signal(true, ...ngDevMode ? [{ debugName: "unavailable" }] : /* istanbul ignore next */ []);
|
|
14
|
+
locked = this.unavailable.asReadonly();
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
afterEveryRender(() => {
|
|
18
|
+
this.unavailable.set(this.element.disabled);
|
|
19
|
+
if (this.element.disabled && this.visible()) this.setVisible(false);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
preserveEditingFocus(event) {
|
|
23
|
+
if (event.button === 0 && this.document.activeElement === this.element) event.preventDefault();
|
|
24
|
+
}
|
|
25
|
+
toggle() {
|
|
26
|
+
if (this.element.disabled) return;
|
|
27
|
+
this.setVisible(!this.visible());
|
|
28
|
+
}
|
|
29
|
+
setVisible(visible) {
|
|
30
|
+
const { selectionStart, selectionEnd, selectionDirection, scrollLeft } = this.element;
|
|
31
|
+
this.visible.set(visible);
|
|
32
|
+
this.element.type = visible ? "text" : "password";
|
|
33
|
+
if (selectionStart !== null && selectionEnd !== null) this.element.setSelectionRange(selectionStart, selectionEnd, selectionDirection ?? "none");
|
|
34
|
+
this.element.scrollLeft = scrollLeft;
|
|
35
|
+
}
|
|
36
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
37
|
+
minVersion: "12.0.0",
|
|
38
|
+
version: "22.2.1",
|
|
39
|
+
ngImport: i0,
|
|
40
|
+
type: VdPasswordInput,
|
|
41
|
+
deps: [],
|
|
42
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
43
|
+
});
|
|
44
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
45
|
+
minVersion: "14.0.0",
|
|
46
|
+
version: "22.2.1",
|
|
47
|
+
type: VdPasswordInput,
|
|
48
|
+
isStandalone: true,
|
|
49
|
+
selector: "input[vdPasswordInput]",
|
|
50
|
+
host: {
|
|
51
|
+
properties: { "type": "revealed() ? \"text\" : \"password\"" },
|
|
52
|
+
classAttribute: "vd-password-input__input"
|
|
53
|
+
},
|
|
54
|
+
exportAs: ["vdPasswordInput"],
|
|
55
|
+
usesInheritance: true,
|
|
56
|
+
ngImport: i0
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
60
|
+
minVersion: "12.0.0",
|
|
61
|
+
version: "22.2.1",
|
|
62
|
+
ngImport: i0,
|
|
63
|
+
type: VdPasswordInput,
|
|
64
|
+
decorators: [{
|
|
65
|
+
type: Directive,
|
|
66
|
+
args: [{
|
|
67
|
+
selector: "input[vdPasswordInput]",
|
|
68
|
+
exportAs: "vdPasswordInput",
|
|
69
|
+
host: {
|
|
70
|
+
class: "vd-password-input__input",
|
|
71
|
+
"[type]": "revealed() ? \"text\" : \"password\""
|
|
72
|
+
}
|
|
73
|
+
}]
|
|
74
|
+
}],
|
|
75
|
+
ctorParameters: () => []
|
|
76
|
+
});
|
|
77
|
+
var VdPasswordInputGroup = class VdPasswordInputGroup {
|
|
78
|
+
revealLabel = input(...ngDevMode ? [void 0, { debugName: "revealLabel" }] : /* istanbul ignore next */ []);
|
|
79
|
+
t = vdTexts("passwordInput", { revealLabel: this.revealLabel });
|
|
80
|
+
control = contentChild(VdPasswordInput, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
81
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
82
|
+
minVersion: "12.0.0",
|
|
83
|
+
version: "22.2.1",
|
|
84
|
+
ngImport: i0,
|
|
85
|
+
type: VdPasswordInputGroup,
|
|
86
|
+
deps: [],
|
|
87
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
88
|
+
});
|
|
89
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
90
|
+
minVersion: "17.2.0",
|
|
91
|
+
version: "22.2.1",
|
|
92
|
+
type: VdPasswordInputGroup,
|
|
93
|
+
isStandalone: true,
|
|
94
|
+
selector: "vd-password-input",
|
|
95
|
+
inputs: { revealLabel: {
|
|
96
|
+
classPropertyName: "revealLabel",
|
|
97
|
+
publicName: "revealLabel",
|
|
98
|
+
isSignal: true,
|
|
99
|
+
isRequired: false,
|
|
100
|
+
transformFunction: null
|
|
101
|
+
} },
|
|
102
|
+
host: {
|
|
103
|
+
properties: { "attr.data-revealed": "control()?.revealed() ? \"\" : null" },
|
|
104
|
+
classAttribute: "vd-input-group vd-password-input"
|
|
105
|
+
},
|
|
106
|
+
queries: [{
|
|
107
|
+
propertyName: "control",
|
|
108
|
+
first: true,
|
|
109
|
+
predicate: VdPasswordInput,
|
|
110
|
+
descendants: true,
|
|
111
|
+
isSignal: true
|
|
112
|
+
}],
|
|
113
|
+
ngImport: i0,
|
|
114
|
+
template: `
|
|
115
|
+
<ng-content select="[slot=start]" />
|
|
116
|
+
<ng-content select="input[vdPasswordInput]" />
|
|
117
|
+
<button
|
|
118
|
+
vdButton
|
|
119
|
+
type="button"
|
|
120
|
+
variant="ghost"
|
|
121
|
+
iconOnly
|
|
122
|
+
slot="end"
|
|
123
|
+
[size]="control()?.size() ?? 'md'"
|
|
124
|
+
[disabled]="control()?.locked() ?? true"
|
|
125
|
+
[attr.aria-label]="t().revealLabel"
|
|
126
|
+
[attr.aria-pressed]="control()?.revealed() ?? false"
|
|
127
|
+
[attr.aria-controls]="control()?.id() ?? null"
|
|
128
|
+
(mousedown)="control()?.preserveEditingFocus($event)"
|
|
129
|
+
(click)="control()?.toggle()"
|
|
130
|
+
>
|
|
131
|
+
<vd-icon [name]="control()?.revealed() ? 'eye-off' : 'eye'" />
|
|
132
|
+
</button>
|
|
133
|
+
`,
|
|
134
|
+
isInline: true,
|
|
135
|
+
dependencies: [{
|
|
136
|
+
kind: "component",
|
|
137
|
+
type: VdButton,
|
|
138
|
+
selector: "button[vdButton], a[vdButton]",
|
|
139
|
+
inputs: [
|
|
140
|
+
"variant",
|
|
141
|
+
"size",
|
|
142
|
+
"disabled",
|
|
143
|
+
"loading",
|
|
144
|
+
"iconOnly",
|
|
145
|
+
"type"
|
|
146
|
+
]
|
|
147
|
+
}, {
|
|
148
|
+
kind: "component",
|
|
149
|
+
type: VdIcon,
|
|
150
|
+
selector: "vd-icon",
|
|
151
|
+
inputs: ["name", "label"]
|
|
152
|
+
}],
|
|
153
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
154
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
158
|
+
minVersion: "12.0.0",
|
|
159
|
+
version: "22.2.1",
|
|
160
|
+
ngImport: i0,
|
|
161
|
+
type: VdPasswordInputGroup,
|
|
162
|
+
decorators: [{
|
|
163
|
+
type: Component,
|
|
164
|
+
args: [{
|
|
165
|
+
selector: "vd-password-input",
|
|
166
|
+
imports: [VdButton, VdIcon],
|
|
167
|
+
template: `
|
|
168
|
+
<ng-content select="[slot=start]" />
|
|
169
|
+
<ng-content select="input[vdPasswordInput]" />
|
|
170
|
+
<button
|
|
171
|
+
vdButton
|
|
172
|
+
type="button"
|
|
173
|
+
variant="ghost"
|
|
174
|
+
iconOnly
|
|
175
|
+
slot="end"
|
|
176
|
+
[size]="control()?.size() ?? 'md'"
|
|
177
|
+
[disabled]="control()?.locked() ?? true"
|
|
178
|
+
[attr.aria-label]="t().revealLabel"
|
|
179
|
+
[attr.aria-pressed]="control()?.revealed() ?? false"
|
|
180
|
+
[attr.aria-controls]="control()?.id() ?? null"
|
|
181
|
+
(mousedown)="control()?.preserveEditingFocus($event)"
|
|
182
|
+
(click)="control()?.toggle()"
|
|
183
|
+
>
|
|
184
|
+
<vd-icon [name]="control()?.revealed() ? 'eye-off' : 'eye'" />
|
|
185
|
+
</button>
|
|
186
|
+
`,
|
|
187
|
+
host: {
|
|
188
|
+
class: "vd-input-group vd-password-input",
|
|
189
|
+
"[attr.data-revealed]": "control()?.revealed() ? \"\" : null"
|
|
190
|
+
},
|
|
191
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
192
|
+
encapsulation: ViewEncapsulation.None
|
|
193
|
+
}]
|
|
194
|
+
}],
|
|
195
|
+
propDecorators: {
|
|
196
|
+
revealLabel: [{
|
|
197
|
+
type: i0.Input,
|
|
198
|
+
args: [{
|
|
199
|
+
isSignal: true,
|
|
200
|
+
alias: "revealLabel",
|
|
201
|
+
required: false
|
|
202
|
+
}]
|
|
203
|
+
}],
|
|
204
|
+
control: [{
|
|
205
|
+
type: i0.ContentChild,
|
|
206
|
+
args: [i0.forwardRef(() => VdPasswordInput), { isSignal: true }]
|
|
207
|
+
}]
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const VD_PASSWORD_INPUT = [VdPasswordInputGroup, VdPasswordInput];
|
|
211
|
+
export { VD_PASSWORD_INPUT, VdPasswordInput, VdPasswordInputGroup };
|
|
212
|
+
|
|
213
|
+
//# sourceMappingURL=vadem-ui-password-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vadem-ui-password-input.mjs","names":[],"sources":["../../../projects/ui/password-input/src/password-input.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n afterEveryRender,\n ChangeDetectionStrategy,\n Component,\n contentChild,\n Directive,\n ElementRef,\n inject,\n input,\n signal,\n ViewEncapsulation,\n} from '@angular/core';\nimport { VdButton } from '@vadem/ui/button';\nimport { VdIcon } from '@vadem/ui/icon';\nimport { VdInput } from '@vadem/ui/input';\nimport { vdTexts } from '@vadem/ui/locale';\n\n/** Native password value and forms accessor remain on the input. This directive owns type. */\n@Directive({\n selector: 'input[vdPasswordInput]',\n exportAs: 'vdPasswordInput',\n host: { class: 'vd-password-input__input', '[type]': 'revealed() ? \"text\" : \"password\"' },\n})\nexport class VdPasswordInput extends VdInput {\n readonly element: HTMLInputElement = inject(ElementRef).nativeElement;\n private readonly document = inject(DOCUMENT);\n private readonly visible = signal(false);\n readonly revealed = this.visible.asReadonly();\n private readonly unavailable = signal(true);\n readonly locked = this.unavailable.asReadonly();\n\n constructor() {\n super();\n afterEveryRender(() => {\n this.unavailable.set(this.element.disabled);\n if (this.element.disabled && this.visible()) this.setVisible(false);\n });\n }\n\n /** Pointer activation while editing preserves input focus; keyboard focus stays on the button. */\n preserveEditingFocus(event: MouseEvent): void {\n if (event.button === 0 && this.document.activeElement === this.element) event.preventDefault();\n }\n\n toggle(): void {\n if (this.element.disabled) return;\n this.setVisible(!this.visible());\n }\n\n private setVisible(visible: boolean): void {\n const { selectionStart, selectionEnd, selectionDirection, scrollLeft } = this.element;\n this.visible.set(visible);\n // Update synchronously so restoring the range follows the actual native type change.\n this.element.type = visible ? 'text' : 'password';\n if (selectionStart !== null && selectionEnd !== null)\n this.element.setSelectionRange(selectionStart, selectionEnd, selectionDirection ?? 'none');\n this.element.scrollLeft = scrollLeft;\n }\n}\n\n@Component({\n selector: 'vd-password-input',\n imports: [VdButton, VdIcon],\n template: `\n <ng-content select=\"[slot=start]\" />\n <ng-content select=\"input[vdPasswordInput]\" />\n <button\n vdButton\n type=\"button\"\n variant=\"ghost\"\n iconOnly\n slot=\"end\"\n [size]=\"control()?.size() ?? 'md'\"\n [disabled]=\"control()?.locked() ?? true\"\n [attr.aria-label]=\"t().revealLabel\"\n [attr.aria-pressed]=\"control()?.revealed() ?? false\"\n [attr.aria-controls]=\"control()?.id() ?? null\"\n (mousedown)=\"control()?.preserveEditingFocus($event)\"\n (click)=\"control()?.toggle()\"\n >\n <vd-icon [name]=\"control()?.revealed() ? 'eye-off' : 'eye'\" />\n </button>\n `,\n host: {\n class: 'vd-input-group vd-password-input',\n '[attr.data-revealed]': 'control()?.revealed() ? \"\" : null',\n },\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class VdPasswordInputGroup {\n /** Stable toggle name; aria-pressed conveys whether revealing is enabled. */\n readonly revealLabel = input<string>();\n /** Text inputs resolved against the active VD_LOCALE. */\n protected readonly t = vdTexts('passwordInput', { revealLabel: this.revealLabel });\n protected readonly control = contentChild(VdPasswordInput);\n}\n\nexport const VD_PASSWORD_INPUT = [VdPasswordInputGroup, VdPasswordInput] as const;\n"],"mappings":";;;;;;;AAwBA,IAAa,kBAAb,MAAa,wBAAwB,QAAO;CACjC,UAA4B,OAAO,UAAU,CAAC,CAAC;CACvC,WAAW,OAAO,QAAQ;CAC1B,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAC/B,WAAW,KAAK,QAAQ,WAAU;CAC1B,cAAc,OAAO,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAClC,SAAS,KAAK,YAAY,WAAU;CAE7C,cAAA;EACE,MAAK;EACL,uBAAsB;GACpB,KAAK,YAAY,IAAI,KAAK,QAAQ,QAAQ;GAC1C,IAAI,KAAK,QAAQ,YAAY,KAAK,QAAO,GAAI,KAAK,WAAW,KAAK;EACpE,CAAC;CACH;CAGA,qBAAqB,OAAiB;EACpC,IAAI,MAAM,WAAW,KAAK,KAAK,SAAS,kBAAkB,KAAK,SAAS,MAAM,eAAc;CAC9F;CAEA,SAAM;EACJ,IAAI,KAAK,QAAQ,UAAU;EAC3B,KAAK,WAAW,CAAC,KAAK,QAAO,CAAE;CACjC;CAEQ,WAAW,SAAgB;EACjC,MAAM,EAAE,gBAAgB,cAAc,oBAAoB,eAAe,KAAK;EAC9E,KAAK,QAAQ,IAAI,OAAO;EAExB,KAAK,QAAQ,OAAO,UAAU,SAAS;EACvC,IAAI,mBAAmB,QAAQ,iBAAiB,MAC9C,KAAK,QAAQ,kBAAkB,gBAAgB,cAAc,sBAAsB,MAAM;EAC3F,KAAK,QAAQ,aAAa;CAC5B;CAlCW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAe,M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