@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,15 @@
1
+ import { FormInputOptions } from './95-form-input';
2
+ import { FormInputGroupOptions } from './96-form-group';
3
+ import { FormListOptions } from './97-form-list';
4
+ export declare const formInputTagName = "GZM-FORM-INPUT";
5
+ export declare const formGroupTagName = "GZM-INPUT-GROUP";
6
+ export declare const formListTagName = "GZM-FORM";
7
+ export declare const styleSheet: CSSStyleSheet;
8
+ /**
9
+ * 《model 与 data 的融合.md》非 PlainObject 化
10
+ * 同时允许非代理对象作为数据源
11
+ * @param ds
12
+ * @param model
13
+ * @returns
14
+ */
15
+ export declare function checkDataSource(ds: object, model?: FormListOptions | FormInputGroupOptions | FormInputOptions): void;
@@ -0,0 +1,51 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ViewModel, ViewElement } from '@gzmjs/mvvm';
3
+ import { InputLabelOptions, InputLabel } from './03-label';
4
+ import { InputTextOptions } from './06-text';
5
+ import { InputCalOptions } from './09-cal';
6
+ import { InputCheckOptions } from './12-check';
7
+ import { InputNumOptions } from './15-num';
8
+ import { InputColorOptions } from './18-color';
9
+ import { InputLinesOptions } from './21-lines';
10
+ import { InputComboOptions } from './26-combo';
11
+ import { CheckListOptions } from './27-checklist';
12
+ import { SearchListOptions } from './30-search-list';
13
+ import { FormInputGroup } from './96-form-group';
14
+ import { formInputTagName } from './94.form';
15
+ declare global {
16
+ interface HTMLElementTagNameMap {
17
+ [formInputTagName]: FormInput;
18
+ }
19
+ }
20
+ type AllInputTypes = InputLabelOptions | InputTextOptions | InputCalOptions | InputCheckOptions | InputNumOptions | InputColorOptions | InputLinesOptions | InputComboOptions | CheckListOptions | SearchListOptions;
21
+ export interface FormInputOptions extends ViewModel<FormInput> {
22
+ label: string;
23
+ input: AllInputTypes;
24
+ dataSource?: object;
25
+ }
26
+ declare const mutableAttributes: readonly ["label", "title"];
27
+ export declare class FormInput extends ViewElement<FormInputOptions> implements AttributeHandlers<typeof mutableAttributes[number]> {
28
+ #private;
29
+ get $head(): HTMLElement;
30
+ get $label(): HTMLLabelElement;
31
+ /**
32
+ * <gzm-input-*>
33
+ * 可能不是 InputLabel,但是它们都有共同的基类,所以用 Label 来欺骗 TypeScript。
34
+ */
35
+ $ipt?: InputLabel;
36
+ /**
37
+ * 在录入组件和 label 之间切换,其实就是用来生成 $ipt。
38
+ * @param readonly - 必须是所属组的 readonly,所以请等到 connectedCallback() 后再调用!
39
+ */
40
+ switchLabel(readonly?: boolean): void;
41
+ get $group(): FormInputGroup | null;
42
+ connectedCallback(): void;
43
+ accessor label: string | undefined;
44
+ _label_set(): void;
45
+ _title_set(): void;
46
+ get dataSource(): object | undefined;
47
+ set dataSource(ds: object);
48
+ get input(): AllInputTypes | undefined;
49
+ set input(v: AllInputTypes | undefined);
50
+ }
51
+ export {};
@@ -0,0 +1,39 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ViewListElement, ViewListModel } from '@gzmjs/mvvm';
3
+ import { FormInput, FormInputOptions } from './95-form-input';
4
+ import { formGroupTagName } from './94.form';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [formGroupTagName]: FormInputGroup;
8
+ }
9
+ }
10
+ export interface FormInputGroupOptions extends ViewListModel<FormInputOptions, FormInput, FormInputGroup> {
11
+ label?: string;
12
+ collapsed?: boolean;
13
+ /**
14
+ * 需要放在 modelList 之后!
15
+ */
16
+ readonly?: boolean;
17
+ /**
18
+ * 需要放在 modelList 之后!
19
+ */
20
+ dataSource?: object;
21
+ }
22
+ declare const mutableAttributes: readonly ["label", "collapsed", "readonly"];
23
+ export declare class FormInputGroup extends ViewListElement<FormInputOptions, FormInput, FormInputGroupOptions> implements AttributeHandlers<typeof mutableAttributes[number]> {
24
+ #private;
25
+ get $head(): HTMLElement;
26
+ get $icn(): HTMLButtonElement;
27
+ get $lbl(): HTMLElement;
28
+ get $section(): HTMLElement;
29
+ protected _getViewItemTagName(): string;
30
+ get $viewItemsContainer(): HTMLElement | ShadowRoot;
31
+ set dataSource(ds: object);
32
+ accessor label: string | undefined;
33
+ _label_set(): void;
34
+ accessor collapsed: boolean;
35
+ _collapsed_set(): void;
36
+ accessor readonly: boolean;
37
+ _readonly_set(): void;
38
+ }
39
+ export {};
@@ -0,0 +1,38 @@
1
+ import { AttributeHandlers } from '@gzmjs/ui-basic';
2
+ import { ViewListElement, ViewListModel } from '@gzmjs/mvvm';
3
+ import { FormInputGroup, FormInputGroupOptions } from './96-form-group';
4
+ import { formListTagName } from './94.form';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [formListTagName]: FormList;
8
+ }
9
+ }
10
+ export interface FormListOptions extends ViewListModel<FormInputGroupOptions, FormInputGroup, FormList> {
11
+ tagName?: typeof formListTagName;
12
+ /**
13
+ * 需要放在 modelList 之后!
14
+ */
15
+ readonly?: boolean;
16
+ /**
17
+ * 需要放在 modelList 之后!
18
+ */
19
+ dataSource?: object;
20
+ }
21
+ declare const mutableAttributes: readonly ["readonly"];
22
+ export declare class FormList extends ViewListElement<FormInputGroupOptions, FormInputGroup, FormListOptions> implements AttributeHandlers<typeof mutableAttributes[number]> {
23
+ constructor();
24
+ readonly $form: HTMLFormElement;
25
+ getFormData(): FormData;
26
+ submit(): void;
27
+ checkValidity(): boolean;
28
+ protected _getViewItemTagName(): string;
29
+ get $viewItemsContainer(): HTMLElement | ShadowRoot;
30
+ accessor readonly: boolean;
31
+ _readonly_set(): void;
32
+ /**
33
+ * 必须要等到 modelList 处理完毕之后再调用!
34
+ * 其实还有一种方法:queueMicrotask()
35
+ */
36
+ set dataSource(ds: object);
37
+ }
38
+ export {};