@digital-realty/ix-field 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ix-field
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,69 @@
1
+ # \<ix-field>
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-field
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@digital-realty/ix-field/ix-field.js';
16
+ </script>
17
+
18
+ <ix-field></ix-field>
19
+ ```
20
+
21
+ ### In React
22
+ ```html
23
+ <script type="module">
24
+ import { IxField } from '@digital-realty/ix-field/IxField'
25
+ </script>
26
+ ```
27
+
28
+ ## Linting and formatting
29
+
30
+ To scan the project for linting and formatting errors, run
31
+
32
+ ```bash
33
+ npm run lint
34
+ ```
35
+
36
+ To automatically fix linting and formatting errors, run
37
+
38
+ ```bash
39
+ npm run format
40
+ ```
41
+
42
+ ## Testing with Web Test Runner
43
+
44
+ To execute a single test run:
45
+
46
+ ```bash
47
+ npm run test
48
+ ```
49
+
50
+ To run the tests in interactive watch mode run:
51
+
52
+ ```bash
53
+ npm run test:watch
54
+ ```
55
+
56
+
57
+ ## Tooling configs
58
+
59
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
60
+
61
+ If you customize the configuration a lot, you can consider moving them to individual files.
62
+
63
+ ## Local Demo with `web-dev-server`
64
+
65
+ ```bash
66
+ npm start
67
+ ```
68
+
69
+ To run a local development server that serves the basic demo located in `demo/index.html`
@@ -0,0 +1,29 @@
1
+ import { LitElement } from 'lit';
2
+ import '@material/web/field/filled-field.js';
3
+ import '@material/web/field/outlined-field.js';
4
+ export declare class IxField extends LitElement {
5
+ filled: boolean;
6
+ disabled: boolean;
7
+ error: boolean;
8
+ focused: boolean;
9
+ label: string;
10
+ populated: boolean;
11
+ required: boolean;
12
+ resizable: boolean;
13
+ supportingText: string;
14
+ errorText: string;
15
+ count: number;
16
+ max: number;
17
+ /**
18
+ * Whether or not the field has leading content.
19
+ */
20
+ hasStart: boolean;
21
+ /**
22
+ * Whether or not the field has trailing content.
23
+ */
24
+ hasEnd: boolean;
25
+ private input;
26
+ connectedCallback(): void;
27
+ private handleSlotInput;
28
+ protected render(): import("lit-html").TemplateResult<2 | 1>;
29
+ }
@@ -0,0 +1,112 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement } from 'lit';
3
+ import { html as staticHtml, literal } from 'lit/static-html.js';
4
+ import '@material/web/field/filled-field.js';
5
+ import '@material/web/field/outlined-field.js';
6
+ import { property } from 'lit/decorators.js';
7
+ export class IxField extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.filled = false;
11
+ this.disabled = false;
12
+ this.error = false;
13
+ this.focused = false;
14
+ this.label = '';
15
+ this.populated = false;
16
+ this.required = false;
17
+ this.resizable = false;
18
+ this.supportingText = '';
19
+ this.errorText = '';
20
+ this.count = -1;
21
+ this.max = -1;
22
+ /**
23
+ * Whether or not the field has leading content.
24
+ */
25
+ this.hasStart = false;
26
+ /**
27
+ * Whether or not the field has trailing content.
28
+ */
29
+ this.hasEnd = false;
30
+ this.input = null;
31
+ }
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ this.input = this.querySelector('input, textarea');
35
+ this.handleSlotInput();
36
+ }
37
+ handleSlotInput() {
38
+ var _a, _b;
39
+ const length = (_b = (_a = this.input) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length;
40
+ this.count = length !== undefined ? length : this.count;
41
+ }
42
+ render() {
43
+ const tag = this.filled
44
+ ? literal `md-filled-field`
45
+ : literal `md-outlined-field`;
46
+ return staticHtml `<${tag}
47
+ ?disabled=${this.disabled}
48
+ ?error=${this.error}
49
+ error-text=${this.errorText}
50
+ ?focused=${this.focused}
51
+ label=${this.label}
52
+ supporting-text=${this.supportingText}
53
+ ?populated=${this.populated}
54
+ ?required=${this.required}
55
+ ?resizable=${this.resizable}
56
+ count=${this.count}
57
+ max=${this.max}
58
+ ?has-start=${this.hasStart}
59
+ ?has-end=${this.hasEnd}
60
+ >
61
+ <slot name="start" slot="start"></slot>
62
+ <slot
63
+ @input=${this.handleSlotInput}
64
+ ></slot>
65
+ <slot name="end" slot="end"></slot>
66
+ <slot name="aria-describedby" slot="aria-describedby"></slot>
67
+ </${tag}>`;
68
+ }
69
+ }
70
+ __decorate([
71
+ property({ type: Boolean })
72
+ ], IxField.prototype, "filled", void 0);
73
+ __decorate([
74
+ property({ type: Boolean, reflect: true })
75
+ ], IxField.prototype, "disabled", void 0);
76
+ __decorate([
77
+ property({ type: Boolean })
78
+ ], IxField.prototype, "error", void 0);
79
+ __decorate([
80
+ property({ type: Boolean })
81
+ ], IxField.prototype, "focused", void 0);
82
+ __decorate([
83
+ property()
84
+ ], IxField.prototype, "label", void 0);
85
+ __decorate([
86
+ property({ type: Boolean })
87
+ ], IxField.prototype, "populated", void 0);
88
+ __decorate([
89
+ property({ type: Boolean })
90
+ ], IxField.prototype, "required", void 0);
91
+ __decorate([
92
+ property({ type: Boolean })
93
+ ], IxField.prototype, "resizable", void 0);
94
+ __decorate([
95
+ property({ attribute: 'supporting-text' })
96
+ ], IxField.prototype, "supportingText", void 0);
97
+ __decorate([
98
+ property({ attribute: 'error-text' })
99
+ ], IxField.prototype, "errorText", void 0);
100
+ __decorate([
101
+ property({ type: Number })
102
+ ], IxField.prototype, "count", void 0);
103
+ __decorate([
104
+ property({ type: Number })
105
+ ], IxField.prototype, "max", void 0);
106
+ __decorate([
107
+ property({ type: Boolean, attribute: 'has-start' })
108
+ ], IxField.prototype, "hasStart", void 0);
109
+ __decorate([
110
+ property({ type: Boolean, attribute: 'has-end' })
111
+ ], IxField.prototype, "hasEnd", void 0);
112
+ //# sourceMappingURL=IxField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxField.js","sourceRoot":"","sources":["../src/IxField.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAe,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,qCAAqC,CAAC;AAC7C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,OAAO,OAAQ,SAAQ,UAAU;IAAvC;;QAC+B,WAAM,GAAG,KAAK,CAAC;QAEA,aAAQ,GAAG,KAAK,CAAC;QAEhC,UAAK,GAAG,KAAK,CAAC;QAEd,YAAO,GAAG,KAAK,CAAC;QAEjC,UAAK,GAAG,EAAE,CAAC;QAEM,cAAS,GAAG,KAAK,CAAC;QAElB,aAAQ,GAAG,KAAK,CA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AAe;;;;QAI3B,GAAG,GAAG,CAAC;IACb,CAAC;CACF;AA3E8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCAAgB;AAEA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAkB;AAEhC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAe;AAEd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAiB;AAEjC;IAAX,QAAQ,EAAE;sCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAmB;AAElB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAmB;AAEH;IAA3C,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;+CAAqB;AAEzB;IAAtC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;0CAAgB;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAAU;AAKgB;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;yCAAkB;AAKnB;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;uCAAgB","sourcesContent":["import { LitElement } from 'lit';\nimport { html as staticHtml, StaticValue, literal } from 'lit/static-html.js';\nimport '@material/web/field/filled-field.js';\nimport '@material/web/field/outlined-field.js';\nimport { property } from 'lit/decorators.js';\n\nexport class IxField extends LitElement {\n @property({ type: Boolean }) filled = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @property({ type: Boolean }) error = false;\n\n @property({ type: Boolean }) focused = false;\n\n @property() label = '';\n\n @property({ type: Boolean }) populated = false;\n\n @property({ type: Boolean }) required = false;\n\n @property({ type: Boolean }) resizable = false;\n\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n @property({ attribute: 'error-text' }) errorText = '';\n\n @property({ type: Number }) count = -1;\n\n @property({ type: Number }) max = -1;\n\n /**\n * Whether or not the field has leading content.\n */\n @property({ type: Boolean, attribute: 'has-start' }) hasStart = false;\n\n /**\n * Whether or not the field has trailing content.\n */\n @property({ type: Boolean, attribute: 'has-end' }) hasEnd = false;\n\n private input: HTMLInputElement | null = null;\n\n override connectedCallback() {\n super.connectedCallback();\n this.input = this.querySelector('input, textarea') as HTMLInputElement;\n this.handleSlotInput();\n }\n\n private handleSlotInput() {\n const length = this.input?.value?.length;\n this.count = length !== undefined ? length : this.count;\n }\n\n protected override render() {\n const tag: StaticValue = this.filled\n ? literal`md-filled-field`\n : literal`md-outlined-field`;\n\n return staticHtml`<${tag}\n ?disabled=${this.disabled}\n ?error=${this.error}\n error-text=${this.errorText}\n ?focused=${this.focused}\n label=${this.label}\n supporting-text=${this.supportingText}\n ?populated=${this.populated}\n ?required=${this.required}\n ?resizable=${this.resizable}\n count=${this.count}\n max=${this.max}\n ?has-start=${this.hasStart}\n ?has-end=${this.hasEnd}\n >\n <slot name=\"start\" slot=\"start\"></slot>\n <slot\n @input=${this.handleSlotInput}\n ></slot>\n <slot name=\"end\" slot=\"end\"></slot>\n <slot name=\"aria-describedby\" slot=\"aria-describedby\"></slot>\n </${tag}>`;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export { IxField } from './IxField.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { IxField } from './IxField.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,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { IxField } from './IxField.js';\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IxField } from './IxField.js';
2
+ window.customElements.define('ix-field', IxField);
3
+ //# sourceMappingURL=ix-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ix-field.js","sourceRoot":"","sources":["../src/ix-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC","sourcesContent":["import { IxField } from './IxField.js';\n\nwindow.customElements.define('ix-field', IxField);\n"]}
@@ -0,0 +1,2 @@
1
+ import { IxField as LitComp } from '../IxField.js';
2
+ export declare const IxField: import("@lit-labs/react").ReactWebComponent<LitComp, {}>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit-labs/react';
3
+ import { IxField as LitComp } from '../IxField.js';
4
+ window.customElements.define('ix-field', LitComp);
5
+ export const IxField = createComponent({
6
+ tagName: 'ix-field',
7
+ elementClass: LitComp,
8
+ react: React,
9
+ });
10
+ //# sourceMappingURL=IxField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IxField.js","sourceRoot":"","sources":["../../src/react/IxField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,OAAO;IACrB,KAAK,EAAE,KAAK;CACb,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit-labs/react';\nimport { IxField as LitComp } from '../IxField.js';\n\nwindow.customElements.define('ix-field', LitComp);\n\nexport const IxField = createComponent({\n tagName: 'ix-field',\n elementClass: LitComp,\n react: React,\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@digital-realty/ix-field",
3
+ "description": "Webcomponent ix-field following open-wc recommendations",
4
+ "license": "MIT",
5
+ "author": "Digital Realty",
6
+ "version": "0.0.1",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./ix-field.js": "./dist/ix-field.js",
13
+ "./IxIcon": "./dist/react/IxIcon.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.1.0",
30
+ "@material/web": "^1.0.0",
31
+ "lit": "^2.0.2",
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
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
39
+ "@typescript-eslint/parser": "^5.48.0",
40
+ "@web/dev-server": "^0.1.34",
41
+ "@web/test-runner": "^0.14.0",
42
+ "concurrently": "^5.3.0",
43
+ "eslint": "^8.31.0",
44
+ "eslint-config-prettier": "^8.3.0",
45
+ "husky": "^4.3.8",
46
+ "lint-staged": "^10.5.4",
47
+ "prettier": "^2.4.1",
48
+ "tslib": "^2.3.1",
49
+ "typescript": "^4.5.2"
50
+ },
51
+ "customElements": "custom-elements.json",
52
+ "eslintConfig": {
53
+ "parser": "@typescript-eslint/parser",
54
+ "extends": [
55
+ "@open-wc",
56
+ "prettier"
57
+ ],
58
+ "plugins": [
59
+ "@typescript-eslint"
60
+ ],
61
+ "rules": {
62
+ "no-unused-vars": "off",
63
+ "@typescript-eslint/no-unused-vars": [
64
+ "error"
65
+ ],
66
+ "import/no-unresolved": "off",
67
+ "import/extensions": [
68
+ "error",
69
+ "always",
70
+ {
71
+ "ignorePackages": true
72
+ }
73
+ ]
74
+ }
75
+ },
76
+ "prettier": {
77
+ "singleQuote": true,
78
+ "arrowParens": "avoid"
79
+ },
80
+ "husky": {
81
+ "hooks": {
82
+ "pre-commit": "lint-staged"
83
+ }
84
+ },
85
+ "lint-staged": {
86
+ "*.ts": [
87
+ "eslint --fix",
88
+ "prettier --write"
89
+ ]
90
+ },
91
+ "files": [
92
+ "/dist",
93
+ "!/dist/test",
94
+ "package.json",
95
+ "README.md",
96
+ "LICENSE"
97
+ ],
98
+ "gitHead": "d57dedc86cbf4e58a5f01445702dc5f540317d00"
99
+ }