@digital-realty/ix-time 1.0.5
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 +21 -0
- package/README.md +78 -0
- package/dist/IxTime.d.ts +84 -0
- package/dist/IxTime.js +216 -0
- package/dist/IxTime.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/ix-time-styles.d.ts +1 -0
- package/dist/ix-time-styles.js +25 -0
- package/dist/ix-time-styles.js.map +1 -0
- package/dist/ix-time.d.ts +1 -0
- package/dist/ix-time.js +3 -0
- package/dist/ix-time.js.map +1 -0
- package/package.json +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ix-time
|
|
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,78 @@
|
|
|
1
|
+
# \<ix-time>
|
|
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-time
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import '@digital-realty/ix-time/ix-time.js';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<ix-time
|
|
19
|
+
label="Restricted time"
|
|
20
|
+
value="10:30"
|
|
21
|
+
min="09:00"
|
|
22
|
+
max="17:00"
|
|
23
|
+
.onChanged=${selectedDate => console.log(selectedDate)}
|
|
24
|
+
></ix-time>
|
|
25
|
+
|
|
26
|
+
<ix-time label="Disabled time" value="10:30" disabled></ix-time>
|
|
27
|
+
|
|
28
|
+
<ix-time label="Unrestricted time" value="10:30"></ix-time>
|
|
29
|
+
|
|
30
|
+
<ix-time label="Required time" required></ix-time>
|
|
31
|
+
|
|
32
|
+
<ix-time
|
|
33
|
+
label="Time with custom error text"
|
|
34
|
+
errorText="Custom error text here."
|
|
35
|
+
></ix-time>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Linting and formatting
|
|
39
|
+
|
|
40
|
+
To scan the project for linting and formatting errors, run
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run lint
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
To automatically fix linting and formatting errors, run
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run format
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Testing with Web Test Runner
|
|
53
|
+
|
|
54
|
+
To execute a single test run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run test
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
To run the tests in interactive watch mode run:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run test:watch
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Tooling configs
|
|
67
|
+
|
|
68
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
69
|
+
|
|
70
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
71
|
+
|
|
72
|
+
## Local Demo with `web-dev-server`
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm start
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
package/dist/IxTime.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@digital-realty/ix-field/ix-field.js';
|
|
3
|
+
export declare class IxTime extends LitElement {
|
|
4
|
+
static get styles(): import("lit").CSSResult[];
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
min: string;
|
|
8
|
+
max: string;
|
|
9
|
+
/** @nocollapse */
|
|
10
|
+
static shadowRootOptions: {
|
|
11
|
+
delegatesFocus: boolean;
|
|
12
|
+
mode: ShadowRootMode;
|
|
13
|
+
slotAssignment?: SlotAssignmentMode | undefined;
|
|
14
|
+
customElements?: CustomElementRegistry | undefined;
|
|
15
|
+
registry?: CustomElementRegistry | undefined;
|
|
16
|
+
};
|
|
17
|
+
/** @nocollapse */
|
|
18
|
+
static readonly formAssociated = true;
|
|
19
|
+
private readonly internals;
|
|
20
|
+
timeInput: HTMLInputElement;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Gets or sets whether or not the text field is in a visually invalid state.
|
|
24
|
+
*
|
|
25
|
+
* This error state overrides the error state controlled by
|
|
26
|
+
* `reportValidity()`.
|
|
27
|
+
*/
|
|
28
|
+
get error(): boolean;
|
|
29
|
+
errorText: string;
|
|
30
|
+
required: boolean;
|
|
31
|
+
hideError: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The associated form element with which this element's value will submit.
|
|
34
|
+
*/
|
|
35
|
+
get form(): HTMLFormElement | null;
|
|
36
|
+
/**
|
|
37
|
+
* The labels this element is associated with.
|
|
38
|
+
*/
|
|
39
|
+
get labels(): NodeList;
|
|
40
|
+
/**
|
|
41
|
+
* The HTML name to use in form submission.
|
|
42
|
+
*/
|
|
43
|
+
get name(): string;
|
|
44
|
+
set name(name: string);
|
|
45
|
+
/**
|
|
46
|
+
* Returns the text field's validation error message.
|
|
47
|
+
*
|
|
48
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
|
|
49
|
+
*/
|
|
50
|
+
get validationMessage(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a `ValidityState` object that represents the validity states of the
|
|
53
|
+
* text field.
|
|
54
|
+
*
|
|
55
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
|
|
56
|
+
*/
|
|
57
|
+
get validity(): ValidityState;
|
|
58
|
+
/**
|
|
59
|
+
* Returns whether an element will successfully validate based on forms
|
|
60
|
+
* validation rules and constraints.
|
|
61
|
+
*
|
|
62
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
|
|
63
|
+
*/
|
|
64
|
+
get willValidate(): boolean;
|
|
65
|
+
checkValidity(): boolean;
|
|
66
|
+
reportValidity(): boolean;
|
|
67
|
+
/** @private */
|
|
68
|
+
formResetCallback(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Reset the text field to its default value.
|
|
71
|
+
*/
|
|
72
|
+
reset(): void;
|
|
73
|
+
protected updated(): void;
|
|
74
|
+
focus(): void;
|
|
75
|
+
onChanged: any;
|
|
76
|
+
private focused;
|
|
77
|
+
firstUpdated(): void;
|
|
78
|
+
focusin: () => void;
|
|
79
|
+
clear: () => void;
|
|
80
|
+
handleChange: (e: InputEvent) => void;
|
|
81
|
+
validateDate: () => void;
|
|
82
|
+
focusOut: () => void;
|
|
83
|
+
render(): import("lit").TemplateResult<1>;
|
|
84
|
+
}
|
package/dist/IxTime.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import '@digital-realty/ix-field/ix-field.js';
|
|
6
|
+
import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
|
|
7
|
+
import { IxTimeStyles } from './ix-time-styles.js';
|
|
8
|
+
export class IxTime extends LitElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.label = '';
|
|
12
|
+
this.value = '';
|
|
13
|
+
this.min = '';
|
|
14
|
+
this.max = '';
|
|
15
|
+
this.internals = this /* needed for closure */
|
|
16
|
+
.attachInternals();
|
|
17
|
+
this.disabled = false;
|
|
18
|
+
this.errorText = '';
|
|
19
|
+
this.required = false;
|
|
20
|
+
this.hideError = false;
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this
|
|
22
|
+
this.onChanged = () => { };
|
|
23
|
+
this.focused = false;
|
|
24
|
+
this.focusin = () => {
|
|
25
|
+
this.focused = true;
|
|
26
|
+
};
|
|
27
|
+
this.clear = () => {
|
|
28
|
+
this.value = '';
|
|
29
|
+
};
|
|
30
|
+
this.handleChange = (e) => {
|
|
31
|
+
const { value } = e.target;
|
|
32
|
+
this.value = value;
|
|
33
|
+
this.validateDate();
|
|
34
|
+
this.onChanged(value);
|
|
35
|
+
};
|
|
36
|
+
this.validateDate = () => {
|
|
37
|
+
if (this.value && this.timeInput.validity.valid)
|
|
38
|
+
this.errorText = '';
|
|
39
|
+
else if (this.timeInput.validity.rangeUnderflow ||
|
|
40
|
+
this.timeInput.validity.rangeOverflow) {
|
|
41
|
+
this.errorText = `The value must be between ${this.min} and ${this.max}.`;
|
|
42
|
+
}
|
|
43
|
+
else if (this.required && !this.timeInput.validity.valid) {
|
|
44
|
+
this.errorText = `Time is not valid.`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this.focusOut = () => {
|
|
48
|
+
this.focused = false;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static get styles() {
|
|
52
|
+
return [IxTimeStyles];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets or sets whether or not the text field is in a visually invalid state.
|
|
56
|
+
*
|
|
57
|
+
* This error state overrides the error state controlled by
|
|
58
|
+
* `reportValidity()`.
|
|
59
|
+
*/
|
|
60
|
+
get error() {
|
|
61
|
+
return !!this.errorText;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The associated form element with which this element's value will submit.
|
|
65
|
+
*/
|
|
66
|
+
get form() {
|
|
67
|
+
return this.internals.form;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The labels this element is associated with.
|
|
71
|
+
*/
|
|
72
|
+
get labels() {
|
|
73
|
+
return this.internals.labels;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The HTML name to use in form submission.
|
|
77
|
+
*/
|
|
78
|
+
get name() {
|
|
79
|
+
var _a;
|
|
80
|
+
return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
|
|
81
|
+
}
|
|
82
|
+
set name(name) {
|
|
83
|
+
this.setAttribute('name', name);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns the text field's validation error message.
|
|
87
|
+
*
|
|
88
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
|
|
89
|
+
*/
|
|
90
|
+
get validationMessage() {
|
|
91
|
+
return this.internals.validationMessage;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns a `ValidityState` object that represents the validity states of the
|
|
95
|
+
* text field.
|
|
96
|
+
*
|
|
97
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
|
|
98
|
+
*/
|
|
99
|
+
get validity() {
|
|
100
|
+
return this.internals.validity;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns whether an element will successfully validate based on forms
|
|
104
|
+
* validation rules and constraints.
|
|
105
|
+
*
|
|
106
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
|
|
107
|
+
*/
|
|
108
|
+
get willValidate() {
|
|
109
|
+
return this.internals.willValidate;
|
|
110
|
+
}
|
|
111
|
+
checkValidity() {
|
|
112
|
+
return this.internals.checkValidity();
|
|
113
|
+
}
|
|
114
|
+
reportValidity() {
|
|
115
|
+
return this.internals.reportValidity();
|
|
116
|
+
}
|
|
117
|
+
/** @private */
|
|
118
|
+
formResetCallback() {
|
|
119
|
+
this.reset();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Reset the text field to its default value.
|
|
123
|
+
*/
|
|
124
|
+
reset() {
|
|
125
|
+
var _a;
|
|
126
|
+
this.clear();
|
|
127
|
+
this.value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
|
128
|
+
}
|
|
129
|
+
updated() {
|
|
130
|
+
this.internals.setValidity({
|
|
131
|
+
badInput: this.error,
|
|
132
|
+
}, this.error ? this.errorText : '', this.timeInput);
|
|
133
|
+
this.internals.setFormValue(this.value);
|
|
134
|
+
}
|
|
135
|
+
focus() {
|
|
136
|
+
this.timeInput.focus();
|
|
137
|
+
}
|
|
138
|
+
firstUpdated() {
|
|
139
|
+
this.validateDate();
|
|
140
|
+
}
|
|
141
|
+
render() {
|
|
142
|
+
const classes = {
|
|
143
|
+
disabled: this.disabled,
|
|
144
|
+
error: !this.disabled && this.error,
|
|
145
|
+
};
|
|
146
|
+
return html `
|
|
147
|
+
<ix-field
|
|
148
|
+
class="${classMap(classes)}"
|
|
149
|
+
?focused=${this.focused}
|
|
150
|
+
?populated=${this.value}
|
|
151
|
+
?disabled=${this.disabled}
|
|
152
|
+
?required=${this.required}
|
|
153
|
+
?error=${this.error && !this.hideError}
|
|
154
|
+
error-text=${this.errorText}
|
|
155
|
+
label=${this.label}
|
|
156
|
+
@focusin=${this.focusin}
|
|
157
|
+
@focusout=${this.focusOut}
|
|
158
|
+
>
|
|
159
|
+
<input
|
|
160
|
+
id="time-input"
|
|
161
|
+
@change=${this.handleChange}
|
|
162
|
+
.value=${this.value}
|
|
163
|
+
class="flex-fill"
|
|
164
|
+
type="time"
|
|
165
|
+
min=${this.min}
|
|
166
|
+
max=${this.max}
|
|
167
|
+
/>
|
|
168
|
+
</ix-field>
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
(() => {
|
|
173
|
+
requestUpdateOnAriaChange(IxTime);
|
|
174
|
+
})();
|
|
175
|
+
// Form association
|
|
176
|
+
/** @nocollapse */
|
|
177
|
+
IxTime.shadowRootOptions = {
|
|
178
|
+
...LitElement.shadowRootOptions,
|
|
179
|
+
delegatesFocus: true,
|
|
180
|
+
};
|
|
181
|
+
/** @nocollapse */
|
|
182
|
+
IxTime.formAssociated = true;
|
|
183
|
+
__decorate([
|
|
184
|
+
property({ type: String })
|
|
185
|
+
], IxTime.prototype, "label", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: String })
|
|
188
|
+
], IxTime.prototype, "value", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property({ type: String })
|
|
191
|
+
], IxTime.prototype, "min", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property({ type: String })
|
|
194
|
+
], IxTime.prototype, "max", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
query('#time-input')
|
|
197
|
+
], IxTime.prototype, "timeInput", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
property({ type: Boolean, reflect: true })
|
|
200
|
+
], IxTime.prototype, "disabled", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: String })
|
|
203
|
+
], IxTime.prototype, "errorText", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: Boolean, reflect: true })
|
|
206
|
+
], IxTime.prototype, "required", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: Boolean, reflect: true })
|
|
209
|
+
], IxTime.prototype, "hideError", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: Function })
|
|
212
|
+
], IxTime.prototype, "onChanged", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
state()
|
|
215
|
+
], IxTime.prototype, "focused", void 0);
|
|
216
|
+
//# sourceMappingURL=IxTime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IxTime.js","sourceRoot":"","sources":["../src/IxTime.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,OAAO,MAAO,SAAQ,UAAU;IAAtC;;QAS8B,UAAK,GAAG,EAAE,CAAC;QAEX,UAAK,GAAG,EAAE,CAAC;QAEX,QAAG,GAAG,EAAE,CAAC;QAET,QAAG,GAAG,EAAE,CAAC;QAapB,cAAS,GAAI,IAAoB,CAAC,wBAAwB;aACxE,eAAe,EAAE,CAAC;QAIuB,aAAQ,GAAG,KAAK,CAAC;QAYjC,cAAS,GAAG,EAAE,CAAC;QAEC,aAAQ,GAAG,KAAK,CAAC;QAEjB,cAAS,GAAG,KAAK,CAAC;QA4F9D,kDAAkD;QACpB,cAAS,GAAQ,GAAG,EAAE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Q,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qCAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCAAU;AAET;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCAAU;AAgBf;IAArB,KAAK,CAAC,aAAa,CAAC;yCAA8B;AAEP;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAkB;AAYjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAgB;AAEC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAkB;AAEjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAmB;AA6FhC;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;yCAA2B;AAE/C;IAAR,KAAK,EAAE;uCAAyB","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport { IxTimeStyles } from './ix-time-styles.js';\n\nexport class IxTime extends LitElement {\n static {\n requestUpdateOnAriaChange(IxTime);\n }\n\n static get styles() {\n return [IxTimeStyles];\n }\n\n @property({ type: String }) label = '';\n\n @property({ type: String }) value = '';\n\n @property({ type: String }) min = '';\n\n @property({ type: String }) max = '';\n\n // Form association\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n @query('#time-input') timeInput!: HTMLInputElement;\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 * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n get error() {\n return !!this.errorText;\n }\n\n @property({ type: String }) errorText = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n @property({ type: Boolean, reflect: true }) hideError = false;\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this.internals.labels;\n }\n\n /**\n * The HTML name to use in form submission.\n */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n /**\n * Returns the text field's validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Returns a `ValidityState` object that represents the validity states of the\n * text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n checkValidity() {\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.internals.reportValidity();\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset() {\n this.clear();\n this.value = this.getAttribute('value') ?? '';\n }\n\n protected override updated() {\n this.internals.setValidity(\n {\n badInput: this.error,\n },\n this.error ? this.errorText : '',\n this.timeInput\n );\n this.internals.setFormValue(this.value);\n }\n\n override focus() {\n this.timeInput.focus();\n }\n\n // eslint-disable-next-line class-methods-use-this\n @property({ type: Function }) onChanged: any = () => {};\n\n @state() private focused = false;\n\n firstUpdated() {\n this.validateDate();\n }\n\n focusin = () => {\n this.focused = true;\n };\n\n clear = () => {\n this.value = '';\n };\n\n handleChange = (e: InputEvent) => {\n const { value } = e.target as HTMLInputElement;\n this.value = value;\n this.validateDate();\n this.onChanged(value);\n };\n\n validateDate = () => {\n if (this.value && this.timeInput.validity.valid) this.errorText = '';\n else if (\n this.timeInput.validity.rangeUnderflow ||\n this.timeInput.validity.rangeOverflow\n ) {\n this.errorText = `The value must be between ${this.min} and ${this.max}.`;\n } else if (this.required && !this.timeInput.validity.valid) {\n this.errorText = `Time is not valid.`;\n }\n };\n\n focusOut = () => {\n this.focused = false;\n };\n\n render() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.error,\n };\n\n return html`\n <ix-field\n class=\"${classMap(classes)}\"\n ?focused=${this.focused}\n ?populated=${this.value}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error && !this.hideError}\n error-text=${this.errorText}\n label=${this.label}\n @focusin=${this.focusin}\n @focusout=${this.focusOut}\n >\n <input\n id=\"time-input\"\n @change=${this.handleChange}\n .value=${this.value}\n class=\"flex-fill\"\n type=\"time\"\n min=${this.min}\n max=${this.max}\n />\n </ix-field>\n `;\n }\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IxTime } from './IxTime.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { IxTime } from './IxTime.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const IxTimeStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const IxTimeStyles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
ix-field {
|
|
7
|
+
display: block;
|
|
8
|
+
--md-outlined-field-label-text-color: var(--md-sys-text-color-primary);
|
|
9
|
+
--md-outlined-field-outline-color: var(--md-outlined-field-outline-color);
|
|
10
|
+
}
|
|
11
|
+
.flex-fill {
|
|
12
|
+
flex: 1;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
input {
|
|
16
|
+
border: none;
|
|
17
|
+
background: transparent;
|
|
18
|
+
outline: none;
|
|
19
|
+
min-width: 3rem;
|
|
20
|
+
}
|
|
21
|
+
.time {
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
//# sourceMappingURL=ix-time-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ix-time-styles.js","sourceRoot":"","sources":["../src/ix-time-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;CAsB9B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const IxTimeStyles = css`\n :host {\n display: block;\n }\n ix-field {\n display: block;\n --md-outlined-field-label-text-color: var(--md-sys-text-color-primary);\n --md-outlined-field-outline-color: var(--md-outlined-field-outline-color);\n }\n .flex-fill {\n flex: 1;\n align-items: center;\n }\n input {\n border: none;\n background: transparent;\n outline: none;\n min-width: 3rem;\n }\n .time {\n position: relative;\n }\n`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/ix-time.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ix-time.js","sourceRoot":"","sources":["../src/ix-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { IxTime } from './IxTime.js';\n\nwindow.customElements.define('ix-time', IxTime);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digital-realty/ix-time",
|
|
3
|
+
"description": "Webcomponent ix-time following open-wc recommendations",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Digital Realty",
|
|
6
|
+
"version": "1.0.5",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./ix-time.js": "./dist/ix-time.js"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"analyze": "cem analyze --litelement",
|
|
19
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
20
|
+
"build": "tsc && npm run analyze -- --exclude dist",
|
|
21
|
+
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
22
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
23
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
24
|
+
"test": "tsc && wtr --coverage",
|
|
25
|
+
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@digital-realty/ix-field": "*",
|
|
29
|
+
"@digital-realty/theme": "*",
|
|
30
|
+
"@material/web": "^1.0.0",
|
|
31
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
32
|
+
"lit": "^2.0.2"
|
|
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": "9ca086736818b0c988fe3a99745291a039f45145"
|
|
99
|
+
}
|