@substrate-system/password-input 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/dist/index.cjs +71 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -2
- package/dist/index.js.map +2 -2
- package/dist/index.min.js +12 -12
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Password Input
|
|
2
|
-
](https://github.com/substrate-system/password-input/actions/workflows/nodejs.yml)
|
|
3
3
|
[](README.md)
|
|
4
4
|
[](README.md)
|
|
5
5
|
[](https://packagephobia.com/result?p=@bicycle-codes/keys)
|
|
@@ -26,10 +26,16 @@ Accessible by default — `aria-*` attributes, the `id` attribute, and a
|
|
|
26
26
|
- [API](#api)
|
|
27
27
|
* [ESM](#esm)
|
|
28
28
|
* [Common JS](#common-js)
|
|
29
|
+
* [Attributes](#attributes)
|
|
30
|
+
+ [Supported `aria-*` attributes](#supported-aria--attributes)
|
|
31
|
+
+ [Usage Notes](#usage-notes)
|
|
32
|
+
+ [Example](#example)
|
|
29
33
|
- [Use](#use)
|
|
30
34
|
* [JS](#js)
|
|
31
35
|
* [HTML](#html)
|
|
32
36
|
* [pre-built](#pre-built)
|
|
37
|
+
+ [copy](#copy)
|
|
38
|
+
+ [HTML](#html-1)
|
|
33
39
|
- [CSS](#css)
|
|
34
40
|
* [Import CSS](#import-css)
|
|
35
41
|
- [Notes](#notes)
|
|
@@ -58,6 +64,63 @@ import { PasswordInput } from '@substrate-system/password-input'
|
|
|
58
64
|
```js
|
|
59
65
|
require('@substrate-system/password-input')
|
|
60
66
|
```
|
|
67
|
+
|
|
68
|
+
### Attributes
|
|
69
|
+
|
|
70
|
+
You can pass attributes on `<password-input>`, and the component maps them to
|
|
71
|
+
the inner `<input>` as described below. Do not pass the `type` attribute.
|
|
72
|
+
That is controlled by the component.
|
|
73
|
+
|
|
74
|
+
| Attribute | Should pass? | Behavior |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `label` | Optional, recommended | Renders visible label text above the input. |
|
|
77
|
+
| `visible` | Optional | If present, initial state is visible text (`type="text"`). If absent, initial state is hidden (`type="password"`). |
|
|
78
|
+
| `id` | Recommended when used with external labels/help text | Moved to the inner `<input id="...">` and removed from `<password-input>`. |
|
|
79
|
+
| `aria-*` | Recommended for accessibility | Any supported ARIA attribute passed on `<password-input>` is moved to the inner `<input>` and removed from `<password-input>`. |
|
|
80
|
+
| Standard input attributes (`name`, `placeholder`, `value`, `autocomplete`, `required`, `disabled`, `readonly`, `minlength`, `maxlength`, `pattern`, etc.) | Optional as needed | Forwarded to the inner `<input>`. |
|
|
81
|
+
|
|
82
|
+
#### Supported `aria-*` attributes
|
|
83
|
+
|
|
84
|
+
`aria-activedescendant`, `aria-atomic`, `aria-autocomplete`,
|
|
85
|
+
`aria-braillelabel`, `aria-brailleroledescription`, `aria-busy`,
|
|
86
|
+
`aria-checked`, `aria-colcount`, `aria-colindex`, `aria-colindextext`,
|
|
87
|
+
`aria-colspan`, `aria-controls`, `aria-current`, `aria-describedby`,
|
|
88
|
+
`aria-description`, `aria-details`, `aria-disabled`, `aria-dropeffect`,
|
|
89
|
+
`aria-errormessage`, `aria-expanded`, `aria-flowto`, `aria-grabbed`,
|
|
90
|
+
`aria-haspopup`, `aria-hidden`, `aria-invalid`, `aria-keyshortcuts`,
|
|
91
|
+
`aria-label`, `aria-labelledby`, `aria-level`, `aria-live`, `aria-modal`,
|
|
92
|
+
`aria-multiline`, `aria-multiselectable`, `aria-orientation`, `aria-owns`,
|
|
93
|
+
`aria-placeholder`, `aria-posinset`, `aria-pressed`, `aria-readonly`,
|
|
94
|
+
`aria-relevant`, `aria-required`, `aria-roledescription`, `aria-rowcount`,
|
|
95
|
+
`aria-rowindex`, `aria-rowindextext`, `aria-rowspan`, `aria-selected`,
|
|
96
|
+
`aria-setsize`, `aria-sort`, `aria-valuemax`, `aria-valuemin`,
|
|
97
|
+
`aria-valuenow`, `aria-valuetext`
|
|
98
|
+
|
|
99
|
+
#### Usage Notes
|
|
100
|
+
|
|
101
|
+
- Do **not** pass `type`. The component controls `type` internally
|
|
102
|
+
(`password` or `text`) based on the visibility toggle.
|
|
103
|
+
- If an ARIA attribute changes later (`setAttribute('aria-label', '...')` on
|
|
104
|
+
`<password-input>`), the inner `<input>` is updated through
|
|
105
|
+
`attributeChangedCallback`.
|
|
106
|
+
|
|
107
|
+
#### Example
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<password-input
|
|
111
|
+
id="account-password"
|
|
112
|
+
label="New Password"
|
|
113
|
+
name="password"
|
|
114
|
+
placeholder="At least 12 characters"
|
|
115
|
+
autocomplete="new-password"
|
|
116
|
+
required
|
|
117
|
+
minlength="12"
|
|
118
|
+
aria-describedby="password-help">
|
|
119
|
+
</password-input>
|
|
120
|
+
<p id="password-help">Use a strong, unique password.</p>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
61
124
|
## Use
|
|
62
125
|
|
|
63
126
|
This calls the global function `customElements.define`. Just import, then use
|
|
@@ -134,4 +197,3 @@ Implementation notes.
|
|
|
134
197
|
|
|
135
198
|
Without this guard, the second callback would treat the host removal as a
|
|
136
199
|
real “delete” request and clear the input attribute you just transferred.
|
|
137
|
-
|
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,37 @@ class PasswordInput extends HTMLElement {
|
|
|
32
32
|
__name(this, "PasswordInput");
|
|
33
33
|
}
|
|
34
34
|
static TAG = "password-input";
|
|
35
|
+
static INPUT_ATTRIBUTES = [
|
|
36
|
+
"accept",
|
|
37
|
+
"alt",
|
|
38
|
+
"autocomplete",
|
|
39
|
+
"autocapitalize",
|
|
40
|
+
"autocorrect",
|
|
41
|
+
"autofocus",
|
|
42
|
+
"capture",
|
|
43
|
+
"dirname",
|
|
44
|
+
"disabled",
|
|
45
|
+
"enterkeyhint",
|
|
46
|
+
"form",
|
|
47
|
+
"inputmode",
|
|
48
|
+
"list",
|
|
49
|
+
"max",
|
|
50
|
+
"maxlength",
|
|
51
|
+
"min",
|
|
52
|
+
"minlength",
|
|
53
|
+
"multiple",
|
|
54
|
+
"name",
|
|
55
|
+
"pattern",
|
|
56
|
+
"placeholder",
|
|
57
|
+
"readonly",
|
|
58
|
+
"required",
|
|
59
|
+
"size",
|
|
60
|
+
"spellcheck",
|
|
61
|
+
"step",
|
|
62
|
+
"tabindex",
|
|
63
|
+
"title",
|
|
64
|
+
"value"
|
|
65
|
+
];
|
|
35
66
|
static ARIA_ATTRIBUTES = [
|
|
36
67
|
"aria-activedescendant",
|
|
37
68
|
"aria-atomic",
|
|
@@ -87,10 +118,11 @@ class PasswordInput extends HTMLElement {
|
|
|
87
118
|
"aria-valuenow",
|
|
88
119
|
"aria-valuetext"
|
|
89
120
|
];
|
|
90
|
-
static observedAttributes = ["visible", "label"].concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
121
|
+
static observedAttributes = ["visible", "label", "id"].concat(PasswordInput.INPUT_ATTRIBUTES).concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
91
122
|
inputId = null;
|
|
92
123
|
inputAriaAttributes = {};
|
|
93
124
|
ignoredAriaCallbackNames = /* @__PURE__ */ new Set();
|
|
125
|
+
ignoredIdCallback = false;
|
|
94
126
|
// empty string = is visible
|
|
95
127
|
// null = not visible
|
|
96
128
|
handleChange_visible(_, _newValue) {
|
|
@@ -117,6 +149,32 @@ class PasswordInput extends HTMLElement {
|
|
|
117
149
|
this.removeAttribute(name);
|
|
118
150
|
}
|
|
119
151
|
}
|
|
152
|
+
handleChange_id(_oldValue, newValue) {
|
|
153
|
+
if (this.ignoredIdCallback) {
|
|
154
|
+
this.ignoredIdCallback = false;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (newValue === null) {
|
|
158
|
+
this.inputId = null;
|
|
159
|
+
this.querySelector("input")?.removeAttribute("id");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.inputId = newValue;
|
|
163
|
+
this.querySelector("input")?.setAttribute("id", newValue);
|
|
164
|
+
if (this.hasAttribute("id")) {
|
|
165
|
+
this.ignoredIdCallback = true;
|
|
166
|
+
this.removeAttribute("id");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
handleChange_inputAttribute(name, newValue) {
|
|
170
|
+
const input = this.querySelector("input");
|
|
171
|
+
if (!input) return;
|
|
172
|
+
if (newValue === null) {
|
|
173
|
+
input.removeAttribute(name);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
input.setAttribute(name, newValue);
|
|
177
|
+
}
|
|
120
178
|
/**
|
|
121
179
|
* Listen for change in visiblity.
|
|
122
180
|
*
|
|
@@ -125,10 +183,18 @@ class PasswordInput extends HTMLElement {
|
|
|
125
183
|
* @param {string} newValue The new attribute value
|
|
126
184
|
*/
|
|
127
185
|
async attributeChangedCallback(name, oldValue, newValue) {
|
|
186
|
+
if (name === "id") {
|
|
187
|
+
this.handleChange_id(oldValue, newValue);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
128
190
|
if (name.startsWith("aria-")) {
|
|
129
191
|
this.handleChange_aria(name, oldValue, newValue);
|
|
130
192
|
return;
|
|
131
193
|
}
|
|
194
|
+
if (PasswordInput.INPUT_ATTRIBUTES.includes(name)) {
|
|
195
|
+
this.handleChange_inputAttribute(name, newValue);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
132
198
|
if (this[`handleChange_${name}`]) {
|
|
133
199
|
this[`handleChange_${name}`](oldValue, newValue);
|
|
134
200
|
}
|
|
@@ -228,7 +294,10 @@ class PasswordInput extends HTMLElement {
|
|
|
228
294
|
</span>
|
|
229
295
|
</div>
|
|
230
296
|
`;
|
|
231
|
-
this.
|
|
297
|
+
if (this.hasAttribute("id")) {
|
|
298
|
+
this.ignoredIdCallback = true;
|
|
299
|
+
this.removeAttribute("id");
|
|
300
|
+
}
|
|
232
301
|
for (const attr of hostAriaAttributes) {
|
|
233
302
|
this.ignoredAriaCallbackNames.add(attr.name);
|
|
234
303
|
this.removeAttribute(attr.name);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label'])\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create object from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n this.removeAttribute('id')\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AACvB,uBAAsC;AACtC,yBAAwC;AAAA,IAIxC,iBAAAA,QAAY;AAAA,IACZ,mBAAAC,QAAc;AASP,MAAM,sBAAsB,YAAY;AAAA,EAhB/C,OAgB+C;AAAA;AAAA;AAAA,EAC3C,OAAO,MAAM;AAAA,EACb,OAAO,kBAAkB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EAEA,OAAO,qBAAsB,CAAC,WAAW,OAAO,
|
|
4
|
+
"sourcesContent": ["import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static INPUT_ATTRIBUTES = [\n 'accept',\n 'alt',\n 'autocomplete',\n 'autocapitalize',\n 'autocorrect',\n 'autofocus',\n 'capture',\n 'dirname',\n 'disabled',\n 'enterkeyhint',\n 'form',\n 'inputmode',\n 'list',\n 'max',\n 'maxlength',\n 'min',\n 'minlength',\n 'multiple',\n 'name',\n 'pattern',\n 'placeholder',\n 'readonly',\n 'required',\n 'size',\n 'spellcheck',\n 'step',\n 'tabindex',\n 'title',\n 'value'\n ]\n\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label', 'id'])\n .concat(PasswordInput.INPUT_ATTRIBUTES)\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n ignoredIdCallback = false\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n handleChange_id (_oldValue:string|null, newValue:string|null) {\n if (this.ignoredIdCallback) {\n this.ignoredIdCallback = false\n return\n }\n\n if (newValue === null) {\n this.inputId = null\n this.querySelector('input')?.removeAttribute('id')\n return\n }\n\n this.inputId = newValue\n this.querySelector('input')?.setAttribute('id', newValue)\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n }\n\n handleChange_inputAttribute (name:string, newValue:string|null) {\n const input = this.querySelector('input')\n if (!input) return\n\n if (newValue === null) {\n input.removeAttribute(name)\n return\n }\n\n input.setAttribute(name, newValue)\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name === 'id') {\n this.handleChange_id(oldValue, newValue)\n return\n }\n\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (PasswordInput.INPUT_ATTRIBUTES.includes(name)) {\n this.handleChange_inputAttribute(name, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create string from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AACvB,uBAAsC;AACtC,yBAAwC;AAAA,IAIxC,iBAAAA,QAAY;AAAA,IACZ,mBAAAC,QAAc;AASP,MAAM,sBAAsB,YAAY;AAAA,EAhB/C,OAgB+C;AAAA;AAAA;AAAA,EAC3C,OAAO,MAAM;AAAA,EACb,OAAO,mBAAmB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;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C;AAAA;AAAA;AAAA;AAAA;AAMzC,QAAI,KAAK,aAAa,IAAI,GAAG;AACzB,WAAK,oBAAoB;AACzB,WAAK,gBAAgB,IAAI;AAAA,IAC7B;AACA,eAAW,QAAQ,oBAAoB;AACnC,WAAK,yBAAyB,IAAI,KAAK,IAAI;AAC3C,WAAK,gBAAgB,KAAK,IAAI;AAAA,IAClC;AAAA,EACJ;AACJ;AAAA,IAEA,oBAAO,cAAc,KAAK,aAAa;",
|
|
6
6
|
"names": ["slashDefine", "regularDefine"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,18 @@ declare global {
|
|
|
5
5
|
}
|
|
6
6
|
export declare class PasswordInput extends HTMLElement {
|
|
7
7
|
static TAG: string;
|
|
8
|
+
static INPUT_ATTRIBUTES: string[];
|
|
8
9
|
static ARIA_ATTRIBUTES: string[];
|
|
9
10
|
static observedAttributes: string[];
|
|
10
11
|
inputId: string | null;
|
|
11
12
|
inputAriaAttributes: Record<string, string>;
|
|
12
13
|
ignoredAriaCallbackNames: Set<string>;
|
|
14
|
+
ignoredIdCallback: boolean;
|
|
13
15
|
handleChange_visible(_: any, _newValue: any): void;
|
|
14
16
|
handleChange_label(_oldValue: any, _newValue: any): void;
|
|
15
17
|
handleChange_aria(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
18
|
+
handleChange_id(_oldValue: string | null, newValue: string | null): void;
|
|
19
|
+
handleChange_inputAttribute(name: string, newValue: string | null): void;
|
|
16
20
|
/**
|
|
17
21
|
* Listen for change in visiblity.
|
|
18
22
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,gBAAgB,EAAC,aAAa,CAAA;KACjC;CACJ;AAED,qBAAa,aAAc,SAAQ,WAAW;IAC1C,MAAM,C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,IAAI,KAAK,CAAE,KAAK,EAAC,MAAM,GAAC,IAAI,EAO3B;IAED,IAAI,KAAK,IAAI,MAAM,GAAC,IAAI,CAEvB;IAED,gBAAgB;IAMhB;;OAEG;IACH,QAAQ;IAOR,MAAM;CAgFT"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,37 @@ class PasswordInput extends HTMLElement {
|
|
|
10
10
|
__name(this, "PasswordInput");
|
|
11
11
|
}
|
|
12
12
|
static TAG = "password-input";
|
|
13
|
+
static INPUT_ATTRIBUTES = [
|
|
14
|
+
"accept",
|
|
15
|
+
"alt",
|
|
16
|
+
"autocomplete",
|
|
17
|
+
"autocapitalize",
|
|
18
|
+
"autocorrect",
|
|
19
|
+
"autofocus",
|
|
20
|
+
"capture",
|
|
21
|
+
"dirname",
|
|
22
|
+
"disabled",
|
|
23
|
+
"enterkeyhint",
|
|
24
|
+
"form",
|
|
25
|
+
"inputmode",
|
|
26
|
+
"list",
|
|
27
|
+
"max",
|
|
28
|
+
"maxlength",
|
|
29
|
+
"min",
|
|
30
|
+
"minlength",
|
|
31
|
+
"multiple",
|
|
32
|
+
"name",
|
|
33
|
+
"pattern",
|
|
34
|
+
"placeholder",
|
|
35
|
+
"readonly",
|
|
36
|
+
"required",
|
|
37
|
+
"size",
|
|
38
|
+
"spellcheck",
|
|
39
|
+
"step",
|
|
40
|
+
"tabindex",
|
|
41
|
+
"title",
|
|
42
|
+
"value"
|
|
43
|
+
];
|
|
13
44
|
static ARIA_ATTRIBUTES = [
|
|
14
45
|
"aria-activedescendant",
|
|
15
46
|
"aria-atomic",
|
|
@@ -65,10 +96,11 @@ class PasswordInput extends HTMLElement {
|
|
|
65
96
|
"aria-valuenow",
|
|
66
97
|
"aria-valuetext"
|
|
67
98
|
];
|
|
68
|
-
static observedAttributes = ["visible", "label"].concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
99
|
+
static observedAttributes = ["visible", "label", "id"].concat(PasswordInput.INPUT_ATTRIBUTES).concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
69
100
|
inputId = null;
|
|
70
101
|
inputAriaAttributes = {};
|
|
71
102
|
ignoredAriaCallbackNames = /* @__PURE__ */ new Set();
|
|
103
|
+
ignoredIdCallback = false;
|
|
72
104
|
// empty string = is visible
|
|
73
105
|
// null = not visible
|
|
74
106
|
handleChange_visible(_, _newValue) {
|
|
@@ -95,6 +127,32 @@ class PasswordInput extends HTMLElement {
|
|
|
95
127
|
this.removeAttribute(name);
|
|
96
128
|
}
|
|
97
129
|
}
|
|
130
|
+
handleChange_id(_oldValue, newValue) {
|
|
131
|
+
if (this.ignoredIdCallback) {
|
|
132
|
+
this.ignoredIdCallback = false;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (newValue === null) {
|
|
136
|
+
this.inputId = null;
|
|
137
|
+
this.querySelector("input")?.removeAttribute("id");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.inputId = newValue;
|
|
141
|
+
this.querySelector("input")?.setAttribute("id", newValue);
|
|
142
|
+
if (this.hasAttribute("id")) {
|
|
143
|
+
this.ignoredIdCallback = true;
|
|
144
|
+
this.removeAttribute("id");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
handleChange_inputAttribute(name, newValue) {
|
|
148
|
+
const input = this.querySelector("input");
|
|
149
|
+
if (!input) return;
|
|
150
|
+
if (newValue === null) {
|
|
151
|
+
input.removeAttribute(name);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
input.setAttribute(name, newValue);
|
|
155
|
+
}
|
|
98
156
|
/**
|
|
99
157
|
* Listen for change in visiblity.
|
|
100
158
|
*
|
|
@@ -103,10 +161,18 @@ class PasswordInput extends HTMLElement {
|
|
|
103
161
|
* @param {string} newValue The new attribute value
|
|
104
162
|
*/
|
|
105
163
|
async attributeChangedCallback(name, oldValue, newValue) {
|
|
164
|
+
if (name === "id") {
|
|
165
|
+
this.handleChange_id(oldValue, newValue);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
106
168
|
if (name.startsWith("aria-")) {
|
|
107
169
|
this.handleChange_aria(name, oldValue, newValue);
|
|
108
170
|
return;
|
|
109
171
|
}
|
|
172
|
+
if (PasswordInput.INPUT_ATTRIBUTES.includes(name)) {
|
|
173
|
+
this.handleChange_inputAttribute(name, newValue);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
110
176
|
if (this[`handleChange_${name}`]) {
|
|
111
177
|
this[`handleChange_${name}`](oldValue, newValue);
|
|
112
178
|
}
|
|
@@ -206,7 +272,10 @@ class PasswordInput extends HTMLElement {
|
|
|
206
272
|
</span>
|
|
207
273
|
</div>
|
|
208
274
|
`;
|
|
209
|
-
this.
|
|
275
|
+
if (this.hasAttribute("id")) {
|
|
276
|
+
this.ignoredIdCallback = true;
|
|
277
|
+
this.removeAttribute("id");
|
|
278
|
+
}
|
|
210
279
|
for (const attr of hostAriaAttributes) {
|
|
211
280
|
this.ignoredAriaCallbackNames.add(attr.name);
|
|
212
281
|
this.removeAttribute(attr.name);
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label'])\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create object from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n this.removeAttribute('id')\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
-
"mappings": ";;AAAA,SAAS,cAAc;AACvB,SAAS,UAAU,mBAAmB;AACtC,SAAS,UAAU,qBAAqB;AAIxC,YAAY;AACZ,cAAc;AASP,MAAM,sBAAsB,YAAY;AAAA,EAhB/C,OAgB+C;AAAA;AAAA;AAAA,EAC3C,OAAO,MAAM;AAAA,EACb,OAAO,kBAAkB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EAEA,OAAO,qBAAsB,CAAC,WAAW,OAAO,
|
|
4
|
+
"sourcesContent": ["import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static INPUT_ATTRIBUTES = [\n 'accept',\n 'alt',\n 'autocomplete',\n 'autocapitalize',\n 'autocorrect',\n 'autofocus',\n 'capture',\n 'dirname',\n 'disabled',\n 'enterkeyhint',\n 'form',\n 'inputmode',\n 'list',\n 'max',\n 'maxlength',\n 'min',\n 'minlength',\n 'multiple',\n 'name',\n 'pattern',\n 'placeholder',\n 'readonly',\n 'required',\n 'size',\n 'spellcheck',\n 'step',\n 'tabindex',\n 'title',\n 'value'\n ]\n\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label', 'id'])\n .concat(PasswordInput.INPUT_ATTRIBUTES)\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n ignoredIdCallback = false\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n handleChange_id (_oldValue:string|null, newValue:string|null) {\n if (this.ignoredIdCallback) {\n this.ignoredIdCallback = false\n return\n }\n\n if (newValue === null) {\n this.inputId = null\n this.querySelector('input')?.removeAttribute('id')\n return\n }\n\n this.inputId = newValue\n this.querySelector('input')?.setAttribute('id', newValue)\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n }\n\n handleChange_inputAttribute (name:string, newValue:string|null) {\n const input = this.querySelector('input')\n if (!input) return\n\n if (newValue === null) {\n input.removeAttribute(name)\n return\n }\n\n input.setAttribute(name, newValue)\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name === 'id') {\n this.handleChange_id(oldValue, newValue)\n return\n }\n\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (PasswordInput.INPUT_ATTRIBUTES.includes(name)) {\n this.handleChange_inputAttribute(name, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create string from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,cAAc;AACvB,SAAS,UAAU,mBAAmB;AACtC,SAAS,UAAU,qBAAqB;AAIxC,YAAY;AACZ,cAAc;AAS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AK,YAAY,QAAQ;AAAA,4BACL,OAAO;AAAA,8CACW,KAAK;AAAA;AAAA;AAAA,0BAGzB,WAAW;AAAA,0BACX,cAAc;AAAA,0BACd,KAAK;AAAA,+BACA,KAAK,QAAQ,CAAC;AAAA;AAAA,0BAEnB,KAAK,iBAAiB,CAAC;AAAA;AAAA;AAAA;AAAA,YAIrC;AAAA,0BACc,OAAO;AAAA;AAAA;AAAA,0BAGP,WAAW;AAAA,0BACX,cAAc;AAAA,0BACd,KAAK;AAAA,+BACA,KAAK,QAAQ,CAAC;AAAA;AAAA,0BAEnB,KAAK,iBAAiB,CAAC;AAAA;AAAA;AAAA;AAAA;AAMzC,QAAI,KAAK,aAAa,IAAI,GAAG;AACzB,WAAK,oBAAoB;AACzB,WAAK,gBAAgB,IAAI;AAAA,IAC7B;AACA,eAAW,QAAQ,oBAAoB;AACnC,WAAK,yBAAyB,IAAI,KAAK,IAAI;AAC3C,WAAK,gBAAgB,KAAK,IAAI;AAAA,IAClC;AAAA,EACJ;AACJ;AAEA,OAAO,cAAc,KAAK,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var q=Object.defineProperty;var i=(t,e)=>q(t,"name",{value:e,configurable:!0});var R=Object.defineProperty,M=i((t,e)=>R(t,"name",{value:e,configurable:!0}),"__name");function T(t){return Object.keys(t).reduce((e,n)=>{let r=t[n];return r?typeof r=="boolean"?r?(e+` ${n}`).trim():e:Array.isArray(r)?e+` ${n}="${r.join(" ")}"`:(e+` ${n}="${r}"`).trim():e},"")}i(T,"toAttributes");M(T,"toAttributes");var O=Object.defineProperty,b=i((t,e)=>O(t,"name",{value:e,configurable:!0}),"__name");function $(t){return document.createElement(t).constructor!==window.HTMLElement}i($,"isRegistered");b($,"isRegistered");function h(t,e){window&&"customElements"in window&&($(t)||window.customElements.define(t,e))}i(h,"define");b(h,"define");var se=document.querySelector.bind(document),oe=document.querySelectorAll.bind(document);function B(t,e){return t.matches||(t=t.parentElement),t.matches(e)?t:t.closest(e)}i(B,"match");b(B,"match");var z=Object.defineProperty,D=i((t,e)=>z(t,"name",{value:e,configurable:!0}),"__name");function x(t){return Object.keys(t).reduce((e,n)=>{let r=t[n];return r?typeof r=="boolean"?r?(e+` ${n}`).trim():e:Array.isArray(r)?e+` ${n}="${r.join(" ")}"`:(e+` ${n}="${r}"`).trim():e},"")}i(x,"toAttributes");D(x,"toAttributes");var N=Object.defineProperty,S=i((t,e)=>N(t,"name",{value:e,configurable:!0}),"__name");function I(t){return document.createElement(t).constructor!==window.HTMLElement}i(I,"isRegistered");S(I,"isRegistered");function o(t,e){window&&"customElements"in window&&(I(t)||window.customElements.define(t,e))}i(o,"define");S(o,"define");var he=document.querySelector.bind(document),pe=document.querySelectorAll.bind(document);var F=Object.defineProperty,U=i((t,e)=>F(t,"name",{value:e,configurable:!0}),"__name"),G=/[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/,W=/[A-ZÀ-Ý\u00C0-\u00D6\u00D9-\u00DD][a-zà-ÿ]/g,V=/[A-ZÀ-Ý\u00C0-\u00D6\u00D9-\u00DD]+/g;function s(t){return t=t.replace(W,function(e){return" "+(e[0].toLowerCase()||e[0])+e[1]}),t=t.replace(V,function(e){return" "+e.toLowerCase()}),t.trim().split(G).join("-").replace(/^-/,"").replace(/-\s*$/,"")}i(s,"kebabCase");U(s,"kebabCase");var Z=Object.defineProperty,J=i((t,e)=>Z(t,"name",{value:e,configurable:!0}),"__name");function l(t,e){return function(n){let r=t(n);return typeof window>"u"?`<${e} class="icon">
|
|
2
2
|
${r}
|
|
3
|
-
</${e}>`:r}}i(l,"createRenderer");J(l,"createRenderer");var K=Object.defineProperty,P=i((t,e)=>K(t,"name",{value:e,configurable:!0}),"__name"),
|
|
3
|
+
</${e}>`:r}}i(l,"createRenderer");J(l,"createRenderer");var K=Object.defineProperty,P=i((t,e)=>K(t,"name",{value:e,configurable:!0}),"__name"),p=l(k,"eye-slash");function k({title:t}={}){return t||(t="Hide"),`<svg
|
|
4
4
|
class="icon eye-slash"
|
|
5
5
|
xmlns="http://www.w3.org/2000/svg"
|
|
6
6
|
viewBox="0 0 640 512"
|
|
@@ -10,7 +10,7 @@ var R=Object.defineProperty;var i=(t,e)=>R(t,"name",{value:e,configurable:!0});v
|
|
|
10
10
|
<title id=${s(t)}>${t}</title>
|
|
11
11
|
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
|
12
12
|
<path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5L373 389.9z" />
|
|
13
|
-
</svg>`}i(
|
|
13
|
+
</svg>`}i(k,"createHtml");P(k,"createHtml");function Q({title:t}){return`<eye-slash>${p({title:t})}</eye-slash>`}i(Q,"outerHtml");P(Q,"outerHtml");var X=Object.defineProperty,H=i((t,e)=>X(t,"name",{value:e,configurable:!0}),"__name"),u=class extends HTMLElement{static{i(this,"EyeSlash")}static{H(this,"EyeSlash")}static TAG="eye-slash";_title;constructor(){super(),this._title=this.getAttribute("title")||"Hide"}attributeChangedCallback(e,n,r){this._title=r,this.render()}connectedCallback(){let e=this.getAttribute("title");e==null?this._title="Hide":this._title=e,this.render()}render(){let e=this._title;this.innerHTML=p({title:e})}};function f(){o(u.TAG,u)}i(f,"define");H(f,"define");var Y=Object.defineProperty,E=i((t,e)=>Y(t,"name",{value:e,configurable:!0}),"__name"),m=l(L,"eye-regular");function L({title:t}={}){t||(t="Show");let e=s(t);return`<svg
|
|
14
14
|
class="icon eye-regular"
|
|
15
15
|
xmlns="http://www.w3.org/2000/svg"
|
|
16
16
|
viewBox="0 0 576 512"
|
|
@@ -20,14 +20,14 @@ var R=Object.defineProperty;var i=(t,e)=>R(t,"name",{value:e,configurable:!0});v
|
|
|
20
20
|
<title id="${e}">${t}</title>
|
|
21
21
|
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
|
22
22
|
<path d="M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z" />
|
|
23
|
-
</svg>`}i(
|
|
24
|
-
<label class="${
|
|
25
|
-
<span class="label-content">${
|
|
23
|
+
</svg>`}i(L,"createHtml");E(L,"createHtml");function ee({title:t}){return`<eye-regular>${m({title:t})}</eye-regular>`}i(ee,"outerHtml");E(ee,"outerHtml");var te=Object.defineProperty,j=i((t,e)=>te(t,"name",{value:e,configurable:!0}),"__name"),c=class extends HTMLElement{static{i(this,"EyeRegular")}static{j(this,"EyeRegular")}static TAG="eye-regular";_title;constructor(){super(),this._title=this.getAttribute("title")||"See"}attributeChangedCallback(e,n,r){this._title=r,this.render()}connectedCallback(){let e=this.getAttribute("title");e==null?this._title="See":this._title=e,this.render()}render(){let e=this._title;e&&(this.innerHTML=m({title:e}))}};function g(){o(c.TAG,c)}i(g,"define");j(g,"define");f();g();var d=class t extends HTMLElement{static{i(this,"PasswordInput")}static TAG="password-input";static INPUT_ATTRIBUTES=["accept","alt","autocomplete","autocapitalize","autocorrect","autofocus","capture","dirname","disabled","enterkeyhint","form","inputmode","list","max","maxlength","min","minlength","multiple","name","pattern","placeholder","readonly","required","size","spellcheck","step","tabindex","title","value"];static ARIA_ATTRIBUTES=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-braillelabel","aria-brailleroledescription","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colindextext","aria-colspan","aria-controls","aria-current","aria-describedby","aria-description","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowindextext","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"];static observedAttributes=["visible","label","id"].concat(t.INPUT_ATTRIBUTES).concat(t.ARIA_ATTRIBUTES);inputId=null;inputAriaAttributes={};ignoredAriaCallbackNames=new Set;ignoredIdCallback=!1;handleChange_visible(e,n){this.reRender()}handleChange_label(e,n){this.render(),this._listen()}handleChange_aria(e,n,r){if(this.ignoredAriaCallbackNames.has(e)){this.ignoredAriaCallbackNames.delete(e);return}if(r===null){delete this.inputAriaAttributes[e],this.querySelector("input")?.removeAttribute(e);return}this.inputAriaAttributes[e]=r,this.querySelector("input")?.setAttribute(e,r),this.hasAttribute(e)&&(this.ignoredAriaCallbackNames.add(e),this.removeAttribute(e))}handleChange_id(e,n){if(this.ignoredIdCallback){this.ignoredIdCallback=!1;return}if(n===null){this.inputId=null,this.querySelector("input")?.removeAttribute("id");return}this.inputId=n,this.querySelector("input")?.setAttribute("id",n),this.hasAttribute("id")&&(this.ignoredIdCallback=!0,this.removeAttribute("id"))}handleChange_inputAttribute(e,n){let r=this.querySelector("input");if(r){if(n===null){r.removeAttribute(e);return}r.setAttribute(e,n)}}async attributeChangedCallback(e,n,r){if(e==="id"){this.handleChange_id(n,r);return}if(e.startsWith("aria-")){this.handleChange_aria(e,n,r);return}if(t.INPUT_ATTRIBUTES.includes(e)){this.handleChange_inputAttribute(e,r);return}this[`handleChange_${e}`]&&this[`handleChange_${e}`](n,r)}connectedCallback(){this.render(),this._listen()}_listen(){this.querySelector("button").addEventListener("click",n=>{n.preventDefault(),this.isVisible=!this.isVisible})}getType(){return this.isVisible?"text":"password"}set isVisible(e){e?this.setAttribute("visible",""):this.removeAttribute("visible")}get isVisible(){return this.hasAttribute("visible")}set label(e){if(e===null){this.removeAttribute("label");return}this.setAttribute("label",e)}get label(){return this.getAttribute("label")}getButtonContent(){return this.isVisible?'<eye-regular></eye-regular><span class="visually-hidden">Hide</span>':'<eye-slash></eye-slash><span class="visually-hidden">Show</span>'}reRender(){let e=this.querySelector(".pw-visibility");e.innerHTML=this.getButtonContent(),this.setAttribute("type",this.getType()),this.querySelector("input")?.setAttribute("type",this.getType())}render(){let e=this.getAttribute("name"),n=this.getAttribute("label"),r=this.getAttribute("id"),A=Array.from(this.attributes).filter(a=>a.name.startsWith("aria-"));r!==null&&(this.inputId=r);for(let a of A)this.inputAriaAttributes[a.name]=a.value;let _=Array.from(this.attributes).filter(a=>a.name!=="label"&&a.name!=="id"&&!a.name.startsWith("aria-")).map(a=>a.name+(a.value===""?"":`="${a.value}"`)).join(" "),y=(this.getAttribute("class")??"").split(" ").concat(["password","input",e||""]).filter(Boolean).join(" "),v=this.inputId?`id="${this.inputId}"`:"",C=Object.entries(this.inputAriaAttributes).map(([a,w])=>a+(w===""?"":`="${w}"`)).join(" ");this.innerHTML=n?`
|
|
24
|
+
<label class="${y}">
|
|
25
|
+
<span class="label-content">${n}</span>
|
|
26
26
|
<span class="input">
|
|
27
27
|
<input
|
|
28
28
|
${v}
|
|
29
|
-
${
|
|
30
|
-
${
|
|
29
|
+
${C}
|
|
30
|
+
${_}
|
|
31
31
|
type=${this.getType()} />
|
|
32
32
|
<button class="pw-visibility">
|
|
33
33
|
${this.getButtonContent()}
|
|
@@ -35,17 +35,17 @@ var R=Object.defineProperty;var i=(t,e)=>R(t,"name",{value:e,configurable:!0});v
|
|
|
35
35
|
</span>
|
|
36
36
|
</label>
|
|
37
37
|
`:`
|
|
38
|
-
<div class="${
|
|
38
|
+
<div class="${y}">
|
|
39
39
|
<span class="input">
|
|
40
40
|
<input
|
|
41
41
|
${v}
|
|
42
|
-
${
|
|
43
|
-
${
|
|
42
|
+
${C}
|
|
43
|
+
${_}
|
|
44
44
|
type=${this.getType()} />
|
|
45
45
|
<button class="pw-visibility">
|
|
46
46
|
${this.getButtonContent()}
|
|
47
47
|
</button>
|
|
48
48
|
</span>
|
|
49
49
|
</div>
|
|
50
|
-
`,this.removeAttribute("id");for(let
|
|
50
|
+
`,this.hasAttribute("id")&&(this.ignoredIdCallback=!0,this.removeAttribute("id"));for(let a of A)this.ignoredAriaCallbackNames.add(a.name),this.removeAttribute(a.name)}};h(d.TAG,d);export{d as PasswordInput};
|
|
51
51
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/@substrate-system/web-component/src/attributes.ts", "../node_modules/@substrate-system/web-component/src/util.ts", "../node_modules/@substrate-system/icons/node_modules/@substrate-system/web-component/src/attributes.ts", "../node_modules/@substrate-system/icons/node_modules/@substrate-system/web-component/src/util.ts", "../node_modules/@substrate-system/kebab-case/src/index.ts", "../node_modules/@substrate-system/icons/src/util.ts", "../node_modules/@substrate-system/icons/src/render/eye-slash.ts", "../node_modules/@substrate-system/icons/src/eye-slash.ts", "../node_modules/@substrate-system/icons/src/render/eye-regular.ts", "../node_modules/@substrate-system/icons/src/eye-regular.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (!window) return\n if (!('customElements' in window)) return\n\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\nexport const qs = document.querySelector.bind(document)\nexport const qsa = document.querySelectorAll.bind(document)\n\n/**\n * Get the closes parent element matching the given selector.\n * @param el Element to start from\n * @param s Selector for an element\n * @returns {HTMLElement|null} The closes parent element that matches.\n */\nexport function match (el:HTMLElement, s:string):HTMLElement|null {\n if (!el.matches) el = el.parentElement!\n return el.matches(s) ? el : el.closest(s)\n}\n", "export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (!window) return\n if (!('customElements' in window)) return\n\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\nexport const qs = document.querySelector.bind(document)\nexport const qsa = document.querySelectorAll.bind(document)\n", "// any combination of spaces and punctuation characters\n// thanks to http://stackoverflow.com/a/25575009\nconst wordSeparators = /[\\s\\u2000-\\u206F\\u2E00-\\u2E7F\\\\'!\"#$%&()*+,\\-.\\/:;<=>?@\\[\\]^_`{|}~]+/\nconst capitalPlusLower = /[A-Z\u00C0-\u00DD\\u00C0-\\u00D6\\u00D9-\\u00DD][a-z\u00E0-\u00FF]/g\nconst capitals = /[A-Z\u00C0-\u00DD\\u00C0-\\u00D6\\u00D9-\\u00DD]+/g\n\nexport function kebabCase (str:string):string {\n // replace word starts with space + lower case equivalent for later parsing\n // 1) treat cap + lower as start of new word\n str = str.replace(capitalPlusLower, function (match) {\n // match is one caps followed by one non-cap\n return ' ' + (match[0].toLowerCase() || match[0]) + match[1]\n })\n // 2) treat all remaining capitals as words\n str = str.replace(capitals, function (match) {\n // match is a series of caps\n return ' ' + match.toLowerCase()\n })\n return str\n .trim()\n .split(wordSeparators)\n .join('-')\n .replace(/^-/, '')\n .replace(/-\\s*$/, '')\n}\n\nexport default kebabCase\n", "import { type Attrs } from '@substrate-system/web-component/attributes'\n\nexport function createRenderer (\n createHtml:(attrs?:Attrs)=>string,\n tag:string\n) {\n return function (attrs?:Attrs):string {\n const html = createHtml(attrs)\n\n // running in node?\n return typeof window === 'undefined' ?\n `<${tag} class=\"icon\">\n ${html}\n </${tag}>` :\n html\n }\n}\n", "import { kebabCase } from '@substrate-system/kebab-case'\nimport { createRenderer } from '../util.js'\n\nexport const eyeSlash = createRenderer(createHtml, 'eye-slash')\n\nfunction createHtml ({ title }:{ title?:string } = {}) {\n if (!title) title = 'Hide'\n\n const html = `<svg\n class=\"icon eye-slash\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 640 512\"\n role=\"image\"\n aria-labelledby=\"${kebabCase(title)}\"\n >\n <title id=${kebabCase(title)}>${title}</title>\n <!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->\n <path d=\"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5L373 389.9z\" />\n </svg>`\n\n return html\n}\n\nexport function outerHtml ({ title }:{ title?:string }) {\n return `<eye-slash>${eyeSlash({ title })}</eye-slash>`\n}\n", "import { define as _define } from '@substrate-system/web-component/util'\nimport { eyeSlash as render } from './render/eye-slash'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'eye-slash': EyeSlash\n }\n}\n\nexport class EyeSlash extends HTMLElement {\n static TAG = 'eye-slash'\n _title:string\n\n constructor () {\n super()\n this._title = this.getAttribute('title') || 'Hide'\n }\n\n /**\n * Only watching for 'title'.\n */\n attributeChangedCallback (_name, _oldValue, newValue) {\n this._title = newValue\n this.render()\n }\n\n connectedCallback () {\n const title = this.getAttribute('title')\n if (title === undefined || title === null) {\n this._title = 'Hide'\n } else {\n this._title = title\n }\n\n this.render()\n }\n\n render () {\n const title = this._title\n\n this.innerHTML = render({ title })\n }\n}\n\nexport function define () {\n _define(EyeSlash.TAG, EyeSlash)\n}\n", "import { kebabCase } from '@substrate-system/kebab-case'\nimport { createRenderer } from '../util.js'\n\nexport const render = createRenderer(createHtml, 'eye-regular')\n\nfunction createHtml ({ title }:{ title?:string } = {}) {\n if (!title) title = 'Show'\n const kebabTitle = kebabCase(title)\n\n const html = `<svg\n class=\"icon eye-regular\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 576 512\"\n role=\"image\"\n aria-labelledby=\"${kebabTitle}\"\n >\n <title id=\"${kebabTitle}\">${title}</title>\n <!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->\n <path d=\"M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z\" />\n </svg>`\n\n return html\n}\n\nexport function outerHtml ({ title }:{ title?:string }) {\n return `<eye-regular>${render({ title })}</eye-regular>`\n}\n", "import { define as _define } from '@substrate-system/web-component/util'\nimport { render } from './render/eye-regular.js'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'eye-regular': EyeRegular\n }\n}\n\nexport class EyeRegular extends HTMLElement {\n static TAG = 'eye-regular'\n _title:string\n\n constructor () {\n super()\n this._title = this.getAttribute('title') || 'See'\n }\n\n /**\n * Only watching for 'title'.\n */\n attributeChangedCallback (_name, _oldValue, newValue) {\n this._title = newValue\n this.render()\n }\n\n connectedCallback () {\n const title = this.getAttribute('title')\n if (title === undefined || title === null) {\n this._title = 'See'\n } else {\n this._title = title\n }\n\n this.render()\n }\n\n render () {\n const title = this._title\n if (!title) return\n\n this.innerHTML = render({ title })\n }\n}\n\nexport function define () {\n _define(EyeRegular.TAG, EyeRegular)\n}\n", "import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label'])\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create object from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n this.removeAttribute('id')\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
-
"mappings": "sKASO,SAASA,EAAcC,EAAoB,CAC9C,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC,EAAKC,IAAM,CACzC,IAAMC,EAAQH,EAAME,CAAC,EACrB,OAAKC,EAED,OAAOA,GAAU,UACbA,GAAeF,EAAM,IAAIC,CAAC,IAAI,KAAK,EAChCD,EAGP,MAAM,QAAQE,CAAK,EACXF,EAAM,IAAIC,CAAC,KAAKC,EAAM,KAAK,GAAG,CAAC,KAGnCF,EAAM,IAAIC,CAAC,KAAKC,CAAK,KAAK,KAAK,EAXpBF,CAYvB,EAAG,EAAE,CACT,CAhBgBG,EAAAL,EAAA,gBAAAK,EAAAL,EAAA,cAAA,yFCAT,SAASM,EAAcC,EAAuB,CACjD,OAAO,SAAS,cAAcA,CAAM,EAAE,cAAgB,OAAO,WACjE,CAFgBC,EAAAF,EAAA,gBAAAE,EAAAF,EAAA,cAAA,EAIT,SAASG,EAAQC,EAAaC,EAAkC,CAC9D,QACC,mBAAoB,SAErBL,EAAaI,CAAI,GAClB,OAAO,eAAe,OAAOA,EAAMC,CAAO,EAElD,CAPgBH,EAAAC,EAAA,UAAAD,EAAAC,EAAA,QAAA,EAST,IAAMG,GAAK,SAAS,cAAc,KAAK,QAAQ,EACzCC,GAAM,SAAS,iBAAiB,KAAK,QAAQ,EAQnD,SAASC,EAAOC,EAAgBC,EAA2B,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AAN,EAAAM,EAAA,QAAA,ECxChBC,EAAY,EACZA,EAAc,EASP,IAAMC,EAAN,MAAMC,UAAsB,WAAY,CAhB/C,MAgB+C,CAAAC,EAAA,sBAC3C,OAAO,IAAM,iBACb,OAAO,gBAAkB,CACrB,wBACA,cACA,oBACA,oBACA,8BACA,YACA,eACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,mBACA,mBACA,eACA,gBACA,kBACA,oBACA,gBACA,cACA,eACA,gBACA,cACA,eACA,oBACA,aACA,kBACA,aACA,YACA,aACA,iBACA,uBACA,mBACA,YACA,mBACA,gBACA,eACA,gBACA,gBACA,gBACA,uBACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,YACA,gBACA,gBACA,gBACA,gBACJ,EAEA,OAAO,mBAAsB,CAAC,UAAW,
|
|
6
|
-
"names": ["toAttributes", "attrs", "acc", "k", "value", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "qs", "qsa", "match", "el", "s", "toAttributes", "attrs", "acc", "k", "value", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "qs", "qsa", "wordSeparators", "capitalPlusLower", "capitals", "kebabCase", "str", "match", "__name", "createRenderer", "createHtml", "tag", "attrs", "html", "__name", "eyeSlash", "createRenderer", "createHtml", "title", "kebabCase", "__name", "outerHtml", "EyeSlash", "__name", "_name", "_oldValue", "newValue", "title", "eyeSlash", "define", "render", "createRenderer", "createHtml", "title", "kebabTitle", "kebabCase", "__name", "outerHtml", "EyeRegular", "__name", "_name", "_oldValue", "newValue", "title", "render", "define", "define", "PasswordInput", "_PasswordInput", "__name", "_", "_newValue", "_oldValue", "name", "newValue", "oldValue", "ev", "value", "btn", "label", "hostId", "hostAriaAttributes", "attr", "attrs", "classes", "idAttribute", "ariaAttributes", "attrName", "attrValue"]
|
|
4
|
+
"sourcesContent": ["export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (!window) return\n if (!('customElements' in window)) return\n\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\nexport const qs = document.querySelector.bind(document)\nexport const qsa = document.querySelectorAll.bind(document)\n\n/**\n * Get the closes parent element matching the given selector.\n * @param el Element to start from\n * @param s Selector for an element\n * @returns {HTMLElement|null} The closes parent element that matches.\n */\nexport function match (el:HTMLElement, s:string):HTMLElement|null {\n if (!el.matches) el = el.parentElement!\n return el.matches(s) ? el : el.closest(s)\n}\n", "export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (!window) return\n if (!('customElements' in window)) return\n\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\nexport const qs = document.querySelector.bind(document)\nexport const qsa = document.querySelectorAll.bind(document)\n", "// any combination of spaces and punctuation characters\n// thanks to http://stackoverflow.com/a/25575009\nconst wordSeparators = /[\\s\\u2000-\\u206F\\u2E00-\\u2E7F\\\\'!\"#$%&()*+,\\-.\\/:;<=>?@\\[\\]^_`{|}~]+/\nconst capitalPlusLower = /[A-Z\u00C0-\u00DD\\u00C0-\\u00D6\\u00D9-\\u00DD][a-z\u00E0-\u00FF]/g\nconst capitals = /[A-Z\u00C0-\u00DD\\u00C0-\\u00D6\\u00D9-\\u00DD]+/g\n\nexport function kebabCase (str:string):string {\n // replace word starts with space + lower case equivalent for later parsing\n // 1) treat cap + lower as start of new word\n str = str.replace(capitalPlusLower, function (match) {\n // match is one caps followed by one non-cap\n return ' ' + (match[0].toLowerCase() || match[0]) + match[1]\n })\n // 2) treat all remaining capitals as words\n str = str.replace(capitals, function (match) {\n // match is a series of caps\n return ' ' + match.toLowerCase()\n })\n return str\n .trim()\n .split(wordSeparators)\n .join('-')\n .replace(/^-/, '')\n .replace(/-\\s*$/, '')\n}\n\nexport default kebabCase\n", "import { type Attrs } from '@substrate-system/web-component/attributes'\n\nexport function createRenderer (\n createHtml:(attrs?:Attrs)=>string,\n tag:string\n) {\n return function (attrs?:Attrs):string {\n const html = createHtml(attrs)\n\n // running in node?\n return typeof window === 'undefined' ?\n `<${tag} class=\"icon\">\n ${html}\n </${tag}>` :\n html\n }\n}\n", "import { kebabCase } from '@substrate-system/kebab-case'\nimport { createRenderer } from '../util.js'\n\nexport const eyeSlash = createRenderer(createHtml, 'eye-slash')\n\nfunction createHtml ({ title }:{ title?:string } = {}) {\n if (!title) title = 'Hide'\n\n const html = `<svg\n class=\"icon eye-slash\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 640 512\"\n role=\"image\"\n aria-labelledby=\"${kebabCase(title)}\"\n >\n <title id=${kebabCase(title)}>${title}</title>\n <!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->\n <path d=\"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5L373 389.9z\" />\n </svg>`\n\n return html\n}\n\nexport function outerHtml ({ title }:{ title?:string }) {\n return `<eye-slash>${eyeSlash({ title })}</eye-slash>`\n}\n", "import { define as _define } from '@substrate-system/web-component/util'\nimport { eyeSlash as render } from './render/eye-slash'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'eye-slash': EyeSlash\n }\n}\n\nexport class EyeSlash extends HTMLElement {\n static TAG = 'eye-slash'\n _title:string\n\n constructor () {\n super()\n this._title = this.getAttribute('title') || 'Hide'\n }\n\n /**\n * Only watching for 'title'.\n */\n attributeChangedCallback (_name, _oldValue, newValue) {\n this._title = newValue\n this.render()\n }\n\n connectedCallback () {\n const title = this.getAttribute('title')\n if (title === undefined || title === null) {\n this._title = 'Hide'\n } else {\n this._title = title\n }\n\n this.render()\n }\n\n render () {\n const title = this._title\n\n this.innerHTML = render({ title })\n }\n}\n\nexport function define () {\n _define(EyeSlash.TAG, EyeSlash)\n}\n", "import { kebabCase } from '@substrate-system/kebab-case'\nimport { createRenderer } from '../util.js'\n\nexport const render = createRenderer(createHtml, 'eye-regular')\n\nfunction createHtml ({ title }:{ title?:string } = {}) {\n if (!title) title = 'Show'\n const kebabTitle = kebabCase(title)\n\n const html = `<svg\n class=\"icon eye-regular\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 576 512\"\n role=\"image\"\n aria-labelledby=\"${kebabTitle}\"\n >\n <title id=\"${kebabTitle}\">${title}</title>\n <!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->\n <path d=\"M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z\" />\n </svg>`\n\n return html\n}\n\nexport function outerHtml ({ title }:{ title?:string }) {\n return `<eye-regular>${render({ title })}</eye-regular>`\n}\n", "import { define as _define } from '@substrate-system/web-component/util'\nimport { render } from './render/eye-regular.js'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'eye-regular': EyeRegular\n }\n}\n\nexport class EyeRegular extends HTMLElement {\n static TAG = 'eye-regular'\n _title:string\n\n constructor () {\n super()\n this._title = this.getAttribute('title') || 'See'\n }\n\n /**\n * Only watching for 'title'.\n */\n attributeChangedCallback (_name, _oldValue, newValue) {\n this._title = newValue\n this.render()\n }\n\n connectedCallback () {\n const title = this.getAttribute('title')\n if (title === undefined || title === null) {\n this._title = 'See'\n } else {\n this._title = title\n }\n\n this.render()\n }\n\n render () {\n const title = this._title\n if (!title) return\n\n this.innerHTML = render({ title })\n }\n}\n\nexport function define () {\n _define(EyeRegular.TAG, EyeRegular)\n}\n", "import { define } from '@substrate-system/web-component/util'\nimport { define as slashDefine } from '@substrate-system/icons/eye-slash'\nimport { define as regularDefine } from '@substrate-system/icons/eye-regular'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('password-input')\n\nslashDefine()\nregularDefine()\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'password-input':PasswordInput\n }\n}\n\nexport class PasswordInput extends HTMLElement {\n static TAG = 'password-input'\n static INPUT_ATTRIBUTES = [\n 'accept',\n 'alt',\n 'autocomplete',\n 'autocapitalize',\n 'autocorrect',\n 'autofocus',\n 'capture',\n 'dirname',\n 'disabled',\n 'enterkeyhint',\n 'form',\n 'inputmode',\n 'list',\n 'max',\n 'maxlength',\n 'min',\n 'minlength',\n 'multiple',\n 'name',\n 'pattern',\n 'placeholder',\n 'readonly',\n 'required',\n 'size',\n 'spellcheck',\n 'step',\n 'tabindex',\n 'title',\n 'value'\n ]\n\n static ARIA_ATTRIBUTES = [\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-dropeffect',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-grabbed',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-modal',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext'\n ]\n\n static observedAttributes = (['visible', 'label', 'id'])\n .concat(PasswordInput.INPUT_ATTRIBUTES)\n .concat(PasswordInput.ARIA_ATTRIBUTES)\n\n inputId:string|null = null\n inputAriaAttributes:Record<string, string> = {}\n ignoredAriaCallbackNames:Set<string> = new Set()\n ignoredIdCallback = false\n\n // empty string = is visible\n // null = not visible\n handleChange_visible (_, _newValue) {\n this.reRender()\n }\n\n handleChange_label (_oldValue, _newValue) {\n this.render()\n this._listen()\n }\n\n handleChange_aria (\n name:string,\n _oldValue:string|null,\n newValue:string|null\n ) {\n if (this.ignoredAriaCallbackNames.has(name)) {\n this.ignoredAriaCallbackNames.delete(name)\n return\n }\n\n if (newValue === null) {\n delete this.inputAriaAttributes[name]\n this.querySelector('input')?.removeAttribute(name)\n return\n }\n\n this.inputAriaAttributes[name] = newValue\n this.querySelector('input')?.setAttribute(name, newValue)\n\n if (this.hasAttribute(name)) {\n this.ignoredAriaCallbackNames.add(name)\n this.removeAttribute(name)\n }\n }\n\n handleChange_id (_oldValue:string|null, newValue:string|null) {\n if (this.ignoredIdCallback) {\n this.ignoredIdCallback = false\n return\n }\n\n if (newValue === null) {\n this.inputId = null\n this.querySelector('input')?.removeAttribute('id')\n return\n }\n\n this.inputId = newValue\n this.querySelector('input')?.setAttribute('id', newValue)\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n }\n\n handleChange_inputAttribute (name:string, newValue:string|null) {\n const input = this.querySelector('input')\n if (!input) return\n\n if (newValue === null) {\n input.removeAttribute(name)\n return\n }\n\n input.setAttribute(name, newValue)\n }\n\n /**\n * Listen for change in visiblity.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n async attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ) {\n if (name === 'id') {\n this.handleChange_id(oldValue, newValue)\n return\n }\n\n if (name.startsWith('aria-')) {\n this.handleChange_aria(name, oldValue, newValue)\n return\n }\n\n if (PasswordInput.INPUT_ATTRIBUTES.includes(name)) {\n this.handleChange_inputAttribute(name, newValue)\n return\n }\n\n if (this[`handleChange_${name}`]) {\n this[`handleChange_${name}`](oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n this._listen()\n }\n\n _listen () {\n const btn = this.querySelector('button')!\n btn.addEventListener('click', (ev) => {\n ev.preventDefault()\n this.isVisible = !this.isVisible\n })\n }\n\n getType ():'text'|'password' {\n return this.isVisible ? 'text' : 'password'\n }\n\n set isVisible (value:boolean) {\n if (value) {\n this.setAttribute('visible', '')\n } else {\n this.removeAttribute('visible')\n }\n }\n\n get isVisible ():boolean {\n return this.hasAttribute('visible')\n }\n\n set label (value:string|null) {\n if (value === null) {\n this.removeAttribute('label')\n return\n }\n\n this.setAttribute('label', value)\n }\n\n get label ():string|null {\n return this.getAttribute('label')\n }\n\n getButtonContent () {\n return (this.isVisible ?\n '<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>' :\n '<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>')\n }\n\n /**\n * Change the visibility button state.\n */\n reRender () {\n const btn = this.querySelector('.pw-visibility')\n btn!.innerHTML = this.getButtonContent()\n this.setAttribute('type', this.getType())\n this.querySelector('input')?.setAttribute('type', this.getType())\n }\n\n render () {\n const name = this.getAttribute('name')\n const label = this.getAttribute('label')\n const hostId = this.getAttribute('id')\n const hostAriaAttributes = Array.from(this.attributes)\n .filter(attr => attr.name.startsWith('aria-'))\n\n if (hostId !== null) {\n this.inputId = hostId\n }\n\n for (const attr of hostAriaAttributes) {\n this.inputAriaAttributes[attr.name] = attr.value\n }\n\n // create string from attributes\n const attrs = Array.from(this.attributes)\n .filter(attr =>\n attr.name !== 'label' &&\n attr.name !== 'id' &&\n !attr.name.startsWith('aria-')\n )\n .map(attr => attr.name + (attr.value === '' ?\n '' :\n ('=' + `\"${attr.value}\"`))\n )\n .join(' ')\n\n const classes = (this.getAttribute('class') ?? '').split(' ')\n .concat(['password', 'input', name || ''])\n .filter(Boolean)\n .join(' ')\n\n const idAttribute = this.inputId ? `id=\"${this.inputId}\"` : ''\n const ariaAttributes = Object.entries(this.inputAriaAttributes)\n .map(([attrName, attrValue]) => {\n return (attrName + (attrValue === '' ?\n '' :\n ('=' + `\"${attrValue}\"`)))\n })\n .join(' ')\n\n this.innerHTML = label ? `\n <label class=\"${classes}\">\n <span class=\"label-content\">${label}</span>\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </label>\n ` : `\n <div class=\"${classes}\">\n <span class=\"input\">\n <input\n ${idAttribute}\n ${ariaAttributes}\n ${attrs}\n type=${this.getType()} />\n <button class=\"pw-visibility\">\n ${this.getButtonContent()}\n </button>\n </span>\n </div>\n `\n\n if (this.hasAttribute('id')) {\n this.ignoredIdCallback = true\n this.removeAttribute('id')\n }\n for (const attr of hostAriaAttributes) {\n this.ignoredAriaCallbackNames.add(attr.name)\n this.removeAttribute(attr.name)\n }\n }\n}\n\ndefine(PasswordInput.TAG, PasswordInput)\n"],
|
|
5
|
+
"mappings": "sKASO,SAASA,EAAcC,EAAoB,CAC9C,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC,EAAKC,IAAM,CACzC,IAAMC,EAAQH,EAAME,CAAC,EACrB,OAAKC,EAED,OAAOA,GAAU,UACbA,GAAeF,EAAM,IAAIC,CAAC,IAAI,KAAK,EAChCD,EAGP,MAAM,QAAQE,CAAK,EACXF,EAAM,IAAIC,CAAC,KAAKC,EAAM,KAAK,GAAG,CAAC,KAGnCF,EAAM,IAAIC,CAAC,KAAKC,CAAK,KAAK,KAAK,EAXpBF,CAYvB,EAAG,EAAE,CACT,CAhBgBG,EAAAL,EAAA,gBAAAK,EAAAL,EAAA,cAAA,yFCAT,SAASM,EAAcC,EAAuB,CACjD,OAAO,SAAS,cAAcA,CAAM,EAAE,cAAgB,OAAO,WACjE,CAFgBC,EAAAF,EAAA,gBAAAE,EAAAF,EAAA,cAAA,EAIT,SAASG,EAAQC,EAAaC,EAAkC,CAC9D,QACC,mBAAoB,SAErBL,EAAaI,CAAI,GAClB,OAAO,eAAe,OAAOA,EAAMC,CAAO,EAElD,CAPgBH,EAAAC,EAAA,UAAAD,EAAAC,EAAA,QAAA,EAST,IAAMG,GAAK,SAAS,cAAc,KAAK,QAAQ,EACzCC,GAAM,SAAS,iBAAiB,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EAAW,IAAKA,CAAU,CACtC,CAFgBC,EAAAM,EAAA,UAAAN,EAAAM,EAAA,QAAA,ECxChBC,EAAY,EACZA,EAAc,EASP,IAAMC,EAAN,MAAMC,UAAsB,WAAY,CAhB/C,MAgB+C,CAAAC,EAAA,sBAC3C,OAAO,IAAM,iBACb,OAAO,iBAAmB,CACtB,SACA,MACA,eACA,iBACA,cACA,YACA,UACA,UACA,WACA,eACA,OACA,YACA,OACA,MACA,YACA,MACA,YACA,WACA,OACA,UACA,cACA,WACA,WACA,OACA,aACA,OACA,WACA,QACA,OACJ,EAEA,OAAO,gBAAkB,CACrB,wBACA,cACA,oBACA,oBACA,8BACA,YACA,eACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,mBACA,mBACA,eACA,gBACA,kBACA,oBACA,gBACA,cACA,eACA,gBACA,cACA,eACA,oBACA,aACA,kBACA,aACA,YACA,aACA,iBACA,uBACA,mBACA,YACA,mBACA,gBACA,eACA,gBACA,gBACA,gBACA,uBACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,YACA,gBACA,gBACA,gBACA,gBACJ,EAEA,OAAO,mBAAsB,CAAC,UAAW,QAAS,IAAI,EACjD,OAAOD,EAAc,gBAAgB,EACrC,OAAOA,EAAc,eAAe,EAEzC,QAAsB,KACtB,oBAA6C,CAAC,EAC9C,yBAAuC,IAAI,IAC3C,kBAAoB,GAIpB,qBAAsBE,EAAGC,EAAW,CAChC,KAAK,SAAS,CAClB,CAEA,mBAAoBC,EAAWD,EAAW,CACtC,KAAK,OAAO,EACZ,KAAK,QAAQ,CACjB,CAEA,kBACIE,EACAD,EACAE,EACF,CACE,GAAI,KAAK,yBAAyB,IAAID,CAAI,EAAG,CACzC,KAAK,yBAAyB,OAAOA,CAAI,EACzC,MACJ,CAEA,GAAIC,IAAa,KAAM,CACnB,OAAO,KAAK,oBAAoBD,CAAI,EACpC,KAAK,cAAc,OAAO,GAAG,gBAAgBA,CAAI,EACjD,MACJ,CAEA,KAAK,oBAAoB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Aa,OAAO,GAAK,IAAI,MAAM,GAAG,EACvD,OAAO,CAAC,WAAY,QAASZ,GAAQ,EAAE,CAAC,EACxC,OAAO,OAAO,EACd,KAAK,GAAG,EAEPa,EAAc,KAAK,QAAU,OAAO,KAAK,OAAO,IAAM,GACtDC,EAAiB,OAAO,QAAQ,KAAK,mBAAmB,EACzD,IAAI,CAAC,CAACC,EAAUC,CAAS,IACdD,GAAYC,IAAc,GAC9B,GACC,KAAUA,CAAS,IAC3B,EACA,KAAK,GAAG,EAEb,KAAK,UAAYT,EAAQ;AAAA,4BACLK,CAAO;AAAA,8CACWL,CAAK;AAAA;AAAA;AAAA,0BAGzBM,CAAW;AAAA,0BACXC,CAAc;AAAA,0BACdH,CAAK;AAAA,+BACA,KAAK,QAAQ,CAAC;AAAA;AAAA,0BAEnB,KAAK,iBAAiB,CAAC;AAAA;AAAA;AAAA;AAAA,UAIrC;AAAA,0BACcC,CAAO;AAAA;AAAA;AAAA,0BAGPC,CAAW;AAAA,0BACXC,CAAc;AAAA,0BACdH,CAAK;AAAA,+BACA,KAAK,QAAQ,CAAC;AAAA;AAAA,0BAEnB,KAAK,iBAAiB,CAAC;AAAA;AAAA;AAAA;AAAA,UAMrC,KAAK,aAAa,IAAI,IACtB,KAAK,kBAAoB,GACzB,KAAK,gBAAgB,IAAI,GAE7B,QAAWD,KAAQD,EACf,KAAK,yBAAyB,IAAIC,EAAK,IAAI,EAC3C,KAAK,gBAAgBA,EAAK,IAAI,CAEtC,CACJ,EAEAjB,EAAOC,EAAc,IAAKA,CAAa",
|
|
6
|
+
"names": ["toAttributes", "attrs", "acc", "k", "value", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "qs", "qsa", "match", "el", "s", "toAttributes", "attrs", "acc", "k", "value", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "qs", "qsa", "wordSeparators", "capitalPlusLower", "capitals", "kebabCase", "str", "match", "__name", "createRenderer", "createHtml", "tag", "attrs", "html", "__name", "eyeSlash", "createRenderer", "createHtml", "title", "kebabCase", "__name", "outerHtml", "EyeSlash", "__name", "_name", "_oldValue", "newValue", "title", "eyeSlash", "define", "render", "createRenderer", "createHtml", "title", "kebabTitle", "kebabCase", "__name", "outerHtml", "EyeRegular", "__name", "_name", "_oldValue", "newValue", "title", "render", "define", "define", "PasswordInput", "_PasswordInput", "__name", "_", "_newValue", "_oldValue", "name", "newValue", "input", "oldValue", "ev", "value", "btn", "label", "hostId", "hostAriaAttributes", "attr", "attrs", "classes", "idAttribute", "ariaAttributes", "attrName", "attrValue"]
|
|
7
7
|
}
|
package/dist/meta.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"src/index.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 9764,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm"
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"imports": [],
|
|
12
12
|
"exports": [],
|
|
13
13
|
"inputs": {},
|
|
14
|
-
"bytes":
|
|
14
|
+
"bytes": 15150
|
|
15
15
|
},
|
|
16
16
|
"dist/index.js": {
|
|
17
17
|
"imports": [
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"entryPoint": "src/index.ts",
|
|
38
38
|
"inputs": {
|
|
39
39
|
"src/index.ts": {
|
|
40
|
-
"bytesInOutput":
|
|
40
|
+
"bytesInOutput": 8092
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
"bytes":
|
|
43
|
+
"bytes": 8283
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrate-system/password-input",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"./dist/*"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build-docs": "typedoc --tsconfig tsconfig.build.json ./src/index.ts",
|
|
19
19
|
"build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-cjs && npm run build-esm && npm run build-esm:min && npm run build-css && npm run build-css:min",
|
|
20
20
|
"start": "vite",
|
|
21
|
-
"toc": "markdown-toc --maxdepth
|
|
21
|
+
"toc": "markdown-toc --maxdepth 4 -i README.md",
|
|
22
22
|
"preversion": "npm run lint && stylelint src/*.css",
|
|
23
23
|
"version": "npm run toc && auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md README.md",
|
|
24
24
|
"postversion": "git push --follow-tags && npm publish",
|