@substrate-system/input 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ # PolyForm Small Business License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/small-business/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright Nick Thomas (https://nichoth.com)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Fair Use
53
+
54
+ You may have "fair use" rights for the software under the
55
+ law. These terms do not limit them.
56
+
57
+ ## Small Business
58
+
59
+ Use of the software for the benefit of your company is use for
60
+ a permitted purpose if your company has fewer than 100 total
61
+ individuals working as employees and independent contractors,
62
+ and less than 1,000,000 USD (2019) total revenue in the prior
63
+ tax year. Adjust this revenue threshold for inflation according
64
+ to the United States Bureau of Labor Statistics' consumer price
65
+ index for all urban consumers, U.S. city average, for all items,
66
+ not seasonally adjusted, with 1982–1984=100 reference base.
67
+
68
+ ## No Other Rights
69
+
70
+ These terms do not allow you to sublicense or transfer any of
71
+ your licenses to anyone else, or prevent the licensor from
72
+ granting licenses to anyone else. These terms do not imply
73
+ any other licenses.
74
+
75
+ ## Patent Defense
76
+
77
+ If you make any written claim that the software infringes or
78
+ contributes to infringement of any patent, your patent license
79
+ for the software granted under these terms ends immediately. If
80
+ your company makes such a claim, your patent license ends
81
+ immediately for work on behalf of your company.
82
+
83
+ ## Violations
84
+
85
+ The first time you are notified in writing that you have
86
+ violated any of these terms, or done anything with the software
87
+ not covered by your licenses, your licenses can nonetheless
88
+ continue if you come into full compliance with these terms,
89
+ and take practical steps to correct past violations, within
90
+ 32 days of receiving notice. Otherwise, all your licenses
91
+ end immediately.
92
+
93
+ ## No Liability
94
+
95
+ ***As far as the law allows, the software comes as is, without
96
+ any warranty or condition, and the licensor will not be liable
97
+ to you for any damages arising out of these terms or the use
98
+ or nature of the software, under any kind of legal claim.***
99
+
100
+ ## Definitions
101
+
102
+ The **licensor** is the individual or entity offering these
103
+ terms, and the **software** is the software the licensor makes
104
+ available under these terms.
105
+
106
+ **You** refers to the individual or entity agreeing to these
107
+ terms.
108
+
109
+ **Your company** is any legal entity, sole proprietorship,
110
+ or other kind of organization that you work for, plus all
111
+ organizations that have control over, are under the control of,
112
+ or are under common control with that organization. **Control**
113
+ means ownership of substantially all the assets of an entity,
114
+ or the power to direct its management and policies by vote,
115
+ contract, or otherwise. Control can be direct or indirect.
116
+
117
+ **Your licenses** are all the licenses granted to you for the
118
+ software under these terms.
119
+
120
+ **Use** means anything you do with the software requiring one
121
+ of your licenses.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # input
2
+ ![tests](https://github.com/substrate-system/input/actions/workflows/nodejs.yml/badge.svg)
3
+ [![types](https://img.shields.io/npm/types/@substrate-system/input?style=flat-square)](README.md)
4
+ [![module](https://img.shields.io/badge/module-ESM%2FCJS-blue?style=flat-square)](README.md)
5
+ [![install size](https://packagephobia.com/badge?p=@substrate-system/input)](https://packagephobia.com/result?p=@substrate-system/input)
6
+ <!-- [![GZip size](https://img.badgesize.io/https%3A%2F%2Fesm.sh%2F%40substrate-system%2Finput%2Fes2022%2Finput.mjs?style=flat-square&compression=gzip)](https://esm.sh/@substrate-system/input/es2022/input.mjs) -->
7
+ [![dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg?style=flat-square)](package.json)
8
+ [![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&style=flat-square)](https://semver.org/)
9
+ [![Common Changelog](https://nichoth.github.io/badge/common-changelog.svg)](./CHANGELOG.md)
10
+ [![license](https://img.shields.io/badge/license-Polyform_Small_Business-249fbc?style=flat-square)](LICENSE)
11
+
12
+
13
+ A parent web component to inherit from.
14
+
15
+ [See a live demo](https://substrate-system.github.io/input/)
16
+
17
+ <!-- toc -->
18
+
19
+ ## install
20
+
21
+ ```sh
22
+ npm i -S @substrate-system/input
23
+ ```
24
+
25
+ ## API
26
+
27
+ This exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).
28
+
29
+ ### ESM
30
+ ```js
31
+ import { Input } from '@substrate-system/input'
32
+ ```
33
+
34
+ ### Common JS
35
+ ```js
36
+ const { Input } = require('@substrate-system/input')
37
+ ```
38
+
39
+ -----------------
40
+
41
+ ## Use
42
+ Inherit from this module. It has some methods for common event handling.
43
+
44
+ ### JS
45
+ ```js
46
+ import { Input } from '@substrate-system/input'
47
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ Input: () => Input
23
+ });
24
+ module.exports = __toCommonJS(index_exports);
25
+ var import_debug = require("@substrate-system/debug");
26
+ const debug = (0, import_debug.createDebug)();
27
+ class Input extends HTMLElement {
28
+ static {
29
+ __name(this, "Input");
30
+ }
31
+ // Define the attributes to observe
32
+ // need this for `attributeChangedCallback`
33
+ static observedAttributes = ["autofocus", "disabled", "spinning"];
34
+ static tag;
35
+ static define() {
36
+ if (!("customElements" in window)) return;
37
+ if (customElements.get(this.tag)) return;
38
+ return customElements.define(this.tag, this);
39
+ }
40
+ constructor() {
41
+ super();
42
+ const disabled = this.getAttribute("disabled");
43
+ if (disabled !== null) {
44
+ setTimeout(() => {
45
+ this.disabled = true;
46
+ }, 0);
47
+ }
48
+ setTimeout(() => {
49
+ const attr = this.getAttribute("value");
50
+ if (attr) {
51
+ this.value = attr;
52
+ }
53
+ }, 0);
54
+ }
55
+ get input() {
56
+ return this.querySelector("input");
57
+ }
58
+ get tabindex() {
59
+ const i = this.input?.getAttribute("tabindex");
60
+ if (!i) return 0;
61
+ return parseInt(i);
62
+ }
63
+ /**
64
+ * Remove from `this` element and also child.
65
+ */
66
+ _removeAttribute(name) {
67
+ this.removeAttribute(name);
68
+ this.input?.removeAttribute(name);
69
+ }
70
+ get disabled() {
71
+ return !!this.input?.hasAttribute("disabled");
72
+ }
73
+ set disabled(disabledValue) {
74
+ if (!disabledValue) {
75
+ this._removeAttribute("disabled");
76
+ this.input?.setAttribute("aria-disabled", "false");
77
+ } else {
78
+ this.input?.setAttribute("disabled", "");
79
+ this.input?.setAttribute("aria-disabled", "true");
80
+ }
81
+ }
82
+ /**
83
+ * Handle 'example' attribute changes
84
+ * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}
85
+ *
86
+ * @param {string} oldValue The old attribute value
87
+ * @param {string} newValue The new attribute value
88
+ */
89
+ handleChange_disabled(oldValue, newValue) {
90
+ debug("changing disabled", oldValue, newValue);
91
+ if (!this.input) {
92
+ debug("not input");
93
+ setTimeout(() => {
94
+ if (newValue === null) {
95
+ this.disabled = false;
96
+ } else {
97
+ this.disabled = true;
98
+ }
99
+ }, 0);
100
+ } else {
101
+ debug("input");
102
+ if (newValue === null) {
103
+ debug("is null");
104
+ this.disabled = false;
105
+ } else {
106
+ this.disabled = true;
107
+ }
108
+ }
109
+ }
110
+ /**
111
+ * Runs when the value of an attribute is changed
112
+ *
113
+ * @param {string} name The attribute name
114
+ * @param {string} oldValue The old attribute value
115
+ * @param {string} newValue The new attribute value
116
+ */
117
+ attributeChangedCallback(name, oldValue, newValue) {
118
+ const handler = this[`handleChange_${name}`];
119
+ handler && handler.call(this, oldValue, newValue);
120
+ this.render();
121
+ }
122
+ connectedCallback() {
123
+ this.render();
124
+ }
125
+ get type() {
126
+ return this.input?.getAttribute("type");
127
+ }
128
+ set type(value) {
129
+ this._setAttribute("type", value);
130
+ }
131
+ get value() {
132
+ return this.input?.value;
133
+ }
134
+ set value(text) {
135
+ if (!text) this.input?.removeAttribute("value");
136
+ else {
137
+ this.input.value = text;
138
+ }
139
+ }
140
+ /**
141
+ * Set attributes on the internal input element.
142
+ */
143
+ _setAttribute(name, value) {
144
+ if (!value) {
145
+ return this._removeAttribute(name);
146
+ }
147
+ if (value === true) {
148
+ return this.input?.setAttribute(name, "");
149
+ }
150
+ this.input?.setAttribute(name, value);
151
+ }
152
+ render() {
153
+ const {
154
+ type,
155
+ autofocus,
156
+ tabindex,
157
+ disabled,
158
+ value
159
+ } = this;
160
+ const classes = ["substrate-input"];
161
+ const btn = !!(this.type === "submit" || this.type === "button");
162
+ const props = [
163
+ `class="${classes.filter(Boolean).join(" ")}"`,
164
+ disabled ? "disabled" : "",
165
+ autofocus ? "autofocus" : "",
166
+ type ? `type="${this.type}"` : "",
167
+ tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
168
+ btn ? 'role="button"' : "",
169
+ value ? `value=${value}` : ""
170
+ ].filter(Boolean).join(" ");
171
+ this.innerHTML = `<input
172
+ ${props}
173
+ />`;
174
+ }
175
+ }
176
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { createDebug } from '@substrate-system/debug'\nconst debug = createDebug()\n\nexport abstract class Input extends HTMLElement {\n // Define the attributes to observe\n // need this for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled', 'spinning']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) {\n this.value = attr\n }\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n debug('changing disabled', oldValue, newValue)\n if (!this.input) {\n debug('not input')\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n debug('input')\n if (newValue === null) {\n debug('is null')\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : ''\n ]).filter(Boolean).join(' ')\n\n this.innerHTML = `<input\n ${props}\n />`\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAC5B,MAAM,YAAQ,0BAAY;AAEnB,MAAe,cAAc,YAAY;AAAA,EAHhD,OAGgD;AAAA;AAAA;AAAA;AAAA;AAAA,EAG5C,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO;AAAA,EAEP,OAAO,SAA8D;AACjE,QAAI,EAAE,oBAAoB,QAAS;AACnC,QAAI,eAAe,IAAI,KAAK,GAAG,EAAG;AAElC,WAAO,eAAe,OAAO,KAAK,KAAK,IAAI;AAAA,EAC/C;AAAA,EAEA,cAAe;AACX,UAAM;AACN,UAAM,WAAW,KAAK,aAAa,UAAU;AAC7C,QAAI,aAAa,MAAM;AACnB,iBAAW,MAAM;AAEb,aAAK,WAAW;AAAA,MACpB,GAAG,CAAC;AAAA,IACR;AAEA,eAAW,MAAM;AACb,YAAM,OAAO,KAAK,aAAa,OAAO;AACtC,UAAI,MAAM;AACN,aAAK,QAAQ;AAAA,MACjB;AAAA,IACJ,GAAG,CAAC;AAAA,EACR;AAAA,EAEA,IAAI,QAA+B;AAC/B,WAAO,KAAK,cAAc,OAAO;AAAA,EACrC;AAAA,EAEA,IAAI,WAAmB;AACnB,UAAM,IAAI,KAAK,OAAO,aAAa,UAAU;AAC7C,QAAI,CAAC,EAAG,QAAO;AACf,WAAO,SAAS,CAAC;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAkB,MAAa;AAC3B,SAAK,gBAAgB,IAAI;AACzB,SAAK,OAAO,gBAAgB,IAAI;AAAA,EACpC;AA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,EACvB;AAAA,EAEA,IAAI,MAAO,MAA4B;AACnC,QAAI,CAAC,KAAM,MAAK,OAAO,gBAAgB,OAAO;AAAA,SACzC;AACD,WAAK,MAAO,QAAQ;AAAA,IACxB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,cAAe,MAAa,OAAgC;AACxD,QAAI,CAAC,OAAO;AACR,aAAO,KAAK,iBAAiB,IAAI;AAAA,IACrC;AAEA,QAAI,UAAU,MAAM;AAEhB,aAAO,KAAK,OAAO,aAAa,MAAM,EAAE;AAAA,IAC5C;AAGA,SAAK,OAAO,aAAa,MAAM,KAAK;AAAA,EACxC;AAAA,EAEA,SAAU;AACN,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AAEJ,UAAM,UAAmB,CAAC,iBAAiB;AAE3C,UAAM,MAAM,CAAC,EAAE,KAAK,SAAS,YAAY,KAAK,SAAS;AAEvD,UAAM,QAAS;AAAA,MACX,UAAU,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAAA,MAC3C,WAAW,aAAa;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,OAAO,SAAS,KAAK,IAAI,MAAM;AAAA,MAC/B,WAAW,aAAa,QAAQ,MAAM;AAAA,MACtC,MAAM,kBAAkB;AAAA,MACxB,QAAQ,SAAS,KAAK,KAAK;AAAA,IAC/B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAE3B,SAAK,YAAY;AAAA,cACX,KAAK;AAAA;AAAA,EAEf;AACJ;",
6
+ "names": []
7
+ }
package/dist/index.css ADDED
@@ -0,0 +1,5 @@
1
+ input {
2
+ font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
3
+ }
4
+
5
+ /*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9pbmRleC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7SUFDSSw2RUFBNkU7QUFDakYiLCJmaWxlIjoic3JjL2luZGV4LmNzcyIsInNvdXJjZXNDb250ZW50IjpbImlucHV0IHtcbiAgICBmb250LWZhbWlseTogJ0dpbGwgU2FucycsICdHaWxsIFNhbnMgTVQnLCBDYWxpYnJpLCAnVHJlYnVjaGV0IE1TJywgc2Fucy1zZXJpZjtcbn1cbiJdfQ== */
@@ -0,0 +1,41 @@
1
+ export declare abstract class Input extends HTMLElement {
2
+ static observedAttributes: string[];
3
+ static tag: string;
4
+ static define(this: ((new (...args: any[]) => Input) & typeof Input)): void;
5
+ constructor();
6
+ get input(): HTMLInputElement | null;
7
+ get tabindex(): number;
8
+ /**
9
+ * Remove from `this` element and also child.
10
+ */
11
+ _removeAttribute(name: string): void;
12
+ get disabled(): boolean;
13
+ set disabled(disabledValue: boolean);
14
+ /**
15
+ * Handle 'example' attribute changes
16
+ * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}
17
+ *
18
+ * @param {string} oldValue The old attribute value
19
+ * @param {string} newValue The new attribute value
20
+ */
21
+ handleChange_disabled(oldValue: string, newValue: string): void;
22
+ /**
23
+ * Runs when the value of an attribute is changed
24
+ *
25
+ * @param {string} name The attribute name
26
+ * @param {string} oldValue The old attribute value
27
+ * @param {string} newValue The new attribute value
28
+ */
29
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
30
+ connectedCallback(): void;
31
+ get type(): string | null | undefined;
32
+ set type(value: string);
33
+ get value(): string | undefined | null;
34
+ set value(text: string | undefined | null);
35
+ /**
36
+ * Set attributes on the internal input element.
37
+ */
38
+ _setAttribute(name: string, value: boolean | string | null): void;
39
+ render(): void;
40
+ }
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,8BAAsB,KAAM,SAAQ,WAAW;IAG3C,MAAM,CAAC,kBAAkB,WAAwC;IACjE,MAAM,CAAC,GAAG,EAAC,MAAM,CAAA;IAEjB,MAAM,CAAC,MAAM,CAAE,IAAI,EAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAC,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,OAAO,KAAK,CAAC;;IAyBnE,IAAI,KAAK,IAAI,gBAAgB,GAAC,IAAI,CAEjC;IAED,IAAI,QAAQ,IAAI,MAAM,CAIrB;IAED;;OAEG;IACH,gBAAgB,CAAE,IAAI,EAAC,MAAM;IAK7B,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAE,aAAa,EAAC,OAAO,EAQlC;IAED;;;;;;OAMG;IACH,qBAAqB,CAAE,QAAQ,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM;IAwBvD;;;;;;OAMG;IACH,wBAAwB,CAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM;IAMvE,iBAAiB;IAIjB,IAAI,IAAI,IAAI,MAAM,GAAC,IAAI,GAAC,SAAS,CAEhC;IAED,IAAI,IAAI,CAAE,KAAK,EAAC,MAAM,EAErB;IAED,IAAI,KAAK,IAIO,MAAM,GAAC,SAAS,GAAC,IAAI,CAFpC;IAED,IAAI,KAAK,CAAE,IAAI,EAAC,MAAM,GAAC,SAAS,GAAC,IAAI,EAKpC;IAED;;OAEG;IACH,aAAa,CAAE,IAAI,EAAC,MAAM,EAAE,KAAK,EAAC,OAAO,GAAC,MAAM,GAAC,IAAI,GAAE,IAAI;IAc3D,MAAM;CA2BT"}
package/dist/index.js ADDED
@@ -0,0 +1,157 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { createDebug } from "@substrate-system/debug";
4
+ const debug = createDebug();
5
+ class Input extends HTMLElement {
6
+ static {
7
+ __name(this, "Input");
8
+ }
9
+ // Define the attributes to observe
10
+ // need this for `attributeChangedCallback`
11
+ static observedAttributes = ["autofocus", "disabled", "spinning"];
12
+ static tag;
13
+ static define() {
14
+ if (!("customElements" in window)) return;
15
+ if (customElements.get(this.tag)) return;
16
+ return customElements.define(this.tag, this);
17
+ }
18
+ constructor() {
19
+ super();
20
+ const disabled = this.getAttribute("disabled");
21
+ if (disabled !== null) {
22
+ setTimeout(() => {
23
+ this.disabled = true;
24
+ }, 0);
25
+ }
26
+ setTimeout(() => {
27
+ const attr = this.getAttribute("value");
28
+ if (attr) {
29
+ this.value = attr;
30
+ }
31
+ }, 0);
32
+ }
33
+ get input() {
34
+ return this.querySelector("input");
35
+ }
36
+ get tabindex() {
37
+ const i = this.input?.getAttribute("tabindex");
38
+ if (!i) return 0;
39
+ return parseInt(i);
40
+ }
41
+ /**
42
+ * Remove from `this` element and also child.
43
+ */
44
+ _removeAttribute(name) {
45
+ this.removeAttribute(name);
46
+ this.input?.removeAttribute(name);
47
+ }
48
+ get disabled() {
49
+ return !!this.input?.hasAttribute("disabled");
50
+ }
51
+ set disabled(disabledValue) {
52
+ if (!disabledValue) {
53
+ this._removeAttribute("disabled");
54
+ this.input?.setAttribute("aria-disabled", "false");
55
+ } else {
56
+ this.input?.setAttribute("disabled", "");
57
+ this.input?.setAttribute("aria-disabled", "true");
58
+ }
59
+ }
60
+ /**
61
+ * Handle 'example' attribute changes
62
+ * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}
63
+ *
64
+ * @param {string} oldValue The old attribute value
65
+ * @param {string} newValue The new attribute value
66
+ */
67
+ handleChange_disabled(oldValue, newValue) {
68
+ debug("changing disabled", oldValue, newValue);
69
+ if (!this.input) {
70
+ debug("not input");
71
+ setTimeout(() => {
72
+ if (newValue === null) {
73
+ this.disabled = false;
74
+ } else {
75
+ this.disabled = true;
76
+ }
77
+ }, 0);
78
+ } else {
79
+ debug("input");
80
+ if (newValue === null) {
81
+ debug("is null");
82
+ this.disabled = false;
83
+ } else {
84
+ this.disabled = true;
85
+ }
86
+ }
87
+ }
88
+ /**
89
+ * Runs when the value of an attribute is changed
90
+ *
91
+ * @param {string} name The attribute name
92
+ * @param {string} oldValue The old attribute value
93
+ * @param {string} newValue The new attribute value
94
+ */
95
+ attributeChangedCallback(name, oldValue, newValue) {
96
+ const handler = this[`handleChange_${name}`];
97
+ handler && handler.call(this, oldValue, newValue);
98
+ this.render();
99
+ }
100
+ connectedCallback() {
101
+ this.render();
102
+ }
103
+ get type() {
104
+ return this.input?.getAttribute("type");
105
+ }
106
+ set type(value) {
107
+ this._setAttribute("type", value);
108
+ }
109
+ get value() {
110
+ return this.input?.value;
111
+ }
112
+ set value(text) {
113
+ if (!text) this.input?.removeAttribute("value");
114
+ else {
115
+ this.input.value = text;
116
+ }
117
+ }
118
+ /**
119
+ * Set attributes on the internal input element.
120
+ */
121
+ _setAttribute(name, value) {
122
+ if (!value) {
123
+ return this._removeAttribute(name);
124
+ }
125
+ if (value === true) {
126
+ return this.input?.setAttribute(name, "");
127
+ }
128
+ this.input?.setAttribute(name, value);
129
+ }
130
+ render() {
131
+ const {
132
+ type,
133
+ autofocus,
134
+ tabindex,
135
+ disabled,
136
+ value
137
+ } = this;
138
+ const classes = ["substrate-input"];
139
+ const btn = !!(this.type === "submit" || this.type === "button");
140
+ const props = [
141
+ `class="${classes.filter(Boolean).join(" ")}"`,
142
+ disabled ? "disabled" : "",
143
+ autofocus ? "autofocus" : "",
144
+ type ? `type="${this.type}"` : "",
145
+ tabindex ? `tabindex="${tabindex}"` : 'tabindex="0"',
146
+ btn ? 'role="button"' : "",
147
+ value ? `value=${value}` : ""
148
+ ].filter(Boolean).join(" ");
149
+ this.innerHTML = `<input
150
+ ${props}
151
+ />`;
152
+ }
153
+ }
154
+ export {
155
+ Input
156
+ };
157
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { createDebug } from '@substrate-system/debug'\nconst debug = createDebug()\n\nexport abstract class Input extends HTMLElement {\n // Define the attributes to observe\n // need this for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled', 'spinning']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) {\n this.value = attr\n }\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n debug('changing disabled', oldValue, newValue)\n if (!this.input) {\n debug('not input')\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n debug('input')\n if (newValue === null) {\n debug('is null')\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : ''\n ]).filter(Boolean).join(' ')\n\n this.innerHTML = `<input\n ${props}\n />`\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,mBAAmB;AAC5B,MAAM,QAAQ,YAAY;AAEnB,MAAe,cAAc,YAAY;AAAA,EAHhD,OAGgD;AAAA;AAAA;AAAA;AAAA;AAAA,EAG5C,OAAO,qBAAqB,CAAC,aAAa,YAAY,UAAU;AAAA,EAChE,OAAO;AAAA,EAEP,OAAO,SAA8D;AACjE,QAAI,EAAE,oBAAoB,QAAS;AACnC,QAAI,eAAe,IAAI,KAAK,GAAG,EAAG;AAElC,WAAO,eAAe,OAAO,KAAK,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AS;AAEvD,UAAM,QAAS;AAAA,MACX,UAAU,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAAA,MAC3C,WAAW,aAAa;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,OAAO,SAAS,KAAK,IAAI,MAAM;AAAA,MAC/B,WAAW,aAAa,QAAQ,MAAM;AAAA,MACtC,MAAM,kBAAkB;AAAA,MACxB,QAAQ,SAAS,KAAK,KAAK;AAAA,IAC/B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG;AAE3B,SAAK,YAAY;AAAA,cACX,KAAK;AAAA;AAAA,EAEf;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ input{font-family:Gill Sans,Gill Sans MT,Calibri,Trebuchet MS,sans-serif}
2
+ /*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9pbmRleC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFDSSxrRUFDSiIsImZpbGUiOiJzcmMvaW5kZXguY3NzIiwic291cmNlc0NvbnRlbnQiOlsiaW5wdXQge1xuICAgIGZvbnQtZmFtaWx5OiAnR2lsbCBTYW5zJywgJ0dpbGwgU2FucyBNVCcsIENhbGlicmksICdUcmVidWNoZXQgTVMnLCBzYW5zLXNlcmlmO1xufVxuIl19 */
@@ -0,0 +1,4 @@
1
+ var U=Object.create;var b=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var s=(e,t)=>b(e,"name",{value:t,configurable:!0});var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var V=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of k(t))!I.call(e,i)&&i!==r&&b(e,i,{get:()=>t[i],enumerable:!(n=$(t,i))||n.enumerable});return e};var R=(e,t,r)=>(r=e!=null?U(G(e)):{},V(t||!e||!e.__esModule?b(r,"default",{value:e,enumerable:!0}):r,e));var y=L((Y,m)=>{"use strict";var C=1e3,d=C*60,f=d*60,a=f*24,N=a*7,O=a*365.25;m.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return j(e);if(r==="number"&&isFinite(e))return t.long?H(e):z(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function j(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*O;case"weeks":case"week":case"w":return r*N;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*f;case"minutes":case"minute":case"mins":case"min":case"m":return r*d;case"seconds":case"second":case"secs":case"sec":case"s":return r*C;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}s(j,"parse");function z(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+"d":t>=f?Math.round(e/f)+"h":t>=d?Math.round(e/d)+"m":t>=C?Math.round(e/C)+"s":e+"ms"}s(z,"fmtShort");function H(e){var t=Math.abs(e);return t>=a?h(e,t,a,"day"):t>=f?h(e,t,f,"hour"):t>=d?h(e,t,d,"minute"):t>=C?h(e,t,C,"second"):e+" ms"}s(H,"fmtLong");function h(e,t,r,n){var i=t>=r*1.5;return Math.round(e/r)+" "+n+(i?"s":"")}s(h,"plural")});var D=R(y(),1);function A(e){return e instanceof Error?e.stack||e.message:String(e)}s(A,"coerce");function E(e,t){let r=0;for(let n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t[Math.abs(r)%t.length]}s(E,"selectColor");function v(e){return e.split(/[\s,]+/).filter(Boolean).map(n=>n.replace(/\*/g,".*?")).map(n=>new RegExp("^"+n+"$"))}s(v,"createRegexFromEnvVar");function x(e=6){return Math.random().toString(20).substring(2,e)}s(x,"generateRandomString");var w=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];var J=console.log||(()=>{});function P(e,t){return t&&(t.VITE_DEBUG==="*"||t.DEBUG==="*")?!0:e==="DEV"?!t||!t.VITE_DEBUG&&!t.DEBUG:!t||!t.VITE_DEBUG&&!t.DEBUG?!1:v(e).some(n=>n.test(t.VITE_DEBUG||t.DEBUG))}s(P,"isEnabled");function Z(){return{j:s(function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+String(t)}},"j")}}s(Z,"createFormatters");function q(e,t,{prevTime:r,color:n},i){if(!P(e,i||import.meta.env))return;let u=Number(new Date),c=u-(r||u);r=u,t[0]=A(t[0]);let l=Z();typeof t[0]!="string"&&t.unshift("%O");let o=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(F,S)=>{if(F==="%%")return"%";o++;let p=l[S];if(typeof p=="function"){let T=t[o];F=p.call(self,T),t.splice(o,1),o--}return F});let B=Q({diff:c,color:n,useColors:K(),namespace:e},t);J(...B)}s(q,"logger");function K(){return typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:!!(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}s(K,"shouldUseColors");function Q({diff:e,color:t,namespace:r,useColors:n},i){if(i[0]=(n?"%c":"")+r+(n?" %c":" ")+i[0]+(n?"%c ":" ")+"+"+(0,D.default)(e),!n)return;let u="color: "+t;i.splice(1,0,u,"color: inherit");let c=0,l=0;return i[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(c++,o==="%c"&&(l=c))}),i.splice(l,0,u),i}s(Q,"formatArgs");function M(e,t){if(e===!1)return W;let r=Number(new Date),n=E(typeof e=="string"?e:x(10),w);return s(function(...u){return q(typeof e=="string"?e:"DEV",u,{prevTime:r,color:n},t)},"debug")}s(M,"createDebug");function W(){}s(W,"noop");var g=M(),_=class extends HTMLElement{static{s(this,"Input")}static observedAttributes=["autofocus","disabled","spinning"];static tag;static define(){if("customElements"in window&&!customElements.get(this.tag))return customElements.define(this.tag,this)}constructor(){super(),this.getAttribute("disabled")!==null&&setTimeout(()=>{this.disabled=!0},0),setTimeout(()=>{let r=this.getAttribute("value");r&&(this.value=r)},0)}get input(){return this.querySelector("input")}get tabindex(){let t=this.input?.getAttribute("tabindex");return t?parseInt(t):0}_removeAttribute(t){this.removeAttribute(t),this.input?.removeAttribute(t)}get disabled(){return!!this.input?.hasAttribute("disabled")}set disabled(t){t?(this.input?.setAttribute("disabled",""),this.input?.setAttribute("aria-disabled","true")):(this._removeAttribute("disabled"),this.input?.setAttribute("aria-disabled","false"))}handleChange_disabled(t,r){g("changing disabled",t,r),this.input?(g("input"),r===null?(g("is null"),this.disabled=!1):this.disabled=!0):(g("not input"),setTimeout(()=>{r===null?this.disabled=!1:this.disabled=!0},0))}attributeChangedCallback(t,r,n){let i=this[`handleChange_${t}`];i&&i.call(this,r,n),this.render()}connectedCallback(){this.render()}get type(){return this.input?.getAttribute("type")}set type(t){this._setAttribute("type",t)}get value(){return this.input?.value}set value(t){t?this.input.value=t:this.input?.removeAttribute("value")}_setAttribute(t,r){if(!r)return this._removeAttribute(t);if(r===!0)return this.input?.setAttribute(t,"");this.input?.setAttribute(t,r)}render(){let{type:t,autofocus:r,tabindex:n,disabled:i,value:u}=this,c=["substrate-input"],l=this.type==="submit"||this.type==="button",o=[`class="${c.filter(Boolean).join(" ")}"`,i?"disabled":"",r?"autofocus":"",t?`type="${this.type}"`:"",n?`tabindex="${n}"`:'tabindex="0"',l?'role="button"':"",u?`value=${u}`:""].filter(Boolean).join(" ");this.innerHTML=`<input
2
+ ${o}
3
+ />`}};export{_ as Input};
4
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/ms/index.js", "../node_modules/@substrate-system/debug/src/browser/index.ts", "../node_modules/@substrate-system/debug/src/common.ts", "../node_modules/@substrate-system/debug/src/browser/util.ts", "../src/index.ts"],
4
+ "sourcesContent": ["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", null, null, null, "import { createDebug } from '@substrate-system/debug'\nconst debug = createDebug()\n\nexport abstract class Input extends HTMLElement {\n // Define the attributes to observe\n // need this for `attributeChangedCallback`\n static observedAttributes = ['autofocus', 'disabled', 'spinning']\n static tag:string\n\n static define (this:((new (...args:any[]) => Input) & typeof Input)) {\n if (!('customElements' in window)) return\n if (customElements.get(this.tag)) return // only define it once\n\n return customElements.define(this.tag, this)\n }\n\n constructor () {\n super()\n const disabled = this.getAttribute('disabled')\n if (disabled !== null) {\n setTimeout(() => {\n // need to wait for it to render\n this.disabled = true\n }, 0)\n }\n\n setTimeout(() => {\n const attr = this.getAttribute('value')\n if (attr) {\n this.value = attr\n }\n }, 0)\n }\n\n get input ():HTMLInputElement|null {\n return this.querySelector('input')\n }\n\n get tabindex ():number {\n const i = this.input?.getAttribute('tabindex')\n if (!i) return 0\n return parseInt(i)\n }\n\n /**\n * Remove from `this` element and also child.\n */\n _removeAttribute (name:string) {\n this.removeAttribute(name)\n this.input?.removeAttribute(name)\n }\n\n get disabled ():boolean {\n return !!(this.input?.hasAttribute('disabled'))\n }\n\n set disabled (disabledValue:boolean) {\n if (!disabledValue) {\n this._removeAttribute('disabled')\n this.input?.setAttribute('aria-disabled', 'false')\n } else {\n this.input?.setAttribute('disabled', '')\n this.input?.setAttribute('aria-disabled', 'true')\n }\n }\n\n /**\n * Handle 'example' attribute changes\n * @see {@link https://gomakethings.com/how-to-detect-when-attributes-change-on-a-web-component/#organizing-your-code Go Make Things article}\n *\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n handleChange_disabled (oldValue:string, newValue:string) {\n debug('changing disabled', oldValue, newValue)\n if (!this.input) {\n debug('not input')\n setTimeout(() => {\n if (newValue === null) {\n // [example] was removed\n this.disabled = false\n } else {\n // set [example] attribute\n this.disabled = true\n }\n }, 0) // wait to render\n } else {\n debug('input')\n if (newValue === null) {\n debug('is null')\n this.disabled = false\n } else {\n this.disabled = true\n }\n }\n }\n\n /**\n * Runs when the value of an attribute is changed\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n attributeChangedCallback (name:string, oldValue:string, newValue:string) {\n const handler = this[`handleChange_${name}`];\n (handler && handler.call(this, oldValue, newValue))\n this.render()\n }\n\n connectedCallback () {\n this.render()\n }\n\n get type ():string|null|undefined {\n return this.input?.getAttribute('type')\n }\n\n set type (value:string) {\n this._setAttribute('type', value)\n }\n\n get value () {\n return this.input?.value\n }\n\n set value (text:string|undefined|null) {\n if (!text) this.input?.removeAttribute('value')\n else {\n this.input!.value = text\n }\n }\n\n /**\n * Set attributes on the internal input element.\n */\n _setAttribute (name:string, value:boolean|string|null):void {\n if (!value) {\n return this._removeAttribute(name)\n }\n\n if (value === true) {\n // true means set the attribute with no value\n return this.input?.setAttribute(name, '')\n }\n\n // else, set the value\n this.input?.setAttribute(name, value)\n }\n\n render () {\n const {\n type,\n autofocus,\n tabindex,\n disabled,\n value\n } = this\n\n const classes:string[] = ['substrate-input']\n\n const btn = !!(this.type === 'submit' || this.type === 'button')\n\n const props = ([\n `class=\"${classes.filter(Boolean).join(' ')}\"`,\n disabled ? 'disabled' : '',\n autofocus ? 'autofocus' : '',\n type ? `type=\"${this.type}\"` : '',\n tabindex ? `tabindex=\"${tabindex}\"` : 'tabindex=\"0\"',\n btn ? 'role=\"button\"' : '',\n value ? `value=${value}` : ''\n ]).filter(Boolean).join(' ')\n\n this.innerHTML = `<input\n ${props}\n />`\n }\n}\n"],
5
+ "mappings": "4jBAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,cAIA,IAAIC,EAAI,IACJC,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EA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,CAC9B,OAAO,KAAK,OAAO,aAAa,MAAM,CAC1C,CAEA,IAAI,KAAME,EAAc,CACpB,KAAK,cAAc,OAAQA,CAAK,CACpC,CAEA,IAAI,OAAS,CACT,OAAO,KAAK,OAAO,KACvB,CAEA,IAAI,MAAOC,EAA4B,CAC9BA,EAED,KAAK,MAAO,MAAQA,EAFb,KAAK,OAAO,gBAAgB,OAAO,CAIlD,CAKA,cAAeN,EAAaK,EAAgC,CACxD,GAAI,CAACA,EACD,OAAO,KAAK,iBAAiBL,CAAI,EAGrC,GAAIK,IAAU,GAEV,OAAO,KAAK,OAAO,aAAaL,EAAM,EAAE,EAI5C,KAAK,OAAO,aAAaA,EAAMK,CAAK,CACxC,CAEA,QAAU,CACN,GAAM,CACF,KAAAE,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAL,CACJ,EAAI,KAEEM,EAAmB,CAAC,iBAAiB,EAErCC,EAAS,KAAK,OAAS,UAAY,KAAK,OAAS,SAEjDC,EAAS,CACX,UAAUF,EAAQ,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,IAC3CD,EAAW,WAAa,GACxBF,EAAY,YAAc,GAC1BD,EAAO,SAAS,KAAK,IAAI,IAAM,GAC/BE,EAAW,aAAaA,CAAQ,IAAM,eACtCG,EAAM,gBAAkB,GACxBP,EAAQ,SAASA,CAAK,GAAK,EAC/B,EAAG,OAAO,OAAO,EAAE,KAAK,GAAG,EAE3B,KAAK,UAAY;AAAA,cACXQ,CAAK;AAAA,WAEf,CACJ",
6
+ "names": ["require_ms", "__commonJSMin", "exports", "module", "s", "m", "h", "d", "w", "y", "val", "options", "type", "parse", "fmtLong", "fmtShort", "str", "match", "n", "__name", "ms", "msAbs", "plural", "name", "isPlural", "import_ms", "coerce", "val", "__name", "selectColor", "namespace", "colors", "hash", "i", "createRegexFromEnvVar", "names", "word", "r", "generateRandomString", "length", "colors", "log", "isEnabled", "namespace", "env", "createRegexFromEnvVar", "regex", "__name", "createFormatters", "v", "error", "logger", "args", "prevTime", "color", "curr", "diff", "coerce", "formatters", "index", "match", "format", "formatter", "val", "_args", "formatArgs", "shouldUseColors", "log", "useColors", "humanize", "c", "lastC", "createDebug", "noop", "selectColor", "generateRandomString", "colors", "debug", "createDebug", "Input", "__name", "attr", "i", "name", "disabledValue", "oldValue", "newValue", "handler", "value", "text", "type", "autofocus", "tabindex", "disabled", "classes", "btn", "props"]
7
+ }
package/dist/meta.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "inputs": {
3
+ "src/index.ts": {
4
+ "bytes": 5061,
5
+ "imports": [],
6
+ "format": "esm"
7
+ }
8
+ },
9
+ "outputs": {
10
+ "dist/index.js.map": {
11
+ "imports": [],
12
+ "exports": [],
13
+ "inputs": {},
14
+ "bytes": 8058
15
+ },
16
+ "dist/index.js": {
17
+ "imports": [
18
+ {
19
+ "path": "@substrate-system/debug",
20
+ "kind": "import-statement",
21
+ "external": true
22
+ }
23
+ ],
24
+ "exports": [
25
+ "Input"
26
+ ],
27
+ "entryPoint": "src/index.ts",
28
+ "inputs": {
29
+ "src/index.ts": {
30
+ "bytesInOutput": 4016
31
+ }
32
+ },
33
+ "bytes": 4199
34
+ }
35
+ }
36
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@substrate-system/input",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "./dist/*"
8
+ ],
9
+ "scripts": {
10
+ "lint": "eslint \"./**/*.{ts,js}\"",
11
+ "build-tests": "esbuild test/index.ts --target=es2020 --bundle --keep-names > test/test-bundle.js",
12
+ "test": "npm run lint && npm run build && npm run build-tests && npm run test-tape-run",
13
+ "test-tape-run": "cat test/index.html | tape-run --input=html --static=test | tap-spec",
14
+ "build-css": "postcss src/index.css --use postcss-nesting > dist/index.css",
15
+ "build-css:min": "postcss src/index.css --use cssnano postcss-nesting > dist/index.min.css",
16
+ "build-cjs": "esbuild src/*.ts --format=cjs --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.cjs --sourcemap",
17
+ "build-esm": "esbuild src/*.ts --format=esm --metafile=dist/meta.json --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --sourcemap && tsc --emitDeclarationOnly --project tsconfig.build.json --outDir dist",
18
+ "build-esm:min": "esbuild ./src/*.ts --format=esm --keep-names --bundle --tsconfig=tsconfig.build.json --minify --out-extension:.js=.min.js --outdir=./dist --sourcemap",
19
+ "build-example": "mkdir -p ./public && rm -rf ./public/* && VITE_DEBUG_MODE=staging vite --mode staging --base=\"/input\" build",
20
+ "build-docs": "typedoc --tsconfig tsconfig.build.json ./src/index.ts",
21
+ "build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-cjs && npm run build-esm && npm run build-esm:min && npm run build-css && npm run build-css:min",
22
+ "start": "vite",
23
+ "toc": "markdown-toc --maxdepth 3 -i README.md",
24
+ "preversion": "npm run lint && stylelint src/*.css",
25
+ "version": "npm run toc && auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md README.md",
26
+ "postversion": "git push --follow-tags && npm publish",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ },
34
+ "./css": "./dist/index.css",
35
+ "./css/min": "./dist/index.min.css",
36
+ "./*": {
37
+ "import": [
38
+ "./dist/*.js",
39
+ "./dist/*"
40
+ ],
41
+ "require": [
42
+ "./dist/*.cjs",
43
+ "./dist/*"
44
+ ]
45
+ }
46
+ },
47
+ "dependencies": {},
48
+ "devDependencies": {
49
+ "@bicycle-codes/dom": "^0.1.2",
50
+ "@substrate-system/debug": "^0.9.0",
51
+ "@substrate-system/tapzero": "^0.10.13",
52
+ "@typescript-eslint/eslint-plugin": "^8.7.0",
53
+ "@typescript-eslint/parser": "^8.7.0",
54
+ "auto-changelog": "^2.4.0",
55
+ "cssnano": "^7.0.3",
56
+ "esbuild": "^0.25.0",
57
+ "eslint": "^8.57.0",
58
+ "eslint-config-standard": "^17.1.0",
59
+ "markdown-toc": "^1.2.0",
60
+ "postcss": "^8.5.1",
61
+ "postcss-cli": "^11.0.0",
62
+ "postcss-nesting": "^13.0.1",
63
+ "stylelint": "^16.9.0",
64
+ "stylelint-config-standard": "^38.0.0",
65
+ "tap-spec": "^5.0.0",
66
+ "tape-run": "^11.0.0",
67
+ "typedoc": "^0.28.1",
68
+ "typescript": "^5.7.3",
69
+ "vite": "^6.0.11"
70
+ },
71
+ "author": "nichoth <nichoth@nichoth.com> (https://nichoth.com)",
72
+ "license": "MIT"
73
+ }