@substrate-system/input 0.0.6 → 0.0.8
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 +61 -83
- package/README.md +7 -7
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +2 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +2 -2
- package/dist/meta.json +4 -4
- package/package.json +23 -3
package/LICENSE
CHANGED
|
@@ -1,121 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Big Time Public License
|
|
2
2
|
|
|
3
|
-
|
|
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 and in small business for free, while also guaranteeing that paid licenses for big businesses will be available on fair, reasonable, and nondiscriminatory terms.
|
|
4
10
|
|
|
5
11
|
## Acceptance
|
|
6
12
|
|
|
7
|
-
In order to get any license under these terms, you must agree
|
|
8
|
-
to them as both strict obligations and conditions to all
|
|
9
|
-
your licenses.
|
|
13
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Noncommercial Purposes
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
software to do everything you might do with the software
|
|
15
|
-
that would otherwise infringe the licensor's copyright
|
|
16
|
-
in it for any permitted purpose. However, you may
|
|
17
|
-
only distribute the software according to [Distribution
|
|
18
|
-
License](#distribution-license) and make changes or new works
|
|
19
|
-
based on the software according to [Changes and New Works
|
|
20
|
-
License](#changes-and-new-works-license).
|
|
17
|
+
You may use the software for any noncommercial purpose.
|
|
21
18
|
|
|
22
|
-
##
|
|
19
|
+
## Personal Uses
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
to distribute copies of the software. Your license
|
|
26
|
-
to distribute covers distributing the software with
|
|
27
|
-
changes and new works permitted by [Changes and New Works
|
|
28
|
-
License](#changes-and-new-works-license).
|
|
21
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, count as use for noncommercial purposes.
|
|
29
22
|
|
|
30
|
-
##
|
|
23
|
+
## Noncommercial Organizations
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
the software from you also gets a copy of these terms or the
|
|
34
|
-
URL for them above, as well as copies of any plain-text lines
|
|
35
|
-
beginning with `Required Notice:` that the licensor provided
|
|
36
|
-
with the software. For example:
|
|
25
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution counts as use for noncommercial purposes, regardless of the source of funding or obligations resulting from the funding.
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
## Small Business
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
You may use the software for the benefit of your company if it meets all these criteria:
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
make changes and new works based on the software for any
|
|
44
|
-
permitted purpose.
|
|
31
|
+
1. had fewer than 20 total individuals working as employees and independent contractors at all times during the last tax year
|
|
45
32
|
|
|
46
|
-
|
|
33
|
+
2. earned less than $1,000,000 total revenue in the last tax year
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
covers patent claims the licensor can license, or becomes able
|
|
50
|
-
to license, that you would infringe by using the software.
|
|
35
|
+
3. received less than $1,000,000 total debt, equity, and other investment in the last five tax years, counting investment in predecessor companies that reorganized into, merged with, or spun out your company
|
|
51
36
|
|
|
52
|
-
|
|
37
|
+
All dollar figures are United States dollars as of 2019. Adjust for them inflation according to the United States Bureau of Labor Statistics' consumer price index for all urban consumers, United States city average, for all items, not seasonally adjusted, with 1982–1984=100 reference base.
|
|
53
38
|
|
|
54
|
-
|
|
55
|
-
law. These terms do not limit them.
|
|
39
|
+
## Big Business
|
|
56
40
|
|
|
57
|
-
|
|
41
|
+
You may use the software for the benefit of your company:
|
|
42
|
+
|
|
43
|
+
1. for 128 days after your company stops qualifying under [Small Business](#small-business)
|
|
44
|
+
|
|
45
|
+
2. indefinitely, if the licensor or their legal successor does not offer fair, reasonable, and nondiscriminatory terms for a commercial license for the software within 32 days of [written request](#how-to-request) and negotiate in good faith to conclude a deal
|
|
46
|
+
|
|
47
|
+
## How to Request
|
|
48
|
+
|
|
49
|
+
If this software includes an address for the licensor or an agent of the licensor in a standard place, such as in documentation, software package metadata, or an "about" page or screen, try to request a fair commercial license at that address. If this package includes both online and offline addresses, try online before offline. If you can't deliver a request that way, or this software doesn't include any addressees, spend one hour online researching an address, recording all your searches and inquiries as you go, and try any addresses that you find. If you can't find any addresses, or if those addresses also fail, that counts as failure to offer a fair commercial license by the licensor under [Big Business](#big-business).
|
|
50
|
+
|
|
51
|
+
## Fair, Reasonable, and Nondiscriminatory Terms
|
|
52
|
+
|
|
53
|
+
Fair, reasonable, and nondiscriminatory terms may license the software perpetually or for a term, and may or may not cover new versions of the software. If the licensor advertises license terms and a pricing structure for generally available commercial licenses, the licensor proposes license terms and a price as advertised, and a customer not affiliated with the licensor has bought a commercial license for the software on substantially equivalent terms in the past year, the proposal is fair, reasonable, and nondiscriminatory.
|
|
54
|
+
|
|
55
|
+
## Copyright License
|
|
56
|
+
|
|
57
|
+
The licensor grants you a copyright license to do everything with the software that would otherwise infringe the licensor's copyright in it for any purpose allowed by these terms.
|
|
58
|
+
|
|
59
|
+
## Notices
|
|
60
|
+
|
|
61
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
62
|
+
|
|
63
|
+
> Required Notice: Nick Thomas (https://nichoth.com)
|
|
64
|
+
|
|
65
|
+
## Patent License
|
|
66
|
+
|
|
67
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
68
|
+
|
|
69
|
+
## Fair Use
|
|
58
70
|
|
|
59
|
-
|
|
60
|
-
a permitted purpose if your company has fewer than 100 total
|
|
61
|
-
individuals working as employees and independent contractors,
|
|
62
|
-
and less than 1,000,000 USD (2019) total revenue in the prior
|
|
63
|
-
tax year. Adjust this revenue threshold for inflation according
|
|
64
|
-
to the United States Bureau of Labor Statistics' consumer price
|
|
65
|
-
index for all urban consumers, U.S. city average, for all items,
|
|
66
|
-
not seasonally adjusted, with 1982–1984=100 reference base.
|
|
71
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
67
72
|
|
|
68
73
|
## No Other Rights
|
|
69
74
|
|
|
70
|
-
These terms do not allow you to sublicense or transfer any of
|
|
71
|
-
your licenses to anyone else, or prevent the licensor from
|
|
72
|
-
granting licenses to anyone else. These terms do not imply
|
|
73
|
-
any other licenses.
|
|
75
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
74
76
|
|
|
75
77
|
## Patent Defense
|
|
76
78
|
|
|
77
|
-
If you make any written claim that the software infringes or
|
|
78
|
-
contributes to infringement of any patent, your patent license
|
|
79
|
-
for the software granted under these terms ends immediately. If
|
|
80
|
-
your company makes such a claim, your patent license ends
|
|
81
|
-
immediately for work on behalf of your company.
|
|
79
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
82
80
|
|
|
83
81
|
## Violations
|
|
84
82
|
|
|
85
|
-
The first time you are notified in writing that you have
|
|
86
|
-
violated any of these terms, or done anything with the software
|
|
87
|
-
not covered by your licenses, your licenses can nonetheless
|
|
88
|
-
continue if you come into full compliance with these terms,
|
|
89
|
-
and take practical steps to correct past violations, within
|
|
90
|
-
32 days of receiving notice. Otherwise, all your licenses
|
|
91
|
-
end immediately.
|
|
83
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
92
84
|
|
|
93
85
|
## No Liability
|
|
94
86
|
|
|
95
|
-
***As far as the law allows, the software comes as is, without
|
|
96
|
-
any warranty or condition, and the licensor will not be liable
|
|
97
|
-
to you for any damages arising out of these terms or the use
|
|
98
|
-
or nature of the software, under any kind of legal claim.***
|
|
87
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
99
88
|
|
|
100
89
|
## Definitions
|
|
101
90
|
|
|
102
|
-
The **licensor** is the individual or entity offering these
|
|
103
|
-
terms, and the **software** is the software the licensor makes
|
|
104
|
-
available under these terms.
|
|
91
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
105
92
|
|
|
106
|
-
**You** refers to the individual or entity agreeing to these
|
|
107
|
-
terms.
|
|
93
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
108
94
|
|
|
109
|
-
**Your company** is any legal entity, sole proprietorship,
|
|
110
|
-
or other kind of organization that you work for, plus all
|
|
111
|
-
organizations that have control over, are under the control of,
|
|
112
|
-
or are under common control with that organization. **Control**
|
|
113
|
-
means ownership of substantially all the assets of an entity,
|
|
114
|
-
or the power to direct its management and policies by vote,
|
|
115
|
-
contract, or otherwise. Control can be direct or indirect.
|
|
95
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
116
96
|
|
|
117
|
-
**Your licenses** are all the licenses granted to you for the
|
|
118
|
-
software under these terms.
|
|
97
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
119
98
|
|
|
120
|
-
**Use** means anything you do with the software requiring one
|
|
121
|
-
of your licenses.
|
|
99
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# input
|
|
2
|
-
](https://github.com/substrate-system/input/actions/workflows/nodejs.yml)
|
|
3
3
|
[](README.md)
|
|
4
4
|
[](README.md)
|
|
5
5
|
[](https://packagephobia.com/result?p=@substrate-system/input)
|
|
6
|
-
[](https://bundlephobia.com/package/@substrate-system/input)
|
|
7
7
|
[](package.json)
|
|
8
8
|
[](https://semver.org/)
|
|
9
9
|
[](./CHANGELOG.md)
|
|
10
|
-
[](LICENSE)
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
A parent web component to inherit from.
|
|
@@ -16,8 +16,8 @@ A parent web component to inherit from.
|
|
|
16
16
|
|
|
17
17
|
<!-- toc -->
|
|
18
18
|
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
19
|
+
- [Install](#install)
|
|
20
|
+
- [Modules](#modules)
|
|
21
21
|
* [ESM](#esm)
|
|
22
22
|
* [Common JS](#common-js)
|
|
23
23
|
- [Use](#use)
|
|
@@ -25,13 +25,13 @@ A parent web component to inherit from.
|
|
|
25
25
|
|
|
26
26
|
<!-- tocstop -->
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Install
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
npm i -S @substrate-system/input
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Modules
|
|
35
35
|
|
|
36
36
|
This exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).
|
|
37
37
|
|
package/dist/index.cjs
CHANGED
|
@@ -165,6 +165,7 @@ class Input extends HTMLElement {
|
|
|
165
165
|
const props = [
|
|
166
166
|
`class="${classes.filter(Boolean).join(" ")}"`,
|
|
167
167
|
disabled ? "disabled" : "",
|
|
168
|
+
disabled ? 'aria-disabled="true"' : 'aria-diabled="false"',
|
|
168
169
|
autofocus ? "autofocus" : "",
|
|
169
170
|
type ? `type="${this.type}"` : "",
|
|
170
171
|
tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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AAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,cAAe,MAAa,OAAgC;AACxD,QAAI,CAAC,OAAO;AACR,aAAO,KAAK,iBAAiB,IAAI;AAAA,IACrC;AAEA,QAAI,UAAU,MAAM;AAEhB,aAAO,KAAK,OAAO,aAAa,MAAM,EAAE;AAAA,IAC5C;AAGA,SAAK,OAAO,aAAa,MAAM,KAAK;AAAA,EACxC;AAAA,EAEA,SAAsB;AAClB,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AAEJ,UAAM,UAAmB,CAAC,iBAAiB;AAE3C,UAAM,MAAM,CAAC,EAAE,KAAK,SAAS,YAAY,KAAK,SAAS;AAEvD,UAAM,QAAS;AAAA,MACX,UAAU,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAAA,MAC3C,WAAW,aAAa;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,OAAO,SAAS,KAAK,IAAI,MAAM;AAAA,MAC/B,WAAW,aAAa,QAAQ,MAAM;AAAA,MACtC,MAAM,kBAAkB;AAAA,MACxB,QAAQ,SAAS,KAAK,KAAK;AAAA,MAC3B,OAAO,QAAQ,IAAI,KAAK;AAAA,IAC5B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAE3B,WAAO,UAAU,KAAK;AAAA,EAC1B;AACJ;",
|
|
4
|
+
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void { // void for child class\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n disabled ? 'aria-disabled=\"true\"' : 'aria-diabled=\"false\"',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAe,cAAc,YAAY;AAAA,EAAhD,OAAgD;AAAA;AAAA;AAAA;AAAA,EAE5C,OAAO,qBAAqB,CAAC,aAAa,UAAU;AAAA,EACpD,OAAO;AAAA,EAEP,OAAO,SAA8D;AACjE,QAAI,EAAE,oBAAoB,QAAS;AACnC,QAAI,eAAe,IAAI,KAAK,GAAG,EAAG;AAElC,WAAO,eAAe,OAAO,KAAK,KAAK,IAAI;AAAA,EAC/C;AAAA,EAEA,cAAe;AACX,UAAM;AACN,UAAM,WAAW,KAAK,aAAa,UAAU;AAC7C,QAAI,aAAa,MAAM;AACnB,iBAAW,MAAM;AAEb,aAAK,WAAW;AAAA,MACpB,GAAG,CAAC;AAAA,IACR;AAGA,eAAW,MAAM;AACb,YAAM,OAAO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AE,QAAQ,EAAC,MAAM;IAoBvD;;;;;;OAMG;IACH,wBAAwB,CAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM;IAMvE,iBAAiB;IAIjB,IAAI,IAAI,IAAI,MAAM,GAAC,IAAI,GAAC,SAAS,CAEhC;IAED,IAAI,IAAI,CAAE,KAAK,EAAC,MAAM,EAErB;IAED,IAAI,KAAK,IAIO,MAAM,GAAC,SAAS,GAAC,IAAI,CAFpC;IAED,IAAI,KAAK,CAAE,IAAI,EAAC,MAAM,GAAC,SAAS,GAAC,IAAI,EAKpC;IAED;;OAEG;IACH,aAAa,CAAE,IAAI,EAAC,MAAM,EAAE,KAAK,EAAC,OAAO,GAAC,MAAM,GAAC,IAAI,GAAE,IAAI;IAc3D,MAAM,IAAI,MAAM,GAAC,IAAI;CA4BxB"}
|
package/dist/index.js
CHANGED
|
@@ -143,6 +143,7 @@ class Input extends HTMLElement {
|
|
|
143
143
|
const props = [
|
|
144
144
|
`class="${classes.filter(Boolean).join(" ")}"`,
|
|
145
145
|
disabled ? "disabled" : "",
|
|
146
|
+
disabled ? 'aria-disabled="true"' : 'aria-diabled="false"',
|
|
146
147
|
autofocus ? "autofocus" : "",
|
|
147
148
|
type ? `type="${this.type}"` : "",
|
|
148
149
|
tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAAO,MAAe,cAAc,YAAY;AAAA,EAAhD,OAAgD;AAAA;AAAA;AAAA;AAAA,EAE5C,OAAO,qBAAqB,CAAC,aAAa,UAAU;AAAA,EACpD,OAAO;AAAA,EAEP,OAAO,SAA8D;AACjE,QAAI,EAAE,oBAAoB,QAAS;AACnC,QAAI,eAAe,IAAI,KAAK,GAAG,EAAG;AAElC,WAAO,eAAe,OAAO,KAAK,KAAK,IAAI;AAAA,EAC/C;AAAA,EAEA,cAAe;AACX,UAAM;AACN,UAAM,WAAW,KAAK,aAAa,UAAU;AAC7C,QAAI,aAAa,MAAM;AACnB,iBAAW,MAAM;AAEb,aAAK,WAAW;AAAA,MACpB,GAAG,CAAC;AAAA,IACR;AAGA,eAAW,MAAM;AACb,YAAM,OAAO,KAAK,a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AAAA,MACX,UAAU,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAAA,MAC3C,WAAW,aAAa;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,OAAO,SAAS,KAAK,IAAI,MAAM;AAAA,MAC/B,WAAW,aAAa,QAAQ,MAAM;AAAA,MACtC,MAAM,kBAAkB;AAAA,MACxB,QAAQ,SAAS,KAAK,KAAK;AAAA,MAC3B,OAAO,QAAQ,IAAI,KAAK;AAAA,IAC5B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAE3B,WAAO,UAAU,KAAK;AAAA,EAC1B;AACJ;",
|
|
4
|
+
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void { // void for child class\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n disabled ? 'aria-disabled=\"true\"' : 'aria-diabled=\"false\"',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAO,MAAe,cAAc,YAAY;AAAA,EAAhD,OAAgD;AAAA;AAAA;AAAA;AAAA,EAE5C,OAAO,qBAAqB,CAAC,aAAa,UAAU;AAAA,EACpD,OAAO;AAAA,EAEP,OAAO,SAA8D;AACjE,QAAI,EAAE,oBAAoB,QAAS;AACnC,QAAI,eAAe,IAAI,KAAK,GAAG,EAAG;AAElC,WAAO,eAAe,OAAO,KAAK,KAAK,IAAI;AAAA,EAC/C;AAAA,EAEA,cAAe;AACX,UAAM;AACN,UAAM,WAAW,KAAK,aAAa,UAAU;AAC7C,QAAI,aAAa,MAAM;AACnB,iBAAW,MAAM;AAEb,aAAK,WAAW;AAAA,MACpB,GAAG,CAAC;AAAA,IACR;AAGA,eAAW,MAAM;AACb,YAAM,OAAO,KAAK,aAAa,OAAO;AACtC,UAAI,KAAM,MAAK,QAAQ;AAEvB,YAAM,OAAO,KAAK,aAAa,MAAM;AACrC,UAAI,KAAM,MAAK,OAAO;AAEtB,YAAM,OAAO,KAAK,aAAa,MAAM;AACrC,UAAI,KAAM,MAAK,OAAO;AAAA,IAC1B,GAAG,CAAC;AAAA,EACR;AAAA,EAEA,IAAI,QAA+B;AAC/B,WAAO,KAAK,cAAc,OAAO;AAAA,EACrC;AAAA,EAEA,IAAI,WAAmB;AACnB,UAAM,IAAI,KAAK,OAAO,aAAa,UAAU;AAC7C,QAAI,CAAC,EAAG,QAAO;AACf,WAAO,SAAS,CAAC;AAAA,EACrB;AAAA,EAEA,IAAI,OAA8B;AAC9B,WAAO,KAAK,OAAO;AAAA,EACvB;AAAA,EAEA,IAAI,KAAM,SAAgB;AACtB,QAAI,CAAC,K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,t)=>o(n,"name",{value:t,configurable:!0});var l=class extends HTMLElement{static{a(this,"Input")}static observedAttributes=["autofocus","disabled"];static tag;static define(){if("customElements"in window&&!customElements.get(this.tag))return customElements.define(this.tag,this)}constructor(){super(),this.getAttribute("disabled")!==null&&setTimeout(()=>{this.disabled=!0},0),setTimeout(()=>{let e=this.getAttribute("value");e&&(this.value=e);let
|
|
1
|
+
var o=Object.defineProperty;var a=(n,t)=>o(n,"name",{value:t,configurable:!0});var l=class extends HTMLElement{static{a(this,"Input")}static observedAttributes=["autofocus","disabled"];static tag;static define(){if("customElements"in window&&!customElements.get(this.tag))return customElements.define(this.tag,this)}constructor(){super(),this.getAttribute("disabled")!==null&&setTimeout(()=>{this.disabled=!0},0),setTimeout(()=>{let e=this.getAttribute("value");e&&(this.value=e);let s=this.getAttribute("type");s&&(this.type=s);let i=this.getAttribute("name");i&&(this.name=i)},0)}get input(){return this.querySelector("input")}get tabindex(){let t=this.input?.getAttribute("tabindex");return t?parseInt(t):0}get name(){return this.input?.name}set name(t){this.input&&(this.input.name=t)}_removeAttribute(t){this.removeAttribute(t),this.input?.removeAttribute(t)}get disabled(){return!!this.input?.hasAttribute("disabled")}set disabled(t){t?(this.input?.setAttribute("disabled",""),this.input?.setAttribute("aria-disabled","true")):(this._removeAttribute("disabled"),this.input?.setAttribute("aria-disabled","false"))}handleChange_disabled(t,e){this.input?e===null?this.disabled=!1:this.disabled=!0:setTimeout(()=>{e===null?this.disabled=!1:this.disabled=!0},0)}attributeChangedCallback(t,e,s){let i=this[`handleChange_${t}`];i&&i.call(this,e,s),this.render()}connectedCallback(){this.render()}get type(){return this.input?.getAttribute("type")}set type(t){this._setAttribute("type",t)}get value(){return this.input?.value}set value(t){t?this.input.value=t:this.input?.removeAttribute("value")}_setAttribute(t,e){if(!e)return this._removeAttribute(t);if(e===!0)return this.input?.setAttribute(t,"");this.input?.setAttribute(t,e)}render(){let{type:t,autofocus:e,tabindex:s,disabled:i,value:r,name:u}=this,d=["substrate-input"],b=this.type==="submit"||this.type==="button";return`<input ${[`class="${d.filter(Boolean).join(" ")}"`,i?"disabled":"",i?'aria-disabled="true"':'aria-diabled="false"',e?"autofocus":"",t?`type="${this.type}"`:"",s?`tabindex="${s}"`:'tabindex="0"',b?'role="button"':"",r?`value=${r}`:"",u?`name=${u}`:""].filter(Boolean).join(" ")} />`}};export{l as Input};
|
|
2
2
|
//# 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": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
-
"mappings": "+EAAO,IAAeA,EAAf,cAA6B,WAAY,CAAhD,MAAgD,CAAAC,EAAA,cAE5C,OAAO,mBAAqB,CAAC,YAAa,UAAU,EACpD,OAAO,IAEP,OAAO,QAA8D,CACjE,GAAM,mBAAoB,QACtB,gBAAe,IAAI,KAAK,GAAG,EAE/B,OAAO,eAAe,OAAO,KAAK,IAAK,IAAI,CAC/C,CAEA,aAAe,CACX,MAAM,EACW,KAAK,aAAa,UAAU,IAC5B,MACb,WAAW,IAAM,CAEb,KAAK,SAAW,EACpB,EAAG,CAAC,EAIR,WAAW,IAAM,CACb,IAAMC,EAAO,KAAK,aAAa,OAAO,EAClCA,IAAM,KAAK,MAAQA,GAEvB,IAAMC,EAAO,KAAK,aAAa,MAAM,EACjCA,IAAM,KAAK,KAAOA,GAEtB,IAAMC,EAAO,KAAK,aAAa,MAAM,EACjCA,IAAM,KAAK,KAAOA,EAC1B,EAAG,CAAC,CACR,CAEA,IAAI,OAA+B,CAC/B,OAAO,KAAK,cAAc,OAAO,CACrC,CAEA,IAAI,UAAmB,CACnB,IAAMC,EAAI,KAAK,OAAO,aAAa,UAAU,EAC7C,OAAKA,EACE,SAASA,CAAC,EADF,CAEnB,CAEA,IAAI,MAA8B,CAC9B,OAAO,KAAK,OAAO,IACvB,CAEA,IAAI,KAAMC,EAAgB,CACjB,KAAK,QACV,KAAK,MAAM,KAAOA,EACtB,CAKA,iBAAkBF,EAAa,CAC3B,KAAK,gBAAgBA,CAAI,EACzB,KAAK,OAAO,gBAAgBA,CAAI,CACpC,CAEA,IAAI,UAAoB,CACpB,MAAO,CAAC,CAAE,KAAK,OAAO,aAAa,UAAU,CACjD,CAEA,IAAI,SAAUG,EAAuB,CAC5BA,GAID,KAAK,OAAO,aAAa,WAAY,EAAE,EACvC,KAAK,OAAO,aAAa,gBAAiB,MAAM,IAJhD,KAAK,iBAAiB,UAAU,EAChC,KAAK,OAAO,aAAa,gBAAiB,OAAO,EAKzD,CASA,sBAAuBC,EAAiBC,EAAiB,CAChD,KAAK,MAWFA,IAAa,KACb,KAAK,SAAW,GAEhB,KAAK,SAAW,GAbpB,WAAW,IAAM,CACTA,IAAa,KAEb,KAAK,SAAW,GAGhB,KAAK,SAAW,EAExB,EAAG,CAAC,CAQZ,CASA,yBAA0BL,EAAaI,EAAiBC,EAAiB,CACrE,IAAMC,EAAU,KAAK,gBAAgBN,CAAI,EAAE,EAC1CM,GAAWA,EAAQ,KAAK,KAAMF,EAAUC,CAAQ,EACjD,KAAK,OAAO,CAChB,CAEA,mBAAqB,CACjB,KAAK,OAAO,CAChB,CAEA,IAAI,MAA8B,CAC9B,OAAO,KAAK,OAAO,aAAa,MAAM,CAC1C,CAEA,IAAI,KAAME,EAAc,CACpB,KAAK,cAAc,OAAQA,CAAK,CACpC,CAEA,IAAI,OAAS,CACT,OAAO,KAAK,OAAO,KACvB,CAEA,IAAI,MAAOC,EAA4B,CAC9BA,EAED,KAAK,MAAO,MAAQA,EAFb,KAAK,OAAO,gBAAgB,OAAO,CAIlD,CAKA,cAAeR,EAAaO,EAAgC,CACxD,GAAI,CAACA,EACD,OAAO,KAAK,iBAAiBP,CAAI,EAGrC,GAAIO,IAAU,GAEV,OAAO,KAAK,OAAO,aAAaP,EAAM,EAAE,EAI5C,KAAK,OAAO,aAAaA,EAAMO,CAAK,CACxC,CAEA,QAAsB,CAClB,GAAM,CACF,KAAAR,EACA,UAAAU,EACA,SAAAC,EACA,SAAAC,EACA,MAAAJ,EACA,KAAAP,CACJ,EAAI,KAEEY,EAAmB,CAAC,iBAAiB,EAErCC,EAAS,KAAK,OAAS,UAAY,KAAK,OAAS,
|
|
4
|
+
"sourcesContent": ["export abstract class Input extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n // timeout b/c we need to render first\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) this.value = attr\n\n const type = this.getAttribute('type')\n if (type) this.type = type\n\n const name = this.getAttribute('name')\n if (name) this.name = name\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get name ():string|undefined|null {\n return this.input?.name\n }\n\n set name (newName:string) {\n if (!this.input) return\n this.input.name = newName\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n if (!this.input) {\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n if (newValue === null) {\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\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 attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render ():string|void { // void for child class\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value,\n name\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n disabled ? 'aria-disabled=\"true\"' : 'aria-diabled=\"false\"',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : '',\n name ? `name=${name}` : '',\n ]).filter(Boolean).join(' ')\n\n return `<input ${props} />`\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAO,IAAeA,EAAf,cAA6B,WAAY,CAAhD,MAAgD,CAAAC,EAAA,cAE5C,OAAO,mBAAqB,CAAC,YAAa,UAAU,EACpD,OAAO,IAEP,OAAO,QAA8D,CACjE,GAAM,mBAAoB,QACtB,gBAAe,IAAI,KAAK,GAAG,EAE/B,OAAO,eAAe,OAAO,KAAK,IAAK,IAAI,CAC/C,CAEA,aAAe,CACX,MAA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EAAQ,KAAK,KAAMF,EAAUC,CAAQ,EACjD,KAAK,OAAO,CAChB,CAEA,mBAAqB,CACjB,KAAK,OAAO,CAChB,CAEA,IAAI,MAA8B,CAC9B,OAAO,KAAK,OAAO,aAAa,MAAM,CAC1C,CAEA,IAAI,KAAME,EAAc,CACpB,KAAK,cAAc,OAAQA,CAAK,CACpC,CAEA,IAAI,OAAS,CACT,OAAO,KAAK,OAAO,KACvB,CAEA,IAAI,MAAOC,EAA4B,CAC9BA,EAED,KAAK,MAAO,MAAQA,EAFb,KAAK,OAAO,gBAAgB,OAAO,CAIlD,CAKA,cAAeR,EAAaO,EAAgC,CACxD,GAAI,CAACA,EACD,OAAO,KAAK,iBAAiBP,CAAI,EAGrC,GAAIO,IAAU,GAEV,OAAO,KAAK,OAAO,aAAaP,EAAM,EAAE,EAI5C,KAAK,OAAO,aAAaA,EAAMO,CAAK,CACxC,CAEA,QAAsB,CAClB,GAAM,CACF,KAAAR,EACA,UAAAU,EACA,SAAAC,EACA,SAAAC,EACA,MAAAJ,EACA,KAAAP,CACJ,EAAI,KAEEY,EAAmB,CAAC,iBAAiB,EAErCC,EAAS,KAAK,OAAS,UAAY,KAAK,OAAS,SAcvD,MAAO,UAZQ,CACX,UAAUD,EAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAC3CD,EAAW,WAAa,GACxBA,EAAW,uBAAyB,uBACpCF,EAAY,YAAc,GAC1BV,EAAO,SAAS,KAAK,IAAI,IAAM,GAC/BW,EAAW,aAAaA,CAAQ,IAAM,eACtCG,EAAM,gBAAkB,GACxBN,EAAQ,SAASA,CAAK,GAAK,GAC3BP,EAAO,QAAQA,CAAI,GAAK,EAC5B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,CAEL,KAC1B,CACJ",
|
|
6
6
|
"names": ["Input", "__name", "attr", "type", "name", "i", "newName", "disabledValue", "oldValue", "newValue", "handler", "value", "text", "autofocus", "tabindex", "disabled", "classes", "btn"]
|
|
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": 5289,
|
|
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": 8462
|
|
15
15
|
},
|
|
16
16
|
"dist/index.js": {
|
|
17
17
|
"imports": [],
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"entryPoint": "src/index.ts",
|
|
22
22
|
"inputs": {
|
|
23
23
|
"src/index.ts": {
|
|
24
|
-
"bytesInOutput":
|
|
24
|
+
"bytesInOutput": 4104
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
"bytes":
|
|
27
|
+
"bytes": 4287
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrate-system/input",
|
|
3
|
+
"version": "0.0.8",
|
|
3
4
|
"type": "module",
|
|
4
|
-
"
|
|
5
|
+
"description": "A minimal parent input component to inherit from",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"files": [
|
|
7
8
|
"./dist/*"
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
},
|
|
48
|
+
"dependencies": {},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@bicycle-codes/dom": "^0.1.2",
|
|
49
50
|
"@substrate-system/debug": "^0.9.0",
|
|
50
51
|
"@substrate-system/dom": "^0.1.7",
|
|
51
52
|
"@substrate-system/tapzero": "^0.10.13",
|
|
@@ -69,5 +70,24 @@
|
|
|
69
70
|
"vite": "^6.0.11"
|
|
70
71
|
},
|
|
71
72
|
"author": "nichoth <nichoth@nichoth.com> (https://nichoth.com)",
|
|
72
|
-
"
|
|
73
|
+
"directories": {
|
|
74
|
+
"example": "example",
|
|
75
|
+
"test": "test"
|
|
76
|
+
},
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "git+https://github.com/substrate-system/input.git"
|
|
80
|
+
},
|
|
81
|
+
"keywords": [
|
|
82
|
+
"input",
|
|
83
|
+
"web",
|
|
84
|
+
"component",
|
|
85
|
+
"parent"
|
|
86
|
+
],
|
|
87
|
+
"types": "./dist/index.d.ts",
|
|
88
|
+
"bugs": {
|
|
89
|
+
"url": "https://github.com/substrate-system/input/issues"
|
|
90
|
+
},
|
|
91
|
+
"homepage": "https://github.com/substrate-system/input#readme",
|
|
92
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
73
93
|
}
|