@edsis/ui 0.0.2
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 +40 -0
- package/accordion/README.md +195 -0
- package/alert/README.md +177 -0
- package/alert-dialog/README.md +239 -0
- package/aspect-ratio/README.md +112 -0
- package/avatar/README.md +176 -0
- package/badge/README.md +133 -0
- package/breadcrumb/README.md +216 -0
- package/button/README.md +139 -0
- package/button-group/README.md +204 -0
- package/calendar/README.md +132 -0
- package/card/README.md +220 -0
- package/carousel/README.md +276 -0
- package/chart/README.md +249 -0
- package/checkbox/README.md +149 -0
- package/collapsible/README.md +191 -0
- package/combobox/README.md +198 -0
- package/command/README.md +275 -0
- package/composer/README.md +235 -0
- package/context-menu/README.md +267 -0
- package/date-picker/README.md +177 -0
- package/dialog/README.md +237 -0
- package/drawer/README.md +145 -0
- package/dropdown-menu/README.md +311 -0
- package/editor/README.md +136 -0
- package/empty/README.md +183 -0
- package/fesm2022/edsis-ui-accordion.mjs +174 -0
- package/fesm2022/edsis-ui-accordion.mjs.map +1 -0
- package/fesm2022/edsis-ui-alert-dialog.mjs +242 -0
- package/fesm2022/edsis-ui-alert-dialog.mjs.map +1 -0
- package/fesm2022/edsis-ui-alert.mjs +90 -0
- package/fesm2022/edsis-ui-alert.mjs.map +1 -0
- package/fesm2022/edsis-ui-aspect-ratio.mjs +33 -0
- package/fesm2022/edsis-ui-aspect-ratio.mjs.map +1 -0
- package/fesm2022/edsis-ui-avatar.mjs +123 -0
- package/fesm2022/edsis-ui-avatar.mjs.map +1 -0
- package/fesm2022/edsis-ui-badge.mjs +47 -0
- package/fesm2022/edsis-ui-badge.mjs.map +1 -0
- package/fesm2022/edsis-ui-breadcrumb.mjs +186 -0
- package/fesm2022/edsis-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/edsis-ui-button-group.mjs +95 -0
- package/fesm2022/edsis-ui-button-group.mjs.map +1 -0
- package/fesm2022/edsis-ui-button.mjs +64 -0
- package/fesm2022/edsis-ui-button.mjs.map +1 -0
- package/fesm2022/edsis-ui-calendar.mjs +78 -0
- package/fesm2022/edsis-ui-calendar.mjs.map +1 -0
- package/fesm2022/edsis-ui-card.mjs +137 -0
- package/fesm2022/edsis-ui-card.mjs.map +1 -0
- package/fesm2022/edsis-ui-carousel.mjs +310 -0
- package/fesm2022/edsis-ui-carousel.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-area.mjs +6 -0
- package/fesm2022/edsis-ui-chart-area.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-bar.mjs +6 -0
- package/fesm2022/edsis-ui-chart-bar.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-line.mjs +6 -0
- package/fesm2022/edsis-ui-chart-line.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-pie.mjs +6 -0
- package/fesm2022/edsis-ui-chart-pie.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-radar.mjs +6 -0
- package/fesm2022/edsis-ui-chart-radar.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-radial.mjs +6 -0
- package/fesm2022/edsis-ui-chart-radial.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart-scatter.mjs +6 -0
- package/fesm2022/edsis-ui-chart-scatter.mjs.map +1 -0
- package/fesm2022/edsis-ui-chart.mjs +3714 -0
- package/fesm2022/edsis-ui-chart.mjs.map +1 -0
- package/fesm2022/edsis-ui-checkbox.mjs +104 -0
- package/fesm2022/edsis-ui-checkbox.mjs.map +1 -0
- package/fesm2022/edsis-ui-collapsible.mjs +116 -0
- package/fesm2022/edsis-ui-collapsible.mjs.map +1 -0
- package/fesm2022/edsis-ui-combobox.mjs +263 -0
- package/fesm2022/edsis-ui-combobox.mjs.map +1 -0
- package/fesm2022/edsis-ui-command.mjs +268 -0
- package/fesm2022/edsis-ui-command.mjs.map +1 -0
- package/fesm2022/edsis-ui-composer.mjs +329 -0
- package/fesm2022/edsis-ui-composer.mjs.map +1 -0
- package/fesm2022/edsis-ui-context-menu.mjs +100 -0
- package/fesm2022/edsis-ui-context-menu.mjs.map +1 -0
- package/fesm2022/edsis-ui-date-picker.mjs +155 -0
- package/fesm2022/edsis-ui-date-picker.mjs.map +1 -0
- package/fesm2022/edsis-ui-dialog.mjs +262 -0
- package/fesm2022/edsis-ui-dialog.mjs.map +1 -0
- package/fesm2022/edsis-ui-drawer.mjs +6 -0
- package/fesm2022/edsis-ui-drawer.mjs.map +1 -0
- package/fesm2022/edsis-ui-dropdown-menu.mjs +466 -0
- package/fesm2022/edsis-ui-dropdown-menu.mjs.map +1 -0
- package/fesm2022/edsis-ui-editor.mjs +692 -0
- package/fesm2022/edsis-ui-editor.mjs.map +1 -0
- package/fesm2022/edsis-ui-empty.mjs +132 -0
- package/fesm2022/edsis-ui-empty.mjs.map +1 -0
- package/fesm2022/edsis-ui-form.mjs +334 -0
- package/fesm2022/edsis-ui-form.mjs.map +1 -0
- package/fesm2022/edsis-ui-hover-card.mjs +284 -0
- package/fesm2022/edsis-ui-hover-card.mjs.map +1 -0
- package/fesm2022/edsis-ui-input-group.mjs +164 -0
- package/fesm2022/edsis-ui-input-group.mjs.map +1 -0
- package/fesm2022/edsis-ui-input-otp.mjs +485 -0
- package/fesm2022/edsis-ui-input-otp.mjs.map +1 -0
- package/fesm2022/edsis-ui-input.mjs +43 -0
- package/fesm2022/edsis-ui-input.mjs.map +1 -0
- package/fesm2022/edsis-ui-item.mjs +241 -0
- package/fesm2022/edsis-ui-item.mjs.map +1 -0
- package/fesm2022/edsis-ui-kanban.mjs +289 -0
- package/fesm2022/edsis-ui-kanban.mjs.map +1 -0
- package/fesm2022/edsis-ui-kbd.mjs +51 -0
- package/fesm2022/edsis-ui-kbd.mjs.map +1 -0
- package/fesm2022/edsis-ui-label.mjs +30 -0
- package/fesm2022/edsis-ui-label.mjs.map +1 -0
- package/fesm2022/edsis-ui-menubar.mjs +302 -0
- package/fesm2022/edsis-ui-menubar.mjs.map +1 -0
- package/fesm2022/edsis-ui-native-select.mjs +61 -0
- package/fesm2022/edsis-ui-native-select.mjs.map +1 -0
- package/fesm2022/edsis-ui-navigation-menu.mjs +399 -0
- package/fesm2022/edsis-ui-navigation-menu.mjs.map +1 -0
- package/fesm2022/edsis-ui-pagination.mjs +216 -0
- package/fesm2022/edsis-ui-pagination.mjs.map +1 -0
- package/fesm2022/edsis-ui-pillbox.mjs +777 -0
- package/fesm2022/edsis-ui-pillbox.mjs.map +1 -0
- package/fesm2022/edsis-ui-popover.mjs +163 -0
- package/fesm2022/edsis-ui-popover.mjs.map +1 -0
- package/fesm2022/edsis-ui-progress.mjs +53 -0
- package/fesm2022/edsis-ui-progress.mjs.map +1 -0
- package/fesm2022/edsis-ui-radio.mjs +111 -0
- package/fesm2022/edsis-ui-radio.mjs.map +1 -0
- package/fesm2022/edsis-ui-resizable.mjs +454 -0
- package/fesm2022/edsis-ui-resizable.mjs.map +1 -0
- package/fesm2022/edsis-ui-scroll-area.mjs +48 -0
- package/fesm2022/edsis-ui-scroll-area.mjs.map +1 -0
- package/fesm2022/edsis-ui-select.mjs +164 -0
- package/fesm2022/edsis-ui-select.mjs.map +1 -0
- package/fesm2022/edsis-ui-separator.mjs +33 -0
- package/fesm2022/edsis-ui-separator.mjs.map +1 -0
- package/fesm2022/edsis-ui-sheet.mjs +264 -0
- package/fesm2022/edsis-ui-sheet.mjs.map +1 -0
- package/fesm2022/edsis-ui-skeleton.mjs +29 -0
- package/fesm2022/edsis-ui-skeleton.mjs.map +1 -0
- package/fesm2022/edsis-ui-slider.mjs +405 -0
- package/fesm2022/edsis-ui-slider.mjs.map +1 -0
- package/fesm2022/edsis-ui-spinner.mjs +58 -0
- package/fesm2022/edsis-ui-spinner.mjs.map +1 -0
- package/fesm2022/edsis-ui-switch.mjs +107 -0
- package/fesm2022/edsis-ui-switch.mjs.map +1 -0
- package/fesm2022/edsis-ui-table.mjs +139 -0
- package/fesm2022/edsis-ui-table.mjs.map +1 -0
- package/fesm2022/edsis-ui-tabs.mjs +252 -0
- package/fesm2022/edsis-ui-tabs.mjs.map +1 -0
- package/fesm2022/edsis-ui-textarea.mjs +37 -0
- package/fesm2022/edsis-ui-textarea.mjs.map +1 -0
- package/fesm2022/edsis-ui-timeline.mjs +213 -0
- package/fesm2022/edsis-ui-timeline.mjs.map +1 -0
- package/fesm2022/edsis-ui-toast.mjs +71 -0
- package/fesm2022/edsis-ui-toast.mjs.map +1 -0
- package/fesm2022/edsis-ui-toggle-group.mjs +269 -0
- package/fesm2022/edsis-ui-toggle-group.mjs.map +1 -0
- package/fesm2022/edsis-ui-toggle.mjs +76 -0
- package/fesm2022/edsis-ui-toggle.mjs.map +1 -0
- package/fesm2022/edsis-ui-tooltip.mjs +339 -0
- package/fesm2022/edsis-ui-tooltip.mjs.map +1 -0
- package/fesm2022/edsis-ui-utils.mjs +13 -0
- package/fesm2022/edsis-ui-utils.mjs.map +1 -0
- package/fesm2022/edsis-ui.mjs +11 -0
- package/fesm2022/edsis-ui.mjs.map +1 -0
- package/form/README.md +210 -0
- package/hover-card/README.md +146 -0
- package/input/README.md +159 -0
- package/input-group/README.md +234 -0
- package/input-otp/README.md +273 -0
- package/item/README.md +247 -0
- package/kanban/README.md +81 -0
- package/kbd/README.md +139 -0
- package/label/README.md +136 -0
- package/menubar/README.md +269 -0
- package/native-select/README.md +176 -0
- package/navigation-menu/README.md +160 -0
- package/package.json +310 -0
- package/pagination/README.md +144 -0
- package/pillbox/README.md +67 -0
- package/popover/README.md +43 -0
- package/progress/README.md +160 -0
- package/radio/README.md +209 -0
- package/resizable/README.md +164 -0
- package/scroll-area/README.md +143 -0
- package/select/README.md +174 -0
- package/separator/README.md +170 -0
- package/sheet/README.md +183 -0
- package/skeleton/README.md +158 -0
- package/slider/README.md +207 -0
- package/spinner/README.md +160 -0
- package/switch/README.md +166 -0
- package/table/README.md +291 -0
- package/tabs/README.md +214 -0
- package/textarea/README.md +154 -0
- package/timeline/README.md +94 -0
- package/toast/README.md +321 -0
- package/toggle/README.md +131 -0
- package/toggle-group/README.md +206 -0
- package/tooltip/README.md +211 -0
- package/types/edsis-ui-accordion.d.ts +51 -0
- package/types/edsis-ui-alert-dialog.d.ts +93 -0
- package/types/edsis-ui-alert.d.ts +37 -0
- package/types/edsis-ui-aspect-ratio.d.ts +12 -0
- package/types/edsis-ui-avatar.d.ts +51 -0
- package/types/edsis-ui-badge.d.ts +19 -0
- package/types/edsis-ui-breadcrumb.d.ts +46 -0
- package/types/edsis-ui-button-group.d.ts +26 -0
- package/types/edsis-ui-button.d.ts +22 -0
- package/types/edsis-ui-calendar.d.ts +33 -0
- package/types/edsis-ui-card.d.ts +60 -0
- package/types/edsis-ui-carousel.d.ts +86 -0
- package/types/edsis-ui-chart-area.d.ts +1 -0
- package/types/edsis-ui-chart-bar.d.ts +1 -0
- package/types/edsis-ui-chart-line.d.ts +1 -0
- package/types/edsis-ui-chart-pie.d.ts +1 -0
- package/types/edsis-ui-chart-radar.d.ts +1 -0
- package/types/edsis-ui-chart-radial.d.ts +1 -0
- package/types/edsis-ui-chart-scatter.d.ts +1 -0
- package/types/edsis-ui-chart.d.ts +1094 -0
- package/types/edsis-ui-checkbox.d.ts +35 -0
- package/types/edsis-ui-collapsible.d.ts +42 -0
- package/types/edsis-ui-combobox.d.ts +51 -0
- package/types/edsis-ui-command.d.ts +99 -0
- package/types/edsis-ui-composer.d.ts +90 -0
- package/types/edsis-ui-context-menu.d.ts +35 -0
- package/types/edsis-ui-date-picker.d.ts +41 -0
- package/types/edsis-ui-dialog.d.ts +87 -0
- package/types/edsis-ui-drawer.d.ts +1 -0
- package/types/edsis-ui-dropdown-menu.d.ts +136 -0
- package/types/edsis-ui-editor.d.ts +123 -0
- package/types/edsis-ui-empty.d.ts +50 -0
- package/types/edsis-ui-form.d.ts +141 -0
- package/types/edsis-ui-hover-card.d.ts +74 -0
- package/types/edsis-ui-input-group.d.ts +51 -0
- package/types/edsis-ui-input-otp.d.ts +136 -0
- package/types/edsis-ui-input.d.ts +16 -0
- package/types/edsis-ui-item.d.ts +88 -0
- package/types/edsis-ui-kanban.d.ts +70 -0
- package/types/edsis-ui-kbd.d.ts +16 -0
- package/types/edsis-ui-label.d.ts +11 -0
- package/types/edsis-ui-menubar.d.ts +67 -0
- package/types/edsis-ui-native-select.d.ts +26 -0
- package/types/edsis-ui-navigation-menu.d.ts +96 -0
- package/types/edsis-ui-pagination.d.ts +34 -0
- package/types/edsis-ui-pillbox.d.ts +157 -0
- package/types/edsis-ui-popover.d.ts +43 -0
- package/types/edsis-ui-progress.d.ts +17 -0
- package/types/edsis-ui-radio.d.ts +40 -0
- package/types/edsis-ui-resizable.d.ts +99 -0
- package/types/edsis-ui-scroll-area.d.ts +19 -0
- package/types/edsis-ui-select.d.ts +57 -0
- package/types/edsis-ui-separator.d.ts +14 -0
- package/types/edsis-ui-sheet.d.ts +76 -0
- package/types/edsis-ui-skeleton.d.ts +10 -0
- package/types/edsis-ui-slider.d.ts +74 -0
- package/types/edsis-ui-spinner.d.ts +13 -0
- package/types/edsis-ui-switch.d.ts +40 -0
- package/types/edsis-ui-table.d.ts +52 -0
- package/types/edsis-ui-tabs.d.ts +92 -0
- package/types/edsis-ui-textarea.d.ts +12 -0
- package/types/edsis-ui-timeline.d.ts +63 -0
- package/types/edsis-ui-toast.d.ts +38 -0
- package/types/edsis-ui-toggle-group.d.ts +89 -0
- package/types/edsis-ui-toggle.d.ts +25 -0
- package/types/edsis-ui-tooltip.d.ts +89 -0
- package/types/edsis-ui-utils.d.ts +5 -0
- package/types/edsis-ui.d.ts +2 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Combobox
|
|
2
|
+
|
|
3
|
+
Searchable single-select surface built from a button trigger, a CDK overlay,
|
|
4
|
+
and the shared [Command](../command/README.md) list primitives.
|
|
5
|
+
|
|
6
|
+
Use Combobox when users need type-to-filter selection from a medium-sized list
|
|
7
|
+
without leaving the current form, settings screen, or dashboard panel.
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { ComboboxComponent, type ComboboxOption } from '@edsis/ui/combobox';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Composition
|
|
16
|
+
|
|
17
|
+
The Angular structure maps the combobox idea onto the existing library stack:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
ui-combobox
|
|
21
|
+
├── button[role="combobox"]
|
|
22
|
+
└── CDK overlay
|
|
23
|
+
└── ui-command
|
|
24
|
+
├── input[ui-command-input]
|
|
25
|
+
└── ui-command-list
|
|
26
|
+
└── button[ui-command-item]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This differs from the current shadcn Base UI page, which documents an input-first
|
|
30
|
+
combobox. The Angular library currently ships the common searchable single-select
|
|
31
|
+
pattern on top of Button + Command + CDK Overlay.
|
|
32
|
+
|
|
33
|
+
## Basic usage
|
|
34
|
+
|
|
35
|
+
Bind `[(value)]` when a signal or parent component should own the selected value.
|
|
36
|
+
Pass width or layout utilities through the host `class`; the trigger fills that
|
|
37
|
+
host width.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
frameworkOptions: ComboboxOption<string>[] = [
|
|
41
|
+
{ value: 'angular', label: 'Angular' },
|
|
42
|
+
{ value: 'nextjs', label: 'Next.js' },
|
|
43
|
+
{ value: 'astro', label: 'Astro' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
selectedFramework = signal<string | null>(null);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<ui-combobox
|
|
51
|
+
class="w-80"
|
|
52
|
+
[options]="frameworkOptions"
|
|
53
|
+
[(value)]="selectedFramework"
|
|
54
|
+
placeholder="Select framework"
|
|
55
|
+
searchPlaceholder="Search frameworks..." />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Common patterns
|
|
59
|
+
|
|
60
|
+
### Object-backed values
|
|
61
|
+
|
|
62
|
+
Option values can be full domain objects, not only strings.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
type Country = {
|
|
66
|
+
code: string;
|
|
67
|
+
label: string;
|
|
68
|
+
region: string;
|
|
69
|
+
currency: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
countryOptions: ComboboxOption<Country>[] = [
|
|
73
|
+
{
|
|
74
|
+
value: { code: 'ca', label: 'Canada', region: 'North America', currency: 'CAD' },
|
|
75
|
+
label: 'Canada',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
value: { code: 'jp', label: 'Japan', region: 'Asia', currency: 'JPY' },
|
|
79
|
+
label: 'Japan',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
selectedCountry = signal<Country | null>(countryOptions[0]?.value ?? null);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<ui-combobox
|
|
88
|
+
class="w-full max-w-sm"
|
|
89
|
+
[options]="countryOptions"
|
|
90
|
+
[(value)]="selectedCountry"
|
|
91
|
+
placeholder="Select country"
|
|
92
|
+
searchPlaceholder="Search countries..." />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Disabled options and empty states
|
|
96
|
+
|
|
97
|
+
Mark options with `disabled: true` when they should stay visible but unavailable.
|
|
98
|
+
Tune `searchPlaceholder` and `emptyText` so large lists feel intentional.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
feedOptions: ComboboxOption<string>[] = [
|
|
102
|
+
{ value: 'release-notes', label: 'Release notes' },
|
|
103
|
+
{ value: 'beta-api', label: 'Beta API access', disabled: true },
|
|
104
|
+
{ value: 'status-page', label: 'Status page' },
|
|
105
|
+
];
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<ui-combobox
|
|
110
|
+
class="w-full max-w-sm"
|
|
111
|
+
[options]="feedOptions"
|
|
112
|
+
placeholder="Choose a feed"
|
|
113
|
+
searchPlaceholder="Search feeds..."
|
|
114
|
+
emptyText="No feeds matched your query." />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Reactive forms
|
|
118
|
+
|
|
119
|
+
The component implements `ControlValueAccessor`, so it also works with Angular
|
|
120
|
+
reactive forms.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
readonly form = new FormGroup({
|
|
124
|
+
framework: new FormControl<string | null>(null),
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<form [formGroup]="form">
|
|
130
|
+
<ui-combobox
|
|
131
|
+
class="w-80"
|
|
132
|
+
formControlName="framework"
|
|
133
|
+
[options]="frameworkOptions"
|
|
134
|
+
placeholder="Select framework"
|
|
135
|
+
searchPlaceholder="Search frameworks..." />
|
|
136
|
+
</form>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## API reference
|
|
140
|
+
|
|
141
|
+
| Input or model | Type | Default |
|
|
142
|
+
| ------------------- | ---------------------------------- | --------------------- |
|
|
143
|
+
| `options` | `ReadonlyArray<ComboboxOption<T>>` | `[]` |
|
|
144
|
+
| `value` | `T \| null` | `null` |
|
|
145
|
+
| `placeholder` | `string` | `'Select…'` |
|
|
146
|
+
| `searchPlaceholder` | `string` | `'Search…'` |
|
|
147
|
+
| `emptyText` | `string` | `'No results found.'` |
|
|
148
|
+
| `disabled` | `boolean` | `false` |
|
|
149
|
+
| `class` | `string` | `''` |
|
|
150
|
+
|
|
151
|
+
Output: `valueChange: T | null`.
|
|
152
|
+
|
|
153
|
+
### `ComboboxOption<T>`
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
interface ComboboxOption<T = unknown> {
|
|
157
|
+
value: T;
|
|
158
|
+
label: string;
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Styling and theming
|
|
164
|
+
|
|
165
|
+
- Pass `class` to the host element for width and layout. The trigger fills the host width.
|
|
166
|
+
- Trigger uses the shared `outline` button variant.
|
|
167
|
+
- Overlay panel class is `ui-combobox-panel`.
|
|
168
|
+
- Overlay width tracks the trigger with `--ui-combobox-trigger-width`.
|
|
169
|
+
|
|
170
|
+
## Accessibility
|
|
171
|
+
|
|
172
|
+
- Trigger exposes `role="combobox"`, `aria-expanded`, `aria-controls`, and `aria-haspopup="listbox"`.
|
|
173
|
+
- Panel content is powered by `ui-command`, which provides the filter input and listbox roles.
|
|
174
|
+
- Escape and outside click close the panel; focus returns to the trigger.
|
|
175
|
+
- Keep a visible label or surrounding explanatory copy when placeholder text alone is not enough context.
|
|
176
|
+
|
|
177
|
+
## Keyboard interactions
|
|
178
|
+
|
|
179
|
+
- Enter or Space opens the trigger because it is a native button.
|
|
180
|
+
- Arrow keys move between filtered command items once the search input is focused.
|
|
181
|
+
- Enter selects the active option, and Escape closes the surface.
|
|
182
|
+
- Tab leaves the combobox in normal DOM order.
|
|
183
|
+
|
|
184
|
+
## Angular notes
|
|
185
|
+
|
|
186
|
+
- `[(value)]` is the simplest signal-friendly binding for standalone components.
|
|
187
|
+
- Because the component implements `ControlValueAccessor`, it also works with reactive forms.
|
|
188
|
+
- Object-backed selections rely on strict equality. Reuse the same object instances from the bound `options` array.
|
|
189
|
+
|
|
190
|
+
## Source parity
|
|
191
|
+
|
|
192
|
+
The current shadcn combobox docs also cover grouped collections, popup triggers,
|
|
193
|
+
clear buttons, invalid styling, input add-ons, and multi-select chips. Those
|
|
194
|
+
variants are not exposed by `ui-combobox` yet.
|
|
195
|
+
|
|
196
|
+
This README documents the supported Angular surface today and calls out the
|
|
197
|
+
upstream shadcn page as a reference for future expansion, not as a promise that
|
|
198
|
+
every upstream example already exists in this package.
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# Command
|
|
2
|
+
|
|
3
|
+
Searchable command palette primitive for quick actions, navigation, and settings.
|
|
4
|
+
|
|
5
|
+
Use Command inline for filterable action lists, or compose it with Dialog to recreate shadcn's `CommandDialog` pattern. The same primitive also powers [Combobox](../combobox/README.md).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
Import the command parts directly from the component package.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {
|
|
13
|
+
CommandComponent,
|
|
14
|
+
CommandEmptyComponent,
|
|
15
|
+
CommandGroupComponent,
|
|
16
|
+
CommandInputComponent,
|
|
17
|
+
CommandItemComponent,
|
|
18
|
+
CommandListComponent,
|
|
19
|
+
CommandSeparatorComponent,
|
|
20
|
+
CommandShortcutComponent,
|
|
21
|
+
} from '@edsis/ui/command';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
When you want a palette launcher like shadcn's `CommandDialog`, add Button and Dialog primitives as well.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { ButtonComponent } from '@edsis/ui/button';
|
|
28
|
+
import {
|
|
29
|
+
DialogComponent,
|
|
30
|
+
DialogDescriptionComponent,
|
|
31
|
+
DialogHeaderComponent,
|
|
32
|
+
DialogTitleComponent,
|
|
33
|
+
} from '@edsis/ui/dialog';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Composition
|
|
37
|
+
|
|
38
|
+
The Angular composition mirrors shadcn's structure while keeping overlay behavior separate.
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
ui-command
|
|
42
|
+
├── input[ui-command-input]
|
|
43
|
+
└── ui-command-list
|
|
44
|
+
├── ui-command-empty
|
|
45
|
+
├── ui-command-group
|
|
46
|
+
│ ├── button[ui-command-item]
|
|
47
|
+
│ └── button[ui-command-item]
|
|
48
|
+
├── ui-command-separator
|
|
49
|
+
└── ui-command-group
|
|
50
|
+
├── button[ui-command-item]
|
|
51
|
+
└── button[ui-command-item]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Basic usage
|
|
55
|
+
|
|
56
|
+
Build the searchable surface from the root, input, list, and grouped items. Add `span[ui-command-shortcut]` when an item should expose a trailing keyboard hint.
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<ui-command class="max-w-md rounded-lg border border-border">
|
|
60
|
+
<input ui-command-input placeholder="Type a command or search..." />
|
|
61
|
+
<ui-command-list>
|
|
62
|
+
<ui-command-empty>No results found.</ui-command-empty>
|
|
63
|
+
|
|
64
|
+
<ui-command-group heading="Suggestions">
|
|
65
|
+
<button type="button" ui-command-item value="Calendar" (selected)="open('calendar')">Calendar</button>
|
|
66
|
+
<button type="button" ui-command-item value="Search Emoji" (selected)="open('emoji')">Search Emoji</button>
|
|
67
|
+
</ui-command-group>
|
|
68
|
+
|
|
69
|
+
<ui-command-separator />
|
|
70
|
+
|
|
71
|
+
<ui-command-group heading="Settings">
|
|
72
|
+
<button type="button" ui-command-item value="Profile" (selected)="open('profile')">
|
|
73
|
+
Profile
|
|
74
|
+
<span ui-command-shortcut>⌘P</span>
|
|
75
|
+
</button>
|
|
76
|
+
</ui-command-group>
|
|
77
|
+
</ui-command-list>
|
|
78
|
+
</ui-command>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Common patterns
|
|
82
|
+
|
|
83
|
+
### Command palette dialog
|
|
84
|
+
|
|
85
|
+
shadcn ships a dedicated `CommandDialog` helper. In this Angular library, compose `ui-dialog` with `ui-command` instead.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const commandOpen = signal(false);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<button type="button" ui-button variant="outline" (click)="commandOpen.set(true)">Open menu</button>
|
|
93
|
+
|
|
94
|
+
<ui-dialog [(open)]="commandOpen">
|
|
95
|
+
<ui-dialog-header>
|
|
96
|
+
<ui-dialog-title>Command palette</ui-dialog-title>
|
|
97
|
+
<ui-dialog-description> Search for navigation, billing, or settings actions. </ui-dialog-description>
|
|
98
|
+
</ui-dialog-header>
|
|
99
|
+
|
|
100
|
+
<ui-command class="mt-4 rounded-lg border border-border">
|
|
101
|
+
<input ui-command-input placeholder="Type a command or search..." />
|
|
102
|
+
<ui-command-list>
|
|
103
|
+
<ui-command-empty>No results found.</ui-command-empty>
|
|
104
|
+
<ui-command-group heading="Suggestions">
|
|
105
|
+
<button type="button" ui-command-item value="Calendar" (selected)="commandOpen.set(false)">Calendar</button>
|
|
106
|
+
</ui-command-group>
|
|
107
|
+
</ui-command-list>
|
|
108
|
+
</ui-command>
|
|
109
|
+
</ui-dialog>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Shortcuts
|
|
113
|
+
|
|
114
|
+
Use `span[ui-command-shortcut]` for keyboard hints aligned to the trailing edge of each row.
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<ui-command class="max-w-md rounded-lg border border-border">
|
|
118
|
+
<input ui-command-input placeholder="Search shortcuts..." />
|
|
119
|
+
<ui-command-list>
|
|
120
|
+
<ui-command-group heading="Quick actions">
|
|
121
|
+
<button type="button" ui-command-item value="Profile">
|
|
122
|
+
Profile
|
|
123
|
+
<span ui-command-shortcut>⌘P</span>
|
|
124
|
+
</button>
|
|
125
|
+
<button type="button" ui-command-item value="Billing">
|
|
126
|
+
Billing
|
|
127
|
+
<span ui-command-shortcut>⌘B</span>
|
|
128
|
+
</button>
|
|
129
|
+
</ui-command-group>
|
|
130
|
+
</ui-command-list>
|
|
131
|
+
</ui-command>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Scrollable command lists
|
|
135
|
+
|
|
136
|
+
The list container defaults to a scrollable max height. Override it with `class` when the palette needs to expose many groups.
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<ui-command class="max-w-xl rounded-lg border border-border">
|
|
140
|
+
<input ui-command-input placeholder="Jump to a tool or action..." />
|
|
141
|
+
<ui-command-list class="max-h-56">
|
|
142
|
+
<ui-command-empty>No results found.</ui-command-empty>
|
|
143
|
+
<ui-command-group heading="Navigation">...</ui-command-group>
|
|
144
|
+
<ui-command-separator />
|
|
145
|
+
<ui-command-group heading="Actions">...</ui-command-group>
|
|
146
|
+
<ui-command-separator />
|
|
147
|
+
<ui-command-group heading="Tools">...</ui-command-group>
|
|
148
|
+
</ui-command-list>
|
|
149
|
+
</ui-command>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Controlled query
|
|
153
|
+
|
|
154
|
+
Two-way bind the query when the parent needs to inspect, reset, or prefill the current search string.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const query = signal('');
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```html
|
|
161
|
+
<ui-command [(query)]="query" class="max-w-md rounded-lg border border-border">
|
|
162
|
+
<input ui-command-input placeholder="Filter actions..." />
|
|
163
|
+
<ui-command-list>...</ui-command-list>
|
|
164
|
+
</ui-command>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### RTL
|
|
168
|
+
|
|
169
|
+
For right-to-left interfaces, apply `dir="rtl"` to the wrapper and input.
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<section dir="rtl" lang="ar" class="max-w-md text-right">
|
|
173
|
+
<ui-command class="rounded-lg border border-border">
|
|
174
|
+
<input ui-command-input placeholder="اكتب أمرًا أو ابحث..." dir="rtl" />
|
|
175
|
+
<ui-command-list>
|
|
176
|
+
<ui-command-empty>لم يتم العثور على نتائج.</ui-command-empty>
|
|
177
|
+
<ui-command-group heading="اقتراحات">...</ui-command-group>
|
|
178
|
+
<ui-command-separator />
|
|
179
|
+
<ui-command-group heading="الإعدادات">...</ui-command-group>
|
|
180
|
+
</ui-command-list>
|
|
181
|
+
</ui-command>
|
|
182
|
+
</section>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## API reference
|
|
186
|
+
|
|
187
|
+
### `CommandComponent`
|
|
188
|
+
|
|
189
|
+
| Input / Model | Type | Default |
|
|
190
|
+
| ------------- | -------- | ------- |
|
|
191
|
+
| `query` | `string` | `''` |
|
|
192
|
+
| `class` | `string` | `''` |
|
|
193
|
+
|
|
194
|
+
### `CommandInputComponent`
|
|
195
|
+
|
|
196
|
+
| Input | Type | Default |
|
|
197
|
+
| ------------- | -------- | ----------------------------- |
|
|
198
|
+
| `placeholder` | `string` | `Type a command or search...` |
|
|
199
|
+
| `class` | `string` | `''` |
|
|
200
|
+
|
|
201
|
+
Behavior:
|
|
202
|
+
|
|
203
|
+
- Uses `role="combobox"` and `aria-autocomplete="list"`.
|
|
204
|
+
- Arrow Down and Arrow Up move the active item.
|
|
205
|
+
- Enter selects the active visible item.
|
|
206
|
+
|
|
207
|
+
### `CommandListComponent`
|
|
208
|
+
|
|
209
|
+
| Input | Type | Default |
|
|
210
|
+
| ------- | -------- | ------- |
|
|
211
|
+
| `class` | `string` | `''` |
|
|
212
|
+
|
|
213
|
+
Behavior: renders the listbox region and scroll container.
|
|
214
|
+
|
|
215
|
+
### `CommandGroupComponent`
|
|
216
|
+
|
|
217
|
+
| Input | Type | Default |
|
|
218
|
+
| --------- | ---------------- | ------- |
|
|
219
|
+
| `heading` | `string \| null` | `null` |
|
|
220
|
+
| `class` | `string` | `''` |
|
|
221
|
+
|
|
222
|
+
### `CommandItemComponent`
|
|
223
|
+
|
|
224
|
+
| Input / Output | Type | Default |
|
|
225
|
+
| -------------- | ----------------------------- | -------------------- |
|
|
226
|
+
| `value` | `string` | `''` |
|
|
227
|
+
| `disabled` | `boolean` | `false` |
|
|
228
|
+
| `class` | `string` | `''` |
|
|
229
|
+
| `selected` | `MouseEvent \| KeyboardEvent` | emitted on selection |
|
|
230
|
+
|
|
231
|
+
Behavior:
|
|
232
|
+
|
|
233
|
+
- Uses `role="option"`.
|
|
234
|
+
- Hides automatically when the current query does not match its `value` or text content.
|
|
235
|
+
- Skips selection when `disabled` is `true`.
|
|
236
|
+
|
|
237
|
+
### Auxiliary parts
|
|
238
|
+
|
|
239
|
+
- `ui-command-empty` appears only when no visible items match the query.
|
|
240
|
+
- `ui-command-separator` renders a divider between groups.
|
|
241
|
+
- `span[ui-command-shortcut]` aligns trailing shortcut text with `ml-auto` styling.
|
|
242
|
+
|
|
243
|
+
## Styling and theming
|
|
244
|
+
|
|
245
|
+
Pass `class` to the root and parts to tune borders, width, list height, and embedded dialog layouts.
|
|
246
|
+
|
|
247
|
+
The primitive already applies shared theme tokens such as `bg-popover`, `text-popover-foreground`, `border-border`, and active-row accent styles. Typical overrides include:
|
|
248
|
+
|
|
249
|
+
- `rounded-lg border border-border` on the root for shadcn-like cards.
|
|
250
|
+
- `max-h-*` on `ui-command-list` for taller or shorter scroll regions.
|
|
251
|
+
- Additional spacing or layout classes on items when an app supplies inline badges or icons.
|
|
252
|
+
|
|
253
|
+
## Accessibility
|
|
254
|
+
|
|
255
|
+
- The input uses combobox semantics while the list exposes listbox-style options.
|
|
256
|
+
- Items expose `aria-selected`, `data-active`, and disabled state markers.
|
|
257
|
+
- Disabled items remain visible for discoverability but are skipped by keyboard selection.
|
|
258
|
+
- Keep item labels descriptive and avoid deeply nested interactive content inside a command item.
|
|
259
|
+
|
|
260
|
+
## Keyboard interactions
|
|
261
|
+
|
|
262
|
+
- Arrow Down and Arrow Up move the active option through visible items.
|
|
263
|
+
- Enter selects the active item.
|
|
264
|
+
- Typing filters items by the configured `value` or fallback text content.
|
|
265
|
+
|
|
266
|
+
## Angular notes
|
|
267
|
+
|
|
268
|
+
- The root exposes a signal-backed `query` model, so `[(query)]` works naturally in standalone components.
|
|
269
|
+
- `button[ui-command-item]` is the most practical item host because it preserves native semantics for click and keyboard handlers.
|
|
270
|
+
- `ComboboxComponent` already builds on this primitive, so keep command examples action-oriented instead of mixing them with form-specific behavior.
|
|
271
|
+
- This primitive intentionally stays presentational. Compose it with higher-level surfaces such as Dialog rather than coupling it to overlay infrastructure.
|
|
272
|
+
|
|
273
|
+
## Source parity
|
|
274
|
+
|
|
275
|
+
This Angular implementation follows shadcn's Command information architecture and `cmdk` mental model while translating the dialog helper into existing `ui-dialog` primitives and Angular selectors.
|