@umbraco-ui/uui-input-lock 0.1.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 uui-app
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,35 @@
1
+ # uui-input-lock
2
+
3
+ ![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-input-lock?logoColor=%231B264F)
4
+
5
+ Umbraco style input-lock component.
6
+
7
+ ### See it in action
8
+
9
+ Preview the component on [Storybook](https://uui.umbraco.com/?path=/story/uui-input-lock)
10
+
11
+ ## Installation
12
+
13
+ ### ES imports
14
+
15
+ ```zsh
16
+ npm i @umbraco-ui/uui-input-lock
17
+ ```
18
+
19
+ Import the registration of `<uui-input-lock>` via:
20
+
21
+ ```javascript
22
+ import '@umbraco-ui/uui-input-lock';
23
+ ```
24
+
25
+ When looking to leverage the `UUIInputLockElement` base class as a type and/or for extension purposes, do so via:
26
+
27
+ ```javascript
28
+ import { UUIInputLockElement } from '@umbraco-ui/uui-input-lock';
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```html
34
+ <uui-input-lock></uui-input-lock>
35
+ ```
@@ -0,0 +1,270 @@
1
+ {
2
+ "version": "experimental",
3
+ "tags": [
4
+ {
5
+ "name": "uui-input-lock",
6
+ "path": "./lib/uui-input-lock.element.ts",
7
+ "attributes": [
8
+ {
9
+ "name": "locked",
10
+ "description": "Determine the inputs locked state.",
11
+ "type": "boolean",
12
+ "default": "\"true\""
13
+ },
14
+ {
15
+ "name": "minlength",
16
+ "description": "This is a minimum value of the input.",
17
+ "type": "number",
18
+ "default": "\"undefined\""
19
+ },
20
+ {
21
+ "name": "minlength-message",
22
+ "description": "Minlength validation message.",
23
+ "type": "boolean"
24
+ },
25
+ {
26
+ "name": "maxlength",
27
+ "description": "This is a maximum value of the input.",
28
+ "type": "number",
29
+ "default": "\"undefined\""
30
+ },
31
+ {
32
+ "name": "maxlength-message",
33
+ "description": "Maxlength validation message.",
34
+ "type": "boolean"
35
+ },
36
+ {
37
+ "name": "disabled",
38
+ "description": "Disables the input.",
39
+ "type": "boolean",
40
+ "default": "\"false\""
41
+ },
42
+ {
43
+ "name": "readonly",
44
+ "description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
45
+ "type": "boolean",
46
+ "default": "true"
47
+ },
48
+ {
49
+ "name": "label",
50
+ "description": "Label for input element.",
51
+ "type": "string"
52
+ },
53
+ {
54
+ "name": "placeholder",
55
+ "description": "Defines the input placeholder.",
56
+ "type": "string",
57
+ "default": "\"''\""
58
+ },
59
+ {
60
+ "name": "type",
61
+ "description": "This property specifies the type of input that will be rendered.",
62
+ "type": "'text' | 'tel'| 'url'| 'email'| 'password'| 'date'| 'month'| 'week'| 'time'| 'datetime-local'| 'number'| 'color'",
63
+ "default": "\"text\""
64
+ },
65
+ {
66
+ "name": "name",
67
+ "description": "This is a name property of the component.",
68
+ "type": "string",
69
+ "default": "\"''\""
70
+ },
71
+ {
72
+ "name": "value",
73
+ "description": "Value of this form control.",
74
+ "type": "string",
75
+ "default": "\"''\""
76
+ },
77
+ {
78
+ "name": "pristine",
79
+ "description": "Determines wether the form control has been touched or interacted with, this determines wether the validation-status of this form control should be made visible.",
80
+ "type": "boolean",
81
+ "default": "\"false\""
82
+ },
83
+ {
84
+ "name": "required",
85
+ "description": "Apply validation rule for requiring a value of this form control.",
86
+ "type": "boolean",
87
+ "default": "\"false\""
88
+ },
89
+ {
90
+ "name": "required-message",
91
+ "description": "Required validation message.",
92
+ "type": "string",
93
+ "default": "\"This field is required\""
94
+ },
95
+ {
96
+ "name": "error",
97
+ "description": "Apply custom error on this input.",
98
+ "type": "boolean",
99
+ "default": "false"
100
+ },
101
+ {
102
+ "name": "error-message",
103
+ "description": "Custom error message.",
104
+ "type": "string",
105
+ "default": "\"This field is invalid\""
106
+ }
107
+ ],
108
+ "properties": [
109
+ {
110
+ "name": "locked",
111
+ "attribute": "locked",
112
+ "description": "Determine the inputs locked state.",
113
+ "type": "boolean",
114
+ "default": "\"true\""
115
+ },
116
+ {
117
+ "name": "styles",
118
+ "type": "CSSResult[]",
119
+ "default": "[null,null]"
120
+ },
121
+ {
122
+ "name": "minlength",
123
+ "attribute": "minlength",
124
+ "description": "This is a minimum value of the input.",
125
+ "type": "number",
126
+ "default": "\"undefined\""
127
+ },
128
+ {
129
+ "name": "minlengthMessage",
130
+ "attribute": "minlength-message",
131
+ "description": "Minlength validation message.",
132
+ "type": "boolean"
133
+ },
134
+ {
135
+ "name": "maxlength",
136
+ "attribute": "maxlength",
137
+ "description": "This is a maximum value of the input.",
138
+ "type": "number",
139
+ "default": "\"undefined\""
140
+ },
141
+ {
142
+ "name": "maxlengthMessage",
143
+ "attribute": "maxlength-message",
144
+ "description": "Maxlength validation message.",
145
+ "type": "boolean"
146
+ },
147
+ {
148
+ "name": "disabled",
149
+ "attribute": "disabled",
150
+ "description": "Disables the input.",
151
+ "type": "boolean",
152
+ "default": "\"false\""
153
+ },
154
+ {
155
+ "name": "readonly",
156
+ "attribute": "readonly",
157
+ "description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
158
+ "type": "boolean",
159
+ "default": "true"
160
+ },
161
+ {
162
+ "name": "label",
163
+ "attribute": "label",
164
+ "description": "Label for input element.",
165
+ "type": "string"
166
+ },
167
+ {
168
+ "name": "placeholder",
169
+ "attribute": "placeholder",
170
+ "description": "Defines the input placeholder.",
171
+ "type": "string",
172
+ "default": "\"''\""
173
+ },
174
+ {
175
+ "name": "type",
176
+ "attribute": "type",
177
+ "description": "This property specifies the type of input that will be rendered.",
178
+ "type": "'text' | 'tel'| 'url'| 'email'| 'password'| 'date'| 'month'| 'week'| 'time'| 'datetime-local'| 'number'| 'color'",
179
+ "default": "\"text\""
180
+ },
181
+ {
182
+ "name": "formAssociated",
183
+ "description": "This is a static class field indicating that the element is can be used inside a native form and participate in its events. It may require a polyfill, check support here https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals. Read more about form controls here https://web.dev/more-capable-form-controls/",
184
+ "type": "boolean",
185
+ "default": "true"
186
+ },
187
+ {
188
+ "name": "name",
189
+ "attribute": "name",
190
+ "description": "This is a name property of the component.",
191
+ "type": "string",
192
+ "default": "\"''\""
193
+ },
194
+ {
195
+ "name": "value",
196
+ "attribute": "value",
197
+ "description": "Value of this form control.",
198
+ "type": "string",
199
+ "default": "\"''\""
200
+ },
201
+ {
202
+ "name": "pristine",
203
+ "attribute": "pristine",
204
+ "description": "Determines wether the form control has been touched or interacted with, this determines wether the validation-status of this form control should be made visible.",
205
+ "type": "boolean",
206
+ "default": "\"false\""
207
+ },
208
+ {
209
+ "name": "required",
210
+ "attribute": "required",
211
+ "description": "Apply validation rule for requiring a value of this form control.",
212
+ "type": "boolean",
213
+ "default": "\"false\""
214
+ },
215
+ {
216
+ "name": "requiredMessage",
217
+ "attribute": "required-message",
218
+ "description": "Required validation message.",
219
+ "type": "string",
220
+ "default": "\"This field is required\""
221
+ },
222
+ {
223
+ "name": "error",
224
+ "attribute": "error",
225
+ "description": "Apply custom error on this input.",
226
+ "type": "boolean",
227
+ "default": "false"
228
+ },
229
+ {
230
+ "name": "errorMessage",
231
+ "attribute": "error-message",
232
+ "description": "Custom error message.",
233
+ "type": "string",
234
+ "default": "\"This field is invalid\""
235
+ },
236
+ {
237
+ "name": "validationMessage"
238
+ }
239
+ ],
240
+ "events": [
241
+ {
242
+ "name": "change",
243
+ "description": "on change"
244
+ },
245
+ {
246
+ "name": "input",
247
+ "description": "on input"
248
+ },
249
+ {
250
+ "name": "keyup",
251
+ "description": "on keyup"
252
+ }
253
+ ],
254
+ "slots": [
255
+ {
256
+ "name": "",
257
+ "description": "input label - for the input label text."
258
+ },
259
+ {
260
+ "name": "prepend",
261
+ "description": "for components to render to the left of the input."
262
+ },
263
+ {
264
+ "name": "append",
265
+ "description": "for components to render to the right of the input."
266
+ }
267
+ ]
268
+ }
269
+ ]
270
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './uui-input-lock.element';
package/lib/index.js ADDED
@@ -0,0 +1,74 @@
1
+ import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2
+ import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
3
+ import { css, html } from 'lit';
4
+ import { UUIInputElement } from '@umbraco-ui/uui-input/lib';
5
+ import { iconLock, iconUnlock } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
6
+ import { property } from 'lit/decorators.js';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __decorateClass = (decorators, target, key, kind) => {
11
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
+ if (decorator = decorators[i])
14
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
15
+ if (kind && result)
16
+ __defProp(target, key, result);
17
+ return result;
18
+ };
19
+ let UUIInputLockElement = class extends UUIInputElement {
20
+ constructor() {
21
+ super();
22
+ this.locked = true;
23
+ this.readonly = true;
24
+ }
25
+ connectedCallback() {
26
+ super.connectedCallback();
27
+ demandCustomElement(this, "uui-icon");
28
+ demandCustomElement(this, "uui-button");
29
+ }
30
+ _onLockToggle() {
31
+ this.readonly = this.locked = !this.locked;
32
+ }
33
+ renderIcon() {
34
+ return this.locked === true ? html`<uui-icon name="lock" .fallback=${iconLock.strings[0]}></uui-icon>` : html`<uui-icon
35
+ name="unlock"
36
+ .fallback=${iconUnlock.strings[0]}></uui-icon>`;
37
+ }
38
+ renderPrepend() {
39
+ return html`<uui-button
40
+ .disabled=${this.disabled}
41
+ @click=${this._onLockToggle}
42
+ compact
43
+ id="lock">
44
+ ${this.renderIcon()}
45
+ </uui-button>`;
46
+ }
47
+ };
48
+ UUIInputLockElement.styles = [
49
+ ...UUIInputElement.styles,
50
+ css`
51
+ #lock {
52
+ height: 100%;
53
+
54
+ --uui-button-padding-top-factor: 0;
55
+ --uui-button-padding-bottom-factor: 0;
56
+ --uui-button-padding-left-factor: 0.75;
57
+ --uui-button-padding-right-factor: 0.75;
58
+ font-size: 12px;
59
+ }
60
+
61
+ :host([locked]) #input {
62
+ cursor: not-allowed;
63
+ opacity: 0.5;
64
+ }
65
+ `
66
+ ];
67
+ __decorateClass([
68
+ property({ type: Boolean, reflect: true })
69
+ ], UUIInputLockElement.prototype, "locked", 2);
70
+ UUIInputLockElement = __decorateClass([
71
+ defineElement("uui-input-lock")
72
+ ], UUIInputLockElement);
73
+
74
+ export { UUIInputLockElement };
@@ -0,0 +1,25 @@
1
+ import { UUIInputElement } from '@umbraco-ui/uui-input/lib';
2
+ /**
3
+ * @element uui-input-lock
4
+ * @extends uui-input
5
+ */
6
+ export declare class UUIInputLockElement extends UUIInputElement {
7
+ static styles: import("lit").CSSResult[];
8
+ /**
9
+ * Determine the inputs locked state.
10
+ * @type {boolean}
11
+ * @attr
12
+ * @default true
13
+ */
14
+ locked: boolean;
15
+ constructor();
16
+ connectedCallback(): void;
17
+ _onLockToggle(): void;
18
+ renderIcon(): import("lit-html").TemplateResult<1>;
19
+ renderPrepend(): import("lit-html").TemplateResult<1>;
20
+ }
21
+ declare global {
22
+ interface HTMLElementTagNameMap {
23
+ 'uui-input-lock': UUIInputLockElement;
24
+ }
25
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@umbraco-ui/uui-input-lock",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "keywords": [
6
+ "Umbraco",
7
+ "Custom elements",
8
+ "Web components",
9
+ "UI",
10
+ "Lit",
11
+ "Input Lock"
12
+ ],
13
+ "description": "Umbraco UI input-lock component",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/umbraco/Umbraco.UI.git",
17
+ "directory": "packages/uui-input-lock"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/umbraco/Umbraco.UI/issues"
21
+ },
22
+ "main": "./lib/index.js",
23
+ "module": "./lib/index.js",
24
+ "types": "./lib/index.d.ts",
25
+ "type": "module",
26
+ "customElements": "custom-elements.json",
27
+ "files": [
28
+ "lib/**/*.d.ts",
29
+ "lib/**/*.js",
30
+ "custom-elements.json"
31
+ ],
32
+ "dependencies": {
33
+ "@umbraco-ui/uui-base": "0.1.0",
34
+ "@umbraco-ui/uui-button": "0.2.0",
35
+ "@umbraco-ui/uui-icon": "0.1.0",
36
+ "@umbraco-ui/uui-input": "0.1.0"
37
+ },
38
+ "scripts": {
39
+ "build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
40
+ "clean": "tsc --build --clean && rimraf dist lib/*.js lib/**/*.js custom-elements.json",
41
+ "analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "homepage": "https://uui.umbraco.com/?path=/story/uui-input-lock",
47
+ "gitHead": "9ed7860ce865d310b85bd1718f37b59db873aefd"
48
+ }