@gzmjs/form 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.
@@ -0,0 +1,18 @@
1
+ export declare const inputAutoComplete: readonly ["", "on", "off"];
2
+ export type InputAutoComplete = typeof inputAutoComplete[number];
3
+ export declare function getInputIdForLabel($ipt: HTMLElement): string;
4
+ /**
5
+ * 主要对绑定多个字段的情况进行处理:
6
+ * 假设绑定了 2 个字段,且没有选中项,这时 dataValue = [null, null],这时应该返回 ''。
7
+ * 但是 toString() 之后是 ',',所以下面用了一个正则表达式判断 ret 中是否全是逗号。
8
+ *
9
+ * 测试:042-check-list-test.html 中最后一个 check-list 可以测试这种情况。
10
+ * @returns 将作为 this.$.ipt.value 的值。
11
+ */
12
+ export declare function getHiddenValueFromDataValue(dv: unknown): string;
13
+ export declare function removeZWC(s: string): string;
14
+ export declare function toDateStr(d: Date): string;
15
+ export declare function toMonthStr(d: Date): string;
16
+ export declare function toWeekStr(d: Date): string;
17
+ export declare function toTimeStr(d: Date): string;
18
+ export declare const iptStyle: CSSStyleSheet;
@@ -0,0 +1,122 @@
1
+ import { ViewModel, ViewElement, ObjValue, ObjMember, ModelEventSubscriber, ListSource, handleModelEvent, ModelEvent } from '@gzmjs/mvvm';
2
+ export declare class InputDataSource<T extends object> {
3
+ constructor(o: T, vm: ObjMember | string | string[]);
4
+ readonly data: T;
5
+ readonly valueMember: ObjMember;
6
+ getValue(): ObjValue;
7
+ setValue(v: unknown): void;
8
+ onDataEvent(listener: ModelEventSubscriber): boolean;
9
+ offDataEvent(listener: ModelEventSubscriber): boolean;
10
+ }
11
+ export declare const textAlign: readonly ["start", "end", "center"];
12
+ export type LabelTextAlign = typeof textAlign[number];
13
+ export interface InputOptions<V, E extends InputBase<V, InputOptions<V, E>>> extends ViewModel<E> {
14
+ name: string;
15
+ dataSource?: InputDataSource<object>;
16
+ listSource?: ListSource<object>;
17
+ /**
18
+ * 验证属性,required 表示必须有值,所有组件(除了 input-check)都支持。
19
+ */
20
+ required?: boolean;
21
+ /**
22
+ * 无效值的组件,默认显示红色的框,但并不显示具体的错误信息。
23
+ * 如果设置为 true,则会在组件下方显示具体的错误信息。
24
+ */
25
+ showValidityMessage?: boolean;
26
+ /**
27
+ * 虽然只是 input-label 使用的属性,但是在 form 中每一个 input 都可以和 label 互相转换。
28
+ * 所以作为基础属性。
29
+ */
30
+ textAlign?: LabelTextAlign;
31
+ /**
32
+ * 涉及到 $ipt 的值改变或者验证条件改变时,都会调用此函数。
33
+ * 一般而言只有需要调用 setCustomValidity() 的组件才需要实现此函数。
34
+ * @param $ipt
35
+ * @returns
36
+ */
37
+ checkValidity?: ($ipt: HTMLInputElement | HTMLTextAreaElement) => void | Promise<void>;
38
+ /**
39
+ * 组件 dataValue 改变时调用此函数。
40
+ * @param newValue
41
+ * @param oldValue
42
+ * @returns
43
+ */
44
+ dataValueChanged?: (newValue: unknown, oldValue: unknown) => void;
45
+ }
46
+ export declare const inputCopyAttributes: {
47
+ name: string;
48
+ required: string;
49
+ };
50
+ export declare abstract class InputBase<V, T extends InputOptions<V, InputBase<V, T>>> extends ViewElement<T> {
51
+ #private;
52
+ constructor();
53
+ readonly ei: ElementInternals;
54
+ readonly $ipt: HTMLInputElement | HTMLTextAreaElement;
55
+ protected abstract _createInput(): HTMLInputElement | HTMLTextAreaElement;
56
+ protected abstract _showValue(): void;
57
+ get dataValue(): V | undefined;
58
+ set dataValue(val: V | undefined);
59
+ /**
60
+ * 在处理与 listSource 相关的操作时需要用到!
61
+ */
62
+ protected get dsValue(): ObjValue;
63
+ /**
64
+ * 对于定义了 dataType 属性的组件,需要将 #dv 转换为 dataType 指定的类型
65
+ */
66
+ protected _checkValueType(dv: V | undefined): V | undefined;
67
+ protected _changeValue2Type(v: V | undefined, t: unknown): V | undefined;
68
+ protected _writeDataSource(): void;
69
+ /**
70
+ * form 的值与 #dv 同步
71
+ * @param dv
72
+ * @returns
73
+ */
74
+ protected _setFormValue(): void;
75
+ /**
76
+ * $ipt 的值与 #dv 同步。这主要针对 $ipt.hidden = true 的组件,如 CheckList, SearchList。
77
+ * 这些组件的 $ipt 只是用来满足表单验证需求的,并不直接显示数据。而且也只能满足 required 验证需求。
78
+ * 所以这里设置 $ipt 的值不必太复杂。
79
+ */
80
+ protected _setIptValue($ipt?: HTMLInputElement | HTMLTextAreaElement): void;
81
+ get dataSource(): InputDataSource<object> | undefined;
82
+ set dataSource(ds: InputDataSource<object> | undefined);
83
+ _getValueFromDataSource(): void;
84
+ [handleModelEvent](source: unknown, evt: ModelEvent): boolean;
85
+ get listSource(): ListSource<object> | undefined;
86
+ set listSource(ls: ListSource<object> | undefined);
87
+ protected _setActiveItem(...activeItems: object[]): void;
88
+ /**
89
+ * 对于有 list 属性的组件,需要生成一个 <datalist>
90
+ * <datalist> 的弹出由浏览器自己控制,所以需要有一个 bind 的过程。
91
+ * 对于 input-combo,list 弹出由代码控制,所以就无需重写 _bindList()。
92
+ */
93
+ protected _bindList($ipt?: HTMLInputElement | HTMLTextAreaElement): void;
94
+ protected _createListItems($dl: Element, ls: string[]): void;
95
+ focus(): void;
96
+ /**
97
+ * 因为这个函数完全是基于 $ipt 的 validity 来设置 ei 的 validity,
98
+ * 所以当 $ipt 的值变化时,必须调用此函数以确保 ei 的 validity 正确。
99
+ * 1 - _showValue() 中调用此函数,以确保 ei 的 validity 正确。
100
+ * 2 - 验证属性变化时(如 required, max, min 等),也需要调用此函数。
101
+ * 3 - 在 oninput onchange 事件中也需要调用此函数。
102
+ */
103
+ protected _setValidity($ipt?: HTMLInputElement | HTMLTextAreaElement): Promise<void>;
104
+ protected _required_set(): void;
105
+ protected _pattern_set(): void;
106
+ protected _min_set(): void;
107
+ protected _max_set(): void;
108
+ protected _minLength_set(): void;
109
+ protected _maxLength_set(): void;
110
+ protected _step_set(): void;
111
+ protected _type_set(): void;
112
+ protected _show_validity_message(): void;
113
+ setCustomError(error: string): void;
114
+ /**
115
+ * 通过 setCustomError() 设置的错误,只能通过此函数才能去掉!
116
+ * @returns
117
+ */
118
+ clearCustomError(): void;
119
+ accessor name: string | undefined;
120
+ accessor required: boolean;
121
+ accessor showValidityMessage: boolean;
122
+ }
@@ -0,0 +1,38 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions, LabelTextAlign } from './01-input';
3
+ export declare const tagName = "GZM-INPUT-LABEL";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [tagName]: InputLabel;
7
+ }
8
+ }
9
+ export interface InputLabelOptions extends InputOptions<unknown, InputLabel> {
10
+ tagName?: typeof tagName;
11
+ trueText?: string;
12
+ falseText?: string;
13
+ /**
14
+ * 当 listSource.multiple = true 时,显示选中多项用此符号隔开。
15
+ */
16
+ multipleDelimiter?: string;
17
+ }
18
+ declare const mutableAttributes: readonly ["name", "text-align", "true-text", "false-text"];
19
+ declare const copyAttributes: {
20
+ name: string;
21
+ };
22
+ export declare class InputLabel extends InputBase<unknown, InputLabelOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
23
+ static formAssociated: boolean;
24
+ /**
25
+ * 不开启 shadowRoot,因为其本质上是在 innerHTML 中显示内容
26
+ * 本来打算在这里放一个 <output> 元素,但阅读了文档后又觉得没有必要:https://devdocs.io/html/element/output。
27
+ */
28
+ _createInput(): HTMLInputElement;
29
+ _showValue(): void;
30
+ accessor textAlign: LabelTextAlign;
31
+ _text_align_set(nv: string | null): void;
32
+ accessor trueText: string | undefined;
33
+ _true_text_set(): void;
34
+ accessor falseText: string | undefined;
35
+ _false_text_set(): void;
36
+ accessor multipleDelimiter: string;
37
+ }
38
+ export {};
@@ -0,0 +1,57 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ import { InputAutoComplete } from './00-common';
4
+ export declare const tagName = "GZM-INPUT-TEXT";
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [tagName]: TextInput;
8
+ }
9
+ }
10
+ declare const textType: readonly ["text", "password", "email", "tel", "url", "search"];
11
+ type InputTextType = typeof textType[number];
12
+ export interface InputTextOptions extends InputOptions<string, TextInput> {
13
+ tagName?: typeof tagName;
14
+ type?: InputTextType;
15
+ autocomplete?: InputAutoComplete;
16
+ maxlength?: string;
17
+ minlength?: string;
18
+ /**
19
+ * email,url 有默认的 pattern,无需代码处理。
20
+ */
21
+ pattern?: string;
22
+ placeholder?: string;
23
+ /**
24
+ * HTMLElement 本身有此属性,所以只需要定义 mutableAttributes 和 copyAttributes,保证能够复制到 $ipt。
25
+ */
26
+ spellcheck?: boolean;
27
+ list?: string[];
28
+ }
29
+ declare const mutableAttributes: readonly ["name", "spellcheck", "type", "autocomplete", "maxlength", "minlength", "pattern", "placeholder", "required", "list"];
30
+ declare const copyAttributes: {
31
+ type: string;
32
+ autocomplete: string;
33
+ maxlength: string;
34
+ minlength: string;
35
+ pattern: string;
36
+ placeholder: string;
37
+ spellcheck: string;
38
+ } & {
39
+ name: string;
40
+ required: string;
41
+ };
42
+ export declare class TextInput extends InputBase<string, InputTextOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
43
+ static formAssociated: boolean;
44
+ _createInput(): HTMLInputElement;
45
+ readonly shadowRoot: ShadowRoot;
46
+ $ipt: HTMLInputElement;
47
+ protected _showValue($ipt?: HTMLInputElement): void;
48
+ accessor type: InputTextType;
49
+ accessor autoComplete: InputAutoComplete;
50
+ accessor maxlength: string | undefined;
51
+ accessor minlength: string | undefined;
52
+ accessor pattern: string | undefined;
53
+ accessor placeholder: string | undefined;
54
+ accessor list: string[] | undefined;
55
+ _list_set(): void;
56
+ }
57
+ export {};
@@ -0,0 +1,65 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ import { InputAutoComplete } from './00-common';
4
+ export declare const tagName = "GZM-INPUT-CAL";
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [tagName]: CalInput;
8
+ }
9
+ }
10
+ declare const calType: readonly ["date", "time", "datetime-local", "month", "week"];
11
+ type InputCalType = typeof calType[number];
12
+ /**
13
+ * 根据 /try/html/input-date.html 的测试,并不是每一种 calType 支持 valueAsDate 和 valueAsNumber。
14
+ * 而且不同浏览器的情况还不一样!不过对于 value 的支持是肯定的,所以一定要以 value 即字符串值作为基础。
15
+ */
16
+ declare const calDataType: readonly ["string", "date", "number"];
17
+ type InputCalDataType = typeof calDataType[number];
18
+ type CalDataType = string | number | Date;
19
+ export interface InputCalOptions extends InputOptions<CalDataType, CalInput> {
20
+ tagName?: typeof tagName;
21
+ type?: InputCalType;
22
+ dataType?: InputCalDataType;
23
+ autocomplete?: InputAutoComplete;
24
+ max?: string;
25
+ min?: string;
26
+ step?: string;
27
+ list?: string[];
28
+ }
29
+ declare const mutableAttributes: readonly ["name", "type", "autocomplete", "max", "min", "step", "required", "list"];
30
+ declare const copyAttributes: {
31
+ type: string;
32
+ autocomplete: string;
33
+ max: string;
34
+ min: string;
35
+ step: string;
36
+ } & {
37
+ name: string;
38
+ required: string;
39
+ };
40
+ export declare class CalInput extends InputBase<CalDataType, InputCalOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
41
+ #private;
42
+ static formAssociated: boolean;
43
+ _createInput(): HTMLInputElement;
44
+ readonly shadowRoot: ShadowRoot;
45
+ $ipt: HTMLInputElement;
46
+ /**
47
+ * number -> Date -> string
48
+ * 为了提高可用性,这里没有判断 dataType,而是根据实际的数据类型来处理。
49
+ */
50
+ protected _showValue($ipt?: HTMLInputElement): void;
51
+ /**
52
+ * 对于这个 input 而言,值就是一个字符串。当 t === string,无需进行任何转换。
53
+ * 所以只需要处理 date 或者 number, string -> Date -> number。
54
+ */
55
+ _changeValue2Type(v: unknown, t: InputCalDataType): CalDataType | undefined;
56
+ accessor type: InputCalType;
57
+ accessor dataType: InputCalDataType;
58
+ accessor autocomplete: InputAutoComplete;
59
+ accessor max: string | undefined;
60
+ accessor min: string | undefined;
61
+ accessor Step: string | undefined;
62
+ accessor list: string[] | undefined;
63
+ _list_set(): void;
64
+ }
65
+ export {};
@@ -0,0 +1,33 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ export declare const tagName = "GZM-INPUT-CHECK";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [tagName]: CheckInput;
7
+ }
8
+ }
9
+ declare const checkDataType: readonly ["boolean", "string", "number"];
10
+ type InputCheckDataType = typeof checkDataType[number];
11
+ type CheckDataType = boolean | string | number;
12
+ export interface InputCheckOptions extends InputOptions<CheckDataType, CheckInput> {
13
+ tagName?: typeof tagName;
14
+ dataType?: InputCheckDataType;
15
+ trueText?: string;
16
+ falseText?: string;
17
+ }
18
+ declare const mutableAttributes: readonly ["name"];
19
+ declare const copyAttributes: {
20
+ name: string;
21
+ };
22
+ export declare class CheckInput extends InputBase<CheckDataType, InputCheckOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
23
+ static formAssociated: boolean;
24
+ _createInput(): HTMLInputElement;
25
+ readonly shadowRoot: ShadowRoot;
26
+ $ipt: HTMLInputElement;
27
+ protected _showValue($ipt?: HTMLInputElement): void;
28
+ _changeValue2Type(v: unknown, t: InputCheckDataType): CheckDataType | undefined;
29
+ accessor dataType: InputCheckDataType;
30
+ accessor trueText: string | undefined;
31
+ accessor falseText: string | undefined;
32
+ }
33
+ export {};
@@ -0,0 +1,50 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ import { InputAutoComplete } from './00-common';
4
+ export declare const tagName = "GZM-INPUT-NUM";
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [tagName]: NumInput;
8
+ }
9
+ }
10
+ declare const numDataType: readonly ["number", "int", "currency"];
11
+ type InputNumDataType = typeof numDataType[number];
12
+ export interface InputNumOptions extends InputOptions<number, NumInput> {
13
+ tagName?: typeof tagName;
14
+ dataType?: InputNumDataType;
15
+ autocomplete?: InputAutoComplete;
16
+ max?: string;
17
+ min?: string;
18
+ step?: string;
19
+ placeholder?: string;
20
+ list?: string[];
21
+ }
22
+ declare const mutableAttributes: readonly ["name", "data-type", "autocomplete", "max", "min", "step", "placeholder", "list", "required"];
23
+ declare const copyAttributes: {
24
+ autocomplete: string;
25
+ max: string;
26
+ min: string;
27
+ step: string;
28
+ placeholder: string;
29
+ } & {
30
+ name: string;
31
+ required: string;
32
+ };
33
+ export declare class NumInput extends InputBase<number, InputNumOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
34
+ static formAssociated: boolean;
35
+ _createInput(): HTMLInputElement;
36
+ readonly shadowRoot: ShadowRoot;
37
+ $ipt: HTMLInputElement;
38
+ protected _showValue($ipt?: HTMLInputElement): void;
39
+ _changeValue2Type(v: unknown, t: InputNumDataType): number | undefined;
40
+ accessor dataType: InputNumDataType;
41
+ accessor autoComplete: InputAutoComplete;
42
+ accessor max: string | undefined;
43
+ accessor min: string | undefined;
44
+ accessor step: string | undefined;
45
+ accessor placeholder: string | undefined;
46
+ accessor list: string[] | undefined;
47
+ _list_set(): void;
48
+ _data_type_set(): void;
49
+ }
50
+ export {};
@@ -0,0 +1,41 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ import { InputAutoComplete } from './00-common';
4
+ export declare const tagName = "GZM-INPUT-COLOR";
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [tagName]: ColorInput;
8
+ }
9
+ }
10
+ declare const colorDataType: readonly ["string", "int"];
11
+ type InputColorDataType = typeof colorDataType[number];
12
+ type ColorDataType = string | number;
13
+ export interface InputColorOptions extends InputOptions<ColorDataType, ColorInput> {
14
+ tagName?: typeof tagName;
15
+ dataType?: InputColorDataType;
16
+ autocomplete?: InputAutoComplete;
17
+ list?: string[];
18
+ }
19
+ declare const mutableAttributes: readonly ["name", "autocomplete", "list", "required"];
20
+ declare const copyAttributes: {
21
+ autocomplete: string;
22
+ } & {
23
+ name: string;
24
+ required: string;
25
+ };
26
+ export declare class ColorInput extends InputBase<ColorDataType, InputColorOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
27
+ #private;
28
+ static formAssociated: boolean;
29
+ constructor();
30
+ _createInput(): HTMLInputElement;
31
+ readonly shadowRoot: ShadowRoot;
32
+ $ipt: HTMLInputElement;
33
+ private $lbl?;
34
+ protected _showValue($ipt?: HTMLInputElement): void;
35
+ _changeValue2Type(v: unknown, t: InputColorDataType): ColorDataType | undefined;
36
+ accessor dataType: InputColorDataType;
37
+ accessor autocomplete: InputAutoComplete;
38
+ accessor list: string[] | undefined;
39
+ _list_set(): void;
40
+ }
41
+ export {};
@@ -0,0 +1,53 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { InputBase, InputOptions } from './01-input';
3
+ export declare const tagName = "GZM-INPUT-LINES";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [tagName]: LinesInput;
7
+ }
8
+ }
9
+ declare const linesDataType: readonly ["string", "array"];
10
+ type InputLinesDataType = typeof linesDataType[number];
11
+ type LinesDataType = string | string[];
12
+ export interface InputLinesOptions extends InputOptions<LinesDataType, LinesInput> {
13
+ tagName?: typeof tagName;
14
+ /**
15
+ * array 类型适用于【标签】这种类型的数据。
16
+ */
17
+ dataType?: InputLinesDataType;
18
+ /**
19
+ * 忽略 rows 属性,ta高度由外层决定
20
+ */
21
+ ignoreRows?: boolean;
22
+ /**
23
+ * 未设置时,浏览器中 <textarea> 默认值是 2。
24
+ * 如果设置了 input-lines 的高度,因为 :host display=flex 的原因,rows 不起作用。
25
+ */
26
+ rows?: number;
27
+ /**
28
+ * HTMLElement 本身有此属性,所以只需要定义 mutableAttributes 和 copyAttributes,保证能够复制到 $ipt。
29
+ */
30
+ spellcheck?: boolean;
31
+ }
32
+ declare const mutableAttributes: readonly ["name", "spellcheck", "rows", "required", "data-type", "ignore-rows"];
33
+ declare const copyAttributes: {
34
+ rows: string;
35
+ spellcheck: string;
36
+ 'data-type': string;
37
+ 'ignore-rows': string;
38
+ } & {
39
+ name: string;
40
+ required: string;
41
+ };
42
+ export declare class LinesInput extends InputBase<LinesDataType, InputLinesOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
43
+ static formAssociated: boolean;
44
+ _createInput(): HTMLTextAreaElement;
45
+ readonly shadowRoot: ShadowRoot;
46
+ $ipt: HTMLTextAreaElement;
47
+ protected _showValue($ipt?: HTMLTextAreaElement): void;
48
+ _changeValue2Type(v: unknown, t: InputLinesDataType): LinesDataType | undefined;
49
+ accessor dataType: InputLinesDataType;
50
+ accessor rows: number | undefined;
51
+ accessor ignoreRows: boolean;
52
+ }
53
+ export {};
@@ -0,0 +1,31 @@
1
+ import { AttributeHandlers, Icon } from '@gzmjs/ui-basic';
2
+ import { ViewElement, ViewModel } from '@gzmjs/mvvm';
3
+ import { ComboList } from './25-comboList';
4
+ export declare const tagName = "GZM-COMBO-ITEM";
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [tagName]: ComboItem;
8
+ }
9
+ }
10
+ export interface ComboItemOptions extends ViewModel<ComboItem> {
11
+ active?: boolean;
12
+ data: object;
13
+ values: string[];
14
+ labels: string[];
15
+ }
16
+ declare const mutableAttributes: readonly ["active"];
17
+ export declare class ComboItem extends ViewElement<ComboItemOptions> implements AttributeHandlers<typeof mutableAttributes[number]> {
18
+ #private;
19
+ get $list(): ComboList;
20
+ get multiple(): boolean;
21
+ /**
22
+ * 无论是单选还是多选,都只在选中 active 状态下才显示勾
23
+ * 注意:这个只是 icon 的容器,且只有这个用 div,其他显示文本的都用 span。
24
+ */
25
+ get $icon(): Icon;
26
+ set values(v: string[]);
27
+ set labels(v: string[]);
28
+ accessor active: boolean;
29
+ _active_set(): void;
30
+ }
31
+ export {};
@@ -0,0 +1,27 @@
1
+ import { ViewListElement, ViewListModel, ListSource } from '@gzmjs/mvvm';
2
+ import { ComboItem, ComboItemOptions } from './24-comboItem';
3
+ export declare const tagName = "GZM-COMBO-LIST";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [tagName]: ComboList;
7
+ }
8
+ }
9
+ export interface ComboListOptions extends ViewListModel<ComboItemOptions, ComboItem, ComboList> {
10
+ listSource: ListSource<object>;
11
+ /**
12
+ * 这个属性要求在 listSource 之后定义,需要先通过 listSource 初始化各个 ComboItem,然后才能设置 active 状态。
13
+ */
14
+ activeItems: Set<object>;
15
+ activeItemsChanged?: (activeItems: Set<object>) => void;
16
+ emptyTip?: string;
17
+ }
18
+ export declare class ComboList extends ViewListElement<ComboItemOptions, ComboItem, ComboListOptions> {
19
+ #private;
20
+ constructor();
21
+ protected _getViewItemTagName(): string;
22
+ get $viewItemsContainer(): HTMLElement;
23
+ protected $section: HTMLElement;
24
+ set listSource(l: ListSource<object>);
25
+ set activeItems(items: Set<object>);
26
+ accessor emptyTip: string | undefined;
27
+ }
@@ -0,0 +1,40 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ListSource } from '@gzmjs/mvvm';
3
+ import { InputBase, InputOptions } from './01-input';
4
+ import { ComboList } from './25-comboList';
5
+ export declare const tagName = "GZM-INPUT-COMBO";
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ [tagName]: ComboInput;
9
+ }
10
+ }
11
+ export interface InputComboOptions extends InputOptions<unknown, ComboInput> {
12
+ tagName?: typeof tagName;
13
+ listSource: ListSource<object>;
14
+ /**
15
+ * 当 listSource.multiple = true 时,显示选中多项用此符号隔开。
16
+ */
17
+ multipleDelimiter?: string;
18
+ /**
19
+ * 传递给 combo-list
20
+ */
21
+ emptyTip?: string;
22
+ }
23
+ declare const mutableAttributes: readonly ["name", "required", "multiple-delimiter"];
24
+ declare const copyAttributes: {
25
+ name: string;
26
+ required: string;
27
+ };
28
+ export declare class ComboInput extends InputBase<unknown, InputComboOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
29
+ #private;
30
+ static formAssociated: boolean;
31
+ protected _createInput(): HTMLInputElement;
32
+ readonly shadowRoot: ShadowRoot;
33
+ $ipt: HTMLInputElement;
34
+ protected _showValue($ipt?: HTMLInputElement): void;
35
+ get $currentList(): ComboList | undefined;
36
+ accessor multipleDelimiter: string;
37
+ accessor emptyTip: string | undefined;
38
+ _multiple_delimiter_set(): void;
39
+ }
40
+ export {};
@@ -0,0 +1,36 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ListSource } from '@gzmjs/mvvm';
3
+ import { InputBase, InputOptions } from './01-input';
4
+ import { ComboList } from './25-comboList';
5
+ export declare const tagName = "GZM-CHECK-LIST";
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ [tagName]: CheckList;
9
+ }
10
+ }
11
+ export interface CheckListOptions extends InputOptions<unknown, CheckList> {
12
+ tagName?: typeof tagName;
13
+ listSource: ListSource<object>;
14
+ /**
15
+ * 传递给 combo-list
16
+ */
17
+ emptyTip?: string;
18
+ }
19
+ declare const mutableAttributes: readonly ["name", "required", "empty-tip"];
20
+ declare const copyAttributes: {
21
+ 'empty-tip': string;
22
+ } & {
23
+ name: string;
24
+ required: string;
25
+ };
26
+ export declare class CheckList extends InputBase<unknown, CheckListOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
27
+ static formAssociated: boolean;
28
+ constructor();
29
+ readonly shadowRoot: ShadowRoot;
30
+ readonly $ipt: HTMLInputElement;
31
+ $list: ComboList;
32
+ protected _createInput(): HTMLInputElement;
33
+ protected _showValue(): void;
34
+ accessor emptyTip: string | undefined;
35
+ }
36
+ export {};
@@ -0,0 +1,50 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ListSource } from '@gzmjs/mvvm';
3
+ import { InputBase, InputOptions } from './01-input';
4
+ import { ComboList } from './25-comboList';
5
+ export declare const tagName = "GZM-SEARCH-LIST";
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ [tagName]: SearchList;
9
+ }
10
+ }
11
+ export interface SearchListOptions extends InputOptions<unknown, SearchList> {
12
+ tagName?: typeof tagName;
13
+ listSource: ListSource<object>;
14
+ /**
15
+ * 传递给 combo-list
16
+ */
17
+ emptyTip?: string;
18
+ search?: (txt: string) => object[] | Promise<object[]>;
19
+ }
20
+ declare const mutableAttributes: readonly ["name", "required", "empty-tip"];
21
+ declare const copyAttributes: {
22
+ 'empty-tip': string;
23
+ } & {
24
+ name: string;
25
+ required: string;
26
+ };
27
+ /**
28
+ * 基本上就是 check-list 的基础上添加了一个 input[search]。
29
+ * 要实现到服务器端搜索,需要从 SearchListSource 继承后重写 search() 方法。
30
+ */
31
+ export declare class SearchList extends InputBase<unknown, SearchListOptions> implements AttributeHandlers<Exclude<typeof mutableAttributes[number], keyof typeof copyAttributes>> {
32
+ #private;
33
+ static formAssociated: boolean;
34
+ constructor();
35
+ readonly shadowRoot: ShadowRoot;
36
+ readonly $ipt: HTMLInputElement;
37
+ $list: ComboList;
38
+ $qb: HTMLInputElement;
39
+ protected _createInput(): HTMLInputElement;
40
+ protected _showValue(): void;
41
+ accessor emptyTip: string | undefined;
42
+ readonly T: {
43
+ readonly qbPlaceholder: string;
44
+ readonly noListSource: string;
45
+ readonly noRecord: string;
46
+ } & {
47
+ bindHtmlElement: <P>(this: P, $ele: HTMLElement) => P;
48
+ };
49
+ }
50
+ export {};