@digital-realty/ix-textbox 2.0.1

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/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.json]
24
+ indent_size = 2
25
+
26
+ [*.{html,js,md}]
27
+ block_comment_start = /**
28
+ block_comment = *
29
+ block_comment_end = */
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ix-textbox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # \<ix-textbox>
2
+
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @digital-realty/ix-textbox
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@digital-realty/ix-textbox.js';
16
+ </script>
17
+
18
+ <ix-textbox></ix-textbox>
19
+ ```
20
+
21
+ ## Linting and formatting
22
+
23
+ To scan the project for linting and formatting errors, run
24
+
25
+ ```bash
26
+ npm run lint
27
+ ```
28
+
29
+ To automatically fix linting and formatting errors, run
30
+
31
+ ```bash
32
+ npm run format
33
+ ```
34
+
35
+ ## Testing with Web Test Runner
36
+
37
+ To execute a single test run:
38
+
39
+ ```bash
40
+ npm run test
41
+ ```
42
+
43
+ To run the tests in interactive watch mode run:
44
+
45
+ ```bash
46
+ npm run test:watch
47
+ ```
48
+
49
+
50
+ ## Tooling configs
51
+
52
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
53
+
54
+ If you customize the configuration a lot, you can consider moving them to individual files.
55
+
56
+ ## Local Demo with `web-dev-server`
57
+
58
+ ```bash
59
+ npm start
60
+ ```
61
+
62
+ To run a local development server that serves the basic demo located in `demo/index.html`
@@ -0,0 +1,29 @@
1
+ <!doctype html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <style>
6
+ body {
7
+ background: #fafafa;
8
+ }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="demo"></div>
13
+
14
+ <script type="module">
15
+ import { html, render } from 'lit';
16
+ import '../dist/src/ix-textbox.js';
17
+
18
+ const header = 'Hello owc World!';
19
+ render(
20
+ html`
21
+ <ix-textbox .header=${header}>
22
+ some light-dom
23
+ </ix-textbox>
24
+ `,
25
+ document.querySelector('#demo')
26
+ );
27
+ </script>
28
+ </body>
29
+ </html>
@@ -0,0 +1,105 @@
1
+ import { LitElement } from 'lit';
2
+ import '@material/web/textfield/filled-text-field.js';
3
+ import '@material/web/textfield/outlined-text-field.js';
4
+ import { TextFieldType, UnsupportedTextFieldType } from './types/index.js';
5
+ export declare class IxTextbox extends LitElement {
6
+ outlined: boolean;
7
+ type: TextFieldType | UnsupportedTextFieldType;
8
+ disabled: boolean;
9
+ /**
10
+ * Gets or sets whether or not the text field is in a visually invalid state.
11
+ *
12
+ * Calling `reportValidity()` will automatically update `error`.
13
+ */
14
+ error: boolean;
15
+ /**
16
+ * The error message that replaces supporting text when `error` is true. If
17
+ * `errorText` is an empty string, then the supporting text will continue to
18
+ * show.
19
+ *
20
+ * Calling `reportValidity()` will automatically update `errorText` to the
21
+ * native `validationMessage`.
22
+ */
23
+ errorText: string;
24
+ label: string;
25
+ required: boolean;
26
+ /**
27
+ * The current value of the text field. It is always a string.
28
+ */
29
+ value: string;
30
+ /**
31
+ * An optional prefix to display before the input value.
32
+ */
33
+ prefixText: string;
34
+ /**
35
+ * An optional suffix to display after the input value.
36
+ */
37
+ suffixText: string;
38
+ /**
39
+ * Whether or not the text field has a leading icon. Used for SSR.
40
+ */
41
+ hasLeadingIcon: boolean;
42
+ /**
43
+ * Whether or not the text field has a trailing icon. Used for SSR.
44
+ */
45
+ hasTrailingIcon: boolean;
46
+ /**
47
+ * Conveys additional information below the text field, such as how it should
48
+ * be used.
49
+ */
50
+ supportingText: string;
51
+ /**
52
+ * Override the input text CSS `direction`. Useful for RTL languages that use
53
+ * LTR notation for fractions.
54
+ */
55
+ textDirection: string;
56
+ /**
57
+ * The number of rows to display for a `type="textarea"` text field.
58
+ * Defaults to 2.
59
+ */
60
+ rows: number;
61
+ /**
62
+ * Defines the greatest value in the range of permitted values.
63
+ *
64
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
65
+ */
66
+ max: string;
67
+ /**
68
+ * The maximum number of characters a user can enter into the text field. Set
69
+ * to -1 for none.
70
+ *
71
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
72
+ */
73
+ maxLength: number;
74
+ /**
75
+ * Defines the most negative value in the range of permitted values.
76
+ *
77
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
78
+ */
79
+ min: string;
80
+ /**
81
+ * The minimum number of characters a user can enter into the text field. Set
82
+ * to -1 for none.
83
+ *
84
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
85
+ */
86
+ minLength: number;
87
+ /**
88
+ * A regular expression that the text field's value must match to pass
89
+ * constraint validation.
90
+ *
91
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
92
+ */
93
+ pattern: string;
94
+ placeholder: string;
95
+ /**
96
+ * Indicates whether or not a user should be able to edit the text field's
97
+ * value.
98
+ *
99
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
100
+ */
101
+ readOnly: boolean;
102
+ onChange: Function;
103
+ _handleChange(e: Event): void;
104
+ render(): import("lit-html").TemplateResult<1>;
105
+ }
@@ -0,0 +1,240 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import '@material/web/textfield/filled-text-field.js';
5
+ import '@material/web/textfield/outlined-text-field.js';
6
+ export class IxTextbox extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.outlined = true;
10
+ this.type = 'text';
11
+ this.disabled = false;
12
+ /**
13
+ * Gets or sets whether or not the text field is in a visually invalid state.
14
+ *
15
+ * Calling `reportValidity()` will automatically update `error`.
16
+ */
17
+ this.error = false;
18
+ /**
19
+ * The error message that replaces supporting text when `error` is true. If
20
+ * `errorText` is an empty string, then the supporting text will continue to
21
+ * show.
22
+ *
23
+ * Calling `reportValidity()` will automatically update `errorText` to the
24
+ * native `validationMessage`.
25
+ */
26
+ this.errorText = '';
27
+ this.label = '';
28
+ this.required = false;
29
+ /**
30
+ * The current value of the text field. It is always a string.
31
+ */
32
+ this.value = '';
33
+ /**
34
+ * An optional prefix to display before the input value.
35
+ */
36
+ this.prefixText = '';
37
+ /**
38
+ * An optional suffix to display after the input value.
39
+ */
40
+ this.suffixText = '';
41
+ /**
42
+ * Whether or not the text field has a leading icon. Used for SSR.
43
+ */
44
+ this.hasLeadingIcon = false;
45
+ /**
46
+ * Whether or not the text field has a trailing icon. Used for SSR.
47
+ */
48
+ this.hasTrailingIcon = false;
49
+ /**
50
+ * Conveys additional information below the text field, such as how it should
51
+ * be used.
52
+ */
53
+ this.supportingText = '';
54
+ /**
55
+ * Override the input text CSS `direction`. Useful for RTL languages that use
56
+ * LTR notation for fractions.
57
+ */
58
+ this.textDirection = '';
59
+ /**
60
+ * The number of rows to display for a `type="textarea"` text field.
61
+ * Defaults to 2.
62
+ */
63
+ this.rows = 2;
64
+ // <input> properties
65
+ /**
66
+ * Defines the greatest value in the range of permitted values.
67
+ *
68
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
69
+ */
70
+ this.max = '';
71
+ /**
72
+ * The maximum number of characters a user can enter into the text field. Set
73
+ * to -1 for none.
74
+ *
75
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
76
+ */
77
+ this.maxLength = -1;
78
+ /**
79
+ * Defines the most negative value in the range of permitted values.
80
+ *
81
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
82
+ */
83
+ this.min = '';
84
+ /**
85
+ * The minimum number of characters a user can enter into the text field. Set
86
+ * to -1 for none.
87
+ *
88
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
89
+ */
90
+ this.minLength = -1;
91
+ /**
92
+ * A regular expression that the text field's value must match to pass
93
+ * constraint validation.
94
+ *
95
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
96
+ */
97
+ this.pattern = '';
98
+ this.placeholder = '';
99
+ /**
100
+ * Indicates whether or not a user should be able to edit the text field's
101
+ * value.
102
+ *
103
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
104
+ */
105
+ this.readOnly = false;
106
+ this.onChange = () => { };
107
+ }
108
+ _handleChange(e) {
109
+ const inputElement = e.target;
110
+ this.onChange({ value: inputElement.value });
111
+ }
112
+ render() {
113
+ let comp;
114
+ if (this.outlined) {
115
+ comp = html `
116
+ <md-outlined-text-field
117
+ ?disabled="${this.disabled}"
118
+ ?required="${this.required}"
119
+ ?error="${this.error}"
120
+ error-text="${this.errorText}"
121
+ label="${this.label}"
122
+ value="${this.value}"
123
+ placeholder="${this.placeholder}"
124
+ ?readOnly="${this.readOnly}"
125
+ text-direction="${this.textDirection}"
126
+ rows="${this.rows}"
127
+ max="${this.max}"
128
+ maxLength="${this.maxLength}"
129
+ min="${this.min}"
130
+ minLength="${this.minLength}"
131
+ pattern="${this.pattern}"
132
+ prefix-text="${this.prefixText}"
133
+ suffix-text="${this.suffixText}"
134
+ supporting-text="${this.supportingText}"
135
+ type="${this.type}"
136
+ @input="${this._handleChange}"
137
+ >
138
+ </md-outlined-text-field>
139
+ `;
140
+ }
141
+ else {
142
+ comp = html `
143
+ <md-filled-text-field
144
+ ?disabled="${this.disabled}"
145
+ ?required="${this.required}"
146
+ ?error="${this.error}"
147
+ error-text="${this.errorText}"
148
+ label="${this.label}"
149
+ value="${this.value}"
150
+ placeholder="${this.placeholder}"
151
+ ?readOnly="${this.readOnly}"
152
+ text-direction="${this.textDirection}"
153
+ rows="${this.rows}"
154
+ max="${this.max}"
155
+ maxLength="${this.maxLength}"
156
+ min="${this.min}"
157
+ minLength="${this.minLength}"
158
+ pattern="${this.pattern}"
159
+ prefix-text="${this.prefixText}"
160
+ suffix-text="${this.suffixText}"
161
+ supporting-text="${this.supportingText}"
162
+ type="${this.type}"
163
+ @input="${this.onChange}"
164
+ >
165
+ </md-filled-text-field>
166
+ `;
167
+ }
168
+ return html ` ${comp} `;
169
+ }
170
+ }
171
+ __decorate([
172
+ property({ type: Boolean })
173
+ ], IxTextbox.prototype, "outlined", void 0);
174
+ __decorate([
175
+ property({ reflect: true })
176
+ ], IxTextbox.prototype, "type", void 0);
177
+ __decorate([
178
+ property({ type: Boolean, reflect: true })
179
+ ], IxTextbox.prototype, "disabled", void 0);
180
+ __decorate([
181
+ property({ type: Boolean, reflect: true })
182
+ ], IxTextbox.prototype, "error", void 0);
183
+ __decorate([
184
+ property({ attribute: 'error-text' })
185
+ ], IxTextbox.prototype, "errorText", void 0);
186
+ __decorate([
187
+ property()
188
+ ], IxTextbox.prototype, "label", void 0);
189
+ __decorate([
190
+ property({ type: Boolean, reflect: true })
191
+ ], IxTextbox.prototype, "required", void 0);
192
+ __decorate([
193
+ property()
194
+ ], IxTextbox.prototype, "value", void 0);
195
+ __decorate([
196
+ property({ attribute: 'prefix-text' })
197
+ ], IxTextbox.prototype, "prefixText", void 0);
198
+ __decorate([
199
+ property({ attribute: 'suffix-text' })
200
+ ], IxTextbox.prototype, "suffixText", void 0);
201
+ __decorate([
202
+ property({ type: Boolean, attribute: 'has-leading-icon' })
203
+ ], IxTextbox.prototype, "hasLeadingIcon", void 0);
204
+ __decorate([
205
+ property({ type: Boolean, attribute: 'has-trailing-icon' })
206
+ ], IxTextbox.prototype, "hasTrailingIcon", void 0);
207
+ __decorate([
208
+ property({ attribute: 'supporting-text' })
209
+ ], IxTextbox.prototype, "supportingText", void 0);
210
+ __decorate([
211
+ property({ attribute: 'text-direction' })
212
+ ], IxTextbox.prototype, "textDirection", void 0);
213
+ __decorate([
214
+ property({ type: Number })
215
+ ], IxTextbox.prototype, "rows", void 0);
216
+ __decorate([
217
+ property()
218
+ ], IxTextbox.prototype, "max", void 0);
219
+ __decorate([
220
+ property({ type: Number })
221
+ ], IxTextbox.prototype, "maxLength", void 0);
222
+ __decorate([
223
+ property()
224
+ ], IxTextbox.prototype, "min", void 0);
225
+ __decorate([
226
+ property({ type: Number })
227
+ ], IxTextbox.prototype, "minLength", void 0);
228
+ __decorate([
229
+ property()
230
+ ], IxTextbox.prototype, "pattern", void 0);
231
+ __decorate([
232
+ property({ reflect: true })
233
+ ], IxTextbox.prototype, "placeholder", void 0);
234
+ __decorate([
235
+ property({ type: Boolean, reflect: true })
236
+ ], IxTextbox.prototype, "readOnly", void 0);
237
+ __decorate([
238
+ property({ type: Function })
239
+ ], IxTextbox.prototype, "onChange", void 0);
240
+ //# sourceMappingURL=IxTextbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxTextbox.js","sourceRoot":"","sources":["../../src/IxTextbox.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,8CAA8C,CAAC;AACtD,OAAO,gDAAgD,CAAC;AAGxD,MAAM,OAAO,SAAU,SAAQ,UAAU;IAAzC;;QAC+B,aAAQ,GAAG,IAAI,CAAC;QAG7C,SAAI,GAA6C,MAAM,CAAC;QAEZ,aAAQ,GAAG,KAAK,CAAC;QAE7D;;;;WAIG;QACyC,UAAK,GAAG,KAAK,CAAC;QAE1D;;;;;;;WAOG;QACoC,cAAS,GAAG,EAAE,CAAC;QAE1C,UAAK,GAAG,EAAE,CAAC;QAEqB,aAAQ,GAAG,KAAK,CAAC;QAE7D;;WAEG;QACS,UAAK,GAAG,EAAE,CAAC;QAEvB;;WAEG;QACqC,eAAU,GAAG,EAAE,CAAC;QAExD;;WAEG;QACqC,eAAU,GAAG,EAAE,CAAC;QAExD;;WAEG;QAEH,mBAAc,GAAG,KAAK,CAAC;QAEvB;;WAEG;QAEH,oBAAe,GAAG,KAAK,CAAC;QAExB;;;WAGG;QACyC,mBAAc,GAAG,EAAE,CAAC;QAEhE;;;WAGG;QACwC,kBAAa,GAAG,EAAE,CAAC;QAE9D;;;WAGG;QACyB,SAAI,GAAG,CAAC,CAAC;QAErC,qBAAqB;QACrB;;;;WAIG;QACS,QAAG,GAAG,EAAE,CAAC;QAErB;;;;;WAKG;QACyB,cAA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,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;iDACpC;AAMvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;kDACpC;AAMoB;IAA3C,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;iDAAqB;AAMrB;IAA1C,QAAQ,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;gDAAoB;AAMlC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAU;AAQzB;IAAX,QAAQ,EAAE;sCAAU;AAQO;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAgB;AAO/B;IAAX,QAAQ,EAAE;sCAAU;AAQO;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAgB;AAQ/B;IAAX,QAAQ,EAAE;0CAAc;AAEI;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAQF;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAE/B;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;2CAA+B","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport '@material/web/textfield/filled-text-field.js';\nimport '@material/web/textfield/outlined-text-field.js';\nimport { TextFieldType, UnsupportedTextFieldType } from './types/index.js';\n\nexport class IxTextbox extends LitElement {\n @property({ type: Boolean }) outlined = true;\n\n @property({ reflect: true })\n type: TextFieldType | UnsupportedTextFieldType = 'text';\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * Calling `reportValidity()` will automatically update `error`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * Calling `reportValidity()` will automatically update `errorText` to the\n * native `validationMessage`.\n */\n @property({ attribute: 'error-text' }) errorText = '';\n\n @property() label = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * The current value of the text field. It is always a string.\n */\n @property() value = '';\n\n /**\n * An optional prefix to display before the input value.\n */\n @property({ attribute: 'prefix-text' }) prefixText = '';\n\n /**\n * An optional suffix to display after the input value.\n */\n @property({ attribute: 'suffix-text' }) suffixText = '';\n\n /**\n * Whether or not the text field has a leading icon. Used for SSR.\n */\n @property({ type: Boolean, attribute: 'has-leading-icon' })\n hasLeadingIcon = false;\n\n /**\n * Whether or not the text field has a trailing icon. Used for SSR.\n */\n @property({ type: Boolean, attribute: 'has-trailing-icon' })\n hasTrailingIcon = false;\n\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n /**\n * Override the input text CSS `direction`. Useful for RTL languages that use\n * LTR notation for fractions.\n */\n @property({ attribute: 'text-direction' }) textDirection = '';\n\n /**\n * The number of rows to display for a `type=\"textarea\"` text field.\n * Defaults to 2.\n */\n @property({ type: Number }) rows = 2;\n\n // <input> properties\n /**\n * Defines the greatest value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max\n */\n @property() max = '';\n\n /**\n * The maximum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength\n */\n @property({ type: Number }) maxLength = -1;\n\n /**\n * Defines the most negative value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min\n */\n @property() min = '';\n\n /**\n * The minimum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength\n */\n @property({ type: Number }) minLength = -1;\n\n /**\n * A regular expression that the text field's value must match to pass\n * constraint validation.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern\n */\n @property() pattern = '';\n\n @property({ reflect: true }) placeholder = '';\n\n /**\n * Indicates whether or not a user should be able to edit the text field's\n * value.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly\n */\n @property({ type: Boolean, reflect: true }) readOnly = false;\n\n @property({ type: Function }) onChange: Function = () => {};\n\n _handleChange(e: Event) {\n const inputElement = e.target as HTMLInputElement;\n this.onChange({ value: inputElement.value });\n }\n\n render() {\n let comp;\n if (this.outlined) {\n comp = html`\n <md-outlined-text-field\n ?disabled=\"${this.disabled}\"\n ?required=\"${this.required}\"\n ?error=\"${this.error}\"\n error-text=\"${this.errorText}\"\n label=\"${this.label}\"\n value=\"${this.value}\"\n placeholder=\"${this.placeholder}\"\n ?readOnly=\"${this.readOnly}\"\n text-direction=\"${this.textDirection}\"\n rows=\"${this.rows}\"\n max=\"${this.max}\"\n maxLength=\"${this.maxLength}\"\n min=\"${this.min}\"\n minLength=\"${this.minLength}\"\n pattern=\"${this.pattern}\"\n prefix-text=\"${this.prefixText}\"\n suffix-text=\"${this.suffixText}\"\n supporting-text=\"${this.supportingText}\"\n type=\"${this.type}\"\n @input=\"${this._handleChange}\"\n >\n </md-outlined-text-field>\n `;\n } else {\n comp = html`\n <md-filled-text-field\n ?disabled=\"${this.disabled}\"\n ?required=\"${this.required}\"\n ?error=\"${this.error}\"\n error-text=\"${this.errorText}\"\n label=\"${this.label}\"\n value=\"${this.value}\"\n placeholder=\"${this.placeholder}\"\n ?readOnly=\"${this.readOnly}\"\n text-direction=\"${this.textDirection}\"\n rows=\"${this.rows}\"\n max=\"${this.max}\"\n maxLength=\"${this.maxLength}\"\n min=\"${this.min}\"\n minLength=\"${this.minLength}\"\n pattern=\"${this.pattern}\"\n prefix-text=\"${this.prefixText}\"\n suffix-text=\"${this.suffixText}\"\n supporting-text=\"${this.supportingText}\"\n type=\"${this.type}\"\n @input=\"${this.onChange}\"\n >\n </md-filled-text-field>\n `;\n }\n return html` ${comp} `;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export { IxTextbox } from './IxTextbox.js';
@@ -0,0 +1,2 @@
1
+ export { IxTextbox } from './IxTextbox.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { IxTextbox } from './IxTextbox.js';\n"]}
@@ -0,0 +1 @@
1
+ export declare const IxTextboxStyles: import("lit").CSSResult;
@@ -0,0 +1,59 @@
1
+ import { css } from 'lit';
2
+ export const IxTextboxStyles = css `
3
+ :host {
4
+ display: block;
5
+ }
6
+
7
+ :host([hidden]) {
8
+ display: none;
9
+ }
10
+
11
+ input {
12
+ display: block;
13
+ width: 100%;
14
+ padding: 0.5em;
15
+ font-size: 1rem;
16
+ line-height: 1.25rem;
17
+ border: 1px solid lightgrey;
18
+ background-repeat: no-repeat;
19
+ background-position: calc(100% - 0.5em) 50%;
20
+ border-radius: 3px;
21
+ box-sizing: border-box;
22
+ }
23
+
24
+ input:focus {
25
+ outline: none;
26
+ box-shadow: 0 0 2px 1px rgba(0, 153, 204, 0.39),
27
+ 0 0 4px 3px rgba(0, 153, 204, 0.18), 0 0 8px 4px rgba(0, 153, 204, 0.1);
28
+ }
29
+
30
+ input:required.-is-valid {
31
+ border-color: #99ca3c;
32
+ background-image: url("data:image/svg+xml,%3Csvg width='19px' height='13px' viewBox='0 0 19 13' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cpolygon fill='%2399CA3C' points='6.70967742 13 0 6.29032258 2.09677419 4.19354839 6.70967742 8.80645161 16.3548387 0 18.4516129 2.09677419'%3E%3C/polygon%3E %3C/svg%3E");
33
+ padding-right: 2em;
34
+ }
35
+
36
+ input:required.-is-invalid {
37
+ border-color: #e3097c;
38
+ background-image: url("data:image/svg+xml,%3Csvg width='15px' height='15px' viewBox='0 0 15 15' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cpolygon id='Path' fill='%23E3097C' points='12.759145 0.0312229203 14.8804653 2.15254326 9.57716447 7.45584412 14.8804653 12.759145 12.759145 14.8804653 7.45584412 9.57716447 2.15254326 14.8804653 0.0312229203 12.759145 5.33452378 7.45584412 0.0312229203 2.15254326 2.15254326 0.0312229203 7.45584412 5.33452378'%3E%3C/polygon%3E %3C/svg%3E");
39
+ padding-right: 2em;
40
+ }
41
+
42
+ input[type='search'] {
43
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24' height='24' viewBox='0 0 24 24'%3E%3Cdefs%3E%3CclipPath id='clip-path'%3E%3Cpath id='Path_46' data-name='Path 46' d='M17.835-27.347l5.506,5.506a2.249,2.249,0,0,1,0,3.182,2.249,2.249,0,0,1-3.182,0h0l-5.506-5.506a10.6,10.6,0,0,0,3.182-3.182ZM9-42a9,9,0,0,1,9,9,9,9,0,0,1-9,9,9,9,0,0,1-9-9A9,9,0,0,1,9-42Zm0,2.25A6.757,6.757,0,0,0,2.25-33,6.757,6.757,0,0,0,9-26.25,6.757,6.757,0,0,0,15.75-33,6.758,6.758,0,0,0,9-39.75Zm0,1.5v1.5A3.754,3.754,0,0,0,5.25-33H3.75A5.256,5.256,0,0,1,9-38.25Z' transform='translate(0 42)' fill='%23d8d8d8' clip-rule='evenodd'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg id='icon_search' data-name='icon search' clip-path='url(%23clip-path)'%3E%3Cpath id='Path_45' data-name='Path 45' d='M-1-43H24.363v25.363H-1Z' transform='translate(0.429 42.429)' fill='%23d8d8d8'/%3E%3C/g%3E%3C/svg%3E%0A");
44
+ background-position: 0.5em 50%;
45
+ padding-left: 2.25rem;
46
+ }
47
+
48
+ input:disabled {
49
+ border-width: 0 0 1px;
50
+ color: #595959;
51
+ border-color: lightgrey;
52
+ }
53
+
54
+ input:not([type='search']):disabled {
55
+ background-image: none;
56
+ padding-left: 0;
57
+ }
58
+ `;
59
+ //# sourceMappingURL=ix-textbox-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-textbox-styles.js","sourceRoot":"","sources":["../../src/ix-textbox-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDjC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const IxTextboxStyles = css`\n :host {\n display: block;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n input {\n display: block;\n width: 100%;\n padding: 0.5em;\n font-size: 1rem;\n line-height: 1.25rem;\n border: 1px solid lightgrey;\n background-repeat: no-repeat;\n background-position: calc(100% - 0.5em) 50%;\n border-radius: 3px;\n box-sizing: border-box;\n }\n\n input:focus {\n outline: none;\n box-shadow: 0 0 2px 1px rgba(0, 153, 204, 0.39),\n 0 0 4px 3px rgba(0, 153, 204, 0.18), 0 0 8px 4px rgba(0, 153, 204, 0.1);\n }\n\n input:required.-is-valid {\n border-color: #99ca3c;\n background-image: url(\"data:image/svg+xml,%3Csvg width='19px' height='13px' viewBox='0 0 19 13' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cpolygon fill='%2399CA3C' points='6.70967742 13 0 6.29032258 2.09677419 4.19354839 6.70967742 8.80645161 16.3548387 0 18.4516129 2.09677419'%3E%3C/polygon%3E %3C/svg%3E\");\n padding-right: 2em;\n }\n\n input:required.-is-invalid {\n border-color: #e3097c;\n background-image: url(\"data:image/svg+xml,%3Csvg width='15px' height='15px' viewBox='0 0 15 15' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cpolygon id='Path' fill='%23E3097C' points='12.759145 0.0312229203 14.8804653 2.15254326 9.57716447 7.45584412 14.8804653 12.759145 12.759145 14.8804653 7.45584412 9.57716447 2.15254326 14.8804653 0.0312229203 12.759145 5.33452378 7.45584412 0.0312229203 2.15254326 2.15254326 0.0312229203 7.45584412 5.33452378'%3E%3C/polygon%3E %3C/svg%3E\");\n padding-right: 2em;\n }\n\n input[type='search'] {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24' height='24' viewBox='0 0 24 24'%3E%3Cdefs%3E%3CclipPath id='clip-path'%3E%3Cpath id='Path_46' data-name='Path 46' d='M17.835-27.347l5.506,5.506a2.249,2.249,0,0,1,0,3.182,2.249,2.249,0,0,1-3.182,0h0l-5.506-5.506a10.6,10.6,0,0,0,3.182-3.182ZM9-42a9,9,0,0,1,9,9,9,9,0,0,1-9,9,9,9,0,0,1-9-9A9,9,0,0,1,9-42Zm0,2.25A6.757,6.757,0,0,0,2.25-33,6.757,6.757,0,0,0,9-26.25,6.757,6.757,0,0,0,15.75-33,6.758,6.758,0,0,0,9-39.75Zm0,1.5v1.5A3.754,3.754,0,0,0,5.25-33H3.75A5.256,5.256,0,0,1,9-38.25Z' transform='translate(0 42)' fill='%23d8d8d8' clip-rule='evenodd'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg id='icon_search' data-name='icon search' clip-path='url(%23clip-path)'%3E%3Cpath id='Path_45' data-name='Path 45' d='M-1-43H24.363v25.363H-1Z' transform='translate(0.429 42.429)' fill='%23d8d8d8'/%3E%3C/g%3E%3C/svg%3E%0A\");\n background-position: 0.5em 50%;\n padding-left: 2.25rem;\n }\n\n input:disabled {\n border-width: 0 0 1px;\n color: #595959;\n border-color: lightgrey;\n }\n\n input:not([type='search']):disabled {\n background-image: none;\n padding-left: 0;\n }\n`;\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IxTextbox } from './IxTextbox.js';
2
+ window.customElements.define('ix-textbox', IxTextbox);
3
+ //# sourceMappingURL=ix-textbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-textbox.js","sourceRoot":"","sources":["../../src/ix-textbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { IxTextbox } from './IxTextbox.js';\n\nwindow.customElements.define('ix-textbox', IxTextbox);\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Input types that are compatible with the text field.
3
+ */
4
+ export type TextFieldType = 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url' | 'textarea';
5
+ /**
6
+ * Input types that are not fully supported for the text field.
7
+ */
8
+ export type UnsupportedTextFieldType = 'color' | 'date' | 'datetime-local' | 'file' | 'month' | 'time' | 'week';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Input types that are compatible with the text field.\n */\nexport type TextFieldType =\n | 'email'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'textarea';\n\n/**\n * Input types that are not fully supported for the text field.\n */\nexport type UnsupportedTextFieldType =\n | 'color'\n | 'date'\n | 'datetime-local'\n | 'file'\n | 'month'\n | 'time'\n | 'week';\n"]}
@@ -0,0 +1,33 @@
1
+ import { TemplateResult } from 'lit';
2
+ import '../src/ix-textbox.js';
3
+ declare const _default: {
4
+ title: string;
5
+ component: string;
6
+ argTypes: {
7
+ header: {
8
+ control: string;
9
+ };
10
+ counter: {
11
+ control: string;
12
+ };
13
+ textColor: {
14
+ control: string;
15
+ };
16
+ };
17
+ };
18
+ export default _default;
19
+ interface Story<T> {
20
+ (args: T): TemplateResult;
21
+ args?: Partial<T>;
22
+ argTypes?: Record<string, unknown>;
23
+ }
24
+ interface ArgTypes {
25
+ header?: string;
26
+ counter?: number;
27
+ textColor?: string;
28
+ slot?: TemplateResult;
29
+ }
30
+ export declare const Regular: Story<ArgTypes>;
31
+ export declare const CustomHeader: Story<ArgTypes>;
32
+ export declare const CustomCounter: Story<ArgTypes>;
33
+ export declare const SlottedContent: Story<ArgTypes>;