kmaterialize 2.3.3-1.0.32 → 2.3.3-1.0.34
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/components/gantt/_gantt.scss +1 -1
- package/components/gantt/gantt.ts +8 -2
- package/components/gantt/ganttSpec.js +21 -0
- package/components/password-input/password-input.ts +112 -62
- package/components/password-input/passwordSpec.js +110 -0
- package/dist/css/materialize.colors.min.css +1 -1
- package/dist/css/materialize.css +2 -2
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.cjs.js +89 -29
- package/dist/js/materialize.d.ts +21 -5
- package/dist/js/materialize.js +89 -29
- package/dist/js/materialize.min.js +3 -3
- package/dist/js/materialize.mjs +89 -29
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
.gantt-task-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.4; }
|
|
69
69
|
.gantt-task-detail { color: var(--md-sys-color-on-surface-variant); font-size: 12px; overflow-wrap: anywhere; }
|
|
70
|
-
.gantt-label.gantt-selectable-label { padding-left: calc(
|
|
70
|
+
.gantt-label.gantt-selectable-label { padding-left: calc(30px + var(--checkbox-size)); }
|
|
71
71
|
input.gantt-select { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
|
|
72
72
|
.gantt-row.is-selected .gantt-label { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
|
|
73
73
|
.gantt-row.is-selected .gantt-bar { box-shadow: 0 0 0 2px var(--md-sys-color-primary); }
|
|
@@ -390,8 +390,14 @@ export class Gantt extends Component<GanttOptions> {
|
|
|
390
390
|
const selector = event.target instanceof Element ? event.target.closest<HTMLElement>('[data-gantt-select]') : null;
|
|
391
391
|
if (selector) {
|
|
392
392
|
const id = selector.dataset.ganttSelect;
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
if (event.shiftKey && this._selectionAnchor) {
|
|
394
|
+
this._selectForInteraction(id, event);
|
|
395
|
+
} else {
|
|
396
|
+
this.setSelectedTaskIds(this._selected.has(id) ? this.getSelectedTaskIds().filter(item => item !== id) : [...this.getSelectedTaskIds(), id]);
|
|
397
|
+
this._selectionAnchor = id;
|
|
398
|
+
}
|
|
399
|
+
// A repeated range may not re-render; undo the native toggle in that case.
|
|
400
|
+
if (selector instanceof HTMLInputElement) selector.checked = this._selected.has(id);
|
|
395
401
|
return;
|
|
396
402
|
}
|
|
397
403
|
const target = event.target instanceof Element ? event.target.closest<HTMLElement>('[data-gantt-task]') : null;
|
|
@@ -484,6 +484,27 @@ describe('Gantt multi-task selection', function () {
|
|
|
484
484
|
expect(host.querySelectorAll('.gantt-row.is-selected').length).toBe(0);
|
|
485
485
|
});
|
|
486
486
|
|
|
487
|
+
it('selects inclusive checkbox ranges in either direction and retains the anchor', function () {
|
|
488
|
+
const checkbox = id => host.querySelector(`[data-gantt-select="${id}"]`);
|
|
489
|
+
const shiftClick = id => checkbox(id).dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, shiftKey: true }));
|
|
490
|
+
const selection = jasmine.createSpy('selection');
|
|
491
|
+
chart.options.onSelectionChange = selection;
|
|
492
|
+
checkbox('m').click();
|
|
493
|
+
shiftClick('a');
|
|
494
|
+
expect(chart.getSelectedTaskIds()).toEqual(['a', 'b', 'c', 'm']);
|
|
495
|
+
expect(host.querySelectorAll('.gantt-select:checked').length).toBe(4);
|
|
496
|
+
shiftClick('a');
|
|
497
|
+
expect(checkbox('a').checked).toBeTrue();
|
|
498
|
+
expect(selection).toHaveBeenCalledTimes(2);
|
|
499
|
+
shiftClick('c');
|
|
500
|
+
expect(chart.getSelectedTaskIds()).toEqual(['c', 'm']);
|
|
501
|
+
chart.setSelectedTaskIds([]);
|
|
502
|
+
checkbox('a').click();
|
|
503
|
+
shiftClick('m');
|
|
504
|
+
expect(chart.getSelectedTaskIds()).toEqual(['a', 'b', 'c', 'm']);
|
|
505
|
+
expect(chart.getTasks()).toEqual(original);
|
|
506
|
+
});
|
|
507
|
+
|
|
487
508
|
it('cancels all previewed dates together and retains selection through zoom and views', function () {
|
|
488
509
|
chart.setSelectedTaskIds(['a', 'b']);
|
|
489
510
|
pointer('pointerdown', 400, button('b')); pointer('pointermove', 496); key('Escape');
|
|
@@ -1,72 +1,122 @@
|
|
|
1
1
|
import { Component, BaseOptions, InitElements, MElement } from '../../src/component';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface PasswordInputOptions extends BaseOptions {
|
|
4
|
+
/** Accessible name when the password is hidden. */
|
|
5
|
+
showLabel: string;
|
|
6
|
+
/** Accessible name when the password is visible. */
|
|
7
|
+
hideLabel: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type PasswordInputElement = HTMLInputElement & { M_PasswordInput?: PasswordInput };
|
|
5
11
|
|
|
6
|
-
const _defaults: PasswordInputOptions = {
|
|
12
|
+
const _defaults: PasswordInputOptions = {
|
|
13
|
+
showLabel: 'Show password',
|
|
14
|
+
hideLabel: 'Hide password'
|
|
15
|
+
};
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// enhancements in this batch this one needs no peer-loader/dynamic import.
|
|
17
|
+
/**
|
|
18
|
+
* Show or hide a password with an accessible suffix button.
|
|
19
|
+
* Existing data-password-toggle-icon wrappers remain supported.
|
|
20
|
+
*/
|
|
13
21
|
export class PasswordInput extends Component<PasswordInputOptions> {
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
declare el: PasswordInputElement;
|
|
23
|
+
private _suffixEl: HTMLElement | null;
|
|
24
|
+
private _stateObserver: MutationObserver;
|
|
25
|
+
private _originalAttributes: Map<string, string | null> = new Map();
|
|
26
|
+
|
|
27
|
+
constructor(el: HTMLInputElement, options: Partial<PasswordInputOptions>) {
|
|
28
|
+
super(el, options, PasswordInput);
|
|
29
|
+
this.el.M_PasswordInput = this;
|
|
30
|
+
this.options = { ...PasswordInput.defaults, ...options };
|
|
31
|
+
this._suffixEl = this.el.parentElement?.querySelector<HTMLElement>('[data-password-toggle-icon]') ?? null;
|
|
32
|
+
|
|
33
|
+
if (this._suffixEl) {
|
|
34
|
+
for (const name of ['type', 'role', 'tabindex', 'aria-label', 'aria-pressed', 'aria-controls', 'aria-disabled', 'disabled'])
|
|
35
|
+
this._originalAttributes.set(name, this._suffixEl.getAttribute(name));
|
|
36
|
+
|
|
37
|
+
if (this._suffixEl instanceof HTMLButtonElement) {
|
|
38
|
+
this._suffixEl.type = 'button';
|
|
39
|
+
} else {
|
|
40
|
+
this._suffixEl.setAttribute('role', 'button');
|
|
41
|
+
this._suffixEl.tabIndex = 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.el.id) this._suffixEl.setAttribute('aria-controls', this.el.id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Read the actual input type, including an initially visible password.
|
|
48
|
+
this._syncState();
|
|
49
|
+
this._suffixEl?.addEventListener('click', this._handleToggleClick);
|
|
50
|
+
this._suffixEl?.addEventListener('keydown', this._handleToggleKeydown);
|
|
51
|
+
this._stateObserver = new MutationObserver(() => this._syncState());
|
|
52
|
+
this._stateObserver.observe(this.el, { attributes: true, attributeFilter: ['type', 'disabled'] });
|
|
53
|
+
for (let parent = this.el.parentElement; parent; parent = parent.parentElement) {
|
|
54
|
+
if (parent instanceof HTMLFieldSetElement)
|
|
55
|
+
this._stateObserver.observe(parent, { attributes: true, attributeFilter: ['disabled'] });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
16
58
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
59
|
+
static get defaults(): PasswordInputOptions {
|
|
60
|
+
return _defaults;
|
|
61
|
+
}
|
|
20
62
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
63
|
+
static init(el: HTMLInputElement, options?: Partial<PasswordInputOptions>): PasswordInput;
|
|
64
|
+
static init(els: InitElements<HTMLInputElement | MElement>, options?: Partial<PasswordInputOptions>): PasswordInput[];
|
|
65
|
+
static init(
|
|
66
|
+
els: HTMLInputElement | InitElements<HTMLInputElement | MElement>,
|
|
67
|
+
options: Partial<PasswordInputOptions> = {}
|
|
68
|
+
): PasswordInput | PasswordInput[] {
|
|
69
|
+
return super.init(els, options, PasswordInput);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static getInstance(el: HTMLInputElement): PasswordInput {
|
|
73
|
+
return (el as PasswordInputElement).M_PasswordInput!;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Remove listeners and restore the supplied button attributes. */
|
|
77
|
+
destroy() {
|
|
78
|
+
this._stateObserver.disconnect();
|
|
79
|
+
this._suffixEl?.removeEventListener('click', this._handleToggleClick);
|
|
80
|
+
this._suffixEl?.removeEventListener('keydown', this._handleToggleKeydown);
|
|
81
|
+
for (const [name, value] of this._originalAttributes) {
|
|
82
|
+
if (value === null) this._suffixEl?.removeAttribute(name);
|
|
83
|
+
else this._suffixEl?.setAttribute(name, value);
|
|
84
|
+
}
|
|
85
|
+
this.el.M_PasswordInput = undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Toggle without submitting the form or changing its value or selection. */
|
|
89
|
+
toggle() {
|
|
90
|
+
if (this.el.matches(':disabled')) return;
|
|
91
|
+
const start = this.el.selectionStart;
|
|
92
|
+
const end = this.el.selectionEnd;
|
|
93
|
+
const direction = this.el.selectionDirection;
|
|
94
|
+
this.el.type = this.el.type === 'password' ? 'text' : 'password';
|
|
95
|
+
if (start !== null && end !== null) this.el.setSelectionRange(start, end, direction ?? undefined);
|
|
96
|
+
this._syncState();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private _syncState() {
|
|
100
|
+
const visible = this.el.type === 'text';
|
|
101
|
+
const disabled = this.el.matches(':disabled');
|
|
102
|
+
this.el.dataset.passwordVisible = visible ? '1' : '0';
|
|
103
|
+
this._suffixEl?.setAttribute('aria-label', visible ? this.options.hideLabel : this.options.showLabel);
|
|
104
|
+
this._suffixEl?.setAttribute('aria-pressed', String(visible));
|
|
105
|
+
this._suffixEl?.setAttribute('aria-disabled', String(disabled));
|
|
106
|
+
if (this._suffixEl instanceof HTMLButtonElement) this._suffixEl.disabled = disabled;
|
|
107
|
+
const icon = this._suffixEl?.querySelector('i');
|
|
108
|
+
if (icon) icon.textContent = visible ? 'visibility_off' : 'visibility';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private _handleToggleClick = (event: MouseEvent) => {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
this.toggle();
|
|
24
114
|
};
|
|
25
115
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _defaults;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static init(el: HTMLInputElement, options?: Partial<PasswordInputOptions>): PasswordInput;
|
|
36
|
-
static init(
|
|
37
|
-
els: InitElements<HTMLInputElement | MElement>,
|
|
38
|
-
options?: Partial<PasswordInputOptions>
|
|
39
|
-
): PasswordInput[];
|
|
40
|
-
static init(
|
|
41
|
-
els: HTMLInputElement | InitElements<HTMLInputElement | MElement>,
|
|
42
|
-
options: Partial<PasswordInputOptions> = {}
|
|
43
|
-
): PasswordInput | PasswordInput[] {
|
|
44
|
-
return super.init(els, options, PasswordInput);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static getInstance(el: HTMLInputElement): PasswordInput {
|
|
48
|
-
return (el as any).M_PasswordInput;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
destroy() {
|
|
52
|
-
this._removeEventHandlers();
|
|
53
|
-
(this.el as any).M_PasswordInput = undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_setupEventHandlers() {
|
|
57
|
-
this._suffixEl?.addEventListener('click', this._handleToggleClick);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_removeEventHandlers() {
|
|
61
|
-
this._suffixEl?.removeEventListener('click', this._handleToggleClick);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
_handleToggleClick = () => {
|
|
65
|
-
const visible = this.el.dataset.passwordVisible === '1';
|
|
66
|
-
this.el.type = visible ? 'password' : 'text';
|
|
67
|
-
this.el.dataset.passwordVisible = visible ? '0' : '1';
|
|
68
|
-
|
|
69
|
-
const iconEl = this._suffixEl?.querySelector('i');
|
|
70
|
-
if (iconEl) iconEl.textContent = visible ? 'visibility' : 'visibility_off';
|
|
71
|
-
};
|
|
116
|
+
private _handleToggleKeydown = (event: KeyboardEvent) => {
|
|
117
|
+
// Native buttons already dispatch clicks for Enter and Space.
|
|
118
|
+
if (this._suffixEl instanceof HTMLButtonElement || !['Enter', ' '].includes(event.key)) return;
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
this.toggle();
|
|
121
|
+
};
|
|
72
122
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
describe('PasswordInput', function() {
|
|
2
|
+
let fixture;
|
|
3
|
+
let input;
|
|
4
|
+
let button;
|
|
5
|
+
let instance;
|
|
6
|
+
|
|
7
|
+
beforeEach(function() {
|
|
8
|
+
fixture = document.createElement('form');
|
|
9
|
+
fixture.innerHTML = '<div class="input-field"><input id="password-test" type="password" value="example-secret" data-password-toggle><button class="suffix btn-flat p-0 transparent" data-password-toggle-icon><i class="material-icons">visibility</i></button></div>';
|
|
10
|
+
document.body.appendChild(fixture);
|
|
11
|
+
input = fixture.querySelector('input');
|
|
12
|
+
button = fixture.querySelector('button');
|
|
13
|
+
instance = M.PasswordInput.init(input);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(function() {
|
|
17
|
+
M.PasswordInput.getInstance(input)?.destroy();
|
|
18
|
+
fixture.remove();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('toggles the supplied suffix button without submitting or changing the value', function() {
|
|
22
|
+
const submit = jasmine.createSpy('submit');
|
|
23
|
+
fixture.addEventListener('submit', submit);
|
|
24
|
+
input.setSelectionRange(2, 5);
|
|
25
|
+
expect(button.type).toBe('button');
|
|
26
|
+
expect(button.getAttribute('aria-controls')).toBe(input.id);
|
|
27
|
+
expect(button.getAttribute('aria-label')).toBe('Show password');
|
|
28
|
+
button.click();
|
|
29
|
+
expect(input.type).toBe('text');
|
|
30
|
+
expect(input.value).toBe('example-secret');
|
|
31
|
+
expect(input.selectionStart).toBe(2);
|
|
32
|
+
expect(input.selectionEnd).toBe(5);
|
|
33
|
+
expect(button.getAttribute('aria-label')).toBe('Hide password');
|
|
34
|
+
expect(button.getAttribute('aria-pressed')).toBe('true');
|
|
35
|
+
expect(button.querySelector('i').textContent).toBe('visibility_off');
|
|
36
|
+
button.click();
|
|
37
|
+
expect(input.type).toBe('password');
|
|
38
|
+
expect(input.dataset.passwordVisible).toBe('0');
|
|
39
|
+
expect(button.getAttribute('aria-pressed')).toBe('false');
|
|
40
|
+
expect(submit).not.toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not toggle a disabled input and synchronizes the button', async function() {
|
|
44
|
+
input.disabled = true;
|
|
45
|
+
instance.toggle();
|
|
46
|
+
await Promise.resolve();
|
|
47
|
+
expect(input.type).toBe('password');
|
|
48
|
+
expect(button.disabled).toBeTrue();
|
|
49
|
+
input.disabled = false;
|
|
50
|
+
await Promise.resolve();
|
|
51
|
+
expect(button.disabled).toBeFalse();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('follows a disabled fieldset', async function() {
|
|
55
|
+
instance.destroy();
|
|
56
|
+
const fieldset = document.createElement('fieldset');
|
|
57
|
+
fixture.appendChild(fieldset);
|
|
58
|
+
fieldset.appendChild(input.parentElement);
|
|
59
|
+
instance = M.PasswordInput.init(input);
|
|
60
|
+
fieldset.disabled = true;
|
|
61
|
+
await Promise.resolve();
|
|
62
|
+
expect(button.disabled).toBeTrue();
|
|
63
|
+
instance.toggle();
|
|
64
|
+
expect(input.type).toBe('password');
|
|
65
|
+
fieldset.disabled = false;
|
|
66
|
+
await Promise.resolve();
|
|
67
|
+
expect(button.disabled).toBeFalse();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('uses the actual type for initially visible passwords and custom labels', function() {
|
|
71
|
+
instance.destroy();
|
|
72
|
+
input.type = 'text';
|
|
73
|
+
instance = M.PasswordInput.init(input, { showLabel: 'Afficher', hideLabel: 'Masquer' });
|
|
74
|
+
expect(button.getAttribute('aria-label')).toBe('Masquer');
|
|
75
|
+
button.click();
|
|
76
|
+
expect(input.type).toBe('password');
|
|
77
|
+
expect(button.getAttribute('aria-label')).toBe('Afficher');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('keeps readonly passwords revealable', function() {
|
|
81
|
+
input.readOnly = true;
|
|
82
|
+
button.click();
|
|
83
|
+
expect(input.type).toBe('text');
|
|
84
|
+
expect(input.readOnly).toBeTrue();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('reinitializes without duplicate listeners and destroys cleanly', function() {
|
|
88
|
+
instance = M.PasswordInput.init(input);
|
|
89
|
+
button.click();
|
|
90
|
+
expect(input.type).toBe('text');
|
|
91
|
+
instance.destroy();
|
|
92
|
+
button.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
93
|
+
expect(input.type).toBe('text');
|
|
94
|
+
expect(M.PasswordInput.getInstance(input)).toBeUndefined();
|
|
95
|
+
expect(button.hasAttribute('aria-pressed')).toBeFalse();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('supports keyboard activation on legacy suffix wrappers', function() {
|
|
99
|
+
instance.destroy();
|
|
100
|
+
button.outerHTML = '<div data-password-toggle-icon><i>visibility</i></div>';
|
|
101
|
+
button = fixture.querySelector('[data-password-toggle-icon]');
|
|
102
|
+
instance = M.PasswordInput.init(input);
|
|
103
|
+
expect(button.getAttribute('role')).toBe('button');
|
|
104
|
+
expect(button.tabIndex).toBe(0);
|
|
105
|
+
button.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }));
|
|
106
|
+
expect(input.type).toBe('text');
|
|
107
|
+
button.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true, cancelable: true }));
|
|
108
|
+
expect(input.type).toBe('password');
|
|
109
|
+
});
|
|
110
|
+
});
|
package/dist/css/materialize.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Materialize v2.3.3-1.0.
|
|
2
|
+
* Materialize v2.3.3-1.0.34 (https://materializeweb.com)
|
|
3
3
|
* Copyright 2014-2026 Materialize
|
|
4
4
|
* MIT License (https://raw.githubusercontent.com/materializecss/materialize/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -14404,7 +14404,7 @@ button.btn-floating {
|
|
|
14404
14404
|
overflow-wrap: anywhere;
|
|
14405
14405
|
}
|
|
14406
14406
|
.gantt .gantt-label.gantt-selectable-label {
|
|
14407
|
-
padding-left: calc(
|
|
14407
|
+
padding-left: calc(30px + var(--checkbox-size));
|
|
14408
14408
|
}
|
|
14409
14409
|
.gantt input.gantt-select {
|
|
14410
14410
|
position: absolute;
|