@substrate-system/button 0.0.22 → 0.0.28

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/dist/client.cjs CHANGED
@@ -19,7 +19,9 @@ 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
22
+ SubstrateButton: () => SubstrateButton,
23
+ define: () => define,
24
+ isRegistered: () => isRegistered
23
25
  });
24
26
  module.exports = __toCommonJS(client_exports);
25
27
  class SubstrateButton extends HTMLElement {
@@ -151,13 +153,21 @@ class SubstrateButton extends HTMLElement {
151
153
  this.render();
152
154
  }
153
155
  static define() {
154
- if (!("customElements" in window)) return;
155
- return customElements.define(
156
- SubstrateButton.TAG || "substrate-button",
157
- SubstrateButton
158
- );
156
+ return define(SubstrateButton.TAG, SubstrateButton);
159
157
  }
160
158
  render() {
161
159
  }
162
160
  }
161
+ function isRegistered(elName) {
162
+ return document.createElement(elName).constructor !== window.HTMLElement;
163
+ }
164
+ __name(isRegistered, "isRegistered");
165
+ function define(name, element) {
166
+ if (!window) return;
167
+ if (!("customElements" in window)) return;
168
+ if (!isRegistered(name)) {
169
+ window.customElements.define(name, element);
170
+ }
171
+ }
172
+ __name(define, "define");
163
173
  //# sourceMappingURL=client.cjs.map
@@ -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 + 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 } else {\n this.classList.remove('substrate-loading')\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 }\n\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n render () {\n // noop\n }\n}\n\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,wBAAwB,YAAY;AAAA,EAVjD,OAUiD;AAAA;AAAA;AAAA;AAAA,EAE7C,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO,MAAM;AAAA,EACb;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,E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J;",
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 } else {\n this.classList.remove('substrate-loading')\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 }\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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,wBAAwB,YAAY;AAAA,EAVjD,OAU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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,yBAA0B,MAAa,UAAiB,UAAiB;AACrE,UAAM,UAAU,KAAK,gBAAgB,IAAI,EAAE;AAC3C,IAAC,WAAW,QAAQ,KAAK,MAAM,UAAU,QAAQ;AAAA,EACrD;AAAA,EAEA,oBAAqB;AAEjB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,OAAO,SAAe;AAClB,WAAO,OAAO,gBAAgB,KAAK,eAAe;AAAA,EACtD;AAAA,EAEA,SAAU;AAAA,EAEV;AACJ;AAEO,SAAS,aAAc,QAAuB;AACjD,SAAO,SAAS,cAAc,MAAM,EAAE,gBAAgB,OAAO;AACjE;AAFgB;AAIT,SAAS,OAAQ,MAAa,SAAuC;AACxE,MAAI,CAAC,OAAQ;AACb,MAAI,EAAE,oBAAoB,QAAS;AAEnC,MAAI,CAAC,aAAa,IAAI,GAAG;AACrB,WAAO,eAAe,OAAO,MAAM,OAAO;AAAA,EAC9C;AACJ;AAPgB;",
6
6
  "names": []
7
7
  }
package/dist/client.d.ts CHANGED
@@ -55,4 +55,6 @@ export declare class SubstrateButton extends HTMLElement {
55
55
  static define(): void;
56
56
  render(): void;
57
57
  }
58
+ export declare function isRegistered(elName: string): boolean;
59
+ export declare function define(name: string, element: CustomElementConstructor): void;
58
60
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,kBAAkB,EAAE,eAAe,CAAA;KACtC;CACJ;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAE5C,MAAM,CAAC,kBAAkB,WAAwC;IACjE,MAAM,CAAC,GAAG,SAAqB;IAC/B,WAAW,EAAC,OAAO,CAAA;;IAenB,IAAI,IAAI,IAAI,eAAe,GAAC,SAAS,GAAC,IAAI,CA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EAAC,MAAM,EAAE,OAAO,EAAC,wBAAwB,GAAE,IAAI,CAO1E"}
package/dist/client.js CHANGED
@@ -129,16 +129,26 @@ class SubstrateButton extends HTMLElement {
129
129
  this.render();
130
130
  }
131
131
  static define() {
132
- if (!("customElements" in window)) return;
133
- return customElements.define(
134
- SubstrateButton.TAG || "substrate-button",
135
- SubstrateButton
136
- );
132
+ return define(SubstrateButton.TAG, SubstrateButton);
137
133
  }
138
134
  render() {
139
135
  }
140
136
  }
137
+ function isRegistered(elName) {
138
+ return document.createElement(elName).constructor !== window.HTMLElement;
139
+ }
140
+ __name(isRegistered, "isRegistered");
141
+ function define(name, element) {
142
+ if (!window) return;
143
+ if (!("customElements" in window)) return;
144
+ if (!isRegistered(name)) {
145
+ window.customElements.define(name, element);
146
+ }
147
+ }
148
+ __name(define, "define");
141
149
  export {
142
- SubstrateButton
150
+ SubstrateButton,
151
+ define,
152
+ isRegistered
143
153
  };
144
154
  //# sourceMappingURL=client.js.map
@@ -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 + 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 } else {\n this.classList.remove('substrate-loading')\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 }\n\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n render () {\n // noop\n }\n}\n\n"],
5
- "mappings": ";;AAUO,MAAM,wBAAwB,YAAY;AAAA,EAVjD,OAUiD;AAAA;AAAA;AAAA;AAAA,EAE7C,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO,MAAM;AAAA,EACb;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;AACjC,QAAI,CAAC,eAAe;AAChB,WAAK,iBAAiB,UAAU;AAChC,WAAK,QAAQ,aAAa,iBAAiB,OAAO;AAAA,IACtD,OAAO;AACH,WAAK,QAAQ,aAAa,YAAY,EAAE;AACxC,WAAK,QAAQ,aAAa,iBAAiB,MAAM;AAAA,IACrD;AAAA,EAC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;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,uBAAwB,WAAkB,UAAiB;AACvD,SAAK,cAAc,aAAa,QAAQ;AAAA,EAC5C;AAAA,EAEA,sBAAuB,MAAM,UAAyB;AAClD,SAAK,WAAY,aAAa;AAC9B,QAAI,aAAa,KAAM,MAAK,QAAQ,gBAAgB,UAAU;AAAA,QACzD,MAAK,QAAQ,aAAa,YAAY,KAAK,QAAQ;AAAA,EAC5D;AAAA,EAEA,sBAAuB,GAAG,UAAkB;AACxC,QAAI,aAAa,MAAM;AACnB,WAAK,UAAU,IAAI,mBAAmB;AAAA,IAC1C,OAAO;AACH,WAAK,UAAU,OAAO,mBAAmB;AAAA,IAC7C;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,yBAA0B,MAAa,UAAiB,UAAiB;AACrE,UAAM,UAAU,KAAK,gBAAgB,IAAI,EAAE;AAC3C,IAAC,WAAW,QAAQ,KAAK,MAAM,UAAU,QAAQ;AAAA,EACrD;AAAA,EAEA,oBAAqB;AAEjB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,OAAO,SAAU;AACb,QAAI,EAAE,oBAAoB,QAAS;AAEnC,WAAO,eAAe;AAAA,MAClB,gBAAgB,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,SAAU;AAAA,EAEV;AACJ;",
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 } else {\n this.classList.remove('substrate-loading')\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 }\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": ";;AAUO,MAAM,wBAAwB,YAAY;AAAA,EAVjD,OAUiD;AAAA;AAAA;AAAA;AAAA,EAE7C,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO,MAAM;AAAA,EACb;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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AACjD,SAAO,SAAS,cAAc,MAAM,EAAE,gBAAgB,OAAO;AACjE;AAFgB;AAIT,SAAS,OAAQ,MAAa,SAAuC;AACxE,MAAI,CAAC,OAAQ;AACb,MAAI,EAAE,oBAAoB,QAAS;AAEnC,MAAI,CAAC,aAAa,IAAI,GAAG;AACrB,WAAO,eAAe,OAAO,MAAM,OAAO;AAAA,EAC9C;AACJ;AAPgB;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var o=Object.defineProperty;var n=(i,t)=>o(i,"name",{value:t,configurable:!0});var r=class i extends HTMLElement{static{n(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;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){t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this._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.setAttribute("spinning",""):this.removeAttribute("spinning")}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){t?this._setAttribute("autofocus",t):this._removeAttribute("autofocus")}_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._setAttribute("autofocus",e)}handleChange_disabled(t,e){this.disabled=e!==null,e===null?this.button?.removeAttribute("disabled"):this.button?.setAttribute("disabled",""+e)}handleChange_spinning(t,e){e!==null?this.classList.add("substrate-loading"):this.classList.remove("substrate-loading")}attributeChangedCallback(t,e,u){let s=this[`handleChange_${t}`];s&&s.call(this,e,u)}connectedCallback(){this.render()}static define(){if("customElements"in window)return customElements.define(i.TAG||"substrate-button",i)}render(){}};export{r as SubstrateButton};
1
+ var o=Object.defineProperty;var s=(i,t)=>o(i,"name",{value:t,configurable:!0});var r=class i extends HTMLElement{static{s(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;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){t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this._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.setAttribute("spinning",""):this.removeAttribute("spinning")}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){t?this._setAttribute("autofocus",t):this._removeAttribute("autofocus")}_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._setAttribute("autofocus",e)}handleChange_disabled(t,e){this.disabled=e!==null,e===null?this.button?.removeAttribute("disabled"):this.button?.setAttribute("disabled",""+e)}handleChange_spinning(t,e){e!==null?this.classList.add("substrate-loading"):this.classList.remove("substrate-loading")}attributeChangedCallback(t,e,u){let n=this[`handleChange_${t}`];n&&n.call(this,e,u)}connectedCallback(){this.render()}static define(){return l(i.TAG,i)}render(){}};function b(i){return document.createElement(i).constructor!==window.HTMLElement}s(b,"isRegistered");function l(i,t){window&&"customElements"in window&&(b(i)||window.customElements.define(i,t))}s(l,"define");export{r as SubstrateButton,l as define,b as isRegistered};
2
2
  //# sourceMappingURL=client.min.js.map
@@ -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 + 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 } else {\n this.classList.remove('substrate-loading')\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 }\n\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\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,cAAeC,EAAaD,EAAgC,CACxD,GAAIA,IAAU,GAEV,KAAK,iBAAiBC,CAAI,EAC1B,KAAK,QAAQ,gBAAgBA,CAAI,MAC9B,CACH,GAAID,IAAU,GAEV,OAAO,KAAK,QAAQ,aAAaC,EAAM,EAAE,EAG7C,GAAID,IAAU,KAEV,OAAO,KAAK,iBAAiBC,CAAI,EAIrC,KAAK,QAAQ,aAAaA,EAAMD,CAAK,CACzC,CACJ,CAKA,iBAAkBC,EAAa,CAC3B,KAAK,gBAAgBA,CAAI,EACzB,KAAK,QAAQ,gBAAgBA,CAAI,CACrC,CAEA,IAAI,QAAiC,CACjC,OAAO,KAAK,cAAc,QAAQ,CACtC,CASA,uBAAwBC,EAAkBC,EAAiB,CACvD,KAAK,cAAc,YAAaA,CAAQ,CAC5C,CAEA,sBAAuBC,EAAMD,EAAyB,CAClD,KAAK,SAAYA,IAAa,KAC1BA,IAAa,KAAM,KAAK,QAAQ,gBAAgB,UAAU,EACzD,KAAK,QAAQ,aAAa,WAAY,GAAKA,CAAQ,CAC5D,CAEA,sBAAuBE,EAAGF,EAAkB,CACpCA,IAAa,KACb,KAAK,UAAU,IAAI,mBAAmB,EAEtC,KAAK,UAAU,OAAO,mBAAmB,CAEjD,CAYA,yBAA0BF,EAAaK,EAAiBH,EAAiB,CACrE,IAAMI,EAAU,KAAK,gBAAgBN,CAAI,EAAE,EAC1CM,GAAWA,EAAQ,KAAK,KAAMD,EAAUH,CAAQ,CACrD,CAEA,mBAAqB,CAEjB,KAAK,OAAO,CAChB,CAEA,OAAO,QAAU,CACb,GAAM,mBAAoB,OAE1B,OAAO,eAAe,OAClBP,EAAgB,KAAO,mBACvBA,CACJ,CACJ,CAEA,QAAU,CAEV,CACJ",
6
- "names": ["SubstrateButton", "_SubstrateButton", "__name", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "oldValue", "handler"]
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 } else {\n this.classList.remove('substrate-loading')\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 }\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": "+EAUO,IAAMA,EAAN,MAAMC,UAAwB,WAAY,CAVjD,MAUiD,CAAAC,EAAA,wBAE7C,OAAO,mBAAqB,CAAC,YAAa,WAAY,UAAU,EAChE,OAAO,IAAM,mBACb,YAEA,aAAe,CACX,MAAM,EACW,KAAK,aAAa,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iBC,CAAI,EAIrC,KAAK,QAAQ,aAAaA,EAAMD,CAAK,CACzC,CACJ,CAKA,iBAAkBC,EAAa,CAC3B,KAAK,gBAAgBA,CAAI,EACzB,KAAK,QAAQ,gBAAgBA,CAAI,CACrC,CAEA,IAAI,QAAiC,CACjC,OAAO,KAAK,cAAc,QAAQ,CACtC,CASA,uBAAwBC,EAAkBC,EAAiB,CACvD,KAAK,cAAc,YAAaA,CAAQ,CAC5C,CAEA,sBAAuBC,EAAMD,EAAyB,CAClD,KAAK,SAAYA,IAAa,KAC1BA,IAAa,KAAM,KAAK,QAAQ,gBAAgB,UAAU,EACzD,KAAK,QAAQ,aAAa,WAAY,GAAKA,CAAQ,CAC5D,CAEA,sBAAuBE,EAAGF,EAAkB,CACpCA,IAAa,KACb,KAAK,UAAU,IAAI,mBAAmB,EAEtC,KAAK,UAAU,OAAO,mBAAmB,CAEjD,CAYA,yBAA0BF,EAAaK,EAAiBH,EAAiB,CACrE,IAAMI,EAAU,KAAK,gBAAgBN,CAAI,EAAE,EAC1CM,GAAWA,EAAQ,KAAK,KAAMD,EAAUH,CAAQ,CACrD,CAEA,mBAAqB,CAEjB,KAAK,OAAO,CAChB,CAEA,OAAO,QAAe,CAClB,OAAOK,EAAOZ,EAAgB,IAAKA,CAAe,CACtD,CAEA,QAAU,CAEV,CACJ,EAEO,SAASa,EAAcC,EAAuB,CACjD,OAAO,SAAS,cAAcA,CAAM,EAAE,cAAgB,OAAO,WACjE,CAFgBb,EAAAY,EAAA,gBAIT,SAASD,EAAQP,EAAaU,EAAuC,CACnE,QACC,mBAAoB,SAErBF,EAAaR,CAAI,GAClB,OAAO,eAAe,OAAOA,EAAMU,CAAO,EAElD,CAPgBd,EAAAW,EAAA",
6
+ "names": ["SubstrateButton", "_SubstrateButton", "__name", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "oldValue", "handler", "define", "isRegistered", "elName", "element"]
7
7
  }
package/dist/html.cjs CHANGED
@@ -28,7 +28,8 @@ function html(attrs, textContent) {
28
28
  autofocus,
29
29
  tabindex,
30
30
  disabled,
31
- classes
31
+ classes,
32
+ name
32
33
  } = attrs;
33
34
  const _classes = new Set(classes);
34
35
  _classes.add("substrate-button");
@@ -38,6 +39,7 @@ function html(attrs, textContent) {
38
39
  disabled ? "disabled" : "",
39
40
  autofocus ? "autofocus" : "",
40
41
  type ? `type="${type}"` : "",
42
+ name ? `name=${name}` : "",
41
43
  tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
42
44
  'role="button"'
43
45
  ].filter(Boolean).join(" ");
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 classes:string[]|Set<string>;\n}\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes\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 tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"'\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 ${textContent}\n </button>`\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,kBAAkB;AAC/B,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,WAAW,aAAa,QAAQ,MAAM;AAAA,IACtC;AAAA,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,IAAI,WAAW;AAAA,gCAErC,WAAW,QAAQ;AAAA,cACb,WAAW;AAAA;AAEzB;AA9BgB;",
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}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name\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 ]).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 ${textContent}\n </button>`\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,kBAAkB;AAC/B,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,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,IAAI,WAAW;AAAA,gCAErC,WAAW,QAAQ;AAAA,cACb,WAAW;AAAA;AAEzB;AAhCgB;",
6
6
  "names": []
7
7
  }
package/dist/html.d.ts CHANGED
@@ -3,6 +3,7 @@ export type Attrs = {
3
3
  autofocus: boolean;
4
4
  tabindex: string | number;
5
5
  disabled: boolean;
6
+ name: string | null;
6
7
  classes: string[] | Set<string>;
7
8
  };
8
9
  export declare function html(attrs: Partial<Attrs>, textContent: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,IAAI,EAAC,MAAM,GAAC,IAAI,CAAC;IACjB,SAAS,EAAC,OAAO,CAAC;IAClB,QAAQ,EAAC,MAAM,GAAC,MAAM,CAAC;IACvB,QAAQ,EAAC,OAAO,CAAC;IACjB,OAAO,EAAC,MAAM,EAAE,GAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC,CAAA;AACD,wBAAgB,IAAI,CAAE,KAAK,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAC,MAAM,UA8B7D"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,IAAI,EAAC,MAAM,GAAC,IAAI,CAAC;IACjB,SAAS,EAAC,OAAO,CAAC;IAClB,QAAQ,EAAC,MAAM,GAAC,MAAM,CAAC;IACvB,QAAQ,EAAC,OAAO,CAAC;IACjB,IAAI,EAAC,MAAM,GAAC,IAAI,CAAC;IACjB,OAAO,EAAC,MAAM,EAAE,GAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC,CAAA;AAED,wBAAgB,IAAI,CAAE,KAAK,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAC,MAAM,UAgC7D"}
package/dist/html.js CHANGED
@@ -6,7 +6,8 @@ function html(attrs, textContent) {
6
6
  autofocus,
7
7
  tabindex,
8
8
  disabled,
9
- classes
9
+ classes,
10
+ name
10
11
  } = attrs;
11
12
  const _classes = new Set(classes);
12
13
  _classes.add("substrate-button");
@@ -16,6 +17,7 @@ function html(attrs, textContent) {
16
17
  disabled ? "disabled" : "",
17
18
  autofocus ? "autofocus" : "",
18
19
  type ? `type="${type}"` : "",
20
+ name ? `name=${name}` : "",
19
21
  tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
20
22
  'role="button"'
21
23
  ].filter(Boolean).join(" ");
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 classes:string[]|Set<string>;\n}\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes\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 tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"'\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 ${textContent}\n </button>`\n}\n"],
5
- "mappings": ";;AAOO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,kBAAkB;AAC/B,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,WAAW,aAAa,QAAQ,MAAM;AAAA,IACtC;AAAA,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,IAAI,WAAW;AAAA,gCAErC,WAAW,QAAQ;AAAA,cACb,WAAW;AAAA;AAEzB;AA9BgB;",
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}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name\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 ]).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 ${textContent}\n </button>`\n}\n"],
5
+ "mappings": ";;AASO,SAAS,KAAM,OAAsB,aAAoB;AAC5D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,WAAW,IAAI,IAAI,OAAO;AAChC,WAAS,IAAI,kBAAkB;AAC/B,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,EACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAG3B,SAAO,OAAO,WAAW,cACrB,oBAAoB,WAAW,cAAc,EAAE;AAAA,sBACjC,QAAQ,IAAI,WAAW;AAAA,gCAErC,WAAW,QAAQ;AAAA,cACb,WAAW;AAAA;AAEzB;AAhCgB;",
6
6
  "names": []
7
7
  }
package/dist/html.min.js CHANGED
@@ -1,6 +1,6 @@
1
- var d=Object.defineProperty;var u=(n,t)=>d(n,"name",{value:t,configurable:!0});function f(n,t){let{type:s,autofocus:i,tabindex:o,disabled:e,classes:l}=n,a=new Set(l);a.add("substrate-button");let r=Array.from(a),b=[r.length?`class="${r.filter(Boolean).join(" ")}"`:"",e?"disabled":"",i?"autofocus":"",s?`type="${s}"`:"",o?`tabindex="${o}"`:'tabindex="0"','role="button"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${e?" disabled":""}>
2
- <button ${b}>${t}</button>
3
- </substrate-button$>`:`<button ${b}>
1
+ var c=Object.defineProperty;var i=(n,t)=>c(n,"name",{value:t,configurable:!0});function f(n,t){let{type:e,autofocus:l,tabindex:s,disabled:o,classes:d,name:a}=n,r=new Set(d);r.add("substrate-button");let b=Array.from(r),u=[b.length?`class="${b.filter(Boolean).join(" ")}"`:"",o?"disabled":"",l?"autofocus":"",e?`type="${e}"`:"",a?`name=${a}`:"",s?`tabindex="${s}"`:'tabindex="0"','role="button"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${o?" disabled":""}>
2
+ <button ${u}>${t}</button>
3
+ </substrate-button$>`:`<button ${u}>
4
4
  ${t}
5
- </button>`}u(f,"html");export{f as html};
5
+ </button>`}i(f,"html");export{f as html};
6
6
  //# sourceMappingURL=html.min.js.map
@@ -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 classes:string[]|Set<string>;\n}\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes\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 tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"'\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 ${textContent}\n </button>`\n}\n"],
5
- "mappings": "+EAOO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,CACJ,EAAIN,EAEEO,EAAW,IAAI,IAAID,CAAO,EAChCC,EAAS,IAAI,kBAAkB,EAC/B,IAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DH,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BE,EAAW,aAAaA,CAAQ,IAAM,eACtC,eACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBC,EAAW,YAAc,EAAE;AAAA,sBACjCI,CAAQ,IAAIR,CAAW;AAAA,8BAErC,WAAWQ,CAAQ;AAAA,cACbR,CAAW;AAAA,kBAEzB,CA9BgBS,EAAAX,EAAA",
6
- "names": ["html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "_classes", "arr", "btnProps", "__name"]
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}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name\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 ]).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 ${textContent}\n </button>`\n}\n"],
5
+ "mappings": "+EASO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,KAAAC,CACJ,EAAIP,EAEEQ,EAAW,IAAI,IAAIF,CAAO,EAChCE,EAAS,IAAI,kBAAkB,EAC/B,IAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DJ,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BK,EAAO,QAAQA,CAAI,GAAK,GACxBH,EAAW,aAAaA,CAAQ,IAAM,eACtC,eACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBC,EAAW,YAAc,EAAE;AAAA,sBACjCK,CAAQ,IAAIT,CAAW;AAAA,8BAErC,WAAWS,CAAQ;AAAA,cACbT,CAAW;AAAA,kBAEzB,CAhCgBU,EAAAZ,EAAA",
6
+ "names": ["html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "name", "_classes", "arr", "btnProps", "__name"]
7
7
  }
package/dist/index.cjs CHANGED
@@ -45,6 +45,7 @@ class SubstrateButton extends import_client.SubstrateButton {
45
45
  tabindex,
46
46
  disabled
47
47
  } = this;
48
+ const name = this.getAttribute("name");
48
49
  const classes = [
49
50
  "substrate-button",
50
51
  this.getAttribute("class")
@@ -55,7 +56,8 @@ class SubstrateButton extends import_client.SubstrateButton {
55
56
  disabled,
56
57
  autofocus,
57
58
  tabindex,
58
- type
59
+ type,
60
+ name
59
61
  };
60
62
  this.innerHTML = (0, import_html.html)(btnProps, text);
61
63
  }
@@ -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\nexport class SubstrateButton extends SubstrateButtonLight {\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\n ]\n const text = this.innerHTML\n\n const btnProps = {\n classes: classes.filter(Boolean),\n disabled,\n autofocus,\n tabindex,\n type,\n }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAAwD;AAEjD,MAAM,wBAAwB,cAAAA,gBAAqB;AAAA,EAH1D,OAG0D;AAAA;AAAA;AAAA,EACtD,OAAO,SAAU;AACb,QAAI,EAAE,oBAAoB,QAAS;AAEnC,WAAO,eAAe;AAAA,MAClB,gBAAgB,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,oBAA0B;AACtB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,SAAU;AACN,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AAEJ,UAAM,UAA0B;AAAA,MAC5B;AAAA,MACA,KAAK,aAAa,OAAO;AAAA,IAC7B;AACA,UAAM,OAAO,KAAK;AAElB,UAAM,WAAW;AAAA,MACb,SAAS,QAAQ,OAAO,OAAO;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAEA,SAAK,gBAAY,kBAAK,UAAU,IAAI;AAAA,EACxC;AACJ;",
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 if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n const name = this.getAttribute('name')\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\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 }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAAwD;AAKjD,MAAM,wBAAwB,cAAAA,gBAAqB;AAAA,EAN1D,OAM0D;AAAA;AAAA;AAAA,EACtD,OAAO,SAAU;AACb,QAAI,EAAE,oBAAoB,QAAS;AAEnC,WAAO,eAAe;AAAA,MAClB,gBAAgB,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,oBAA0B;AACtB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,SAAU;AACN,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AACJ,UAAM,OAAO,KAAK,aAAa,MAAM;AAErC,UAAM,UAA0B;AAAA,MAC5B;AAAA,MACA,KAAK,aAAa,OAAO;AAAA,IAC7B;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,IACJ;AAEA,SAAK,gBAAY,kBAAK,UAAU,IAAI;AAAA,EACxC;AACJ;",
6
6
  "names": ["SubstrateButtonLight"]
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { SubstrateButton as SubstrateButtonLight } from './client.js';
2
+ /**
3
+ * This is the full-version -- knows how to render itself in the browser.
4
+ */
2
5
  export declare class SubstrateButton extends SubstrateButtonLight {
3
6
  static define(): void;
4
7
  connectedCallback(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAErE,qBAAa,eAAgB,SAAQ,oBAAoB;IACrD,MAAM,CAAC,MAAM;IASb,iBAAiB,IAAI,IAAI;IAIzB,MAAM;CAwBT"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,qBAAa,eAAgB,SAAQ,oBAAoB;IACrD,MAAM,CAAC,MAAM;IASb,iBAAiB,IAAI,IAAI;IAIzB,MAAM;CA0BT"}
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ class SubstrateButton extends SubstrateButtonLight {
23
23
  tabindex,
24
24
  disabled
25
25
  } = this;
26
+ const name = this.getAttribute("name");
26
27
  const classes = [
27
28
  "substrate-button",
28
29
  this.getAttribute("class")
@@ -33,7 +34,8 @@ class SubstrateButton extends SubstrateButtonLight {
33
34
  disabled,
34
35
  autofocus,
35
36
  tabindex,
36
- type
37
+ type,
38
+ name
37
39
  };
38
40
  this.innerHTML = html(btnProps, text);
39
41
  }
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { html } from './html.js'\nimport { SubstrateButton as SubstrateButtonLight } from './client.js'\n\nexport class SubstrateButton extends SubstrateButtonLight {\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\n ]\n const text = this.innerHTML\n\n const btnProps = {\n classes: classes.filter(Boolean),\n disabled,\n autofocus,\n tabindex,\n type,\n }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
- "mappings": ";;AAAA,SAAS,YAAY;AACrB,SAAS,mBAAmB,4BAA4B;AAEjD,MAAM,wBAAwB,qBAAqB;AAAA,EAH1D,OAG0D;AAAA;AAAA;AAAA,EACtD,OAAO,SAAU;AACb,QAAI,EAAE,oBAAoB,QAAS;AAEnC,WAAO,eAAe;AAAA,MAClB,gBAAgB,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,oBAA0B;AACtB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,SAAU;AACN,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AAEJ,UAAM,UAA0B;AAAA,MAC5B;AAAA,MACA,KAAK,aAAa,OAAO;AAAA,IAC7B;AACA,UAAM,OAAO,KAAK;AAElB,UAAM,WAAW;AAAA,MACb,SAAS,QAAQ,OAAO,OAAO;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAEA,SAAK,YAAY,KAAK,UAAU,IAAI;AAAA,EACxC;AACJ;",
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 if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n const name = this.getAttribute('name')\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\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 }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,YAAY;AACrB,SAAS,mBAAmB,4BAA4B;AAKjD,MAAM,wBAAwB,qBAAqB;AAAA,EAN1D,OAM0D;AAAA;AAAA;AAAA,EACtD,OAAO,SAAU;AACb,QAAI,EAAE,oBAAoB,QAAS;AAEnC,WAAO,eAAe;AAAA,MAClB,gBAAgB,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,oBAA0B;AACtB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEA,SAAU;AACN,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AACJ,UAAM,OAAO,KAAK,aAAa,MAAM;AAErC,UAAM,UAA0B;AAAA,MAC5B;AAAA,MACA,KAAK,aAAa,OAAO;AAAA,IAC7B;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,IACJ;AAEA,SAAK,YAAY,KAAK,UAAU,IAAI;AAAA,EACxC;AACJ;",
6
6
  "names": []
7
7
  }
package/dist/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
- var g=Object.defineProperty;var n=(s,t)=>g(s,"name",{value:t,configurable:!0});function h(s,t){let{type:e,autofocus:r,tabindex:i,disabled:o,classes:a}=s,u=new Set(a);u.add("substrate-button");let l=Array.from(u),d=[l.length?`class="${l.filter(Boolean).join(" ")}"`:"",o?"disabled":"",r?"autofocus":"",e?`type="${e}"`:"",i?`tabindex="${i}"`:'tabindex="0"','role="button"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${o?" disabled":""}>
2
- <button ${d}>${t}</button>
3
- </substrate-button$>`:`<button ${d}>
1
+ var f=Object.defineProperty;var n=(s,t)=>f(s,"name",{value:t,configurable:!0});function h(s,t){let{type:e,autofocus:o,tabindex:i,disabled:r,classes:l,name:u}=s,a=new Set(l);a.add("substrate-button");let d=Array.from(a),c=[d.length?`class="${d.filter(Boolean).join(" ")}"`:"",r?"disabled":"",o?"autofocus":"",e?`type="${e}"`:"",u?`name=${u}`:"",i?`tabindex="${i}"`:'tabindex="0"','role="button"'].filter(Boolean).join(" ");return typeof window>"u"?`<substrate-button${r?" disabled":""}>
2
+ <button ${c}>${t}</button>
3
+ </substrate-button$>`:`<button ${c}>
4
4
  ${t}
5
- </button>`}n(h,"html");var b=class s extends HTMLElement{static{n(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;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){t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this._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.setAttribute("spinning",""):this.removeAttribute("spinning")}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){t?this._setAttribute("autofocus",t):this._removeAttribute("autofocus")}_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._setAttribute("autofocus",e)}handleChange_disabled(t,e){this.disabled=e!==null,e===null?this.button?.removeAttribute("disabled"):this.button?.setAttribute("disabled",""+e)}handleChange_spinning(t,e){e!==null?this.classList.add("substrate-loading"):this.classList.remove("substrate-loading")}attributeChangedCallback(t,e,r){let i=this[`handleChange_${t}`];i&&i.call(this,e,r)}connectedCallback(){this.render()}static define(){if("customElements"in window)return customElements.define(s.TAG||"substrate-button",s)}render(){}};var c=class s extends b{static{n(this,"SubstrateButton")}static define(){if("customElements"in window)return customElements.define(s.TAG||"substrate-button",s)}connectedCallback(){this.render()}render(){let{type:t,autofocus:e,tabindex:r,disabled:i}=this,o=["substrate-button",this.getAttribute("class")],a=this.innerHTML,u={classes:o.filter(Boolean),disabled:i,autofocus:e,tabindex:r,type:t};this.innerHTML=h(u,a)}};export{c as SubstrateButton};
5
+ </button>`}n(h,"html");var b=class s extends HTMLElement{static{n(this,"SubstrateButton")}static observedAttributes=["autofocus","disabled","spinning"];static TAG="substrate-button";_isSpinning;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){t?(this.button?.setAttribute("disabled",""),this.button?.setAttribute("aria-disabled","true")):(this._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.setAttribute("spinning",""):this.removeAttribute("spinning")}set type(t){this._setAttribute("type",t)}get autofocus(){return!!this.button?.hasAttribute("autofocus")}set autofocus(t){t?this._setAttribute("autofocus",t):this._removeAttribute("autofocus")}_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._setAttribute("autofocus",e)}handleChange_disabled(t,e){this.disabled=e!==null,e===null?this.button?.removeAttribute("disabled"):this.button?.setAttribute("disabled",""+e)}handleChange_spinning(t,e){e!==null?this.classList.add("substrate-loading"):this.classList.remove("substrate-loading")}attributeChangedCallback(t,e,o){let i=this[`handleChange_${t}`];i&&i.call(this,e,o)}connectedCallback(){this.render()}static define(){return A(s.TAG,s)}render(){}};function m(s){return document.createElement(s).constructor!==window.HTMLElement}n(m,"isRegistered");function A(s,t){window&&"customElements"in window&&(m(s)||window.customElements.define(s,t))}n(A,"define");var g=class s extends b{static{n(this,"SubstrateButton")}static define(){if("customElements"in window)return customElements.define(s.TAG||"substrate-button",s)}connectedCallback(){this.render()}render(){let{type:t,autofocus:e,tabindex:o,disabled:i}=this,r=this.getAttribute("name"),l=["substrate-button",this.getAttribute("class")],u=this.innerHTML,a={classes:l.filter(Boolean),disabled:i,autofocus:e,tabindex:o,type:t,name:r};this.innerHTML=h(a,u)}};export{g as SubstrateButton};
6
6
  //# sourceMappingURL=index.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/html.ts", "../src/client.ts", "../src/index.ts"],
4
- "sourcesContent": ["export type Attrs = {\n type:string|null;\n autofocus:boolean;\n tabindex:string|number;\n disabled:boolean;\n classes:string[]|Set<string>;\n}\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes\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 tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n 'role=\"button\"'\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 ${textContent}\n </button>`\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 + 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 } else {\n this.classList.remove('substrate-loading')\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 }\n\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n render () {\n // noop\n }\n}\n\n", "import { html } from './html.js'\nimport { SubstrateButton as SubstrateButtonLight } from './client.js'\n\nexport class SubstrateButton extends SubstrateButtonLight {\n static define () {\n if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\n ]\n const text = this.innerHTML\n\n const btnProps = {\n classes: classes.filter(Boolean),\n disabled,\n autofocus,\n tabindex,\n type,\n }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
- "mappings": "+EAOO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,CACJ,EAAIN,EAEEO,EAAW,IAAI,IAAID,CAAO,EAChCC,EAAS,IAAI,kBAAkB,EAC/B,IAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DH,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BE,EAAW,aAAaA,CAAQ,IAAM,eACtC,eACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBC,EAAW,YAAc,EAAE;AAAA,sBACjCI,CAAQ,IAAIR,CAAW;AAAA,8BAErC,WAAWQ,CAAQ;AAAA,cACbR,CAAW;AAAA,kBAEzB,CA9BgBS,EAAAX,EAAA,QCGT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CAChB,CAEA,QAAU,CACN,GAAM,CACF,KAAAE,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,CACJ,EAAI,KAEEC,EAA0B,CAC5B,mBACA,KAAK,aAAa,OAAO,CAC7B,EACMC,EAAO,KAAK,UAEZC,EAAW,CACb,QAASF,EAAQ,OAAO,OAAO,EAC/B,SAAAD,EACA,UAAAF,EACA,SAAAC,EACA,KAAAF,CACJ,EAEA,KAAK,UAAYO,EAAKD,EAAUD,CAAI,CACxC,CACJ",
6
- "names": ["html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "_classes", "arr", "btnProps", "__name", "SubstrateButton", "_SubstrateButton", "__name", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "oldValue", "handler", "SubstrateButton", "_SubstrateButton", "__name", "type", "autofocus", "tabindex", "disabled", "classes", "text", "btnProps", "html"]
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}\n\nexport function html (attrs:Partial<Attrs>, textContent:string) {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n classes,\n name\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 ]).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 ${textContent}\n </button>`\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 + 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 } else {\n this.classList.remove('substrate-loading')\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 }\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", "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 if (!('customElements' in window)) return\n\n return customElements.define(\n SubstrateButton.TAG || 'substrate-button',\n SubstrateButton\n )\n }\n\n connectedCallback ():void {\n this.render()\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n } = this\n const name = this.getAttribute('name')\n\n const classes:(string|null)[] = [\n 'substrate-button',\n this.getAttribute('class')\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 }\n\n this.innerHTML = html(btnProps, text)\n }\n}\n"],
5
+ "mappings": "+EASO,SAASA,EAAMC,EAAsBC,EAAoB,CAC5D,GAAM,CACF,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,KAAAC,CACJ,EAAIP,EAEEQ,EAAW,IAAI,IAAIF,CAAO,EAChCE,EAAS,IAAI,kBAAkB,EAC/B,IAAMC,EAAM,MAAM,KAAKD,CAAQ,EAEzBE,EAAY,CACdD,EAAI,OAAS,UAAUA,EAAI,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAAM,GAC1DJ,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAASA,CAAI,IAAM,GAC1BK,EAAO,QAAQA,CAAI,GAAK,GACxBH,EAAW,aAAaA,CAAQ,IAAM,eACtC,eACJ,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAG3B,OAAO,OAAO,OAAW,IACrB,oBAAoBC,EAAW,YAAc,EAAE;AAAA,sBACjCK,CAAQ,IAAIT,CAAW;AAAA,8BAErC,WAAWS,CAAQ;AAAA,cACbT,CAAW;AAAA,kBAEzB,CAhCgBU,EAAAZ,EAAA,QCCT,IAAMa,EAAN,MAAMC,UAAwB,WAAY,CAVjD,MAUiD,CAAAC,EAAA,wBAE7C,OAAO,mBAAqB,CAAC,YAAa,WAAY,UAAU,EAChE,OAAO,IAAM,mBACb,YAEA,aAAe,CACX,MAAM,EACW,KAAK,aAAa,UAAU,IAC5B,MACb,WAAW,IAAM,CAEb,KAAK,SAAW,EACpB,EAAG,CAAC,EAER,KAAK,UAAa,KAAK,aAAa,WAAW,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AAC,EACA,SAAAC,CACJ,EAAI,KACEC,EAAO,KAAK,aAAa,MAAM,EAE/BC,EAA0B,CAC5B,mBACA,KAAK,aAAa,OAAO,CAC7B,EACMC,EAAO,KAAK,UAEZC,EAAW,CACb,QAASF,EAAQ,OAAO,OAAO,EAC/B,SAAAF,EACA,UAAAF,EACA,SAAAC,EACA,KAAAF,EACA,KAAAI,CACJ,EAEA,KAAK,UAAYI,EAAKD,EAAUD,CAAI,CACxC,CACJ",
6
+ "names": ["html", "attrs", "textContent", "type", "autofocus", "tabindex", "disabled", "classes", "name", "_classes", "arr", "btnProps", "__name", "SubstrateButton", "_SubstrateButton", "__name", "disabledValue", "i", "value", "name", "_oldValue", "newValue", "_old", "_", "oldValue", "handler", "define", "isRegistered", "elName", "element", "SubstrateButton", "_SubstrateButton", "__name", "type", "autofocus", "tabindex", "disabled", "name", "classes", "text", "btnProps", "html"]
7
7
  }
package/dist/meta.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "inputs": {
3
3
  "src/client.ts": {
4
- "bytes": 5036,
4
+ "bytes": 5294,
5
5
  "imports": [],
6
6
  "format": "esm"
7
7
  },
8
8
  "src/html.ts": {
9
- "bytes": 1063,
9
+ "bytes": 1136,
10
10
  "imports": [],
11
11
  "format": "esm"
12
12
  },
13
13
  "src/index.ts": {
14
- "bytes": 955,
14
+ "bytes": 1102,
15
15
  "imports": [],
16
16
  "format": "esm"
17
17
  }
@@ -21,26 +21,28 @@
21
21
  "imports": [],
22
22
  "exports": [],
23
23
  "inputs": {},
24
- "bytes": 7805
24
+ "bytes": 8251
25
25
  },
26
26
  "dist/client.js": {
27
27
  "imports": [],
28
28
  "exports": [
29
- "SubstrateButton"
29
+ "SubstrateButton",
30
+ "define",
31
+ "isRegistered"
30
32
  ],
31
33
  "entryPoint": "src/client.ts",
32
34
  "inputs": {
33
35
  "src/client.ts": {
34
- "bytesInOutput": 3870
36
+ "bytesInOutput": 4127
35
37
  }
36
38
  },
37
- "bytes": 4064
39
+ "bytes": 4347
38
40
  },
39
41
  "dist/html.js.map": {
40
42
  "imports": [],
41
43
  "exports": [],
42
44
  "inputs": {},
43
- "bytes": 1778
45
+ "bytes": 1896
44
46
  },
45
47
  "dist/html.js": {
46
48
  "imports": [],
@@ -50,16 +52,16 @@
50
52
  "entryPoint": "src/html.ts",
51
53
  "inputs": {
52
54
  "src/html.ts": {
53
- "bytesInOutput": 801
55
+ "bytesInOutput": 843
54
56
  }
55
57
  },
56
- "bytes": 982
58
+ "bytes": 1024
57
59
  },
58
60
  "dist/index.js.map": {
59
61
  "imports": [],
60
62
  "exports": [],
61
63
  "inputs": {},
62
- "bytes": 1671
64
+ "bytes": 1864
63
65
  },
64
66
  "dist/index.js": {
65
67
  "imports": [
@@ -80,10 +82,10 @@
80
82
  "entryPoint": "src/index.ts",
81
83
  "inputs": {
82
84
  "src/index.ts": {
83
- "bytesInOutput": 839
85
+ "bytesInOutput": 895
84
86
  }
85
87
  },
86
- "bytes": 1032
88
+ "bytes": 1088
87
89
  }
88
90
  }
89
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrate-system/button",
3
- "version": "0.0.22",
3
+ "version": "0.0.28",
4
4
  "description": "A button component with a visual \"loading\" state",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,14 +22,8 @@
22
22
  "./css": "./dist/index.css",
23
23
  "./css/min": "./dist/index.min.css",
24
24
  "./*": {
25
- "import": [
26
- "./dist/*.js",
27
- "./dist/*"
28
- ],
29
- "require": [
30
- "./dist/*.cjs",
31
- "./dist/*"
32
- ]
25
+ "import": "./dist/*.js",
26
+ "require": "./dist/*.cjs"
33
27
  }
34
28
  },
35
29
  "scripts": {
@@ -69,12 +63,12 @@
69
63
  "postcss-cli": "^11.0.0",
70
64
  "postcss-nesting": "^13.0.1",
71
65
  "stylelint": "^16.9.0",
72
- "stylelint-config-standard": "^38.0.0",
66
+ "stylelint-config-standard": "^39.0.0",
73
67
  "tap-spec": "^5.0.0",
74
68
  "tape-run": "^11.0.0",
75
69
  "typedoc": "^0.28.1",
76
70
  "typescript": "^5.7.3",
77
- "vite": "^6.0.11"
71
+ "vite": "^7.0.2"
78
72
  },
79
73
  "author": "nichoth <nichoth@nichoth.com> (https://nichoth.com)",
80
74
  "license": "SEE LICENSE IN LICENSE",