@ferrlabs/ui-ng 1.68.5 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -2
- package/fesm2022/ferrlabs-ui-ng.mjs +534 -25
- package/fesm2022/ferrlabs-ui-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ferrlabs-ui-ng.d.ts +146 -1
- package/types/ferrlabs-ui-ng.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -164,13 +164,98 @@ list in place and emits `localeChange` with the chosen code. The app applies the
|
|
|
164
164
|
`ThemeService` (root) holds the preference as a signal (`preference()`, `resolved()`,
|
|
165
165
|
`setPreference()`), stores it in `localStorage` under `flr-theme`, sets `data-theme="dark"` on
|
|
166
166
|
`<html>` for dark and removes the attribute for light, and follows `prefers-color-scheme` while the
|
|
167
|
-
preference is `system`. It runs once something injects it
|
|
168
|
-
|
|
167
|
+
preference is `system`. It runs once something injects it, so every app must call `provideTheme()`
|
|
168
|
+
in its application config. Without it the stored theme is only applied when `flr-user-menu` first
|
|
169
|
+
renders, and routes outside the authenticated layout (login, callback, onboarding, public pages)
|
|
170
|
+
load light and flip to dark mid-session.
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import { provideTheme } from '@ferrlabs/ui-ng';
|
|
174
|
+
|
|
175
|
+
export const appConfig: ApplicationConfig = {
|
|
176
|
+
providers: [provideTheme()],
|
|
177
|
+
};
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
To avoid a light frame before Angular bootstraps, paste this into the `<head>` of `index.html`,
|
|
181
|
+
before the stylesheets. It reads `localStorage['flr-theme']` and `prefers-color-scheme` and sets
|
|
182
|
+
`data-theme="dark"` on `<html>`, with the same resolution as `ThemeService`. It is exported as
|
|
183
|
+
`THEME_PREPAINT_SCRIPT` (generated from the same storage key and rule as the service), and a test
|
|
184
|
+
checks it against `ThemeService`. Under a strict CSP, allow it with a hash or nonce.
|
|
185
|
+
|
|
186
|
+
<!-- prettier-ignore -->
|
|
187
|
+
```html
|
|
188
|
+
<script>(function(){var s=null,d=false;try{s=localStorage.getItem("flr-theme")}catch(e){}try{d=matchMedia("(prefers-color-scheme: dark)").matches}catch(e){}var p=["system","light","dark"].indexOf(s)<0?"system":s;if(p==="dark"||(p==="system"&&d))document.documentElement.setAttribute("data-theme","dark")})()</script>
|
|
189
|
+
```
|
|
169
190
|
|
|
170
191
|
To add a row of your own to a `flr-menu`, provide `MENU_FOCUSABLE` (`focus()`, `disabled()`) on it so
|
|
171
192
|
the arrow keys reach it. `flr-menu-item` takes `keepOpen` (the click does not close the menu) and
|
|
172
193
|
`checked` (renders a `menuitemradio`).
|
|
173
194
|
|
|
195
|
+
## Secret field
|
|
196
|
+
|
|
197
|
+
A read-only secret, masked until the user asks for it. The value is not in the DOM while
|
|
198
|
+
masked. Show reveals it and masks it again after `revealSeconds` (30 by default, `0` keeps it
|
|
199
|
+
shown), Copy copies it without revealing it. Both buttons are named after `aria-label`.
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<flr-field label="Webhook secret">
|
|
203
|
+
<flr-secret-field aria-label="Webhook secret" [value]="secret()" [revealSeconds]="30" />
|
|
204
|
+
</flr-field>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
To fetch the secret only when it is asked for, leave `value` at `null`. The first Show or
|
|
208
|
+
Copy emits `valueRequest` and the field waits until `value` is set. Set `error` when the
|
|
209
|
+
fetch fails, and clear it on the next `valueRequest`. `revealedChange` emits `false` when the
|
|
210
|
+
value is masked again, which is the moment to drop it:
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<flr-secret-field
|
|
214
|
+
aria-label="Webhook secret"
|
|
215
|
+
[value]="secret()"
|
|
216
|
+
[error]="loadError()"
|
|
217
|
+
(valueRequest)="loadSecret()"
|
|
218
|
+
(revealedChange)="$event || secret.set(null)"
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
A copy that follows a fetch runs after the click, and some browsers refuse a clipboard write
|
|
223
|
+
that late. The field then says so and asks the user to show the value and copy it by hand.
|
|
224
|
+
|
|
225
|
+
Every string is replaceable through `labels` (`SecretFieldLabels`).
|
|
226
|
+
|
|
227
|
+
## Combobox: unavailable options and paging
|
|
228
|
+
|
|
229
|
+
An option with `disabled: true` stays in the list and reachable with the arrow keys, so its
|
|
230
|
+
`disabledReason` is read out, but a click or Enter does not select it:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
const options: ComboboxOption[] = [
|
|
234
|
+
{ value: 'api', label: 'Backend API', disabled: true, disabledReason: 'Linked to Mobile' },
|
|
235
|
+
{ value: 'web', label: 'Web app' },
|
|
236
|
+
];
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
For a server-searched list (`[localFilter]="false"`), set `hasMore` while pages remain.
|
|
240
|
+
`loadMore` emits once per page when the list is scrolled near its end, when the down arrow
|
|
241
|
+
is pressed on the last option, or on the "Load more" button. Append the new page to `options`
|
|
242
|
+
and set `loadingMore` meanwhile. `error` shows a message with a `retry` action in place of
|
|
243
|
+
the empty text or the "Load more" button:
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<flr-combobox
|
|
247
|
+
[options]="projects()"
|
|
248
|
+
[localFilter]="false"
|
|
249
|
+
[loading]="loading()"
|
|
250
|
+
[hasMore]="hasMore()"
|
|
251
|
+
[loadingMore]="loadingMore()"
|
|
252
|
+
[error]="loadError()"
|
|
253
|
+
(searchChange)="search($event)"
|
|
254
|
+
(loadMore)="nextPage()"
|
|
255
|
+
(retry)="reload()"
|
|
256
|
+
/>
|
|
257
|
+
```
|
|
258
|
+
|
|
174
259
|
## Versioned docs (`@ferrlabs/ui-ng/docs`)
|
|
175
260
|
|
|
176
261
|
Brand-agnostic versioned-documentation layout, shared across product sites.
|