@c2n/date-input 0.0.8

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) 2024 Nguyen Thai Vinh
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,11 @@
1
+ # Date Input
2
+
3
+ A form-associated, themeable single-date input for Lit applications.
4
+
5
+ ```bash
6
+ npm install @c2n/date-input
7
+ ```
8
+
9
+ ```html
10
+ <c2-date-input name="due" value="2026-09-15" min="2026-09-01" required aria-label="Due date"></c2-date-input>
11
+ ```
@@ -0,0 +1,240 @@
1
+ import { LitElement, html, nothing, unsafeCSS } from "lit";
2
+ import { property, query, state } from "lit/decorators.js";
3
+ import { customElement } from "@c2n/core/element-helper.js";
4
+ import { redispatchEvent } from "@c2n/core/dom-helper.js";
5
+ import { classMap } from "lit/directives/class-map.js";
6
+ import { ifDefined } from "lit/directives/if-defined.js";
7
+ import { live } from "lit/directives/live.js";
8
+ //#region src/date-input.scss?inline
9
+ var date_input_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n flex-direction: column;\n gap: var(--c2-date-input__supporting-text--gap,4px);\n vertical-align: middle;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.field {\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-height: var(--c2-date-input--min-height,36px);\n gap: var(--c2-date-input--gap,8px);\n padding: var(--c2-date-input--padding,6px 8px 6px 12px);\n border: var(--c2-date-input--border,1px solid #bcbcc6);\n border-radius: var(--c2-date-input--border-radius,6px);\n color: var(--c2-date-input--color,#18181b);\n background: var(--c2-date-input--background,#ffffff);\n font-size: var(--c2-date-input--font-size,14px);\n font-family: var(--c2-date-input--font-family,inherit);\n line-height: var(--c2-date-input--line-height,20px);\n cursor: text;\n outline: var(--c2-date-input__focus--outline,2px solid rgba(2, 101, 220, 0.4));\n outline-color: transparent;\n outline-offset: var(--c2-date-input__focus--outline-offset,0px);\n transition: border 250ms cubic-bezier(0.2, 0, 0, 1), background 250ms cubic-bezier(0.2, 0, 0, 1), outline-color 250ms cubic-bezier(0.2, 0, 0, 1);\n}\n.field:hover {\n border: var(--c2-date-input__hover--border,1px solid #a1a1aa);\n}\n.field.focused {\n border: var(--c2-date-input__focus--border,1px solid #0265dc);\n outline: var(--c2-date-input__focus--outline,2px solid rgba(2, 101, 220, 0.4));\n outline-offset: var(--c2-date-input__focus--outline-offset,0px);\n}\n.field.error {\n border: var(--c2-date-input__error--border,1px solid #dc2626);\n}\n.field.error.focused {\n outline: var(--c2-date-input__error__focus--outline,2px solid rgba(220, 38, 38, 0.25));\n}\n.field.read-only {\n cursor: default;\n background: var(--c2-date-input__read-only--background,#fafafa);\n}\n.field.disabled {\n cursor: default;\n opacity: var(--c2-date-input__disabled--opacity,0.38);\n pointer-events: none;\n}\n\ninput {\n flex: 1;\n min-width: 0;\n width: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n outline: 0;\n color: inherit;\n background: transparent;\n font: inherit;\n line-height: inherit;\n}\ninput::-webkit-calendar-picker-indicator {\n display: none;\n}\n\n.calendar-button {\n display: inline-grid;\n flex: none;\n place-items: center;\n width: var(--c2-date-input__calendar-icon--size,18px);\n height: var(--c2-date-input__calendar-icon--size,18px);\n margin: 0;\n padding: 0;\n border: 0;\n color: var(--c2-date-input__calendar-icon--color,#71717a);\n background: transparent;\n cursor: pointer;\n}\n.calendar-button:hover {\n color: var(--c2-date-input__calendar-icon__hover--color,#18181b);\n}\n.calendar-button:disabled {\n cursor: default;\n}\n\n.calendar-button svg,\n::slotted([slot=calendar-icon]) {\n width: var(--c2-date-input__calendar-icon--size,18px);\n height: var(--c2-date-input__calendar-icon--size,18px);\n}\n\n.supporting-text {\n color: var(--c2-date-input__supporting-text--color,#71717a);\n font-size: var(--c2-date-input__supporting-text--font-size,12px);\n line-height: var(--c2-date-input__supporting-text--line-height,16px);\n}\n.supporting-text.error {\n color: var(--c2-date-input__supporting-text__error--color,#dc2626);\n}";
10
+ //#endregion
11
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
12
+ function __decorate(decorators, target, key, desc) {
13
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ }
18
+ //#endregion
19
+ //#region src/date-input.ts
20
+ var DateInput = class DateInput extends LitElement {
21
+ constructor(..._args) {
22
+ super(..._args);
23
+ this.internals = this.attachInternals();
24
+ this.customValidityMessage = "";
25
+ this.defaultValue = "";
26
+ this.defaultCaptured = false;
27
+ this.disabledByForm = false;
28
+ this.focused = false;
29
+ this.hasSupportingSlot = false;
30
+ this.value = "";
31
+ this.min = "";
32
+ this.max = "";
33
+ this.step = 1;
34
+ this.name = "";
35
+ this.autocomplete = "";
36
+ this.required = false;
37
+ this.readOnly = false;
38
+ this.disabled = false;
39
+ this.error = false;
40
+ this.help = "";
41
+ this.errorText = "";
42
+ this.ariaLabel = null;
43
+ }
44
+ static {
45
+ this.formAssociated = true;
46
+ }
47
+ static {
48
+ this.styles = unsafeCSS(date_input_default);
49
+ }
50
+ get form() {
51
+ return this.internals.form;
52
+ }
53
+ get labels() {
54
+ return this.internals.labels;
55
+ }
56
+ get validity() {
57
+ return this.internals.validity;
58
+ }
59
+ get validationMessage() {
60
+ return this.internals.validationMessage;
61
+ }
62
+ get willValidate() {
63
+ return this.internals.willValidate;
64
+ }
65
+ /** Current date as a `Date` at UTC midnight, or `null` when empty. */
66
+ get valueAsDate() {
67
+ return this.input?.valueAsDate ?? null;
68
+ }
69
+ connectedCallback() {
70
+ super.connectedCallback();
71
+ if (!this.defaultCaptured) {
72
+ this.defaultValue = this.getAttribute("value") ?? "";
73
+ this.defaultCaptured = true;
74
+ }
75
+ }
76
+ focus(options) {
77
+ this.input?.focus(options);
78
+ }
79
+ /** Opens the browser date picker when supported. Must be called from a user gesture. */
80
+ showPicker() {
81
+ this.input?.showPicker();
82
+ }
83
+ checkValidity() {
84
+ return this.internals.checkValidity();
85
+ }
86
+ reportValidity() {
87
+ return this.internals.reportValidity();
88
+ }
89
+ setCustomValidity(message) {
90
+ this.customValidityMessage = message;
91
+ this.input?.setCustomValidity(message);
92
+ this.syncFormState();
93
+ }
94
+ formResetCallback() {
95
+ this.value = this.defaultValue;
96
+ this.error = false;
97
+ }
98
+ formDisabledCallback(disabled) {
99
+ this.disabledByForm = disabled && !this.hasAttribute("disabled");
100
+ }
101
+ formStateRestoreCallback(state) {
102
+ if (typeof state === "string") this.value = state;
103
+ }
104
+ get effectiveDisabled() {
105
+ return this.disabled || this.disabledByForm;
106
+ }
107
+ handleInput(event) {
108
+ this.value = event.target.value;
109
+ redispatchEvent(this, event);
110
+ }
111
+ handleChange(event) {
112
+ this.value = event.target.value;
113
+ redispatchEvent(this, event);
114
+ }
115
+ handleFocusIn(event) {
116
+ this.focused = true;
117
+ redispatchEvent(this, event);
118
+ }
119
+ handleFocusOut(event) {
120
+ this.focused = false;
121
+ redispatchEvent(this, event);
122
+ }
123
+ handleSlotChange(event) {
124
+ this.hasSupportingSlot = event.target.assignedNodes({ flatten: true }).length > 0;
125
+ }
126
+ openPicker(event) {
127
+ event.stopPropagation();
128
+ if (!this.effectiveDisabled && !this.readOnly) this.showPicker();
129
+ }
130
+ forwardFocus(event) {
131
+ if (event.target !== this.input) this.input?.focus();
132
+ }
133
+ updated(changed) {
134
+ if (changed.has("value") && this.input && this.input.value !== this.value) {
135
+ this.value = this.input.value;
136
+ return;
137
+ }
138
+ this.syncFormState();
139
+ }
140
+ syncFormState() {
141
+ if (!this.input) return;
142
+ if (this.effectiveDisabled) {
143
+ this.internals.setFormValue(null);
144
+ this.internals.setValidity({});
145
+ return;
146
+ }
147
+ this.internals.setFormValue(this.value, this.value);
148
+ this.input.setCustomValidity(this.customValidityMessage);
149
+ this.internals.setValidity(this.input.validity, this.input.validationMessage, this.input);
150
+ }
151
+ render() {
152
+ const showError = this.error && !this.effectiveDisabled;
153
+ const message = showError ? this.errorText : this.help;
154
+ const showSupporting = !!message || this.hasSupportingSlot;
155
+ return html`
156
+ <div
157
+ class="field ${classMap({
158
+ focused: this.focused,
159
+ error: showError,
160
+ "read-only": this.readOnly,
161
+ disabled: this.effectiveDisabled
162
+ })}"
163
+ @click=${this.forwardFocus}
164
+ >
165
+ <input
166
+ type="date"
167
+ aria-label=${ifDefined(this.ariaLabel || void 0)}
168
+ aria-invalid=${showError ? "true" : nothing}
169
+ aria-describedby=${showSupporting ? "supporting-text" : nothing}
170
+ name=${ifDefined(this.name || void 0)}
171
+ autocomplete=${ifDefined(this.autocomplete || void 0)}
172
+ min=${ifDefined(this.min || void 0)}
173
+ max=${ifDefined(this.max || void 0)}
174
+ step=${this.step}
175
+ ?required=${this.required}
176
+ ?readonly=${this.readOnly}
177
+ ?disabled=${this.effectiveDisabled}
178
+ .value=${live(this.value)}
179
+ @input=${this.handleInput}
180
+ @change=${this.handleChange}
181
+ @focusin=${this.handleFocusIn}
182
+ @focusout=${this.handleFocusOut}
183
+ />
184
+ <button
185
+ class="calendar-button"
186
+ type="button"
187
+ tabindex="-1"
188
+ aria-label="Open calendar"
189
+ ?disabled=${this.effectiveDisabled || this.readOnly}
190
+ @click=${this.openPicker}
191
+ >
192
+ <slot name="calendar-icon">
193
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
194
+ <rect x="3" y="5" width="18" height="16" rx="2"></rect>
195
+ <path d="M16 3v4M8 3v4M3 10h18"></path>
196
+ </svg>
197
+ </slot>
198
+ </button>
199
+ </div>
200
+ ${showSupporting ? html`<div id="supporting-text" class="supporting-text ${classMap({ error: showError })}">
201
+ <slot name="supporting-text" @slotchange=${this.handleSlotChange}>${message}</slot>
202
+ </div>` : html`<slot name="supporting-text" hidden @slotchange=${this.handleSlotChange}></slot>`}
203
+ `;
204
+ }
205
+ };
206
+ __decorate([state()], DateInput.prototype, "disabledByForm", void 0);
207
+ __decorate([state()], DateInput.prototype, "focused", void 0);
208
+ __decorate([state()], DateInput.prototype, "hasSupportingSlot", void 0);
209
+ __decorate([query("input")], DateInput.prototype, "input", void 0);
210
+ __decorate([property({
211
+ type: String,
212
+ reflect: true
213
+ })], DateInput.prototype, "value", void 0);
214
+ __decorate([property({ type: String })], DateInput.prototype, "min", void 0);
215
+ __decorate([property({ type: String })], DateInput.prototype, "max", void 0);
216
+ __decorate([property({ type: Number })], DateInput.prototype, "step", void 0);
217
+ __decorate([property({ type: String })], DateInput.prototype, "name", void 0);
218
+ __decorate([property({ type: String })], DateInput.prototype, "autocomplete", void 0);
219
+ __decorate([property({
220
+ type: Boolean,
221
+ reflect: true
222
+ })], DateInput.prototype, "required", void 0);
223
+ __decorate([property({
224
+ type: Boolean,
225
+ reflect: true
226
+ })], DateInput.prototype, "readOnly", void 0);
227
+ __decorate([property({
228
+ type: Boolean,
229
+ reflect: true
230
+ })], DateInput.prototype, "disabled", void 0);
231
+ __decorate([property({
232
+ type: Boolean,
233
+ reflect: true
234
+ })], DateInput.prototype, "error", void 0);
235
+ __decorate([property({ type: String })], DateInput.prototype, "help", void 0);
236
+ __decorate([property({ attribute: "error-text" })], DateInput.prototype, "errorText", void 0);
237
+ __decorate([property({ attribute: "aria-label" })], DateInput.prototype, "ariaLabel", void 0);
238
+ DateInput = __decorate([customElement("c2-date-input")], DateInput);
239
+ //#endregion
240
+ export { DateInput };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@c2n/date-input",
3
+ "version": "0.0.8",
4
+ "type": "module",
5
+ "main": "dist/date-input.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/src/date-input.d.ts",
9
+ "default": "./dist/date-input.js"
10
+ },
11
+ "./react": {
12
+ "types": "./react.d.ts",
13
+ "default": "./react.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./vue.d.ts",
17
+ "default": "./vue.js"
18
+ },
19
+ "./custom-elements.json": "./custom-elements.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "react.d.ts",
25
+ "react.js",
26
+ "vue.d.ts",
27
+ "vue.js"
28
+ ],
29
+ "keywords": [
30
+ "date-input",
31
+ "web component",
32
+ "lit"
33
+ ],
34
+ "license": "MIT",
35
+ "author": "code2nguyen@gmail.com",
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/code2nguyen/web-components.git"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "wireit",
47
+ "build:only": "vite build",
48
+ "type-check": "wireit"
49
+ },
50
+ "wireit": {
51
+ "type-check": {
52
+ "dependencies": [
53
+ "../../core:build"
54
+ ],
55
+ "command": "tsc -p tsconfig.lib.json --composite false"
56
+ },
57
+ "build": {
58
+ "dependencies": [
59
+ "type-check"
60
+ ],
61
+ "command": "vite build"
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "@c2n/core": "0.0.8",
66
+ "lit": "3.3.3"
67
+ },
68
+ "devDependencies": {
69
+ "@c2n/config": "*"
70
+ },
71
+ "customElements": "custom-elements.json",
72
+ "gitHead": "be59cbccee1d33ca248e39f69b05c0b595ec6c6d"
73
+ }
package/react.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // JSX types for the custom elements of @c2n/date-input. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/date-input/react'
6
+ //
7
+ // Register the elements at module scope before React renders, or React writes an object prop as an
8
+ // attribute and it stringifies.
9
+
10
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react'
11
+ import type { DateInput } from '@c2n/date-input'
12
+
13
+ /** Standard React host-element attributes plus the element's own public properties. */
14
+ type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
15
+
16
+ declare module 'react' {
17
+ namespace JSX {
18
+ interface IntrinsicElements {
19
+ 'c2-date-input': C2Props<DateInput>
20
+ }
21
+ }
22
+ }
23
+
24
+ export {}
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}
@@ -0,0 +1,123 @@
1
+ import { LitElement, type PropertyValues } from 'lit';
2
+ import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
3
+ /** Events fired by {@link DateInput}, keyed for `addEventListener`. */
4
+ export interface DateInputEventMap {
5
+ input: InputEvent;
6
+ change: Event;
7
+ }
8
+ export interface DateInput {
9
+ addEventListener: TypedAddEventListener<DateInput, DateInputEventMap>;
10
+ removeEventListener: TypedRemoveEventListener<DateInput, DateInputEventMap>;
11
+ }
12
+ /**
13
+ * A form-associated single-date field backed by a native `<input type="date">`. Values, `min` and `max` use local
14
+ * calendar ISO strings (`YYYY-MM-DD`). The native picker and keyboard editing remain available while the component
15
+ * adds a consistent field, calendar affordance, helper text, error state and theming surface.
16
+ *
17
+ * @tag c2-date-input
18
+ *
19
+ * @slot calendar-icon - Replaces the calendar icon at the end of the field.
20
+ * @slot supporting-text - Rich helper content below the field. `help` and `error-text` are plain-text shortcuts.
21
+ *
22
+ * @event {InputEvent} input - Re-dispatched from the inner date input whenever the value changes.
23
+ * @event {Event} change - Re-dispatched from the inner date input when the value is committed.
24
+ *
25
+ * @cssproperty {pixel} [--c2-date-input--min-height=36px]
26
+ * @cssproperty {pixel} [--c2-date-input--gap=8px]
27
+ * @cssproperty {padding} [--c2-date-input--padding=6px 8px 6px 12px]
28
+ * @cssproperty {border} [--c2-date-input--border=1px solid #bcbcc6]
29
+ * @cssproperty {border-radius} [--c2-date-input--border-radius=6px]
30
+ * @cssproperty {color} [--c2-date-input--color=#18181b]
31
+ * @cssproperty {color} [--c2-date-input--background=#ffffff]
32
+ * @cssproperty {font-size} [--c2-date-input--font-size=14px]
33
+ * @cssproperty {font-family} [--c2-date-input--font-family=inherit]
34
+ * @cssproperty {pixel} [--c2-date-input--line-height=20px]
35
+ * @cssproperty {border} [--c2-date-input__hover--border=1px solid #a1a1aa]
36
+ * @cssproperty {border} [--c2-date-input__focus--border=1px solid #0265dc]
37
+ * @cssproperty {outline} [--c2-date-input__focus--outline=2px solid rgba(2, 101, 220, 0.4)]
38
+ * @cssproperty {pixel} [--c2-date-input__focus--outline-offset=0px]
39
+ * @cssproperty {border} [--c2-date-input__error--border=1px solid #dc2626]
40
+ * @cssproperty {outline} [--c2-date-input__error__focus--outline=2px solid rgba(220, 38, 38, 0.25)]
41
+ * @cssproperty {color} [--c2-date-input__read-only--background=#fafafa]
42
+ * @cssproperty {opacity} [--c2-date-input__disabled--opacity=0.38]
43
+ * @cssproperty {pixel} [--c2-date-input__calendar-icon--size=18px]
44
+ * @cssproperty {color} [--c2-date-input__calendar-icon--color=#71717a]
45
+ * @cssproperty {color} [--c2-date-input__calendar-icon__hover--color=#18181b]
46
+ * @cssproperty {pixel} [--c2-date-input__supporting-text--gap=4px]
47
+ * @cssproperty {font-size} [--c2-date-input__supporting-text--font-size=12px]
48
+ * @cssproperty {pixel} [--c2-date-input__supporting-text--line-height=16px]
49
+ * @cssproperty {color} [--c2-date-input__supporting-text--color=#71717a]
50
+ * @cssproperty {color} [--c2-date-input__supporting-text__error--color=#dc2626]
51
+ */
52
+ export declare class DateInput extends LitElement {
53
+ static formAssociated: boolean;
54
+ static styles: import("lit").CSSResult;
55
+ private readonly internals;
56
+ private customValidityMessage;
57
+ private defaultValue;
58
+ private defaultCaptured;
59
+ private disabledByForm;
60
+ private focused;
61
+ private hasSupportingSlot;
62
+ private readonly input?;
63
+ /** Current date as a local-calendar `YYYY-MM-DD` string, or an empty string. */
64
+ value: string;
65
+ /** Earliest selectable date as `YYYY-MM-DD`. */
66
+ min: string;
67
+ /** Latest selectable date as `YYYY-MM-DD`. */
68
+ max: string;
69
+ /** Number of days between valid dates. */
70
+ step: number;
71
+ /** Form field name. */
72
+ name: string;
73
+ /** Browser autocomplete hint, for example `bday`. */
74
+ autocomplete: string;
75
+ /** Requires a date before the form can be submitted. */
76
+ required: boolean;
77
+ /** Prevents editing while keeping the value in form submission. */
78
+ readOnly: boolean;
79
+ /** Prevents interaction and excludes the value from form submission. */
80
+ disabled: boolean;
81
+ /** Applies the visual error state and sets `aria-invalid`. */
82
+ error: boolean;
83
+ /** Helper text shown below the field. */
84
+ help: string;
85
+ /** Message shown below the field while `error` is set. */
86
+ errorText: string;
87
+ /** Accessible name forwarded to the native date input. */
88
+ ariaLabel: string | null;
89
+ get form(): HTMLFormElement | null;
90
+ get labels(): NodeList;
91
+ get validity(): ValidityState;
92
+ get validationMessage(): string;
93
+ get willValidate(): boolean;
94
+ /** Current date as a `Date` at UTC midnight, or `null` when empty. */
95
+ get valueAsDate(): Date | null;
96
+ connectedCallback(): void;
97
+ focus(options?: FocusOptions): void;
98
+ /** Opens the browser date picker when supported. Must be called from a user gesture. */
99
+ showPicker(): void;
100
+ checkValidity(): boolean;
101
+ reportValidity(): boolean;
102
+ setCustomValidity(message: string): void;
103
+ formResetCallback(): void;
104
+ formDisabledCallback(disabled: boolean): void;
105
+ formStateRestoreCallback(state: string | File | FormData | null): void;
106
+ private get effectiveDisabled();
107
+ private handleInput;
108
+ private handleChange;
109
+ private handleFocusIn;
110
+ private handleFocusOut;
111
+ private handleSlotChange;
112
+ private openPicker;
113
+ private forwardFocus;
114
+ protected updated(changed: PropertyValues<this>): void;
115
+ private syncFormState;
116
+ render(): import("lit-html").TemplateResult<1>;
117
+ }
118
+ declare global {
119
+ interface HTMLElementTagNameMap {
120
+ 'c2-date-input': DateInput;
121
+ }
122
+ }
123
+ //# sourceMappingURL=date-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-input.d.ts","sourceRoot":"","sources":["../../src/date-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAG/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAOhG,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,qBAAqB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;IACrE,mBAAmB,EAAE,wBAAwB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;CAC5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,SAAU,SAAQ,UAAU;IACvC,MAAM,CAAC,cAAc,UAAO;IAC5B,OAAgB,MAAM,0BAAoB;IAE1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,iBAAiB,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAkB;IAEzD,gFAAgF;IACrC,KAAK,SAAK;IACrD,gDAAgD;IACpB,GAAG,SAAK;IACpC,8CAA8C;IAClB,GAAG,SAAK;IACpC,0CAA0C;IACd,IAAI,SAAI;IACpC,uBAAuB;IACK,IAAI,SAAK;IACrC,qDAAqD;IACzB,YAAY,SAAK;IAC7C,wDAAwD;IACZ,QAAQ,UAAQ;IAC5D,mEAAmE;IACvB,QAAQ,UAAQ;IAC5D,wEAAwE;IAC5B,QAAQ,UAAQ;IAC5D,8DAA8D;IAClB,KAAK,UAAQ;IACzD,yCAAyC;IACb,IAAI,SAAK;IACrC,0DAA0D;IACnB,SAAS,SAAK;IACrD,0DAA0D;IACV,SAAS,EAAE,MAAM,GAAG,IAAI,CAAO;IAE/E,IAAI,IAAI,2BAEP;IACD,IAAI,MAAM,aAET;IACD,IAAI,QAAQ,kBAEX;IACD,IAAI,iBAAiB,WAEpB;IACD,IAAI,YAAY,YAEf;IACD,sEAAsE;IACtE,IAAI,WAAW,gBAEd;IAEQ,iBAAiB;IAQjB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAIrC,wFAAwF;IACxF,UAAU;IAIV,aAAa;IAGb,cAAc;IAGd,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAMjC,iBAAiB;IAIjB,oBAAoB,CAAC,QAAQ,EAAE,OAAO;IAGtC,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI;IAI/D,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IAGxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;cAID,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAQxD,OAAO,CAAC,aAAa;IAYZ,MAAM;CAqDhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,SAAS,CAAA;KAC3B;CACF"}
package/vue.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // Vue template types for the custom elements of @c2n/date-input. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/date-input/vue'
6
+ //
7
+ // Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
8
+ // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
+
10
+ import type { DefineComponent, HTMLAttributes } from 'vue'
11
+ import type { DateInput, DateInputEventMap } from '@c2n/date-input'
12
+
13
+ /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
+ type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
15
+
16
+ declare module 'vue' {
17
+ interface GlobalComponents {
18
+ 'c2-date-input': DefineComponent<
19
+ C2Props<DateInput> & {
20
+ 'error-text'?: unknown
21
+ 'aria-label'?: unknown
22
+ onInput?: (event: DateInputEventMap['input']) => void
23
+ onChange?: (event: DateInputEventMap['change']) => void
24
+ }
25
+ >
26
+ }
27
+ }
28
+
29
+ declare module '@vue/runtime-dom' {
30
+ interface HTMLAttributes {
31
+ /** Vue's own definition omits it, and slotting a plain element into a component needs it. */
32
+ slot?: string
33
+ }
34
+ }
35
+
36
+ export {}
package/vue.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}