@xui/suggest 2.0.0-alpha.11 → 2.0.0-alpha.13
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 +142 -156
- package/fesm2022/xui-suggest.mjs +62 -63
- package/fesm2022/xui-suggest.mjs.map +1 -1
- package/package.json +5 -4
- package/types/xui-suggest.d.ts +18 -8
package/README.md
CHANGED
|
@@ -1,89 +1,103 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
1
|
+
<h1 align="center">xUI</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>90 Angular components, one npm package each, themed from a single token layer.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://xuijs.org">Documentation</a> ·
|
|
9
|
+
<a href="https://develop--67d2b4c756077a325913e5d9.chromatic.com/?globals=theme:dark">Storybook</a> ·
|
|
10
|
+
<a href="https://stackblitz.com/fork/xui">StackBlitz</a> ·
|
|
11
|
+
<a href="#components">Components</a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://github.com/rikarin/xui/actions/workflows/release.yml"><img src="https://github.com/rikarin/xui/actions/workflows/release.yml/badge.svg?branch=master" alt="Build status" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@xui/core"><img src="https://img.shields.io/npm/v/%40xui/core.svg" alt="npm version" /></a>
|
|
17
|
+
<a href="https://www.npmjs.com/org/xui"><img src="https://img.shields.io/npm/dm/%40xui/core.svg" alt="Downloads" /></a>
|
|
18
|
+
<a href="https://app.netlify.com/sites/xui/deploys"><img src="https://api.netlify.com/api/v1/badges/fa0cfd14-97df-47fa-8a7c-152e6d4cfda2/deploy-status" alt="Netlify status" /></a>
|
|
3
19
|
</p>
|
|
4
20
|
|
|
5
21
|
---
|
|
6
22
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[](https://app.netlify.com/sites/xui/deploys)
|
|
23
|
+
xUI is an Angular 22 component library styled with Tailwind CSS 4. You compose it from directives and
|
|
24
|
+
standalone components rather than configuring one monolith, and the set goes well past the
|
|
25
|
+
primitives: data tables, dock managers, omnibars, node graphs and date ranges are packages here, not
|
|
26
|
+
things you are left to build.
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
```ts
|
|
29
|
+
import { XuiButtonImports } from '@xui/button';
|
|
30
|
+
|
|
31
|
+
@Component({
|
|
32
|
+
imports: [XuiButtonImports],
|
|
33
|
+
template: `<button xuiButton color="primary">Save changes</button>`
|
|
34
|
+
})
|
|
35
|
+
export class Example {}
|
|
36
|
+
```
|
|
14
37
|
|
|
15
38
|
## Features
|
|
16
39
|
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
- **
|
|
20
|
-
|
|
21
|
-
- **
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| Spinner | [](https://www.npmjs.com/package/%40xui/spinner)<br />[](https://www.npmjs.com/package/%40xui/spinner)<br />[](https://bundlephobia.com/result?p=%40xui/spinner) | Spinner component |
|
|
53
|
-
| Status | [](https://www.npmjs.com/package/%40xui/status)<br />[](https://www.npmjs.com/package/%40xui/status)<br />[](https://bundlephobia.com/result?p=%40xui/status) | Status component |
|
|
54
|
-
| Table | [](https://www.npmjs.com/package/%40xui/table)<br />[](https://www.npmjs.com/package/%40xui/table)<br />[](https://bundlephobia.com/result?p=%40xui/table) | Table component |
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
Install package with **PNPM**
|
|
40
|
+
- **One package per component.** Install `@xui/button` and you ship a button, not a library. Each
|
|
41
|
+
package exports an imports barrel for standalone components.
|
|
42
|
+
- **Signals throughout.** Signal inputs, `OnPush` and zoneless change detection; no `zone.js`
|
|
43
|
+
required.
|
|
44
|
+
- **Themed by tokens, not overrides.** Components style themselves with `bg-surface`,
|
|
45
|
+
`text-foreground-muted`, `border-error-muted`. Light and dark both work without a single `dark:`
|
|
46
|
+
class, and re-colouring an intent is one CSS variable.
|
|
47
|
+
- **Typed variants.** Every visual axis is a typed input backed by
|
|
48
|
+
[CVA](https://cva.style), and the `class` input merges through `tailwind-merge` — your utility
|
|
49
|
+
wins instead of fighting the component's.
|
|
50
|
+
- **Angular CDK underneath.** Overlays, focus traps, roving tabindex, typeahead, drag and drop and
|
|
51
|
+
bidi come from `@angular/cdk`, so keyboard behaviour and RTL are not reimplemented per component.
|
|
52
|
+
- **Built for coding agents.** An MCP server and an agent skill expose the real API of every
|
|
53
|
+
package — see [AI coding agents](#ai-coding-agents).
|
|
54
|
+
|
|
55
|
+
## Requirements
|
|
56
|
+
|
|
57
|
+
| | |
|
|
58
|
+
| ----------------------- | --- |
|
|
59
|
+
| Angular | 22 |
|
|
60
|
+
| Tailwind CSS | 4 |
|
|
61
|
+
| Node (development only) | 24 |
|
|
62
|
+
|
|
63
|
+
## Getting started
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
ng add @xui/core
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
That installs the core package and wires your global stylesheet: the theme import, the CDK overlay
|
|
70
|
+
stylesheet, and a `@source` glob pointing at the published packages. It is idempotent, so running it
|
|
71
|
+
again only adds what is missing. Use `nx add @xui/core` in an Nx workspace, and `--skip-overlay` if
|
|
72
|
+
you will not use dialogs, drawers, popovers, tooltips, menus or toasts.
|
|
73
|
+
|
|
74
|
+
Then add the components you need:
|
|
59
75
|
|
|
60
76
|
```bash
|
|
61
|
-
pnpm
|
|
77
|
+
pnpm add @xui/button @xui/dialog @xui/icon
|
|
62
78
|
```
|
|
63
79
|
|
|
64
80
|
## Theming
|
|
65
81
|
|
|
66
|
-
|
|
67
|
-
`text-foreground-muted`, `border-error-muted` — that resolve through the token layer shipped with
|
|
68
|
-
`@xui/core`. Import it once, after Tailwind:
|
|
82
|
+
To wire the styles by hand, import the token layer once after Tailwind:
|
|
69
83
|
|
|
70
84
|
```css
|
|
71
85
|
@import 'tailwindcss';
|
|
72
86
|
@import '@xui/core/styles/theme.css';
|
|
73
87
|
|
|
74
|
-
/* Only needed
|
|
75
|
-
|
|
88
|
+
/* Only needed for an overlay surface — popover, tooltip, menu, dialog, drawer
|
|
89
|
+
or toast. Without it, overlays render in the document flow. */
|
|
76
90
|
@import '@angular/cdk/overlay-prebuilt.css';
|
|
77
91
|
|
|
78
|
-
/*
|
|
92
|
+
/* Tailwind only emits utilities it can see, and it cannot see node_modules by default. */
|
|
79
93
|
@source '../node_modules/@xui';
|
|
80
94
|
```
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
Put `.dark` (or `[data-theme='dark']`) on `<html>` to switch themes; with neither present the theme
|
|
97
|
+
follows `prefers-color-scheme`. Both selectors work on any element, so a subtree can render in the
|
|
98
|
+
opposite theme.
|
|
85
99
|
|
|
86
|
-
Re-theme by overriding tokens after the import
|
|
100
|
+
Re-theme by overriding tokens after the import. The `darker` / `lighter` / `subtle` / `muted` /
|
|
87
101
|
`emphasis` steps of each intent are derived, so one declaration re-colours the whole ramp:
|
|
88
102
|
|
|
89
103
|
```css
|
|
@@ -93,37 +107,48 @@ Re-theme by overriding tokens after the import — the `darker` / `lighter` / `s
|
|
|
93
107
|
}
|
|
94
108
|
```
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
Controls share one density scale — 24 / 30 / 40px for `sm` / default / `lg` — so a button, an input
|
|
111
|
+
and a date field on the same row line up. Override `--control-height-md` to re-tune the library.
|
|
98
112
|
|
|
99
|
-
|
|
113
|
+
The full token reference, rendered in both themes, is the **Design tokens** page in Storybook.
|
|
100
114
|
|
|
101
|
-
|
|
115
|
+
## Components
|
|
102
116
|
|
|
103
|
-
|
|
117
|
+
<details>
|
|
118
|
+
<summary><strong>All 90 packages</strong>, grouped as they appear in Storybook</summary>
|
|
104
119
|
|
|
105
|
-
|
|
120
|
+
<br />
|
|
106
121
|
|
|
107
|
-
|
|
122
|
+
**Foundations** — [`@xui/icon`](https://www.npmjs.com/package/@xui/icon) · [`@xui/link`](https://www.npmjs.com/package/@xui/link) · [`@xui/text`](https://www.npmjs.com/package/@xui/text)
|
|
108
123
|
|
|
109
|
-
|
|
110
|
-
pnpm start
|
|
111
|
-
```
|
|
124
|
+
**Actions** — [`@xui/button`](https://www.npmjs.com/package/@xui/button) · [`@xui/button-group`](https://www.npmjs.com/package/@xui/button-group) · [`@xui/hotkeys`](https://www.npmjs.com/package/@xui/hotkeys)
|
|
112
125
|
|
|
113
|
-
|
|
126
|
+
**Forms** — [`@xui/cascader`](https://www.npmjs.com/package/@xui/cascader) · [`@xui/checkbox`](https://www.npmjs.com/package/@xui/checkbox) · [`@xui/color-picker`](https://www.npmjs.com/package/@xui/color-picker) · [`@xui/control-card`](https://www.npmjs.com/package/@xui/control-card) · [`@xui/control-group`](https://www.npmjs.com/package/@xui/control-group) · [`@xui/editable-text`](https://www.npmjs.com/package/@xui/editable-text) · [`@xui/file-input`](https://www.npmjs.com/package/@xui/file-input) · [`@xui/form-field`](https://www.npmjs.com/package/@xui/form-field) · [`@xui/html-select`](https://www.npmjs.com/package/@xui/html-select) · [`@xui/input`](https://www.npmjs.com/package/@xui/input) · [`@xui/input-otp`](https://www.npmjs.com/package/@xui/input-otp) · [`@xui/label`](https://www.npmjs.com/package/@xui/label) · [`@xui/multi-select`](https://www.npmjs.com/package/@xui/multi-select) · [`@xui/numeric-input`](https://www.npmjs.com/package/@xui/numeric-input) · [`@xui/radio`](https://www.npmjs.com/package/@xui/radio) · [`@xui/rate`](https://www.npmjs.com/package/@xui/rate) · [`@xui/rich-text-editor`](https://www.npmjs.com/package/@xui/rich-text-editor) · [`@xui/segmented-control`](https://www.npmjs.com/package/@xui/segmented-control) · [`@xui/select`](https://www.npmjs.com/package/@xui/select) · [`@xui/slider`](https://www.npmjs.com/package/@xui/slider) · [`@xui/suggest`](https://www.npmjs.com/package/@xui/suggest) · [`@xui/switch`](https://www.npmjs.com/package/@xui/switch) · [`@xui/tag-input`](https://www.npmjs.com/package/@xui/tag-input) · [`@xui/textarea`](https://www.npmjs.com/package/@xui/textarea) · [`@xui/transfer`](https://www.npmjs.com/package/@xui/transfer) · [`@xui/tree-select`](https://www.npmjs.com/package/@xui/tree-select) · [`@xui/upload`](https://www.npmjs.com/package/@xui/upload)
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
**Date & time** — [`@xui/date-input`](https://www.npmjs.com/package/@xui/date-input) · [`@xui/date-picker`](https://www.npmjs.com/package/@xui/date-picker) · [`@xui/date-range-input`](https://www.npmjs.com/package/@xui/date-range-input) · [`@xui/date-range-picker`](https://www.npmjs.com/package/@xui/date-range-picker) · [`@xui/time-picker`](https://www.npmjs.com/package/@xui/time-picker) · [`@xui/timezone-select`](https://www.npmjs.com/package/@xui/timezone-select)
|
|
129
|
+
|
|
130
|
+
**Data display** — [`@xui/avatar`](https://www.npmjs.com/package/@xui/avatar) · [`@xui/badge`](https://www.npmjs.com/package/@xui/badge) · [`@xui/card`](https://www.npmjs.com/package/@xui/card) · [`@xui/card-list`](https://www.npmjs.com/package/@xui/card-list) · [`@xui/carousel`](https://www.npmjs.com/package/@xui/carousel) · [`@xui/data-table`](https://www.npmjs.com/package/@xui/data-table) · [`@xui/descriptions`](https://www.npmjs.com/package/@xui/descriptions) · [`@xui/entity-title`](https://www.npmjs.com/package/@xui/entity-title) · [`@xui/kbd`](https://www.npmjs.com/package/@xui/kbd) · [`@xui/statistic`](https://www.npmjs.com/package/@xui/statistic) · [`@xui/status`](https://www.npmjs.com/package/@xui/status) · [`@xui/table`](https://www.npmjs.com/package/@xui/table) · [`@xui/tag`](https://www.npmjs.com/package/@xui/tag) · [`@xui/timeline`](https://www.npmjs.com/package/@xui/timeline) · [`@xui/tree`](https://www.npmjs.com/package/@xui/tree)
|
|
131
|
+
|
|
132
|
+
**Navigation** — [`@xui/breadcrumb`](https://www.npmjs.com/package/@xui/breadcrumb) · [`@xui/menubar`](https://www.npmjs.com/package/@xui/menubar) · [`@xui/navbar`](https://www.npmjs.com/package/@xui/navbar) · [`@xui/navigation-menu`](https://www.npmjs.com/package/@xui/navigation-menu) · [`@xui/pagination`](https://www.npmjs.com/package/@xui/pagination) · [`@xui/panel-stack`](https://www.npmjs.com/package/@xui/panel-stack) · [`@xui/steps`](https://www.npmjs.com/package/@xui/steps) · [`@xui/tabs`](https://www.npmjs.com/package/@xui/tabs)
|
|
133
|
+
|
|
134
|
+
**Overlays** — [`@xui/alert`](https://www.npmjs.com/package/@xui/alert) · [`@xui/alert-dialog`](https://www.npmjs.com/package/@xui/alert-dialog) · [`@xui/context-menu`](https://www.npmjs.com/package/@xui/context-menu) · [`@xui/dialog`](https://www.npmjs.com/package/@xui/dialog) · [`@xui/drawer`](https://www.npmjs.com/package/@xui/drawer) · [`@xui/menu`](https://www.npmjs.com/package/@xui/menu) · [`@xui/omnibar`](https://www.npmjs.com/package/@xui/omnibar) · [`@xui/popover`](https://www.npmjs.com/package/@xui/popover) · [`@xui/toast`](https://www.npmjs.com/package/@xui/toast) · [`@xui/tooltip`](https://www.npmjs.com/package/@xui/tooltip)
|
|
135
|
+
|
|
136
|
+
**Feedback** — [`@xui/callout`](https://www.npmjs.com/package/@xui/callout) · [`@xui/non-ideal-state`](https://www.npmjs.com/package/@xui/non-ideal-state) · [`@xui/progress-bar`](https://www.npmjs.com/package/@xui/progress-bar) · [`@xui/result`](https://www.npmjs.com/package/@xui/result) · [`@xui/skeleton`](https://www.npmjs.com/package/@xui/skeleton) · [`@xui/spinner`](https://www.npmjs.com/package/@xui/spinner)
|
|
137
|
+
|
|
138
|
+
**Layout** — [`@xui/accordion`](https://www.npmjs.com/package/@xui/accordion) · [`@xui/aspect-ratio`](https://www.npmjs.com/package/@xui/aspect-ratio) · [`@xui/collapse`](https://www.npmjs.com/package/@xui/collapse) · [`@xui/divider`](https://www.npmjs.com/package/@xui/divider) · [`@xui/dock-manager`](https://www.npmjs.com/package/@xui/dock-manager) · [`@xui/overflow-list`](https://www.npmjs.com/package/@xui/overflow-list) · [`@xui/scroll-area`](https://www.npmjs.com/package/@xui/scroll-area) · [`@xui/section`](https://www.npmjs.com/package/@xui/section) · [`@xui/splitter`](https://www.npmjs.com/package/@xui/splitter)
|
|
139
|
+
|
|
140
|
+
**Visualisation** — [`@xui/echarts`](https://www.npmjs.com/package/@xui/echarts) · [`@xui/konva`](https://www.npmjs.com/package/@xui/konva) · [`@xui/node-graph`](https://www.npmjs.com/package/@xui/node-graph)
|
|
141
|
+
|
|
142
|
+
</details>
|
|
118
143
|
|
|
119
144
|
## AI coding agents
|
|
120
145
|
|
|
121
146
|
Two pieces of tooling teach coding agents how to build with xUI.
|
|
122
147
|
|
|
123
|
-
**MCP server** — [`@xui/mcp`](
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
148
|
+
**MCP server** — [`@xui/mcp`](libs/mcp/README.md) exposes every package's real API (selectors, signal
|
|
149
|
+
inputs, variant axes, outputs), the design tokens, the docs and the Storybook examples as MCP tools.
|
|
150
|
+
It extracts them from the library sources, so every package is covered and the answers match the
|
|
151
|
+
installed version.
|
|
127
152
|
|
|
128
153
|
```json
|
|
129
154
|
{
|
|
@@ -133,85 +158,46 @@ answers match the installed version.
|
|
|
133
158
|
}
|
|
134
159
|
```
|
|
135
160
|
|
|
136
|
-
In this
|
|
137
|
-
once so it exists.
|
|
161
|
+
In this repository `.mcp.json` already points at `dist/libs/mcp/src/server.js` — run
|
|
162
|
+
`pnpm nx build mcp` once so it exists.
|
|
138
163
|
|
|
139
|
-
**Skill** — [`skills/xui`](
|
|
164
|
+
**Skill** — [`skills/xui`](skills/xui/SKILL.md) is the procedural knowledge: the three-layer
|
|
140
165
|
architecture, discovery through the MCP server, composition and styling rules, theming, the
|
|
141
166
|
generators, and the conventions for authoring a package inside the monorepo. `.claude/skills/xui`
|
|
142
167
|
links to it for agents working in this repository.
|
|
143
168
|
|
|
144
|
-
##
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- [ ] Input OTP
|
|
180
|
-
- [ ] Toggle Group
|
|
181
|
-
|
|
182
|
-
### Additional
|
|
183
|
-
|
|
184
|
-
- [ ] Decagram
|
|
185
|
-
- [ ] Settings
|
|
186
|
-
- [ ] Drawer
|
|
187
|
-
- [ ] Panel Bar
|
|
188
|
-
- [ ] Textarea
|
|
189
|
-
- [ ] Time Picker
|
|
190
|
-
- [ ] Image Upload
|
|
191
|
-
- [ ] Banner
|
|
192
|
-
- [ ] Snack bar
|
|
193
|
-
|
|
194
|
-
## Opinionated "components"
|
|
195
|
-
|
|
196
|
-
- [ ] Graph View (Nodes)
|
|
197
|
-
- [ ] Analysis
|
|
198
|
-
- [ ] Charts (NG Charts?)
|
|
199
|
-
|
|
200
|
-
## CLI
|
|
201
|
-
|
|
202
|
-
Make cli to install the components
|
|
203
|
-
|
|
204
|
-
## TODO
|
|
205
|
-
|
|
206
|
-
- Button
|
|
207
|
-
|
|
208
|
-
- Icon
|
|
209
|
-
- Shine
|
|
210
|
-
|
|
211
|
-
- Breadcrumb
|
|
212
|
-
|
|
213
|
-
- fix styling issues
|
|
214
|
-
- on hover stuff
|
|
215
|
-
- data driven component
|
|
216
|
-
|
|
217
|
-
- adjust generator to generate stories into the apps/storybook
|
|
169
|
+
## Browser support
|
|
170
|
+
|
|
171
|
+
The browsers Angular itself supports — see the
|
|
172
|
+
[Angular browser support policy](https://angular.dev/reference/versions#browser-support).
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
The workspace is [Nx](https://nx.dev) + pnpm.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
pnpm install
|
|
180
|
+
pnpm start # documentation site on :4200
|
|
181
|
+
pnpm storybook # component gallery on :4400
|
|
182
|
+
pnpm nx serve admin # the example admin application
|
|
183
|
+
pnpm test # unit tests
|
|
184
|
+
pnpm nx test-storybook ui-storybook # render every story in headless Chromium
|
|
185
|
+
pnpm build # build every package
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org) and are linted — the
|
|
189
|
+
release is cut from them. See [docs/releasing.md](docs/releasing.md) for how a version is published,
|
|
190
|
+
[apps/ui-storybook/README.md](apps/ui-storybook/README.md) before writing stories, and
|
|
191
|
+
[apps/app/README.md](apps/app/README.md) for the documentation site, whose component pages are
|
|
192
|
+
generated from those same stories, and [apps/admin/README.md](apps/admin/README.md) for the example
|
|
193
|
+
admin application — a full app built from these packages, which is the fastest way to see how they
|
|
194
|
+
fit together.
|
|
195
|
+
|
|
196
|
+
## Contributing
|
|
197
|
+
|
|
198
|
+
Bugs and ideas are welcome in [issues](https://github.com/Rikarin/xui/issues). For a change of any
|
|
199
|
+
size, open an issue first so the API can be agreed before the code exists.
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
See [LICENSE](LICENSE).
|
package/fesm2022/xui-suggest.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, booleanAttribute, model,
|
|
3
|
+
import { input, booleanAttribute, model, signal, contentChild, computed, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
4
|
import { xui } from '@xui/core';
|
|
5
|
-
import {
|
|
5
|
+
import { createXValueAccessor, provideXValueAccessor } from '@xui/core/forms';
|
|
6
|
+
import { createXQueryList, createXItemListPredicate, createXActiveOption, trackXItem } from '@xui/core/query';
|
|
6
7
|
import * as i1 from '@xui/popover';
|
|
7
8
|
import { XuiPopoverImports } from '@xui/popover';
|
|
8
9
|
import { XuiSelectOption } from '@xui/select';
|
|
9
10
|
|
|
10
|
-
const defaultMatch = (text, query) => text.toLowerCase().includes(query.toLowerCase());
|
|
11
11
|
/**
|
|
12
12
|
* A typeahead autocomplete: the text input itself is the target. Typing filters a
|
|
13
13
|
* popover list; choosing an item fills the input with its text. Unlike
|
|
14
|
-
* `xui-select`, there is no separate trigger. `[(
|
|
14
|
+
* `xui-select`, there is no separate trigger. `[(value)]` two-way binding.
|
|
15
15
|
*/
|
|
16
16
|
class XuiSuggest {
|
|
17
17
|
class = input('', /* @ts-ignore */
|
|
@@ -29,10 +29,16 @@ class XuiSuggest {
|
|
|
29
29
|
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
30
30
|
noResultsText = input('No results.', /* @ts-ignore */
|
|
31
31
|
...(ngDevMode ? [{ debugName: "noResultsText" }] : /* istanbul ignore next */ []));
|
|
32
|
-
/** The chosen item. Two-way bindable with `[(
|
|
33
|
-
|
|
34
|
-
...(ngDevMode ? [{ debugName: "
|
|
35
|
-
|
|
32
|
+
/** The chosen item. Two-way bindable with `[(value)]`, or via `formControl`/`ngModel`. */
|
|
33
|
+
value = model(null, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
35
|
+
cva = createXValueAccessor({
|
|
36
|
+
onWrite: value => this.value.set(value ?? null),
|
|
37
|
+
disabled: this.disabled
|
|
38
|
+
});
|
|
39
|
+
isDisabled = this.cva.disabled;
|
|
40
|
+
/** Whether the popover has ever been open — so the initial closed state is not "touched". */
|
|
41
|
+
hasOpened = false;
|
|
36
42
|
open = model(false, /* @ts-ignore */
|
|
37
43
|
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
38
44
|
query = signal('', /* @ts-ignore */
|
|
@@ -42,39 +48,50 @@ class XuiSuggest {
|
|
|
42
48
|
...(ngDevMode ? [{ debugName: "editing" }] : /* istanbul ignore next */ []));
|
|
43
49
|
optionTemplate = contentChild((XuiSelectOption), /* @ts-ignore */
|
|
44
50
|
...(ngDevMode ? [{ debugName: "optionTemplate" }] : /* istanbul ignore next */ []));
|
|
45
|
-
list =
|
|
51
|
+
list = createXQueryList({
|
|
46
52
|
items: this.items,
|
|
47
53
|
query: this.query,
|
|
48
54
|
itemText: item => this.itemText()(item),
|
|
49
55
|
itemDisabled: item => this.itemDisabled()(item),
|
|
50
|
-
itemListPredicate: (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
itemListPredicate: createXItemListPredicate({
|
|
57
|
+
itemText: this.itemText,
|
|
58
|
+
itemPredicate: this.itemPredicate
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
// Keyboard navigation over the filtered list (ArrowDown re-opens the popover).
|
|
62
|
+
nav = createXActiveOption({
|
|
63
|
+
list: this.list,
|
|
64
|
+
select: item => this.choose(item),
|
|
65
|
+
close: () => this.open.set(false),
|
|
66
|
+
open: () => this.open.set(true)
|
|
57
67
|
});
|
|
58
68
|
/** The input shows the live query while editing, else the selected item's text. */
|
|
59
69
|
displayValue = computed(() => {
|
|
60
70
|
if (this.editing()) {
|
|
61
71
|
return this.query();
|
|
62
72
|
}
|
|
63
|
-
const selected = this.
|
|
73
|
+
const selected = this.value();
|
|
64
74
|
return selected == null ? '' : this.itemText()(selected);
|
|
65
75
|
}, /* @ts-ignore */
|
|
66
76
|
...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
67
77
|
computedClass = computed(() => xui('inline-block', this.class()), /* @ts-ignore */
|
|
68
78
|
...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
69
|
-
inputClass = computed(() => xui('border-border bg-surface-inset text-foreground placeholder:text-foreground-subtle h-(--control-height-md) w-full min-w-44 rounded-lg border px-(--control-padding-md) text-sm', 'focus-visible:border-focus transition-colors focus:outline-none', this.
|
|
79
|
+
inputClass = computed(() => xui('border-border bg-surface-inset text-foreground placeholder:text-foreground-subtle h-(--control-height-md) w-full min-w-44 rounded-lg border px-(--control-padding-md) text-sm', 'focus-visible:border-focus transition-colors focus:outline-none', this.isDisabled() && 'cursor-not-allowed opacity-50'), /* @ts-ignore */
|
|
70
80
|
...(ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []));
|
|
71
81
|
constructor() {
|
|
72
|
-
// Stop editing (revert to the selected item's text)
|
|
82
|
+
// Stop editing (revert to the selected item's text) and mark the control
|
|
83
|
+
// touched once the popover closes.
|
|
73
84
|
effect(() => {
|
|
74
|
-
if (
|
|
85
|
+
if (this.open()) {
|
|
86
|
+
this.hasOpened = true;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
75
89
|
untracked(() => {
|
|
76
90
|
this.editing.set(false);
|
|
77
91
|
this.query.set('');
|
|
92
|
+
if (this.hasOpened) {
|
|
93
|
+
this.cva.markTouched();
|
|
94
|
+
}
|
|
78
95
|
});
|
|
79
96
|
}
|
|
80
97
|
});
|
|
@@ -82,11 +99,9 @@ class XuiSuggest {
|
|
|
82
99
|
displayText(item) {
|
|
83
100
|
return this.itemText()(item);
|
|
84
101
|
}
|
|
85
|
-
trackItem
|
|
86
|
-
return item ?? index;
|
|
87
|
-
}
|
|
102
|
+
trackItem = trackXItem;
|
|
88
103
|
optionClass(item) {
|
|
89
|
-
return xui('flex cursor-pointer items-center gap-2 rounded px-2 py-1.5', this.list.isActive(item) && 'bg-primary/10', item === this.
|
|
104
|
+
return xui('flex cursor-pointer items-center gap-2 rounded px-2 py-1.5', this.list.isActive(item) && 'bg-primary/10', item === this.value() && 'text-primary font-medium', this.list.isDisabled(item) && 'pointer-events-none opacity-50');
|
|
90
105
|
}
|
|
91
106
|
onInput(event) {
|
|
92
107
|
this.editing.set(true);
|
|
@@ -95,41 +110,22 @@ class XuiSuggest {
|
|
|
95
110
|
this.list.activateFirst();
|
|
96
111
|
}
|
|
97
112
|
onKeydown(event) {
|
|
98
|
-
|
|
99
|
-
case 'ArrowDown':
|
|
100
|
-
event.preventDefault();
|
|
101
|
-
this.open.set(true);
|
|
102
|
-
this.list.moveActiveItem(1);
|
|
103
|
-
break;
|
|
104
|
-
case 'ArrowUp':
|
|
105
|
-
event.preventDefault();
|
|
106
|
-
this.list.moveActiveItem(-1);
|
|
107
|
-
break;
|
|
108
|
-
case 'Enter': {
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
const active = this.list.activeItem();
|
|
111
|
-
if (active != null) {
|
|
112
|
-
this.choose(active);
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case 'Escape':
|
|
117
|
-
this.open.set(false);
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
113
|
+
this.nav.onKeydown(event);
|
|
122
114
|
}
|
|
123
115
|
choose(item) {
|
|
124
116
|
if (this.list.isDisabled(item)) {
|
|
125
117
|
return;
|
|
126
118
|
}
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
119
|
+
this.value.set(item);
|
|
120
|
+
this.cva.notifyChange(item);
|
|
129
121
|
this.open.set(false);
|
|
130
122
|
}
|
|
123
|
+
writeValue = this.cva.writeValue;
|
|
124
|
+
registerOnChange = this.cva.registerOnChange;
|
|
125
|
+
registerOnTouched = this.cva.registerOnTouched;
|
|
126
|
+
setDisabledState = this.cva.setDisabledState;
|
|
131
127
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiSuggest, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
132
|
-
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: XuiSuggest, isStandalone: true, selector: "xui-suggest", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, itemText: { classPropertyName: "itemText", publicName: "itemText", isSignal: true, isRequired: false, transformFunction: null }, itemPredicate: { classPropertyName: "itemPredicate", publicName: "itemPredicate", isSignal: true, isRequired: false, transformFunction: null }, itemDisabled: { classPropertyName: "itemDisabled", publicName: "itemDisabled", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, noResultsText: { classPropertyName: "noResultsText", publicName: "noResultsText", isSignal: true, isRequired: false, transformFunction: null },
|
|
128
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: XuiSuggest, isStandalone: true, selector: "xui-suggest", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, itemText: { classPropertyName: "itemText", publicName: "itemText", isSignal: true, isRequired: false, transformFunction: null }, itemPredicate: { classPropertyName: "itemPredicate", publicName: "itemPredicate", isSignal: true, isRequired: false, transformFunction: null }, itemDisabled: { classPropertyName: "itemDisabled", publicName: "itemDisabled", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, noResultsText: { classPropertyName: "noResultsText", publicName: "noResultsText", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", open: "openChange" }, host: { properties: { "class": "computedClass()" } }, providers: [provideXValueAccessor((() => XuiSuggest))], queries: [{ propertyName: "optionTemplate", first: true, predicate: (XuiSelectOption), descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
133
129
|
<input
|
|
134
130
|
#input
|
|
135
131
|
type="text"
|
|
@@ -137,15 +133,16 @@ class XuiSuggest {
|
|
|
137
133
|
[class]="inputClass()"
|
|
138
134
|
[value]="displayValue()"
|
|
139
135
|
[placeholder]="placeholder()"
|
|
140
|
-
[disabled]="
|
|
136
|
+
[disabled]="isDisabled()"
|
|
137
|
+
[attr.disabled]="isDisabled() ? '' : null"
|
|
141
138
|
[attr.aria-expanded]="open()"
|
|
142
139
|
[attr.aria-autocomplete]="'list'"
|
|
143
140
|
[xuiPopover]="panel"
|
|
144
|
-
[(
|
|
141
|
+
[(open)]="open"
|
|
145
142
|
[role]="'listbox'"
|
|
146
143
|
[matchTargetWidth]="true"
|
|
147
144
|
[minimal]="true"
|
|
148
|
-
[disabled]="
|
|
145
|
+
[disabled]="isDisabled()"
|
|
149
146
|
interactionKind="click-target"
|
|
150
147
|
placement="bottom-start"
|
|
151
148
|
(input)="onInput($event)"
|
|
@@ -162,7 +159,7 @@ class XuiSuggest {
|
|
|
162
159
|
<li
|
|
163
160
|
role="option"
|
|
164
161
|
[class]="optionClass(item)"
|
|
165
|
-
[attr.aria-selected]="item ===
|
|
162
|
+
[attr.aria-selected]="item === value()"
|
|
166
163
|
(click)="choose(item)"
|
|
167
164
|
(mouseenter)="list.setActiveItem(item)"
|
|
168
165
|
>
|
|
@@ -173,7 +170,7 @@ class XuiSuggest {
|
|
|
173
170
|
$implicit: item,
|
|
174
171
|
item: item,
|
|
175
172
|
active: list.isActive(item),
|
|
176
|
-
selected: item ===
|
|
173
|
+
selected: item === value(),
|
|
177
174
|
index: $index
|
|
178
175
|
}"
|
|
179
176
|
/>
|
|
@@ -186,7 +183,7 @@ class XuiSuggest {
|
|
|
186
183
|
}
|
|
187
184
|
</ul>
|
|
188
185
|
</ng-template>
|
|
189
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.XuiPopover, selector: "[xuiPopover]", inputs: ["xuiPopover", "context", "interactionKind", "placement", "offset", "hoverOpenDelay", "hoverCloseDelay", "minimal", "matchTargetWidth", "disabled", "panelClass", "role", "ariaLabel", "
|
|
186
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.XuiPopover, selector: "[xuiPopover]", inputs: ["xuiPopover", "context", "interactionKind", "placement", "offset", "hoverOpenDelay", "hoverCloseDelay", "minimal", "matchTargetWidth", "disabled", "panelClass", "role", "ariaLabel", "open"], outputs: ["openChange", "opened", "closed"], exportAs: ["xuiPopover"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
190
187
|
}
|
|
191
188
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiSuggest, decorators: [{
|
|
192
189
|
type: Component,
|
|
@@ -201,15 +198,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
201
198
|
[class]="inputClass()"
|
|
202
199
|
[value]="displayValue()"
|
|
203
200
|
[placeholder]="placeholder()"
|
|
204
|
-
[disabled]="
|
|
201
|
+
[disabled]="isDisabled()"
|
|
202
|
+
[attr.disabled]="isDisabled() ? '' : null"
|
|
205
203
|
[attr.aria-expanded]="open()"
|
|
206
204
|
[attr.aria-autocomplete]="'list'"
|
|
207
205
|
[xuiPopover]="panel"
|
|
208
|
-
[(
|
|
206
|
+
[(open)]="open"
|
|
209
207
|
[role]="'listbox'"
|
|
210
208
|
[matchTargetWidth]="true"
|
|
211
209
|
[minimal]="true"
|
|
212
|
-
[disabled]="
|
|
210
|
+
[disabled]="isDisabled()"
|
|
213
211
|
interactionKind="click-target"
|
|
214
212
|
placement="bottom-start"
|
|
215
213
|
(input)="onInput($event)"
|
|
@@ -226,7 +224,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
226
224
|
<li
|
|
227
225
|
role="option"
|
|
228
226
|
[class]="optionClass(item)"
|
|
229
|
-
[attr.aria-selected]="item ===
|
|
227
|
+
[attr.aria-selected]="item === value()"
|
|
230
228
|
(click)="choose(item)"
|
|
231
229
|
(mouseenter)="list.setActiveItem(item)"
|
|
232
230
|
>
|
|
@@ -237,7 +235,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
237
235
|
$implicit: item,
|
|
238
236
|
item: item,
|
|
239
237
|
active: list.isActive(item),
|
|
240
|
-
selected: item ===
|
|
238
|
+
selected: item === value(),
|
|
241
239
|
index: $index
|
|
242
240
|
}"
|
|
243
241
|
/>
|
|
@@ -254,10 +252,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
254
252
|
host: {
|
|
255
253
|
'[class]': 'computedClass()'
|
|
256
254
|
},
|
|
255
|
+
providers: [provideXValueAccessor((() => XuiSuggest))],
|
|
257
256
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
258
257
|
encapsulation: ViewEncapsulation.None
|
|
259
258
|
}]
|
|
260
|
-
}], ctorParameters: () => [], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], itemText: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemText", required: false }] }], itemPredicate: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemPredicate", required: false }] }], itemDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemDisabled", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], noResultsText: [{ type: i0.Input, args: [{ isSignal: true, alias: "noResultsText", required: false }] }],
|
|
259
|
+
}], ctorParameters: () => [], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], itemText: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemText", required: false }] }], itemPredicate: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemPredicate", required: false }] }], itemDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemDisabled", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], noResultsText: [{ type: i0.Input, args: [{ isSignal: true, alias: "noResultsText", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], open: [{ type: i0.Input, args: [{ isSignal: true, alias: "open", required: false }] }, { type: i0.Output, args: ["openChange"] }], optionTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => XuiSelectOption), { isSignal: true }] }] } });
|
|
261
260
|
|
|
262
261
|
const XuiSuggestImports = [XuiSuggest];
|
|
263
262
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xui-suggest.mjs","sources":["../../../../../../libs/ui/suggest/xui/src/lib/suggest.ts","../../../../../../libs/ui/suggest/xui/src/index.ts","../../../../../../libs/ui/suggest/xui/src/xui-suggest.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport { NgTemplateOutlet } from '@angular/common';\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n effect,\n input,\n model,\n output,\n signal,\n untracked,\n ViewEncapsulation\n} from '@angular/core';\nimport { xui } from '@xui/core';\nimport { createQueryList } from '@xui/core/query';\nimport { XuiPopoverImports } from '@xui/popover';\nimport { XuiSelectOption } from '@xui/select';\nimport type { ClassValue } from 'clsx';\n\nconst defaultMatch = (text: string, query: string): boolean => text.toLowerCase().includes(query.toLowerCase());\n\n/**\n * A typeahead autocomplete: the text input itself is the target. Typing filters a\n * popover list; choosing an item fills the input with its text. Unlike\n * `xui-select`, there is no separate trigger. `[(selectedItem)]` two-way binding.\n */\n@Component({\n selector: 'xui-suggest',\n imports: [NgTemplateOutlet, XuiPopoverImports],\n template: `\n <input\n #input\n type=\"text\"\n [attr.role]=\"'combobox'\"\n [class]=\"inputClass()\"\n [value]=\"displayValue()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-autocomplete]=\"'list'\"\n [xuiPopover]=\"panel\"\n [(isOpen)]=\"open\"\n [role]=\"'listbox'\"\n [matchTargetWidth]=\"true\"\n [minimal]=\"true\"\n [disabled]=\"disabled()\"\n interactionKind=\"click-target\"\n placement=\"bottom-start\"\n (input)=\"onInput($event)\"\n (focus)=\"open.set(true)\"\n (keydown)=\"onKeydown($event)\"\n />\n\n <ng-template #panel>\n <ul role=\"listbox\" class=\"m-0 max-h-60 list-none overflow-y-auto p-1 text-sm\">\n @for (item of list.filteredItems(); track trackItem($index, item)) {\n <!-- Keyboard navigation runs through the input, so options are pointer\n targets rather than individual tab stops. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <li\n role=\"option\"\n [class]=\"optionClass(item)\"\n [attr.aria-selected]=\"item === selectedItem()\"\n (click)=\"choose(item)\"\n (mouseenter)=\"list.setActiveItem(item)\"\n >\n @if (optionTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl.template\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n item: item,\n active: list.isActive(item),\n selected: item === selectedItem(),\n index: $index\n }\"\n />\n } @else {\n {{ displayText(item) }}\n }\n </li>\n } @empty {\n <li class=\"text-foreground-muted px-2 py-2\">{{ noResultsText() }}</li>\n }\n </ul>\n </ng-template>\n `,\n host: {\n '[class]': 'computedClass()'\n },\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class XuiSuggest<T> {\n readonly class = input<ClassValue>('');\n\n readonly items = input<readonly T[]>([]);\n readonly itemText = input<(item: T) => string>((item: T) => (item == null ? '' : String(item)));\n readonly itemPredicate = input<(query: string, item: T) => boolean>();\n readonly itemDisabled = input<(item: T) => boolean>(() => false);\n\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n readonly placeholder = input<string>('Search…');\n readonly noResultsText = input<string>('No results.');\n\n /** The chosen item. Two-way bindable with `[(selectedItem)]`. */\n readonly selectedItem = model<T | null>(null);\n\n readonly selectionChange = output<T>();\n\n protected readonly open = model(false);\n protected readonly query = signal('');\n /** Whether the user is actively editing (so the input shows the query). */\n private readonly editing = signal(false);\n\n protected readonly optionTemplate = contentChild(XuiSelectOption<T>);\n\n protected readonly list = createQueryList<T>({\n items: this.items,\n query: this.query,\n itemText: item => this.itemText()(item),\n itemDisabled: item => this.itemDisabled()(item),\n itemListPredicate: (q, items) => {\n if (!q) {\n return items as T[];\n }\n\n const predicate = this.itemPredicate();\n return items.filter(item => (predicate ? predicate(q, item) : defaultMatch(this.itemText()(item), q)));\n }\n });\n\n /** The input shows the live query while editing, else the selected item's text. */\n protected readonly displayValue = computed(() => {\n if (this.editing()) {\n return this.query();\n }\n\n const selected = this.selectedItem();\n return selected == null ? '' : this.itemText()(selected);\n });\n\n protected readonly computedClass = computed(() => xui('inline-block', this.class()));\n\n protected readonly inputClass = computed(() =>\n xui(\n 'border-border bg-surface-inset text-foreground placeholder:text-foreground-subtle h-(--control-height-md) w-full min-w-44 rounded-lg border px-(--control-padding-md) text-sm',\n 'focus-visible:border-focus transition-colors focus:outline-none',\n this.disabled() && 'cursor-not-allowed opacity-50'\n )\n );\n\n constructor() {\n // Stop editing (revert to the selected item's text) once the popover closes.\n effect(() => {\n if (!this.open()) {\n untracked(() => {\n this.editing.set(false);\n this.query.set('');\n });\n }\n });\n }\n\n protected displayText(item: T): string {\n return this.itemText()(item);\n }\n\n protected trackItem(index: number, item: T): unknown {\n return item ?? index;\n }\n\n protected optionClass(item: T): string {\n return xui(\n 'flex cursor-pointer items-center gap-2 rounded px-2 py-1.5',\n this.list.isActive(item) && 'bg-primary/10',\n item === this.selectedItem() && 'text-primary font-medium',\n this.list.isDisabled(item) && 'pointer-events-none opacity-50'\n );\n }\n\n protected onInput(event: Event): void {\n this.editing.set(true);\n this.open.set(true);\n this.query.set((event.target as HTMLInputElement).value);\n this.list.activateFirst();\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.open.set(true);\n this.list.moveActiveItem(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.list.moveActiveItem(-1);\n break;\n case 'Enter': {\n event.preventDefault();\n const active = this.list.activeItem();\n if (active != null) {\n this.choose(active);\n }\n break;\n }\n case 'Escape':\n this.open.set(false);\n break;\n default:\n return;\n }\n }\n\n protected choose(item: T): void {\n if (this.list.isDisabled(item)) {\n return;\n }\n\n this.selectedItem.set(item);\n this.selectionChange.emit(item);\n this.open.set(false);\n }\n}\n","import { XuiSuggest } from './lib/suggest';\n\nexport * from './lib/suggest';\n\nexport const XuiSuggestImports = [XuiSuggest] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAsBA,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,KAAa,KAAc,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AAE/G;;;;AAIG;MAoEU,UAAU,CAAA;IACZ,KAAK,GAAG,KAAK,CAAa,EAAE;8EAAC;IAE7B,KAAK,GAAG,KAAK,CAAe,EAAE;8EAAC;IAC/B,QAAQ,GAAG,KAAK,CAAsB,CAAC,IAAO,MAAM,IAAI,IAAI,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;iFAAC;AACtF,IAAA,aAAa,GAAG,KAAK;iGAAuC;AAC5D,IAAA,YAAY,GAAG,KAAK,CAAuB,MAAM,KAAK;qFAAC;IAEvD,QAAQ,GAAG,KAAK,CAAwB,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;IAC/E,WAAW,GAAG,KAAK,CAAS,SAAS;oFAAC;IACtC,aAAa,GAAG,KAAK,CAAS,aAAa;sFAAC;;IAG5C,YAAY,GAAG,KAAK,CAAW,IAAI;qFAAC;IAEpC,eAAe,GAAG,MAAM,EAAK;IAEnB,IAAI,GAAG,KAAK,CAAC,KAAK;6EAAC;IACnB,KAAK,GAAG,MAAM,CAAC,EAAE;8EAAC;;IAEpB,OAAO,GAAG,MAAM,CAAC,KAAK;gFAAC;AAErB,IAAA,cAAc,GAAG,YAAY,EAAC,eAAkB;uFAAC;IAEjD,IAAI,GAAG,eAAe,CAAI;QAC3C,KAAK,EAAE,IAAI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AA,IAAA,EAAA,CAAA;;2FAiEf,UAAU,EAAA,UAAA,EAAA,CAAA;kBAnEtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,OAAO,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;AAC9C,oBAAA,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDT,EAAA,CAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE;AACZ,qBAAA;oBACD,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,aAAa,EAAE,iBAAiB,CAAC;AAClC,iBAAA;ovCAuBkD,eAAkB,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AClH9D,MAAM,iBAAiB,GAAG,CAAC,UAAU;;ACJ5C;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"xui-suggest.mjs","sources":["../../../../../../libs/ui/suggest/xui/src/lib/suggest.ts","../../../../../../libs/ui/suggest/xui/src/index.ts","../../../../../../libs/ui/suggest/xui/src/xui-suggest.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport { NgTemplateOutlet } from '@angular/common';\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n effect,\n input,\n model,\n signal,\n untracked,\n ViewEncapsulation\n} from '@angular/core';\nimport type { ControlValueAccessor } from '@angular/forms';\nimport { xui } from '@xui/core';\nimport { createXValueAccessor, provideXValueAccessor } from '@xui/core/forms';\nimport { createXActiveOption, createXItemListPredicate, createXQueryList, trackXItem } from '@xui/core/query';\nimport { XuiPopoverImports } from '@xui/popover';\nimport { XuiSelectOption } from '@xui/select';\nimport type { ClassValue } from 'clsx';\n\n/**\n * A typeahead autocomplete: the text input itself is the target. Typing filters a\n * popover list; choosing an item fills the input with its text. Unlike\n * `xui-select`, there is no separate trigger. `[(value)]` two-way binding.\n */\n@Component({\n selector: 'xui-suggest',\n imports: [NgTemplateOutlet, XuiPopoverImports],\n template: `\n <input\n #input\n type=\"text\"\n [attr.role]=\"'combobox'\"\n [class]=\"inputClass()\"\n [value]=\"displayValue()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"isDisabled()\"\n [attr.disabled]=\"isDisabled() ? '' : null\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-autocomplete]=\"'list'\"\n [xuiPopover]=\"panel\"\n [(open)]=\"open\"\n [role]=\"'listbox'\"\n [matchTargetWidth]=\"true\"\n [minimal]=\"true\"\n [disabled]=\"isDisabled()\"\n interactionKind=\"click-target\"\n placement=\"bottom-start\"\n (input)=\"onInput($event)\"\n (focus)=\"open.set(true)\"\n (keydown)=\"onKeydown($event)\"\n />\n\n <ng-template #panel>\n <ul role=\"listbox\" class=\"m-0 max-h-60 list-none overflow-y-auto p-1 text-sm\">\n @for (item of list.filteredItems(); track trackItem($index, item)) {\n <!-- Keyboard navigation runs through the input, so options are pointer\n targets rather than individual tab stops. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <li\n role=\"option\"\n [class]=\"optionClass(item)\"\n [attr.aria-selected]=\"item === value()\"\n (click)=\"choose(item)\"\n (mouseenter)=\"list.setActiveItem(item)\"\n >\n @if (optionTemplate(); as tpl) {\n <ng-container\n [ngTemplateOutlet]=\"tpl.template\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n item: item,\n active: list.isActive(item),\n selected: item === value(),\n index: $index\n }\"\n />\n } @else {\n {{ displayText(item) }}\n }\n </li>\n } @empty {\n <li class=\"text-foreground-muted px-2 py-2\">{{ noResultsText() }}</li>\n }\n </ul>\n </ng-template>\n `,\n host: {\n '[class]': 'computedClass()'\n },\n providers: [provideXValueAccessor(() => XuiSuggest)],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None\n})\nexport class XuiSuggest<T> implements ControlValueAccessor {\n readonly class = input<ClassValue>('');\n\n readonly items = input<readonly T[]>([]);\n readonly itemText = input<(item: T) => string>((item: T) => (item == null ? '' : String(item)));\n readonly itemPredicate = input<(query: string, item: T) => boolean>();\n readonly itemDisabled = input<(item: T) => boolean>(() => false);\n\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n readonly placeholder = input<string>('Search…');\n readonly noResultsText = input<string>('No results.');\n\n /** The chosen item. Two-way bindable with `[(value)]`, or via `formControl`/`ngModel`. */\n readonly value = model<T | null>(null);\n\n protected readonly cva = createXValueAccessor<T | null>({\n onWrite: value => this.value.set(value ?? null),\n disabled: this.disabled\n });\n protected readonly isDisabled = this.cva.disabled;\n\n /** Whether the popover has ever been open — so the initial closed state is not \"touched\". */\n private hasOpened = false;\n\n protected readonly open = model(false);\n protected readonly query = signal('');\n /** Whether the user is actively editing (so the input shows the query). */\n private readonly editing = signal(false);\n\n protected readonly optionTemplate = contentChild(XuiSelectOption<T>);\n\n protected readonly list = createXQueryList<T>({\n items: this.items,\n query: this.query,\n itemText: item => this.itemText()(item),\n itemDisabled: item => this.itemDisabled()(item),\n itemListPredicate: createXItemListPredicate({\n itemText: this.itemText,\n itemPredicate: this.itemPredicate\n })\n });\n\n // Keyboard navigation over the filtered list (ArrowDown re-opens the popover).\n private readonly nav = createXActiveOption<T>({\n list: this.list,\n select: item => this.choose(item),\n close: () => this.open.set(false),\n open: () => this.open.set(true)\n });\n\n /** The input shows the live query while editing, else the selected item's text. */\n protected readonly displayValue = computed(() => {\n if (this.editing()) {\n return this.query();\n }\n\n const selected = this.value();\n return selected == null ? '' : this.itemText()(selected);\n });\n\n protected readonly computedClass = computed(() => xui('inline-block', this.class()));\n\n protected readonly inputClass = computed(() =>\n xui(\n 'border-border bg-surface-inset text-foreground placeholder:text-foreground-subtle h-(--control-height-md) w-full min-w-44 rounded-lg border px-(--control-padding-md) text-sm',\n 'focus-visible:border-focus transition-colors focus:outline-none',\n this.isDisabled() && 'cursor-not-allowed opacity-50'\n )\n );\n\n constructor() {\n // Stop editing (revert to the selected item's text) and mark the control\n // touched once the popover closes.\n effect(() => {\n if (this.open()) {\n this.hasOpened = true;\n } else {\n untracked(() => {\n this.editing.set(false);\n this.query.set('');\n if (this.hasOpened) {\n this.cva.markTouched();\n }\n });\n }\n });\n }\n\n protected displayText(item: T): string {\n return this.itemText()(item);\n }\n\n protected readonly trackItem = trackXItem;\n\n protected optionClass(item: T): string {\n return xui(\n 'flex cursor-pointer items-center gap-2 rounded px-2 py-1.5',\n this.list.isActive(item) && 'bg-primary/10',\n item === this.value() && 'text-primary font-medium',\n this.list.isDisabled(item) && 'pointer-events-none opacity-50'\n );\n }\n\n protected onInput(event: Event): void {\n this.editing.set(true);\n this.open.set(true);\n this.query.set((event.target as HTMLInputElement).value);\n this.list.activateFirst();\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n this.nav.onKeydown(event);\n }\n\n protected choose(item: T): void {\n if (this.list.isDisabled(item)) {\n return;\n }\n\n this.value.set(item);\n this.cva.notifyChange(item);\n this.open.set(false);\n }\n\n readonly writeValue = this.cva.writeValue;\n readonly registerOnChange = this.cva.registerOnChange;\n readonly registerOnTouched = this.cva.registerOnTouched;\n readonly setDisabledState = this.cva.setDisabledState;\n}\n","import { XuiSuggest } from './lib/suggest';\n\nexport * from './lib/suggest';\n\nexport const XuiSuggestImports = [XuiSuggest] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAuBA;;;;AAIG;MAsEU,UAAU,CAAA;IACZ,KAAK,GAAG,KAAK,CAAa,EAAE;8EAAC;IAE7B,KAAK,GAAG,KAAK,CAAe,EAAE;8EAAC;IAC/B,QAAQ,GAAG,KAAK,CAAsB,CAAC,IAAO,MAAM,IAAI,IAAI,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;iFAA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AiB,GAAG,CAAC,UAAU;;ACJ5C;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xui/suggest",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.13",
|
|
4
4
|
"description": "Modern Angular 22 UI Library based on TailwindCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"@angular/cdk": "22",
|
|
40
40
|
"@angular/common": "22",
|
|
41
41
|
"@angular/core": "22",
|
|
42
|
-
"@
|
|
43
|
-
"@xui/
|
|
44
|
-
"@xui/
|
|
42
|
+
"@angular/forms": "22",
|
|
43
|
+
"@xui/core": "2.0.0-alpha.13",
|
|
44
|
+
"@xui/popover": "2.0.0-alpha.13",
|
|
45
|
+
"@xui/select": "2.0.0-alpha.13",
|
|
45
46
|
"clsx": "^2.1.1"
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|
package/types/xui-suggest.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as _xui_core_query from '@xui/core/query';
|
|
2
|
+
import * as _xui_core_forms from '@xui/core/forms';
|
|
2
3
|
import * as _angular_core from '@angular/core';
|
|
3
4
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
5
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
4
6
|
import { XuiSelectOption } from '@xui/select';
|
|
5
7
|
import { ClassValue } from 'clsx';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A typeahead autocomplete: the text input itself is the target. Typing filters a
|
|
9
11
|
* popover list; choosing an item fills the input with its text. Unlike
|
|
10
|
-
* `xui-select`, there is no separate trigger. `[(
|
|
12
|
+
* `xui-select`, there is no separate trigger. `[(value)]` two-way binding.
|
|
11
13
|
*/
|
|
12
|
-
declare class XuiSuggest<T> {
|
|
14
|
+
declare class XuiSuggest<T> implements ControlValueAccessor {
|
|
13
15
|
readonly class: _angular_core.InputSignal<ClassValue>;
|
|
14
16
|
readonly items: _angular_core.InputSignal<readonly T[]>;
|
|
15
17
|
readonly itemText: _angular_core.InputSignal<(item: T) => string>;
|
|
@@ -18,28 +20,36 @@ declare class XuiSuggest<T> {
|
|
|
18
20
|
readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
19
21
|
readonly placeholder: _angular_core.InputSignal<string>;
|
|
20
22
|
readonly noResultsText: _angular_core.InputSignal<string>;
|
|
21
|
-
/** The chosen item. Two-way bindable with `[(
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
23
|
+
/** The chosen item. Two-way bindable with `[(value)]`, or via `formControl`/`ngModel`. */
|
|
24
|
+
readonly value: _angular_core.ModelSignal<T | null>;
|
|
25
|
+
protected readonly cva: _xui_core_forms.XValueAccessor<T | null>;
|
|
26
|
+
protected readonly isDisabled: _angular_core.Signal<boolean>;
|
|
27
|
+
/** Whether the popover has ever been open — so the initial closed state is not "touched". */
|
|
28
|
+
private hasOpened;
|
|
24
29
|
protected readonly open: _angular_core.ModelSignal<boolean>;
|
|
25
30
|
protected readonly query: _angular_core.WritableSignal<string>;
|
|
26
31
|
/** Whether the user is actively editing (so the input shows the query). */
|
|
27
32
|
private readonly editing;
|
|
28
33
|
protected readonly optionTemplate: _angular_core.Signal<XuiSelectOption<any> | undefined>;
|
|
29
|
-
protected readonly list: _xui_core_query.
|
|
34
|
+
protected readonly list: _xui_core_query.XQueryList<T>;
|
|
35
|
+
private readonly nav;
|
|
30
36
|
/** The input shows the live query while editing, else the selected item's text. */
|
|
31
37
|
protected readonly displayValue: _angular_core.Signal<string>;
|
|
32
38
|
protected readonly computedClass: _angular_core.Signal<string>;
|
|
33
39
|
protected readonly inputClass: _angular_core.Signal<string>;
|
|
34
40
|
constructor();
|
|
35
41
|
protected displayText(item: T): string;
|
|
36
|
-
protected trackItem(index: number, item:
|
|
42
|
+
protected readonly trackItem: (index: number, item: unknown) => unknown;
|
|
37
43
|
protected optionClass(item: T): string;
|
|
38
44
|
protected onInput(event: Event): void;
|
|
39
45
|
protected onKeydown(event: KeyboardEvent): void;
|
|
40
46
|
protected choose(item: T): void;
|
|
47
|
+
readonly writeValue: (value: T | null) => void;
|
|
48
|
+
readonly registerOnChange: (fn: _xui_core_forms.XChangeFn<T | null>) => void;
|
|
49
|
+
readonly registerOnTouched: (fn: _xui_core_forms.XTouchFn) => void;
|
|
50
|
+
readonly setDisabledState: (isDisabled: boolean) => void;
|
|
41
51
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XuiSuggest<any>, never>;
|
|
42
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XuiSuggest<any>, "xui-suggest", never, { "class": { "alias": "class"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "itemText": { "alias": "itemText"; "required": false; "isSignal": true; }; "itemPredicate": { "alias": "itemPredicate"; "required": false; "isSignal": true; }; "itemDisabled": { "alias": "itemDisabled"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "noResultsText": { "alias": "noResultsText"; "required": false; "isSignal": true; }; "
|
|
52
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XuiSuggest<any>, "xui-suggest", never, { "class": { "alias": "class"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "itemText": { "alias": "itemText"; "required": false; "isSignal": true; }; "itemPredicate": { "alias": "itemPredicate"; "required": false; "isSignal": true; }; "itemDisabled": { "alias": "itemDisabled"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "noResultsText": { "alias": "noResultsText"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "open": { "alias": "open"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "open": "openChange"; }, ["optionTemplate"], never, true, never>;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
declare const XuiSuggestImports: readonly [typeof XuiSuggest];
|