@ojiepermana/angular 21.2.2 → 21.3.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/README.md +119 -23
- package/fesm2022/ojiepermana-angular-layout-theme.mjs +581 -0
- package/fesm2022/ojiepermana-angular-layout-theme.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-layout.mjs +2 -1
- package/fesm2022/ojiepermana-angular-layout.mjs.map +1 -1
- package/fesm2022/ojiepermana-angular-navigation-icon.mjs +59 -0
- package/fesm2022/ojiepermana-angular-navigation-icon.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-navigation.mjs +6 -58
- package/fesm2022/ojiepermana-angular-navigation.mjs.map +1 -1
- package/fesm2022/ojiepermana-angular-theme.mjs +1 -1
- package/fesm2022/ojiepermana-angular-theme.mjs.map +1 -1
- package/fesm2022/ojiepermana-angular-ui-component-accordion.mjs +174 -0
- package/fesm2022/ojiepermana-angular-ui-component-accordion.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-alert-dialog.mjs +242 -0
- package/fesm2022/ojiepermana-angular-ui-component-alert-dialog.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-alert.mjs +90 -0
- package/fesm2022/ojiepermana-angular-ui-component-alert.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-aspect-ratio.mjs +33 -0
- package/fesm2022/ojiepermana-angular-ui-component-aspect-ratio.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-avatar.mjs +123 -0
- package/fesm2022/ojiepermana-angular-ui-component-avatar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-badge.mjs +47 -0
- package/fesm2022/ojiepermana-angular-ui-component-badge.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-breadcrumb.mjs +186 -0
- package/fesm2022/ojiepermana-angular-ui-component-breadcrumb.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-button-group.mjs +95 -0
- package/fesm2022/ojiepermana-angular-ui-component-button-group.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-button.mjs +64 -0
- package/fesm2022/ojiepermana-angular-ui-component-button.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-calendar.mjs +78 -0
- package/fesm2022/ojiepermana-angular-ui-component-calendar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-card.mjs +137 -0
- package/fesm2022/ojiepermana-angular-ui-component-card.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-carousel.mjs +310 -0
- package/fesm2022/ojiepermana-angular-ui-component-carousel.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-area.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-area.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-bar.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-bar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-line.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-line.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-pie.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-pie.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-radar.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-radar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-radial.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-radial.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-scatter.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-chart-scatter.mjs.map +1 -0
- package/fesm2022/{ojiepermana-angular-chart.mjs → ojiepermana-angular-ui-component-chart.mjs} +2 -2
- package/fesm2022/ojiepermana-angular-ui-component-chart.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-checkbox.mjs +104 -0
- package/fesm2022/ojiepermana-angular-ui-component-checkbox.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-collapsible.mjs +116 -0
- package/fesm2022/ojiepermana-angular-ui-component-collapsible.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-combobox.mjs +263 -0
- package/fesm2022/ojiepermana-angular-ui-component-combobox.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-command.mjs +268 -0
- package/fesm2022/ojiepermana-angular-ui-component-command.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-context-menu.mjs +100 -0
- package/fesm2022/ojiepermana-angular-ui-component-context-menu.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-date-picker.mjs +155 -0
- package/fesm2022/ojiepermana-angular-ui-component-date-picker.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-dialog.mjs +262 -0
- package/fesm2022/ojiepermana-angular-ui-component-dialog.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-drawer.mjs +6 -0
- package/fesm2022/ojiepermana-angular-ui-component-drawer.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-dropdown-menu.mjs +458 -0
- package/fesm2022/ojiepermana-angular-ui-component-dropdown-menu.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-form.mjs +208 -0
- package/fesm2022/ojiepermana-angular-ui-component-form.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-input-group.mjs +164 -0
- package/fesm2022/ojiepermana-angular-ui-component-input-group.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-input.mjs +43 -0
- package/fesm2022/ojiepermana-angular-ui-component-input.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-item.mjs +241 -0
- package/fesm2022/ojiepermana-angular-ui-component-item.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-label.mjs +30 -0
- package/fesm2022/ojiepermana-angular-ui-component-label.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-pagination.mjs +192 -0
- package/fesm2022/ojiepermana-angular-ui-component-pagination.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-popover.mjs +163 -0
- package/fesm2022/ojiepermana-angular-ui-component-popover.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-progress.mjs +53 -0
- package/fesm2022/ojiepermana-angular-ui-component-progress.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-radio.mjs +92 -0
- package/fesm2022/ojiepermana-angular-ui-component-radio.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-scroll-area.mjs +48 -0
- package/fesm2022/ojiepermana-angular-ui-component-scroll-area.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-select.mjs +131 -0
- package/fesm2022/ojiepermana-angular-ui-component-select.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-separator.mjs +33 -0
- package/fesm2022/ojiepermana-angular-ui-component-separator.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-sheet.mjs +235 -0
- package/fesm2022/ojiepermana-angular-ui-component-sheet.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-skeleton.mjs +29 -0
- package/fesm2022/ojiepermana-angular-ui-component-skeleton.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-slider.mjs +29 -0
- package/fesm2022/ojiepermana-angular-ui-component-slider.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-switch.mjs +84 -0
- package/fesm2022/ojiepermana-angular-ui-component-switch.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-table.mjs +139 -0
- package/fesm2022/ojiepermana-angular-ui-component-table.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-tabs.mjs +252 -0
- package/fesm2022/ojiepermana-angular-ui-component-tabs.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-textarea.mjs +37 -0
- package/fesm2022/ojiepermana-angular-ui-component-textarea.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-toast.mjs +47 -0
- package/fesm2022/ojiepermana-angular-ui-component-toast.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-tooltip.mjs +56 -0
- package/fesm2022/ojiepermana-angular-ui-component-tooltip.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-ui-component-utils.mjs +13 -0
- package/fesm2022/ojiepermana-angular-ui-component-utils.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular.mjs +5 -3
- package/fesm2022/ojiepermana-angular.mjs.map +1 -1
- package/layout/theme/package.json +4 -0
- package/navigation-icon/package.json +4 -0
- package/package.json +212 -12
- package/types/ojiepermana-angular-layout-theme.d.ts +205 -0
- package/types/ojiepermana-angular-layout.d.ts +1 -1
- package/types/ojiepermana-angular-navigation-icon.d.ts +17 -0
- package/types/ojiepermana-angular-navigation.d.ts +2 -20
- package/types/ojiepermana-angular-ui-component-accordion.d.ts +51 -0
- package/types/ojiepermana-angular-ui-component-alert-dialog.d.ts +93 -0
- package/types/ojiepermana-angular-ui-component-alert.d.ts +37 -0
- package/types/ojiepermana-angular-ui-component-aspect-ratio.d.ts +12 -0
- package/types/ojiepermana-angular-ui-component-avatar.d.ts +51 -0
- package/types/ojiepermana-angular-ui-component-badge.d.ts +19 -0
- package/types/ojiepermana-angular-ui-component-breadcrumb.d.ts +46 -0
- package/types/ojiepermana-angular-ui-component-button-group.d.ts +26 -0
- package/types/ojiepermana-angular-ui-component-button.d.ts +22 -0
- package/types/ojiepermana-angular-ui-component-calendar.d.ts +33 -0
- package/types/ojiepermana-angular-ui-component-card.d.ts +60 -0
- package/types/ojiepermana-angular-ui-component-carousel.d.ts +86 -0
- package/types/ojiepermana-angular-ui-component-chart-area.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-bar.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-line.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-pie.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-radar.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-radial.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-chart-scatter.d.ts +1 -0
- package/types/{ojiepermana-angular-chart.d.ts → ojiepermana-angular-ui-component-chart.d.ts} +15 -15
- package/types/ojiepermana-angular-ui-component-checkbox.d.ts +35 -0
- package/types/ojiepermana-angular-ui-component-collapsible.d.ts +42 -0
- package/types/ojiepermana-angular-ui-component-combobox.d.ts +51 -0
- package/types/ojiepermana-angular-ui-component-command.d.ts +99 -0
- package/types/ojiepermana-angular-ui-component-context-menu.d.ts +35 -0
- package/types/ojiepermana-angular-ui-component-date-picker.d.ts +41 -0
- package/types/ojiepermana-angular-ui-component-dialog.d.ts +87 -0
- package/types/ojiepermana-angular-ui-component-drawer.d.ts +1 -0
- package/types/ojiepermana-angular-ui-component-dropdown-menu.d.ts +135 -0
- package/types/ojiepermana-angular-ui-component-form.d.ts +92 -0
- package/types/ojiepermana-angular-ui-component-input-group.d.ts +51 -0
- package/types/ojiepermana-angular-ui-component-input.d.ts +16 -0
- package/types/ojiepermana-angular-ui-component-item.d.ts +88 -0
- package/types/ojiepermana-angular-ui-component-label.d.ts +11 -0
- package/types/ojiepermana-angular-ui-component-pagination.d.ts +27 -0
- package/types/ojiepermana-angular-ui-component-popover.d.ts +43 -0
- package/types/ojiepermana-angular-ui-component-progress.d.ts +17 -0
- package/types/ojiepermana-angular-ui-component-radio.d.ts +34 -0
- package/types/ojiepermana-angular-ui-component-scroll-area.d.ts +19 -0
- package/types/ojiepermana-angular-ui-component-select.d.ts +45 -0
- package/types/ojiepermana-angular-ui-component-separator.d.ts +14 -0
- package/types/ojiepermana-angular-ui-component-sheet.d.ts +74 -0
- package/types/ojiepermana-angular-ui-component-skeleton.d.ts +10 -0
- package/types/ojiepermana-angular-ui-component-slider.d.ts +16 -0
- package/types/ojiepermana-angular-ui-component-switch.d.ts +30 -0
- package/types/ojiepermana-angular-ui-component-table.d.ts +52 -0
- package/types/ojiepermana-angular-ui-component-tabs.d.ts +92 -0
- package/types/ojiepermana-angular-ui-component-textarea.d.ts +12 -0
- package/types/ojiepermana-angular-ui-component-toast.d.ts +29 -0
- package/types/ojiepermana-angular-ui-component-tooltip.d.ts +22 -0
- package/types/ojiepermana-angular-ui-component-utils.d.ts +5 -0
- package/ui/component/accordion/package.json +4 -0
- package/ui/component/alert/package.json +4 -0
- package/ui/component/alert-dialog/package.json +4 -0
- package/ui/component/aspect-ratio/package.json +4 -0
- package/ui/component/avatar/package.json +4 -0
- package/ui/component/badge/package.json +4 -0
- package/ui/component/breadcrumb/package.json +4 -0
- package/ui/component/button/package.json +4 -0
- package/ui/component/button-group/package.json +4 -0
- package/ui/component/calendar/package.json +4 -0
- package/ui/component/card/package.json +4 -0
- package/ui/component/carousel/package.json +4 -0
- package/ui/component/chart/README.md +249 -0
- package/ui/component/chart/area/package.json +4 -0
- package/ui/component/chart/bar/package.json +4 -0
- package/ui/component/chart/line/package.json +4 -0
- package/ui/component/chart/package.json +4 -0
- package/ui/component/chart/pie/package.json +4 -0
- package/ui/component/chart/radar/package.json +4 -0
- package/ui/component/chart/radial/package.json +4 -0
- package/ui/component/chart/scatter/package.json +4 -0
- package/ui/component/checkbox/package.json +4 -0
- package/ui/component/collapsible/package.json +4 -0
- package/ui/component/combobox/package.json +4 -0
- package/ui/component/command/package.json +4 -0
- package/ui/component/context-menu/package.json +4 -0
- package/ui/component/date-picker/package.json +4 -0
- package/ui/component/dialog/package.json +4 -0
- package/ui/component/drawer/package.json +4 -0
- package/ui/component/dropdown-menu/package.json +4 -0
- package/ui/component/form/package.json +4 -0
- package/ui/component/input/package.json +4 -0
- package/ui/component/input-group/package.json +4 -0
- package/ui/component/item/package.json +4 -0
- package/ui/component/label/package.json +4 -0
- package/ui/component/pagination/package.json +4 -0
- package/ui/component/popover/package.json +4 -0
- package/ui/component/progress/package.json +4 -0
- package/ui/component/radio/package.json +4 -0
- package/ui/component/scroll-area/package.json +4 -0
- package/ui/component/select/package.json +4 -0
- package/ui/component/separator/package.json +4 -0
- package/ui/component/sheet/package.json +4 -0
- package/ui/component/skeleton/package.json +4 -0
- package/ui/component/slider/package.json +4 -0
- package/ui/component/switch/package.json +4 -0
- package/ui/component/table/package.json +4 -0
- package/ui/component/tabs/package.json +4 -0
- package/ui/component/textarea/package.json +4 -0
- package/ui/component/toast/package.json +4 -0
- package/ui/component/tooltip/package.json +4 -0
- package/ui/component/utils/package.json +4 -0
- package/chart/README.md +0 -0
- package/chart/package.json +0 -4
- package/component/package.json +0 -4
- package/fesm2022/ojiepermana-angular-chart.mjs.map +0 -1
- package/fesm2022/ojiepermana-angular-component.mjs +0 -5774
- package/fesm2022/ojiepermana-angular-component.mjs.map +0 -1
- package/types/ojiepermana-angular-component.d.ts +0 -1927
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, model, input, signal, computed, forwardRef, ChangeDetectionStrategy, Component, inject, ElementRef, output, DestroyRef } from '@angular/core';
|
|
3
|
+
import { cn } from '@ojiepermana/angular/component/utils';
|
|
4
|
+
|
|
5
|
+
/** Base class exposed to children for context lookup. */
|
|
6
|
+
class CommandContextBase {
|
|
7
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandContextBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
8
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.14", type: CommandContextBase, isStandalone: true, ngImport: i0 });
|
|
9
|
+
}
|
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandContextBase, decorators: [{
|
|
11
|
+
type: Directive
|
|
12
|
+
}] });
|
|
13
|
+
class CommandComponent extends CommandContextBase {
|
|
14
|
+
query = model('', ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
15
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
16
|
+
items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
17
|
+
activeIndex = signal(0, ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
18
|
+
classes = computed(() => cn('flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
19
|
+
matches(text) {
|
|
20
|
+
const q = this.query().trim().toLowerCase();
|
|
21
|
+
if (!q)
|
|
22
|
+
return true;
|
|
23
|
+
return text.toLowerCase().includes(q);
|
|
24
|
+
}
|
|
25
|
+
registerItem(item) {
|
|
26
|
+
this.items.update((list) => [...list, item]);
|
|
27
|
+
}
|
|
28
|
+
unregisterItem(item) {
|
|
29
|
+
this.items.update((list) => list.filter((i) => i !== item));
|
|
30
|
+
}
|
|
31
|
+
/** Items currently visible (not filtered out). */
|
|
32
|
+
visibleItems() {
|
|
33
|
+
return this.items().filter((it) => it.visible());
|
|
34
|
+
}
|
|
35
|
+
focusNext(delta) {
|
|
36
|
+
const vis = this.visibleItems();
|
|
37
|
+
if (vis.length === 0)
|
|
38
|
+
return;
|
|
39
|
+
const active = vis.findIndex((i) => i.active());
|
|
40
|
+
const idx = active < 0 ? 0 : (active + delta + vis.length) % vis.length;
|
|
41
|
+
vis.forEach((i, k) => i._setActive(k === idx));
|
|
42
|
+
vis[idx].focus();
|
|
43
|
+
}
|
|
44
|
+
focusFirst() {
|
|
45
|
+
const vis = this.visibleItems();
|
|
46
|
+
vis.forEach((i, k) => i._setActive(k === 0));
|
|
47
|
+
vis[0]?.focus();
|
|
48
|
+
}
|
|
49
|
+
hasVisibleItems() {
|
|
50
|
+
return this.visibleItems().length > 0;
|
|
51
|
+
}
|
|
52
|
+
activateOnly(item) {
|
|
53
|
+
this.items().forEach((entry) => entry._setActive(entry === item));
|
|
54
|
+
}
|
|
55
|
+
/** Returns the first visible item's text if any. Used when user hits Enter with no active. */
|
|
56
|
+
getActive() {
|
|
57
|
+
return this.visibleItems().find((i) => i.active()) ?? this.visibleItems()[0] ?? null;
|
|
58
|
+
}
|
|
59
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
60
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandComponent, isStandalone: true, selector: "ui-command", inputs: { query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { query: "queryChange" }, host: { properties: { "class": "classes()" } }, providers: [{ provide: CommandContextBase, useExisting: forwardRef(() => CommandComponent) }], usesInheritance: true, ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
61
|
+
}
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandComponent, decorators: [{
|
|
63
|
+
type: Component,
|
|
64
|
+
args: [{
|
|
65
|
+
selector: 'ui-command',
|
|
66
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
67
|
+
providers: [{ provide: CommandContextBase, useExisting: forwardRef(() => CommandComponent) }],
|
|
68
|
+
host: { '[class]': 'classes()' },
|
|
69
|
+
template: `<ng-content />`,
|
|
70
|
+
}]
|
|
71
|
+
}], propDecorators: { query: [{ type: i0.Input, args: [{ isSignal: true, alias: "query", required: false }] }, { type: i0.Output, args: ["queryChange"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
72
|
+
class CommandInputComponent {
|
|
73
|
+
ctx = inject(CommandComponent);
|
|
74
|
+
placeholder = input('Type a command or search…', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
75
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
76
|
+
classes = computed(() => cn('flex h-11 w-full rounded-md bg-transparent px-3 py-3 text-sm outline-none', 'placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50', 'border-b border-border', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
77
|
+
onInput(e) {
|
|
78
|
+
this.ctx.query.set(e.target.value);
|
|
79
|
+
queueMicrotask(() => this.ctx.focusFirst());
|
|
80
|
+
}
|
|
81
|
+
onArrow(e, delta) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
this.ctx.focusNext(delta);
|
|
84
|
+
}
|
|
85
|
+
onEnter(e) {
|
|
86
|
+
const active = this.ctx.getActive();
|
|
87
|
+
if (active) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
active._select(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
93
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandInputComponent, isStandalone: true, selector: "input[ui-command-input]", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "text", "role": "combobox", "aria-autocomplete": "list", "aria-expanded": "true", "autocomplete": "off" }, listeners: { "input": "onInput($any($event))", "keydown.arrowDown": "onArrow($any($event), 1)", "keydown.arrowUp": "onArrow($any($event), -1)", "keydown.enter": "onEnter($any($event))" }, properties: { "class": "classes()", "value": "ctx.query()", "placeholder": "placeholder()" } }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
94
|
+
}
|
|
95
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandInputComponent, decorators: [{
|
|
96
|
+
type: Component,
|
|
97
|
+
args: [{
|
|
98
|
+
selector: 'input[ui-command-input]',
|
|
99
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
100
|
+
host: {
|
|
101
|
+
'[class]': 'classes()',
|
|
102
|
+
type: 'text',
|
|
103
|
+
role: 'combobox',
|
|
104
|
+
'aria-autocomplete': 'list',
|
|
105
|
+
'aria-expanded': 'true',
|
|
106
|
+
autocomplete: 'off',
|
|
107
|
+
'[value]': 'ctx.query()',
|
|
108
|
+
'[placeholder]': 'placeholder()',
|
|
109
|
+
'(input)': 'onInput($any($event))',
|
|
110
|
+
'(keydown.arrowDown)': 'onArrow($any($event), 1)',
|
|
111
|
+
'(keydown.arrowUp)': 'onArrow($any($event), -1)',
|
|
112
|
+
'(keydown.enter)': 'onEnter($any($event))',
|
|
113
|
+
},
|
|
114
|
+
template: ``,
|
|
115
|
+
}]
|
|
116
|
+
}], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
117
|
+
class CommandListComponent {
|
|
118
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
119
|
+
classes = computed(() => cn('max-h-[300px] overflow-y-auto overflow-x-hidden p-1', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
120
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
121
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandListComponent, isStandalone: true, selector: "ui-command-list", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "listbox" }, properties: { "class": "classes()" } }, ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
122
|
+
}
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandListComponent, decorators: [{
|
|
124
|
+
type: Component,
|
|
125
|
+
args: [{
|
|
126
|
+
selector: 'ui-command-list',
|
|
127
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
128
|
+
host: { '[class]': 'classes()', role: 'listbox' },
|
|
129
|
+
template: `<ng-content />`,
|
|
130
|
+
}]
|
|
131
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
132
|
+
class CommandEmptyComponent {
|
|
133
|
+
ctx = inject(CommandComponent);
|
|
134
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
135
|
+
classes = computed(() => cn('py-6 text-center text-sm text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
136
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandEmptyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
137
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandEmptyComponent, isStandalone: true, selector: "ui-command-empty", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()", "hidden": "ctx.hasVisibleItems()" } }, ngImport: i0, template: `<ng-content>No results found.</ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
138
|
+
}
|
|
139
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandEmptyComponent, decorators: [{
|
|
140
|
+
type: Component,
|
|
141
|
+
args: [{
|
|
142
|
+
selector: 'ui-command-empty',
|
|
143
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
144
|
+
host: {
|
|
145
|
+
'[class]': 'classes()',
|
|
146
|
+
'[hidden]': 'ctx.hasVisibleItems()',
|
|
147
|
+
},
|
|
148
|
+
template: `<ng-content>No results found.</ng-content>`,
|
|
149
|
+
}]
|
|
150
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
151
|
+
class CommandGroupComponent {
|
|
152
|
+
heading = input(null, ...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
153
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
154
|
+
classes = computed(() => cn('overflow-hidden p-1 text-foreground', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
155
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
156
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: CommandGroupComponent, isStandalone: true, selector: "ui-command-group", inputs: { heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "class": "classes()" } }, ngImport: i0, template: `
|
|
157
|
+
@if (heading()) {
|
|
158
|
+
<div class="px-2 py-1.5 text-xs font-medium text-muted-foreground">{{ heading() }}</div>
|
|
159
|
+
}
|
|
160
|
+
<ng-content />
|
|
161
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
162
|
+
}
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandGroupComponent, decorators: [{
|
|
164
|
+
type: Component,
|
|
165
|
+
args: [{
|
|
166
|
+
selector: 'ui-command-group',
|
|
167
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
168
|
+
host: { '[class]': 'classes()', role: 'group' },
|
|
169
|
+
template: `
|
|
170
|
+
@if (heading()) {
|
|
171
|
+
<div class="px-2 py-1.5 text-xs font-medium text-muted-foreground">{{ heading() }}</div>
|
|
172
|
+
}
|
|
173
|
+
<ng-content />
|
|
174
|
+
`,
|
|
175
|
+
}]
|
|
176
|
+
}], propDecorators: { heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
177
|
+
class CommandSeparatorComponent {
|
|
178
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
179
|
+
classes = computed(() => cn('-mx-1 h-px bg-border block', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
180
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandSeparatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
181
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandSeparatorComponent, isStandalone: true, selector: "ui-command-separator", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "separator" }, properties: { "class": "classes()" } }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
182
|
+
}
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandSeparatorComponent, decorators: [{
|
|
184
|
+
type: Component,
|
|
185
|
+
args: [{
|
|
186
|
+
selector: 'ui-command-separator',
|
|
187
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
188
|
+
host: { '[class]': 'classes()', role: 'separator' },
|
|
189
|
+
template: '',
|
|
190
|
+
}]
|
|
191
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
192
|
+
class CommandItemComponent {
|
|
193
|
+
ctx = inject(CommandComponent);
|
|
194
|
+
el = inject(ElementRef);
|
|
195
|
+
value = input('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
196
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
197
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
198
|
+
selected = output();
|
|
199
|
+
active = signal(false, ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
200
|
+
visible = computed(() => {
|
|
201
|
+
const text = this.value() || this.el.nativeElement.textContent || '';
|
|
202
|
+
return this.ctx.matches(text);
|
|
203
|
+
}, ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
204
|
+
classes = computed(() => cn('relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none', 'data-[active=true]:bg-accent data-[active=true]:text-accent-foreground', 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
205
|
+
constructor() {
|
|
206
|
+
this.ctx.registerItem(this);
|
|
207
|
+
inject(DestroyRef).onDestroy(() => this.ctx.unregisterItem(this));
|
|
208
|
+
}
|
|
209
|
+
focus() {
|
|
210
|
+
this.el.nativeElement.focus();
|
|
211
|
+
}
|
|
212
|
+
_setActive(active) {
|
|
213
|
+
this.active.set(active);
|
|
214
|
+
}
|
|
215
|
+
_select(e) {
|
|
216
|
+
if (this.disabled())
|
|
217
|
+
return;
|
|
218
|
+
this.selected.emit(e);
|
|
219
|
+
}
|
|
220
|
+
onHover() {
|
|
221
|
+
if (this.disabled())
|
|
222
|
+
return;
|
|
223
|
+
this.ctx.activateOnly(this);
|
|
224
|
+
}
|
|
225
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
226
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandItemComponent, isStandalone: true, selector: "ui-command-item, button[ui-command-item]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected" }, host: { listeners: { "click": "_select($any($event))", "mousemove": "onHover()" }, properties: { "class": "classes()", "attr.role": "\"option\"", "attr.tabindex": "-1", "attr.aria-selected": "active()", "attr.data-active": "active() ? \"true\" : null", "attr.data-disabled": "disabled() ? \"true\" : null", "hidden": "!visible()" } }, ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
227
|
+
}
|
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandItemComponent, decorators: [{
|
|
229
|
+
type: Component,
|
|
230
|
+
args: [{
|
|
231
|
+
selector: 'ui-command-item, button[ui-command-item]',
|
|
232
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
233
|
+
host: {
|
|
234
|
+
'[class]': 'classes()',
|
|
235
|
+
'[attr.role]': '"option"',
|
|
236
|
+
'[attr.tabindex]': '-1',
|
|
237
|
+
'[attr.aria-selected]': 'active()',
|
|
238
|
+
'[attr.data-active]': 'active() ? "true" : null',
|
|
239
|
+
'[attr.data-disabled]': 'disabled() ? "true" : null',
|
|
240
|
+
'[hidden]': '!visible()',
|
|
241
|
+
'(click)': '_select($any($event))',
|
|
242
|
+
'(mousemove)': 'onHover()',
|
|
243
|
+
},
|
|
244
|
+
template: `<ng-content />`,
|
|
245
|
+
}]
|
|
246
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], selected: [{ type: i0.Output, args: ["selected"] }] } });
|
|
247
|
+
class CommandShortcutComponent {
|
|
248
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
249
|
+
classes = computed(() => cn('ml-auto text-xs tracking-widest text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandShortcutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
251
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: CommandShortcutComponent, isStandalone: true, selector: "span[ui-command-shortcut]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
252
|
+
}
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CommandShortcutComponent, decorators: [{
|
|
254
|
+
type: Component,
|
|
255
|
+
args: [{
|
|
256
|
+
selector: 'span[ui-command-shortcut]',
|
|
257
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
258
|
+
host: { '[class]': 'classes()' },
|
|
259
|
+
template: `<ng-content />`,
|
|
260
|
+
}]
|
|
261
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Generated bundle index. Do not edit.
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
export { CommandComponent, CommandContextBase, CommandEmptyComponent, CommandGroupComponent, CommandInputComponent, CommandItemComponent, CommandListComponent, CommandSeparatorComponent, CommandShortcutComponent };
|
|
268
|
+
//# sourceMappingURL=ojiepermana-angular-ui-component-command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ojiepermana-angular-ui-component-command.mjs","sources":["../../../projects/angular/ui/component/command/src/lib/command.component.ts","../../../projects/angular/ui/component/command/ojiepermana-angular-ui-component-command.ts"],"sourcesContent":["import {\n AfterContentInit,\n ChangeDetectionStrategy,\n Component,\n ContentChildren,\n DestroyRef,\n Directive,\n ElementRef,\n QueryList,\n ViewChild,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n model,\n output,\n signal,\n} from '@angular/core';\nimport { cn } from '@ojiepermana/angular/component/utils';\n\n/** Base class exposed to children for context lookup. */\n@Directive()\nexport abstract class CommandContextBase {\n abstract query: ReturnType<typeof model<string>>;\n abstract matches(text: string): boolean;\n abstract registerItem(item: CommandItemComponent): void;\n abstract unregisterItem(item: CommandItemComponent): void;\n abstract focusNext(delta: number): void;\n abstract focusFirst(): void;\n abstract hasVisibleItems(): boolean;\n abstract activateOnly(item: CommandItemComponent): void;\n}\n\n@Component({\n selector: 'ui-command',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{ provide: CommandContextBase, useExisting: forwardRef(() => CommandComponent) }],\n host: { '[class]': 'classes()' },\n template: `<ng-content />`,\n})\nexport class CommandComponent extends CommandContextBase {\n readonly query = model<string>('');\n readonly class = input<string>('');\n\n private readonly items = signal<CommandItemComponent[]>([]);\n private readonly activeIndex = signal(0);\n\n protected readonly classes = computed(() =>\n cn('flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground', this.class()),\n );\n\n override matches(text: string): boolean {\n const q = this.query().trim().toLowerCase();\n if (!q) return true;\n return text.toLowerCase().includes(q);\n }\n\n override registerItem(item: CommandItemComponent): void {\n this.items.update((list) => [...list, item]);\n }\n\n override unregisterItem(item: CommandItemComponent): void {\n this.items.update((list) => list.filter((i) => i !== item));\n }\n\n /** Items currently visible (not filtered out). */\n private visibleItems(): CommandItemComponent[] {\n return this.items().filter((it) => it.visible());\n }\n\n override focusNext(delta: number): void {\n const vis = this.visibleItems();\n if (vis.length === 0) return;\n const active = vis.findIndex((i) => i.active());\n const idx = active < 0 ? 0 : (active + delta + vis.length) % vis.length;\n vis.forEach((i, k) => i._setActive(k === idx));\n vis[idx].focus();\n }\n\n override focusFirst(): void {\n const vis = this.visibleItems();\n vis.forEach((i, k) => i._setActive(k === 0));\n vis[0]?.focus();\n }\n\n override hasVisibleItems(): boolean {\n return this.visibleItems().length > 0;\n }\n\n override activateOnly(item: CommandItemComponent): void {\n this.items().forEach((entry) => entry._setActive(entry === item));\n }\n\n /** Returns the first visible item's text if any. Used when user hits Enter with no active. */\n getActive(): CommandItemComponent | null {\n return this.visibleItems().find((i) => i.active()) ?? this.visibleItems()[0] ?? null;\n }\n}\n\n@Component({\n selector: 'input[ui-command-input]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class]': 'classes()',\n type: 'text',\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': 'true',\n autocomplete: 'off',\n '[value]': 'ctx.query()',\n '[placeholder]': 'placeholder()',\n '(input)': 'onInput($any($event))',\n '(keydown.arrowDown)': 'onArrow($any($event), 1)',\n '(keydown.arrowUp)': 'onArrow($any($event), -1)',\n '(keydown.enter)': 'onEnter($any($event))',\n },\n template: ``,\n})\nexport class CommandInputComponent {\n protected readonly ctx = inject(CommandComponent);\n readonly placeholder = input<string>('Type a command or search…');\n readonly class = input<string>('');\n\n protected readonly classes = computed(() =>\n cn(\n 'flex h-11 w-full rounded-md bg-transparent px-3 py-3 text-sm outline-none',\n 'placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',\n 'border-b border-border',\n this.class(),\n ),\n );\n\n protected onInput(e: Event): void {\n this.ctx.query.set((e.target as HTMLInputElement).value);\n queueMicrotask(() => this.ctx.focusFirst());\n }\n\n protected onArrow(e: KeyboardEvent, delta: number): void {\n e.preventDefault();\n this.ctx.focusNext(delta);\n }\n\n protected onEnter(e: KeyboardEvent): void {\n const active = this.ctx.getActive();\n if (active) {\n e.preventDefault();\n active._select(e);\n }\n }\n}\n\n@Component({\n selector: 'ui-command-list',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()', role: 'listbox' },\n template: `<ng-content />`,\n})\nexport class CommandListComponent {\n readonly class = input<string>('');\n protected readonly classes = computed(() => cn('max-h-[300px] overflow-y-auto overflow-x-hidden p-1', this.class()));\n}\n\n@Component({\n selector: 'ui-command-empty',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class]': 'classes()',\n '[hidden]': 'ctx.hasVisibleItems()',\n },\n template: `<ng-content>No results found.</ng-content>`,\n})\nexport class CommandEmptyComponent {\n protected readonly ctx = inject(CommandComponent);\n readonly class = input<string>('');\n protected readonly classes = computed(() => cn('py-6 text-center text-sm text-muted-foreground', this.class()));\n}\n\n@Component({\n selector: 'ui-command-group',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()', role: 'group' },\n template: `\n @if (heading()) {\n <div class=\"px-2 py-1.5 text-xs font-medium text-muted-foreground\">{{ heading() }}</div>\n }\n <ng-content />\n `,\n})\nexport class CommandGroupComponent {\n readonly heading = input<string | null>(null);\n readonly class = input<string>('');\n protected readonly classes = computed(() => cn('overflow-hidden p-1 text-foreground', this.class()));\n}\n\n@Component({\n selector: 'ui-command-separator',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()', role: 'separator' },\n template: '',\n})\nexport class CommandSeparatorComponent {\n readonly class = input<string>('');\n protected readonly classes = computed(() => cn('-mx-1 h-px bg-border block', this.class()));\n}\n\n@Component({\n selector: 'ui-command-item, button[ui-command-item]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class]': 'classes()',\n '[attr.role]': '\"option\"',\n '[attr.tabindex]': '-1',\n '[attr.aria-selected]': 'active()',\n '[attr.data-active]': 'active() ? \"true\" : null',\n '[attr.data-disabled]': 'disabled() ? \"true\" : null',\n '[hidden]': '!visible()',\n '(click)': '_select($any($event))',\n '(mousemove)': 'onHover()',\n },\n template: `<ng-content />`,\n})\nexport class CommandItemComponent {\n protected readonly ctx = inject(CommandComponent);\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n readonly value = input<string>('');\n readonly disabled = input<boolean>(false);\n readonly class = input<string>('');\n\n readonly selected = output<MouseEvent | KeyboardEvent>();\n\n readonly active = signal(false);\n\n readonly visible = computed(() => {\n const text = this.value() || this.el.nativeElement.textContent || '';\n return this.ctx.matches(text);\n });\n\n protected readonly classes = computed(() =>\n cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none',\n 'data-[active=true]:bg-accent data-[active=true]:text-accent-foreground',\n 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50',\n this.class(),\n ),\n );\n\n constructor() {\n this.ctx.registerItem(this);\n inject(DestroyRef).onDestroy(() => this.ctx.unregisterItem(this));\n }\n\n focus(): void {\n this.el.nativeElement.focus();\n }\n\n _setActive(active: boolean): void {\n this.active.set(active);\n }\n\n _select(e: MouseEvent | KeyboardEvent): void {\n if (this.disabled()) return;\n this.selected.emit(e);\n }\n\n protected onHover(): void {\n if (this.disabled()) return;\n this.ctx.activateOnly(this);\n }\n}\n\n@Component({\n selector: 'span[ui-command-shortcut]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()' },\n template: `<ng-content />`,\n})\nexport class CommandShortcutComponent {\n readonly class = input<string>('');\n protected readonly classes = computed(() =>\n cn('ml-auto text-xs tracking-widest text-muted-foreground', this.class()),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAqBA;MAEsB,kBAAkB,CAAA;wGAAlB,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;4FAAlB,kBAAkB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;4FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBADvC;;AAmBK,MAAO,gBAAiB,SAAQ,kBAAkB,CAAA;AAC7C,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,4EAAC;AACzB,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,4EAAC;AAEjB,IAAA,KAAK,GAAG,MAAM,CAAyB,EAAE,4EAAC;AAC1C,IAAA,WAAW,GAAG,MAAM,CAAC,CAAC,kFAAC;AAErB,IAAA,OAAO,GAAG,QAAQ,CAAC,MACpC,EAAE,CAAC,2FAA2F,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,8EAC9G;AAEQ,IAAA,OAAO,CAAC,IAAY,EAAA;AAC3B,QAAA,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAC3C,QAAA,IAAI,CAAC,CAAC;AAAE,YAAA,OAAO,IAAI;QACnB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC;AAES,IAAA,YAAY,CAAC,IAA0B,EAAA;AAC9C,QAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC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A;AACT,oBAAA,QAAQ,EAAE,2BAA2B;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE;AAChC,oBAAA,QAAQ,EAAE,CAAA,cAAA,CAAgB;AAC3B,iBAAA;;;ACrRD;;AAEG;;;;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Overlay } from '@angular/cdk/overlay';
|
|
2
|
+
import { TemplatePortal } from '@angular/cdk/portal';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, ViewContainerRef, ElementRef, DestroyRef, input, output, signal, Directive } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import { merge } from 'rxjs';
|
|
7
|
+
import { filter } from 'rxjs/operators';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Opens a menu anchored to the cursor when the host fires `contextmenu`.
|
|
11
|
+
* Reuses `<ng-template uiMenuContent>` from the dropdown-menu entry.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <div [uiContextMenuTrigger]="menu" class="p-12 border">Right-click me</div>
|
|
15
|
+
* <ng-template uiMenuContent #menu>
|
|
16
|
+
* <ui-menu-surface>
|
|
17
|
+
* <button ui-menu-item>Copy</button>
|
|
18
|
+
* <button ui-menu-item>Paste</button>
|
|
19
|
+
* </ui-menu-surface>
|
|
20
|
+
* </ng-template>
|
|
21
|
+
*/
|
|
22
|
+
class ContextMenuTriggerDirective {
|
|
23
|
+
overlay = inject(Overlay);
|
|
24
|
+
vcr = inject(ViewContainerRef);
|
|
25
|
+
el = inject(ElementRef);
|
|
26
|
+
destroyRef = inject(DestroyRef);
|
|
27
|
+
uiContextMenuTrigger = input.required(...(ngDevMode ? [{ debugName: "uiContextMenuTrigger" }] : /* istanbul ignore next */ []));
|
|
28
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
29
|
+
openedChange = output();
|
|
30
|
+
overlayRef = null;
|
|
31
|
+
isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
32
|
+
onContextMenu(event) {
|
|
33
|
+
if (this.disabled())
|
|
34
|
+
return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
this.close();
|
|
37
|
+
this.openAt(event.clientX, event.clientY);
|
|
38
|
+
}
|
|
39
|
+
onKeyDown(event) {
|
|
40
|
+
const isContextMenuKey = event.key === 'ContextMenu' || (event.shiftKey && event.key === 'F10');
|
|
41
|
+
if (!isContextMenuKey || this.disabled()) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
const rect = this.el.nativeElement.getBoundingClientRect();
|
|
46
|
+
this.close();
|
|
47
|
+
this.openAt(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
48
|
+
}
|
|
49
|
+
openAt(x, y) {
|
|
50
|
+
this.overlayRef = this.overlay.create({
|
|
51
|
+
positionStrategy: this.overlay
|
|
52
|
+
.position()
|
|
53
|
+
.flexibleConnectedTo({ x, y })
|
|
54
|
+
.withPositions([
|
|
55
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
|
|
56
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
|
|
57
|
+
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },
|
|
58
|
+
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },
|
|
59
|
+
]),
|
|
60
|
+
scrollStrategy: this.overlay.scrollStrategies.close(),
|
|
61
|
+
hasBackdrop: false,
|
|
62
|
+
panelClass: 'ui-menu-panel',
|
|
63
|
+
});
|
|
64
|
+
const portal = new TemplatePortal(this.uiContextMenuTrigger().template, this.vcr);
|
|
65
|
+
this.overlayRef.attach(portal);
|
|
66
|
+
merge(this.overlayRef.outsidePointerEvents(), this.overlayRef.keydownEvents().pipe(filter((e) => e.key === 'Escape')), this.overlayRef.detachments())
|
|
67
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
68
|
+
.subscribe(() => this.close());
|
|
69
|
+
this.isOpen.set(true);
|
|
70
|
+
this.openedChange.emit(true);
|
|
71
|
+
}
|
|
72
|
+
close() {
|
|
73
|
+
if (!this.overlayRef)
|
|
74
|
+
return;
|
|
75
|
+
this.overlayRef.dispose();
|
|
76
|
+
this.overlayRef = null;
|
|
77
|
+
this.isOpen.set(false);
|
|
78
|
+
this.openedChange.emit(false);
|
|
79
|
+
}
|
|
80
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: ContextMenuTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
81
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: ContextMenuTriggerDirective, isStandalone: true, selector: "[uiContextMenuTrigger]", inputs: { uiContextMenuTrigger: { classPropertyName: "uiContextMenuTrigger", publicName: "uiContextMenuTrigger", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openedChange: "openedChange" }, host: { listeners: { "contextmenu": "onContextMenu($event)", "keydown": "onKeyDown($event)" } }, exportAs: ["uiContextMenuTrigger"], ngImport: i0 });
|
|
82
|
+
}
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: ContextMenuTriggerDirective, decorators: [{
|
|
84
|
+
type: Directive,
|
|
85
|
+
args: [{
|
|
86
|
+
selector: '[uiContextMenuTrigger]',
|
|
87
|
+
exportAs: 'uiContextMenuTrigger',
|
|
88
|
+
host: {
|
|
89
|
+
'(contextmenu)': 'onContextMenu($event)',
|
|
90
|
+
'(keydown)': 'onKeyDown($event)',
|
|
91
|
+
},
|
|
92
|
+
}]
|
|
93
|
+
}], propDecorators: { uiContextMenuTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiContextMenuTrigger", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], openedChange: [{ type: i0.Output, args: ["openedChange"] }] } });
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generated bundle index. Do not edit.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
export { ContextMenuTriggerDirective };
|
|
100
|
+
//# sourceMappingURL=ojiepermana-angular-ui-component-context-menu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ojiepermana-angular-ui-component-context-menu.mjs","sources":["../../../projects/angular/ui/component/context-menu/src/lib/context-menu-trigger.directive.ts","../../../projects/angular/ui/component/context-menu/ojiepermana-angular-ui-component-context-menu.ts"],"sourcesContent":["import { Overlay, OverlayRef } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport { DestroyRef, Directive, ElementRef, ViewContainerRef, inject, input, output, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { merge } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport type { MenuContentDirective } from '@ojiepermana/angular/component/dropdown-menu';\n\n/**\n * Opens a menu anchored to the cursor when the host fires `contextmenu`.\n * Reuses `<ng-template uiMenuContent>` from the dropdown-menu entry.\n *\n * @example\n * <div [uiContextMenuTrigger]=\"menu\" class=\"p-12 border\">Right-click me</div>\n * <ng-template uiMenuContent #menu>\n * <ui-menu-surface>\n * <button ui-menu-item>Copy</button>\n * <button ui-menu-item>Paste</button>\n * </ui-menu-surface>\n * </ng-template>\n */\n@Directive({\n selector: '[uiContextMenuTrigger]',\n exportAs: 'uiContextMenuTrigger',\n host: {\n '(contextmenu)': 'onContextMenu($event)',\n '(keydown)': 'onKeyDown($event)',\n },\n})\nexport class ContextMenuTriggerDirective {\n private readonly overlay = inject(Overlay);\n private readonly vcr = inject(ViewContainerRef);\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly destroyRef = inject(DestroyRef);\n\n readonly uiContextMenuTrigger = input.required<MenuContentDirective>();\n readonly disabled = input<boolean>(false);\n\n readonly openedChange = output<boolean>();\n\n private overlayRef: OverlayRef | null = null;\n readonly isOpen = signal(false);\n\n protected onContextMenu(event: MouseEvent): void {\n if (this.disabled()) return;\n event.preventDefault();\n this.close();\n this.openAt(event.clientX, event.clientY);\n }\n\n protected onKeyDown(event: KeyboardEvent): void {\n const isContextMenuKey = event.key === 'ContextMenu' || (event.shiftKey && event.key === 'F10');\n\n if (!isContextMenuKey || this.disabled()) {\n return;\n }\n\n event.preventDefault();\n\n const rect = this.el.nativeElement.getBoundingClientRect();\n this.close();\n this.openAt(rect.left + rect.width / 2, rect.top + rect.height / 2);\n }\n\n openAt(x: number, y: number): void {\n this.overlayRef = this.overlay.create({\n positionStrategy: this.overlay\n .position()\n .flexibleConnectedTo({ x, y })\n .withPositions([\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },\n ]),\n scrollStrategy: this.overlay.scrollStrategies.close(),\n hasBackdrop: false,\n panelClass: 'ui-menu-panel',\n });\n\n const portal = new TemplatePortal(this.uiContextMenuTrigger().template, this.vcr);\n this.overlayRef.attach(portal);\n\n merge(\n this.overlayRef.outsidePointerEvents(),\n this.overlayRef.keydownEvents().pipe(filter((e) => e.key === 'Escape')),\n this.overlayRef.detachments(),\n )\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => this.close());\n\n this.isOpen.set(true);\n this.openedChange.emit(true);\n }\n\n close(): void {\n if (!this.overlayRef) return;\n this.overlayRef.dispose();\n this.overlayRef = null;\n this.isOpen.set(false);\n this.opened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EAAA,EAAA,aAAA,EAAA,uBAAA,EAAA,SAAA,EAAA,mBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,sBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;4FAA3B,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBARvC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,wBAAwB;AAClC,oBAAA,QAAQ,EAAE,sBAAsB;AAChC,oBAAA,IAAI,EAAE;AACJ,wBAAA,eAAe,EAAE,uBAAuB;AACxC,wBAAA,WAAW,EAAE,mBAAmB;AACjC,qBAAA;AACF,iBAAA;;;AC5BD;;AAEG;;;;"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { model, input, computed, effect, inject, DestroyRef, untracked, forwardRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { MatDatepicker, MatDatepickerInput } from '@angular/material/datepicker';
|
|
5
|
+
import { MatFormField, MatSuffix } from '@angular/material/form-field';
|
|
6
|
+
import { MatInput } from '@angular/material/input';
|
|
7
|
+
import * as i1 from '@angular/forms';
|
|
8
|
+
import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
9
|
+
import { cn } from '@ojiepermana/angular/component/utils';
|
|
10
|
+
|
|
11
|
+
let nextDatePickerId = 0;
|
|
12
|
+
/**
|
|
13
|
+
* Popup date picker. Requires a date adapter provider in the consumer app
|
|
14
|
+
* (e.g. `provideNativeDateAdapter()` from `@angular/material/core`).
|
|
15
|
+
*/
|
|
16
|
+
class DatePickerComponent {
|
|
17
|
+
value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
18
|
+
id = input(null, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
19
|
+
placeholder = input('Pick a date', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
20
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
21
|
+
min = input(null, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
22
|
+
max = input(null, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
23
|
+
startAt = input(null, ...(ngDevMode ? [{ debugName: "startAt" }] : /* istanbul ignore next */ []));
|
|
24
|
+
startView = input('month', ...(ngDevMode ? [{ debugName: "startView" }] : /* istanbul ignore next */ []));
|
|
25
|
+
touchUi = input(false, ...(ngDevMode ? [{ debugName: "touchUi" }] : /* istanbul ignore next */ []));
|
|
26
|
+
dateFilter = input(null, ...(ngDevMode ? [{ debugName: "dateFilter" }] : /* istanbul ignore next */ []));
|
|
27
|
+
panelClass = input('ui-datepicker-panel', ...(ngDevMode ? [{ debugName: "panelClass" }] : /* istanbul ignore next */ []));
|
|
28
|
+
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
29
|
+
ariaLabelledby = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {}), alias: 'aria-labelledby' });
|
|
30
|
+
disabled = model(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
31
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
32
|
+
fallbackId = `ui-date-picker-${nextDatePickerId++}`;
|
|
33
|
+
classes = computed(() => cn('inline-block', this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
34
|
+
resolvedId = computed(() => this.id() ?? this.fallbackId, ...(ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []));
|
|
35
|
+
control = new FormControl(null);
|
|
36
|
+
onChangeFn = () => { };
|
|
37
|
+
onTouchedFn = () => { };
|
|
38
|
+
constructor() {
|
|
39
|
+
effect(() => {
|
|
40
|
+
const next = this.value();
|
|
41
|
+
if (this.control.value !== next) {
|
|
42
|
+
this.control.setValue(next, { emitEvent: false });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
effect(() => {
|
|
46
|
+
const d = this.disabled();
|
|
47
|
+
d ? this.control.disable({ emitEvent: false }) : this.control.enable({ emitEvent: false });
|
|
48
|
+
});
|
|
49
|
+
this.control.valueChanges.pipe(takeUntilDestroyed(inject(DestroyRef))).subscribe((next) => {
|
|
50
|
+
untracked(() => this.value.set(next));
|
|
51
|
+
this.onChangeFn(next);
|
|
52
|
+
this.onTouchedFn();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
handleTouched() {
|
|
56
|
+
this.onTouchedFn();
|
|
57
|
+
}
|
|
58
|
+
writeValue(v) {
|
|
59
|
+
this.value.set(v);
|
|
60
|
+
}
|
|
61
|
+
registerOnChange(fn) {
|
|
62
|
+
this.onChangeFn = fn;
|
|
63
|
+
}
|
|
64
|
+
registerOnTouched(fn) {
|
|
65
|
+
this.onTouchedFn = fn;
|
|
66
|
+
}
|
|
67
|
+
setDisabledState(state) {
|
|
68
|
+
this.disabled.set(state);
|
|
69
|
+
}
|
|
70
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: DatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
71
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: DatePickerComponent, isStandalone: true, selector: "ui-date-picker", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, startAt: { classPropertyName: "startAt", publicName: "startAt", isSignal: true, isRequired: false, transformFunction: null }, startView: { classPropertyName: "startView", publicName: "startView", isSignal: true, isRequired: false, transformFunction: null }, touchUi: { classPropertyName: "touchUi", publicName: "touchUi", isSignal: true, isRequired: false, transformFunction: null }, dateFilter: { classPropertyName: "dateFilter", publicName: "dateFilter", isSignal: true, isRequired: false, transformFunction: null }, panelClass: { classPropertyName: "panelClass", publicName: "panelClass", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange" }, host: { properties: { "class": "classes()" } }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DatePickerComponent), multi: true }], ngImport: i0, template: `
|
|
72
|
+
<mat-form-field class="ui-date-picker w-full" appearance="outline" subscriptSizing="dynamic">
|
|
73
|
+
<input
|
|
74
|
+
matInput
|
|
75
|
+
[id]="resolvedId()"
|
|
76
|
+
[attr.aria-label]="ariaLabel()"
|
|
77
|
+
[attr.aria-labelledby]="ariaLabelledby()"
|
|
78
|
+
[matDatepicker]="picker"
|
|
79
|
+
[matDatepickerFilter]="dateFilter()"
|
|
80
|
+
[placeholder]="placeholder()"
|
|
81
|
+
[required]="required()"
|
|
82
|
+
[min]="min()"
|
|
83
|
+
[max]="max()"
|
|
84
|
+
[formControl]="control"
|
|
85
|
+
(blur)="handleTouched()" />
|
|
86
|
+
<button
|
|
87
|
+
matIconSuffix
|
|
88
|
+
type="button"
|
|
89
|
+
class="ui-date-picker-toggle"
|
|
90
|
+
aria-label="Open calendar"
|
|
91
|
+
[disabled]="control.disabled"
|
|
92
|
+
(click)="picker.open()">
|
|
93
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
94
|
+
<path d="M8 2v4" />
|
|
95
|
+
<path d="M16 2v4" />
|
|
96
|
+
<rect width="18" height="18" x="3" y="4" rx="2" />
|
|
97
|
+
<path d="M3 10h18" />
|
|
98
|
+
</svg>
|
|
99
|
+
</button>
|
|
100
|
+
<mat-datepicker
|
|
101
|
+
#picker
|
|
102
|
+
[panelClass]="panelClass()"
|
|
103
|
+
[startAt]="startAt()"
|
|
104
|
+
[startView]="startView()"
|
|
105
|
+
[touchUi]="touchUi()"></mat-datepicker>
|
|
106
|
+
</mat-form-field>
|
|
107
|
+
`, isInline: true, styles: [":host{display:inline-block}:host ::ng-deep .mat-mdc-form-field{--mat-form-field-container-height: 2.25rem;--mat-form-field-container-vertical-padding: 0;--mat-form-field-filled-with-label-container-padding-top: 0;--mat-form-field-filled-with-label-container-padding-bottom: 0;--mdc-outlined-text-field-container-shape: calc(var(--radius) - .125rem);--mdc-outlined-text-field-outline-color: hsl(var(--input));--mdc-outlined-text-field-hover-outline-color: hsl(var(--input));--mdc-outlined-text-field-focus-outline-color: hsl(var(--ring));--mdc-outlined-text-field-input-text-color: hsl(var(--foreground));--mdc-outlined-text-field-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-hover-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-focus-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-disabled-outline-color: hsl(var(--input) / .5);--mdc-outlined-text-field-disabled-input-text-color: hsl(var(--muted-foreground));width:100%;font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}:host ::ng-deep .mat-mdc-text-field-wrapper{height:2.25rem;padding:0 .25rem 0 .75rem;background:transparent}:host ::ng-deep .mat-mdc-form-field-flex{height:2.25rem;align-items:center}:host ::ng-deep .mat-mdc-form-field-infix{display:flex;min-height:2.25rem;height:2.25rem;align-items:center;padding:0;width:auto}:host ::ng-deep .mat-mdc-form-field-icon-suffix{align-self:center;padding-right:.25rem!important;padding-left:.25rem!important;color:hsl(var(--muted-foreground))}.ui-date-picker-toggle{display:inline-flex;width:1.75rem;height:1.75rem;align-items:center;justify-content:center;color:hsl(var(--muted-foreground));border-radius:calc(var(--radius) - .125rem);transition:color .15s ease,background-color .15s ease}.ui-date-picker-toggle:hover{color:hsl(var(--foreground));background:hsl(var(--accent))}.ui-date-picker-toggle:focus-visible{outline:2px solid hsl(var(--ring));outline-offset:2px}.ui-date-picker-toggle:disabled{cursor:not-allowed;opacity:.5}.ui-date-picker-toggle svg{width:1rem;height:1rem}:host ::ng-deep .mat-mdc-input-element{font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}:host ::ng-deep .mat-mdc-input-element::placeholder{color:hsl(var(--muted-foreground))}:host ::ng-deep .mat-mdc-form-field-subscript-wrapper{display:none}:host ::ng-deep .mdc-floating-label,:host ::ng-deep .mat-mdc-floating-label,:host ::ng-deep .mdc-notched-outline__notch .mdc-floating-label{display:none}:host ::ng-deep .mdc-notched-outline__notch{padding:0;border-left:none;border-right:none}:host ::ng-deep .mat-mdc-form-field.mat-focused .ui-date-picker-toggle{color:hsl(var(--foreground))}:host ::ng-deep .mat-mdc-form-field.mat-form-field-disabled .ui-date-picker-toggle{opacity:.5}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
108
|
+
}
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: DatePickerComponent, decorators: [{
|
|
110
|
+
type: Component,
|
|
111
|
+
args: [{ selector: 'ui-date-picker', changeDetection: ChangeDetectionStrategy.OnPush, imports: [ReactiveFormsModule, MatFormField, MatSuffix, MatInput, MatDatepicker, MatDatepickerInput], host: { '[class]': 'classes()' }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DatePickerComponent), multi: true }], template: `
|
|
112
|
+
<mat-form-field class="ui-date-picker w-full" appearance="outline" subscriptSizing="dynamic">
|
|
113
|
+
<input
|
|
114
|
+
matInput
|
|
115
|
+
[id]="resolvedId()"
|
|
116
|
+
[attr.aria-label]="ariaLabel()"
|
|
117
|
+
[attr.aria-labelledby]="ariaLabelledby()"
|
|
118
|
+
[matDatepicker]="picker"
|
|
119
|
+
[matDatepickerFilter]="dateFilter()"
|
|
120
|
+
[placeholder]="placeholder()"
|
|
121
|
+
[required]="required()"
|
|
122
|
+
[min]="min()"
|
|
123
|
+
[max]="max()"
|
|
124
|
+
[formControl]="control"
|
|
125
|
+
(blur)="handleTouched()" />
|
|
126
|
+
<button
|
|
127
|
+
matIconSuffix
|
|
128
|
+
type="button"
|
|
129
|
+
class="ui-date-picker-toggle"
|
|
130
|
+
aria-label="Open calendar"
|
|
131
|
+
[disabled]="control.disabled"
|
|
132
|
+
(click)="picker.open()">
|
|
133
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
134
|
+
<path d="M8 2v4" />
|
|
135
|
+
<path d="M16 2v4" />
|
|
136
|
+
<rect width="18" height="18" x="3" y="4" rx="2" />
|
|
137
|
+
<path d="M3 10h18" />
|
|
138
|
+
</svg>
|
|
139
|
+
</button>
|
|
140
|
+
<mat-datepicker
|
|
141
|
+
#picker
|
|
142
|
+
[panelClass]="panelClass()"
|
|
143
|
+
[startAt]="startAt()"
|
|
144
|
+
[startView]="startView()"
|
|
145
|
+
[touchUi]="touchUi()"></mat-datepicker>
|
|
146
|
+
</mat-form-field>
|
|
147
|
+
`, styles: [":host{display:inline-block}:host ::ng-deep .mat-mdc-form-field{--mat-form-field-container-height: 2.25rem;--mat-form-field-container-vertical-padding: 0;--mat-form-field-filled-with-label-container-padding-top: 0;--mat-form-field-filled-with-label-container-padding-bottom: 0;--mdc-outlined-text-field-container-shape: calc(var(--radius) - .125rem);--mdc-outlined-text-field-outline-color: hsl(var(--input));--mdc-outlined-text-field-hover-outline-color: hsl(var(--input));--mdc-outlined-text-field-focus-outline-color: hsl(var(--ring));--mdc-outlined-text-field-input-text-color: hsl(var(--foreground));--mdc-outlined-text-field-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-hover-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-focus-label-text-color: hsl(var(--muted-foreground));--mdc-outlined-text-field-disabled-outline-color: hsl(var(--input) / .5);--mdc-outlined-text-field-disabled-input-text-color: hsl(var(--muted-foreground));width:100%;font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}:host ::ng-deep .mat-mdc-text-field-wrapper{height:2.25rem;padding:0 .25rem 0 .75rem;background:transparent}:host ::ng-deep .mat-mdc-form-field-flex{height:2.25rem;align-items:center}:host ::ng-deep .mat-mdc-form-field-infix{display:flex;min-height:2.25rem;height:2.25rem;align-items:center;padding:0;width:auto}:host ::ng-deep .mat-mdc-form-field-icon-suffix{align-self:center;padding-right:.25rem!important;padding-left:.25rem!important;color:hsl(var(--muted-foreground))}.ui-date-picker-toggle{display:inline-flex;width:1.75rem;height:1.75rem;align-items:center;justify-content:center;color:hsl(var(--muted-foreground));border-radius:calc(var(--radius) - .125rem);transition:color .15s ease,background-color .15s ease}.ui-date-picker-toggle:hover{color:hsl(var(--foreground));background:hsl(var(--accent))}.ui-date-picker-toggle:focus-visible{outline:2px solid hsl(var(--ring));outline-offset:2px}.ui-date-picker-toggle:disabled{cursor:not-allowed;opacity:.5}.ui-date-picker-toggle svg{width:1rem;height:1rem}:host ::ng-deep .mat-mdc-input-element{font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--text-sm--line-height)}:host ::ng-deep .mat-mdc-input-element::placeholder{color:hsl(var(--muted-foreground))}:host ::ng-deep .mat-mdc-form-field-subscript-wrapper{display:none}:host ::ng-deep .mdc-floating-label,:host ::ng-deep .mat-mdc-floating-label,:host ::ng-deep .mdc-notched-outline__notch .mdc-floating-label{display:none}:host ::ng-deep .mdc-notched-outline__notch{padding:0;border-left:none;border-right:none}:host ::ng-deep .mat-mdc-form-field.mat-focused .ui-date-picker-toggle{color:hsl(var(--foreground))}:host ::ng-deep .mat-mdc-form-field.mat-form-field-disabled .ui-date-picker-toggle{opacity:.5}\n"] }]
|
|
148
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], startAt: [{ type: i0.Input, args: [{ isSignal: true, alias: "startAt", required: false }] }], startView: [{ type: i0.Input, args: [{ isSignal: true, alias: "startView", required: false }] }], touchUi: [{ type: i0.Input, args: [{ isSignal: true, alias: "touchUi", required: false }] }], dateFilter: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateFilter", required: false }] }], panelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelClass", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Generated bundle index. Do not edit.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
export { DatePickerComponent };
|
|
155
|
+
//# sourceMappingURL=ojiepermana-angular-ui-component-date-picker.mjs.map
|