@xui/file-input 2.0.0-alpha.11 → 2.0.0-alpha.12
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-file-input.mjs +65 -40
- package/fesm2022/xui-file-input.mjs.map +1 -1
- package/package.json +3 -3
- package/types/xui-file-input.d.ts +33 -18
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).
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { viewChild, input, booleanAttribute,
|
|
3
|
-
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
2
|
+
import { viewChild, signal, input, booleanAttribute, computed, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
3
|
import { provideIcons, NgIcon } from '@ng-icons/core';
|
|
5
4
|
import { matUploadFileRound } from '@ng-icons/material-icons/round';
|
|
6
|
-
import { xui } from '@xui/core';
|
|
5
|
+
import { createXConfigToken, xui } from '@xui/core';
|
|
6
|
+
import { uniqueId } from '@xui/core/a11y';
|
|
7
|
+
import { XFormFieldControl } from '@xui/core/form-field';
|
|
8
|
+
import { createXErrorState, createXValueAccessor, provideXValueAccessor } from '@xui/core/forms';
|
|
7
9
|
import { XuiIcon } from '@xui/icon';
|
|
8
10
|
import { cva } from 'class-variance-authority';
|
|
9
11
|
|
|
12
|
+
const [injectXuiFileInputConfig, provideXuiFileInputConfig] = createXConfigToken('XuiFileInputConfig', {
|
|
13
|
+
size: 'md',
|
|
14
|
+
fill: false
|
|
15
|
+
});
|
|
16
|
+
|
|
10
17
|
const fileInputVariants = cva('border-border bg-surface-inset text-foreground-muted focus-within:border-focus flex cursor-pointer items-center gap-2 rounded-lg border pe-1 transition-colors has-disabled:cursor-not-allowed has-disabled:opacity-50', {
|
|
11
18
|
variants: {
|
|
12
19
|
size: {
|
|
13
|
-
|
|
20
|
+
md: 'h-(--control-height-md) ps-(--control-padding-md) text-sm',
|
|
14
21
|
sm: 'h-(--control-height-sm) ps-(--control-padding-sm) text-xs'
|
|
15
22
|
},
|
|
16
23
|
fill: {
|
|
@@ -18,7 +25,7 @@ const fileInputVariants = cva('border-border bg-surface-inset text-foreground-mu
|
|
|
18
25
|
false: 'w-auto'
|
|
19
26
|
}
|
|
20
27
|
},
|
|
21
|
-
defaultVariants: { size: '
|
|
28
|
+
defaultVariants: { size: 'md', fill: false }
|
|
22
29
|
});
|
|
23
30
|
/**
|
|
24
31
|
* A styled file picker.
|
|
@@ -34,14 +41,24 @@ const fileInputVariants = cva('border-border bg-surface-inset text-foreground-mu
|
|
|
34
41
|
* clear it, never pre-fill a selection.
|
|
35
42
|
*/
|
|
36
43
|
class XuiFileInput {
|
|
44
|
+
config = injectXuiFileInputConfig();
|
|
37
45
|
field = viewChild.required('field', /* @ts-ignore */
|
|
38
46
|
...(ngDevMode ? [{ debugName: "field" }] : /* istanbul ignore next */ []));
|
|
47
|
+
formState = createXErrorState();
|
|
48
|
+
fieldId = uniqueId('xui-file-input');
|
|
49
|
+
/** Error state for `xui-form-field`, derived from the optional bound form control. */
|
|
50
|
+
errorState = this.formState.errorState;
|
|
51
|
+
/** Points the form field's `<label for>` at the real file input, not the host. */
|
|
52
|
+
controlId = signal(this.fieldId).asReadonly();
|
|
53
|
+
get ngControl() {
|
|
54
|
+
return this.formState.ngControl();
|
|
55
|
+
}
|
|
39
56
|
/** The user-defined classes on the trigger. Merged last so they win. */
|
|
40
57
|
class = input('', /* @ts-ignore */
|
|
41
58
|
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
42
|
-
size = input(
|
|
59
|
+
size = input(this.config.size, /* @ts-ignore */
|
|
43
60
|
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
44
|
-
fill = input(
|
|
61
|
+
fill = input(this.config.fill, { ...(ngDevMode ? { debugName: "fill" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
45
62
|
/** Placeholder shown before anything is chosen. */
|
|
46
63
|
text = input('Choose a file…', /* @ts-ignore */
|
|
47
64
|
...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
@@ -52,10 +69,18 @@ class XuiFileInput {
|
|
|
52
69
|
multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
53
70
|
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
54
71
|
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
cva = createXValueAccessor({
|
|
73
|
+
// The browser forbids programmatically setting a file input's value, so the
|
|
74
|
+
// only write we can honour is a reset to empty.
|
|
75
|
+
onWrite: value => {
|
|
76
|
+
if (!value) {
|
|
77
|
+
this.selection.set(null);
|
|
78
|
+
this.field().nativeElement.value = '';
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
disabled: this.disabled
|
|
82
|
+
});
|
|
83
|
+
isDisabled = this.cva.disabled;
|
|
59
84
|
selection = signal(null, /* @ts-ignore */
|
|
60
85
|
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
61
86
|
hasSelection = computed(() => (this.selection()?.length ?? 0) > 0, /* @ts-ignore */
|
|
@@ -71,33 +96,24 @@ class XuiFileInput {
|
|
|
71
96
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
72
97
|
computedClass = computed(() => xui(fileInputVariants({ size: this.size(), fill: this.fill() }), this.class()), /* @ts-ignore */
|
|
73
98
|
...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
74
|
-
onChange;
|
|
75
|
-
onTouched;
|
|
76
99
|
onSelect(files) {
|
|
77
100
|
const value = files && files.length ? files : null;
|
|
78
101
|
this.selection.set(value);
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
81
|
-
}
|
|
82
|
-
writeValue(value) {
|
|
83
|
-
// The browser forbids programmatically setting a file input's value, so the
|
|
84
|
-
// only write we can honour is a reset to empty.
|
|
85
|
-
if (!value) {
|
|
86
|
-
this.selection.set(null);
|
|
87
|
-
this.field().nativeElement.value = '';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
registerOnChange(fn) {
|
|
91
|
-
this.onChange = fn;
|
|
92
|
-
}
|
|
93
|
-
registerOnTouched(fn) {
|
|
94
|
-
this.onTouched = fn;
|
|
95
|
-
}
|
|
96
|
-
setDisabledState(isDisabled) {
|
|
97
|
-
this.disabledByForm.set(isDisabled);
|
|
102
|
+
this.cva.notifyChange(value);
|
|
103
|
+
this.cva.markTouched();
|
|
98
104
|
}
|
|
105
|
+
writeValue = this.cva.writeValue;
|
|
106
|
+
registerOnChange = this.cva.registerOnChange;
|
|
107
|
+
registerOnTouched = this.cva.registerOnTouched;
|
|
108
|
+
setDisabledState = this.cva.setDisabledState;
|
|
99
109
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiFileInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
100
|
-
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: XuiFileInput, isStandalone: true, selector: "xui-file-input", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fill: { classPropertyName: "fill", publicName: "fill", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block" }, providers: [
|
|
110
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: XuiFileInput, isStandalone: true, selector: "xui-file-input", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fill: { classPropertyName: "fill", publicName: "fill", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block" }, providers: [
|
|
111
|
+
provideXValueAccessor((() => XuiFileInput)),
|
|
112
|
+
{
|
|
113
|
+
provide: XFormFieldControl,
|
|
114
|
+
useExisting: forwardRef((() => XuiFileInput))
|
|
115
|
+
}
|
|
116
|
+
], viewQueries: [{ propertyName: "field", first: true, predicate: ["field"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
101
117
|
<label [class]="computedClass()">
|
|
102
118
|
<ng-icon xui size="sm" name="matUploadFileRound" class="shrink-0" />
|
|
103
119
|
<span class="min-w-0 flex-1 truncate" [class.text-foreground]="hasSelection()">{{ label() }}</span>
|
|
@@ -108,17 +124,18 @@ class XuiFileInput {
|
|
|
108
124
|
</span>
|
|
109
125
|
<input
|
|
110
126
|
#field
|
|
127
|
+
[id]="fieldId"
|
|
111
128
|
type="file"
|
|
112
129
|
class="sr-only"
|
|
113
130
|
[attr.accept]="accept()"
|
|
114
131
|
[multiple]="multiple()"
|
|
115
|
-
[disabled]="
|
|
132
|
+
[disabled]="isDisabled()"
|
|
116
133
|
[attr.aria-label]="ariaLabel() ?? text()"
|
|
117
134
|
(change)="onSelect(field.files)"
|
|
118
|
-
(blur)="
|
|
135
|
+
(blur)="cva.markTouched()"
|
|
119
136
|
/>
|
|
120
137
|
</label>
|
|
121
|
-
`, isInline: true, dependencies: [{ kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: XuiIcon, selector: "ng-icon[xui]", inputs: ["class", "size", "color", "
|
|
138
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: XuiIcon, selector: "ng-icon[xui]", inputs: ["class", "size", "color", "label"], exportAs: ["xuiIcon"] }], viewProviders: [provideIcons({ matUploadFileRound })], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
122
139
|
}
|
|
123
140
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiFileInput, decorators: [{
|
|
124
141
|
type: Component,
|
|
@@ -127,7 +144,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
127
144
|
imports: [NgIcon, XuiIcon],
|
|
128
145
|
viewProviders: [provideIcons({ matUploadFileRound })],
|
|
129
146
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
130
|
-
|
|
147
|
+
encapsulation: ViewEncapsulation.None,
|
|
148
|
+
providers: [
|
|
149
|
+
provideXValueAccessor((() => XuiFileInput)),
|
|
150
|
+
{
|
|
151
|
+
provide: XFormFieldControl,
|
|
152
|
+
useExisting: forwardRef((() => XuiFileInput))
|
|
153
|
+
}
|
|
154
|
+
],
|
|
131
155
|
template: `
|
|
132
156
|
<label [class]="computedClass()">
|
|
133
157
|
<ng-icon xui size="sm" name="matUploadFileRound" class="shrink-0" />
|
|
@@ -139,14 +163,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
139
163
|
</span>
|
|
140
164
|
<input
|
|
141
165
|
#field
|
|
166
|
+
[id]="fieldId"
|
|
142
167
|
type="file"
|
|
143
168
|
class="sr-only"
|
|
144
169
|
[attr.accept]="accept()"
|
|
145
170
|
[multiple]="multiple()"
|
|
146
|
-
[disabled]="
|
|
171
|
+
[disabled]="isDisabled()"
|
|
147
172
|
[attr.aria-label]="ariaLabel() ?? text()"
|
|
148
173
|
(change)="onSelect(field.files)"
|
|
149
|
-
(blur)="
|
|
174
|
+
(blur)="cva.markTouched()"
|
|
150
175
|
/>
|
|
151
176
|
</label>
|
|
152
177
|
`,
|
|
@@ -162,5 +187,5 @@ const XuiFileInputImports = [XuiFileInput];
|
|
|
162
187
|
* Generated bundle index. Do not edit.
|
|
163
188
|
*/
|
|
164
189
|
|
|
165
|
-
export { XuiFileInput, XuiFileInputImports };
|
|
190
|
+
export { XuiFileInput, XuiFileInputImports, fileInputVariants, injectXuiFileInputConfig, provideXuiFileInputConfig };
|
|
166
191
|
//# sourceMappingURL=xui-file-input.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xui-file-input.mjs","sources":["../../../../../../libs/ui/file-input/xui/src/lib/file-input.ts","../../../../../../libs/ui/file-input/xui/src/index.ts","../../../../../../libs/ui/file-input/xui/src/xui-file-input.ts"],"sourcesContent":["import type { BooleanInput } from '@angular/cdk/coercion';\nimport {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n booleanAttribute,\n computed,\n forwardRef,\n input,\n signal,\n viewChild\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matUploadFileRound } from '@ng-icons/material-icons/round';\nimport { xui } from '@xui/core';\nimport type { ChangeFn, TouchFn } from '@xui/core/forms';\nimport { XuiIcon } from '@xui/icon';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { ClassValue } from 'clsx';\n\nconst fileInputVariants = cva(\n 'border-border bg-surface-inset text-foreground-muted focus-within:border-focus flex cursor-pointer items-center gap-2 rounded-lg border pe-1 transition-colors has-disabled:cursor-not-allowed has-disabled:opacity-50',\n {\n variants: {\n size: {\n default: 'h-(--control-height-md) ps-(--control-padding-md) text-sm',\n sm: 'h-(--control-height-sm) ps-(--control-padding-sm) text-xs'\n },\n fill: {\n true: 'w-full',\n false: 'w-auto'\n }\n },\n defaultVariants: { size: 'default', fill: false }\n }\n);\n\nexport type XuiFileInputVariants = VariantProps<typeof fileInputVariants>;\n\n/**\n * A styled file picker.\n *\n * ```html\n * <xui-file-input [(ngModel)]=\"files\" accept=\"image/*\" multiple />\n * ```\n *\n * Wraps a real hidden `<input type=\"file\">`, so the native picker, `accept` and\n * `multiple` all work — this only dresses the trigger and shows the selection.\n * Its value is the `FileList` (or `null`), and it is a `ControlValueAccessor`.\n * A file input is write-only in the DOM for security, so `writeValue` can only\n * clear it, never pre-fill a selection.\n */\n@Component({\n selector: 'xui-file-input',\n imports: [NgIcon, XuiIcon],\n viewProviders: [provideIcons({ matUploadFileRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => XuiFileInput), multi: true }],\n template: `\n <label [class]=\"computedClass()\">\n <ng-icon xui size=\"sm\" name=\"matUploadFileRound\" class=\"shrink-0\" />\n <span class=\"min-w-0 flex-1 truncate\" [class.text-foreground]=\"hasSelection()\">{{ label() }}</span>\n <span\n class=\"bg-surface-raised border-border text-foreground my-0.5 me-0.5 flex shrink-0 items-center rounded-md border px-(--control-padding-sm) text-xs font-medium\"\n >\n {{ buttonText() }}\n </span>\n <input\n #field\n type=\"file\"\n class=\"sr-only\"\n [attr.accept]=\"accept()\"\n [multiple]=\"multiple()\"\n [disabled]=\"disabledState()\"\n [attr.aria-label]=\"ariaLabel() ?? text()\"\n (change)=\"onSelect(field.files)\"\n (blur)=\"onTouched?.()\"\n />\n </label>\n `,\n host: {\n class: 'block'\n }\n})\nexport class XuiFileInput implements ControlValueAccessor {\n private readonly field = viewChild.required<ElementRef<HTMLInputElement>>('field');\n\n /** The user-defined classes on the trigger. Merged last so they win. */\n readonly class = input<ClassValue>('');\n readonly size = input<XuiFileInputVariants['size']>('default');\n readonly fill = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /** Placeholder shown before anything is chosen. */\n readonly text = input('Choose a file…');\n readonly buttonText = input('Browse');\n readonly accept = input<string | null>(null);\n readonly multiple = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n private readonly disabledByForm = signal(false);\n protected readonly disabledState = computed(() => this.disabled() || this.disabledByForm());\n\n private readonly selection = signal<FileList | null>(null);\n protected readonly hasSelection = computed(() => (this.selection()?.length ?? 0) > 0);\n\n /** The current selection: the picker's filename(s), or the placeholder. */\n protected readonly label = computed(() => {\n const files = this.selection();\n\n if (!files || files.length === 0) {\n return this.text();\n }\n\n return files.length === 1 ? files[0].name : `${files.length} files`;\n });\n\n protected readonly computedClass = computed(() =>\n xui(fileInputVariants({ size: this.size(), fill: this.fill() }), this.class())\n );\n\n private onChange?: ChangeFn<FileList | null>;\n protected onTouched?: TouchFn;\n\n protected onSelect(files: FileList | null): void {\n const value = files && files.length ? files : null;\n this.selection.set(value);\n this.onChange?.(value);\n this.onTouched?.();\n }\n\n writeValue(value: FileList | null): void {\n // The browser forbids programmatically setting a file input's value, so the\n // only write we can honour is a reset to empty.\n if (!value) {\n this.selection.set(null);\n this.field().nativeElement.value = '';\n }\n }\n\n registerOnChange(fn: ChangeFn<FileList | null>): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: TouchFn): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.disabledByForm.set(isDisabled);\n }\n}\n","import { XuiFileInput } from './lib/file-input';\n\nexport * from './lib/file-input';\n\nexport const XuiFileInputImports = [XuiFileInput] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAqBA,MAAM,iBAAiB,GAAG,GAAG,CAC3B,wNAAwN,EACxN;AACE,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,OAAO,EAAE,2DAA2D;AACpE,YAAA,EAAE,EAAE;AACL,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,KAAK,EAAE;AACR;AACF,KAAA;IACD,eAAe,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK;AAChD,CAAA,CACF;AAID;;;;;;;;;;;;AAYG;MAiCU,YAAY,CAAA;AACN,IAAA,KAAK,GAAG,SAAS,CAAC,QAAQ,CAA+B,OAAO;8EAAC;;IAGzE,KAAK,GAAG,KAAK,CAAa,EAAE;8EAAC;IAC7B,IAAI,GAAG,KAAK,CAA+B,SAAS;6EAAC;IACrD,IAAI,GAAG,KAAK,CAAwB,KAAK,4EAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;IAG3E,IAAI,GAAG,KAAK,CAAC,gBAAgB;6EAAC;IAC9B,UAAU,GAAG,KAAK,CAAC,QAAQ;mFAAC;IAC5B,MAAM,GAAG,KAAK,CAAgB,IAAI;+EAAC;IACnC,QAAQ,GAAG,KAAK,CAAwB,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;IAC/E,SAAS,GAAG,KAAK,CAAgB,IAAI,iFAAI,KAAK,EAAE,YAAY,EAAA,CAAG;IAE/D,QAAQ,GAAG,KAAK,CAAwB,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;IACvE,cAAc,GAAG,MAAM,CA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AA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AClF5E,MAAM,mBAAmB,GAAG,CAAC,YAAY;;ACJhD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"xui-file-input.mjs","sources":["../../../../../../libs/ui/file-input/xui/src/lib/file-input.token.ts","../../../../../../libs/ui/file-input/xui/src/lib/file-input.ts","../../../../../../libs/ui/file-input/xui/src/index.ts","../../../../../../libs/ui/file-input/xui/src/xui-file-input.ts"],"sourcesContent":["import { createXConfigToken } from '@xui/core';\nimport { XuiFileInputVariants } from './file-input';\n\nexport interface XuiFileInputConfig {\n size: XuiFileInputVariants['size'];\n fill: boolean;\n}\n\nexport const [injectXuiFileInputConfig, provideXuiFileInputConfig] = createXConfigToken<XuiFileInputConfig>(\n 'XuiFileInputConfig',\n {\n size: 'md',\n fill: false\n }\n);\n","import type { BooleanInput } from '@angular/cdk/coercion';\nimport {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n ViewEncapsulation,\n booleanAttribute,\n computed,\n forwardRef,\n input,\n signal,\n viewChild,\n type Signal\n} from '@angular/core';\nimport { ControlValueAccessor, type NgControl } from '@angular/forms';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matUploadFileRound } from '@ng-icons/material-icons/round';\nimport { xui } from '@xui/core';\nimport { uniqueId } from '@xui/core/a11y';\nimport { XFormFieldControl } from '@xui/core/form-field';\nimport { createXErrorState, createXValueAccessor, provideXValueAccessor } from '@xui/core/forms';\nimport { XuiIcon } from '@xui/icon';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { ClassValue } from 'clsx';\nimport { injectXuiFileInputConfig } from './file-input.token';\n\nexport const fileInputVariants = cva(\n 'border-border bg-surface-inset text-foreground-muted focus-within:border-focus flex cursor-pointer items-center gap-2 rounded-lg border pe-1 transition-colors has-disabled:cursor-not-allowed has-disabled:opacity-50',\n {\n variants: {\n size: {\n md: 'h-(--control-height-md) ps-(--control-padding-md) text-sm',\n sm: 'h-(--control-height-sm) ps-(--control-padding-sm) text-xs'\n },\n fill: {\n true: 'w-full',\n false: 'w-auto'\n }\n },\n defaultVariants: { size: 'md', fill: false }\n }\n);\n\nexport type XuiFileInputVariants = VariantProps<typeof fileInputVariants>;\n\n/**\n * A styled file picker.\n *\n * ```html\n * <xui-file-input [(ngModel)]=\"files\" accept=\"image/*\" multiple />\n * ```\n *\n * Wraps a real hidden `<input type=\"file\">`, so the native picker, `accept` and\n * `multiple` all work — this only dresses the trigger and shows the selection.\n * Its value is the `FileList` (or `null`), and it is a `ControlValueAccessor`.\n * A file input is write-only in the DOM for security, so `writeValue` can only\n * clear it, never pre-fill a selection.\n */\n@Component({\n selector: 'xui-file-input',\n imports: [NgIcon, XuiIcon],\n viewProviders: [provideIcons({ matUploadFileRound })],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n providers: [\n provideXValueAccessor(() => XuiFileInput),\n {\n provide: XFormFieldControl,\n useExisting: forwardRef(() => XuiFileInput)\n }\n ],\n template: `\n <label [class]=\"computedClass()\">\n <ng-icon xui size=\"sm\" name=\"matUploadFileRound\" class=\"shrink-0\" />\n <span class=\"min-w-0 flex-1 truncate\" [class.text-foreground]=\"hasSelection()\">{{ label() }}</span>\n <span\n class=\"bg-surface-raised border-border text-foreground my-0.5 me-0.5 flex shrink-0 items-center rounded-md border px-(--control-padding-sm) text-xs font-medium\"\n >\n {{ buttonText() }}\n </span>\n <input\n #field\n [id]=\"fieldId\"\n type=\"file\"\n class=\"sr-only\"\n [attr.accept]=\"accept()\"\n [multiple]=\"multiple()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"ariaLabel() ?? text()\"\n (change)=\"onSelect(field.files)\"\n (blur)=\"cva.markTouched()\"\n />\n </label>\n `,\n host: {\n class: 'block'\n }\n})\nexport class XuiFileInput implements ControlValueAccessor, XFormFieldControl {\n private readonly config = injectXuiFileInputConfig();\n private readonly field = viewChild.required<ElementRef<HTMLInputElement>>('field');\n private readonly formState = createXErrorState();\n protected readonly fieldId = uniqueId('xui-file-input');\n\n /** Error state for `xui-form-field`, derived from the optional bound form control. */\n readonly errorState = this.formState.errorState;\n\n /** Points the form field's `<label for>` at the real file input, not the host. */\n readonly controlId: Signal<string | null> = signal(this.fieldId).asReadonly();\n\n get ngControl(): NgControl | null {\n return this.formState.ngControl();\n }\n\n /** The user-defined classes on the trigger. Merged last so they win. */\n readonly class = input<ClassValue>('');\n readonly size = input<XuiFileInputVariants['size']>(this.config.size);\n readonly fill = input<boolean, BooleanInput>(this.config.fill, { transform: booleanAttribute });\n\n /** Placeholder shown before anything is chosen. */\n readonly text = input('Choose a file…');\n readonly buttonText = input('Browse');\n readonly accept = input<string | null>(null);\n readonly multiple = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n protected readonly cva = createXValueAccessor<FileList | null>({\n // The browser forbids programmatically setting a file input's value, so the\n // only write we can honour is a reset to empty.\n onWrite: value => {\n if (!value) {\n this.selection.set(null);\n this.field().nativeElement.value = '';\n }\n },\n disabled: this.disabled\n });\n protected readonly isDisabled = this.cva.disabled;\n\n private readonly selection = signal<FileList | null>(null);\n protected readonly hasSelection = computed(() => (this.selection()?.length ?? 0) > 0);\n\n /** The current selection: the picker's filename(s), or the placeholder. */\n protected readonly label = computed(() => {\n const files = this.selection();\n\n if (!files || files.length === 0) {\n return this.text();\n }\n\n return files.length === 1 ? files[0].name : `${files.length} files`;\n });\n\n protected readonly computedClass = computed(() =>\n xui(fileInputVariants({ size: this.size(), fill: this.fill() }), this.class())\n );\n\n protected onSelect(files: FileList | null): void {\n const value = files && files.length ? files : null;\n this.selection.set(value);\n this.cva.notifyChange(value);\n this.cva.markTouched();\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 { XuiFileInput } from './lib/file-input';\n\nexport * from './lib/file-input';\nexport * from './lib/file-input.token';\n\nexport const XuiFileInputImports = [XuiFileInput] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAQO,MAAM,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,GAAG,kBAAkB,CACrF,oBAAoB,EACpB;AACE,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,IAAI,EAAE;AACP,CAAA;;ACaI,MAAM,iBAAiB,GAAG,GAAG,CAClC,wNAAwN,EACxN;AACE,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,2DAA2D;AAC/D,YAAA,EAAE,EAAE;AACL,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,KAAK,EAAE;AACR;AACF,KAAA;IACD,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;AAC3C,CAAA;AAKH;;;;;;;;;;;;AAYG;MAyCU,YAAY,CAAA;IACN,MAAM,GAAG,wBAAwB,EAAE;AACnC,IAAA,KAAK,GAAG,SAAS,CAAC,QAAQ,CAA+B,OAAO;8EAAC;IACjE,SAAS,GAAG,iBAAiB,EAAE;AAC7B,IAAA,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC;;AAG9C,IAAA,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU;;IAGtC,SAAS,GAA0B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,UAA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AA,CAAA,EAAA,EAAA,CAAA;;AC/F5E,MAAM,mBAAmB,GAAG,CAAC,YAAY;;ACLhD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xui/file-input",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"description": "Modern Angular 22 UI Library based on TailwindCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@angular/forms": "22",
|
|
42
42
|
"@ng-icons/core": "34",
|
|
43
43
|
"@ng-icons/material-icons": "34",
|
|
44
|
-
"@xui/core": "2.0.0-alpha.
|
|
45
|
-
"@xui/icon": "2.0.0-alpha.
|
|
44
|
+
"@xui/core": "2.0.0-alpha.12",
|
|
45
|
+
"@xui/icon": "2.0.0-alpha.12",
|
|
46
46
|
"class-variance-authority": "^0.7.1",
|
|
47
47
|
"clsx": "^2.1.1"
|
|
48
48
|
},
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import * as _xui_core_forms from '@xui/core/forms';
|
|
1
2
|
import * as _angular_core from '@angular/core';
|
|
3
|
+
import { Signal } from '@angular/core';
|
|
2
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
5
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
4
|
-
import { ControlValueAccessor } from '@angular/forms';
|
|
5
|
-
import {
|
|
6
|
+
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
7
|
+
import { XFormFieldControl } from '@xui/core/form-field';
|
|
6
8
|
import { VariantProps } from 'class-variance-authority';
|
|
7
9
|
import { ClassValue } from 'clsx';
|
|
8
10
|
|
|
9
11
|
declare const fileInputVariants: (props?: ({
|
|
10
|
-
size?: "
|
|
12
|
+
size?: "md" | "sm" | null | undefined;
|
|
11
13
|
fill?: boolean | null | undefined;
|
|
12
14
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
13
15
|
type XuiFileInputVariants = VariantProps<typeof fileInputVariants>;
|
|
@@ -24,11 +26,19 @@ type XuiFileInputVariants = VariantProps<typeof fileInputVariants>;
|
|
|
24
26
|
* A file input is write-only in the DOM for security, so `writeValue` can only
|
|
25
27
|
* clear it, never pre-fill a selection.
|
|
26
28
|
*/
|
|
27
|
-
declare class XuiFileInput implements ControlValueAccessor {
|
|
29
|
+
declare class XuiFileInput implements ControlValueAccessor, XFormFieldControl {
|
|
30
|
+
private readonly config;
|
|
28
31
|
private readonly field;
|
|
32
|
+
private readonly formState;
|
|
33
|
+
protected readonly fieldId: string;
|
|
34
|
+
/** Error state for `xui-form-field`, derived from the optional bound form control. */
|
|
35
|
+
readonly errorState: Signal<boolean>;
|
|
36
|
+
/** Points the form field's `<label for>` at the real file input, not the host. */
|
|
37
|
+
readonly controlId: Signal<string | null>;
|
|
38
|
+
get ngControl(): NgControl | null;
|
|
29
39
|
/** The user-defined classes on the trigger. Merged last so they win. */
|
|
30
40
|
readonly class: _angular_core.InputSignal<ClassValue>;
|
|
31
|
-
readonly size: _angular_core.InputSignal<"
|
|
41
|
+
readonly size: _angular_core.InputSignal<"md" | "sm" | null | undefined>;
|
|
32
42
|
readonly fill: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
33
43
|
/** Placeholder shown before anything is chosen. */
|
|
34
44
|
readonly text: _angular_core.InputSignal<string>;
|
|
@@ -37,25 +47,30 @@ declare class XuiFileInput implements ControlValueAccessor {
|
|
|
37
47
|
readonly multiple: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
38
48
|
readonly ariaLabel: _angular_core.InputSignal<string | null>;
|
|
39
49
|
readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
40
|
-
|
|
41
|
-
protected readonly
|
|
50
|
+
protected readonly cva: _xui_core_forms.XValueAccessor<FileList | null>;
|
|
51
|
+
protected readonly isDisabled: Signal<boolean>;
|
|
42
52
|
private readonly selection;
|
|
43
|
-
protected readonly hasSelection:
|
|
53
|
+
protected readonly hasSelection: Signal<boolean>;
|
|
44
54
|
/** The current selection: the picker's filename(s), or the placeholder. */
|
|
45
|
-
protected readonly label:
|
|
46
|
-
protected readonly computedClass:
|
|
47
|
-
private onChange?;
|
|
48
|
-
protected onTouched?: TouchFn;
|
|
55
|
+
protected readonly label: Signal<string>;
|
|
56
|
+
protected readonly computedClass: Signal<string>;
|
|
49
57
|
protected onSelect(files: FileList | null): void;
|
|
50
|
-
writeValue(value: FileList | null)
|
|
51
|
-
registerOnChange(fn:
|
|
52
|
-
registerOnTouched(fn:
|
|
53
|
-
setDisabledState(isDisabled: boolean)
|
|
58
|
+
readonly writeValue: (value: FileList | null) => void;
|
|
59
|
+
readonly registerOnChange: (fn: _xui_core_forms.XChangeFn<FileList | null>) => void;
|
|
60
|
+
readonly registerOnTouched: (fn: _xui_core_forms.XTouchFn) => void;
|
|
61
|
+
readonly setDisabledState: (isDisabled: boolean) => void;
|
|
54
62
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XuiFileInput, never>;
|
|
55
63
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XuiFileInput, "xui-file-input", never, { "class": { "alias": "class"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "fill": { "alias": "fill"; "required": false; "isSignal": true; }; "text": { "alias": "text"; "required": false; "isSignal": true; }; "buttonText": { "alias": "buttonText"; "required": false; "isSignal": true; }; "accept": { "alias": "accept"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
56
64
|
}
|
|
57
65
|
|
|
66
|
+
interface XuiFileInputConfig {
|
|
67
|
+
size: XuiFileInputVariants['size'];
|
|
68
|
+
fill: boolean;
|
|
69
|
+
}
|
|
70
|
+
declare const injectXuiFileInputConfig: () => XuiFileInputConfig;
|
|
71
|
+
declare const provideXuiFileInputConfig: (config: Partial<XuiFileInputConfig>) => _angular_core.ValueProvider;
|
|
72
|
+
|
|
58
73
|
declare const XuiFileInputImports: readonly [typeof XuiFileInput];
|
|
59
74
|
|
|
60
|
-
export { XuiFileInput, XuiFileInputImports };
|
|
61
|
-
export type { XuiFileInputVariants };
|
|
75
|
+
export { XuiFileInput, XuiFileInputImports, fileInputVariants, injectXuiFileInputConfig, provideXuiFileInputConfig };
|
|
76
|
+
export type { XuiFileInputConfig, XuiFileInputVariants };
|