@digital-realty/ix-textbox 2.0.5 → 2.1.2

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/package.json CHANGED
@@ -1,94 +1,95 @@
1
- {
2
- "name": "@digital-realty/ix-textbox",
3
- "version": "2.0.5",
4
- "description": "Webcomponent ix-textbox following open-wc recommendations",
5
- "license": "MIT",
6
- "author": "Digital Realty",
7
- "type": "module",
8
- "main": "dist/src/index.js",
9
- "module": "dist/src/index.js",
10
- "exports": {
11
- ".": "./dist/src/index.js",
12
- "./ix-textbox.js": "./dist/src/ix-textbox.js",
13
- "./IxTextbox": "./dist/src/react/IxTextbox.js"
14
- },
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "scripts": {
19
- "analyze": "cem analyze --litelement",
20
- "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
21
- "build": "tsc && npm run analyze -- --exclude dist",
22
- "prepublish": "tsc && npm run analyze -- --exclude dist",
23
- "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
24
- "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
- "test": "tsc && wtr --coverage",
26
- "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
27
- },
28
- "dependencies": {
29
- "@lit-labs/react": "^2.0.3",
30
- "@material/web": "^1.0.0-pre.15",
31
- "lit": "^2.7.6",
32
- "react": "^18.2.0"
33
- },
34
- "devDependencies": {
35
- "@custom-elements-manifest/analyzer": "^0.4.17",
36
- "@open-wc/eslint-config": "^9.2.1",
37
- "@open-wc/testing": "^3.1.6",
38
- "@types/react": "^18.2.22",
39
- "@typescript-eslint/eslint-plugin": "^5.48.0",
40
- "@typescript-eslint/parser": "^5.48.0",
41
- "@web/dev-server": "^0.1.34",
42
- "@web/test-runner": "^0.14.0",
43
- "concurrently": "^5.3.0",
44
- "eslint": "^8.31.0",
45
- "eslint-config-prettier": "^8.3.0",
46
- "husky": "^4.3.8",
47
- "lint-staged": "^10.5.4",
48
- "prettier": "^2.4.1",
49
- "tslib": "^2.3.1",
50
- "typescript": "^4.5.2"
51
- },
52
- "customElements": "custom-elements.json",
53
- "eslintConfig": {
54
- "root": true,
55
- "parser": "@typescript-eslint/parser",
56
- "extends": [
57
- "@open-wc",
58
- "prettier"
59
- ],
60
- "plugins": [
61
- "@typescript-eslint"
62
- ],
63
- "rules": {
64
- "class-methods-use-this": "off",
65
- "no-unused-vars": "off",
66
- "@typescript-eslint/no-unused-vars": [
67
- "error"
68
- ],
69
- "import/no-unresolved": "off",
70
- "import/extensions": [
71
- "error",
72
- "always",
73
- {
74
- "ignorePackages": true
75
- }
76
- ]
77
- }
78
- },
79
- "prettier": {
80
- "singleQuote": true,
81
- "arrowParens": "avoid"
82
- },
83
- "husky": {
84
- "hooks": {
85
- "pre-commit": "lint-staged"
86
- }
87
- },
88
- "lint-staged": {
89
- "*.ts": [
90
- "eslint --fix",
91
- "prettier --write"
92
- ]
93
- }
94
- }
1
+ {
2
+ "name": "@digital-realty/ix-textbox",
3
+ "version": "2.1.2",
4
+ "description": "Webcomponent ix-textbox following open-wc recommendations",
5
+ "license": "MIT",
6
+ "author": "Digital Realty",
7
+ "type": "module",
8
+ "main": "dist/src/index.js",
9
+ "module": "dist/src/index.js",
10
+ "exports": {
11
+ ".": "./dist/src/index.js",
12
+ "./ix-textbox.js": "./dist/src/ix-textbox.js",
13
+ "./IxTextbox": "./dist/src/react/IxTextbox.js"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "analyze": "cem analyze --litelement",
20
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
21
+ "build": "tsc && npm run analyze -- --exclude dist",
22
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
23
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
24
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
+ "test": "tsc && wtr --coverage",
26
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
27
+ },
28
+ "dependencies": {
29
+ "@lit-labs/react": "^2.0.3",
30
+ "@material/web": "^1.0.0-pre.15",
31
+ "lit": "^2.7.6",
32
+ "react": "^18.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@custom-elements-manifest/analyzer": "^0.4.17",
36
+ "@open-wc/eslint-config": "^9.2.1",
37
+ "@open-wc/testing": "^3.1.6",
38
+ "@types/react": "^18.2.22",
39
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
40
+ "@typescript-eslint/parser": "^5.48.0",
41
+ "@web/dev-server": "^0.1.34",
42
+ "@web/test-runner": "^0.14.0",
43
+ "concurrently": "^5.3.0",
44
+ "eslint": "^8.31.0",
45
+ "eslint-config-prettier": "^8.3.0",
46
+ "husky": "^4.3.8",
47
+ "lint-staged": "^10.5.4",
48
+ "prettier": "^2.4.1",
49
+ "tslib": "^2.3.1",
50
+ "typescript": "^4.5.2"
51
+ },
52
+ "customElements": "custom-elements.json",
53
+ "eslintConfig": {
54
+ "root": true,
55
+ "parser": "@typescript-eslint/parser",
56
+ "extends": [
57
+ "@open-wc",
58
+ "prettier"
59
+ ],
60
+ "plugins": [
61
+ "@typescript-eslint"
62
+ ],
63
+ "rules": {
64
+ "class-methods-use-this": "off",
65
+ "no-unused-vars": "off",
66
+ "@typescript-eslint/no-unused-vars": [
67
+ "error"
68
+ ],
69
+ "import/no-unresolved": "off",
70
+ "import/extensions": [
71
+ "error",
72
+ "always",
73
+ {
74
+ "ignorePackages": true
75
+ }
76
+ ]
77
+ }
78
+ },
79
+ "prettier": {
80
+ "singleQuote": true,
81
+ "arrowParens": "avoid"
82
+ },
83
+ "husky": {
84
+ "hooks": {
85
+ "pre-commit": "lint-staged"
86
+ }
87
+ },
88
+ "lint-staged": {
89
+ "*.ts": [
90
+ "eslint --fix",
91
+ "prettier --write"
92
+ ]
93
+ },
94
+ "gitHead": "1e8e36ae0147d1fb0037ba85c727e3a30daebbc9"
95
+ }
package/src/IxTextbox.ts CHANGED
@@ -1,216 +1,216 @@
1
- import { html, LitElement } from 'lit';
2
- import { property, query } from 'lit/decorators.js';
3
- import '@material/web/textfield/filled-text-field.js';
4
- import '@material/web/textfield/outlined-text-field.js';
5
- import {
6
- TextFieldType,
7
- UnsupportedTextFieldType,
8
- TextChangeEvent,
9
- } from './types/index.js';
10
-
11
- export class IxTextbox extends LitElement {
12
- @property({ type: Boolean }) outlined = true;
13
-
14
- @property({ reflect: true })
15
- type: TextFieldType | UnsupportedTextFieldType = 'text';
16
-
17
- @property({ type: Boolean, reflect: true }) disabled = false;
18
-
19
- /**
20
- * Gets or sets whether or not the text field is in a visually invalid state.
21
- *
22
- * Calling `reportValidity()` will automatically update `error`.
23
- */
24
- @property({ type: Boolean, reflect: true }) error = false;
25
-
26
- /**
27
- * The error message that replaces supporting text when `error` is true. If
28
- * `errorText` is an empty string, then the supporting text will continue to
29
- * show.
30
- *
31
- * Calling `reportValidity()` will automatically update `errorText` to the
32
- * native `validationMessage`.
33
- */
34
- @property({ attribute: 'error-text' }) errorText = '';
35
-
36
- @property() label = '';
37
-
38
- @property({ type: Boolean, reflect: true }) required = false;
39
-
40
- /**
41
- * The current value of the text field. It is always a string.
42
- */
43
- @property() value = '';
44
-
45
- /**
46
- * An optional prefix to display before the input value.
47
- */
48
- @property({ attribute: 'prefix-text' }) prefixText = '';
49
-
50
- /**
51
- * An optional suffix to display after the input value.
52
- */
53
- @property({ attribute: 'suffix-text' }) suffixText = '';
54
-
55
- /**
56
- * Whether or not the text field has a leading icon. Used for SSR.
57
- */
58
- @property({ type: Boolean, attribute: 'has-leading-icon' })
59
- hasLeadingIcon = false;
60
-
61
- /**
62
- * Whether or not the text field has a trailing icon. Used for SSR.
63
- */
64
- @property({ type: Boolean, attribute: 'has-trailing-icon' })
65
- hasTrailingIcon = false;
66
-
67
- /**
68
- * Conveys additional information below the text field, such as how it should
69
- * be used.
70
- */
71
- @property({ attribute: 'supporting-text' }) supportingText = '';
72
-
73
- /**
74
- * Override the input text CSS `direction`. Useful for RTL languages that use
75
- * LTR notation for fractions.
76
- */
77
- @property({ attribute: 'text-direction' }) textDirection = '';
78
-
79
- /**
80
- * The number of rows to display for a `type="textarea"` text field.
81
- * Defaults to 2.
82
- */
83
- @property({ type: Number }) rows = 2;
84
-
85
- // <input> properties
86
- /**
87
- * Defines the greatest value in the range of permitted values.
88
- *
89
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
90
- */
91
- @property() max = '';
92
-
93
- /**
94
- * The maximum number of characters a user can enter into the text field. Set
95
- * to -1 for none.
96
- *
97
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
98
- */
99
- @property({ type: Number }) maxLength = -1;
100
-
101
- /**
102
- * Defines the most negative value in the range of permitted values.
103
- *
104
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
105
- */
106
- @property() min = '';
107
-
108
- /**
109
- * The minimum number of characters a user can enter into the text field. Set
110
- * to -1 for none.
111
- *
112
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
113
- */
114
- @property({ type: Number }) minLength = -1;
115
-
116
- /**
117
- * A regular expression that the text field's value must match to pass
118
- * constraint validation.
119
- *
120
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
121
- */
122
- @property() pattern = '';
123
-
124
- @property({ reflect: true }) placeholder = '';
125
-
126
- /**
127
- * Indicates whether or not a user should be able to edit the text field's
128
- * value.
129
- *
130
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
131
- */
132
- @property({ type: Boolean, reflect: true }) readOnly = false;
133
-
134
- @query('#md-textfield') mdTextfield!: HTMLInputElement;
135
-
136
- handleChange(e: Event) {
137
- const inputElement = e.target as HTMLInputElement;
138
- const textChangeEvent = new CustomEvent('textChange', {
139
- detail: {
140
- value: inputElement.value,
141
- },
142
- composed: true,
143
- } as TextChangeEvent);
144
-
145
- this.dispatchEvent(textChangeEvent);
146
- }
147
-
148
- getValidityStatus() {
149
- return this.mdTextfield?.reportValidity();
150
- }
151
-
152
- render() {
153
- let comp;
154
- if (this.outlined) {
155
- comp = html`
156
- <md-outlined-text-field
157
- id="md-textfield"
158
- ?disabled="${this.disabled}"
159
- ?required="${this.required}"
160
- ?error="${this.error}"
161
- error-text="${this.errorText}"
162
- label="${this.label}"
163
- value="${this.value}"
164
- placeholder="${this.placeholder}"
165
- ?readOnly="${this.readOnly}"
166
- text-direction="${this.textDirection}"
167
- rows="${this.rows}"
168
- max="${this.max}"
169
- maxLength="${this.maxLength}"
170
- min="${this.min}"
171
- minLength="${this.minLength}"
172
- pattern="${this.pattern}"
173
- prefix-text="${this.prefixText}"
174
- suffix-text="${this.suffixText}"
175
- supporting-text="${this.supportingText}"
176
- type="${this.type}"
177
- @input="${this.handleChange}"
178
- >
179
- </md-outlined-text-field>
180
- `;
181
- } else {
182
- comp = html`
183
- <md-filled-text-field
184
- id="md-textfield"
185
- ?disabled="${this.disabled}"
186
- ?required="${this.required}"
187
- ?error="${this.error}"
188
- error-text="${this.errorText}"
189
- label="${this.label}"
190
- value="${this.value}"
191
- placeholder="${this.placeholder}"
192
- ?readOnly="${this.readOnly}"
193
- text-direction="${this.textDirection}"
194
- rows="${this.rows}"
195
- max="${this.max}"
196
- maxLength="${this.maxLength}"
197
- min="${this.min}"
198
- minLength="${this.minLength}"
199
- pattern="${this.pattern}"
200
- prefix-text="${this.prefixText}"
201
- suffix-text="${this.suffixText}"
202
- supporting-text="${this.supportingText}"
203
- type="${this.type}"
204
- @input="${this.handleChange}"
205
- >
206
- </md-filled-text-field>
207
- `;
208
- }
209
- return html` ${comp} `;
210
- }
211
- }
212
- declare global {
213
- interface HTMLElementTagNameMap {
214
- 'ix-textbox': IxTextbox;
215
- }
216
- }
1
+ import { html, LitElement } from 'lit';
2
+ import { property, query } from 'lit/decorators.js';
3
+ import '@material/web/textfield/filled-text-field.js';
4
+ import '@material/web/textfield/outlined-text-field.js';
5
+ import {
6
+ TextFieldType,
7
+ UnsupportedTextFieldType,
8
+ TextChangeEvent,
9
+ } from './types/index.js';
10
+
11
+ export class IxTextbox extends LitElement {
12
+ @property({ type: Boolean }) outlined = true;
13
+
14
+ @property({ reflect: true })
15
+ type: TextFieldType | UnsupportedTextFieldType = 'text';
16
+
17
+ @property({ type: Boolean, reflect: true }) disabled = false;
18
+
19
+ /**
20
+ * Gets or sets whether or not the text field is in a visually invalid state.
21
+ *
22
+ * Calling `reportValidity()` will automatically update `error`.
23
+ */
24
+ @property({ type: Boolean, reflect: true }) error = false;
25
+
26
+ /**
27
+ * The error message that replaces supporting text when `error` is true. If
28
+ * `errorText` is an empty string, then the supporting text will continue to
29
+ * show.
30
+ *
31
+ * Calling `reportValidity()` will automatically update `errorText` to the
32
+ * native `validationMessage`.
33
+ */
34
+ @property({ attribute: 'error-text' }) errorText = '';
35
+
36
+ @property() label = '';
37
+
38
+ @property({ type: Boolean, reflect: true }) required = false;
39
+
40
+ /**
41
+ * The current value of the text field. It is always a string.
42
+ */
43
+ @property() value = '';
44
+
45
+ /**
46
+ * An optional prefix to display before the input value.
47
+ */
48
+ @property({ attribute: 'prefix-text' }) prefixText = '';
49
+
50
+ /**
51
+ * An optional suffix to display after the input value.
52
+ */
53
+ @property({ attribute: 'suffix-text' }) suffixText = '';
54
+
55
+ /**
56
+ * Whether or not the text field has a leading icon. Used for SSR.
57
+ */
58
+ @property({ type: Boolean, attribute: 'has-leading-icon' })
59
+ hasLeadingIcon = false;
60
+
61
+ /**
62
+ * Whether or not the text field has a trailing icon. Used for SSR.
63
+ */
64
+ @property({ type: Boolean, attribute: 'has-trailing-icon' })
65
+ hasTrailingIcon = false;
66
+
67
+ /**
68
+ * Conveys additional information below the text field, such as how it should
69
+ * be used.
70
+ */
71
+ @property({ attribute: 'supporting-text' }) supportingText = '';
72
+
73
+ /**
74
+ * Override the input text CSS `direction`. Useful for RTL languages that use
75
+ * LTR notation for fractions.
76
+ */
77
+ @property({ attribute: 'text-direction' }) textDirection = '';
78
+
79
+ /**
80
+ * The number of rows to display for a `type="textarea"` text field.
81
+ * Defaults to 2.
82
+ */
83
+ @property({ type: Number }) rows = 2;
84
+
85
+ // <input> properties
86
+ /**
87
+ * Defines the greatest value in the range of permitted values.
88
+ *
89
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
90
+ */
91
+ @property() max = '';
92
+
93
+ /**
94
+ * The maximum number of characters a user can enter into the text field. Set
95
+ * to -1 for none.
96
+ *
97
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
98
+ */
99
+ @property({ type: Number }) maxLength = -1;
100
+
101
+ /**
102
+ * Defines the most negative value in the range of permitted values.
103
+ *
104
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
105
+ */
106
+ @property() min = '';
107
+
108
+ /**
109
+ * The minimum number of characters a user can enter into the text field. Set
110
+ * to -1 for none.
111
+ *
112
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
113
+ */
114
+ @property({ type: Number }) minLength = -1;
115
+
116
+ /**
117
+ * A regular expression that the text field's value must match to pass
118
+ * constraint validation.
119
+ *
120
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
121
+ */
122
+ @property() pattern = '';
123
+
124
+ @property({ reflect: true }) placeholder = '';
125
+
126
+ /**
127
+ * Indicates whether or not a user should be able to edit the text field's
128
+ * value.
129
+ *
130
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
131
+ */
132
+ @property({ type: Boolean, reflect: true }) readOnly = false;
133
+
134
+ @query('#md-textfield') mdTextfield!: HTMLInputElement;
135
+
136
+ handleChange(e: Event) {
137
+ const inputElement = e.target as HTMLInputElement;
138
+ const textChangeEvent = new CustomEvent('textChange', {
139
+ detail: {
140
+ value: inputElement.value,
141
+ },
142
+ composed: true,
143
+ } as TextChangeEvent);
144
+
145
+ this.dispatchEvent(textChangeEvent);
146
+ }
147
+
148
+ getValidityStatus() {
149
+ return this.mdTextfield?.reportValidity();
150
+ }
151
+
152
+ render() {
153
+ let comp;
154
+ if (this.outlined) {
155
+ comp = html`
156
+ <md-outlined-text-field
157
+ id="md-textfield"
158
+ ?disabled="${this.disabled}"
159
+ ?required="${this.required}"
160
+ ?error="${this.error}"
161
+ error-text="${this.errorText}"
162
+ label="${this.label}"
163
+ value="${this.value}"
164
+ placeholder="${this.placeholder}"
165
+ ?readOnly="${this.readOnly}"
166
+ text-direction="${this.textDirection}"
167
+ rows="${this.rows}"
168
+ max="${this.max}"
169
+ maxLength="${this.maxLength}"
170
+ min="${this.min}"
171
+ minLength="${this.minLength}"
172
+ pattern="${this.pattern}"
173
+ prefix-text="${this.prefixText}"
174
+ suffix-text="${this.suffixText}"
175
+ supporting-text="${this.supportingText}"
176
+ type="${this.type}"
177
+ @input="${this.handleChange}"
178
+ >
179
+ </md-outlined-text-field>
180
+ `;
181
+ } else {
182
+ comp = html`
183
+ <md-filled-text-field
184
+ id="md-textfield"
185
+ ?disabled="${this.disabled}"
186
+ ?required="${this.required}"
187
+ ?error="${this.error}"
188
+ error-text="${this.errorText}"
189
+ label="${this.label}"
190
+ value="${this.value}"
191
+ placeholder="${this.placeholder}"
192
+ ?readOnly="${this.readOnly}"
193
+ text-direction="${this.textDirection}"
194
+ rows="${this.rows}"
195
+ max="${this.max}"
196
+ maxLength="${this.maxLength}"
197
+ min="${this.min}"
198
+ minLength="${this.minLength}"
199
+ pattern="${this.pattern}"
200
+ prefix-text="${this.prefixText}"
201
+ suffix-text="${this.suffixText}"
202
+ supporting-text="${this.supportingText}"
203
+ type="${this.type}"
204
+ @input="${this.handleChange}"
205
+ >
206
+ </md-filled-text-field>
207
+ `;
208
+ }
209
+ return html` ${comp} `;
210
+ }
211
+ }
212
+ declare global {
213
+ interface HTMLElementTagNameMap {
214
+ 'ix-textbox': IxTextbox;
215
+ }
216
+ }
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export { IxTextbox } from './IxTextbox.js';
1
+ export { IxTextbox } from './IxTextbox.js';