@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/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
3
|
+
import { WebComponent, define } from "@substrate-system/web-component";
|
|
4
|
+
class SubstrateButton extends WebComponent.create("substrate-button") {
|
|
4
5
|
static {
|
|
5
6
|
__name(this, "SubstrateButton");
|
|
6
7
|
}
|
|
@@ -8,6 +9,9 @@ class SubstrateButton extends HTMLElement {
|
|
|
8
9
|
static observedAttributes = ["autofocus", "disabled", "spinning"];
|
|
9
10
|
static TAG = "substrate-button";
|
|
10
11
|
_isSpinning;
|
|
12
|
+
static define() {
|
|
13
|
+
define(SubstrateButton.TAG, SubstrateButton);
|
|
14
|
+
}
|
|
11
15
|
constructor() {
|
|
12
16
|
super();
|
|
13
17
|
const disabled = this.getAttribute("disabled");
|
|
@@ -26,8 +30,11 @@ class SubstrateButton extends HTMLElement {
|
|
|
26
30
|
return !!this.button?.hasAttribute("disabled");
|
|
27
31
|
}
|
|
28
32
|
set disabled(disabledValue) {
|
|
33
|
+
if (this.hasAttribute("disabled") !== disabledValue) {
|
|
34
|
+
this.toggleAttribute("disabled", disabledValue);
|
|
35
|
+
}
|
|
29
36
|
if (!disabledValue) {
|
|
30
|
-
this.
|
|
37
|
+
this.button?.removeAttribute("disabled");
|
|
31
38
|
this.button?.setAttribute("aria-disabled", "false");
|
|
32
39
|
} else {
|
|
33
40
|
this.button?.setAttribute("disabled", "");
|
|
@@ -46,8 +53,17 @@ class SubstrateButton extends HTMLElement {
|
|
|
46
53
|
return this._isSpinning;
|
|
47
54
|
}
|
|
48
55
|
set spinning(value) {
|
|
49
|
-
if (value)
|
|
50
|
-
|
|
56
|
+
if (value) {
|
|
57
|
+
this.classList.add("spinning");
|
|
58
|
+
this.button?.classList.add("spinning");
|
|
59
|
+
this.button?.setAttribute("disabled", "");
|
|
60
|
+
this.setAttribute("spinning", "");
|
|
61
|
+
} else {
|
|
62
|
+
this.classList.remove("spinning");
|
|
63
|
+
this.button?.classList.remove("spinning");
|
|
64
|
+
this.button?.removeAttribute("disabled");
|
|
65
|
+
this.removeAttribute("spinning");
|
|
66
|
+
}
|
|
51
67
|
}
|
|
52
68
|
set type(value) {
|
|
53
69
|
this._setAttribute("type", value);
|
|
@@ -56,11 +72,10 @@ class SubstrateButton extends HTMLElement {
|
|
|
56
72
|
return !!this.button?.hasAttribute("autofocus");
|
|
57
73
|
}
|
|
58
74
|
set autofocus(value) {
|
|
59
|
-
if (value) {
|
|
60
|
-
this.
|
|
61
|
-
} else {
|
|
62
|
-
this._removeAttribute("autofocus");
|
|
75
|
+
if (this.hasAttribute("autofocus") !== value) {
|
|
76
|
+
this.toggleAttribute("autofocus", value);
|
|
63
77
|
}
|
|
78
|
+
this.button?.toggleAttribute("autofocus", value);
|
|
64
79
|
}
|
|
65
80
|
/**
|
|
66
81
|
* Set attributes on the internal button element.
|
|
@@ -97,36 +112,31 @@ class SubstrateButton extends HTMLElement {
|
|
|
97
112
|
* @param {string} newValue The new attribute value
|
|
98
113
|
*/
|
|
99
114
|
handleChange_autofocus(_oldValue, newValue) {
|
|
100
|
-
this.
|
|
115
|
+
this.button?.toggleAttribute("autofocus", newValue !== null);
|
|
101
116
|
}
|
|
102
117
|
handleChange_disabled(_old, newValue) {
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
118
|
+
const isDisabled = newValue !== null;
|
|
119
|
+
if (isDisabled) {
|
|
120
|
+
this.button?.setAttribute("disabled", "");
|
|
121
|
+
this.button?.setAttribute("aria-disabled", "true");
|
|
122
|
+
} else {
|
|
123
|
+
this.button?.removeAttribute("disabled");
|
|
124
|
+
this.button?.setAttribute("aria-disabled", "false");
|
|
125
|
+
}
|
|
106
126
|
}
|
|
107
127
|
handleChange_spinning(_, newValue) {
|
|
108
128
|
if (newValue !== null) {
|
|
109
|
-
this.classList.add("
|
|
129
|
+
this.classList.add("spinning");
|
|
130
|
+
this.button?.classList.add("spinning");
|
|
131
|
+
this.button?.setAttribute("disabled", "");
|
|
110
132
|
this.button?.setAttribute("aria-busy", "true");
|
|
111
133
|
} else {
|
|
112
|
-
this.classList.remove("
|
|
134
|
+
this.classList.remove("spinning");
|
|
135
|
+
this.button?.classList.remove("spinning");
|
|
136
|
+
this.button?.removeAttribute("disabled");
|
|
113
137
|
this.button?.setAttribute("aria-busy", "false");
|
|
114
138
|
}
|
|
115
139
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Runs when the value of an attribute is changed.
|
|
118
|
-
*
|
|
119
|
-
* Should add methods to this class like `handleChange_class`, to
|
|
120
|
-
* listen for changes to `class` attribute.
|
|
121
|
-
*
|
|
122
|
-
* @param {string} name The attribute name
|
|
123
|
-
* @param {string} oldValue The old attribute value
|
|
124
|
-
* @param {string} newValue The new attribute value
|
|
125
|
-
*/
|
|
126
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
127
|
-
const handler = this[`handleChange_${name}`];
|
|
128
|
-
handler && handler.call(this, oldValue, newValue);
|
|
129
|
-
}
|
|
130
140
|
connectedCallback() {
|
|
131
141
|
this.render();
|
|
132
142
|
this._setupKeyboardHandlers();
|
|
@@ -139,27 +149,10 @@ class SubstrateButton extends HTMLElement {
|
|
|
139
149
|
}
|
|
140
150
|
});
|
|
141
151
|
}
|
|
142
|
-
static define() {
|
|
143
|
-
return define(SubstrateButton.TAG, SubstrateButton);
|
|
144
|
-
}
|
|
145
152
|
render() {
|
|
146
153
|
}
|
|
147
154
|
}
|
|
148
|
-
function isRegistered(elName) {
|
|
149
|
-
return document.createElement(elName).constructor !== window.HTMLElement;
|
|
150
|
-
}
|
|
151
|
-
__name(isRegistered, "isRegistered");
|
|
152
|
-
function define(name, element) {
|
|
153
|
-
if (!window) return;
|
|
154
|
-
if (!("customElements" in window)) return;
|
|
155
|
-
if (!isRegistered(name)) {
|
|
156
|
-
window.customElements.define(name, element);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
__name(define, "define");
|
|
160
155
|
export {
|
|
161
|
-
SubstrateButton
|
|
162
|
-
define,
|
|
163
|
-
isRegistered
|
|
156
|
+
SubstrateButton
|
|
164
157
|
};
|
|
165
158
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.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": ";;
|
|
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,SAAS,cAAc,cAAc;AAe9B,MAAM,wBAAwB,aAAa,OAAO,kBAAkB,EAAE;AAAA,EAf7E,OAe6E;AAAA;AAAA;AAAA;AAAA,EAEzE,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO,MAAM;AAAA,EACb;AAAA,EAEA,OAAO,SAAU;AACb,WAAO,gBAAgB,KAAK,eAAe;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;AACA,SAAK,YAAa,KAAK,aAAa,WAAW,MAAM;AACrD,SAAK,cAAe,KAAK,aAAa,UAAU,MAAM;AAAA,EAC1D;AAAA,EAEA,IAAI,OAAuC;AACvC,WAAO,KAAK,QAAQ;AAAA,EACxB;AAAA,EAEA,IAAI,WAAoB;AACpB,WAAO,CAAC,CAAE,KAAK,QAAQ,aAAa,UAAU;AAAA,EAClD;AAAA,EAEA,IAAI,SAAU,eAAuB;AAEjC,QAAI,KAAK,aAAa,UAAU,MAAM,eAAe;AACjD,WAAK,gBAAgB,YAAY,aAAa;AAAA,IAClD;AACA,QAAI,CAAC,eAAe;AAChB,WAAK,QAAQ,gBAAgB,UAAU;AACvC,WAAK,QAAQ,aAAa,iBAAiB,OAAO;AAAA,IACtD,OAAO;AACH,WAAK,QAAQ,aAAa,YAAY,EAAE;AACxC,WAAK,QAAQ,aAAa,iBAAiB,MAAM;AAAA,IACrD;AAAA,EACJ;AAAA,EAEA,IAAI,OAA8B;A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,eAAe;AACjB,aAAK,QAAQ,MAAM;AAAA,MACvB;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,SAAU;AAAA,EAEV;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var o=(i,t)=>n(i,"name",{value:t,configurable:!0});var h=(i,t)=>{for(var e in t)n(i,e,{get:t[e],enumerable:!0})},g=(i,t,e,b)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!d.call(i,s)&&s!==e&&n(i,s,{get:()=>t[s],enumerable:!(b=a(t,s))||b.enumerable});return i};var A=i=>g(n({},"__esModule",{value:!0}),i);var c={};h(c,{SubstrateButton:()=>u});module.exports=A(c);var r=require("@substrate-system/web-component");class u extends r.WebComponent.create("substrate-button"){static{o(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;static define(){(0,r.define)(u.TAG,u)}constructor(){super(),this.getAttribute("disabled")!==null&&setTimeout(()=>{this.disabled=!0},0),this.autofocus=this.getAttribute("autofocus")!==null,this._isSpinning=this.getAttribute("spinning")!==null}get form(){return this.button?.form}get disabled(){return!!this.button?.hasAttribute("disabled")}set disabled(t){this.hasAttribute("disabled")!==t&&this.toggleAttribute("disabled",t),t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-disabled","false"))}get type(){return this.button?.getAttribute("type")}get tabindex(){const t=this.button?.getAttribute("tabindex");return t?parseInt(t):0}get spinning(){return this._isSpinning}set spinning(t){t?(this.classList.add("spinning"),this.button?.classList.add("spinning"),this.button?.setAttribute("disabled",""),this.setAttribute("spinning","")):(this.classList.remove("spinning"),this.button?.classList.remove("spinning"),this.button?.removeAttribute("disabled"),this.removeAttribute("spinning"))}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){this.hasAttribute("autofocus")!==t&&this.toggleAttribute("autofocus",t),this.button?.toggleAttribute("autofocus",t)}_setAttribute(t,e){if(e===!1)this._removeAttribute(t),this.button?.removeAttribute(t);else{if(e===!0)return this.button?.setAttribute(t,"");if(e===null)return this._removeAttribute(t);this.button?.setAttribute(t,e)}}_removeAttribute(t){this.removeAttribute(t),this.button?.removeAttribute(t)}get button(){return this.querySelector("button")}handleChange_autofocus(t,e){this.button?.toggleAttribute("autofocus",e!==null)}handleChange_disabled(t,e){e!==null?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-disabled","false"))}handleChange_spinning(t,e){e!==null?(this.classList.add("spinning"),this.button?.classList.add("spinning"),this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-busy","true")):(this.classList.remove("spinning"),this.button?.classList.remove("spinning"),this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-busy","false"))}connectedCallback(){this.render(),this._setupKeyboardHandlers()}_setupKeyboardHandlers(){this.button?.addEventListener("keydown",t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.button?.click())})}render(){}}
|
|
2
|
+
//# sourceMappingURL=client.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/client.ts"],
|
|
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": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAqC,2CA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Q,aAAa,YAAa,MAAM,IAE7C,KAAK,UAAU,OAAO,UAAU,EAChC,KAAK,QAAQ,UAAU,OAAO,UAAU,EACxC,KAAK,QAAQ,gBAAgB,UAAU,EACvC,KAAK,QAAQ,aAAa,YAAa,OAAO,EAEtD,CAEA,mBAAqB,CAEjB,KAAK,OAAO,EACZ,KAAK,uBAAuB,CAChC,CAEA,wBAA0B,CAEtB,KAAK,QAAQ,iBAAiB,UAAYG,GAAoB,EACtDA,EAAE,MAAQ,KAAOA,EAAE,MAAQ,WAC3BA,EAAE,eAAe,EACjB,KAAK,QAAQ,MAAM,EAE3B,CAAC,CACL,CAEA,QAAU,CAEV,CACJ",
|
|
6
|
+
"names": ["client_exports", "__export", "SubstrateButton", "__toCommonJS", "import_web_component", "SubstrateButton", "__name", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "e"]
|
|
7
|
+
}
|
package/dist/client.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _=Object.defineProperty;var s=(i,t)=>_(i,"name",{value:t,configurable:!0});var E=Object.defineProperty,L=s((i,t)=>E(i,"name",{value:t,configurable:!0}),"__name");function b(i){return Object.keys(i).reduce((t,e)=>{let n=i[e];return n?typeof n=="boolean"?n?(t+` ${e}`).trim():t:Array.isArray(n)?t+` ${e}="${n.join(" ")}"`:(t+` ${e}="${n}"`).trim():t},"")}s(b,"toAttributes");L(b,"toAttributes");var y=Object.defineProperty,d=s((i,t)=>y(i,"name",{value:t,configurable:!0}),"__name");function h(i){return document.createElement(i).constructor!==window.HTMLElement}s(h,"isRegistered");d(h,"isRegistered");function w(i,t){window&&"customElements"in window&&(h(i)||window.customElements.define(i,t))}s(w,"define");d(w,"define");var S=document.querySelector.bind(document),q=document.querySelectorAll.bind(document);function l(i,t){return i.matches||(i=i.parentElement),i.matches(t)?i:i.closest(t)}s(l,"match");d(l,"match");var T=Object.defineProperty,a=s((i,t)=>T(i,"name",{value:t,configurable:!0}),"__name"),o=class i extends window.HTMLElement{static{s(this,"WebComponent")}static{a(this,"WebComponent")}static TAG="";TAG="";static match(t){return l(t,this.TAG)}_globalWildcardListeners=new Set;_namespacedWildcardListeners=new Set;static create(t){let e=class extends i{static{s(this,"CreatedClass")}static{a(this,"CreatedClass")}static TAG=t;TAG=t;render(){throw new Error("`render` should be implemented by children")}};return e.define=function(){return i.define.call(this)},e.event=function(n){return i.event.call(this,n)},e}static define(){u(this.TAG,this)}async attributeChangedCallback(t,e,n){let r=this[`handleChange_${t}`];r&&await r.call(this,e,n)}addEventListener(t,e,n){t===i.event.call(this,"*")?this._namespacedWildcardListeners.add({listener:e,options:n}):t==="*"?e&&this._globalWildcardListeners.add({listener:e,options:n}):super.addEventListener(t,e,n)}_notifyNamespacedWildcardListeners(t){if(this._namespacedWildcardListeners.size===0)return;let e=this.TAG;!e||!t.type.startsWith(`${e}:`)||this._namespacedWildcardListeners.forEach(({listener:n})=>{try{typeof n=="function"?n.call(this,t):n&&typeof n.handleEvent=="function"&&n.handleEvent(t)}catch(r){console.error("Error in namespaced wildcard event listener:",r)}})}_notifyGlobalWildcardListeners(t){this._globalWildcardListeners.size!==0&&this._globalWildcardListeners.forEach(({listener:e})=>{try{typeof e=="function"?e.call(this,t):e&&typeof e.handleEvent=="function"&&e.handleEvent(t)}catch(n){console.error("Error in global wildcard event listener:",n)}})}connectedCallback(){this.render()}qs(t){return this.querySelector(t)}qsa(t){return this.querySelectorAll(t)}static event(t){return f(this.TAG,t)}emit(t,e={}){if(t==="*")throw new Error('Do not emit the literal "*"');let{bubbles:n=!0,cancelable:r=!0,detail:p}=e,A=`${this.TAG}:${t}`,c=new CustomEvent(A,{bubbles:n,cancelable:r,detail:p}),v=this.dispatchEvent(c);return this._notifyNamespacedWildcardListeners(c),v}dispatchEvent(t){let e=super.dispatchEvent(t);return this._notifyGlobalWildcardListeners(t),e}dispatch(t,e={}){let n=new CustomEvent(t,{bubbles:e.bubbles===void 0?!0:e.bubbles,cancelable:e.cancelable===void 0?!0:e.cancelable,detail:e.detail});return this.dispatchEvent(n)}on(t,e,n){let r=i.event.call(this,t);this.addEventListener(r,e,n)}removeEventListener(t,e,n){if(t===i.event.call(this,"*")){if(e&&this._namespacedWildcardListeners){for(let r of this._namespacedWildcardListeners)if(r.listener===e){this._namespacedWildcardListeners.delete(r);break}}}else if(t==="*"){if(e&&this._globalWildcardListeners){for(let r of this._globalWildcardListeners)if(r.listener===e){this._globalWildcardListeners.delete(r);break}}}else super.removeEventListener(t,e,n)}};function f(i,t){return`${i}:${t}`}s(f,"eventName");a(f,"eventName");function m(i){return document.createElement(i).constructor!==window.HTMLElement}s(m,"isRegistered");a(m,"isRegistered");function u(i,t){window&&"customElements"in window&&(m(i)||window.customElements.define(i,t))}s(u,"define");a(u,"define");var g=class i extends o.create("substrate-button"){static{s(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;static define(){u(i.TAG,i)}constructor(){super(),this.getAttribute("disabled")!==null&&setTimeout(()=>{this.disabled=!0},0),this.autofocus=this.getAttribute("autofocus")!==null,this._isSpinning=this.getAttribute("spinning")!==null}get form(){return this.button?.form}get disabled(){return!!this.button?.hasAttribute("disabled")}set disabled(t){this.hasAttribute("disabled")!==t&&this.toggleAttribute("disabled",t),t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-disabled","false"))}get type(){return this.button?.getAttribute("type")}get tabindex(){let t=this.button?.getAttribute("tabindex");return t?parseInt(t):0}get spinning(){return this._isSpinning}set spinning(t){t?(this.classList.add("spinning"),this.button?.classList.add("spinning"),this.button?.setAttribute("disabled",""),this.setAttribute("spinning","")):(this.classList.remove("spinning"),this.button?.classList.remove("spinning"),this.button?.removeAttribute("disabled"),this.removeAttribute("spinning"))}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){this.hasAttribute("autofocus")!==t&&this.toggleAttribute("autofocus",t),this.button?.toggleAttribute("autofocus",t)}_setAttribute(t,e){if(e===!1)this._removeAttribute(t),this.button?.removeAttribute(t);else{if(e===!0)return this.button?.setAttribute(t,"");if(e===null)return this._removeAttribute(t);this.button?.setAttribute(t,e)}}_removeAttribute(t){this.removeAttribute(t),this.button?.removeAttribute(t)}get button(){return this.querySelector("button")}handleChange_autofocus(t,e){this.button?.toggleAttribute("autofocus",e!==null)}handleChange_disabled(t,e){e!==null?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-disabled","false"))}handleChange_spinning(t,e){e!==null?(this.classList.add("spinning"),this.button?.classList.add("spinning"),this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-busy","true")):(this.classList.remove("spinning"),this.button?.classList.remove("spinning"),this.button?.removeAttribute("disabled"),this.button?.setAttribute("aria-busy","false"))}connectedCallback(){this.render(),this._setupKeyboardHandlers()}_setupKeyboardHandlers(){this.button?.addEventListener("keydown",t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.button?.click())})}render(){}};export{g as SubstrateButton};
|
|
2
2
|
//# sourceMappingURL=client.min.js.map
|
package/dist/client.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 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 + server-side rendering.\n */\nexport class SubstrateButton extends HTMLElement {\n // for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled', 'spinning']\n static TAG = 'substrate-button'\n _isSpinning:boolean\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 if (!disabledValue) {\n this._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) this.setAttribute('spinning', '')\n else this.removeAttribute('spinning')\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 if (value) {\n this._setAttribute('autofocus', value)\n } else {\n this._removeAttribute('autofocus')\n }\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) {\n this._setAttribute('autofocus', newValue)\n }\n\n handleChange_disabled (_old, newValue:boolean|string) {\n this.disabled = (newValue !== null)\n if (newValue === null) this.button?.removeAttribute('disabled')\n else this.button?.setAttribute('disabled', '' + newValue)\n }\n\n handleChange_spinning (_, newValue:boolean) {\n if (newValue !== null) {\n this.classList.add('substrate-loading')\n this.button?.setAttribute('aria-busy', 'true')\n } else {\n this.classList.remove('substrate-loading')\n this.button?.setAttribute('aria-busy', 'false')\n }\n }\n\n /**\n * Runs when the value of an attribute is changed.\n *\n * Should add methods to this class like `handleChange_class`, to\n * listen for changes to `class` attribute.\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 }\n\n connectedCallback () {\n // connect event listeners\n this.render()\n this._setupKeyboardHandlers()\n }\n\n _setupKeyboardHandlers () {\n // Ensure keyboard accessibility - 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 static define ():void {\n return define(SubstrateButton.TAG, SubstrateButton)\n }\n\n render () {\n // noop\n }\n}\n\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor):void {\n if (!window) return\n if (!('customElements' in window)) return\n\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../node_modules/@substrate-system/web-component/src/attributes.ts", "../node_modules/@substrate-system/web-component/src/util.ts", "../node_modules/@substrate-system/web-component/src/index.ts", "../src/client.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", "import { match as _match } from './util.js'\n\ninterface WildcardListenerEntry {\n listener:EventListenerOrEventListenerObject\n options?:boolean|AddEventListenerOptions\n}\n\nexport abstract class WebComponent extends window.HTMLElement {\n static TAG:string = ''\n TAG:string = ''\n\n static match (el:HTMLElement):HTMLElement|null {\n return _match(el, this.TAG)\n }\n\n /**\n * Store global wildcard listeners (listen to all events)\n * Triggered by ALL events dispatched through this element\n * @private\n */\n private _globalWildcardListeners:Set<WildcardListenerEntry> = new Set()\n\n /**\n * Store namespaced wildcard listeners (listen to 'component-name:*')\n * Triggered by events from emit() that match this component's namespace\n * @private\n */\n private _namespacedWildcardListeners:Set<WildcardListenerEntry> = new Set()\n\n static create (elementName:string):typeof WebComponent & {\n new (...args:any[]):WebComponent;\n TAG:string;\n define: typeof WebComponent.define;\n event: typeof WebComponent.event;\n } {\n const CreatedClass = class extends WebComponent {\n static TAG = elementName\n TAG = elementName\n render () {\n throw new Error('`render` should be implemented by children')\n }\n }\n\n // Copy static methods with proper binding\n CreatedClass.define = function () {\n return WebComponent.define.call(this)\n }\n CreatedClass.event = function (evType:string) {\n return WebComponent.event.call(this, evType)\n }\n\n return CreatedClass\n }\n\n static define<T extends {\n new (...args:any[]):WebComponent;\n TAG:string;\n }>(this:T) {\n define(this.TAG, this)\n }\n\n /**\n * Runs when the value of an attribute is changed.\n *\n * Depends on `static observedAttributes`.\n *\n * Should name methods like `handleChange_disabled`.\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 ):Promise<void> {\n const handler = this[`handleChange_${name}`]\n if (handler) {\n await handler.call(this, oldValue, newValue)\n }\n }\n\n /**\n * Enhanced addEventListener that supports wildcards:\n * - Component.event('*') - Listen to all namespaced events for this\n * component (e.g., 'my-component:*')\n * - '*' - Listen to ALL events (namespaced and non-namespaced, including\n * normal DOM events)\n *\n * @param type - Event type, Component.event('*') for namespaced wildcard,\n * or '*' for global wildcard\n * @param listener - Event listener function or object\n * @param options - Event listener options\n */\n addEventListener (\n type:string,\n listener:EventListenerOrEventListenerObject,\n options?:boolean|AddEventListenerOptions\n ): void {\n if (type === WebComponent.event.call(this, '*')) {\n // Handle namespaced wildcard listener (component-name:*)\n this._namespacedWildcardListeners.add({ listener, options })\n } else if (type === '*') {\n // Handle global wildcard listener (all events)\n if (listener) {\n this._globalWildcardListeners.add({ listener, options })\n }\n } else {\n // Normal event listener - delegate to native implementation\n super.addEventListener(type, listener, options)\n }\n }\n\n /**\n * Notify namespaced wildcard listeners of an event\n * Only fires for events that match this component's namespace\n *\n * @param event - The event to dispatch to namespaced wildcard listeners\n * @private\n */\n private _notifyNamespacedWildcardListeners (event: Event): void {\n if (this._namespacedWildcardListeners.size === 0) {\n return\n }\n\n const componentName = this.TAG\n\n // Only trigger for events in this component's namespace\n if (!componentName || !event.type.startsWith(`${componentName}:`)) {\n return\n }\n\n // Call each namespaced wildcard listener\n this._namespacedWildcardListeners.forEach(({ listener }) => {\n try {\n if (typeof listener === 'function') {\n listener.call(this, event)\n } else if (listener && typeof listener.handleEvent === 'function') {\n listener.handleEvent(event)\n }\n } catch (error) {\n // Log errors but don't let one listener break others\n console.error(\n 'Error in namespaced wildcard event listener:',\n error\n )\n }\n })\n }\n\n /**\n * Notify global wildcard listeners of an event\n * Fires for ALL events dispatched through this element\n *\n * @param event - The event to dispatch to global wildcard listeners\n * @private\n */\n private _notifyGlobalWildcardListeners (event: Event): void {\n if (this._globalWildcardListeners.size === 0) {\n return\n }\n\n // Call each global wildcard listener\n this._globalWildcardListeners.forEach(({ listener }) => {\n try {\n if (typeof listener === 'function') {\n listener.call(this, event)\n } else if (listener && typeof listener.handleEvent === 'function') {\n listener.handleEvent(event)\n }\n } catch (error) {\n // Log errors but don't let one listener break others\n console.error('Error in global wildcard event listener:', error)\n }\n })\n }\n\n connectedCallback () {\n this.render()\n }\n\n abstract render ():any\n\n qs<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qs<E extends Element = Element>(selector:string):E|null;\n qs (selector:string):Element|null {\n return this.querySelector(selector)\n }\n\n qsa<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qsa<E extends Element = Element>(selector:string):E|null;\n qsa (selector:string):NodeListOf<Element> {\n return this.querySelectorAll(selector)\n }\n\n /**\n * Take a non-namepsaced event name, return namespace event name.\n *\n * @param {string} evType The non-namespace event name\n * @returns {string} Namespaced event name, eg, `my-component:click`\n */\n static event (evType:string):string {\n return eventName(this.TAG, evType)\n }\n\n /**\n * Emit a namespaced event.\n *\n * @param type (non-namespaced) event type string\n * @param opts `bubbles`, `detail`, and `cancelable`. Default is\n * `{ bubbles: true, cancelable: true }`\n * @returns {boolean}\n */\n emit<T = any> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n if (type === '*') throw new Error('Do not emit the literal \"*\"')\n\n const { bubbles = true, cancelable = true, detail } = opts\n const namespacedType = `${this.TAG}:${type}`\n\n const event = new CustomEvent(namespacedType, {\n bubbles,\n cancelable,\n detail\n })\n\n // This will trigger both specific listeners and global wildcard\n // listeners (**)\n const result = this.dispatchEvent(event)\n\n // Notify namespaced wildcard listeners (*)\n this._notifyNamespacedWildcardListeners(event)\n\n return result\n }\n\n /**\n * Override dispatchEvent to notify global wildcard listeners\n * This ensures that '**' listeners catch ALL events\n *\n * @param event - The event to dispatch\n * @returns true if the event was not cancelled\n */\n dispatchEvent (event: Event): boolean {\n const result = super.dispatchEvent(event)\n\n // Notify global wildcard listeners for ALL events\n this._notifyGlobalWildcardListeners(event)\n\n return result\n }\n\n /**\n * Create and emit an event, no namespacing.\n */\n dispatch<T> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n const event = new CustomEvent(type, {\n bubbles: (opts.bubbles === undefined) ? true : opts.bubbles,\n cancelable: (opts.cancelable === undefined) ? true : opts.cancelable,\n detail: opts.detail\n })\n\n return this.dispatchEvent(event)\n }\n\n /**\n * Listen for namespaced events.\n */\n on<T extends Event = Event> (\n evName:string,\n handler:(ev:T)=>any,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:((ev:Event)=>any)|EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void {\n const fullEvName = WebComponent.event.call(this, evName)\n this.addEventListener(fullEvName, handler as EventListenerOrEventListenerObject, options)\n }\n\n /**\n * Enhanced removeEventListener that supports wildcards:\n * - Component.event('*') - Remove namespaced wildcard listener\n * - '*' - Remove global wildcard listener\n *\n * @param type - Event type, Component.event('*') for namespaced, or '*'\n * for global\n * @param listener - Event listener function or object to remove\n * @param options - Event listener options\n */\n removeEventListener (\n type:string,\n listener:EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions\n ): void {\n if (type === WebComponent.event.call(this, '*')) {\n // Remove namespaced wildcard listener\n if (listener && this._namespacedWildcardListeners) {\n for (const entry of this._namespacedWildcardListeners) {\n if (entry.listener === listener) {\n this._namespacedWildcardListeners.delete(entry)\n break\n }\n }\n }\n } else if (type === '*') {\n // Remove global wildcard listener\n if (listener && this._globalWildcardListeners) {\n for (const entry of this._globalWildcardListeners) {\n if (entry.listener === listener) {\n this._globalWildcardListeners.delete(entry)\n break\n }\n }\n }\n } else {\n // Normal event listener - delegate to native implementation\n super.removeEventListener(type, listener, options)\n }\n }\n}\n\nfunction eventName (namespace:string, evType:string) {\n return `${namespace}:${evType}`\n}\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", "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": "sKASO,SAASA,EAAcC,EAAoB,CAC9C,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC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AK,uBAAuB,CAChC,CAEA,wBAA0B,CAEtB,KAAK,QAAQ,iBAAiB,UAAYG,GAAoB,EACtDA,EAAE,MAAQ,KAAOA,EAAE,MAAQ,WAC3BA,EAAE,eAAe,EACjB,KAAK,QAAQ,MAAM,EAE3B,CAAC,CACL,CAEA,QAAU,CAEV,CACJ",
|
|
6
|
+
"names": ["toAttributes", "attrs", "acc", "k", "value", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "qs", "qsa", "match", "el", "s", "WebComponent", "_WebComponent", "__name", "el", "match", "elementName", "CreatedClass", "evType", "define", "name", "oldValue", "newValue", "handler", "type", "listener", "options", "event", "componentName", "error", "selector", "eventName", "opts", "bubbles", "cancelable", "detail", "namespacedType", "result", "evName", "fullEvName", "entry", "namespace", "isRegistered", "elName", "element", "SubstrateButton", "_SubstrateButton", "WebComponent", "__name", "define", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "e"]
|
|
7
7
|
}
|
package/dist/html.cjs
CHANGED
|
@@ -33,7 +33,7 @@ function html(attrs, textContent) {
|
|
|
33
33
|
ariaLabel
|
|
34
34
|
} = attrs;
|
|
35
35
|
const _classes = new Set(classes);
|
|
36
|
-
_classes.add("substrate-button");
|
|
36
|
+
_classes.add("substrate-button btn");
|
|
37
37
|
const arr = Array.from(_classes);
|
|
38
38
|
const btnProps = [
|
|
39
39
|
arr.length ? `class="${arr.filter(Boolean).join(" ")}"` : "",
|
|
@@ -47,9 +47,9 @@ function html(attrs, textContent) {
|
|
|
47
47
|
'aria-live="polite"'
|
|
48
48
|
].filter(Boolean).join(" ");
|
|
49
49
|
return typeof window === "undefined" ? `<substrate-button${disabled ? " disabled" : ""}>
|
|
50
|
-
<button ${btnProps}>${textContent}</button>
|
|
50
|
+
<button ${btnProps}><span class="btn-content">${textContent}</span></button>
|
|
51
51
|
</substrate-button>` : `<button ${btnProps}>
|
|
52
|
-
|
|
52
|
+
<span class="btn-content">${textContent}</span>
|
|
53
53
|
</button>`;
|
|
54
54
|
}
|
|
55
55
|
__name(html, "html");
|
package/dist/html.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/html.ts"],
|
|
4
|
-
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}>${textContent}</button>\n </substrate-button>` :\n `<button ${btnProps}>\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,
|
|
4
|
+
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button btn')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}><span class=\"btn-content\">${textContent}</span></button>\n </substrate-button>` :\n `<button ${btnProps}>\n <span class=\"btn-content\">${textContent}</span>\n </button>`\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,sBAAsB;AACnC,QAAM,MAAM,MAAM,KAAK,QAAQ;AAE/B,QAAM,WAAY;AAAA,IACd,IAAI,SAAS,UAAU,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,MAAM;AAAA,IAC1D,WAAW,aAAa;AAAA,IACxB,YAAY,cAAc;AAAA,IAC1B,OAAO,SAAS,IAAI,MAAM;AAAA,IAC1B,OAAO,QAAQ,IAAI,KAAK;AAAA,IACxB,WAAW,aAAa,QAAQ,MAAM;AAAA,IACtC;AAAA,IACA,YAAY,eAAe,SAAS,MAAM;AAAA,IAC1C;AAAA,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,8BAA8B,WAAW;AAAA,+BAE/D,WAAW,QAAQ;AAAA,wCACa,WAAW;AAAA;AAEnD;AAnCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/html.js
CHANGED
|
@@ -11,7 +11,7 @@ function html(attrs, textContent) {
|
|
|
11
11
|
ariaLabel
|
|
12
12
|
} = attrs;
|
|
13
13
|
const _classes = new Set(classes);
|
|
14
|
-
_classes.add("substrate-button");
|
|
14
|
+
_classes.add("substrate-button btn");
|
|
15
15
|
const arr = Array.from(_classes);
|
|
16
16
|
const btnProps = [
|
|
17
17
|
arr.length ? `class="${arr.filter(Boolean).join(" ")}"` : "",
|
|
@@ -25,9 +25,9 @@ function html(attrs, textContent) {
|
|
|
25
25
|
'aria-live="polite"'
|
|
26
26
|
].filter(Boolean).join(" ");
|
|
27
27
|
return typeof window === "undefined" ? `<substrate-button${disabled ? " disabled" : ""}>
|
|
28
|
-
<button ${btnProps}>${textContent}</button>
|
|
28
|
+
<button ${btnProps}><span class="btn-content">${textContent}</span></button>
|
|
29
29
|
</substrate-button>` : `<button ${btnProps}>
|
|
30
|
-
|
|
30
|
+
<span class="btn-content">${textContent}</span>
|
|
31
31
|
</button>`;
|
|
32
32
|
}
|
|
33
33
|
__name(html, "html");
|
package/dist/html.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/html.ts"],
|
|
4
|
-
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}>${textContent}</button>\n </substrate-button>` :\n `<button ${btnProps}>\n
|
|
5
|
-
"mappings": ";;AAUO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,
|
|
4
|
+
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button btn')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}><span class=\"btn-content\">${textContent}</span></button>\n </substrate-button>` :\n `<button ${btnProps}>\n <span class=\"btn-content\">${textContent}</span>\n </button>`\n}\n"],
|
|
5
|
+
"mappings": ";;AAUO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,sBAAsB;AACnC,QAAM,MAAM,MAAM,KAAK,QAAQ;AAE/B,QAAM,WAAY;AAAA,IACd,IAAI,SAAS,UAAU,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,MAAM;AAAA,IAC1D,WAAW,aAAa;AAAA,IACxB,YAAY,cAAc;AAAA,IAC1B,OAAO,SAAS,IAAI,MAAM;AAAA,IAC1B,OAAO,QAAQ,IAAI,KAAK;AAAA,IACxB,WAAW,aAAa,QAAQ,MAAM;AAAA,IACtC;AAAA,IACA,YAAY,eAAe,SAAS,MAAM;AAAA,IAC1C;AAAA,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,8BAA8B,WAAW;AAAA,+BAE/D,WAAW,QAAQ;AAAA,wCACa,WAAW;AAAA;AAEnD;AAnCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var c=(n,t)=>o(n,"name",{value:t,configurable:!0});var m=(n,t)=>{for(var s in t)o(n,s,{get:t[s],enumerable:!0})},y=(n,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of f(t))!g.call(n,a)&&a!==s&&o(n,a,{get:()=>t[a],enumerable:!(e=$(t,a))||e.enumerable});return n};var x=n=>y(o({},"__esModule",{value:!0}),n);var A={};m(A,{html:()=>w});module.exports=x(A);function w(n,t){const{type:s,autofocus:e,tabindex:a,disabled:l,classes:p,name:r,ariaLabel:b}=n,i=new Set(p);i.add("substrate-button btn");const u=Array.from(i),d=[u.length?`class="${u.filter(Boolean).join(" ")}"`:"",l?"disabled":"",e?"autofocus":"",s?`type="${s}"`:"",r?`name=${r}`:"",a?`tabindex="${a}"`:'tabindex="0"','role="button"',b?`aria-label="${b}"`:"",'aria-live="polite"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${l?" disabled":""}>
|
|
2
|
+
<button ${d}><span class="btn-content">${t}</span></button>
|
|
3
|
+
</substrate-button>`:`<button ${d}>
|
|
4
|
+
<span class="btn-content">${t}</span>
|
|
5
|
+
</button>`}c(w,"html");
|
|
6
|
+
//# sourceMappingURL=html.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/html.ts"],
|
|
4
|
+
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button btn')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}><span class=\"btn-content\">${textContent}</span></button>\n </substrate-button>` :\n `<button ${btnProps}>\n <span class=\"btn-content\">${textContent}</span>\n </button>`\n}\n"],
|
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,GAUO,SAASI,EAAMC,EAAsBC,EAAoB,CAC5D,KAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,KAAAC,EACA,UAAAC,CACJ,EAAIR,EAEES,EAAW,IAAI,IAAIH,CAAO,EAChCG,EAAS,IAAI,sBAAsB,EACnC,MAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DL,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BK,EAAO,QAAQA,CAAI,GAAK,GACxBH,EAAW,aAAaA,CAAQ,IAAM,eACtC,gBACAI,EAAY,eAAeA,CAAS,IAAM,GAC1C,oBACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBH,EAAW,YAAc,EAAE;AAAA,sBACjCM,CAAQ,8BAA8BV,CAAW;AAAA,6BAE/D,WAAWU,CAAQ;AAAA,wCACaV,CAAW;AAAA,kBAEnD,CAnCgBW,EAAAb,EAAA",
|
|
6
|
+
"names": ["html_exports", "__export", "html", "__toCommonJS", "html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "name", "ariaLabel", "_classes", "arr", "btnProps", "__name"]
|
|
7
|
+
}
|
package/dist/html.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
<button ${
|
|
3
|
-
</substrate-button>`:`<button ${
|
|
4
|
-
|
|
5
|
-
</button>`}u(
|
|
1
|
+
var p=Object.defineProperty;var u=(n,t)=>p(n,"name",{value:t,configurable:!0});function f(n,t){let{type:a,autofocus:d,tabindex:s,disabled:e,classes:c,name:o,ariaLabel:l}=n,r=new Set(c);r.add("substrate-button btn");let b=Array.from(r),i=[b.length?`class="${b.filter(Boolean).join(" ")}"`:"",e?"disabled":"",d?"autofocus":"",a?`type="${a}"`:"",o?`name=${o}`:"",s?`tabindex="${s}"`:'tabindex="0"','role="button"',l?`aria-label="${l}"`:"",'aria-live="polite"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${e?" disabled":""}>
|
|
2
|
+
<button ${i}><span class="btn-content">${t}</span></button>
|
|
3
|
+
</substrate-button>`:`<button ${i}>
|
|
4
|
+
<span class="btn-content">${t}</span>
|
|
5
|
+
</button>`}u(f,"html");export{f as html};
|
|
6
6
|
//# sourceMappingURL=html.min.js.map
|
package/dist/html.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/html.ts"],
|
|
4
|
-
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}>${textContent}</button>\n </substrate-button>` :\n `<button ${btnProps}>\n
|
|
5
|
-
"mappings": "+EAUO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,KAAAC,EACA,UAAAC,CACJ,EAAIR,EAEES,EAAW,IAAI,IAAIH,CAAO,EAChCG,EAAS,IAAI,
|
|
4
|
+
"sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n name:string|null;\n classes:string[]|Set<string>;\n ariaLabel:string|null;\n}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name,\n ariaLabel\n } = attrs\n\n const _classes = new Set(classes)\n _classes.add('substrate-button btn')\n const arr = Array.from(_classes)\n\n const btnProps = ([\n arr.length ? `class=\"${arr.filter(Boolean).join(' ')}\"` : '',\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${type}\"` : '',\n name ? `name=${name}` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"',\n ariaLabel ? `aria-label=\"${ariaLabel}\"` : '',\n 'aria-live=\"polite\"'\n ]).filter(Boolean).join(' ')\n\n // rendering in node?\n return typeof window === 'undefined' ?\n `<substrate-button${disabled ? ' disabled' : ''}>\n <button ${btnProps}><span class=\"btn-content\">${textContent}</span></button>\n </substrate-button>` :\n `<button ${btnProps}>\n <span class=\"btn-content\">${textContent}</span>\n </button>`\n}\n"],
|
|
5
|
+
"mappings": "+EAUO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,KAAAC,EACA,UAAAC,CACJ,EAAIR,EAEES,EAAW,IAAI,IAAIH,CAAO,EAChCG,EAAS,IAAI,sBAAsB,EACnC,IAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DL,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BK,EAAO,QAAQA,CAAI,GAAK,GACxBH,EAAW,aAAaA,CAAQ,IAAM,eACtC,gBACAI,EAAY,eAAeA,CAAS,IAAM,GAC1C,oBACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBH,EAAW,YAAc,EAAE;AAAA,sBACjCM,CAAQ,8BAA8BV,CAAW;AAAA,6BAE/D,WAAWU,CAAQ;AAAA,wCACaV,CAAW;AAAA,kBAEnD,CAnCgBW,EAAAb,EAAA",
|
|
6
6
|
"names": ["html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "name", "ariaLabel", "_classes", "arr", "btnProps", "__name"]
|
|
7
7
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -23,33 +23,30 @@ __export(index_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(index_exports);
|
|
25
25
|
var import_html = require("./html.js");
|
|
26
|
+
var import_web_component = require("@substrate-system/web-component");
|
|
26
27
|
var import_client = require("./client.js");
|
|
27
28
|
class SubstrateButton extends import_client.SubstrateButton {
|
|
28
29
|
static {
|
|
29
30
|
__name(this, "SubstrateButton");
|
|
30
31
|
}
|
|
31
32
|
static define() {
|
|
32
|
-
|
|
33
|
-
return customElements.define(
|
|
34
|
-
SubstrateButton.TAG || "substrate-button",
|
|
35
|
-
SubstrateButton
|
|
36
|
-
);
|
|
33
|
+
(0, import_web_component.define)(SubstrateButton.TAG, SubstrateButton);
|
|
37
34
|
}
|
|
38
35
|
connectedCallback() {
|
|
39
36
|
this.render();
|
|
37
|
+
this._setupKeyboardHandlers();
|
|
40
38
|
}
|
|
41
39
|
render() {
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
tabindex,
|
|
46
|
-
disabled
|
|
47
|
-
} = this;
|
|
40
|
+
const { type, tabindex } = this;
|
|
41
|
+
const disabled = this.hasAttribute("disabled");
|
|
42
|
+
const autofocus = this.hasAttribute("autofocus");
|
|
48
43
|
const name = this.getAttribute("name");
|
|
49
44
|
const ariaLabel = this.getAttribute("aria-label");
|
|
45
|
+
const spinning = this.getAttribute("spinning") !== null;
|
|
50
46
|
const classes = [
|
|
51
47
|
"substrate-button",
|
|
52
|
-
this.getAttribute("class")
|
|
48
|
+
this.getAttribute("class"),
|
|
49
|
+
spinning ? "spinning" : null
|
|
53
50
|
];
|
|
54
51
|
const text = this.innerHTML;
|
|
55
52
|
const btnProps = {
|
|
@@ -64,4 +61,5 @@ class SubstrateButton extends import_client.SubstrateButton {
|
|
|
64
61
|
this.innerHTML = (0, import_html.html)(btnProps, text);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
64
|
+
(0, import_web_component.define)("substrate-button", SubstrateButton);
|
|
67
65
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { html } from './html.js'\nimport { SubstrateButton as SubstrateButtonLight } from './client.js'\n\n/**\n * This is the full-version -- knows how to render itself in the browser.\n */\nexport class SubstrateButton extends SubstrateButtonLight {\n static define () {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAAwD;
|
|
4
|
+
"sourcesContent": ["import { html } from './html.js'\nimport { define } from '@substrate-system/web-component'\nimport { SubstrateButton as SubstrateButtonLight } from './client.js'\n// import Debug from '@substrate-system/debug'\n// const debug = Debug('button')\n\n/**\n * This is the full-version -- knows how to render itself in the browser.\n */\nexport class SubstrateButton extends SubstrateButtonLight {\n static define () {\n define(SubstrateButton.TAG, SubstrateButton)\n }\n\n connectedCallback ():void {\n this.render()\n this._setupKeyboardHandlers()\n }\n\n render () {\n const { type, tabindex } = this\n // Read directly from host attributes: the inner button does not\n // exist yet when render() first runs, so the getters (which\n // read from the inner button) would return false.\n const disabled = this.hasAttribute('disabled')\n const autofocus = this.hasAttribute('autofocus')\n const name = this.getAttribute('name')\n const ariaLabel = this.getAttribute('aria-label')\n\n const spinning = this.getAttribute('spinning') !== null\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class'),\n spinning ? 'spinning' : null\n ]\n const text = this.innerHTML\n\n const btnProps = {\n classes: classes.filter(Boolean),\n disabled,\n autofocus,\n tabindex,\n type,\n name,\n ariaLabel,\n }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n\ndefine('substrate-button', SubstrateButton)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,2BAAuB;AACvB,oBAAwD;AAOjD,MAAM,wBAAwB,cAAAA,gBAAqB;AAAA,EAT1D,OAS0D;AAAA;AAAA;AAAA,EACtD,OAAO,SAAU;AACb,qCAAO,gBAAgB,KAAK,eAAe;AAAA,EAC/C;AAAA,EAEA,oBAA0B;AACtB,SAAK,OAAO;AACZ,SAAK,uBAAuB;AAAA,EAChC;AAAA,EAEA,SAAU;AACN,UAAM,EAAE,MAAM,SAAS,IAAI;AAI3B,UAAM,WAAW,KAAK,aAAa,UAAU;AAC7C,UAAM,YAAY,KAAK,aAAa,WAAW;AAC/C,UAAM,OAAO,KAAK,aAAa,MAAM;AACrC,UAAM,YAAY,KAAK,aAAa,YAAY;AAEhD,UAAM,WAAW,KAAK,aAAa,UAAU,MAAM;AAEnD,UAAM,UAA0B;AAAA,MAC5B;AAAA,MACA,KAAK,aAAa,OAAO;AAAA,MACzB,WAAW,aAAa;AAAA,IAC5B;AACA,UAAM,OAAO,KAAK;AAElB,UAAM,WAAW;AAAA,MACb,SAAS,QAAQ,OAAO,OAAO;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAEA,SAAK,gBAAY,kBAAK,UAAU,IAAI;AAAA,EACxC;AACJ;AAAA,IAEA,6BAAO,oBAAoB,eAAe;",
|
|
6
6
|
"names": ["SubstrateButtonLight"]
|
|
7
7
|
}
|