@su-labs/fields 22.0.0 → 22.1.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/CHANGELOG.md +7 -1
- package/README.md +85 -0
- package/fesm2022/su-labs-fields.mjs +631 -2
- package/fesm2022/su-labs-fields.mjs.map +1 -1
- package/package.json +7 -2
- package/types/su-labs-fields.d.ts +222 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [22.1.0] - 2026-11-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `su-lib-email-field`: an email input that checks the address the way people mistype it, says what's wrong once the field is left, shows a tick when it looks right, and suggests a common domain for a likely typo (`gmial.com` → `gmail.com`) applied with one tap; `required`, your own `domains` and `messages`, `validityChange`. The check is exported as `suCheckEmail`
|
|
12
|
+
- `su-lib-checkbox`: a real checkbox whose tick draws itself in, with a squash when pressed and a dash when partly checked; `[(checked)]`, `indeterminate`, `disabled`
|
|
13
|
+
- `su-lib-chips`: toggle chips to pick several options or one (`multiple`), each popping a tick in when picked; typed `[(value)]`, disabled options
|
|
14
|
+
- `su-lib-switch`: a real checkbox (`role="switch"`) drawn as a sliding switch, with a stretching knob, a spring and a tick when on; `[(checked)]`, the label before or after it (`labelPosition`), `small` or `medium`, `disabled`, and `busy` (ignores clicks while saving, then shows the saved value); themed with `--su-switch-*` variables
|
|
9
15
|
|
|
10
16
|
## [22.0.0] - 2026-11-11
|
|
11
17
|
|
package/README.md
CHANGED
|
@@ -65,6 +65,91 @@ The rule is exported too: `suPasswordStrength(password, minLength)` gives 0 to 4
|
|
|
65
65
|
|
|
66
66
|
It also shrinks back when its form is reset.
|
|
67
67
|
|
|
68
|
+
## Switch
|
|
69
|
+
|
|
70
|
+
A real checkbox (`role="switch"`) drawn as a sliding switch: the knob stretches while pressed, springs across, and a
|
|
71
|
+
tick pops in when it's on. The label goes inside.
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<su-lib-switch [(checked)]="notify">Email me about new games</su-lib-switch>
|
|
75
|
+
|
|
76
|
+
<su-lib-switch labelPosition="start" size="small" [checked]="isPublic()" [busy]="saving()" (checkedChange)="save($event)">
|
|
77
|
+
<strong>Show me on the leaderboard</strong>
|
|
78
|
+
<small>Others see your screen name and best scores</small>
|
|
79
|
+
</su-lib-switch>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Input / output | Default | Description |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `checked` / `checkedChange` | `false` | Whether it's on; `[(checked)]` binds both ways |
|
|
85
|
+
| `labelPosition` | `'end'` | `'end'`: label after the switch; `'start'`: label first, switch at the end of the row |
|
|
86
|
+
| `size` | `'medium'` | `'small'` or `'medium'` |
|
|
87
|
+
| `disabled` | `false` | |
|
|
88
|
+
| `busy` | `false` | While saving: clicks are ignored and `aria-busy` is set; once done it shows `checked` again, so a change that failed to save flips back |
|
|
89
|
+
|
|
90
|
+
| Variable | Default |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `--su-switch-on` / `--su-switch-tick` | `#111` / `#fff` (the knob and the tick when on) |
|
|
93
|
+
| `--su-switch-track-on` | the on colour at 35% |
|
|
94
|
+
| `--su-switch-knob-off` / `--su-switch-track-off` / `--su-switch-border` | grey / a faint tint / a soft line |
|
|
95
|
+
| `--su-switch-width` / `--su-switch-height` | `3rem` / `1.75rem` (`--su-switch-small-width`, `--su-switch-small-height`: `2.125rem` / `1.25rem`) |
|
|
96
|
+
| `--su-switch-label-weight` / `--su-switch-focus-outline` | `500` / `2px solid currentColor` |
|
|
97
|
+
|
|
98
|
+
## Email field
|
|
99
|
+
|
|
100
|
+
An email input that checks the address the way people mistype it: no @, nothing before or after it, no dot in the
|
|
101
|
+
domain, spaces, or a one-letter ending. It stays quiet while you type and says what's wrong once you leave the field;
|
|
102
|
+
a tick shows when the address looks right. For a likely typo in a common domain it offers the fix, applied with one tap:
|
|
103
|
+
`jo@gmial.com` → "Did you mean jo@gmail.com?"
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<su-lib-email-field label="Email" required [(value)]="email" (validityChange)="emailOk.set($event)" />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
| Input / output | Default | Description |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `value` | `''` | The address; `[(value)]` binds both ways |
|
|
112
|
+
| `label` | — | The visible label |
|
|
113
|
+
| `placeholder` | — | |
|
|
114
|
+
| `required` | `false` | An empty field counts as a problem |
|
|
115
|
+
| `domains` | common providers | Domains to suggest for a typo, e.g. your company's |
|
|
116
|
+
| `messages` | English | `Partial<SuEmailMessages>`: the problem texts and "Did you mean" |
|
|
117
|
+
| `validityChange` | — | Whether the address is valid, on every change |
|
|
118
|
+
|
|
119
|
+
The check itself is exported: `suCheckEmail(value, domains?)` gives `{ valid, problem, suggestion }`.
|
|
120
|
+
|
|
121
|
+
## Checkbox
|
|
122
|
+
|
|
123
|
+
A real checkbox whose tick draws itself in, with a small squash when pressed and a dash when partly checked.
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<su-lib-checkbox [(checked)]="agree">I agree to the terms</su-lib-checkbox>
|
|
127
|
+
<su-lib-checkbox [checked]="all()" [indeterminate]="some()" (checkedChange)="selectAll($event)">Select all</su-lib-checkbox>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Inputs: `checked` / `checkedChange` (`[(checked)]`), `indeterminate`, `disabled`. Size and tick colour:
|
|
131
|
+
`--su-checkbox-size` (`1.25rem`), `--su-checkbox-tick` (`#fff`); the box uses `--su-field-accent` when checked.
|
|
132
|
+
|
|
133
|
+
## Chips
|
|
134
|
+
|
|
135
|
+
Toggle chips to pick several options, or one with `multiple` off. Each is a button (`aria-pressed`) that pops a tick in
|
|
136
|
+
when picked; the value keeps the options' order and type.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
categories: readonly SuChipOption<Category>[] = [
|
|
140
|
+
{ value: 'tools', label: 'Tools' },
|
|
141
|
+
{ value: 'garden', label: 'Garden' },
|
|
142
|
+
];
|
|
143
|
+
picked = signal<readonly Category[]>([]);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<su-lib-chips label="Categories" [options]="categories" [(value)]="picked" />
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Inputs: `options` (`{ value, label, disabled? }`), `value` (`[(value)]`), `label` (the group's name for screen readers),
|
|
151
|
+
`multiple` (`true`). Spacing: `--su-chips-gap` (`0.5rem`).
|
|
152
|
+
|
|
68
153
|
## Theming
|
|
69
154
|
|
|
70
155
|
Set these CSS variables (each has a fallback):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, afterNextRender, booleanAttribute, computed, effect, inject, input, model, signal } from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, afterNextRender, booleanAttribute, computed, effect, inject, input, linkedSignal, model, output, signal, untracked } from "@angular/core";
|
|
3
3
|
var SuCodeBoxesComponent = class SuCodeBoxesComponent {
|
|
4
4
|
value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
5
5
|
length = input.required(...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
@@ -329,6 +329,635 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
329
329
|
}]
|
|
330
330
|
}] }
|
|
331
331
|
});
|
|
332
|
-
|
|
332
|
+
var SuSwitchComponent = class SuSwitchComponent {
|
|
333
|
+
checked = input(false, {
|
|
334
|
+
...ngDevMode ? { debugName: "checked" } : /* istanbul ignore next */ {},
|
|
335
|
+
transform: booleanAttribute
|
|
336
|
+
});
|
|
337
|
+
disabled = input(false, {
|
|
338
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
339
|
+
transform: booleanAttribute
|
|
340
|
+
});
|
|
341
|
+
busy = input(false, {
|
|
342
|
+
...ngDevMode ? { debugName: "busy" } : /* istanbul ignore next */ {},
|
|
343
|
+
transform: booleanAttribute
|
|
344
|
+
});
|
|
345
|
+
labelPosition = input("end", ...ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []);
|
|
346
|
+
size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
347
|
+
checkedChange = output();
|
|
348
|
+
shown = linkedSignal(() => this.checked(), ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
|
|
349
|
+
constructor() {
|
|
350
|
+
effect(() => {
|
|
351
|
+
if (!this.busy()) untracked(() => this.shown.set(this.checked()));
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
onClick(event) {
|
|
355
|
+
if (this.busy()) event.preventDefault();
|
|
356
|
+
}
|
|
357
|
+
onChange(event) {
|
|
358
|
+
if (event.target instanceof HTMLInputElement) {
|
|
359
|
+
this.shown.set(event.target.checked);
|
|
360
|
+
this.checkedChange.emit(event.target.checked);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
364
|
+
minVersion: "12.0.0",
|
|
365
|
+
version: "22.2.4",
|
|
366
|
+
ngImport: i0,
|
|
367
|
+
type: SuSwitchComponent,
|
|
368
|
+
deps: [],
|
|
369
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
370
|
+
});
|
|
371
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
372
|
+
minVersion: "17.1.0",
|
|
373
|
+
version: "22.2.4",
|
|
374
|
+
type: SuSwitchComponent,
|
|
375
|
+
isStandalone: true,
|
|
376
|
+
selector: "su-lib-switch",
|
|
377
|
+
inputs: {
|
|
378
|
+
checked: {
|
|
379
|
+
classPropertyName: "checked",
|
|
380
|
+
publicName: "checked",
|
|
381
|
+
isSignal: true,
|
|
382
|
+
isRequired: false,
|
|
383
|
+
transformFunction: null
|
|
384
|
+
},
|
|
385
|
+
disabled: {
|
|
386
|
+
classPropertyName: "disabled",
|
|
387
|
+
publicName: "disabled",
|
|
388
|
+
isSignal: true,
|
|
389
|
+
isRequired: false,
|
|
390
|
+
transformFunction: null
|
|
391
|
+
},
|
|
392
|
+
busy: {
|
|
393
|
+
classPropertyName: "busy",
|
|
394
|
+
publicName: "busy",
|
|
395
|
+
isSignal: true,
|
|
396
|
+
isRequired: false,
|
|
397
|
+
transformFunction: null
|
|
398
|
+
},
|
|
399
|
+
labelPosition: {
|
|
400
|
+
classPropertyName: "labelPosition",
|
|
401
|
+
publicName: "labelPosition",
|
|
402
|
+
isSignal: true,
|
|
403
|
+
isRequired: false,
|
|
404
|
+
transformFunction: null
|
|
405
|
+
},
|
|
406
|
+
size: {
|
|
407
|
+
classPropertyName: "size",
|
|
408
|
+
publicName: "size",
|
|
409
|
+
isSignal: true,
|
|
410
|
+
isRequired: false,
|
|
411
|
+
transformFunction: null
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
outputs: { checkedChange: "checkedChange" },
|
|
415
|
+
ngImport: i0,
|
|
416
|
+
template: "<label class=\"su-switch su-switch-{{ size() }}\" [class.is-label-start]=\"labelPosition() === 'start'\">\n <input\n type=\"checkbox\"\n role=\"switch\"\n [checked]=\"shown()\"\n [disabled]=\"disabled()\"\n [attr.aria-busy]=\"busy() ? true : null\"\n (click)=\"onClick($event)\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-switch-track\" aria-hidden=\"true\"></span>\n <span class=\"su-switch-label\"><ng-content /></span>\n</label>\n",
|
|
417
|
+
styles: [":host{display:block}.su-switch{align-items:center;cursor:pointer;display:inline-flex;font-weight:var(--su-switch-label-weight, 500);gap:.75rem}.su-switch input{height:1px;opacity:0;position:absolute;width:1px}.su-switch.is-label-start{display:flex;flex-direction:row-reverse;gap:1rem;justify-content:space-between;width:100%}.su-switch-label{display:grid;gap:.125rem}.is-label-start .su-switch-label{flex:1}.su-switch-label:empty{display:none}.su-switch-track{--switch-width: var(--su-switch-width, 3rem);--switch-height: var(--su-switch-height, 1.75rem);--switch-inset: .1875rem;--switch-knob: calc(var(--switch-height) - 2 * var(--switch-inset));--switch-travel: calc(var(--switch-width) - var(--switch-height));--switch-stretch: calc(var(--switch-knob) * .3);--knob-width: var(--switch-knob);--knob-move: 0rem;--knob-scale: .7;--knob-colour: var(--su-switch-knob-off, #9b9a97);background:var(--su-switch-track-off, rgba(0, 0, 0, .06));border-radius:9999px;box-shadow:inset 0 0 0 2px var(--su-switch-border, rgba(0, 0, 0, .14));flex-shrink:0;height:var(--switch-height);position:relative;transition:background-color .2s ease,box-shadow .2s ease;width:var(--switch-width)}.su-switch-small .su-switch-track{--switch-width: var(--su-switch-small-width, 2.125rem);--switch-height: var(--su-switch-small-height, 1.25rem)}.su-switch-track:after{background:var(--knob-colour);border-radius:9999px;box-shadow:0 1px 3px #00000040;content:\"\";height:var(--switch-knob);left:var(--switch-inset);position:absolute;scale:var(--knob-scale);top:var(--switch-inset);transition:translate .25s cubic-bezier(.34,1.56,.64,1),width .2s ease,scale .25s cubic-bezier(.34,1.56,.64,1),background-color .2s ease;translate:var(--knob-move) 0;width:var(--knob-width)}.su-switch-track:before{background:var(--su-switch-tick, #fff);content:\"\";height:var(--switch-knob);left:calc(var(--switch-inset) + var(--switch-travel));-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/55% no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/55% no-repeat;opacity:0;position:absolute;scale:.3;top:var(--switch-inset);transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1);width:var(--switch-knob);z-index:1}.su-switch:active input:not(:disabled)+.su-switch-track{--knob-scale: 1;--knob-width: calc(var(--switch-knob) + var(--switch-stretch))}.su-switch input:checked+.su-switch-track{--knob-move: var(--switch-travel);--knob-scale: 1;--knob-colour: var(--su-switch-on, #111);background:var(--su-switch-track-on, color-mix(in srgb, var(--su-switch-on, #111) 35%, Canvas));box-shadow:none}.su-switch input:checked+.su-switch-track:before{opacity:1;scale:1}.su-switch:active input:checked:not(:disabled)+.su-switch-track{--knob-move: calc(var(--switch-travel) - var(--switch-stretch))}.su-switch:active input:checked:not(:disabled)+.su-switch-track:before{opacity:0}.su-switch input:focus-visible+.su-switch-track{outline:var(--su-switch-focus-outline, 2px solid currentColor);outline-offset:2px}.su-switch:has(input:disabled){cursor:not-allowed}.su-switch input:disabled+.su-switch-track{opacity:.5}@media(prefers-reduced-motion:reduce){.su-switch-track,.su-switch-track:after,.su-switch-track:before{transition:none}}\n"],
|
|
418
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
422
|
+
minVersion: "12.0.0",
|
|
423
|
+
version: "22.2.4",
|
|
424
|
+
ngImport: i0,
|
|
425
|
+
type: SuSwitchComponent,
|
|
426
|
+
decorators: [{
|
|
427
|
+
type: Component,
|
|
428
|
+
args: [{
|
|
429
|
+
selector: "su-lib-switch",
|
|
430
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
431
|
+
template: "<label class=\"su-switch su-switch-{{ size() }}\" [class.is-label-start]=\"labelPosition() === 'start'\">\n <input\n type=\"checkbox\"\n role=\"switch\"\n [checked]=\"shown()\"\n [disabled]=\"disabled()\"\n [attr.aria-busy]=\"busy() ? true : null\"\n (click)=\"onClick($event)\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-switch-track\" aria-hidden=\"true\"></span>\n <span class=\"su-switch-label\"><ng-content /></span>\n</label>\n",
|
|
432
|
+
styles: [":host{display:block}.su-switch{align-items:center;cursor:pointer;display:inline-flex;font-weight:var(--su-switch-label-weight, 500);gap:.75rem}.su-switch input{height:1px;opacity:0;position:absolute;width:1px}.su-switch.is-label-start{display:flex;flex-direction:row-reverse;gap:1rem;justify-content:space-between;width:100%}.su-switch-label{display:grid;gap:.125rem}.is-label-start .su-switch-label{flex:1}.su-switch-label:empty{display:none}.su-switch-track{--switch-width: var(--su-switch-width, 3rem);--switch-height: var(--su-switch-height, 1.75rem);--switch-inset: .1875rem;--switch-knob: calc(var(--switch-height) - 2 * var(--switch-inset));--switch-travel: calc(var(--switch-width) - var(--switch-height));--switch-stretch: calc(var(--switch-knob) * .3);--knob-width: var(--switch-knob);--knob-move: 0rem;--knob-scale: .7;--knob-colour: var(--su-switch-knob-off, #9b9a97);background:var(--su-switch-track-off, rgba(0, 0, 0, .06));border-radius:9999px;box-shadow:inset 0 0 0 2px var(--su-switch-border, rgba(0, 0, 0, .14));flex-shrink:0;height:var(--switch-height);position:relative;transition:background-color .2s ease,box-shadow .2s ease;width:var(--switch-width)}.su-switch-small .su-switch-track{--switch-width: var(--su-switch-small-width, 2.125rem);--switch-height: var(--su-switch-small-height, 1.25rem)}.su-switch-track:after{background:var(--knob-colour);border-radius:9999px;box-shadow:0 1px 3px #00000040;content:\"\";height:var(--switch-knob);left:var(--switch-inset);position:absolute;scale:var(--knob-scale);top:var(--switch-inset);transition:translate .25s cubic-bezier(.34,1.56,.64,1),width .2s ease,scale .25s cubic-bezier(.34,1.56,.64,1),background-color .2s ease;translate:var(--knob-move) 0;width:var(--knob-width)}.su-switch-track:before{background:var(--su-switch-tick, #fff);content:\"\";height:var(--switch-knob);left:calc(var(--switch-inset) + var(--switch-travel));-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/55% no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/55% no-repeat;opacity:0;position:absolute;scale:.3;top:var(--switch-inset);transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1);width:var(--switch-knob);z-index:1}.su-switch:active input:not(:disabled)+.su-switch-track{--knob-scale: 1;--knob-width: calc(var(--switch-knob) + var(--switch-stretch))}.su-switch input:checked+.su-switch-track{--knob-move: var(--switch-travel);--knob-scale: 1;--knob-colour: var(--su-switch-on, #111);background:var(--su-switch-track-on, color-mix(in srgb, var(--su-switch-on, #111) 35%, Canvas));box-shadow:none}.su-switch input:checked+.su-switch-track:before{opacity:1;scale:1}.su-switch:active input:checked:not(:disabled)+.su-switch-track{--knob-move: calc(var(--switch-travel) - var(--switch-stretch))}.su-switch:active input:checked:not(:disabled)+.su-switch-track:before{opacity:0}.su-switch input:focus-visible+.su-switch-track{outline:var(--su-switch-focus-outline, 2px solid currentColor);outline-offset:2px}.su-switch:has(input:disabled){cursor:not-allowed}.su-switch input:disabled+.su-switch-track{opacity:.5}@media(prefers-reduced-motion:reduce){.su-switch-track,.su-switch-track:after,.su-switch-track:before{transition:none}}\n"]
|
|
433
|
+
}]
|
|
434
|
+
}],
|
|
435
|
+
ctorParameters: () => [],
|
|
436
|
+
propDecorators: {
|
|
437
|
+
checked: [{
|
|
438
|
+
type: i0.Input,
|
|
439
|
+
args: [{
|
|
440
|
+
isSignal: true,
|
|
441
|
+
alias: "checked",
|
|
442
|
+
required: false
|
|
443
|
+
}]
|
|
444
|
+
}],
|
|
445
|
+
disabled: [{
|
|
446
|
+
type: i0.Input,
|
|
447
|
+
args: [{
|
|
448
|
+
isSignal: true,
|
|
449
|
+
alias: "disabled",
|
|
450
|
+
required: false
|
|
451
|
+
}]
|
|
452
|
+
}],
|
|
453
|
+
busy: [{
|
|
454
|
+
type: i0.Input,
|
|
455
|
+
args: [{
|
|
456
|
+
isSignal: true,
|
|
457
|
+
alias: "busy",
|
|
458
|
+
required: false
|
|
459
|
+
}]
|
|
460
|
+
}],
|
|
461
|
+
labelPosition: [{
|
|
462
|
+
type: i0.Input,
|
|
463
|
+
args: [{
|
|
464
|
+
isSignal: true,
|
|
465
|
+
alias: "labelPosition",
|
|
466
|
+
required: false
|
|
467
|
+
}]
|
|
468
|
+
}],
|
|
469
|
+
size: [{
|
|
470
|
+
type: i0.Input,
|
|
471
|
+
args: [{
|
|
472
|
+
isSignal: true,
|
|
473
|
+
alias: "size",
|
|
474
|
+
required: false
|
|
475
|
+
}]
|
|
476
|
+
}],
|
|
477
|
+
checkedChange: [{
|
|
478
|
+
type: i0.Output,
|
|
479
|
+
args: ["checkedChange"]
|
|
480
|
+
}]
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
const SU_COMMON_EMAIL_DOMAINS = [
|
|
484
|
+
"gmail.com",
|
|
485
|
+
"hotmail.com",
|
|
486
|
+
"outlook.com",
|
|
487
|
+
"live.com",
|
|
488
|
+
"yahoo.com",
|
|
489
|
+
"icloud.com",
|
|
490
|
+
"me.com",
|
|
491
|
+
"aol.com",
|
|
492
|
+
"proton.me",
|
|
493
|
+
"protonmail.com",
|
|
494
|
+
"gmx.com",
|
|
495
|
+
"yandex.com",
|
|
496
|
+
"hotmail.es",
|
|
497
|
+
"yahoo.es"
|
|
498
|
+
];
|
|
499
|
+
const MAX_TYPO_DISTANCE = 2;
|
|
500
|
+
function editDistance(a, b) {
|
|
501
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
502
|
+
for (let i = 1; i <= a.length; i++) {
|
|
503
|
+
const current = [i];
|
|
504
|
+
for (let j = 1; j <= b.length; j++) current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
505
|
+
previous = current;
|
|
506
|
+
}
|
|
507
|
+
return previous[b.length];
|
|
508
|
+
}
|
|
509
|
+
function closestDomain(domain, domains) {
|
|
510
|
+
if (!domain || domains.includes(domain)) return null;
|
|
511
|
+
let best = null;
|
|
512
|
+
for (const candidate of domains) {
|
|
513
|
+
const distance = editDistance(domain, candidate);
|
|
514
|
+
if (distance <= MAX_TYPO_DISTANCE && (!best || distance < best.distance)) best = {
|
|
515
|
+
domain: candidate,
|
|
516
|
+
distance
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
return best?.domain ?? null;
|
|
520
|
+
}
|
|
521
|
+
function problemOf(email) {
|
|
522
|
+
if (email === "") return "empty";
|
|
523
|
+
if (/\s/.test(email)) return "spaces";
|
|
524
|
+
const parts = email.split("@");
|
|
525
|
+
if (parts.length !== 2) return "at";
|
|
526
|
+
const [name, domain] = parts;
|
|
527
|
+
if (!name) return "name";
|
|
528
|
+
if (!domain) return "domain";
|
|
529
|
+
const labels = domain.split(".");
|
|
530
|
+
if (labels.length < 2 || labels.some((label) => label === "")) return "dot";
|
|
531
|
+
return /^\p{L}{2,}$/u.test(labels[labels.length - 1]) ? null : "ending";
|
|
532
|
+
}
|
|
533
|
+
function suCheckEmail(value, domains = SU_COMMON_EMAIL_DOMAINS) {
|
|
534
|
+
const email = value.trim();
|
|
535
|
+
const problem = problemOf(email);
|
|
536
|
+
const [name = "", domain = ""] = email.split("@");
|
|
537
|
+
const fix = (problem === null || problem === "dot" || problem === "ending") && name ? closestDomain(domain.toLowerCase(), domains) : null;
|
|
538
|
+
return {
|
|
539
|
+
valid: problem === null,
|
|
540
|
+
problem,
|
|
541
|
+
suggestion: fix ? `${name}@${fix}` : null
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
const SU_EMAIL_MESSAGES = {
|
|
545
|
+
empty: "Enter your email address",
|
|
546
|
+
spaces: "An email address has no spaces",
|
|
547
|
+
at: "An email address has one @, like name@example.com",
|
|
548
|
+
name: "Add the part before the @",
|
|
549
|
+
domain: "Add the part after the @, like example.com",
|
|
550
|
+
dot: "The part after the @ needs a dot, like example.com",
|
|
551
|
+
ending: "The ending after the last dot needs at least two letters",
|
|
552
|
+
suggestion: "Did you mean"
|
|
553
|
+
};
|
|
554
|
+
let nextId = 0;
|
|
555
|
+
var SuEmailFieldComponent = class SuEmailFieldComponent {
|
|
556
|
+
value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
557
|
+
label = input.required(...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
558
|
+
placeholder = input(...ngDevMode ? [void 0, { debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
559
|
+
required = input(false, {
|
|
560
|
+
...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
|
|
561
|
+
transform: booleanAttribute
|
|
562
|
+
});
|
|
563
|
+
messages = input({}, ...ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []);
|
|
564
|
+
domains = input(SU_COMMON_EMAIL_DOMAINS, ...ngDevMode ? [{ debugName: "domains" }] : /* istanbul ignore next */ []);
|
|
565
|
+
validityChange = output();
|
|
566
|
+
id = `su-email-${nextId++}`;
|
|
567
|
+
touched = signal(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
568
|
+
check = computed(() => suCheckEmail(this.value(), this.domains()), ...ngDevMode ? [{ debugName: "check" }] : /* istanbul ignore next */ []);
|
|
569
|
+
text = computed(() => ({
|
|
570
|
+
...SU_EMAIL_MESSAGES,
|
|
571
|
+
...this.messages()
|
|
572
|
+
}), ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
573
|
+
problem = computed(() => {
|
|
574
|
+
const { problem } = this.check();
|
|
575
|
+
if (!this.touched() || !problem || problem === "empty" && !this.required()) return null;
|
|
576
|
+
return problem;
|
|
577
|
+
}, ...ngDevMode ? [{ debugName: "problem" }] : /* istanbul ignore next */ []);
|
|
578
|
+
constructor() {
|
|
579
|
+
effect(() => this.validityChange.emit(this.check().valid));
|
|
580
|
+
}
|
|
581
|
+
onInput(event) {
|
|
582
|
+
if (event.target instanceof HTMLInputElement) this.value.set(event.target.value);
|
|
583
|
+
}
|
|
584
|
+
apply(suggestion) {
|
|
585
|
+
this.value.set(suggestion);
|
|
586
|
+
this.touched.set(true);
|
|
587
|
+
}
|
|
588
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
589
|
+
minVersion: "12.0.0",
|
|
590
|
+
version: "22.2.4",
|
|
591
|
+
ngImport: i0,
|
|
592
|
+
type: SuEmailFieldComponent,
|
|
593
|
+
deps: [],
|
|
594
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
595
|
+
});
|
|
596
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
597
|
+
minVersion: "17.0.0",
|
|
598
|
+
version: "22.2.4",
|
|
599
|
+
type: SuEmailFieldComponent,
|
|
600
|
+
isStandalone: true,
|
|
601
|
+
selector: "su-lib-email-field",
|
|
602
|
+
inputs: {
|
|
603
|
+
value: {
|
|
604
|
+
classPropertyName: "value",
|
|
605
|
+
publicName: "value",
|
|
606
|
+
isSignal: true,
|
|
607
|
+
isRequired: false,
|
|
608
|
+
transformFunction: null
|
|
609
|
+
},
|
|
610
|
+
label: {
|
|
611
|
+
classPropertyName: "label",
|
|
612
|
+
publicName: "label",
|
|
613
|
+
isSignal: true,
|
|
614
|
+
isRequired: true,
|
|
615
|
+
transformFunction: null
|
|
616
|
+
},
|
|
617
|
+
placeholder: {
|
|
618
|
+
classPropertyName: "placeholder",
|
|
619
|
+
publicName: "placeholder",
|
|
620
|
+
isSignal: true,
|
|
621
|
+
isRequired: false,
|
|
622
|
+
transformFunction: null
|
|
623
|
+
},
|
|
624
|
+
required: {
|
|
625
|
+
classPropertyName: "required",
|
|
626
|
+
publicName: "required",
|
|
627
|
+
isSignal: true,
|
|
628
|
+
isRequired: false,
|
|
629
|
+
transformFunction: null
|
|
630
|
+
},
|
|
631
|
+
messages: {
|
|
632
|
+
classPropertyName: "messages",
|
|
633
|
+
publicName: "messages",
|
|
634
|
+
isSignal: true,
|
|
635
|
+
isRequired: false,
|
|
636
|
+
transformFunction: null
|
|
637
|
+
},
|
|
638
|
+
domains: {
|
|
639
|
+
classPropertyName: "domains",
|
|
640
|
+
publicName: "domains",
|
|
641
|
+
isSignal: true,
|
|
642
|
+
isRequired: false,
|
|
643
|
+
transformFunction: null
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
outputs: {
|
|
647
|
+
value: "valueChange",
|
|
648
|
+
validityChange: "validityChange"
|
|
649
|
+
},
|
|
650
|
+
ngImport: i0,
|
|
651
|
+
template: "@let result = check();\n@let t = text();\n<label class=\"su-email-label\" [for]=\"id\">{{ label() }}</label>\n<div class=\"su-email-box\" [class.is-valid]=\"result.valid\" [class.is-invalid]=\"problem() !== null\">\n <input\n class=\"su-email-input\"\n type=\"email\"\n inputmode=\"email\"\n autocomplete=\"email\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [id]=\"id\"\n [value]=\"value()\"\n [required]=\"required()\"\n [attr.placeholder]=\"placeholder() ?? null\"\n [attr.aria-invalid]=\"problem() !== null ? true : null\"\n [attr.aria-describedby]=\"id + '-message'\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n />\n <span class=\"su-email-tick\" aria-hidden=\"true\"></span>\n</div>\n<p class=\"su-email-message\" aria-live=\"polite\" [id]=\"id + '-message'\">\n @if (problem(); as problem) {\n <span class=\"su-email-problem\">{{ t[problem] }}</span>\n }\n @if (result.suggestion; as suggestion) {\n <span class=\"su-email-suggestion\">\n {{ t.suggestion }}\n <button type=\"button\" class=\"su-email-fix\" (click)=\"apply(suggestion)\">{{ suggestion }}</button>?\n </span>\n }\n</p>\n",
|
|
652
|
+
styles: [":host{display:grid;gap:.375rem}.su-email-label{font-size:.875rem}.su-email-box{position:relative}.su-email-input{background:var(--su-field-surface, transparent);border:1px solid var(--su-field-border, rgba(127, 127, 127, .4));border-radius:.5rem;box-sizing:border-box;color:var(--su-field-text, currentColor);font:inherit;min-height:2.75rem;padding:.5rem 2.5rem .5rem .75rem;transition:border-color .2s ease,box-shadow .2s ease;width:100%}.su-email-input:focus-visible{border-color:var(--su-field-accent, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--su-field-accent, #3b82f6) 25%,transparent);outline:none}.is-valid .su-email-input{border-color:var(--su-field-success, #2e8b57)}.is-invalid .su-email-input{animation:su-email-nudge .26s ease;border-color:var(--su-field-danger, #c0392b)}.su-email-tick{background:var(--su-field-success, #2e8b57);height:1.1rem;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;opacity:0;pointer-events:none;position:absolute;right:.75rem;scale:.3;top:50%;transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1);translate:0 -50%;width:1.1rem}.is-valid .su-email-tick{opacity:1;scale:1}.su-email-message{display:grid;font-size:.8125rem;gap:.25rem;margin:0;min-height:1.25rem}.su-email-message:empty{min-height:0}.su-email-problem{color:var(--su-field-danger, #c0392b)}.su-email-suggestion{color:var(--su-field-text, currentColor)}.su-email-fix{background:none;border:0;border-radius:4px;color:var(--su-field-accent, #3b82f6);cursor:pointer;font:inherit;font-weight:600;padding:0;text-decoration:underline;text-underline-offset:2px}.su-email-fix:focus-visible{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}@keyframes su-email-nudge{25%{translate:-3px 0}75%{translate:3px 0}}@media(prefers-reduced-motion:reduce){.is-invalid .su-email-input{animation:none}.su-email-tick{transition:none}}\n"],
|
|
653
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
657
|
+
minVersion: "12.0.0",
|
|
658
|
+
version: "22.2.4",
|
|
659
|
+
ngImport: i0,
|
|
660
|
+
type: SuEmailFieldComponent,
|
|
661
|
+
decorators: [{
|
|
662
|
+
type: Component,
|
|
663
|
+
args: [{
|
|
664
|
+
selector: "su-lib-email-field",
|
|
665
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
666
|
+
template: "@let result = check();\n@let t = text();\n<label class=\"su-email-label\" [for]=\"id\">{{ label() }}</label>\n<div class=\"su-email-box\" [class.is-valid]=\"result.valid\" [class.is-invalid]=\"problem() !== null\">\n <input\n class=\"su-email-input\"\n type=\"email\"\n inputmode=\"email\"\n autocomplete=\"email\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [id]=\"id\"\n [value]=\"value()\"\n [required]=\"required()\"\n [attr.placeholder]=\"placeholder() ?? null\"\n [attr.aria-invalid]=\"problem() !== null ? true : null\"\n [attr.aria-describedby]=\"id + '-message'\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n />\n <span class=\"su-email-tick\" aria-hidden=\"true\"></span>\n</div>\n<p class=\"su-email-message\" aria-live=\"polite\" [id]=\"id + '-message'\">\n @if (problem(); as problem) {\n <span class=\"su-email-problem\">{{ t[problem] }}</span>\n }\n @if (result.suggestion; as suggestion) {\n <span class=\"su-email-suggestion\">\n {{ t.suggestion }}\n <button type=\"button\" class=\"su-email-fix\" (click)=\"apply(suggestion)\">{{ suggestion }}</button>?\n </span>\n }\n</p>\n",
|
|
667
|
+
styles: [":host{display:grid;gap:.375rem}.su-email-label{font-size:.875rem}.su-email-box{position:relative}.su-email-input{background:var(--su-field-surface, transparent);border:1px solid var(--su-field-border, rgba(127, 127, 127, .4));border-radius:.5rem;box-sizing:border-box;color:var(--su-field-text, currentColor);font:inherit;min-height:2.75rem;padding:.5rem 2.5rem .5rem .75rem;transition:border-color .2s ease,box-shadow .2s ease;width:100%}.su-email-input:focus-visible{border-color:var(--su-field-accent, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--su-field-accent, #3b82f6) 25%,transparent);outline:none}.is-valid .su-email-input{border-color:var(--su-field-success, #2e8b57)}.is-invalid .su-email-input{animation:su-email-nudge .26s ease;border-color:var(--su-field-danger, #c0392b)}.su-email-tick{background:var(--su-field-success, #2e8b57);height:1.1rem;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;opacity:0;pointer-events:none;position:absolute;right:.75rem;scale:.3;top:50%;transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1);translate:0 -50%;width:1.1rem}.is-valid .su-email-tick{opacity:1;scale:1}.su-email-message{display:grid;font-size:.8125rem;gap:.25rem;margin:0;min-height:1.25rem}.su-email-message:empty{min-height:0}.su-email-problem{color:var(--su-field-danger, #c0392b)}.su-email-suggestion{color:var(--su-field-text, currentColor)}.su-email-fix{background:none;border:0;border-radius:4px;color:var(--su-field-accent, #3b82f6);cursor:pointer;font:inherit;font-weight:600;padding:0;text-decoration:underline;text-underline-offset:2px}.su-email-fix:focus-visible{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}@keyframes su-email-nudge{25%{translate:-3px 0}75%{translate:3px 0}}@media(prefers-reduced-motion:reduce){.is-invalid .su-email-input{animation:none}.su-email-tick{transition:none}}\n"]
|
|
668
|
+
}]
|
|
669
|
+
}],
|
|
670
|
+
ctorParameters: () => [],
|
|
671
|
+
propDecorators: {
|
|
672
|
+
value: [{
|
|
673
|
+
type: i0.Input,
|
|
674
|
+
args: [{
|
|
675
|
+
isSignal: true,
|
|
676
|
+
alias: "value",
|
|
677
|
+
required: false
|
|
678
|
+
}]
|
|
679
|
+
}, {
|
|
680
|
+
type: i0.Output,
|
|
681
|
+
args: ["valueChange"]
|
|
682
|
+
}],
|
|
683
|
+
label: [{
|
|
684
|
+
type: i0.Input,
|
|
685
|
+
args: [{
|
|
686
|
+
isSignal: true,
|
|
687
|
+
alias: "label",
|
|
688
|
+
required: true
|
|
689
|
+
}]
|
|
690
|
+
}],
|
|
691
|
+
placeholder: [{
|
|
692
|
+
type: i0.Input,
|
|
693
|
+
args: [{
|
|
694
|
+
isSignal: true,
|
|
695
|
+
alias: "placeholder",
|
|
696
|
+
required: false
|
|
697
|
+
}]
|
|
698
|
+
}],
|
|
699
|
+
required: [{
|
|
700
|
+
type: i0.Input,
|
|
701
|
+
args: [{
|
|
702
|
+
isSignal: true,
|
|
703
|
+
alias: "required",
|
|
704
|
+
required: false
|
|
705
|
+
}]
|
|
706
|
+
}],
|
|
707
|
+
messages: [{
|
|
708
|
+
type: i0.Input,
|
|
709
|
+
args: [{
|
|
710
|
+
isSignal: true,
|
|
711
|
+
alias: "messages",
|
|
712
|
+
required: false
|
|
713
|
+
}]
|
|
714
|
+
}],
|
|
715
|
+
domains: [{
|
|
716
|
+
type: i0.Input,
|
|
717
|
+
args: [{
|
|
718
|
+
isSignal: true,
|
|
719
|
+
alias: "domains",
|
|
720
|
+
required: false
|
|
721
|
+
}]
|
|
722
|
+
}],
|
|
723
|
+
validityChange: [{
|
|
724
|
+
type: i0.Output,
|
|
725
|
+
args: ["validityChange"]
|
|
726
|
+
}]
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
var SuCheckboxComponent = class SuCheckboxComponent {
|
|
730
|
+
checked = input(false, {
|
|
731
|
+
...ngDevMode ? { debugName: "checked" } : /* istanbul ignore next */ {},
|
|
732
|
+
transform: booleanAttribute
|
|
733
|
+
});
|
|
734
|
+
indeterminate = input(false, {
|
|
735
|
+
...ngDevMode ? { debugName: "indeterminate" } : /* istanbul ignore next */ {},
|
|
736
|
+
transform: booleanAttribute
|
|
737
|
+
});
|
|
738
|
+
disabled = input(false, {
|
|
739
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
740
|
+
transform: booleanAttribute
|
|
741
|
+
});
|
|
742
|
+
checkedChange = output();
|
|
743
|
+
shown = linkedSignal(() => this.checked(), ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
|
|
744
|
+
onChange(event) {
|
|
745
|
+
if (event.target instanceof HTMLInputElement) {
|
|
746
|
+
this.shown.set(event.target.checked);
|
|
747
|
+
this.checkedChange.emit(event.target.checked);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
751
|
+
minVersion: "12.0.0",
|
|
752
|
+
version: "22.2.4",
|
|
753
|
+
ngImport: i0,
|
|
754
|
+
type: SuCheckboxComponent,
|
|
755
|
+
deps: [],
|
|
756
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
757
|
+
});
|
|
758
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
759
|
+
minVersion: "17.1.0",
|
|
760
|
+
version: "22.2.4",
|
|
761
|
+
type: SuCheckboxComponent,
|
|
762
|
+
isStandalone: true,
|
|
763
|
+
selector: "su-lib-checkbox",
|
|
764
|
+
inputs: {
|
|
765
|
+
checked: {
|
|
766
|
+
classPropertyName: "checked",
|
|
767
|
+
publicName: "checked",
|
|
768
|
+
isSignal: true,
|
|
769
|
+
isRequired: false,
|
|
770
|
+
transformFunction: null
|
|
771
|
+
},
|
|
772
|
+
indeterminate: {
|
|
773
|
+
classPropertyName: "indeterminate",
|
|
774
|
+
publicName: "indeterminate",
|
|
775
|
+
isSignal: true,
|
|
776
|
+
isRequired: false,
|
|
777
|
+
transformFunction: null
|
|
778
|
+
},
|
|
779
|
+
disabled: {
|
|
780
|
+
classPropertyName: "disabled",
|
|
781
|
+
publicName: "disabled",
|
|
782
|
+
isSignal: true,
|
|
783
|
+
isRequired: false,
|
|
784
|
+
transformFunction: null
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
outputs: { checkedChange: "checkedChange" },
|
|
788
|
+
ngImport: i0,
|
|
789
|
+
template: "<label class=\"su-checkbox\" [class.is-mixed]=\"indeterminate() && !shown()\">\n <input\n type=\"checkbox\"\n [checked]=\"shown()\"\n [indeterminate]=\"indeterminate() && !shown()\"\n [disabled]=\"disabled()\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-checkbox-box\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 24 24\">\n <path class=\"su-checkbox-tick\" d=\"M5 12.5l4.5 4.5L19 7.5\" />\n <path class=\"su-checkbox-dash\" d=\"M6 12h12\" />\n </svg>\n </span>\n <span class=\"su-checkbox-label\"><ng-content /></span>\n</label>\n",
|
|
790
|
+
styles: [":host{display:block}.su-checkbox{align-items:center;cursor:pointer;display:inline-flex;gap:.625rem}.su-checkbox input{height:1px;opacity:0;position:absolute;width:1px}.su-checkbox-box{align-items:center;background:var(--su-field-surface, transparent);border:2px solid var(--su-field-border, rgba(127, 127, 127, .5));border-radius:.375rem;box-sizing:border-box;display:inline-flex;flex-shrink:0;height:var(--su-checkbox-size, 1.25rem);justify-content:center;transition:background-color .18s ease,border-color .18s ease,scale .25s cubic-bezier(.34,1.56,.64,1);width:var(--su-checkbox-size, 1.25rem)}.su-checkbox-box svg{fill:none;height:80%;stroke:var(--su-checkbox-tick, #fff);stroke-linecap:round;stroke-linejoin:round;stroke-width:3.5;width:80%}.su-checkbox-tick,.su-checkbox-dash{stroke-dasharray:24;stroke-dashoffset:24;transition:stroke-dashoffset .22s ease-out 60ms}.su-checkbox:active input:not(:disabled)+.su-checkbox-box{scale:.86}.su-checkbox input:checked+.su-checkbox-box,.is-mixed .su-checkbox-box{background:var(--su-field-accent, #3b82f6);border-color:var(--su-field-accent, #3b82f6)}.su-checkbox input:checked+.su-checkbox-box .su-checkbox-tick,.is-mixed .su-checkbox-dash{stroke-dashoffset:0}.su-checkbox input:focus-visible+.su-checkbox-box{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}.su-checkbox:has(input:disabled){cursor:not-allowed;opacity:.5}.su-checkbox-label:empty{display:none}@media(prefers-reduced-motion:reduce){.su-checkbox-box,.su-checkbox-tick,.su-checkbox-dash{transition:none}}\n"],
|
|
791
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
795
|
+
minVersion: "12.0.0",
|
|
796
|
+
version: "22.2.4",
|
|
797
|
+
ngImport: i0,
|
|
798
|
+
type: SuCheckboxComponent,
|
|
799
|
+
decorators: [{
|
|
800
|
+
type: Component,
|
|
801
|
+
args: [{
|
|
802
|
+
selector: "su-lib-checkbox",
|
|
803
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
804
|
+
template: "<label class=\"su-checkbox\" [class.is-mixed]=\"indeterminate() && !shown()\">\n <input\n type=\"checkbox\"\n [checked]=\"shown()\"\n [indeterminate]=\"indeterminate() && !shown()\"\n [disabled]=\"disabled()\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-checkbox-box\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 24 24\">\n <path class=\"su-checkbox-tick\" d=\"M5 12.5l4.5 4.5L19 7.5\" />\n <path class=\"su-checkbox-dash\" d=\"M6 12h12\" />\n </svg>\n </span>\n <span class=\"su-checkbox-label\"><ng-content /></span>\n</label>\n",
|
|
805
|
+
styles: [":host{display:block}.su-checkbox{align-items:center;cursor:pointer;display:inline-flex;gap:.625rem}.su-checkbox input{height:1px;opacity:0;position:absolute;width:1px}.su-checkbox-box{align-items:center;background:var(--su-field-surface, transparent);border:2px solid var(--su-field-border, rgba(127, 127, 127, .5));border-radius:.375rem;box-sizing:border-box;display:inline-flex;flex-shrink:0;height:var(--su-checkbox-size, 1.25rem);justify-content:center;transition:background-color .18s ease,border-color .18s ease,scale .25s cubic-bezier(.34,1.56,.64,1);width:var(--su-checkbox-size, 1.25rem)}.su-checkbox-box svg{fill:none;height:80%;stroke:var(--su-checkbox-tick, #fff);stroke-linecap:round;stroke-linejoin:round;stroke-width:3.5;width:80%}.su-checkbox-tick,.su-checkbox-dash{stroke-dasharray:24;stroke-dashoffset:24;transition:stroke-dashoffset .22s ease-out 60ms}.su-checkbox:active input:not(:disabled)+.su-checkbox-box{scale:.86}.su-checkbox input:checked+.su-checkbox-box,.is-mixed .su-checkbox-box{background:var(--su-field-accent, #3b82f6);border-color:var(--su-field-accent, #3b82f6)}.su-checkbox input:checked+.su-checkbox-box .su-checkbox-tick,.is-mixed .su-checkbox-dash{stroke-dashoffset:0}.su-checkbox input:focus-visible+.su-checkbox-box{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}.su-checkbox:has(input:disabled){cursor:not-allowed;opacity:.5}.su-checkbox-label:empty{display:none}@media(prefers-reduced-motion:reduce){.su-checkbox-box,.su-checkbox-tick,.su-checkbox-dash{transition:none}}\n"]
|
|
806
|
+
}]
|
|
807
|
+
}],
|
|
808
|
+
propDecorators: {
|
|
809
|
+
checked: [{
|
|
810
|
+
type: i0.Input,
|
|
811
|
+
args: [{
|
|
812
|
+
isSignal: true,
|
|
813
|
+
alias: "checked",
|
|
814
|
+
required: false
|
|
815
|
+
}]
|
|
816
|
+
}],
|
|
817
|
+
indeterminate: [{
|
|
818
|
+
type: i0.Input,
|
|
819
|
+
args: [{
|
|
820
|
+
isSignal: true,
|
|
821
|
+
alias: "indeterminate",
|
|
822
|
+
required: false
|
|
823
|
+
}]
|
|
824
|
+
}],
|
|
825
|
+
disabled: [{
|
|
826
|
+
type: i0.Input,
|
|
827
|
+
args: [{
|
|
828
|
+
isSignal: true,
|
|
829
|
+
alias: "disabled",
|
|
830
|
+
required: false
|
|
831
|
+
}]
|
|
832
|
+
}],
|
|
833
|
+
checkedChange: [{
|
|
834
|
+
type: i0.Output,
|
|
835
|
+
args: ["checkedChange"]
|
|
836
|
+
}]
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
var SuChipsComponent = class SuChipsComponent {
|
|
840
|
+
options = input.required(...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
841
|
+
value = model([], ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
842
|
+
label = input.required(...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
843
|
+
multiple = input(true, {
|
|
844
|
+
...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
|
|
845
|
+
transform: booleanAttribute
|
|
846
|
+
});
|
|
847
|
+
isPicked(value) {
|
|
848
|
+
return this.value().includes(value);
|
|
849
|
+
}
|
|
850
|
+
toggle(option) {
|
|
851
|
+
if (!this.multiple()) {
|
|
852
|
+
this.value.set([option.value]);
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const picked = this.isPicked(option.value) ? this.value().filter((value) => value !== option.value) : [...this.value(), option.value];
|
|
856
|
+
this.value.set(this.options().map((item) => item.value).filter((value) => picked.includes(value)));
|
|
857
|
+
}
|
|
858
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
859
|
+
minVersion: "12.0.0",
|
|
860
|
+
version: "22.2.4",
|
|
861
|
+
ngImport: i0,
|
|
862
|
+
type: SuChipsComponent,
|
|
863
|
+
deps: [],
|
|
864
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
865
|
+
});
|
|
866
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
867
|
+
minVersion: "17.0.0",
|
|
868
|
+
version: "22.2.4",
|
|
869
|
+
type: SuChipsComponent,
|
|
870
|
+
isStandalone: true,
|
|
871
|
+
selector: "su-lib-chips",
|
|
872
|
+
inputs: {
|
|
873
|
+
options: {
|
|
874
|
+
classPropertyName: "options",
|
|
875
|
+
publicName: "options",
|
|
876
|
+
isSignal: true,
|
|
877
|
+
isRequired: true,
|
|
878
|
+
transformFunction: null
|
|
879
|
+
},
|
|
880
|
+
value: {
|
|
881
|
+
classPropertyName: "value",
|
|
882
|
+
publicName: "value",
|
|
883
|
+
isSignal: true,
|
|
884
|
+
isRequired: false,
|
|
885
|
+
transformFunction: null
|
|
886
|
+
},
|
|
887
|
+
label: {
|
|
888
|
+
classPropertyName: "label",
|
|
889
|
+
publicName: "label",
|
|
890
|
+
isSignal: true,
|
|
891
|
+
isRequired: true,
|
|
892
|
+
transformFunction: null
|
|
893
|
+
},
|
|
894
|
+
multiple: {
|
|
895
|
+
classPropertyName: "multiple",
|
|
896
|
+
publicName: "multiple",
|
|
897
|
+
isSignal: true,
|
|
898
|
+
isRequired: false,
|
|
899
|
+
transformFunction: null
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
outputs: { value: "valueChange" },
|
|
903
|
+
ngImport: i0,
|
|
904
|
+
template: "<div class=\"su-chips\" role=\"group\" [attr.aria-label]=\"label()\">\n @for (option of options(); track option.value) {\n <button\n type=\"button\"\n class=\"su-chip\"\n [attr.aria-pressed]=\"isPicked(option.value)\"\n [disabled]=\"option.disabled ?? false\"\n (click)=\"toggle(option)\"\n >\n <span class=\"su-chip-tick\" aria-hidden=\"true\"></span>\n {{ option.label }}\n </button>\n }\n</div>\n",
|
|
905
|
+
styles: [":host{display:block}.su-chips{display:flex;flex-wrap:wrap;gap:var(--su-chips-gap, .5rem)}.su-chip{align-items:center;background:var(--su-field-surface, transparent);border:1px solid var(--su-field-border, rgba(127, 127, 127, .4));border-radius:9999px;color:var(--su-field-text, currentColor);cursor:pointer;display:inline-flex;font:inherit;font-size:.875rem;gap:0;padding:.35rem .85rem;transition:background-color .18s ease,border-color .18s ease,color .18s ease,gap .22s cubic-bezier(.34,1.56,.64,1),scale .22s cubic-bezier(.34,1.56,.64,1)}.su-chip:active:not(:disabled){scale:.94}.su-chip[aria-pressed=true]{background:color-mix(in srgb,var(--su-field-accent, #3b82f6) 14%,transparent);border-color:var(--su-field-accent, #3b82f6);gap:.35rem}.su-chip:focus-visible{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}.su-chip:disabled{cursor:not-allowed;opacity:.5}.su-chip-tick{background:var(--su-field-accent, #3b82f6);height:.9rem;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;opacity:0;scale:.3;transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1),width .22s cubic-bezier(.34,1.56,.64,1);width:0}[aria-pressed=true] .su-chip-tick{opacity:1;scale:1;width:.9rem}@media(prefers-reduced-motion:reduce){.su-chip,.su-chip-tick{transition:none}}\n"],
|
|
906
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
907
|
+
});
|
|
908
|
+
};
|
|
909
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
910
|
+
minVersion: "12.0.0",
|
|
911
|
+
version: "22.2.4",
|
|
912
|
+
ngImport: i0,
|
|
913
|
+
type: SuChipsComponent,
|
|
914
|
+
decorators: [{
|
|
915
|
+
type: Component,
|
|
916
|
+
args: [{
|
|
917
|
+
selector: "su-lib-chips",
|
|
918
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
919
|
+
template: "<div class=\"su-chips\" role=\"group\" [attr.aria-label]=\"label()\">\n @for (option of options(); track option.value) {\n <button\n type=\"button\"\n class=\"su-chip\"\n [attr.aria-pressed]=\"isPicked(option.value)\"\n [disabled]=\"option.disabled ?? false\"\n (click)=\"toggle(option)\"\n >\n <span class=\"su-chip-tick\" aria-hidden=\"true\"></span>\n {{ option.label }}\n </button>\n }\n</div>\n",
|
|
920
|
+
styles: [":host{display:block}.su-chips{display:flex;flex-wrap:wrap;gap:var(--su-chips-gap, .5rem)}.su-chip{align-items:center;background:var(--su-field-surface, transparent);border:1px solid var(--su-field-border, rgba(127, 127, 127, .4));border-radius:9999px;color:var(--su-field-text, currentColor);cursor:pointer;display:inline-flex;font:inherit;font-size:.875rem;gap:0;padding:.35rem .85rem;transition:background-color .18s ease,border-color .18s ease,color .18s ease,gap .22s cubic-bezier(.34,1.56,.64,1),scale .22s cubic-bezier(.34,1.56,.64,1)}.su-chip:active:not(:disabled){scale:.94}.su-chip[aria-pressed=true]{background:color-mix(in srgb,var(--su-field-accent, #3b82f6) 14%,transparent);border-color:var(--su-field-accent, #3b82f6);gap:.35rem}.su-chip:focus-visible{outline:2px solid var(--su-field-accent, #3b82f6);outline-offset:2px}.su-chip:disabled{cursor:not-allowed;opacity:.5}.su-chip-tick{background:var(--su-field-accent, #3b82f6);height:.9rem;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E\") center/contain no-repeat;opacity:0;scale:.3;transition:opacity .15s ease,scale .25s cubic-bezier(.34,1.56,.64,1),width .22s cubic-bezier(.34,1.56,.64,1);width:0}[aria-pressed=true] .su-chip-tick{opacity:1;scale:1;width:.9rem}@media(prefers-reduced-motion:reduce){.su-chip,.su-chip-tick{transition:none}}\n"]
|
|
921
|
+
}]
|
|
922
|
+
}],
|
|
923
|
+
propDecorators: {
|
|
924
|
+
options: [{
|
|
925
|
+
type: i0.Input,
|
|
926
|
+
args: [{
|
|
927
|
+
isSignal: true,
|
|
928
|
+
alias: "options",
|
|
929
|
+
required: true
|
|
930
|
+
}]
|
|
931
|
+
}],
|
|
932
|
+
value: [{
|
|
933
|
+
type: i0.Input,
|
|
934
|
+
args: [{
|
|
935
|
+
isSignal: true,
|
|
936
|
+
alias: "value",
|
|
937
|
+
required: false
|
|
938
|
+
}]
|
|
939
|
+
}, {
|
|
940
|
+
type: i0.Output,
|
|
941
|
+
args: ["valueChange"]
|
|
942
|
+
}],
|
|
943
|
+
label: [{
|
|
944
|
+
type: i0.Input,
|
|
945
|
+
args: [{
|
|
946
|
+
isSignal: true,
|
|
947
|
+
alias: "label",
|
|
948
|
+
required: true
|
|
949
|
+
}]
|
|
950
|
+
}],
|
|
951
|
+
multiple: [{
|
|
952
|
+
type: i0.Input,
|
|
953
|
+
args: [{
|
|
954
|
+
isSignal: true,
|
|
955
|
+
alias: "multiple",
|
|
956
|
+
required: false
|
|
957
|
+
}]
|
|
958
|
+
}]
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
export { SU_COMMON_EMAIL_DOMAINS, SU_DEFAULT_MIN_PASSWORD_LENGTH, SU_EMAIL_MESSAGES, SU_STRENGTH_LEVELS, SuAutoGrowDirective, SuCheckboxComponent, SuChipsComponent, SuCodeBoxesComponent, SuEmailFieldComponent, SuStrengthMeterComponent, SuSwitchComponent, suCheckEmail, suPasswordStrength, suStrengthLevel };
|
|
333
962
|
|
|
334
963
|
//# sourceMappingURL=su-labs-fields.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"su-labs-fields.mjs","names":[],"sources":["../../../../projects/su-labs/fields/src/lib/code-boxes/code-boxes.component.ts","../../../../projects/su-labs/fields/src/lib/code-boxes/code-boxes.component.html","../../../../projects/su-labs/fields/src/lib/strength-meter/password-strength.ts","../../../../projects/su-labs/fields/src/lib/strength-meter/strength-meter.component.ts","../../../../projects/su-labs/fields/src/lib/strength-meter/strength-meter.component.html","../../../../projects/su-labs/fields/src/lib/auto-grow/auto-grow.directive.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input, model } from '@angular/core';\n\n/**\n * A short code typed into a row of boxes that fill one by one, then turn green in a wave once the code is complete.\n * One real text field lies over the boxes, so typing, pasting, the phone keyboard and screen readers all work as usual.\n */\n@Component({\n selector: 'su-lib-code-boxes',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './code-boxes.component.html',\n styleUrl: './code-boxes.component.scss',\n})\nexport class SuCodeBoxesComponent {\n readonly value = model('');\n readonly length = input.required<number>();\n readonly label = input.required<string>();\n /** The code is whole and well-formed: the boxes turn green */\n readonly complete = input(false);\n\n protected readonly boxes = computed(() =>\n Array.from({ length: this.length() }, (_, index) => index)\n );\n\n /** Capitals without spaces, never longer than the boxes */\n protected onInput(field: HTMLInputElement): void {\n const code = field.value\n .replace(/\\s/g, '')\n .toUpperCase()\n .slice(0, this.length());\n field.value = code;\n this.value.set(code);\n }\n}\n","<input\n #field\n class=\"field\"\n type=\"text\"\n inputmode=\"text\"\n autocomplete=\"off\"\n autocapitalize=\"characters\"\n spellcheck=\"false\"\n required\n [attr.maxlength]=\"length()\"\n [attr.aria-label]=\"label()\"\n [value]=\"value()\"\n (input)=\"onInput(field)\"\n/>\n<span class=\"boxes\" [class.is-complete]=\"complete()\" aria-hidden=\"true\">\n @for (index of boxes(); track index) {\n <span\n class=\"box\"\n [class.is-filled]=\"index < value().length\"\n [class.is-current]=\"index === value().length\"\n [style.--index]=\"index\"\n >{{ value()[index] }}</span\n >\n }\n</span>\n","/** How strong a new password looks, one step per bar of the meter */\nexport const SU_STRENGTH_LEVELS = ['weak', 'fair', 'good', 'strong'] as const;\nexport type SuStrengthLevel = (typeof SU_STRENGTH_LEVELS)[number];\n\n/** Shortest password the meter counts as more than weak, unless told otherwise */\nexport const SU_DEFAULT_MIN_PASSWORD_LENGTH = 8;\n\n/**\n * Bars of the strength meter a password fills, from 0 (empty) to 4. Under the minimum length it stays at one bar,\n * whatever else it has. Then one bar each for: four characters past the minimum, letters with digits, and symbols or\n * mixed case.\n */\nexport function suPasswordStrength(\n password: string,\n minLength = SU_DEFAULT_MIN_PASSWORD_LENGTH\n): number {\n if (password.length === 0) {\n return 0;\n }\n if (password.length < minLength) {\n return 1;\n }\n const extras = [\n password.length >= minLength + 4,\n /\\p{L}/u.test(password) && /\\d/.test(password),\n /[^\\p{L}\\d]/u.test(password) ||\n (/\\p{Lu}/u.test(password) && /\\p{Ll}/u.test(password)),\n ].filter(Boolean).length;\n return 1 + extras;\n}\n\n/** The meter's word for a number of bars, or null for an empty password */\nexport const suStrengthLevel = (bars: number): SuStrengthLevel | null =>\n SU_STRENGTH_LEVELS[bars - 1] ?? null;\n","import { ChangeDetectionStrategy, Component, computed, effect, input, signal } from '@angular/core';\nimport { SU_DEFAULT_MIN_PASSWORD_LENGTH, SU_STRENGTH_LEVELS, suPasswordStrength, SuStrengthLevel, suStrengthLevel } from './password-strength';\n\n/**\n * Four bars under a new password that fill, and change colour, as the password gets stronger. It follows the field's\n * own typing, so forms keep their plain fields; a form that empties the field by code sends it an `input` event.\n * Its texts come in as inputs, so it fits any language.\n */\n@Component({\n selector: 'su-lib-strength-meter',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './strength-meter.component.html',\n styleUrl: './strength-meter.component.scss',\n})\nexport class SuStrengthMeterComponent {\n readonly field = input.required<HTMLInputElement>();\n /** The meter's name for screen readers, e.g. \"Password strength\" */\n readonly label = input.required<string>();\n /** The word shown for each step */\n readonly levelNames =\n input.required<Readonly<Record<SuStrengthLevel, string>>>();\n readonly minLength = input(SU_DEFAULT_MIN_PASSWORD_LENGTH);\n\n private readonly password = signal('');\n protected readonly steps = SU_STRENGTH_LEVELS;\n protected readonly bars = computed(() =>\n suPasswordStrength(this.password(), this.minLength())\n );\n protected readonly level = computed(() => suStrengthLevel(this.bars()));\n protected readonly levelName = computed(() => {\n const level = this.level();\n return level ? this.levelNames()[level] : null;\n });\n\n constructor() {\n effect(onCleanup => {\n const field = this.field();\n const read = () => this.password.set(field.value);\n read();\n field.addEventListener('input', read);\n onCleanup(() => field.removeEventListener('input', read));\n });\n }\n}\n","<div\n class=\"bars\"\n role=\"meter\"\n [attr.aria-label]=\"label()\"\n aria-valuemin=\"0\"\n [attr.aria-valuemax]=\"steps.length\"\n [attr.aria-valuenow]=\"bars()\"\n [attr.aria-valuetext]=\"levelName()\"\n>\n @for (step of steps; track step; let index = $index) {\n <span class=\"bar\" [class.is-filled]=\"index < bars()\" [style.--index]=\"index\"></span>\n }\n</div>\n@if (levelName(); as name) {\n <small class=\"level\" [attr.data-level]=\"level()\" aria-hidden=\"true\">{{ name }}</small>\n}\n","import { afterNextRender, booleanAttribute, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\n\n/** A soft spring that overshoots a little, as the box settles on its new height */\nconst SPRING = 'height 240ms cubic-bezier(0.34, 1.56, 0.64, 1)';\n\n/**\n * A text box that grows a line at a time as the text gets longer, and shrinks back when it is emptied, with a soft\n * spring (none for visitors who asked their device for less motion). `[suAutoGrow]=\"false\"` leaves it as it is.\n */\n@Directive({\n selector: 'textarea[suAutoGrow]',\n host: { '(input)': 'fit()' },\n})\nexport class SuAutoGrowDirective {\n readonly isOn = input(true, { alias: 'suAutoGrow', transform: booleanAttribute });\n\n private readonly box: HTMLTextAreaElement = inject(ElementRef).nativeElement;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n afterNextRender(() => {\n // Emptied by a form reset, which sends no input event; the value only changes after the event\n const onReset = () => setTimeout(() => this.fit());\n this.box.form?.addEventListener('reset', onReset);\n destroyRef.onDestroy(() =>\n this.box.form?.removeEventListener('reset', onReset)\n );\n });\n }\n\n protected fit(): void {\n if (!this.isOn()) {\n return;\n }\n const box = this.box;\n const from = box.offsetHeight;\n // Measured at its natural height, without the animation, then set back so the change can animate\n box.style.transition = 'none';\n box.style.height = 'auto';\n const to = box.scrollHeight + box.offsetHeight - box.clientHeight;\n box.style.height = `${from}px`;\n void box.offsetHeight;\n box.style.overflowY = 'hidden';\n box.style.transition = matchMedia('(prefers-reduced-motion: reduce)')\n .matches\n ? 'none'\n : SPRING;\n box.style.height = `${to}px`;\n }\n}\n"],"mappings":";;AAYA,IAAa,uBAAb,MAAa,qBAAoB;CACtB,QAAQ,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACjB,SAAS,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACjC,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAEhC,WAAW,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAEb,QAAQ,eACzB,MAAM,KAAK,EAAE,QAAQ,KAAK,OAAM,EAAE,IAAK,GAAG,UAAU,KAAK,GAC1D,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CA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EAJ/B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,WAAW,QAAO;EAC3B,CAAA"}
|
|
1
|
+
{"version":3,"file":"su-labs-fields.mjs","names":[],"sources":["../../../../projects/su-labs/fields/src/lib/code-boxes/code-boxes.component.ts","../../../../projects/su-labs/fields/src/lib/code-boxes/code-boxes.component.html","../../../../projects/su-labs/fields/src/lib/strength-meter/password-strength.ts","../../../../projects/su-labs/fields/src/lib/strength-meter/strength-meter.component.ts","../../../../projects/su-labs/fields/src/lib/strength-meter/strength-meter.component.html","../../../../projects/su-labs/fields/src/lib/auto-grow/auto-grow.directive.ts","../../../../projects/su-labs/fields/src/lib/switch/switch.component.ts","../../../../projects/su-labs/fields/src/lib/switch/switch.component.html","../../../../projects/su-labs/fields/src/lib/email-field/email-check.ts","../../../../projects/su-labs/fields/src/lib/email-field/email-field.component.ts","../../../../projects/su-labs/fields/src/lib/email-field/email-field.component.html","../../../../projects/su-labs/fields/src/lib/checkbox/checkbox.component.ts","../../../../projects/su-labs/fields/src/lib/checkbox/checkbox.component.html","../../../../projects/su-labs/fields/src/lib/chips/chips.component.ts","../../../../projects/su-labs/fields/src/lib/chips/chips.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input, model } from '@angular/core';\n\n/**\n * A short code typed into a row of boxes that fill one by one, then turn green in a wave once the code is complete.\n * One real text field lies over the boxes, so typing, pasting, the phone keyboard and screen readers all work as usual.\n */\n@Component({\n selector: 'su-lib-code-boxes',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './code-boxes.component.html',\n styleUrl: './code-boxes.component.scss',\n})\nexport class SuCodeBoxesComponent {\n readonly value = model('');\n readonly length = input.required<number>();\n readonly label = input.required<string>();\n /** The code is whole and well-formed: the boxes turn green */\n readonly complete = input(false);\n\n protected readonly boxes = computed(() =>\n Array.from({ length: this.length() }, (_, index) => index)\n );\n\n /** Capitals without spaces, never longer than the boxes */\n protected onInput(field: HTMLInputElement): void {\n const code = field.value\n .replace(/\\s/g, '')\n .toUpperCase()\n .slice(0, this.length());\n field.value = code;\n this.value.set(code);\n }\n}\n","<input\n #field\n class=\"field\"\n type=\"text\"\n inputmode=\"text\"\n autocomplete=\"off\"\n autocapitalize=\"characters\"\n spellcheck=\"false\"\n required\n [attr.maxlength]=\"length()\"\n [attr.aria-label]=\"label()\"\n [value]=\"value()\"\n (input)=\"onInput(field)\"\n/>\n<span class=\"boxes\" [class.is-complete]=\"complete()\" aria-hidden=\"true\">\n @for (index of boxes(); track index) {\n <span\n class=\"box\"\n [class.is-filled]=\"index < value().length\"\n [class.is-current]=\"index === value().length\"\n [style.--index]=\"index\"\n >{{ value()[index] }}</span\n >\n }\n</span>\n","/** How strong a new password looks, one step per bar of the meter */\nexport const SU_STRENGTH_LEVELS = ['weak', 'fair', 'good', 'strong'] as const;\nexport type SuStrengthLevel = (typeof SU_STRENGTH_LEVELS)[number];\n\n/** Shortest password the meter counts as more than weak, unless told otherwise */\nexport const SU_DEFAULT_MIN_PASSWORD_LENGTH = 8;\n\n/**\n * Bars of the strength meter a password fills, from 0 (empty) to 4. Under the minimum length it stays at one bar,\n * whatever else it has. Then one bar each for: four characters past the minimum, letters with digits, and symbols or\n * mixed case.\n */\nexport function suPasswordStrength(\n password: string,\n minLength = SU_DEFAULT_MIN_PASSWORD_LENGTH\n): number {\n if (password.length === 0) {\n return 0;\n }\n if (password.length < minLength) {\n return 1;\n }\n const extras = [\n password.length >= minLength + 4,\n /\\p{L}/u.test(password) && /\\d/.test(password),\n /[^\\p{L}\\d]/u.test(password) ||\n (/\\p{Lu}/u.test(password) && /\\p{Ll}/u.test(password)),\n ].filter(Boolean).length;\n return 1 + extras;\n}\n\n/** The meter's word for a number of bars, or null for an empty password */\nexport const suStrengthLevel = (bars: number): SuStrengthLevel | null =>\n SU_STRENGTH_LEVELS[bars - 1] ?? null;\n","import { ChangeDetectionStrategy, Component, computed, effect, input, signal } from '@angular/core';\nimport { SU_DEFAULT_MIN_PASSWORD_LENGTH, SU_STRENGTH_LEVELS, suPasswordStrength, SuStrengthLevel, suStrengthLevel } from './password-strength';\n\n/**\n * Four bars under a new password that fill, and change colour, as the password gets stronger. It follows the field's\n * own typing, so forms keep their plain fields; a form that empties the field by code sends it an `input` event.\n * Its texts come in as inputs, so it fits any language.\n */\n@Component({\n selector: 'su-lib-strength-meter',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './strength-meter.component.html',\n styleUrl: './strength-meter.component.scss',\n})\nexport class SuStrengthMeterComponent {\n readonly field = input.required<HTMLInputElement>();\n /** The meter's name for screen readers, e.g. \"Password strength\" */\n readonly label = input.required<string>();\n /** The word shown for each step */\n readonly levelNames =\n input.required<Readonly<Record<SuStrengthLevel, string>>>();\n readonly minLength = input(SU_DEFAULT_MIN_PASSWORD_LENGTH);\n\n private readonly password = signal('');\n protected readonly steps = SU_STRENGTH_LEVELS;\n protected readonly bars = computed(() =>\n suPasswordStrength(this.password(), this.minLength())\n );\n protected readonly level = computed(() => suStrengthLevel(this.bars()));\n protected readonly levelName = computed(() => {\n const level = this.level();\n return level ? this.levelNames()[level] : null;\n });\n\n constructor() {\n effect(onCleanup => {\n const field = this.field();\n const read = () => this.password.set(field.value);\n read();\n field.addEventListener('input', read);\n onCleanup(() => field.removeEventListener('input', read));\n });\n }\n}\n","<div\n class=\"bars\"\n role=\"meter\"\n [attr.aria-label]=\"label()\"\n aria-valuemin=\"0\"\n [attr.aria-valuemax]=\"steps.length\"\n [attr.aria-valuenow]=\"bars()\"\n [attr.aria-valuetext]=\"levelName()\"\n>\n @for (step of steps; track step; let index = $index) {\n <span class=\"bar\" [class.is-filled]=\"index < bars()\" [style.--index]=\"index\"></span>\n }\n</div>\n@if (levelName(); as name) {\n <small class=\"level\" [attr.data-level]=\"level()\" aria-hidden=\"true\">{{ name }}</small>\n}\n","import { afterNextRender, booleanAttribute, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\n\n/** A soft spring that overshoots a little, as the box settles on its new height */\nconst SPRING = 'height 240ms cubic-bezier(0.34, 1.56, 0.64, 1)';\n\n/**\n * A text box that grows a line at a time as the text gets longer, and shrinks back when it is emptied, with a soft\n * spring (none for visitors who asked their device for less motion). `[suAutoGrow]=\"false\"` leaves it as it is.\n */\n@Directive({\n selector: 'textarea[suAutoGrow]',\n host: { '(input)': 'fit()' },\n})\nexport class SuAutoGrowDirective {\n readonly isOn = input(true, { alias: 'suAutoGrow', transform: booleanAttribute });\n\n private readonly box: HTMLTextAreaElement = inject(ElementRef).nativeElement;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n afterNextRender(() => {\n const onReset = () => setTimeout(() => this.fit());\n this.box.form?.addEventListener('reset', onReset);\n destroyRef.onDestroy(() =>\n this.box.form?.removeEventListener('reset', onReset)\n );\n });\n }\n\n protected fit(): void {\n if (!this.isOn()) {\n return;\n }\n const box = this.box;\n const from = box.offsetHeight;\n box.style.transition = 'none';\n box.style.height = 'auto';\n const to = box.scrollHeight + box.offsetHeight - box.clientHeight;\n box.style.height = `${from}px`;\n void box.offsetHeight;\n box.style.overflowY = 'hidden';\n box.style.transition = matchMedia('(prefers-reduced-motion: reduce)')\n .matches\n ? 'none'\n : SPRING;\n box.style.height = `${to}px`;\n }\n}\n","import { booleanAttribute, ChangeDetectionStrategy, Component, effect, input, linkedSignal, output, untracked } from '@angular/core';\n\n/** Where the label sits: after the switch, or before it with the switch at the end of the row */\nexport type SuSwitchLabelPosition = 'start' | 'end';\n\nexport type SuSwitchSize = 'small' | 'medium';\n\n/**\n * A real checkbox (`role=\"switch\"`) drawn as a sliding switch: the knob stretches while pressed, springs across and a\n * tick pops in when it's on. Put the label inside: `<su-lib-switch [(checked)]=\"on\">Reduce motion</su-lib-switch>`.\n *\n * It shows a click at once and follows `checked` whenever it changes. While `busy` (e.g. saving the change) it ignores\n * clicks, and once no longer busy it shows `checked` again, so a change that failed to save flips back.\n */\n@Component({\n selector: 'su-lib-switch',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './switch.component.html',\n styleUrl: './switch.component.scss',\n})\nexport class SuSwitchComponent {\n readonly checked = input(false, { transform: booleanAttribute });\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Busy saving the change: clicks are ignored, and `aria-busy` is set */\n readonly busy = input(false, { transform: booleanAttribute });\n /** @default 'end' */\n readonly labelPosition = input<SuSwitchLabelPosition>('end');\n /** @default 'medium' */\n readonly size = input<SuSwitchSize>('medium');\n /** Switched by the user: the new value */\n readonly checkedChange = output<boolean>();\n\n protected readonly shown = linkedSignal(() => this.checked());\n\n constructor() {\n effect(() => {\n if (!this.busy()) {\n untracked(() => this.shown.set(this.checked()));\n }\n });\n }\n\n protected onClick(event: MouseEvent): void {\n if (this.busy()) {\n event.preventDefault();\n }\n }\n\n protected onChange(event: Event): void {\n if (event.target instanceof HTMLInputElement) {\n this.shown.set(event.target.checked);\n this.checkedChange.emit(event.target.checked);\n }\n }\n}\n","<label class=\"su-switch su-switch-{{ size() }}\" [class.is-label-start]=\"labelPosition() === 'start'\">\n <input\n type=\"checkbox\"\n role=\"switch\"\n [checked]=\"shown()\"\n [disabled]=\"disabled()\"\n [attr.aria-busy]=\"busy() ? true : null\"\n (click)=\"onClick($event)\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-switch-track\" aria-hidden=\"true\"></span>\n <span class=\"su-switch-label\"><ng-content /></span>\n</label>\n","/** What's wrong with an email address, in the order it's checked */\nexport type SuEmailProblem = 'empty' | 'spaces' | 'at' | 'name' | 'domain' | 'dot' | 'ending';\n\n/** The outcome of `suCheckEmail` */\nexport interface SuEmailCheck {\n readonly valid: boolean;\n readonly problem: SuEmailProblem | null;\n /** The address with a common domain in place of a likely typo, e.g. `jo@gmail.com` for `jo@gmial.com`, or null */\n readonly suggestion: string | null;\n}\n\n/** Domains `suCheckEmail` suggests when one is mistyped */\nexport const SU_COMMON_EMAIL_DOMAINS: readonly string[] = [\n 'gmail.com',\n 'hotmail.com',\n 'outlook.com',\n 'live.com',\n 'yahoo.com',\n 'icloud.com',\n 'me.com',\n 'aol.com',\n 'proton.me',\n 'protonmail.com',\n 'gmx.com',\n 'yandex.com',\n 'hotmail.es',\n 'yahoo.es',\n];\n\n/** How far a typed domain may be from a common one, in single-letter edits, to suggest it */\nconst MAX_TYPO_DISTANCE = 2;\n\nfunction editDistance(a: string, b: string): number {\n let previous = Array.from({ length: b.length + 1 }, (_, index) => index);\n for (let i = 1; i <= a.length; i++) {\n const current = [i];\n for (let j = 1; j <= b.length; j++) {\n current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));\n }\n previous = current;\n }\n return previous[b.length];\n}\n\n/** The common domain a typed one most likely meant, or null when it's already common or nothing is close */\nfunction closestDomain(domain: string, domains: readonly string[]): string | null {\n if (!domain || domains.includes(domain)) {\n return null;\n }\n let best: { readonly domain: string; readonly distance: number } | null = null;\n for (const candidate of domains) {\n const distance = editDistance(domain, candidate);\n if (distance <= MAX_TYPO_DISTANCE && (!best || distance < best.distance)) {\n best = { domain: candidate, distance };\n }\n }\n return best?.domain ?? null;\n}\n\nfunction problemOf(email: string): SuEmailProblem | null {\n if (email === '') {\n return 'empty';\n }\n if (/\\s/.test(email)) {\n return 'spaces';\n }\n const parts = email.split('@');\n if (parts.length !== 2) {\n return 'at';\n }\n const [name, domain] = parts;\n if (!name) {\n return 'name';\n }\n if (!domain) {\n return 'domain';\n }\n const labels = domain.split('.');\n if (labels.length < 2 || labels.some((label) => label === '')) {\n return 'dot';\n }\n return /^\\p{L}{2,}$/u.test(labels[labels.length - 1]) ? null : 'ending';\n}\n\n/**\n * Checks an email address the way people mistype them: empty, spaces, not exactly one @, nothing before or after it,\n * a domain without a proper dot, or an ending shorter than two letters. It also suggests a common domain for a\n * likely typo (`gmial.com` → `gmail.com`), even when the address is otherwise valid.\n */\nexport function suCheckEmail(value: string, domains: readonly string[] = SU_COMMON_EMAIL_DOMAINS): SuEmailCheck {\n const email = value.trim();\n const problem = problemOf(email);\n const [name = '', domain = ''] = email.split('@');\n const fixable = problem === null || problem === 'dot' || problem === 'ending';\n const fix = fixable && name ? closestDomain(domain.toLowerCase(), domains) : null;\n return { valid: problem === null, problem, suggestion: fix ? `${name}@${fix}` : null };\n}\n","import { booleanAttribute, ChangeDetectionStrategy, Component, computed, effect, input, model, output, signal } from '@angular/core';\nimport { SU_COMMON_EMAIL_DOMAINS, suCheckEmail, SuEmailProblem } from './email-check';\n\n/** The field's texts, e.g. in the page's language */\nexport interface SuEmailMessages extends Readonly<Record<SuEmailProblem, string>> {\n /** Before a suggested address: \"Did you mean jo@gmail.com?\" */\n readonly suggestion: string;\n}\n\nexport const SU_EMAIL_MESSAGES: SuEmailMessages = {\n empty: 'Enter your email address',\n spaces: 'An email address has no spaces',\n at: 'An email address has one @, like name@example.com',\n name: 'Add the part before the @',\n domain: 'Add the part after the @, like example.com',\n dot: 'The part after the @ needs a dot, like example.com',\n ending: 'The ending after the last dot needs at least two letters',\n suggestion: 'Did you mean',\n};\n\nlet nextId = 0;\n\n/**\n * An email field that checks the address the way people mistype it, and suggests a common domain for a likely typo\n * (`gmial.com` → `gmail.com`, applied with one tap). It stays quiet while typing and says what's wrong once the field\n * is left; a tick shows when the address looks right.\n */\n@Component({\n selector: 'su-lib-email-field',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './email-field.component.html',\n styleUrl: './email-field.component.scss',\n})\nexport class SuEmailFieldComponent {\n readonly value = model('');\n /** The visible label */\n readonly label = input.required<string>();\n readonly placeholder = input<string>();\n /** An empty field counts as a problem @default false */\n readonly required = input(false, { transform: booleanAttribute });\n readonly messages = input<Partial<SuEmailMessages>>({});\n /** Domains to suggest when one is mistyped */\n readonly domains = input<readonly string[]>(SU_COMMON_EMAIL_DOMAINS);\n /** Whether the address is valid, on every change */\n readonly validityChange = output<boolean>();\n\n protected readonly id = `su-email-${nextId++}`;\n protected readonly touched = signal(false);\n protected readonly check = computed(() => suCheckEmail(this.value(), this.domains()));\n protected readonly text = computed<SuEmailMessages>(() => ({ ...SU_EMAIL_MESSAGES, ...this.messages() }));\n /** The problem to show: only once the field was left, and an empty field only when it's required */\n protected readonly problem = computed(() => {\n const { problem } = this.check();\n if (!this.touched() || !problem || (problem === 'empty' && !this.required())) {\n return null;\n }\n return problem;\n });\n\n constructor() {\n effect(() => this.validityChange.emit(this.check().valid));\n }\n\n protected onInput(event: Event): void {\n if (event.target instanceof HTMLInputElement) {\n this.value.set(event.target.value);\n }\n }\n\n protected apply(suggestion: string): void {\n this.value.set(suggestion);\n this.touched.set(true);\n }\n}\n","@let result = check();\n@let t = text();\n<label class=\"su-email-label\" [for]=\"id\">{{ label() }}</label>\n<div class=\"su-email-box\" [class.is-valid]=\"result.valid\" [class.is-invalid]=\"problem() !== null\">\n <input\n class=\"su-email-input\"\n type=\"email\"\n inputmode=\"email\"\n autocomplete=\"email\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [id]=\"id\"\n [value]=\"value()\"\n [required]=\"required()\"\n [attr.placeholder]=\"placeholder() ?? null\"\n [attr.aria-invalid]=\"problem() !== null ? true : null\"\n [attr.aria-describedby]=\"id + '-message'\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n />\n <span class=\"su-email-tick\" aria-hidden=\"true\"></span>\n</div>\n<p class=\"su-email-message\" aria-live=\"polite\" [id]=\"id + '-message'\">\n @if (problem(); as problem) {\n <span class=\"su-email-problem\">{{ t[problem] }}</span>\n }\n @if (result.suggestion; as suggestion) {\n <span class=\"su-email-suggestion\">\n {{ t.suggestion }}\n <button type=\"button\" class=\"su-email-fix\" (click)=\"apply(suggestion)\">{{ suggestion }}</button>?\n </span>\n }\n</p>\n","import { booleanAttribute, ChangeDetectionStrategy, Component, input, linkedSignal, output } from '@angular/core';\n\n/**\n * A real checkbox whose tick draws itself in, with a small squash when pressed and a dash when partly checked. Put the\n * label inside: `<su-lib-checkbox [(checked)]=\"agree\">I agree</su-lib-checkbox>`.\n */\n@Component({\n selector: 'su-lib-checkbox',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './checkbox.component.html',\n styleUrl: './checkbox.component.scss',\n})\nexport class SuCheckboxComponent {\n readonly checked = input(false, { transform: booleanAttribute });\n /** Partly checked, e.g. some of a group; a click checks it */\n readonly indeterminate = input(false, { transform: booleanAttribute });\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Ticked or unticked by the user: the new value */\n readonly checkedChange = output<boolean>();\n\n protected readonly shown = linkedSignal(() => this.checked());\n\n protected onChange(event: Event): void {\n if (event.target instanceof HTMLInputElement) {\n this.shown.set(event.target.checked);\n this.checkedChange.emit(event.target.checked);\n }\n }\n}\n","<label class=\"su-checkbox\" [class.is-mixed]=\"indeterminate() && !shown()\">\n <input\n type=\"checkbox\"\n [checked]=\"shown()\"\n [indeterminate]=\"indeterminate() && !shown()\"\n [disabled]=\"disabled()\"\n (change)=\"onChange($event)\"\n />\n <span class=\"su-checkbox-box\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 24 24\">\n <path class=\"su-checkbox-tick\" d=\"M5 12.5l4.5 4.5L19 7.5\" />\n <path class=\"su-checkbox-dash\" d=\"M6 12h12\" />\n </svg>\n </span>\n <span class=\"su-checkbox-label\"><ng-content /></span>\n</label>\n","import { booleanAttribute, ChangeDetectionStrategy, Component, input, model } from '@angular/core';\n\n/** One chip: the value it stands for and its text */\nexport interface SuChipOption<TValue extends string> {\n readonly value: TValue;\n readonly label: string;\n readonly disabled?: boolean;\n}\n\n/**\n * Toggle chips to pick several options (or one, with `multiple` off): each is a button that pops a tick in when\n * picked. `<su-lib-chips label=\"Categories\" [options]=\"categories\" [(value)]=\"picked\" />`\n */\n@Component({\n selector: 'su-lib-chips',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './chips.component.html',\n styleUrl: './chips.component.scss',\n})\nexport class SuChipsComponent<TValue extends string> {\n readonly options = input.required<readonly SuChipOption<TValue>[]>();\n /** The picked values, in the options' order */\n readonly value = model<readonly TValue[]>([]);\n /** The group's name for screen readers */\n readonly label = input.required<string>();\n /** Several can be picked; off, picking one replaces the other @default true */\n readonly multiple = input(true, { transform: booleanAttribute });\n\n protected isPicked(value: TValue): boolean {\n return this.value().includes(value);\n }\n\n protected toggle(option: SuChipOption<TValue>): void {\n if (!this.multiple()) {\n this.value.set([option.value]);\n return;\n }\n const picked = this.isPicked(option.value)\n ? this.value().filter((value) => value !== option.value)\n : [...this.value(), option.value];\n this.value.set(this.options().map((item) => item.value).filter((value) => picked.includes(value)));\n }\n}\n","<div class=\"su-chips\" role=\"group\" [attr.aria-label]=\"label()\">\n @for (option of options(); track option.value) {\n <button\n type=\"button\"\n class=\"su-chip\"\n [attr.aria-pressed]=\"isPicked(option.value)\"\n [disabled]=\"option.disabled ?? false\"\n (click)=\"toggle(option)\"\n >\n <span class=\"su-chip-tick\" aria-hidden=\"true\"></span>\n {{ option.label }}\n </button>\n }\n</div>\n"],"mappings":";;AAYA,IAAa,uBAAb,MAAa,qBAAoB;CACtB,QAAQ,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACjB,SAAS,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACjC,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAEhC,WAAW,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAEb,QAAQ,eACzB,MAAM,KAAK,EAAE,QAAQ,KAAK,OAAM,EAAE,IAAK,GAAG,UAAU,KAAK,GAC1D,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGS,QAAQ,OAAuB;EACvC,MAAM,OAAO,MAAM,MAChB,QAAQ,OAAO,EAAE,CAAC,CAClB,YAAW,CAAE,CACb,MAAM,GAAG,KAA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SAAS,KAAK,KAAK,CAAC,CAAC,QAAQ,UAAU,OAAO,SAAS,KAAK,CAAC,CAAC;CACnG;CAtBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAhB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAgB,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,OAAA,cAAA;EAAA,UAAA;EAAA,UCnB7B;EAcA,QAAA,CAAA,4uDAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;ADKa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAN5B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAc,iBACP,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,4uDAAA;EAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-labs/fields",
|
|
3
|
-
"version": "22.
|
|
4
|
-
"description": "Animated Angular form fields: code boxes that fill one by one, a password strength meter, and a text box that grows as you type.",
|
|
3
|
+
"version": "22.1.0",
|
|
4
|
+
"description": "Animated Angular form fields: code boxes that fill one by one, a password strength meter, an email field that catches typos, a sliding switch, checkboxes, chips, and a text box that grows as you type.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
7
7
|
"form",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"password-strength",
|
|
12
12
|
"textarea",
|
|
13
13
|
"auto-grow",
|
|
14
|
+
"switch",
|
|
15
|
+
"toggle",
|
|
16
|
+
"checkbox",
|
|
17
|
+
"chips",
|
|
18
|
+
"email",
|
|
14
19
|
"animation",
|
|
15
20
|
"ui"
|
|
16
21
|
],
|
|
@@ -110,4 +110,226 @@ export declare class SuAutoGrowDirective {
|
|
|
110
110
|
"isSignal": true;
|
|
111
111
|
};
|
|
112
112
|
}, {}, never, never, true, never>;
|
|
113
|
+
}
|
|
114
|
+
/** Where the label sits: after the switch, or before it with the switch at the end of the row */
|
|
115
|
+
export type SuSwitchLabelPosition = 'start' | 'end';
|
|
116
|
+
export type SuSwitchSize = 'small' | 'medium';
|
|
117
|
+
/**
|
|
118
|
+
* A real checkbox (`role="switch"`) drawn as a sliding switch: the knob stretches while pressed, springs across and a
|
|
119
|
+
* tick pops in when it's on. Put the label inside: `<su-lib-switch [(checked)]="on">Reduce motion</su-lib-switch>`.
|
|
120
|
+
*
|
|
121
|
+
* It shows a click at once and follows `checked` whenever it changes. While `busy` (e.g. saving the change) it ignores
|
|
122
|
+
* clicks, and once no longer busy it shows `checked` again, so a change that failed to save flips back.
|
|
123
|
+
*/
|
|
124
|
+
export declare class SuSwitchComponent {
|
|
125
|
+
readonly checked: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
126
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
127
|
+
/** Busy saving the change: clicks are ignored, and `aria-busy` is set */
|
|
128
|
+
readonly busy: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
129
|
+
/** @default 'end' */
|
|
130
|
+
readonly labelPosition: import("@angular/core").InputSignal<SuSwitchLabelPosition>;
|
|
131
|
+
/** @default 'medium' */
|
|
132
|
+
readonly size: import("@angular/core").InputSignal<SuSwitchSize>;
|
|
133
|
+
/** Switched by the user: the new value */
|
|
134
|
+
readonly checkedChange: import("@angular/core").OutputEmitterRef<boolean>;
|
|
135
|
+
protected readonly shown: import("@angular/core").WritableSignal<boolean>;
|
|
136
|
+
constructor();
|
|
137
|
+
protected onClick(event: MouseEvent): void;
|
|
138
|
+
protected onChange(event: Event): void;
|
|
139
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuSwitchComponent, never>;
|
|
140
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuSwitchComponent, "su-lib-switch", never, {
|
|
141
|
+
"checked": {
|
|
142
|
+
"alias": "checked";
|
|
143
|
+
"required": false;
|
|
144
|
+
"isSignal": true;
|
|
145
|
+
};
|
|
146
|
+
"disabled": {
|
|
147
|
+
"alias": "disabled";
|
|
148
|
+
"required": false;
|
|
149
|
+
"isSignal": true;
|
|
150
|
+
};
|
|
151
|
+
"busy": {
|
|
152
|
+
"alias": "busy";
|
|
153
|
+
"required": false;
|
|
154
|
+
"isSignal": true;
|
|
155
|
+
};
|
|
156
|
+
"labelPosition": {
|
|
157
|
+
"alias": "labelPosition";
|
|
158
|
+
"required": false;
|
|
159
|
+
"isSignal": true;
|
|
160
|
+
};
|
|
161
|
+
"size": {
|
|
162
|
+
"alias": "size";
|
|
163
|
+
"required": false;
|
|
164
|
+
"isSignal": true;
|
|
165
|
+
};
|
|
166
|
+
}, {
|
|
167
|
+
"checkedChange": "checkedChange";
|
|
168
|
+
}, never, ["*"], true, never>;
|
|
169
|
+
}
|
|
170
|
+
/** What's wrong with an email address, in the order it's checked */
|
|
171
|
+
export type SuEmailProblem = 'empty' | 'spaces' | 'at' | 'name' | 'domain' | 'dot' | 'ending';
|
|
172
|
+
/** The outcome of `suCheckEmail` */
|
|
173
|
+
export interface SuEmailCheck {
|
|
174
|
+
readonly valid: boolean;
|
|
175
|
+
readonly problem: SuEmailProblem | null;
|
|
176
|
+
/** The address with a common domain in place of a likely typo, e.g. `jo@gmail.com` for `jo@gmial.com`, or null */
|
|
177
|
+
readonly suggestion: string | null;
|
|
178
|
+
}
|
|
179
|
+
/** Domains `suCheckEmail` suggests when one is mistyped */
|
|
180
|
+
export declare const SU_COMMON_EMAIL_DOMAINS: readonly string[];
|
|
181
|
+
/**
|
|
182
|
+
* Checks an email address the way people mistype them: empty, spaces, not exactly one @, nothing before or after it,
|
|
183
|
+
* a domain without a proper dot, or an ending shorter than two letters. It also suggests a common domain for a
|
|
184
|
+
* likely typo (`gmial.com` → `gmail.com`), even when the address is otherwise valid.
|
|
185
|
+
*/
|
|
186
|
+
export declare function suCheckEmail(value: string, domains?: readonly string[]): SuEmailCheck;
|
|
187
|
+
/** The field's texts, e.g. in the page's language */
|
|
188
|
+
export interface SuEmailMessages extends Readonly<Record<SuEmailProblem, string>> {
|
|
189
|
+
/** Before a suggested address: "Did you mean jo@gmail.com?" */
|
|
190
|
+
readonly suggestion: string;
|
|
191
|
+
}
|
|
192
|
+
export declare const SU_EMAIL_MESSAGES: SuEmailMessages;
|
|
193
|
+
/**
|
|
194
|
+
* An email field that checks the address the way people mistype it, and suggests a common domain for a likely typo
|
|
195
|
+
* (`gmial.com` → `gmail.com`, applied with one tap). It stays quiet while typing and says what's wrong once the field
|
|
196
|
+
* is left; a tick shows when the address looks right.
|
|
197
|
+
*/
|
|
198
|
+
export declare class SuEmailFieldComponent {
|
|
199
|
+
readonly value: import("@angular/core").ModelSignal<string>;
|
|
200
|
+
/** The visible label */
|
|
201
|
+
readonly label: import("@angular/core").InputSignal<string>;
|
|
202
|
+
readonly placeholder: import("@angular/core").InputSignal<string | undefined>;
|
|
203
|
+
/** An empty field counts as a problem @default false */
|
|
204
|
+
readonly required: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
205
|
+
readonly messages: import("@angular/core").InputSignal<Partial<SuEmailMessages>>;
|
|
206
|
+
/** Domains to suggest when one is mistyped */
|
|
207
|
+
readonly domains: import("@angular/core").InputSignal<readonly string[]>;
|
|
208
|
+
/** Whether the address is valid, on every change */
|
|
209
|
+
readonly validityChange: import("@angular/core").OutputEmitterRef<boolean>;
|
|
210
|
+
protected readonly id: string;
|
|
211
|
+
protected readonly touched: import("@angular/core").WritableSignal<boolean>;
|
|
212
|
+
protected readonly check: import("@angular/core").Signal<import("@su-labs/fields").SuEmailCheck>;
|
|
213
|
+
protected readonly text: import("@angular/core").Signal<SuEmailMessages>;
|
|
214
|
+
/** The problem to show: only once the field was left, and an empty field only when it's required */
|
|
215
|
+
protected readonly problem: import("@angular/core").Signal<"empty" | "spaces" | "at" | "name" | "domain" | "dot" | "ending" | null>;
|
|
216
|
+
constructor();
|
|
217
|
+
protected onInput(event: Event): void;
|
|
218
|
+
protected apply(suggestion: string): void;
|
|
219
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuEmailFieldComponent, never>;
|
|
220
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuEmailFieldComponent, "su-lib-email-field", never, {
|
|
221
|
+
"value": {
|
|
222
|
+
"alias": "value";
|
|
223
|
+
"required": false;
|
|
224
|
+
"isSignal": true;
|
|
225
|
+
};
|
|
226
|
+
"label": {
|
|
227
|
+
"alias": "label";
|
|
228
|
+
"required": true;
|
|
229
|
+
"isSignal": true;
|
|
230
|
+
};
|
|
231
|
+
"placeholder": {
|
|
232
|
+
"alias": "placeholder";
|
|
233
|
+
"required": false;
|
|
234
|
+
"isSignal": true;
|
|
235
|
+
};
|
|
236
|
+
"required": {
|
|
237
|
+
"alias": "required";
|
|
238
|
+
"required": false;
|
|
239
|
+
"isSignal": true;
|
|
240
|
+
};
|
|
241
|
+
"messages": {
|
|
242
|
+
"alias": "messages";
|
|
243
|
+
"required": false;
|
|
244
|
+
"isSignal": true;
|
|
245
|
+
};
|
|
246
|
+
"domains": {
|
|
247
|
+
"alias": "domains";
|
|
248
|
+
"required": false;
|
|
249
|
+
"isSignal": true;
|
|
250
|
+
};
|
|
251
|
+
}, {
|
|
252
|
+
"value": "valueChange";
|
|
253
|
+
"validityChange": "validityChange";
|
|
254
|
+
}, never, never, true, never>;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A real checkbox whose tick draws itself in, with a small squash when pressed and a dash when partly checked. Put the
|
|
258
|
+
* label inside: `<su-lib-checkbox [(checked)]="agree">I agree</su-lib-checkbox>`.
|
|
259
|
+
*/
|
|
260
|
+
export declare class SuCheckboxComponent {
|
|
261
|
+
readonly checked: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
262
|
+
/** Partly checked, e.g. some of a group; a click checks it */
|
|
263
|
+
readonly indeterminate: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
264
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
265
|
+
/** Ticked or unticked by the user: the new value */
|
|
266
|
+
readonly checkedChange: import("@angular/core").OutputEmitterRef<boolean>;
|
|
267
|
+
protected readonly shown: import("@angular/core").WritableSignal<boolean>;
|
|
268
|
+
protected onChange(event: Event): void;
|
|
269
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuCheckboxComponent, never>;
|
|
270
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuCheckboxComponent, "su-lib-checkbox", never, {
|
|
271
|
+
"checked": {
|
|
272
|
+
"alias": "checked";
|
|
273
|
+
"required": false;
|
|
274
|
+
"isSignal": true;
|
|
275
|
+
};
|
|
276
|
+
"indeterminate": {
|
|
277
|
+
"alias": "indeterminate";
|
|
278
|
+
"required": false;
|
|
279
|
+
"isSignal": true;
|
|
280
|
+
};
|
|
281
|
+
"disabled": {
|
|
282
|
+
"alias": "disabled";
|
|
283
|
+
"required": false;
|
|
284
|
+
"isSignal": true;
|
|
285
|
+
};
|
|
286
|
+
}, {
|
|
287
|
+
"checkedChange": "checkedChange";
|
|
288
|
+
}, never, ["*"], true, never>;
|
|
289
|
+
}
|
|
290
|
+
/** One chip: the value it stands for and its text */
|
|
291
|
+
export interface SuChipOption<TValue extends string> {
|
|
292
|
+
readonly value: TValue;
|
|
293
|
+
readonly label: string;
|
|
294
|
+
readonly disabled?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Toggle chips to pick several options (or one, with `multiple` off): each is a button that pops a tick in when
|
|
298
|
+
* picked. `<su-lib-chips label="Categories" [options]="categories" [(value)]="picked" />`
|
|
299
|
+
*/
|
|
300
|
+
export declare class SuChipsComponent<TValue extends string> {
|
|
301
|
+
readonly options: import("@angular/core").InputSignal<readonly SuChipOption<TValue>[]>;
|
|
302
|
+
/** The picked values, in the options' order */
|
|
303
|
+
readonly value: import("@angular/core").ModelSignal<readonly TValue[]>;
|
|
304
|
+
/** The group's name for screen readers */
|
|
305
|
+
readonly label: import("@angular/core").InputSignal<string>;
|
|
306
|
+
/** Several can be picked; off, picking one replaces the other @default true */
|
|
307
|
+
readonly multiple: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
308
|
+
protected isPicked(value: TValue): boolean;
|
|
309
|
+
protected toggle(option: SuChipOption<TValue>): void;
|
|
310
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuChipsComponent<any>, never>;
|
|
311
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuChipsComponent<any>, "su-lib-chips", never, {
|
|
312
|
+
"options": {
|
|
313
|
+
"alias": "options";
|
|
314
|
+
"required": true;
|
|
315
|
+
"isSignal": true;
|
|
316
|
+
};
|
|
317
|
+
"value": {
|
|
318
|
+
"alias": "value";
|
|
319
|
+
"required": false;
|
|
320
|
+
"isSignal": true;
|
|
321
|
+
};
|
|
322
|
+
"label": {
|
|
323
|
+
"alias": "label";
|
|
324
|
+
"required": true;
|
|
325
|
+
"isSignal": true;
|
|
326
|
+
};
|
|
327
|
+
"multiple": {
|
|
328
|
+
"alias": "multiple";
|
|
329
|
+
"required": false;
|
|
330
|
+
"isSignal": true;
|
|
331
|
+
};
|
|
332
|
+
}, {
|
|
333
|
+
"value": "valueChange";
|
|
334
|
+
}, never, never, true, never>;
|
|
113
335
|
}
|