ng-primitives 0.125.0 → 0.126.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/fesm2022/ng-primitives-password.mjs +293 -0
- package/fesm2022/ng-primitives-password.mjs.map +1 -0
- package/package.json +5 -1
- package/password/README.md +3 -0
- package/schematics/ng-generate/templates/password/password.__fileSuffix@dasherize__.ts.template +141 -0
- package/types/ng-primitives-password.d.ts +296 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, signal, computed, input, booleanAttribute, Directive, output } from '@angular/core';
|
|
3
|
+
import { uniqueId } from 'ng-primitives/utils';
|
|
4
|
+
import { ngpInput } from 'ng-primitives/input';
|
|
5
|
+
import { injectElementRef } from 'ng-primitives/internal';
|
|
6
|
+
import { createPrimitive, controlled, controlledState, dataBinding, deprecatedSetter, attrBinding, onMount, listener } from 'ng-primitives/state';
|
|
7
|
+
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
|
8
|
+
|
|
9
|
+
const defaultPasswordConfig = {
|
|
10
|
+
showLabel: 'Show password',
|
|
11
|
+
hideLabel: 'Hide password',
|
|
12
|
+
shownAnnouncement: 'Your password is shown',
|
|
13
|
+
hiddenAnnouncement: 'Your password is hidden',
|
|
14
|
+
ignorePasswordManagers: false,
|
|
15
|
+
};
|
|
16
|
+
const NgpPasswordConfigToken = new InjectionToken('NgpPasswordConfigToken');
|
|
17
|
+
/**
|
|
18
|
+
* Provide the default Password configuration
|
|
19
|
+
* @param config The Password configuration
|
|
20
|
+
* @returns The provider
|
|
21
|
+
*/
|
|
22
|
+
function providePasswordConfig(config) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
provide: NgpPasswordConfigToken,
|
|
26
|
+
useValue: { ...defaultPasswordConfig, ...config },
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Inject the Password configuration
|
|
32
|
+
* @returns The global Password configuration
|
|
33
|
+
*/
|
|
34
|
+
function injectPasswordConfig() {
|
|
35
|
+
return inject(NgpPasswordConfigToken, { optional: true }) ?? defaultPasswordConfig;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const [NgpPasswordStateToken, ngpPassword, injectPasswordState, providePasswordState] = createPrimitive('NgpPassword', ({ visible: _visible, defaultVisible: _defaultVisible, onVisibleChange, }) => {
|
|
39
|
+
const element = injectElementRef();
|
|
40
|
+
const defaultVisible = controlled(_defaultVisible, false);
|
|
41
|
+
const input = signal(null, ...(ngDevMode ? [{ debugName: "input" }] : /* istanbul ignore next */ []));
|
|
42
|
+
const inputId = signal(null, ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
|
|
43
|
+
const [visible, setVisible, visibleChange] = controlledState({
|
|
44
|
+
value: _visible,
|
|
45
|
+
defaultValue: defaultVisible,
|
|
46
|
+
onChange: onVisibleChange,
|
|
47
|
+
});
|
|
48
|
+
dataBinding(element, 'data-visible', visible);
|
|
49
|
+
function toggle() {
|
|
50
|
+
setVisible(!visible());
|
|
51
|
+
}
|
|
52
|
+
function registerInput(el, id) {
|
|
53
|
+
input.set(el);
|
|
54
|
+
inputId.set(id);
|
|
55
|
+
}
|
|
56
|
+
function focusInput() {
|
|
57
|
+
input()?.focus();
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
visible: deprecatedSetter(visible, 'setVisible', setVisible),
|
|
61
|
+
visibleChange,
|
|
62
|
+
inputId: computed(() => inputId()?.() ?? null),
|
|
63
|
+
toggle,
|
|
64
|
+
setVisible,
|
|
65
|
+
setDefaultVisible: defaultVisible.set,
|
|
66
|
+
registerInput,
|
|
67
|
+
focusInput,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const [NgpPasswordInputStateToken, ngpPasswordInput, injectPasswordInputState, providePasswordInputState,] = createPrimitive('NgpPasswordInput', ({ id, disabled, ignorePasswordManagers = signal(false), }) => {
|
|
72
|
+
const element = injectElementRef();
|
|
73
|
+
const password = injectPasswordState();
|
|
74
|
+
// Compose ngpInput for form control, interactions, autofill and the id.
|
|
75
|
+
const input = ngpInput({ id, disabled });
|
|
76
|
+
// Register with the container for aria-controls.
|
|
77
|
+
password().registerInput(element.nativeElement, input.id);
|
|
78
|
+
// Consumers keep type="password" in the markup so the field renders masked
|
|
79
|
+
// from the start; this drives the toggle to text and back.
|
|
80
|
+
attrBinding(element, 'type', () => (password().visible() ? 'text' : 'password'));
|
|
81
|
+
dataBinding(element, 'data-visible', () => password().visible());
|
|
82
|
+
// Opt out of password manager injection when requested.
|
|
83
|
+
attrBinding(element, 'data-1p-ignore', () => (ignorePasswordManagers() ? '' : null));
|
|
84
|
+
attrBinding(element, 'data-lpignore', () => (ignorePasswordManagers() ? 'true' : null));
|
|
85
|
+
attrBinding(element, 'data-bwignore', () => (ignorePasswordManagers() ? '' : null));
|
|
86
|
+
// Reset to hidden on submit so browsers don't cache a plaintext field.
|
|
87
|
+
onMount(() => {
|
|
88
|
+
const form = element.nativeElement.form;
|
|
89
|
+
if (form) {
|
|
90
|
+
listener(form, 'submit', () => password().setVisible(false));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return input;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Apply the `ngpPasswordInput` directive to an `input` element within an `ngpPassword` container.
|
|
98
|
+
* It is a complete input (form control, interactions, autofill) with password visibility toggling
|
|
99
|
+
* layered on top, so it does not need to be combined with `ngpInput`.
|
|
100
|
+
*/
|
|
101
|
+
class NgpPasswordInput {
|
|
102
|
+
constructor() {
|
|
103
|
+
/**
|
|
104
|
+
* Access the global password configuration.
|
|
105
|
+
*/
|
|
106
|
+
this.config = injectPasswordConfig();
|
|
107
|
+
/**
|
|
108
|
+
* The id of the input.
|
|
109
|
+
*/
|
|
110
|
+
this.id = input(uniqueId('ngp-password-input'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
111
|
+
/**
|
|
112
|
+
* Whether the input is disabled.
|
|
113
|
+
*/
|
|
114
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
115
|
+
/**
|
|
116
|
+
* Whether to opt the input out of password manager injection
|
|
117
|
+
* (1Password, LastPass, Bitwarden, etc.).
|
|
118
|
+
*/
|
|
119
|
+
this.ignorePasswordManagers = input(this.config.ignorePasswordManagers, { ...(ngDevMode ? { debugName: "ignorePasswordManagers" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordInputIgnorePasswordManagers',
|
|
120
|
+
transform: booleanAttribute });
|
|
121
|
+
/**
|
|
122
|
+
* The state for the password input primitive.
|
|
123
|
+
*/
|
|
124
|
+
this.state = ngpPasswordInput({
|
|
125
|
+
id: this.id,
|
|
126
|
+
disabled: this.disabled,
|
|
127
|
+
ignorePasswordManagers: this.ignorePasswordManagers,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPasswordInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
131
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPasswordInput, isStandalone: true, selector: "input[ngpPasswordInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ignorePasswordManagers: { classPropertyName: "ignorePasswordManagers", publicName: "ngpPasswordInputIgnorePasswordManagers", isSignal: true, isRequired: false, transformFunction: null } }, providers: [providePasswordInputState()], exportAs: ["ngpPasswordInput"], ngImport: i0 }); }
|
|
132
|
+
}
|
|
133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPasswordInput, decorators: [{
|
|
134
|
+
type: Directive,
|
|
135
|
+
args: [{
|
|
136
|
+
selector: 'input[ngpPasswordInput]',
|
|
137
|
+
exportAs: 'ngpPasswordInput',
|
|
138
|
+
providers: [providePasswordInputState()],
|
|
139
|
+
}]
|
|
140
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ignorePasswordManagers: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordInputIgnorePasswordManagers", required: false }] }] } });
|
|
141
|
+
|
|
142
|
+
const [NgpPasswordToggleStateToken, ngpPasswordToggle, injectPasswordToggleState, providePasswordToggleState,] = createPrimitive('NgpPasswordToggle', ({ showLabel, hideLabel, shownAnnouncement, hiddenAnnouncement, }) => {
|
|
143
|
+
const element = injectElementRef();
|
|
144
|
+
const password = injectPasswordState();
|
|
145
|
+
const announcer = inject(LiveAnnouncer);
|
|
146
|
+
// Pointer activation returns focus to the input; keyboard keeps it on the button.
|
|
147
|
+
const pointerActivated = signal(false, ...(ngDevMode ? [{ debugName: "pointerActivated" }] : /* istanbul ignore next */ []));
|
|
148
|
+
attrBinding(element, 'type', 'button');
|
|
149
|
+
attrBinding(element, 'aria-controls', () => password().inputId());
|
|
150
|
+
attrBinding(element, 'aria-label', () => {
|
|
151
|
+
// Defer to the button's own text if it has any.
|
|
152
|
+
if ((element.nativeElement.textContent ?? '').trim().length > 0) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return password().visible() ? hideLabel() : showLabel();
|
|
156
|
+
});
|
|
157
|
+
dataBinding(element, 'data-visible', () => password().visible());
|
|
158
|
+
listener(element, 'pointerdown', () => pointerActivated.set(true));
|
|
159
|
+
listener(element, 'click', () => toggle());
|
|
160
|
+
function toggle() {
|
|
161
|
+
const state = password();
|
|
162
|
+
// Announce the intended state: in controlled mode state.visible() may not
|
|
163
|
+
// reflect the new value until the parent propagates it back.
|
|
164
|
+
const willBeVisible = !state.visible();
|
|
165
|
+
state.toggle();
|
|
166
|
+
announcer.announce(willBeVisible ? shownAnnouncement() : hiddenAnnouncement());
|
|
167
|
+
if (pointerActivated()) {
|
|
168
|
+
state.focusInput();
|
|
169
|
+
}
|
|
170
|
+
pointerActivated.set(false);
|
|
171
|
+
}
|
|
172
|
+
return { toggle };
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Apply the `ngpPasswordToggle` directive to a `button` element to toggle the visibility of the
|
|
177
|
+
* password within an `ngpPassword` container.
|
|
178
|
+
*/
|
|
179
|
+
class NgpPasswordToggle {
|
|
180
|
+
constructor() {
|
|
181
|
+
/**
|
|
182
|
+
* Access the global password configuration.
|
|
183
|
+
*/
|
|
184
|
+
this.config = injectPasswordConfig();
|
|
185
|
+
/**
|
|
186
|
+
* The accessible label shown when the password is hidden.
|
|
187
|
+
*/
|
|
188
|
+
this.showLabel = input(this.config.showLabel, { ...(ngDevMode ? { debugName: "showLabel" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordToggleShowLabel' });
|
|
189
|
+
/**
|
|
190
|
+
* The accessible label shown when the password is visible.
|
|
191
|
+
*/
|
|
192
|
+
this.hideLabel = input(this.config.hideLabel, { ...(ngDevMode ? { debugName: "hideLabel" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordToggleHideLabel' });
|
|
193
|
+
/**
|
|
194
|
+
* The message announced when the password becomes visible.
|
|
195
|
+
*/
|
|
196
|
+
this.shownAnnouncement = input(this.config.shownAnnouncement, { ...(ngDevMode ? { debugName: "shownAnnouncement" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordToggleShownAnnouncement' });
|
|
197
|
+
/**
|
|
198
|
+
* The message announced when the password becomes hidden.
|
|
199
|
+
*/
|
|
200
|
+
this.hiddenAnnouncement = input(this.config.hiddenAnnouncement, { ...(ngDevMode ? { debugName: "hiddenAnnouncement" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordToggleHiddenAnnouncement' });
|
|
201
|
+
/**
|
|
202
|
+
* The state for the password toggle primitive.
|
|
203
|
+
*/
|
|
204
|
+
this.state = ngpPasswordToggle({
|
|
205
|
+
showLabel: this.showLabel,
|
|
206
|
+
hideLabel: this.hideLabel,
|
|
207
|
+
shownAnnouncement: this.shownAnnouncement,
|
|
208
|
+
hiddenAnnouncement: this.hiddenAnnouncement,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Toggle the visibility of the password.
|
|
213
|
+
*/
|
|
214
|
+
toggle() {
|
|
215
|
+
this.state.toggle();
|
|
216
|
+
}
|
|
217
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPasswordToggle, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
218
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPasswordToggle, isStandalone: true, selector: "button[ngpPasswordToggle]", inputs: { showLabel: { classPropertyName: "showLabel", publicName: "ngpPasswordToggleShowLabel", isSignal: true, isRequired: false, transformFunction: null }, hideLabel: { classPropertyName: "hideLabel", publicName: "ngpPasswordToggleHideLabel", isSignal: true, isRequired: false, transformFunction: null }, shownAnnouncement: { classPropertyName: "shownAnnouncement", publicName: "ngpPasswordToggleShownAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, hiddenAnnouncement: { classPropertyName: "hiddenAnnouncement", publicName: "ngpPasswordToggleHiddenAnnouncement", isSignal: true, isRequired: false, transformFunction: null } }, providers: [providePasswordToggleState()], exportAs: ["ngpPasswordToggle"], ngImport: i0 }); }
|
|
219
|
+
}
|
|
220
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPasswordToggle, decorators: [{
|
|
221
|
+
type: Directive,
|
|
222
|
+
args: [{
|
|
223
|
+
selector: 'button[ngpPasswordToggle]',
|
|
224
|
+
exportAs: 'ngpPasswordToggle',
|
|
225
|
+
providers: [providePasswordToggleState()],
|
|
226
|
+
}]
|
|
227
|
+
}], propDecorators: { showLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordToggleShowLabel", required: false }] }], hideLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordToggleHideLabel", required: false }] }], shownAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordToggleShownAnnouncement", required: false }] }], hiddenAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordToggleHiddenAnnouncement", required: false }] }] } });
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The `NgpPassword` directive is a container for a password field and its visibility toggle.
|
|
231
|
+
*/
|
|
232
|
+
class NgpPassword {
|
|
233
|
+
constructor() {
|
|
234
|
+
/**
|
|
235
|
+
* Whether the password is visible.
|
|
236
|
+
*/
|
|
237
|
+
this.visible = input(undefined, { ...(ngDevMode ? { debugName: "visible" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordVisible',
|
|
238
|
+
transform: booleanAttribute });
|
|
239
|
+
/**
|
|
240
|
+
* The default visibility state for uncontrolled usage.
|
|
241
|
+
* @default false
|
|
242
|
+
*/
|
|
243
|
+
this.defaultVisible = input(false, { ...(ngDevMode ? { debugName: "defaultVisible" } : /* istanbul ignore next */ {}), alias: 'ngpPasswordDefaultVisible',
|
|
244
|
+
transform: booleanAttribute });
|
|
245
|
+
/**
|
|
246
|
+
* Emits when the visibility state changes.
|
|
247
|
+
*/
|
|
248
|
+
this.visibleChange = output({
|
|
249
|
+
alias: 'ngpPasswordVisibleChange',
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* The state for the password primitive.
|
|
253
|
+
*/
|
|
254
|
+
this.state = ngpPassword({
|
|
255
|
+
visible: this.visible,
|
|
256
|
+
defaultVisible: this.defaultVisible,
|
|
257
|
+
onVisibleChange: value => this.visibleChange.emit(value),
|
|
258
|
+
});
|
|
259
|
+
/**
|
|
260
|
+
* Whether the password is currently visible.
|
|
261
|
+
*/
|
|
262
|
+
this.isVisible = computed(() => this.state.visible(), ...(ngDevMode ? [{ debugName: "isVisible" }] : /* istanbul ignore next */ []));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Toggle the visibility of the password.
|
|
266
|
+
*/
|
|
267
|
+
toggle() {
|
|
268
|
+
this.state.toggle();
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Set the visibility of the password.
|
|
272
|
+
*/
|
|
273
|
+
setVisible(value, options) {
|
|
274
|
+
this.state.setVisible(value, options);
|
|
275
|
+
}
|
|
276
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPassword, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
277
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPassword, isStandalone: true, selector: "[ngpPassword]", inputs: { visible: { classPropertyName: "visible", publicName: "ngpPasswordVisible", isSignal: true, isRequired: false, transformFunction: null }, defaultVisible: { classPropertyName: "defaultVisible", publicName: "ngpPasswordDefaultVisible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "ngpPasswordVisibleChange" }, providers: [providePasswordState()], exportAs: ["ngpPassword"], ngImport: i0 }); }
|
|
278
|
+
}
|
|
279
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPassword, decorators: [{
|
|
280
|
+
type: Directive,
|
|
281
|
+
args: [{
|
|
282
|
+
selector: '[ngpPassword]',
|
|
283
|
+
exportAs: 'ngpPassword',
|
|
284
|
+
providers: [providePasswordState()],
|
|
285
|
+
}]
|
|
286
|
+
}], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordVisible", required: false }] }], defaultVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPasswordDefaultVisible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["ngpPasswordVisibleChange"] }] } });
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Generated bundle index. Do not edit.
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
export { NgpPassword, NgpPasswordConfigToken, NgpPasswordInput, NgpPasswordToggle, defaultPasswordConfig, injectPasswordConfig, injectPasswordInputState, injectPasswordState, injectPasswordToggleState, ngpPassword, ngpPasswordInput, ngpPasswordToggle, providePasswordConfig, providePasswordInputState, providePasswordState, providePasswordToggleState };
|
|
293
|
+
//# sourceMappingURL=ng-primitives-password.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-primitives-password.mjs","sources":["../../../../packages/ng-primitives/password/src/config/password-config.ts","../../../../packages/ng-primitives/password/src/password/password-state.ts","../../../../packages/ng-primitives/password/src/password-input/password-input-state.ts","../../../../packages/ng-primitives/password/src/password-input/password-input.ts","../../../../packages/ng-primitives/password/src/password-toggle/password-toggle-state.ts","../../../../packages/ng-primitives/password/src/password-toggle/password-toggle.ts","../../../../packages/ng-primitives/password/src/password/password.ts","../../../../packages/ng-primitives/password/src/ng-primitives-password.ts"],"sourcesContent":["import { inject, InjectionToken, Provider } from '@angular/core';\n\nexport interface NgpPasswordConfig {\n /**\n * The accessible label for the toggle button when the password is hidden.\n * @default 'Show password'\n */\n showLabel: string;\n\n /**\n * The accessible label for the toggle button when the password is visible.\n * @default 'Hide password'\n */\n hideLabel: string;\n\n /**\n * The message announced to screen readers when the password becomes visible.\n * @default 'Your password is shown'\n */\n shownAnnouncement: string;\n\n /**\n * The message announced to screen readers when the password becomes hidden.\n * @default 'Your password is hidden'\n */\n hiddenAnnouncement: string;\n\n /**\n * Whether to opt the input out of password manager injection by default.\n * @default false\n */\n ignorePasswordManagers: boolean;\n}\n\nexport const defaultPasswordConfig: NgpPasswordConfig = {\n showLabel: 'Show password',\n hideLabel: 'Hide password',\n shownAnnouncement: 'Your password is shown',\n hiddenAnnouncement: 'Your password is hidden',\n ignorePasswordManagers: false,\n};\n\nexport const NgpPasswordConfigToken = new InjectionToken<NgpPasswordConfig>(\n 'NgpPasswordConfigToken',\n);\n\n/**\n * Provide the default Password configuration\n * @param config The Password configuration\n * @returns The provider\n */\nexport function providePasswordConfig(config: Partial<NgpPasswordConfig>): Provider[] {\n return [\n {\n provide: NgpPasswordConfigToken,\n useValue: { ...defaultPasswordConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Password configuration\n * @returns The global Password configuration\n */\nexport function injectPasswordConfig(): NgpPasswordConfig {\n return inject(NgpPasswordConfigToken, { optional: true }) ?? defaultPasswordConfig;\n}\n","import { computed, Signal, signal, WritableSignal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n controlled,\n controlledState,\n createPrimitive,\n dataBinding,\n deprecatedSetter,\n SetterOptions,\n} from 'ng-primitives/state';\nimport { Observable } from 'rxjs';\n\n/**\n * Public state surface for the Password primitive.\n */\nexport interface NgpPasswordState {\n /**\n * Whether the password is currently visible.\n */\n readonly visible: WritableSignal<boolean>;\n /**\n * Emits when the visibility state changes.\n */\n readonly visibleChange: Observable<boolean>;\n /**\n * The id of the registered input, used to wire up `aria-controls`.\n * @internal\n */\n readonly inputId: Signal<string | null>;\n /**\n * Toggle the visibility state.\n */\n toggle(): void;\n /**\n * Set the visibility state.\n */\n setVisible(value: boolean, options?: SetterOptions): void;\n /**\n * Set the default visibility state.\n */\n setDefaultVisible(value: boolean): void;\n /**\n * Register the password input with the container.\n * @internal\n */\n registerInput(input: HTMLInputElement, id: Signal<string>): void;\n /**\n * Focus the registered input.\n * @internal\n */\n focusInput(): void;\n}\n\n/**\n * Inputs for configuring the Password primitive.\n */\nexport interface NgpPasswordProps {\n /**\n * Whether the password is visible.\n */\n readonly visible: Signal<boolean | undefined>;\n /**\n * The default visibility state for uncontrolled usage.\n */\n readonly defaultVisible?: Signal<boolean>;\n /**\n * Callback fired when the visibility state changes.\n */\n readonly onVisibleChange?: (visible: boolean) => void;\n}\n\nexport const [NgpPasswordStateToken, ngpPassword, injectPasswordState, providePasswordState] =\n createPrimitive(\n 'NgpPassword',\n ({\n visible: _visible,\n defaultVisible: _defaultVisible,\n onVisibleChange,\n }: NgpPasswordProps): NgpPasswordState => {\n const element = injectElementRef<HTMLElement>();\n const defaultVisible = controlled(_defaultVisible, false);\n\n const input = signal<HTMLInputElement | null>(null);\n const inputId = signal<Signal<string> | null>(null);\n\n const [visible, setVisible, visibleChange] = controlledState({\n value: _visible,\n defaultValue: defaultVisible,\n onChange: onVisibleChange,\n });\n\n dataBinding(element, 'data-visible', visible);\n\n function toggle(): void {\n setVisible(!visible());\n }\n\n function registerInput(el: HTMLInputElement, id: Signal<string>): void {\n input.set(el);\n inputId.set(id);\n }\n\n function focusInput(): void {\n input()?.focus();\n }\n\n return {\n visible: deprecatedSetter(visible, 'setVisible', setVisible),\n visibleChange,\n inputId: computed(() => inputId()?.() ?? null),\n toggle,\n setVisible,\n setDefaultVisible: defaultVisible.set,\n registerInput,\n focusInput,\n } satisfies NgpPasswordState;\n },\n );\n","import { Signal, signal } from '@angular/core';\nimport { ngpInput, NgpInputState } from 'ng-primitives/input';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, createPrimitive, dataBinding, listener, onMount } from 'ng-primitives/state';\nimport { injectPasswordState } from '../password/password-state';\n\n/**\n * The state for the PasswordInput pattern, extending the Input state.\n */\nexport type NgpPasswordInputState = NgpInputState;\n\n/**\n * The props interface for the PasswordInput pattern.\n */\nexport interface NgpPasswordInputProps {\n /**\n * The id of the input.\n */\n readonly id?: Signal<string>;\n /**\n * Whether the input is disabled.\n */\n readonly disabled?: Signal<boolean>;\n /**\n * Whether to opt the input out of password manager injection.\n */\n readonly ignorePasswordManagers?: Signal<boolean>;\n}\n\nexport const [\n NgpPasswordInputStateToken,\n ngpPasswordInput,\n injectPasswordInputState,\n providePasswordInputState,\n] = createPrimitive(\n 'NgpPasswordInput',\n ({\n id,\n disabled,\n ignorePasswordManagers = signal(false),\n }: NgpPasswordInputProps): NgpPasswordInputState => {\n const element = injectElementRef<HTMLInputElement>();\n const password = injectPasswordState();\n\n // Compose ngpInput for form control, interactions, autofill and the id.\n const input = ngpInput({ id, disabled });\n\n // Register with the container for aria-controls.\n password().registerInput(element.nativeElement, input.id);\n\n // Consumers keep type=\"password\" in the markup so the field renders masked\n // from the start; this drives the toggle to text and back.\n attrBinding(element, 'type', () => (password().visible() ? 'text' : 'password'));\n dataBinding(element, 'data-visible', () => password().visible());\n\n // Opt out of password manager injection when requested.\n attrBinding(element, 'data-1p-ignore', () => (ignorePasswordManagers() ? '' : null));\n attrBinding(element, 'data-lpignore', () => (ignorePasswordManagers() ? 'true' : null));\n attrBinding(element, 'data-bwignore', () => (ignorePasswordManagers() ? '' : null));\n\n // Reset to hidden on submit so browsers don't cache a plaintext field.\n onMount(() => {\n const form = element.nativeElement.form;\n if (form) {\n listener(form, 'submit', () => password().setVisible(false));\n }\n });\n\n return input;\n },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectPasswordConfig } from '../config/password-config';\nimport { ngpPasswordInput, providePasswordInputState } from './password-input-state';\n\n/**\n * Apply the `ngpPasswordInput` directive to an `input` element within an `ngpPassword` container.\n * It is a complete input (form control, interactions, autofill) with password visibility toggling\n * layered on top, so it does not need to be combined with `ngpInput`.\n */\n@Directive({\n selector: 'input[ngpPasswordInput]',\n exportAs: 'ngpPasswordInput',\n providers: [providePasswordInputState()],\n})\nexport class NgpPasswordInput {\n /**\n * Access the global password configuration.\n */\n private readonly config = injectPasswordConfig();\n\n /**\n * The id of the input.\n */\n readonly id = input<string>(uniqueId('ngp-password-input'));\n\n /**\n * Whether the input is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * Whether to opt the input out of password manager injection\n * (1Password, LastPass, Bitwarden, etc.).\n */\n readonly ignorePasswordManagers = input<boolean, BooleanInput>(\n this.config.ignorePasswordManagers,\n {\n alias: 'ngpPasswordInputIgnorePasswordManagers',\n transform: booleanAttribute,\n },\n );\n\n /**\n * The state for the password input primitive.\n */\n protected readonly state = ngpPasswordInput({\n id: this.id,\n disabled: this.disabled,\n ignorePasswordManagers: this.ignorePasswordManagers,\n });\n}\n","import { LiveAnnouncer } from '@angular/cdk/a11y';\nimport { inject, Signal, signal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, createPrimitive, dataBinding, listener } from 'ng-primitives/state';\nimport { injectPasswordState } from '../password/password-state';\n\n/**\n * The state interface for the PasswordToggle pattern.\n */\nexport interface NgpPasswordToggleState {\n /**\n * Toggle the visibility of the password.\n */\n toggle(): void;\n}\n\n/**\n * The props interface for the PasswordToggle pattern.\n */\nexport interface NgpPasswordToggleProps {\n /**\n * The accessible label shown when the password is hidden.\n */\n readonly showLabel: Signal<string>;\n /**\n * The accessible label shown when the password is visible.\n */\n readonly hideLabel: Signal<string>;\n /**\n * The message announced when the password becomes visible.\n */\n readonly shownAnnouncement: Signal<string>;\n /**\n * The message announced when the password becomes hidden.\n */\n readonly hiddenAnnouncement: Signal<string>;\n}\n\nexport const [\n NgpPasswordToggleStateToken,\n ngpPasswordToggle,\n injectPasswordToggleState,\n providePasswordToggleState,\n] = createPrimitive(\n 'NgpPasswordToggle',\n ({\n showLabel,\n hideLabel,\n shownAnnouncement,\n hiddenAnnouncement,\n }: NgpPasswordToggleProps): NgpPasswordToggleState => {\n const element = injectElementRef<HTMLButtonElement>();\n const password = injectPasswordState();\n const announcer = inject(LiveAnnouncer);\n\n // Pointer activation returns focus to the input; keyboard keeps it on the button.\n const pointerActivated = signal(false);\n\n attrBinding(element, 'type', 'button');\n attrBinding(element, 'aria-controls', () => password().inputId());\n attrBinding(element, 'aria-label', () => {\n // Defer to the button's own text if it has any.\n if ((element.nativeElement.textContent ?? '').trim().length > 0) {\n return null;\n }\n return password().visible() ? hideLabel() : showLabel();\n });\n dataBinding(element, 'data-visible', () => password().visible());\n\n listener(element, 'pointerdown', () => pointerActivated.set(true));\n listener(element, 'click', () => toggle());\n\n function toggle(): void {\n const state = password();\n // Announce the intended state: in controlled mode state.visible() may not\n // reflect the new value until the parent propagates it back.\n const willBeVisible = !state.visible();\n state.toggle();\n\n announcer.announce(willBeVisible ? shownAnnouncement() : hiddenAnnouncement());\n\n if (pointerActivated()) {\n state.focusInput();\n }\n pointerActivated.set(false);\n }\n\n return { toggle } satisfies NgpPasswordToggleState;\n },\n);\n","import { Directive, input } from '@angular/core';\nimport { injectPasswordConfig } from '../config/password-config';\nimport { ngpPasswordToggle, providePasswordToggleState } from './password-toggle-state';\n\n/**\n * Apply the `ngpPasswordToggle` directive to a `button` element to toggle the visibility of the\n * password within an `ngpPassword` container.\n */\n@Directive({\n selector: 'button[ngpPasswordToggle]',\n exportAs: 'ngpPasswordToggle',\n providers: [providePasswordToggleState()],\n})\nexport class NgpPasswordToggle {\n /**\n * Access the global password configuration.\n */\n private readonly config = injectPasswordConfig();\n\n /**\n * The accessible label shown when the password is hidden.\n */\n readonly showLabel = input(this.config.showLabel, { alias: 'ngpPasswordToggleShowLabel' });\n\n /**\n * The accessible label shown when the password is visible.\n */\n readonly hideLabel = input(this.config.hideLabel, { alias: 'ngpPasswordToggleHideLabel' });\n\n /**\n * The message announced when the password becomes visible.\n */\n readonly shownAnnouncement = input(this.config.shownAnnouncement, {\n alias: 'ngpPasswordToggleShownAnnouncement',\n });\n\n /**\n * The message announced when the password becomes hidden.\n */\n readonly hiddenAnnouncement = input(this.config.hiddenAnnouncement, {\n alias: 'ngpPasswordToggleHiddenAnnouncement',\n });\n\n /**\n * The state for the password toggle primitive.\n */\n protected readonly state = ngpPasswordToggle({\n showLabel: this.showLabel,\n hideLabel: this.hideLabel,\n shownAnnouncement: this.shownAnnouncement,\n hiddenAnnouncement: this.hiddenAnnouncement,\n });\n\n /**\n * Toggle the visibility of the password.\n */\n toggle(): void {\n this.state.toggle();\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, computed, Directive, input, output, Signal } from '@angular/core';\nimport { SetterOptions } from 'ng-primitives/state';\nimport { ngpPassword, providePasswordState } from './password-state';\n\n/**\n * The `NgpPassword` directive is a container for a password field and its visibility toggle.\n */\n@Directive({\n selector: '[ngpPassword]',\n exportAs: 'ngpPassword',\n providers: [providePasswordState()],\n})\nexport class NgpPassword {\n /**\n * Whether the password is visible.\n */\n readonly visible = input<boolean | undefined, BooleanInput>(undefined, {\n alias: 'ngpPasswordVisible',\n transform: booleanAttribute,\n });\n\n /**\n * The default visibility state for uncontrolled usage.\n * @default false\n */\n readonly defaultVisible = input<boolean, BooleanInput>(false, {\n alias: 'ngpPasswordDefaultVisible',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the visibility state changes.\n */\n readonly visibleChange = output<boolean>({\n alias: 'ngpPasswordVisibleChange',\n });\n\n /**\n * The state for the password primitive.\n */\n protected readonly state = ngpPassword({\n visible: this.visible,\n defaultVisible: this.defaultVisible,\n onVisibleChange: value => this.visibleChange.emit(value),\n });\n\n /**\n * Whether the password is currently visible.\n */\n readonly isVisible: Signal<boolean> = computed(() => this.state.visible());\n\n /**\n * Toggle the visibility of the password.\n */\n toggle(): void {\n this.state.toggle();\n }\n\n /**\n * Set the visibility of the password.\n */\n setVisible(value: boolean, options?: SetterOptions): void {\n this.state.setVisible(value, options);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAkCO,MAAM,qBAAqB,GAAsB;AACtD,IAAA,SAAS,EAAE,eAAe;AAC1B,IAAA,SAAS,EAAE,eAAe;AAC1B,IAAA,iBAAiB,EAAE,wBAAwB;AAC3C,IAAA,kBAAkB,EAAE,yBAAyB;AAC7C,IAAA,sBAAsB,EAAE,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|
"description": "Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. ",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.126.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"angular",
|
|
8
8
|
"primitives",
|
|
@@ -183,6 +183,10 @@
|
|
|
183
183
|
"types": "./types/ng-primitives-pagination.d.ts",
|
|
184
184
|
"default": "./fesm2022/ng-primitives-pagination.mjs"
|
|
185
185
|
},
|
|
186
|
+
"./password": {
|
|
187
|
+
"types": "./types/ng-primitives-password.d.ts",
|
|
188
|
+
"default": "./fesm2022/ng-primitives-password.mjs"
|
|
189
|
+
},
|
|
186
190
|
"./popover": {
|
|
187
191
|
"types": "./types/ng-primitives-popover.d.ts",
|
|
188
192
|
"default": "./fesm2022/ng-primitives-popover.mjs"
|
package/schematics/ng-generate/templates/password/password.__fileSuffix@dasherize__.ts.template
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Component, input, signal } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
4
|
+
import { lucideEye, lucideEyeOff } from '@ng-icons/lucide';
|
|
5
|
+
import { NgpButton } from 'ng-primitives/button';
|
|
6
|
+
import {
|
|
7
|
+
injectPasswordState,
|
|
8
|
+
NgpPassword,
|
|
9
|
+
NgpPasswordInput,
|
|
10
|
+
NgpPasswordToggle,
|
|
11
|
+
} from 'ng-primitives/password';
|
|
12
|
+
import { ChangeFn, provideValueAccessor, TouchedFn } from 'ng-primitives/utils';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: '<%= prefix %>-password',
|
|
16
|
+
hostDirectives: [NgpPassword],
|
|
17
|
+
imports: [NgIcon, NgpPasswordInput, NgpPasswordToggle, NgpButton],
|
|
18
|
+
providers: [provideValueAccessor(Password<%= componentSuffix %>), provideIcons({ lucideEye, lucideEyeOff })],
|
|
19
|
+
template: `
|
|
20
|
+
<input
|
|
21
|
+
[value]="value()"
|
|
22
|
+
[placeholder]="placeholder()"
|
|
23
|
+
(input)="onValueChange($event)"
|
|
24
|
+
ngpPasswordInput
|
|
25
|
+
type="password"
|
|
26
|
+
autocomplete="current-password"
|
|
27
|
+
/>
|
|
28
|
+
<button ngpButton ngpPasswordToggle>
|
|
29
|
+
<ng-icon [name]="state().visible() ? 'lucideEyeOff' : 'lucideEye'" />
|
|
30
|
+
</button>
|
|
31
|
+
`,
|
|
32
|
+
styles: `
|
|
33
|
+
/* These styles rely on CSS variables that can be imported from ng-primitives/example-theme/index.css in your global styles */
|
|
34
|
+
|
|
35
|
+
:host {
|
|
36
|
+
display: block;
|
|
37
|
+
position: relative;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[ngpPasswordInput] {
|
|
41
|
+
height: 2.125rem;
|
|
42
|
+
width: 100%;
|
|
43
|
+
border-radius: 0.5rem;
|
|
44
|
+
padding: 0 40px 0 12px;
|
|
45
|
+
border: none;
|
|
46
|
+
background: var(--ngp-background);
|
|
47
|
+
color: var(--ngp-text-primary);
|
|
48
|
+
font-size: 0.875rem;
|
|
49
|
+
letter-spacing: -0.006em;
|
|
50
|
+
box-shadow: var(--ngp-input-shadow);
|
|
51
|
+
outline: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
[ngpPasswordInput][data-focus] {
|
|
55
|
+
outline: 2px solid var(--ngp-focus-ring);
|
|
56
|
+
outline-offset: 2px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[ngpPasswordInput]::placeholder {
|
|
60
|
+
color: var(--ngp-text-placeholder);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[ngpPasswordToggle] {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0;
|
|
66
|
+
right: 0;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
height: 2.125rem;
|
|
71
|
+
width: 2.125rem;
|
|
72
|
+
border: none;
|
|
73
|
+
border-radius: 0.5rem;
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
color: var(--ngp-text-tertiary);
|
|
76
|
+
font-size: 1.125rem;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
outline: none;
|
|
79
|
+
transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[ngpPasswordToggle][data-hover] {
|
|
83
|
+
color: var(--ngp-text-secondary);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[ngpPasswordToggle][data-visible] {
|
|
87
|
+
color: var(--ngp-primary);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[ngpPasswordToggle][data-focus-visible] {
|
|
91
|
+
outline: 2px solid var(--ngp-focus-ring);
|
|
92
|
+
outline-offset: -2px;
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
host: {
|
|
96
|
+
'(focusout)': 'onFocusOut($event)',
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
export class Password<%= componentSuffix %> implements ControlValueAccessor {
|
|
100
|
+
/** Access the password state to read the visibility. */
|
|
101
|
+
protected readonly state = injectPasswordState();
|
|
102
|
+
|
|
103
|
+
/** The placeholder text */
|
|
104
|
+
readonly placeholder = input<string>('');
|
|
105
|
+
|
|
106
|
+
/** The current value */
|
|
107
|
+
protected value = signal<string>('');
|
|
108
|
+
|
|
109
|
+
/** The function to call when the value changes */
|
|
110
|
+
private onChange?: ChangeFn<string>;
|
|
111
|
+
|
|
112
|
+
/** The function to call when the control is touched */
|
|
113
|
+
protected onTouched?: TouchedFn;
|
|
114
|
+
|
|
115
|
+
writeValue(value: string): void {
|
|
116
|
+
this.value.set(value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
registerOnChange(fn: ChangeFn<string>): void {
|
|
120
|
+
this.onChange = fn;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
registerOnTouched(fn: TouchedFn): void {
|
|
124
|
+
this.onTouched = fn;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
protected onValueChange(event: Event): void {
|
|
128
|
+
const input = event.target as HTMLInputElement;
|
|
129
|
+
this.value.set(input.value);
|
|
130
|
+
this.onChange?.(input.value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
protected onFocusOut(event: FocusEvent): void {
|
|
134
|
+
// only mark as touched when focus leaves the component, not when moving
|
|
135
|
+
// between the input and the toggle button
|
|
136
|
+
const host = event.currentTarget as HTMLElement;
|
|
137
|
+
if (!host.contains(event.relatedTarget as Node | null)) {
|
|
138
|
+
this.onTouched?.();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { InjectionToken, Provider, Signal, WritableSignal } from '@angular/core';
|
|
3
|
+
import * as ng_primitives_input from 'ng-primitives/input';
|
|
4
|
+
import { NgpInputState } from 'ng-primitives/input';
|
|
5
|
+
import { BooleanInput } from '@angular/cdk/coercion';
|
|
6
|
+
import * as ng_primitives_state from 'ng-primitives/state';
|
|
7
|
+
import { SetterOptions } from 'ng-primitives/state';
|
|
8
|
+
import * as ng_primitives_password from 'ng-primitives/password';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
|
|
11
|
+
interface NgpPasswordConfig {
|
|
12
|
+
/**
|
|
13
|
+
* The accessible label for the toggle button when the password is hidden.
|
|
14
|
+
* @default 'Show password'
|
|
15
|
+
*/
|
|
16
|
+
showLabel: string;
|
|
17
|
+
/**
|
|
18
|
+
* The accessible label for the toggle button when the password is visible.
|
|
19
|
+
* @default 'Hide password'
|
|
20
|
+
*/
|
|
21
|
+
hideLabel: string;
|
|
22
|
+
/**
|
|
23
|
+
* The message announced to screen readers when the password becomes visible.
|
|
24
|
+
* @default 'Your password is shown'
|
|
25
|
+
*/
|
|
26
|
+
shownAnnouncement: string;
|
|
27
|
+
/**
|
|
28
|
+
* The message announced to screen readers when the password becomes hidden.
|
|
29
|
+
* @default 'Your password is hidden'
|
|
30
|
+
*/
|
|
31
|
+
hiddenAnnouncement: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to opt the input out of password manager injection by default.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
ignorePasswordManagers: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare const defaultPasswordConfig: NgpPasswordConfig;
|
|
39
|
+
declare const NgpPasswordConfigToken: InjectionToken<NgpPasswordConfig>;
|
|
40
|
+
/**
|
|
41
|
+
* Provide the default Password configuration
|
|
42
|
+
* @param config The Password configuration
|
|
43
|
+
* @returns The provider
|
|
44
|
+
*/
|
|
45
|
+
declare function providePasswordConfig(config: Partial<NgpPasswordConfig>): Provider[];
|
|
46
|
+
/**
|
|
47
|
+
* Inject the Password configuration
|
|
48
|
+
* @returns The global Password configuration
|
|
49
|
+
*/
|
|
50
|
+
declare function injectPasswordConfig(): NgpPasswordConfig;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Apply the `ngpPasswordInput` directive to an `input` element within an `ngpPassword` container.
|
|
54
|
+
* It is a complete input (form control, interactions, autofill) with password visibility toggling
|
|
55
|
+
* layered on top, so it does not need to be combined with `ngpInput`.
|
|
56
|
+
*/
|
|
57
|
+
declare class NgpPasswordInput {
|
|
58
|
+
/**
|
|
59
|
+
* Access the global password configuration.
|
|
60
|
+
*/
|
|
61
|
+
private readonly config;
|
|
62
|
+
/**
|
|
63
|
+
* The id of the input.
|
|
64
|
+
*/
|
|
65
|
+
readonly id: _angular_core.InputSignal<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the input is disabled.
|
|
68
|
+
*/
|
|
69
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
70
|
+
/**
|
|
71
|
+
* Whether to opt the input out of password manager injection
|
|
72
|
+
* (1Password, LastPass, Bitwarden, etc.).
|
|
73
|
+
*/
|
|
74
|
+
readonly ignorePasswordManagers: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
75
|
+
/**
|
|
76
|
+
* The state for the password input primitive.
|
|
77
|
+
*/
|
|
78
|
+
protected readonly state: ng_primitives_input.NgpInputState;
|
|
79
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpPasswordInput, never>;
|
|
80
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpPasswordInput, "input[ngpPasswordInput]", ["ngpPasswordInput"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "ignorePasswordManagers": { "alias": "ngpPasswordInputIgnorePasswordManagers"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The state for the PasswordInput pattern, extending the Input state.
|
|
85
|
+
*/
|
|
86
|
+
type NgpPasswordInputState = NgpInputState;
|
|
87
|
+
/**
|
|
88
|
+
* The props interface for the PasswordInput pattern.
|
|
89
|
+
*/
|
|
90
|
+
interface NgpPasswordInputProps {
|
|
91
|
+
/**
|
|
92
|
+
* The id of the input.
|
|
93
|
+
*/
|
|
94
|
+
readonly id?: Signal<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Whether the input is disabled.
|
|
97
|
+
*/
|
|
98
|
+
readonly disabled?: Signal<boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to opt the input out of password manager injection.
|
|
101
|
+
*/
|
|
102
|
+
readonly ignorePasswordManagers?: Signal<boolean>;
|
|
103
|
+
}
|
|
104
|
+
declare const ngpPasswordInput: ({ id, disabled, ignorePasswordManagers, }: NgpPasswordInputProps) => NgpPasswordInputState;
|
|
105
|
+
declare const injectPasswordInputState: {
|
|
106
|
+
(): Signal<NgpInputState>;
|
|
107
|
+
(options: ng_primitives_state.StateInjectionOptions): Signal<NgpInputState | null>;
|
|
108
|
+
(options?: ng_primitives_state.StateInjectionOptions): Signal<NgpInputState> | Signal<NgpInputState | null>;
|
|
109
|
+
};
|
|
110
|
+
declare const providePasswordInputState: (opts?: {
|
|
111
|
+
inherit?: boolean;
|
|
112
|
+
}) => _angular_core.FactoryProvider;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Apply the `ngpPasswordToggle` directive to a `button` element to toggle the visibility of the
|
|
116
|
+
* password within an `ngpPassword` container.
|
|
117
|
+
*/
|
|
118
|
+
declare class NgpPasswordToggle {
|
|
119
|
+
/**
|
|
120
|
+
* Access the global password configuration.
|
|
121
|
+
*/
|
|
122
|
+
private readonly config;
|
|
123
|
+
/**
|
|
124
|
+
* The accessible label shown when the password is hidden.
|
|
125
|
+
*/
|
|
126
|
+
readonly showLabel: _angular_core.InputSignal<string>;
|
|
127
|
+
/**
|
|
128
|
+
* The accessible label shown when the password is visible.
|
|
129
|
+
*/
|
|
130
|
+
readonly hideLabel: _angular_core.InputSignal<string>;
|
|
131
|
+
/**
|
|
132
|
+
* The message announced when the password becomes visible.
|
|
133
|
+
*/
|
|
134
|
+
readonly shownAnnouncement: _angular_core.InputSignal<string>;
|
|
135
|
+
/**
|
|
136
|
+
* The message announced when the password becomes hidden.
|
|
137
|
+
*/
|
|
138
|
+
readonly hiddenAnnouncement: _angular_core.InputSignal<string>;
|
|
139
|
+
/**
|
|
140
|
+
* The state for the password toggle primitive.
|
|
141
|
+
*/
|
|
142
|
+
protected readonly state: ng_primitives_password.NgpPasswordToggleState;
|
|
143
|
+
/**
|
|
144
|
+
* Toggle the visibility of the password.
|
|
145
|
+
*/
|
|
146
|
+
toggle(): void;
|
|
147
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpPasswordToggle, never>;
|
|
148
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpPasswordToggle, "button[ngpPasswordToggle]", ["ngpPasswordToggle"], { "showLabel": { "alias": "ngpPasswordToggleShowLabel"; "required": false; "isSignal": true; }; "hideLabel": { "alias": "ngpPasswordToggleHideLabel"; "required": false; "isSignal": true; }; "shownAnnouncement": { "alias": "ngpPasswordToggleShownAnnouncement"; "required": false; "isSignal": true; }; "hiddenAnnouncement": { "alias": "ngpPasswordToggleHiddenAnnouncement"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The state interface for the PasswordToggle pattern.
|
|
153
|
+
*/
|
|
154
|
+
interface NgpPasswordToggleState {
|
|
155
|
+
/**
|
|
156
|
+
* Toggle the visibility of the password.
|
|
157
|
+
*/
|
|
158
|
+
toggle(): void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The props interface for the PasswordToggle pattern.
|
|
162
|
+
*/
|
|
163
|
+
interface NgpPasswordToggleProps {
|
|
164
|
+
/**
|
|
165
|
+
* The accessible label shown when the password is hidden.
|
|
166
|
+
*/
|
|
167
|
+
readonly showLabel: Signal<string>;
|
|
168
|
+
/**
|
|
169
|
+
* The accessible label shown when the password is visible.
|
|
170
|
+
*/
|
|
171
|
+
readonly hideLabel: Signal<string>;
|
|
172
|
+
/**
|
|
173
|
+
* The message announced when the password becomes visible.
|
|
174
|
+
*/
|
|
175
|
+
readonly shownAnnouncement: Signal<string>;
|
|
176
|
+
/**
|
|
177
|
+
* The message announced when the password becomes hidden.
|
|
178
|
+
*/
|
|
179
|
+
readonly hiddenAnnouncement: Signal<string>;
|
|
180
|
+
}
|
|
181
|
+
declare const ngpPasswordToggle: ({ showLabel, hideLabel, shownAnnouncement, hiddenAnnouncement, }: NgpPasswordToggleProps) => NgpPasswordToggleState;
|
|
182
|
+
declare const injectPasswordToggleState: {
|
|
183
|
+
(): Signal<NgpPasswordToggleState>;
|
|
184
|
+
(options: ng_primitives_state.StateInjectionOptions): Signal<NgpPasswordToggleState | null>;
|
|
185
|
+
(options?: ng_primitives_state.StateInjectionOptions): Signal<NgpPasswordToggleState> | Signal<NgpPasswordToggleState | null>;
|
|
186
|
+
};
|
|
187
|
+
declare const providePasswordToggleState: (opts?: {
|
|
188
|
+
inherit?: boolean;
|
|
189
|
+
}) => _angular_core.FactoryProvider;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The `NgpPassword` directive is a container for a password field and its visibility toggle.
|
|
193
|
+
*/
|
|
194
|
+
declare class NgpPassword {
|
|
195
|
+
/**
|
|
196
|
+
* Whether the password is visible.
|
|
197
|
+
*/
|
|
198
|
+
readonly visible: _angular_core.InputSignalWithTransform<boolean | undefined, BooleanInput>;
|
|
199
|
+
/**
|
|
200
|
+
* The default visibility state for uncontrolled usage.
|
|
201
|
+
* @default false
|
|
202
|
+
*/
|
|
203
|
+
readonly defaultVisible: _angular_core.InputSignalWithTransform<boolean, BooleanInput>;
|
|
204
|
+
/**
|
|
205
|
+
* Emits when the visibility state changes.
|
|
206
|
+
*/
|
|
207
|
+
readonly visibleChange: _angular_core.OutputEmitterRef<boolean>;
|
|
208
|
+
/**
|
|
209
|
+
* The state for the password primitive.
|
|
210
|
+
*/
|
|
211
|
+
protected readonly state: ng_primitives_password.NgpPasswordState;
|
|
212
|
+
/**
|
|
213
|
+
* Whether the password is currently visible.
|
|
214
|
+
*/
|
|
215
|
+
readonly isVisible: Signal<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* Toggle the visibility of the password.
|
|
218
|
+
*/
|
|
219
|
+
toggle(): void;
|
|
220
|
+
/**
|
|
221
|
+
* Set the visibility of the password.
|
|
222
|
+
*/
|
|
223
|
+
setVisible(value: boolean, options?: SetterOptions): void;
|
|
224
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpPassword, never>;
|
|
225
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpPassword, "[ngpPassword]", ["ngpPassword"], { "visible": { "alias": "ngpPasswordVisible"; "required": false; "isSignal": true; }; "defaultVisible": { "alias": "ngpPasswordDefaultVisible"; "required": false; "isSignal": true; }; }, { "visibleChange": "ngpPasswordVisibleChange"; }, never, never, true, never>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Public state surface for the Password primitive.
|
|
230
|
+
*/
|
|
231
|
+
interface NgpPasswordState {
|
|
232
|
+
/**
|
|
233
|
+
* Whether the password is currently visible.
|
|
234
|
+
*/
|
|
235
|
+
readonly visible: WritableSignal<boolean>;
|
|
236
|
+
/**
|
|
237
|
+
* Emits when the visibility state changes.
|
|
238
|
+
*/
|
|
239
|
+
readonly visibleChange: Observable<boolean>;
|
|
240
|
+
/**
|
|
241
|
+
* The id of the registered input, used to wire up `aria-controls`.
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
readonly inputId: Signal<string | null>;
|
|
245
|
+
/**
|
|
246
|
+
* Toggle the visibility state.
|
|
247
|
+
*/
|
|
248
|
+
toggle(): void;
|
|
249
|
+
/**
|
|
250
|
+
* Set the visibility state.
|
|
251
|
+
*/
|
|
252
|
+
setVisible(value: boolean, options?: SetterOptions): void;
|
|
253
|
+
/**
|
|
254
|
+
* Set the default visibility state.
|
|
255
|
+
*/
|
|
256
|
+
setDefaultVisible(value: boolean): void;
|
|
257
|
+
/**
|
|
258
|
+
* Register the password input with the container.
|
|
259
|
+
* @internal
|
|
260
|
+
*/
|
|
261
|
+
registerInput(input: HTMLInputElement, id: Signal<string>): void;
|
|
262
|
+
/**
|
|
263
|
+
* Focus the registered input.
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
focusInput(): void;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Inputs for configuring the Password primitive.
|
|
270
|
+
*/
|
|
271
|
+
interface NgpPasswordProps {
|
|
272
|
+
/**
|
|
273
|
+
* Whether the password is visible.
|
|
274
|
+
*/
|
|
275
|
+
readonly visible: Signal<boolean | undefined>;
|
|
276
|
+
/**
|
|
277
|
+
* The default visibility state for uncontrolled usage.
|
|
278
|
+
*/
|
|
279
|
+
readonly defaultVisible?: Signal<boolean>;
|
|
280
|
+
/**
|
|
281
|
+
* Callback fired when the visibility state changes.
|
|
282
|
+
*/
|
|
283
|
+
readonly onVisibleChange?: (visible: boolean) => void;
|
|
284
|
+
}
|
|
285
|
+
declare const ngpPassword: ({ visible: _visible, defaultVisible: _defaultVisible, onVisibleChange, }: NgpPasswordProps) => NgpPasswordState;
|
|
286
|
+
declare const injectPasswordState: {
|
|
287
|
+
(): Signal<NgpPasswordState>;
|
|
288
|
+
(options: ng_primitives_state.StateInjectionOptions): Signal<NgpPasswordState | null>;
|
|
289
|
+
(options?: ng_primitives_state.StateInjectionOptions): Signal<NgpPasswordState> | Signal<NgpPasswordState | null>;
|
|
290
|
+
};
|
|
291
|
+
declare const providePasswordState: (opts?: {
|
|
292
|
+
inherit?: boolean;
|
|
293
|
+
}) => _angular_core.FactoryProvider;
|
|
294
|
+
|
|
295
|
+
export { NgpPassword, NgpPasswordConfigToken, NgpPasswordInput, NgpPasswordToggle, defaultPasswordConfig, injectPasswordConfig, injectPasswordInputState, injectPasswordState, injectPasswordToggleState, ngpPassword, ngpPasswordInput, ngpPasswordToggle, providePasswordConfig, providePasswordInputState, providePasswordState, providePasswordToggleState };
|
|
296
|
+
export type { NgpPasswordConfig, NgpPasswordInputProps, NgpPasswordInputState, NgpPasswordProps, NgpPasswordState, NgpPasswordToggleProps, NgpPasswordToggleState };
|