|
1 | 1 | import type {} from 'element-internals-polyfill'; |
2 | | -import { BaseFieldProps } from 'web-utility'; |
| 2 | +import { Constructor } from 'web-utility/source/data'; |
| 3 | +import { BaseFieldProps, CustomFormElement } from 'web-utility/source/DOM-type'; |
3 | 4 |
|
4 | 5 | import { WebCellProps } from './utility'; |
5 | | -import { mixin, WebCellClass, WebCellComponent } from './WebCell'; |
| 6 | +import { mixin, WebCellComponent } from './WebCell'; |
6 | 7 | import { watch, attribute } from './decorator'; |
7 | 8 |
|
8 | 9 | export interface WebFieldProps extends BaseFieldProps, WebCellProps {} |
9 | 10 |
|
10 | | -export interface WebFieldComponent< |
| 11 | +export type WebFieldComponent< |
11 | 12 | P extends WebFieldProps = WebFieldProps, |
12 | 13 | S = {} |
13 | | -> extends WebCellComponent<P, S> { |
14 | | - /** |
15 | | - * Called when the browser associates the element with a form element, |
16 | | - * or disassociates the element from a form element. |
17 | | - */ |
18 | | - formAssociatedCallback?(form: HTMLFormElement): void; |
19 | | - /** |
20 | | - * Called after the disabled state of the element changes, |
21 | | - * either because the disabled attribute of this element was added or removed; |
22 | | - * or because the disabled state changed on a `<fieldset>` that's an ancestor of this element. |
23 | | - * |
24 | | - * @param disabled This parameter represents the new disabled state of the element. |
25 | | - */ |
26 | | - formDisabledCallback?(disabled: boolean): void; |
27 | | - /** |
28 | | - * Called after the form is reset. |
29 | | - * The element should reset itself to some kind of default state. |
30 | | - */ |
31 | | - formResetCallback?(): void; |
32 | | - /** |
33 | | - * Called in one of two circumstances: |
34 | | - * - When the browser restores the state of the element (for example, after a navigation, or when the browser restarts). The `mode` argument is `"restore"` in this case. |
35 | | - * - When the browser's input-assist features such as form autofilling sets a value. The `mode` argument is `"autocomplete"` in this case. |
36 | | - * |
37 | | - * @param state The type of this argument depends on how the `this.internals.setFormValue()` method was called. |
38 | | - * @param mode |
39 | | - */ |
40 | | - formStateRestoreCallback?( |
41 | | - state: string | File | FormData, |
42 | | - mode: 'restore' | 'autocomplete' |
43 | | - ): void; |
44 | | -} |
| 14 | +> = CustomFormElement & WebCellComponent<P, S>; |
45 | 15 |
|
46 | | -export interface WebFieldClass<P extends WebFieldProps = WebFieldProps, S = {}> |
47 | | - extends WebCellClass<P, S> { |
48 | | - new (options?: ShadowRootInit): WebFieldComponent<P, S>; |
49 | | -} |
| 16 | +export type WebFieldClass< |
| 17 | + P extends WebFieldProps = WebFieldProps, |
| 18 | + S = {} |
| 19 | +> = Constructor<WebFieldComponent<P, S>>; |
50 | 20 |
|
51 | 21 | export function mixinForm<P extends WebFieldProps = WebFieldProps, S = {}>( |
52 | | - superClass = HTMLElement |
| 22 | + superClass: Constructor<HTMLElement> = HTMLElement |
53 | 23 | ): WebFieldClass<P, S> { |
54 | 24 | class WebField |
55 | 25 | extends mixin<P, S>(superClass) |
|
0 commit comments