@substrate-system/button 0.0.31 → 0.0.36
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 +129 -82
- package/README.md +10 -3
- package/dist/client.cjs +39 -46
- package/dist/client.cjs.map +2 -2
- package/dist/client.d.ts +15 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -46
- package/dist/client.js.map +2 -2
- package/dist/client.min.cjs +2 -0
- package/dist/client.min.cjs.map +7 -0
- package/dist/client.min.js +1 -1
- package/dist/client.min.js.map +4 -4
- package/dist/html.cjs +3 -3
- package/dist/html.cjs.map +2 -2
- package/dist/html.js +3 -3
- package/dist/html.js.map +2 -2
- package/dist/html.min.cjs +6 -0
- package/dist/html.min.cjs.map +7 -0
- package/dist/html.min.js +5 -5
- package/dist/html.min.js.map +2 -2
- package/dist/index.cjs +10 -12
- package/dist/index.cjs.map +2 -2
- package/dist/index.css +53 -139
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -12
- package/dist/index.js.map +2 -2
- package/dist/index.min.cjs +2 -0
- package/dist/index.min.cjs.map +7 -0
- package/dist/index.min.css +1 -2
- package/dist/index.min.js +5 -5
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +25 -16
- package/package.json +26 -23
package/LICENSE
CHANGED
|
@@ -1,121 +1,168 @@
|
|
|
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
|
|
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.
|
|
4
13
|
|
|
5
14
|
## Acceptance
|
|
6
15
|
|
|
7
|
-
In order to get any license under these terms, you must agree
|
|
8
|
-
|
|
9
|
-
your licenses.
|
|
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.
|
|
10
18
|
|
|
11
|
-
##
|
|
19
|
+
## Noncommercial Purposes
|
|
12
20
|
|
|
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).
|
|
21
|
+
You may use the software for any noncommercial purpose.
|
|
21
22
|
|
|
22
|
-
##
|
|
23
|
+
## Personal Uses
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
License](#changes-and-new-works-license).
|
|
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
29
|
|
|
30
|
-
##
|
|
30
|
+
## Noncommercial Organizations
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
37
|
|
|
38
|
-
|
|
38
|
+
## Small Business
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
You may use the software for the benefit of your company if it meets all
|
|
41
|
+
these criteria:
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
permitted purpose.
|
|
43
|
+
1. had fewer than 20 total individuals working as employees and
|
|
44
|
+
independent contractors at all times during the last tax year
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
2. earned less than $1,000,000 total revenue in the last tax year
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
51
|
|
|
52
|
-
|
|
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.
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
law. These terms do not limit them.
|
|
57
|
+
## Big Business
|
|
56
58
|
|
|
57
|
-
|
|
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.
|
|
58
92
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
67
118
|
|
|
68
119
|
## No Other Rights
|
|
69
120
|
|
|
70
|
-
These terms do not allow you to sublicense or transfer any of
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
any other licenses.
|
|
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.
|
|
74
124
|
|
|
75
125
|
## Patent Defense
|
|
76
126
|
|
|
77
|
-
If you make any written claim that the software infringes or
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
your
|
|
81
|
-
immediately for work on behalf of your company.
|
|
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.
|
|
82
131
|
|
|
83
132
|
## Violations
|
|
84
133
|
|
|
85
|
-
The first time you are notified in writing that you have
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
end immediately.
|
|
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.
|
|
92
140
|
|
|
93
141
|
## No Liability
|
|
94
142
|
|
|
95
|
-
***As far as the law allows, the software comes as is, without
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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.***
|
|
99
147
|
|
|
100
148
|
## Definitions
|
|
101
149
|
|
|
102
|
-
The **licensor** is the individual or entity offering these
|
|
103
|
-
|
|
104
|
-
available under these terms.
|
|
105
|
-
|
|
106
|
-
**You** refers to the individual or entity agreeing to these
|
|
150
|
+
The **licensor** is the individual or entity offering these terms, and
|
|
151
|
+
the **software** is the software the licensor makes available under these
|
|
107
152
|
terms.
|
|
108
153
|
|
|
109
|
-
**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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,
|
|
115
161
|
contract, or otherwise. Control can be direct or indirect.
|
|
116
162
|
|
|
117
|
-
**Your licenses** are all the licenses granted to you for the
|
|
118
|
-
|
|
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.
|
|
119
168
|
|
|
120
|
-
**Use** means anything you do with the software requiring one
|
|
121
|
-
of your licenses.
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://bundlephobia.com/package/@substrate-system/button)
|
|
8
8
|
[](https://semver.org/)
|
|
9
9
|
[](./CHANGELOG.md)
|
|
10
|
-
[](LICENSE)
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
A button web component, with a visual "loading" state.
|
|
@@ -32,7 +32,7 @@ A button web component, with a visual "loading" state.
|
|
|
32
32
|
- [Module format](#module-format)
|
|
33
33
|
* [Bundler](#bundler-1)
|
|
34
34
|
* [pre-built](#pre-built)
|
|
35
|
-
|
|
35
|
+
- [Example](#example)
|
|
36
36
|
* [Attributes](#attributes)
|
|
37
37
|
|
|
38
38
|
<!-- tocstop -->
|
|
@@ -194,11 +194,18 @@ cp ./node_modules/@substrate-system/button/dist/index.min.css ./public/substrate
|
|
|
194
194
|
</body>
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
+
-------------------
|
|
197
198
|
|
|
198
|
-
|
|
199
|
+
## Example
|
|
199
200
|
|
|
200
201
|
See the example in [./example](./example/).
|
|
201
202
|
|
|
203
|
+
```html
|
|
204
|
+
<substrate-button id="labeled" aria-label="Save your changes">
|
|
205
|
+
Save
|
|
206
|
+
</substrate-button>
|
|
207
|
+
```
|
|
208
|
+
|
|
202
209
|
### Attributes
|
|
203
210
|
|
|
204
211
|
#### spinning
|
package/dist/client.cjs
CHANGED
|
@@ -19,12 +19,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var client_exports = {};
|
|
21
21
|
__export(client_exports, {
|
|
22
|
-
SubstrateButton: () => SubstrateButton
|
|
23
|
-
define: () => define,
|
|
24
|
-
isRegistered: () => isRegistered
|
|
22
|
+
SubstrateButton: () => SubstrateButton
|
|
25
23
|
});
|
|
26
24
|
module.exports = __toCommonJS(client_exports);
|
|
27
|
-
|
|
25
|
+
var import_web_component = require("@substrate-system/web-component");
|
|
26
|
+
class SubstrateButton extends import_web_component.WebComponent.create("substrate-button") {
|
|
28
27
|
static {
|
|
29
28
|
__name(this, "SubstrateButton");
|
|
30
29
|
}
|
|
@@ -32,6 +31,9 @@ class SubstrateButton extends HTMLElement {
|
|
|
32
31
|
static observedAttributes = ["autofocus", "disabled", "spinning"];
|
|
33
32
|
static TAG = "substrate-button";
|
|
34
33
|
_isSpinning;
|
|
34
|
+
static define() {
|
|
35
|
+
(0, import_web_component.define)(SubstrateButton.TAG, SubstrateButton);
|
|
36
|
+
}
|
|
35
37
|
constructor() {
|
|
36
38
|
super();
|
|
37
39
|
const disabled = this.getAttribute("disabled");
|
|
@@ -50,8 +52,11 @@ class SubstrateButton extends HTMLElement {
|
|
|
50
52
|
return !!this.button?.hasAttribute("disabled");
|
|
51
53
|
}
|
|
52
54
|
set disabled(disabledValue) {
|
|
55
|
+
if (this.hasAttribute("disabled") !== disabledValue) {
|
|
56
|
+
this.toggleAttribute("disabled", disabledValue);
|
|
57
|
+
}
|
|
53
58
|
if (!disabledValue) {
|
|
54
|
-
this.
|
|
59
|
+
this.button?.removeAttribute("disabled");
|
|
55
60
|
this.button?.setAttribute("aria-disabled", "false");
|
|
56
61
|
} else {
|
|
57
62
|
this.button?.setAttribute("disabled", "");
|
|
@@ -70,8 +75,17 @@ class SubstrateButton extends HTMLElement {
|
|
|
70
75
|
return this._isSpinning;
|
|
71
76
|
}
|
|
72
77
|
set spinning(value) {
|
|
73
|
-
if (value)
|
|
74
|
-
|
|
78
|
+
if (value) {
|
|
79
|
+
this.classList.add("spinning");
|
|
80
|
+
this.button?.classList.add("spinning");
|
|
81
|
+
this.button?.setAttribute("disabled", "");
|
|
82
|
+
this.setAttribute("spinning", "");
|
|
83
|
+
} else {
|
|
84
|
+
this.classList.remove("spinning");
|
|
85
|
+
this.button?.classList.remove("spinning");
|
|
86
|
+
this.button?.removeAttribute("disabled");
|
|
87
|
+
this.removeAttribute("spinning");
|
|
88
|
+
}
|
|
75
89
|
}
|
|
76
90
|
set type(value) {
|
|
77
91
|
this._setAttribute("type", value);
|
|
@@ -80,11 +94,10 @@ class SubstrateButton extends HTMLElement {
|
|
|
80
94
|
return !!this.button?.hasAttribute("autofocus");
|
|
81
95
|
}
|
|
82
96
|
set autofocus(value) {
|
|
83
|
-
if (value) {
|
|
84
|
-
this.
|
|
85
|
-
} else {
|
|
86
|
-
this._removeAttribute("autofocus");
|
|
97
|
+
if (this.hasAttribute("autofocus") !== value) {
|
|
98
|
+
this.toggleAttribute("autofocus", value);
|
|
87
99
|
}
|
|
100
|
+
this.button?.toggleAttribute("autofocus", value);
|
|
88
101
|
}
|
|
89
102
|
/**
|
|
90
103
|
* Set attributes on the internal button element.
|
|
@@ -121,36 +134,31 @@ class SubstrateButton extends HTMLElement {
|
|
|
121
134
|
* @param {string} newValue The new attribute value
|
|
122
135
|
*/
|
|
123
136
|
handleChange_autofocus(_oldValue, newValue) {
|
|
124
|
-
this.
|
|
137
|
+
this.button?.toggleAttribute("autofocus", newValue !== null);
|
|
125
138
|
}
|
|
126
139
|
handleChange_disabled(_old, newValue) {
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
140
|
+
const isDisabled = newValue !== null;
|
|
141
|
+
if (isDisabled) {
|
|
142
|
+
this.button?.setAttribute("disabled", "");
|
|
143
|
+
this.button?.setAttribute("aria-disabled", "true");
|
|
144
|
+
} else {
|
|
145
|
+
this.button?.removeAttribute("disabled");
|
|
146
|
+
this.button?.setAttribute("aria-disabled", "false");
|
|
147
|
+
}
|
|
130
148
|
}
|
|
131
149
|
handleChange_spinning(_, newValue) {
|
|
132
150
|
if (newValue !== null) {
|
|
133
|
-
this.classList.add("
|
|
151
|
+
this.classList.add("spinning");
|
|
152
|
+
this.button?.classList.add("spinning");
|
|
153
|
+
this.button?.setAttribute("disabled", "");
|
|
134
154
|
this.button?.setAttribute("aria-busy", "true");
|
|
135
155
|
} else {
|
|
136
|
-
this.classList.remove("
|
|
156
|
+
this.classList.remove("spinning");
|
|
157
|
+
this.button?.classList.remove("spinning");
|
|
158
|
+
this.button?.removeAttribute("disabled");
|
|
137
159
|
this.button?.setAttribute("aria-busy", "false");
|
|
138
160
|
}
|
|
139
161
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Runs when the value of an attribute is changed.
|
|
142
|
-
*
|
|
143
|
-
* Should add methods to this class like `handleChange_class`, to
|
|
144
|
-
* listen for changes to `class` attribute.
|
|
145
|
-
*
|
|
146
|
-
* @param {string} name The attribute name
|
|
147
|
-
* @param {string} oldValue The old attribute value
|
|
148
|
-
* @param {string} newValue The new attribute value
|
|
149
|
-
*/
|
|
150
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
151
|
-
const handler = this[`handleChange_${name}`];
|
|
152
|
-
handler && handler.call(this, oldValue, newValue);
|
|
153
|
-
}
|
|
154
162
|
connectedCallback() {
|
|
155
163
|
this.render();
|
|
156
164
|
this._setupKeyboardHandlers();
|
|
@@ -163,22 +171,7 @@ class SubstrateButton extends HTMLElement {
|
|
|
163
171
|
}
|
|
164
172
|
});
|
|
165
173
|
}
|
|
166
|
-
static define() {
|
|
167
|
-
return define(SubstrateButton.TAG, SubstrateButton);
|
|
168
|
-
}
|
|
169
174
|
render() {
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
|
-
function isRegistered(elName) {
|
|
173
|
-
return document.createElement(elName).constructor !== window.HTMLElement;
|
|
174
|
-
}
|
|
175
|
-
__name(isRegistered, "isRegistered");
|
|
176
|
-
function define(name, element) {
|
|
177
|
-
if (!window) return;
|
|
178
|
-
if (!("customElements" in window)) return;
|
|
179
|
-
if (!isRegistered(name)) {
|
|
180
|
-
window.customElements.define(name, element);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
__name(define, "define");
|
|
184
177
|
//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'substrate-button': SubstrateButton\n }\n}\n\n/**\n * This is the lightweight version for browsers
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { WebComponent, define } from '@substrate-system/web-component'\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'substrate-button': SubstrateButton\n }\n}\n\n/**\n * This is the lightweight version for browsers.\n * It \"hydrates\" only, meaining sets up event listeners.\n * It does not know how to render itself.\n */\n\nexport class SubstrateButton extends WebComponent.create('substrate-button') {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled', 'spinning']\n static TAG = 'substrate-button'\n _isSpinning:boolean\n\n static define () {\n define(SubstrateButton.TAG, SubstrateButton)\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 this.autofocus = (this.getAttribute('autofocus') !== null)\n this._isSpinning = (this.getAttribute('spinning') !== null)\n }\n\n get form ():HTMLFormElement|undefined|null {\n return this.button?.form\n }\n\n get disabled ():boolean {\n return !!(this.button?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n // Reflect to host attribute; guard against re-entrancy\n if (this.hasAttribute('disabled') !== disabledValue) {\n this.toggleAttribute('disabled', disabledValue)\n }\n if (!disabledValue) {\n this.button?.removeAttribute('disabled')\n this.button?.setAttribute('aria-disabled', 'false')\n } else {\n this.button?.setAttribute('disabled', '')\n this.button?.setAttribute('aria-disabled', 'true')\n }\n }\n\n get type ():string|null|undefined {\n return this.button?.getAttribute('type')\n }\n\n get tabindex ():number {\n const i = this.button?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n get spinning ():boolean {\n return this._isSpinning\n }\n\n set spinning (value:boolean) {\n if (value) {\n this.classList.add('spinning')\n this.button?.classList.add('spinning')\n this.button?.setAttribute('disabled', '')\n this.setAttribute('spinning', '')\n } else {\n this.classList.remove('spinning')\n this.button?.classList.remove('spinning')\n this.button?.removeAttribute('disabled')\n this.removeAttribute('spinning')\n }\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get autofocus ():boolean {\n return !!(this.button?.hasAttribute('autofocus'))\n }\n\n set autofocus (value:boolean) {\n // Reflect to host attribute; guard against re-entrancy\n if (this.hasAttribute('autofocus') !== value) {\n this.toggleAttribute('autofocus', value)\n }\n this.button?.toggleAttribute('autofocus', value)\n }\n\n /**\n * Set attributes on the internal button element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (value === false) {\n // false means remove the attribute\n this._removeAttribute(name)\n this.button?.removeAttribute(name)\n } else {\n if (value === true) {\n // true means set the attribute with no value\n return this.button?.setAttribute(name, '')\n }\n\n if (value === null) {\n // null means remove\n return this._removeAttribute(name)\n }\n\n // else, set value to a string\n this.button?.setAttribute(name, value)\n }\n }\n\n /**\n * Remove from `this` and also button child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.button?.removeAttribute(name)\n }\n\n get button ():HTMLButtonElement|null {\n return this.querySelector('button')\n }\n\n /**\n * Handle 'autofocus' 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_autofocus (_oldValue:string, newValue:string|null) {\n this.button?.toggleAttribute('autofocus', newValue !== null)\n }\n\n handleChange_disabled (_old:string|null, newValue:string|null) {\n const isDisabled = newValue !== null\n if (isDisabled) {\n this.button?.setAttribute('disabled', '')\n this.button?.setAttribute('aria-disabled', 'true')\n } else {\n this.button?.removeAttribute('disabled')\n this.button?.setAttribute('aria-disabled', 'false')\n }\n }\n\n handleChange_spinning (_, newValue:boolean) {\n if (newValue !== null) {\n this.classList.add('spinning')\n this.button?.classList.add('spinning')\n this.button?.setAttribute('disabled', '')\n this.button?.setAttribute('aria-busy', 'true')\n } else {\n this.classList.remove('spinning')\n this.button?.classList.remove('spinning')\n this.button?.removeAttribute('disabled')\n this.button?.setAttribute('aria-busy', 'false')\n }\n }\n\n connectedCallback () {\n // connect event listeners\n this.render()\n this._setupKeyboardHandlers()\n }\n\n _setupKeyboardHandlers () {\n // Space and Enter should trigger click\n this.button?.addEventListener('keydown', (e:KeyboardEvent) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault()\n this.button?.click()\n }\n })\n }\n\n render () {\n // noop\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAqC;AAe9B,MAAM,wBAAwB,kCAAa,OAAO,kBAAkB,EAAE;AAAA,EAf7E,OAe6E;AAAA;AAAA;AAAA;AAAA,EAEzE,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO,MAAM;AAAA,EAC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AAuB,MAAkB,UAAsB;AAC3D,UAAM,aAAa,aAAa;AAChC,QAAI,YAAY;AACZ,WAAK,QAAQ,aAAa,YAAY,EAAE;AACxC,WAAK,QAAQ,aAAa,iBAAiB,MAAM;AAAA,IACrD,OAAO;AACH,WAAK,QAAQ,gBAAgB,UAAU;AACvC,WAAK,QAAQ,aAAa,iBAAiB,OAAO;AAAA,IACtD;AAAA,EACJ;AAAA,EAEA,sBAAuB,GAAG,UAAkB;AACxC,QAAI,aAAa,MAAM;AACnB,WAAK,UAAU,IAAI,UAAU;AAC7B,WAAK,QAAQ,UAAU,IAAI,UAAU;AACrC,WAAK,QAAQ,aAAa,YAAY,EAAE;AACxC,WAAK,QAAQ,aAAa,aAAa,MAAM;AAAA,IACjD,OAAO;AACH,WAAK,UAAU,OAAO,UAAU;AAChC,WAAK,QAAQ,UAAU,OAAO,UAAU;AACxC,WAAK,QAAQ,gBAAgB,UAAU;AACvC,WAAK,QAAQ,aAAa,aAAa,OAAO;AAAA,IAClD;AAAA,EACJ;AAAA,EAEA,oBAAqB;AAEjB,SAAK,OAAO;AACZ,SAAK,uBAAuB;AAAA,EAChC;AAAA,EAEA,yBAA0B;AAEtB,SAAK,QAAQ,iBAAiB,WAAW,CAAC,MAAoB;AAC1D,UAAI,EAAE,QAAQ,OAAO,EAAE,QAAQ,SAAS;AACpC,UAAE,eAAe;AACjB,aAAK,QAAQ,MAAM;AAAA,MACvB;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,SAAU;AAAA,EAEV;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { WebComponent } from '@substrate-system/web-component';
|
|
1
2
|
declare global {
|
|
2
3
|
interface HTMLElementTagNameMap {
|
|
3
4
|
'substrate-button': SubstrateButton;
|
|
4
5
|
}
|
|
5
6
|
}
|
|
7
|
+
declare const SubstrateButton_base: typeof WebComponent & {
|
|
8
|
+
new (...args: any[]): WebComponent;
|
|
9
|
+
TAG: string;
|
|
10
|
+
define: typeof WebComponent.define;
|
|
11
|
+
event: typeof WebComponent.event;
|
|
12
|
+
};
|
|
6
13
|
/**
|
|
7
|
-
* This is the lightweight version for browsers
|
|
14
|
+
* This is the lightweight version for browsers.
|
|
15
|
+
* It "hydrates" only, meaining sets up event listeners.
|
|
16
|
+
* It does not know how to render itself.
|
|
8
17
|
*/
|
|
9
|
-
export declare class SubstrateButton extends
|
|
18
|
+
export declare class SubstrateButton extends SubstrateButton_base {
|
|
10
19
|
static observedAttributes: string[];
|
|
11
20
|
static TAG: string;
|
|
12
21
|
_isSpinning: boolean;
|
|
22
|
+
static define(): void;
|
|
13
23
|
constructor();
|
|
14
24
|
get form(): HTMLFormElement | undefined | null;
|
|
15
25
|
get disabled(): boolean;
|
|
@@ -37,25 +47,12 @@ export declare class SubstrateButton extends HTMLElement {
|
|
|
37
47
|
* @param {string} oldValue The old attribute value
|
|
38
48
|
* @param {string} newValue The new attribute value
|
|
39
49
|
*/
|
|
40
|
-
handleChange_autofocus(_oldValue: string, newValue: string): void;
|
|
41
|
-
handleChange_disabled(_old:
|
|
50
|
+
handleChange_autofocus(_oldValue: string, newValue: string | null): void;
|
|
51
|
+
handleChange_disabled(_old: string | null, newValue: string | null): void;
|
|
42
52
|
handleChange_spinning(_: any, newValue: boolean): void;
|
|
43
|
-
/**
|
|
44
|
-
* Runs when the value of an attribute is changed.
|
|
45
|
-
*
|
|
46
|
-
* Should add methods to this class like `handleChange_class`, to
|
|
47
|
-
* listen for changes to `class` attribute.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} name The attribute name
|
|
50
|
-
* @param {string} oldValue The old attribute value
|
|
51
|
-
* @param {string} newValue The new attribute value
|
|
52
|
-
*/
|
|
53
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
54
53
|
connectedCallback(): void;
|
|
55
54
|
_setupKeyboardHandlers(): void;
|
|
56
|
-
static define(): void;
|
|
57
55
|
render(): void;
|
|
58
56
|
}
|
|
59
|
-
export
|
|
60
|
-
export declare function define(name: string, element: CustomElementConstructor): void;
|
|
57
|
+
export {};
|
|
61
58
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,MAAM,iCAAiC,CAAA;AAGtE,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,kBAAkB,EAAE,eAAe,CAAA;KACtC;CACJ;;;;;;;AAED;;;;GAIG;AAEH,qBAAa,eAAgB,SAAQ,oBAAuC;IAExE,MAAM,CAAC,kBAAkB,WAAwC;IACjE,MAAM,CAAC,GAAG,SAAqB;IAC/B,WAAW,EAAC,OAAO,CAAA;IAEnB,MAAM,CAAC,MAAM;;IAiBb,IAAI,IAAI,IAAI,eAAe,GAAC,SAAS,GAAC,IAAI,CAEzC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAE,aAAa,EAAC,OAAO,EAYlC;IAED,IAAI,IAAI,IAAI,MAAM,GAAC,IAAI,GAAC,SAAS,CAEhC;IAED,IAAI,QAAQ,IAAI,MAAM,CAIrB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAE,KAAK,EAAC,OAAO,EAY1B;IAED,IAAI,IAAI,CAAE,KAAK,EAAC,MAAM,EAErB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,SAAS,CAAE,KAAK,EAAC,OAAO,EAM3B;IAED;;OAEG;IACH,aAAa,CAAE,IAAI,EAAC,MAAM,EAAE,KAAK,EAAC,OAAO,GAAC,MAAM,GAAC,IAAI,GAAE,IAAI;IAqB3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