@substrate-system/password-input 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +168 -0
- package/README.md +136 -0
- package/dist/index.cjs +239 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.css +70 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +7 -0
- package/dist/index.min.css +1 -0
- package/dist/index.min.js +51 -0
- package/dist/index.min.js.map +7 -0
- package/dist/meta.json +46 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Big Time Public License
|
|
2
|
+
|
|
3
|
+
Version 2.0.2
|
|
4
|
+
|
|
5
|
+
<https://bigtimelicense.com/versions/2.0.2>
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
These terms let you use and share this software for noncommercial purposes
|
|
10
|
+
and in small business for free, while also guaranteeing that paid licenses
|
|
11
|
+
for big businesses will be available on fair, reasonable, and
|
|
12
|
+
nondiscriminatory terms.
|
|
13
|
+
|
|
14
|
+
## Acceptance
|
|
15
|
+
|
|
16
|
+
In order to get any license under these terms, you must agree to them as
|
|
17
|
+
both strict obligations and conditions to all your licenses.
|
|
18
|
+
|
|
19
|
+
## Noncommercial Purposes
|
|
20
|
+
|
|
21
|
+
You may use the software for any noncommercial purpose.
|
|
22
|
+
|
|
23
|
+
## Personal Uses
|
|
24
|
+
|
|
25
|
+
Personal use for research, experiment, and testing for the benefit of
|
|
26
|
+
public knowledge, personal study, private entertainment, hobby projects,
|
|
27
|
+
amateur pursuits, or religious observance, without any anticipated
|
|
28
|
+
commercial application, count as use for noncommercial purposes.
|
|
29
|
+
|
|
30
|
+
## Noncommercial Organizations
|
|
31
|
+
|
|
32
|
+
Use by any charitable organization, educational institution, public
|
|
33
|
+
research organization, public safety or health organization, environmental
|
|
34
|
+
protection organization, or government institution counts as use for
|
|
35
|
+
noncommercial purposes, regardless of the source of funding or obligations
|
|
36
|
+
resulting from the funding.
|
|
37
|
+
|
|
38
|
+
## Small Business
|
|
39
|
+
|
|
40
|
+
You may use the software for the benefit of your company if it meets all
|
|
41
|
+
these criteria:
|
|
42
|
+
|
|
43
|
+
1. had fewer than 20 total individuals working as employees and
|
|
44
|
+
independent contractors at all times during the last tax year
|
|
45
|
+
|
|
46
|
+
2. earned less than $1,000,000 total revenue in the last tax year
|
|
47
|
+
|
|
48
|
+
3. received less than $1,000,000 total debt, equity, and other investment
|
|
49
|
+
in the last five tax years, counting investment in predecessor
|
|
50
|
+
companies that reorganized into, merged with, or spun out your company
|
|
51
|
+
|
|
52
|
+
All dollar figures are United States dollars as of 2019. Adjust for them
|
|
53
|
+
inflation according to the United States Bureau of Labor Statistics'
|
|
54
|
+
consumer price index for all urban consumers, United States city average,
|
|
55
|
+
for all items, not seasonally adjusted, with 1982–1984=100 reference base.
|
|
56
|
+
|
|
57
|
+
## Big Business
|
|
58
|
+
|
|
59
|
+
You may use the software for the benefit of your company:
|
|
60
|
+
|
|
61
|
+
1. for 128 days after your company stops qualifying under
|
|
62
|
+
[Small Business](#small-business)
|
|
63
|
+
|
|
64
|
+
2. indefinitely, if the licensor or their legal successor does not offer
|
|
65
|
+
fair, reasonable, and nondiscriminatory terms for a commercial license for
|
|
66
|
+
the software within 32 days of [written request](#how-to-request) and
|
|
67
|
+
negotiate in good faith to conclude a deal
|
|
68
|
+
|
|
69
|
+
## How to Request
|
|
70
|
+
|
|
71
|
+
If this software includes an address for the licensor or an agent of the
|
|
72
|
+
licensor in a standard place, such as in documentation, software package
|
|
73
|
+
metadata, or an "about" page or screen, try to request a fair commercial
|
|
74
|
+
license at that address. If this package includes both online and offline
|
|
75
|
+
addresses, try online before offline. If you can't deliver a request that
|
|
76
|
+
way, or this software doesn't include any addressees, spend one hour online
|
|
77
|
+
researching an address, recording all your searches and inquiries as you
|
|
78
|
+
go, and try any addresses that you find. If you can't find any addresses,
|
|
79
|
+
or if those addresses also fail, that counts as failure to offer a fair
|
|
80
|
+
commercial license by the licensor under [Big Business](#big-business).
|
|
81
|
+
|
|
82
|
+
## Fair, Reasonable, and Nondiscriminatory Terms
|
|
83
|
+
|
|
84
|
+
Fair, reasonable, and nondiscriminatory terms may license the software
|
|
85
|
+
perpetually or for a term, and may or may not cover new versions of the
|
|
86
|
+
software. If the licensor advertises license terms and a pricing structure
|
|
87
|
+
for generally available commercial licenses, the licensor proposes license
|
|
88
|
+
terms and a price as advertised, and a customer not affiliated with the
|
|
89
|
+
licensor has bought a commercial license for the software on substantially
|
|
90
|
+
equivalent terms in the past year, the proposal is fair, reasonable, and
|
|
91
|
+
nondiscriminatory.
|
|
92
|
+
|
|
93
|
+
## Copyright License
|
|
94
|
+
|
|
95
|
+
The licensor grants you a copyright license to do everything with the
|
|
96
|
+
software that would otherwise infringe the licensor's copyright in it for
|
|
97
|
+
any purpose allowed by these terms.
|
|
98
|
+
|
|
99
|
+
## Notices
|
|
100
|
+
|
|
101
|
+
You must ensure that anyone who gets a copy of any part of the software
|
|
102
|
+
from you also gets a copy of these terms or the URL for them above, as well
|
|
103
|
+
as copies of any plain-text lines beginning with `Required Notice:` that
|
|
104
|
+
the licensor provided with the software. For example:
|
|
105
|
+
|
|
106
|
+
> Required Notice: Copyright Nick Thomas (https://nichoth.com)
|
|
107
|
+
|
|
108
|
+
## Patent License
|
|
109
|
+
|
|
110
|
+
The licensor grants you a patent license for the software that covers
|
|
111
|
+
patent claims the licensor can license, or becomes able to license, that
|
|
112
|
+
you would infringe by using the software.
|
|
113
|
+
|
|
114
|
+
## Fair Use
|
|
115
|
+
|
|
116
|
+
You may have "fair use" rights for the software under the law. These terms
|
|
117
|
+
do not limit them.
|
|
118
|
+
|
|
119
|
+
## No Other Rights
|
|
120
|
+
|
|
121
|
+
These terms do not allow you to sublicense or transfer any of your licenses
|
|
122
|
+
to anyone else, or prevent the licensor from granting licenses to anyone
|
|
123
|
+
else. These terms do not imply any other licenses.
|
|
124
|
+
|
|
125
|
+
## Patent Defense
|
|
126
|
+
|
|
127
|
+
If you make any written claim that the software infringes or contributes to
|
|
128
|
+
infringement of any patent, your patent license for the software granted
|
|
129
|
+
under these terms ends immediately. If your company makes such a claim,
|
|
130
|
+
your patent license ends immediately for work on behalf of your company.
|
|
131
|
+
|
|
132
|
+
## Violations
|
|
133
|
+
|
|
134
|
+
The first time you are notified in writing that you have violated any of
|
|
135
|
+
these terms, or done anything with the software not covered by your
|
|
136
|
+
licenses, your licenses can nonetheless continue if you come into full
|
|
137
|
+
compliance with these terms, and take practical steps to correct past
|
|
138
|
+
violations, within 32 days of receiving notice. Otherwise, all your
|
|
139
|
+
licenses end immediately.
|
|
140
|
+
|
|
141
|
+
## No Liability
|
|
142
|
+
|
|
143
|
+
***As far as the law allows, the software comes as is, without any warranty
|
|
144
|
+
or condition, and the licensor will not be liable to you for any damages
|
|
145
|
+
arising out of these terms or the use or nature of the software, under any
|
|
146
|
+
kind of legal claim.***
|
|
147
|
+
|
|
148
|
+
## Definitions
|
|
149
|
+
|
|
150
|
+
The **licensor** is the individual or entity offering these terms, and
|
|
151
|
+
the **software** is the software the licensor makes available under these
|
|
152
|
+
terms.
|
|
153
|
+
|
|
154
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
155
|
+
|
|
156
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
|
157
|
+
organization that you work for, plus all organizations that have control
|
|
158
|
+
over, are under the control of, or are under common control with that
|
|
159
|
+
organization. **Control** means ownership of substantially all the assets
|
|
160
|
+
of an entity, or the power to direct its management and policies by vote,
|
|
161
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
162
|
+
|
|
163
|
+
**Your licenses** are all the licenses granted to you for the software
|
|
164
|
+
under these terms.
|
|
165
|
+
|
|
166
|
+
**Use** means anything you do with the software requiring one of your
|
|
167
|
+
licenses.
|
|
168
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Password Input
|
|
2
|
+

|
|
3
|
+
[](README.md)
|
|
4
|
+
[](README.md)
|
|
5
|
+
[](https://packagephobia.com/result?p=@bicycle-codes/keys)
|
|
6
|
+
[](https://esm.sh/@substrate-system/password-input/es2022/password-input.mjs)
|
|
7
|
+
[](https://semver.org/)
|
|
8
|
+
[](./CHANGELOG.md)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
A password input with less style than
|
|
13
|
+
[password-field](https://github.com/substrate-system/password-field).
|
|
14
|
+
|
|
15
|
+
Accessible by default — `aria-*` attributes, the `id` attribute, and a
|
|
16
|
+
`label` attribute, if present, are all handled correctly.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[See a live demo](https://substrate-system.github.io/password-input/)
|
|
20
|
+
|
|
21
|
+
<details><summary><h2>Contents</h2></summary>
|
|
22
|
+
|
|
23
|
+
<!-- toc -->
|
|
24
|
+
|
|
25
|
+
- [Install](#install)
|
|
26
|
+
- [API](#api)
|
|
27
|
+
* [ESM](#esm)
|
|
28
|
+
* [Common JS](#common-js)
|
|
29
|
+
- [CSS](#css)
|
|
30
|
+
* [Import CSS](#import-css)
|
|
31
|
+
* [Customize CSS via some variables](#customize-css-via-some-variables)
|
|
32
|
+
- [Use](#use)
|
|
33
|
+
* [JS](#js)
|
|
34
|
+
* [HTML](#html)
|
|
35
|
+
* [pre-built](#pre-built)
|
|
36
|
+
|
|
37
|
+
<!-- tocstop -->
|
|
38
|
+
|
|
39
|
+
</details>
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm i -S @substrate-system/password-input
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
This exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).
|
|
50
|
+
|
|
51
|
+
### ESM
|
|
52
|
+
```js
|
|
53
|
+
import { PasswordInput } from '@substrate-system/password-input'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Common JS
|
|
57
|
+
```js
|
|
58
|
+
require('@substrate-system/password-input')
|
|
59
|
+
```
|
|
60
|
+
## Use
|
|
61
|
+
|
|
62
|
+
This calls the global function `customElements.define`. Just import, then use
|
|
63
|
+
the tag in your HTML.
|
|
64
|
+
|
|
65
|
+
### JS
|
|
66
|
+
```js
|
|
67
|
+
import '@substrate-system/password-input'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### HTML
|
|
71
|
+
```html
|
|
72
|
+
<div>
|
|
73
|
+
<password-input></password-input>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### pre-built
|
|
78
|
+
This package exposes minified JS and CSS files too. Copy them to a location that is
|
|
79
|
+
accessible to your web server, then link to them in HTML.
|
|
80
|
+
|
|
81
|
+
#### copy
|
|
82
|
+
```sh
|
|
83
|
+
cp ./node_modules/@substrate-system/password-input/dist/index.min.js ./public/password-input.min.js
|
|
84
|
+
cp ./node_modules/@substrate-system/password-input/dist/style.min.css ./public/password-input.css
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### HTML
|
|
88
|
+
```html
|
|
89
|
+
<head>
|
|
90
|
+
<link rel="stylesheet" href="./password-input.css">
|
|
91
|
+
</head>
|
|
92
|
+
<body>
|
|
93
|
+
<!-- ... -->
|
|
94
|
+
<script type="module" src="./password-input.min.js"></script>
|
|
95
|
+
</body>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## CSS
|
|
101
|
+
|
|
102
|
+
### Import CSS
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import '@substrate-system/password-input/css'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or minified:
|
|
109
|
+
```js
|
|
110
|
+
import '@substrate-system/password-input/min/css'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Notes
|
|
116
|
+
|
|
117
|
+
Implementation notes.
|
|
118
|
+
|
|
119
|
+
### `ignoredAriaCallbackNames` property
|
|
120
|
+
|
|
121
|
+
1. You set an `aria-*` attribute on `<password-input>`.
|
|
122
|
+
2. `attributeChangedCallback` routes to `handleChange_aria` (index.ts (line 105)).
|
|
123
|
+
3. `handleChange_aria` copies that value to the inner `<input>`
|
|
124
|
+
(index.ts (line 189)).
|
|
125
|
+
4. Then it removes the same `aria-*` from the host (index.ts (line 194))
|
|
126
|
+
so host stays clean.
|
|
127
|
+
5. That removal triggers `attributeChangedCallback` again with
|
|
128
|
+
`newValue === null`.
|
|
129
|
+
6. The guard sees the name in `ignoredAriaCallbackNames`, deletes it, and
|
|
130
|
+
returns early (index.ts (line 178)),
|
|
131
|
+
so it does not remove the attribute from the input/cache.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
Without this guard, the second callback would treat the host removal as a
|
|
135
|
+
real “delete” request and clear the input attribute you just transferred.
|
|
136
|
+
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
PasswordInput: () => PasswordInput
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
|
+
var import_util = require("@substrate-system/web-component/util");
|
|
26
|
+
var import_eye_slash = require("@substrate-system/icons/eye-slash");
|
|
27
|
+
var import_eye_regular = require("@substrate-system/icons/eye-regular");
|
|
28
|
+
(0, import_eye_slash.define)();
|
|
29
|
+
(0, import_eye_regular.define)();
|
|
30
|
+
class PasswordInput extends HTMLElement {
|
|
31
|
+
static {
|
|
32
|
+
__name(this, "PasswordInput");
|
|
33
|
+
}
|
|
34
|
+
static TAG = "password-input";
|
|
35
|
+
static ARIA_ATTRIBUTES = [
|
|
36
|
+
"aria-activedescendant",
|
|
37
|
+
"aria-atomic",
|
|
38
|
+
"aria-autocomplete",
|
|
39
|
+
"aria-braillelabel",
|
|
40
|
+
"aria-brailleroledescription",
|
|
41
|
+
"aria-busy",
|
|
42
|
+
"aria-checked",
|
|
43
|
+
"aria-colcount",
|
|
44
|
+
"aria-colindex",
|
|
45
|
+
"aria-colindextext",
|
|
46
|
+
"aria-colspan",
|
|
47
|
+
"aria-controls",
|
|
48
|
+
"aria-current",
|
|
49
|
+
"aria-describedby",
|
|
50
|
+
"aria-description",
|
|
51
|
+
"aria-details",
|
|
52
|
+
"aria-disabled",
|
|
53
|
+
"aria-dropeffect",
|
|
54
|
+
"aria-errormessage",
|
|
55
|
+
"aria-expanded",
|
|
56
|
+
"aria-flowto",
|
|
57
|
+
"aria-grabbed",
|
|
58
|
+
"aria-haspopup",
|
|
59
|
+
"aria-hidden",
|
|
60
|
+
"aria-invalid",
|
|
61
|
+
"aria-keyshortcuts",
|
|
62
|
+
"aria-label",
|
|
63
|
+
"aria-labelledby",
|
|
64
|
+
"aria-level",
|
|
65
|
+
"aria-live",
|
|
66
|
+
"aria-modal",
|
|
67
|
+
"aria-multiline",
|
|
68
|
+
"aria-multiselectable",
|
|
69
|
+
"aria-orientation",
|
|
70
|
+
"aria-owns",
|
|
71
|
+
"aria-placeholder",
|
|
72
|
+
"aria-posinset",
|
|
73
|
+
"aria-pressed",
|
|
74
|
+
"aria-readonly",
|
|
75
|
+
"aria-relevant",
|
|
76
|
+
"aria-required",
|
|
77
|
+
"aria-roledescription",
|
|
78
|
+
"aria-rowcount",
|
|
79
|
+
"aria-rowindex",
|
|
80
|
+
"aria-rowindextext",
|
|
81
|
+
"aria-rowspan",
|
|
82
|
+
"aria-selected",
|
|
83
|
+
"aria-setsize",
|
|
84
|
+
"aria-sort",
|
|
85
|
+
"aria-valuemax",
|
|
86
|
+
"aria-valuemin",
|
|
87
|
+
"aria-valuenow",
|
|
88
|
+
"aria-valuetext"
|
|
89
|
+
];
|
|
90
|
+
static observedAttributes = ["visible", "label"].concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
91
|
+
inputId = null;
|
|
92
|
+
inputAriaAttributes = {};
|
|
93
|
+
ignoredAriaCallbackNames = /* @__PURE__ */ new Set();
|
|
94
|
+
// empty string = is visible
|
|
95
|
+
// null = not visible
|
|
96
|
+
handleChange_visible(_, _newValue) {
|
|
97
|
+
this.reRender();
|
|
98
|
+
}
|
|
99
|
+
handleChange_label(_oldValue, _newValue) {
|
|
100
|
+
this.render();
|
|
101
|
+
this._listen();
|
|
102
|
+
}
|
|
103
|
+
handleChange_aria(name, _oldValue, newValue) {
|
|
104
|
+
if (this.ignoredAriaCallbackNames.has(name)) {
|
|
105
|
+
this.ignoredAriaCallbackNames.delete(name);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (newValue === null) {
|
|
109
|
+
delete this.inputAriaAttributes[name];
|
|
110
|
+
this.querySelector("input")?.removeAttribute(name);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.inputAriaAttributes[name] = newValue;
|
|
114
|
+
this.querySelector("input")?.setAttribute(name, newValue);
|
|
115
|
+
if (this.hasAttribute(name)) {
|
|
116
|
+
this.ignoredAriaCallbackNames.add(name);
|
|
117
|
+
this.removeAttribute(name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Listen for change in visiblity.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} name The attribute name
|
|
124
|
+
* @param {string} oldValue The old attribute value
|
|
125
|
+
* @param {string} newValue The new attribute value
|
|
126
|
+
*/
|
|
127
|
+
async attributeChangedCallback(name, oldValue, newValue) {
|
|
128
|
+
if (name.startsWith("aria-")) {
|
|
129
|
+
this.handleChange_aria(name, oldValue, newValue);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (this[`handleChange_${name}`]) {
|
|
133
|
+
this[`handleChange_${name}`](oldValue, newValue);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
connectedCallback() {
|
|
137
|
+
this.render();
|
|
138
|
+
this._listen();
|
|
139
|
+
}
|
|
140
|
+
_listen() {
|
|
141
|
+
const btn = this.querySelector("button");
|
|
142
|
+
btn.addEventListener("click", (ev) => {
|
|
143
|
+
ev.preventDefault();
|
|
144
|
+
this.isVisible = !this.isVisible;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
getType() {
|
|
148
|
+
return this.isVisible ? "text" : "password";
|
|
149
|
+
}
|
|
150
|
+
set isVisible(value) {
|
|
151
|
+
if (value) {
|
|
152
|
+
this.setAttribute("visible", "");
|
|
153
|
+
} else {
|
|
154
|
+
this.removeAttribute("visible");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
get isVisible() {
|
|
158
|
+
return this.hasAttribute("visible");
|
|
159
|
+
}
|
|
160
|
+
set label(value) {
|
|
161
|
+
if (value === null) {
|
|
162
|
+
this.removeAttribute("label");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.setAttribute("label", value);
|
|
166
|
+
}
|
|
167
|
+
get label() {
|
|
168
|
+
return this.getAttribute("label");
|
|
169
|
+
}
|
|
170
|
+
getButtonContent() {
|
|
171
|
+
return this.isVisible ? '<eye-regular></eye-regular><span class="visually-hidden">Hide</span>' : '<eye-slash></eye-slash><span class="visually-hidden">Show</span>';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Change the visibility button state.
|
|
175
|
+
*/
|
|
176
|
+
reRender() {
|
|
177
|
+
const btn = this.querySelector(".pw-visibility");
|
|
178
|
+
btn.innerHTML = this.getButtonContent();
|
|
179
|
+
this.setAttribute("type", this.getType());
|
|
180
|
+
this.querySelector("input")?.setAttribute("type", this.getType());
|
|
181
|
+
}
|
|
182
|
+
render() {
|
|
183
|
+
const name = this.getAttribute("name");
|
|
184
|
+
const label = this.getAttribute("label");
|
|
185
|
+
const hostId = this.getAttribute("id");
|
|
186
|
+
const hostAriaAttributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith("aria-"));
|
|
187
|
+
if (hostId !== null) {
|
|
188
|
+
this.inputId = hostId;
|
|
189
|
+
}
|
|
190
|
+
for (const attr of hostAriaAttributes) {
|
|
191
|
+
this.inputAriaAttributes[attr.name] = attr.value;
|
|
192
|
+
}
|
|
193
|
+
const attrs = Array.from(this.attributes).filter(
|
|
194
|
+
(attr) => attr.name !== "label" && attr.name !== "id" && !attr.name.startsWith("aria-")
|
|
195
|
+
).map(
|
|
196
|
+
(attr) => attr.name + (attr.value === "" ? "" : `="${attr.value}"`)
|
|
197
|
+
).join(" ");
|
|
198
|
+
const classes = (this.getAttribute("class") ?? "").split(" ").concat(["password", "input", name || ""]).filter(Boolean).join(" ");
|
|
199
|
+
const idAttribute = this.inputId ? `id="${this.inputId}"` : "";
|
|
200
|
+
const ariaAttributes = Object.entries(this.inputAriaAttributes).map(([attrName, attrValue]) => {
|
|
201
|
+
return attrName + (attrValue === "" ? "" : `="${attrValue}"`);
|
|
202
|
+
}).join(" ");
|
|
203
|
+
this.innerHTML = label ? `
|
|
204
|
+
<label class="${classes}">
|
|
205
|
+
<span class="label-content">${label}</span>
|
|
206
|
+
<span class="input">
|
|
207
|
+
<input
|
|
208
|
+
${idAttribute}
|
|
209
|
+
${ariaAttributes}
|
|
210
|
+
${attrs}
|
|
211
|
+
type=${this.getType()} />
|
|
212
|
+
<button class="pw-visibility">
|
|
213
|
+
${this.getButtonContent()}
|
|
214
|
+
</button>
|
|
215
|
+
</span>
|
|
216
|
+
</label>
|
|
217
|
+
` : `
|
|
218
|
+
<div class="${classes}">
|
|
219
|
+
<span class="input">
|
|
220
|
+
<input
|
|
221
|
+
${idAttribute}
|
|
222
|
+
${ariaAttributes}
|
|
223
|
+
${attrs}
|
|
224
|
+
type=${this.getType()} />
|
|
225
|
+
<button class="pw-visibility">
|
|
226
|
+
${this.getButtonContent()}
|
|
227
|
+
</button>
|
|
228
|
+
</span>
|
|
229
|
+
</div>
|
|
230
|
+
`;
|
|
231
|
+
this.removeAttribute("id");
|
|
232
|
+
for (const attr of hostAriaAttributes) {
|
|
233
|
+
this.ignoredAriaCallbackNames.add(attr.name);
|
|
234
|
+
this.removeAttribute(attr.name);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
(0, import_util.define)(PasswordInput.TAG, PasswordInput);
|
|
239
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,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C;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,SAAK,gBAAgB,IAAI;AACzB,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
|
+
"names": ["slashDefine", "regularDefine"]
|
|
7
|
+
}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import "@substrate-system/icons/css";
|
|
2
|
+
@import "@substrate-system/a11y/visually-hidden";
|
|
3
|
+
|
|
4
|
+
password-input {
|
|
5
|
+
display: block;
|
|
6
|
+
|
|
7
|
+
& .password.input {
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
align-items: center;
|
|
10
|
+
min-width: 100%;
|
|
11
|
+
display: flex;
|
|
12
|
+
|
|
13
|
+
& .label-content {
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
& span.input {
|
|
18
|
+
align-items: center;
|
|
19
|
+
width: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
& input {
|
|
24
|
+
border: 1px solid;
|
|
25
|
+
border-radius: 0;
|
|
26
|
+
outline: 1px solid #0000;
|
|
27
|
+
width: 100%;
|
|
28
|
+
padding: 1rem 1rem .8rem;
|
|
29
|
+
transition: all .2s;
|
|
30
|
+
|
|
31
|
+
&:focus {
|
|
32
|
+
outline: 1px solid;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:disabled {
|
|
36
|
+
& + .pw-visibility {
|
|
37
|
+
opacity: .4;
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
cursor: default;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& button.pw-visibility {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
background-color: #0000;
|
|
47
|
+
border: none;
|
|
48
|
+
outline: 2px solid #0000;
|
|
49
|
+
width: 2.4rem;
|
|
50
|
+
height: 2.4rem;
|
|
51
|
+
transition: all .2s;
|
|
52
|
+
position: relative;
|
|
53
|
+
right: 3rem;
|
|
54
|
+
|
|
55
|
+
&:focus-visible {
|
|
56
|
+
& .icon {
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
outline-offset: 2px;
|
|
62
|
+
outline: 2px solid;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
password-input:not(:defined) {
|
|
69
|
+
visibility: hidden;
|
|
70
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementTagNameMap {
|
|
3
|
+
'password-input': PasswordInput;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare class PasswordInput extends HTMLElement {
|
|
7
|
+
static TAG: string;
|
|
8
|
+
static ARIA_ATTRIBUTES: string[];
|
|
9
|
+
static observedAttributes: string[];
|
|
10
|
+
inputId: string | null;
|
|
11
|
+
inputAriaAttributes: Record<string, string>;
|
|
12
|
+
ignoredAriaCallbackNames: Set<string>;
|
|
13
|
+
handleChange_visible(_: any, _newValue: any): void;
|
|
14
|
+
handleChange_label(_oldValue: any, _newValue: any): void;
|
|
15
|
+
handleChange_aria(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
16
|
+
/**
|
|
17
|
+
* Listen for change in visiblity.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} name The attribute name
|
|
20
|
+
* @param {string} oldValue The old attribute value
|
|
21
|
+
* @param {string} newValue The new attribute value
|
|
22
|
+
*/
|
|
23
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): Promise<void>;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
_listen(): void;
|
|
26
|
+
getType(): 'text' | 'password';
|
|
27
|
+
set isVisible(value: boolean);
|
|
28
|
+
get isVisible(): boolean;
|
|
29
|
+
set label(value: string | null);
|
|
30
|
+
get label(): string | null;
|
|
31
|
+
getButtonContent(): "<eye-regular></eye-regular><span class=\"visually-hidden\">Hide</span>" | "<eye-slash></eye-slash><span class=\"visually-hidden\">Show</span>";
|
|
32
|
+
/**
|
|
33
|
+
* Change the visibility button state.
|
|
34
|
+
*/
|
|
35
|
+
reRender(): void;
|
|
36
|
+
render(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,CAAC,GAAG,SAAmB;IAC7B,MAAM,CAAC,eAAe,WAsDrB;IAED,MAAM,CAAC,kBAAkB,WACiB;IAE1C,OAAO,EAAC,MAAM,GAAC,IAAI,CAAO;IAC1B,mBAAmB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAC/C,wBAAwB,EAAC,GAAG,CAAC,MAAM,CAAC,CAAY;IAIhD,oBAAoB,CAAE,CAAC,KAAA,EAAE,SAAS,KAAA;IAIlC,kBAAkB,CAAE,SAAS,KAAA,EAAE,SAAS,KAAA;IAKxC,iBAAiB,CACb,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,MAAM,GAAC,IAAI,EACrB,QAAQ,EAAC,MAAM,GAAC,IAAI;IAsBxB;;;;;;OAMG;IACG,wBAAwB,CAC1B,IAAI,EAAC,MAAM,EACX,QAAQ,EAAC,MAAM,EACf,QAAQ,EAAC,MAAM;IAYnB,iBAAiB;IAKjB,OAAO;IAQP,OAAO,IAAI,MAAM,GAAC,UAAU;IAI5B,IAAI,SAAS,CAAE,KAAK,EAAC,OAAO,EAM3B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,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;CA6ET"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { define } from "@substrate-system/web-component/util";
|
|
4
|
+
import { define as slashDefine } from "@substrate-system/icons/eye-slash";
|
|
5
|
+
import { define as regularDefine } from "@substrate-system/icons/eye-regular";
|
|
6
|
+
slashDefine();
|
|
7
|
+
regularDefine();
|
|
8
|
+
class PasswordInput extends HTMLElement {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "PasswordInput");
|
|
11
|
+
}
|
|
12
|
+
static TAG = "password-input";
|
|
13
|
+
static ARIA_ATTRIBUTES = [
|
|
14
|
+
"aria-activedescendant",
|
|
15
|
+
"aria-atomic",
|
|
16
|
+
"aria-autocomplete",
|
|
17
|
+
"aria-braillelabel",
|
|
18
|
+
"aria-brailleroledescription",
|
|
19
|
+
"aria-busy",
|
|
20
|
+
"aria-checked",
|
|
21
|
+
"aria-colcount",
|
|
22
|
+
"aria-colindex",
|
|
23
|
+
"aria-colindextext",
|
|
24
|
+
"aria-colspan",
|
|
25
|
+
"aria-controls",
|
|
26
|
+
"aria-current",
|
|
27
|
+
"aria-describedby",
|
|
28
|
+
"aria-description",
|
|
29
|
+
"aria-details",
|
|
30
|
+
"aria-disabled",
|
|
31
|
+
"aria-dropeffect",
|
|
32
|
+
"aria-errormessage",
|
|
33
|
+
"aria-expanded",
|
|
34
|
+
"aria-flowto",
|
|
35
|
+
"aria-grabbed",
|
|
36
|
+
"aria-haspopup",
|
|
37
|
+
"aria-hidden",
|
|
38
|
+
"aria-invalid",
|
|
39
|
+
"aria-keyshortcuts",
|
|
40
|
+
"aria-label",
|
|
41
|
+
"aria-labelledby",
|
|
42
|
+
"aria-level",
|
|
43
|
+
"aria-live",
|
|
44
|
+
"aria-modal",
|
|
45
|
+
"aria-multiline",
|
|
46
|
+
"aria-multiselectable",
|
|
47
|
+
"aria-orientation",
|
|
48
|
+
"aria-owns",
|
|
49
|
+
"aria-placeholder",
|
|
50
|
+
"aria-posinset",
|
|
51
|
+
"aria-pressed",
|
|
52
|
+
"aria-readonly",
|
|
53
|
+
"aria-relevant",
|
|
54
|
+
"aria-required",
|
|
55
|
+
"aria-roledescription",
|
|
56
|
+
"aria-rowcount",
|
|
57
|
+
"aria-rowindex",
|
|
58
|
+
"aria-rowindextext",
|
|
59
|
+
"aria-rowspan",
|
|
60
|
+
"aria-selected",
|
|
61
|
+
"aria-setsize",
|
|
62
|
+
"aria-sort",
|
|
63
|
+
"aria-valuemax",
|
|
64
|
+
"aria-valuemin",
|
|
65
|
+
"aria-valuenow",
|
|
66
|
+
"aria-valuetext"
|
|
67
|
+
];
|
|
68
|
+
static observedAttributes = ["visible", "label"].concat(PasswordInput.ARIA_ATTRIBUTES);
|
|
69
|
+
inputId = null;
|
|
70
|
+
inputAriaAttributes = {};
|
|
71
|
+
ignoredAriaCallbackNames = /* @__PURE__ */ new Set();
|
|
72
|
+
// empty string = is visible
|
|
73
|
+
// null = not visible
|
|
74
|
+
handleChange_visible(_, _newValue) {
|
|
75
|
+
this.reRender();
|
|
76
|
+
}
|
|
77
|
+
handleChange_label(_oldValue, _newValue) {
|
|
78
|
+
this.render();
|
|
79
|
+
this._listen();
|
|
80
|
+
}
|
|
81
|
+
handleChange_aria(name, _oldValue, newValue) {
|
|
82
|
+
if (this.ignoredAriaCallbackNames.has(name)) {
|
|
83
|
+
this.ignoredAriaCallbackNames.delete(name);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (newValue === null) {
|
|
87
|
+
delete this.inputAriaAttributes[name];
|
|
88
|
+
this.querySelector("input")?.removeAttribute(name);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.inputAriaAttributes[name] = newValue;
|
|
92
|
+
this.querySelector("input")?.setAttribute(name, newValue);
|
|
93
|
+
if (this.hasAttribute(name)) {
|
|
94
|
+
this.ignoredAriaCallbackNames.add(name);
|
|
95
|
+
this.removeAttribute(name);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Listen for change in visiblity.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} name The attribute name
|
|
102
|
+
* @param {string} oldValue The old attribute value
|
|
103
|
+
* @param {string} newValue The new attribute value
|
|
104
|
+
*/
|
|
105
|
+
async attributeChangedCallback(name, oldValue, newValue) {
|
|
106
|
+
if (name.startsWith("aria-")) {
|
|
107
|
+
this.handleChange_aria(name, oldValue, newValue);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (this[`handleChange_${name}`]) {
|
|
111
|
+
this[`handleChange_${name}`](oldValue, newValue);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
connectedCallback() {
|
|
115
|
+
this.render();
|
|
116
|
+
this._listen();
|
|
117
|
+
}
|
|
118
|
+
_listen() {
|
|
119
|
+
const btn = this.querySelector("button");
|
|
120
|
+
btn.addEventListener("click", (ev) => {
|
|
121
|
+
ev.preventDefault();
|
|
122
|
+
this.isVisible = !this.isVisible;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
getType() {
|
|
126
|
+
return this.isVisible ? "text" : "password";
|
|
127
|
+
}
|
|
128
|
+
set isVisible(value) {
|
|
129
|
+
if (value) {
|
|
130
|
+
this.setAttribute("visible", "");
|
|
131
|
+
} else {
|
|
132
|
+
this.removeAttribute("visible");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
get isVisible() {
|
|
136
|
+
return this.hasAttribute("visible");
|
|
137
|
+
}
|
|
138
|
+
set label(value) {
|
|
139
|
+
if (value === null) {
|
|
140
|
+
this.removeAttribute("label");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.setAttribute("label", value);
|
|
144
|
+
}
|
|
145
|
+
get label() {
|
|
146
|
+
return this.getAttribute("label");
|
|
147
|
+
}
|
|
148
|
+
getButtonContent() {
|
|
149
|
+
return this.isVisible ? '<eye-regular></eye-regular><span class="visually-hidden">Hide</span>' : '<eye-slash></eye-slash><span class="visually-hidden">Show</span>';
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Change the visibility button state.
|
|
153
|
+
*/
|
|
154
|
+
reRender() {
|
|
155
|
+
const btn = this.querySelector(".pw-visibility");
|
|
156
|
+
btn.innerHTML = this.getButtonContent();
|
|
157
|
+
this.setAttribute("type", this.getType());
|
|
158
|
+
this.querySelector("input")?.setAttribute("type", this.getType());
|
|
159
|
+
}
|
|
160
|
+
render() {
|
|
161
|
+
const name = this.getAttribute("name");
|
|
162
|
+
const label = this.getAttribute("label");
|
|
163
|
+
const hostId = this.getAttribute("id");
|
|
164
|
+
const hostAriaAttributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith("aria-"));
|
|
165
|
+
if (hostId !== null) {
|
|
166
|
+
this.inputId = hostId;
|
|
167
|
+
}
|
|
168
|
+
for (const attr of hostAriaAttributes) {
|
|
169
|
+
this.inputAriaAttributes[attr.name] = attr.value;
|
|
170
|
+
}
|
|
171
|
+
const attrs = Array.from(this.attributes).filter(
|
|
172
|
+
(attr) => attr.name !== "label" && attr.name !== "id" && !attr.name.startsWith("aria-")
|
|
173
|
+
).map(
|
|
174
|
+
(attr) => attr.name + (attr.value === "" ? "" : `="${attr.value}"`)
|
|
175
|
+
).join(" ");
|
|
176
|
+
const classes = (this.getAttribute("class") ?? "").split(" ").concat(["password", "input", name || ""]).filter(Boolean).join(" ");
|
|
177
|
+
const idAttribute = this.inputId ? `id="${this.inputId}"` : "";
|
|
178
|
+
const ariaAttributes = Object.entries(this.inputAriaAttributes).map(([attrName, attrValue]) => {
|
|
179
|
+
return attrName + (attrValue === "" ? "" : `="${attrValue}"`);
|
|
180
|
+
}).join(" ");
|
|
181
|
+
this.innerHTML = label ? `
|
|
182
|
+
<label class="${classes}">
|
|
183
|
+
<span class="label-content">${label}</span>
|
|
184
|
+
<span class="input">
|
|
185
|
+
<input
|
|
186
|
+
${idAttribute}
|
|
187
|
+
${ariaAttributes}
|
|
188
|
+
${attrs}
|
|
189
|
+
type=${this.getType()} />
|
|
190
|
+
<button class="pw-visibility">
|
|
191
|
+
${this.getButtonContent()}
|
|
192
|
+
</button>
|
|
193
|
+
</span>
|
|
194
|
+
</label>
|
|
195
|
+
` : `
|
|
196
|
+
<div class="${classes}">
|
|
197
|
+
<span class="input">
|
|
198
|
+
<input
|
|
199
|
+
${idAttribute}
|
|
200
|
+
${ariaAttributes}
|
|
201
|
+
${attrs}
|
|
202
|
+
type=${this.getType()} />
|
|
203
|
+
<button class="pw-visibility">
|
|
204
|
+
${this.getButtonContent()}
|
|
205
|
+
</button>
|
|
206
|
+
</span>
|
|
207
|
+
</div>
|
|
208
|
+
`;
|
|
209
|
+
this.removeAttribute("id");
|
|
210
|
+
for (const attr of hostAriaAttributes) {
|
|
211
|
+
this.ignoredAriaCallbackNames.add(attr.name);
|
|
212
|
+
this.removeAttribute(attr.name);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
define(PasswordInput.TAG, PasswordInput);
|
|
217
|
+
export {
|
|
218
|
+
PasswordInput
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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(Pas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AO,KAAK,OAAO,MAAM;AAC5D,UAAM,iBAAiB,OAAO,QAAQ,KAAK,mBAAmB,EACzD,IAAI,CAAC,CAAC,UAAU,SAAS,MAAM;AAC5B,aAAQ,YAAY,cAAc,KAC9B,KACC,KAAU,SAAS;AAAA,IAC5B,CAAC,EACA,KAAK,GAAG;AAEb,SAAK,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,SAAK,gBAAgB,IAAI;AACzB,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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "@substrate-system/icons/css";@import "@substrate-system/a11y/visually-hidden";password-input{display:block;& .password.input{flex-wrap:wrap;align-items:center;min-width:100%;display:flex;& .label-content{width:100%}& span.input{align-items:center;width:100%;display:flex}& input{border:1px solid;border-radius:0;outline:1px solid #0000;width:100%;padding:1rem 1rem .8rem;transition:all .2s;&:focus{outline:1px solid}&:disabled{&+.pw-visibility{opacity:.4;pointer-events:none;cursor:default}}}& button.pw-visibility{cursor:pointer;background-color:#0000;border:none;outline:2px solid #0000;width:2.4rem;height:2.4rem;transition:all .2s;position:relative;right:3rem;&:focus-visible{& .icon{width:100%;height:100%}outline-offset:2px;outline:2px solid}}}}password-input:not(:defined){visibility:hidden}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var R=Object.defineProperty;var i=(t,e)=>R(t,"name",{value:e,configurable:!0});var q=Object.defineProperty,O=i((t,e)=>q(t,"name",{value:e,configurable:!0}),"__name");function $(t){return Object.keys(t).reduce((e,a)=>{let r=t[a];return r?typeof r=="boolean"?r?(e+` ${a}`).trim():e:Array.isArray(r)?e+` ${a}="${r.join(" ")}"`:(e+` ${a}="${r}"`).trim():e},"")}i($,"toAttributes");O($,"toAttributes");var D=Object.defineProperty,b=i((t,e)=>D(t,"name",{value:e,configurable:!0}),"__name");function x(t){return document.createElement(t).constructor!==window.HTMLElement}i(x,"isRegistered");b(x,"isRegistered");function f(t,e){window&&"customElements"in window&&(x(t)||window.customElements.define(t,e))}i(f,"define");b(f,"define");var se=document.querySelector.bind(document),oe=document.querySelectorAll.bind(document);function I(t,e){return t.matches||(t=t.parentElement),t.matches(e)?t:t.closest(e)}i(I,"match");b(I,"match");var z=Object.defineProperty,B=i((t,e)=>z(t,"name",{value:e,configurable:!0}),"__name");function T(t){return Object.keys(t).reduce((e,a)=>{let r=t[a];return r?typeof r=="boolean"?r?(e+` ${a}`).trim():e:Array.isArray(r)?e+` ${a}="${r.join(" ")}"`:(e+` ${a}="${r}"`).trim():e},"")}i(T,"toAttributes");B(T,"toAttributes");var F=Object.defineProperty,H=i((t,e)=>F(t,"name",{value:e,configurable:!0}),"__name");function L(t){return document.createElement(t).constructor!==window.HTMLElement}i(L,"isRegistered");H(L,"isRegistered");function o(t,e){window&&"customElements"in window&&(L(t)||window.customElements.define(t,e))}i(o,"define");H(o,"define");var fe=document.querySelector.bind(document),he=document.querySelectorAll.bind(document);var V=Object.defineProperty,G=i((t,e)=>V(t,"name",{value:e,configurable:!0}),"__name"),N=/[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/,W=/[A-ZÀ-Ý\u00C0-\u00D6\u00D9-\u00DD][a-zà-ÿ]/g,U=/[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(U,function(e){return" "+e.toLowerCase()}),t.trim().split(N).join("-").replace(/^-/,"").replace(/-\s*$/,"")}i(s,"kebabCase");G(s,"kebabCase");var Z=Object.defineProperty,J=i((t,e)=>Z(t,"name",{value:e,configurable:!0}),"__name");function l(t,e){return function(a){let r=t(a);return typeof window>"u"?`<${e} class="icon">
|
|
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"),h=l(S,"eye-slash");function S({title:t}={}){return t||(t="Hide"),`<svg
|
|
4
|
+
class="icon eye-slash"
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
viewBox="0 0 640 512"
|
|
7
|
+
role="image"
|
|
8
|
+
aria-labelledby="${s(t)}"
|
|
9
|
+
>
|
|
10
|
+
<title id=${s(t)}>${t}</title>
|
|
11
|
+
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
|
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(S,"createHtml");P(S,"createHtml");function Q({title:t}){return`<eye-slash>${h({title:t})}</eye-slash>`}i(Q,"outerHtml");P(Q,"outerHtml");var X=Object.defineProperty,j=i((t,e)=>X(t,"name",{value:e,configurable:!0}),"__name"),u=class extends HTMLElement{static{i(this,"EyeSlash")}static{j(this,"EyeSlash")}static TAG="eye-slash";_title;constructor(){super(),this._title=this.getAttribute("title")||"Hide"}attributeChangedCallback(e,a,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=h({title:e})}};function m(){o(u.TAG,u)}i(m,"define");j(m,"define");var Y=Object.defineProperty,E=i((t,e)=>Y(t,"name",{value:e,configurable:!0}),"__name"),p=l(M,"eye-regular");function M({title:t}={}){t||(t="Show");let e=s(t);return`<svg
|
|
14
|
+
class="icon eye-regular"
|
|
15
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
16
|
+
viewBox="0 0 576 512"
|
|
17
|
+
role="image"
|
|
18
|
+
aria-labelledby="${e}"
|
|
19
|
+
>
|
|
20
|
+
<title id="${e}">${t}</title>
|
|
21
|
+
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
|
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(M,"createHtml");E(M,"createHtml");function ee({title:t}){return`<eye-regular>${p({title:t})}</eye-regular>`}i(ee,"outerHtml");E(ee,"outerHtml");var te=Object.defineProperty,k=i((t,e)=>te(t,"name",{value:e,configurable:!0}),"__name"),c=class extends HTMLElement{static{i(this,"EyeRegular")}static{k(this,"EyeRegular")}static TAG="eye-regular";_title;constructor(){super(),this._title=this.getAttribute("title")||"See"}attributeChangedCallback(e,a,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=p({title:e}))}};function g(){o(c.TAG,c)}i(g,"define");k(g,"define");m();g();var d=class t extends HTMLElement{static{i(this,"PasswordInput")}static TAG="password-input";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"].concat(t.ARIA_ATTRIBUTES);inputId=null;inputAriaAttributes={};ignoredAriaCallbackNames=new Set;handleChange_visible(e,a){this.reRender()}handleChange_label(e,a){this.render(),this._listen()}handleChange_aria(e,a,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))}async attributeChangedCallback(e,a,r){if(e.startsWith("aria-")){this.handleChange_aria(e,a,r);return}this[`handleChange_${e}`]&&this[`handleChange_${e}`](a,r)}connectedCallback(){this.render(),this._listen()}_listen(){this.querySelector("button").addEventListener("click",a=>{a.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"),a=this.getAttribute("label"),r=this.getAttribute("id"),_=Array.from(this.attributes).filter(n=>n.name.startsWith("aria-"));r!==null&&(this.inputId=r);for(let n of _)this.inputAriaAttributes[n.name]=n.value;let y=Array.from(this.attributes).filter(n=>n.name!=="label"&&n.name!=="id"&&!n.name.startsWith("aria-")).map(n=>n.name+(n.value===""?"":`="${n.value}"`)).join(" "),A=(this.getAttribute("class")??"").split(" ").concat(["password","input",e||""]).filter(Boolean).join(" "),v=this.inputId?`id="${this.inputId}"`:"",w=Object.entries(this.inputAriaAttributes).map(([n,C])=>n+(C===""?"":`="${C}"`)).join(" ");this.innerHTML=a?`
|
|
24
|
+
<label class="${A}">
|
|
25
|
+
<span class="label-content">${a}</span>
|
|
26
|
+
<span class="input">
|
|
27
|
+
<input
|
|
28
|
+
${v}
|
|
29
|
+
${w}
|
|
30
|
+
${y}
|
|
31
|
+
type=${this.getType()} />
|
|
32
|
+
<button class="pw-visibility">
|
|
33
|
+
${this.getButtonContent()}
|
|
34
|
+
</button>
|
|
35
|
+
</span>
|
|
36
|
+
</label>
|
|
37
|
+
`:`
|
|
38
|
+
<div class="${A}">
|
|
39
|
+
<span class="input">
|
|
40
|
+
<input
|
|
41
|
+
${v}
|
|
42
|
+
${w}
|
|
43
|
+
${y}
|
|
44
|
+
type=${this.getType()} />
|
|
45
|
+
<button class="pw-visibility">
|
|
46
|
+
${this.getButtonContent()}
|
|
47
|
+
</button>
|
|
48
|
+
</span>
|
|
49
|
+
</div>
|
|
50
|
+
`,this.removeAttribute("id");for(let n of _)this.ignoredAriaCallbackNames.add(n.name),this.removeAttribute(n.name)}};f(d.TAG,d);export{d as PasswordInput};
|
|
51
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,OAA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AAO,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,UAMzC,KAAK,gBAAgB,IAAI,EACzB,QAAWD,KAAQD,EACf,KAAK,yBAAyB,IAAIC,EAAK,IAAI,EAC3C,KAAK,gBAAgBA,EAAK,IAAI,CAEtC,CACJ,EAEAhB,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", "oldValue", "ev", "value", "btn", "label", "hostId", "hostAriaAttributes", "attr", "attrs", "classes", "idAttribute", "ariaAttributes", "attrName", "attrValue"]
|
|
7
|
+
}
|
package/dist/meta.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"inputs": {
|
|
3
|
+
"src/index.ts": {
|
|
4
|
+
"bytes": 7849,
|
|
5
|
+
"imports": [],
|
|
6
|
+
"format": "esm"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"outputs": {
|
|
10
|
+
"dist/index.js.map": {
|
|
11
|
+
"imports": [],
|
|
12
|
+
"exports": [],
|
|
13
|
+
"inputs": {},
|
|
14
|
+
"bytes": 12085
|
|
15
|
+
},
|
|
16
|
+
"dist/index.js": {
|
|
17
|
+
"imports": [
|
|
18
|
+
{
|
|
19
|
+
"path": "@substrate-system/web-component/util",
|
|
20
|
+
"kind": "import-statement",
|
|
21
|
+
"external": true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "@substrate-system/icons/eye-slash",
|
|
25
|
+
"kind": "import-statement",
|
|
26
|
+
"external": true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "@substrate-system/icons/eye-regular",
|
|
30
|
+
"kind": "import-statement",
|
|
31
|
+
"external": true
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"exports": [
|
|
35
|
+
"PasswordInput"
|
|
36
|
+
],
|
|
37
|
+
"entryPoint": "src/index.ts",
|
|
38
|
+
"inputs": {
|
|
39
|
+
"src/index.ts": {
|
|
40
|
+
"bytesInOutput": 6512
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"bytes": 6703
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@substrate-system/password-input",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"./dist/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"lint": "eslint \"./**/*.{ts,js}\"",
|
|
11
|
+
"test": "esbuild --bundle ./test/index.ts | tapout",
|
|
12
|
+
"build-css": "lightningcss --nesting src/index.css -o dist/index.css",
|
|
13
|
+
"build-css:min": "lightningcss --nesting --minify src/index.css -o dist/index.min.css",
|
|
14
|
+
"build-cjs": "esbuild src/*.ts --format=cjs --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.cjs --sourcemap",
|
|
15
|
+
"build-esm": "esbuild src/*.ts --format=esm --metafile=dist/meta.json --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --sourcemap && tsc --emitDeclarationOnly --project tsconfig.build.json --outDir dist",
|
|
16
|
+
"build-esm:min": "esbuild ./src/*.ts --format=esm --keep-names --bundle --tsconfig=tsconfig.build.json --minify --out-extension:.js=.min.js --outdir=./dist --sourcemap",
|
|
17
|
+
"build-example": "mkdir -p ./public && rm -rf ./public/* && NODE_ENV=development vite --mode development --base=\"/password-input\" build",
|
|
18
|
+
"build-docs": "typedoc --tsconfig tsconfig.build.json ./src/index.ts",
|
|
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
|
+
"start": "vite",
|
|
21
|
+
"toc": "markdown-toc --maxdepth 3 -i README.md",
|
|
22
|
+
"preversion": "npm run lint && stylelint src/*.css",
|
|
23
|
+
"version": "npm run toc && auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md README.md",
|
|
24
|
+
"postversion": "git push --follow-tags && npm publish",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./css": "./dist/index.css",
|
|
33
|
+
"./min/css": "./dist/index.min.css",
|
|
34
|
+
"./min/*": {
|
|
35
|
+
"import": "./dist/*.min.js",
|
|
36
|
+
"require": "./dist/*.min.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./*": {
|
|
39
|
+
"import": "./dist/*.js",
|
|
40
|
+
"require": "./dist/*.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@substrate-system/a11y": "^0.0.17",
|
|
45
|
+
"@substrate-system/icons": "^0.1.29",
|
|
46
|
+
"@substrate-system/web-component": "^0.0.43"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@substrate-system/debug": "^0.9.32",
|
|
50
|
+
"@substrate-system/dom": "^0.1.13",
|
|
51
|
+
"@substrate-system/tapout": "^0.0.35",
|
|
52
|
+
"@substrate-system/tapzero": "^0.10.16",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
54
|
+
"@typescript-eslint/parser": "^8.7.0",
|
|
55
|
+
"auto-changelog": "^2.4.0",
|
|
56
|
+
"browserslist": "^4.28.1",
|
|
57
|
+
"esbuild": "^0.27.2",
|
|
58
|
+
"eslint": "^8.57.0",
|
|
59
|
+
"eslint-config-standard": "^17.1.0",
|
|
60
|
+
"lightningcss": "^1.30.2",
|
|
61
|
+
"lightningcss-cli": "^1.30.2",
|
|
62
|
+
"markdown-toc": "^1.2.0",
|
|
63
|
+
"stylelint": "^17.0.0",
|
|
64
|
+
"stylelint-config-standard": "^40.0.0",
|
|
65
|
+
"tap-spec": "^5.0.0",
|
|
66
|
+
"tape-run": "^11.0.0",
|
|
67
|
+
"typedoc": "^0.28.1",
|
|
68
|
+
"typescript": "^5.7.3",
|
|
69
|
+
"vite": "^7.3.0"
|
|
70
|
+
},
|
|
71
|
+
"author": "nichoth <nichoth@nichoth.com> (https://nichoth.com)",
|
|
72
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
73
|
+
}
|