@next-bricks/form 0.5.0 → 0.7.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.
Files changed (130) hide show
  1. package/dist/bricks.json +15 -4
  2. package/dist/chunks/{1970.0122d8c6.js → 1970.1bf0f5c1.js} +3 -3
  3. package/dist/chunks/{1970.0122d8c6.js.map → 1970.1bf0f5c1.js.map} +1 -1
  4. package/dist/chunks/2179.5d5ada16.js +2 -0
  5. package/dist/chunks/{6205.af7a9022.js.map → 2179.5d5ada16.js.map} +1 -1
  6. package/dist/chunks/2618.4d1b4f8f.js +2 -0
  7. package/dist/chunks/2618.4d1b4f8f.js.map +1 -0
  8. package/dist/chunks/{3494.4a17db19.js → 3494.81238413.js} +2 -2
  9. package/dist/chunks/{3494.4a17db19.js.map → 3494.81238413.js.map} +1 -1
  10. package/dist/chunks/4131.cd33579d.js +2 -0
  11. package/dist/chunks/4131.cd33579d.js.map +1 -0
  12. package/dist/chunks/4356.e66da273.js +2 -0
  13. package/dist/chunks/4356.e66da273.js.map +1 -0
  14. package/dist/chunks/4791.288c8084.js +2 -0
  15. package/dist/chunks/4791.288c8084.js.map +1 -0
  16. package/dist/chunks/5636.676bad66.js +2 -0
  17. package/dist/chunks/5636.676bad66.js.map +1 -0
  18. package/dist/chunks/6205.e5f8de3e.js +2 -0
  19. package/dist/chunks/{7164.dcaf6d0e.js.map → 6205.e5f8de3e.js.map} +1 -1
  20. package/dist/chunks/7164.c5911296.js +2 -0
  21. package/dist/chunks/7164.c5911296.js.map +1 -0
  22. package/dist/chunks/{7822.53604e29.js → 7822.8c36398f.js} +2 -2
  23. package/dist/chunks/{7822.53604e29.js.map → 7822.8c36398f.js.map} +1 -1
  24. package/dist/chunks/{8826.4444fb49.js → 9223.c35f1d9a.js} +2 -2
  25. package/dist/chunks/9223.c35f1d9a.js.map +1 -0
  26. package/dist/chunks/{9431.4eea30bd.js → 9431.cabf049c.js} +2 -2
  27. package/dist/chunks/{9431.4eea30bd.js.map → 9431.cabf049c.js.map} +1 -1
  28. package/dist/chunks/{code-editor.c7e4ccfa.js → code-editor.85b3ad33.js} +2 -2
  29. package/dist/chunks/code-editor.85b3ad33.js.map +1 -0
  30. package/dist/chunks/dynamic-form-item.f3f40a4e.js +2 -0
  31. package/dist/chunks/dynamic-form-item.f3f40a4e.js.map +1 -0
  32. package/dist/chunks/general-checkbox.81d8d8d1.js +3 -0
  33. package/dist/chunks/general-checkbox.81d8d8d1.js.map +1 -0
  34. package/dist/chunks/general-form-item.9a3d11f7.js +3 -0
  35. package/dist/chunks/general-form-item.9a3d11f7.js.map +1 -0
  36. package/dist/chunks/general-form.03de30e1.js +2 -0
  37. package/dist/chunks/general-form.03de30e1.js.map +1 -0
  38. package/dist/chunks/general-input.1e2be165.js +3 -0
  39. package/dist/chunks/general-input.1e2be165.js.map +1 -0
  40. package/dist/chunks/general-radio.f5b2b849.js +3 -0
  41. package/dist/chunks/general-radio.f5b2b849.js.map +1 -0
  42. package/dist/chunks/general-search.a76cac8b.js +3 -0
  43. package/dist/chunks/general-search.a76cac8b.js.map +1 -0
  44. package/dist/chunks/general-select.b806fc3d.js +3 -0
  45. package/dist/chunks/general-select.b806fc3d.js.map +1 -0
  46. package/dist/chunks/general-textarea.ce42122f.js +3 -0
  47. package/dist/chunks/general-textarea.ce42122f.js.map +1 -0
  48. package/dist/chunks/icon-select.c1e34968.js +3 -0
  49. package/dist/chunks/icon-select.c1e34968.js.LICENSE.txt +5 -0
  50. package/dist/chunks/icon-select.c1e34968.js.map +1 -0
  51. package/dist/chunks/main.ba6d4ded.js +2 -0
  52. package/dist/chunks/main.ba6d4ded.js.map +1 -0
  53. package/dist/chunks/submit-buttons.0a2d1413.js +2 -0
  54. package/dist/chunks/submit-buttons.0a2d1413.js.map +1 -0
  55. package/dist/index.a93d21e4.js +2 -0
  56. package/dist/index.a93d21e4.js.map +1 -0
  57. package/dist/manifest.json +294 -212
  58. package/dist-types/bootstrap.d.ts +1 -0
  59. package/dist-types/checkbox/index.d.ts +37 -40
  60. package/dist-types/code-editor/index.d.ts +3 -3
  61. package/dist-types/dynamic-form-item/index.d.ts +14 -9
  62. package/dist-types/form/index.d.ts +19 -16
  63. package/dist-types/form-item/index.d.ts +4 -5
  64. package/dist-types/icon-select/i18n.d.ts +15 -0
  65. package/dist-types/icon-select/index.d.ts +53 -0
  66. package/dist-types/icon-select/index.spec.d.ts +1 -0
  67. package/dist-types/icon-select/utils.d.ts +25 -0
  68. package/dist-types/input/index.d.ts +82 -11
  69. package/dist-types/input/index.spec.d.ts +1 -0
  70. package/dist-types/radio/index.d.ts +44 -82
  71. package/dist-types/search/index.d.ts +5 -5
  72. package/dist-types/select/index.d.ts +19 -79
  73. package/dist-types/submit-buttons/index.d.ts +11 -49
  74. package/dist-types/textarea/calculateAutoSizeStyle.d.ts +1 -0
  75. package/dist-types/textarea/index.d.ts +25 -58
  76. package/docs/dynamic-form-item.md +89 -0
  77. package/docs/general-checkbox.md +221 -0
  78. package/docs/general-form.md +245 -0
  79. package/docs/general-input.md +163 -0
  80. package/docs/general-radio.md +286 -0
  81. package/docs/general-select.md +205 -0
  82. package/docs/general-textarea.md +109 -0
  83. package/docs/icon-select.md +14 -0
  84. package/docs/submit-buttons.md +67 -0
  85. package/package.json +2 -2
  86. package/dist/chunks/2255.91dc8128.js +0 -2
  87. package/dist/chunks/2255.91dc8128.js.map +0 -1
  88. package/dist/chunks/2993.5d245055.js +0 -2
  89. package/dist/chunks/2993.5d245055.js.map +0 -1
  90. package/dist/chunks/6205.af7a9022.js +0 -2
  91. package/dist/chunks/7164.dcaf6d0e.js +0 -2
  92. package/dist/chunks/8826.4444fb49.js.map +0 -1
  93. package/dist/chunks/9396.f9127ea6.js +0 -2
  94. package/dist/chunks/9396.f9127ea6.js.map +0 -1
  95. package/dist/chunks/code-editor.c7e4ccfa.js.map +0 -1
  96. package/dist/chunks/dynamic-form-item.97b25da2.js +0 -2
  97. package/dist/chunks/dynamic-form-item.97b25da2.js.map +0 -1
  98. package/dist/chunks/general-checkbox.0ec43d11.js +0 -3
  99. package/dist/chunks/general-checkbox.0ec43d11.js.map +0 -1
  100. package/dist/chunks/general-form-item.865dc60f.js +0 -3
  101. package/dist/chunks/general-form-item.865dc60f.js.map +0 -1
  102. package/dist/chunks/general-form.c9523ae0.js +0 -2
  103. package/dist/chunks/general-form.c9523ae0.js.map +0 -1
  104. package/dist/chunks/general-input.243352ff.js +0 -3
  105. package/dist/chunks/general-input.243352ff.js.map +0 -1
  106. package/dist/chunks/general-radio.21553834.js +0 -3
  107. package/dist/chunks/general-radio.21553834.js.map +0 -1
  108. package/dist/chunks/general-search.0ba9a7cb.js +0 -3
  109. package/dist/chunks/general-search.0ba9a7cb.js.map +0 -1
  110. package/dist/chunks/general-select.d6404264.js +0 -3
  111. package/dist/chunks/general-select.d6404264.js.map +0 -1
  112. package/dist/chunks/general-textarea.11a84e7c.js +0 -3
  113. package/dist/chunks/general-textarea.11a84e7c.js.map +0 -1
  114. package/dist/chunks/main.c796802d.js +0 -2
  115. package/dist/chunks/main.c796802d.js.map +0 -1
  116. package/dist/chunks/submit-buttons.6fe24040.js +0 -2
  117. package/dist/chunks/submit-buttons.6fe24040.js.map +0 -1
  118. package/dist/index.7af0aa96.js +0 -2
  119. package/dist/index.7af0aa96.js.map +0 -1
  120. package/dist-types/form/formStore.d.ts +0 -53
  121. package/dist-types/form-item/FormItemElement.d.ts +0 -22
  122. package/dist-types/utils/PubSub.d.ts +0 -6
  123. /package/dist/chunks/{1970.0122d8c6.js.LICENSE.txt → 1970.1bf0f5c1.js.LICENSE.txt} +0 -0
  124. /package/dist/chunks/{general-checkbox.0ec43d11.js.LICENSE.txt → general-checkbox.81d8d8d1.js.LICENSE.txt} +0 -0
  125. /package/dist/chunks/{general-form-item.865dc60f.js.LICENSE.txt → general-form-item.9a3d11f7.js.LICENSE.txt} +0 -0
  126. /package/dist/chunks/{general-input.243352ff.js.LICENSE.txt → general-input.1e2be165.js.LICENSE.txt} +0 -0
  127. /package/dist/chunks/{general-radio.21553834.js.LICENSE.txt → general-radio.f5b2b849.js.LICENSE.txt} +0 -0
  128. /package/dist/chunks/{general-search.0ba9a7cb.js.LICENSE.txt → general-search.a76cac8b.js.LICENSE.txt} +0 -0
  129. /package/dist/chunks/{general-select.d6404264.js.LICENSE.txt → general-select.b806fc3d.js.LICENSE.txt} +0 -0
  130. /package/dist/chunks/{general-textarea.11a84e7c.js.LICENSE.txt → general-textarea.ce42122f.js.LICENSE.txt} +0 -0
@@ -9,3 +9,4 @@ import "./checkbox/index.js";
9
9
  import "./code-editor/index.js";
10
10
  import "./dynamic-form-item/index.js";
11
11
  import "./search/index.js";
12
+ import "./icon-select/index.js";
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import "@next-core/theme";
3
- import { FormItemElement } from "../form-item/FormItemElement.js";
3
+ import type { FormItemProps } from "../form-item/index.js";
4
+ import { FormItemElementBase } from "@next-shared/form";
4
5
  export type CheckboxType = "default" | "icon";
5
6
  export declare type CheckboxValueType = string | number | boolean;
6
7
  export interface CheckboxOptionType {
@@ -19,66 +20,62 @@ export interface OptionGroup {
19
20
  key: string;
20
21
  options: CheckboxOptionType[];
21
22
  }
22
- export interface CheckboxProps {
23
+ export interface CheckboxProps extends FormItemProps {
23
24
  options?: CheckboxOptionType[];
24
25
  label?: string;
25
26
  value?: CheckboxValueType[];
26
- onChange?: (value: CheckboxOptionType[]) => void;
27
- text?: string;
27
+ disabled?: boolean;
28
28
  type?: CheckboxType;
29
29
  isCustom?: boolean;
30
- name?: string;
31
- [propName: string]: any;
30
+ onChange?: (value: CheckboxOptionType[]) => void;
31
+ optionsChange?: (options: CheckboxOptionType[], name: string) => void;
32
32
  }
33
- declare class Checkbox extends FormItemElement {
33
+ /**
34
+ * 表单复选框构件
35
+ * @author derrickma
36
+ */
37
+ declare class Checkbox extends FormItemElementBase {
34
38
  #private;
35
39
  /**
36
- * @kind string
37
- * @required true
38
- * @default -
39
- * @description 多选框当前选中初始值
40
- * @group basic
40
+ * 字段名称
41
41
  */
42
- accessor value: string[] | undefined;
42
+ accessor name: string | undefined;
43
43
  /**
44
- * @required true
45
- * @default -
46
- * @description 多选框选项表
47
- * @group basic
44
+ * 字段说明
48
45
  */
49
- accessor options: CheckboxOptionType[];
46
+ accessor label: string | undefined;
50
47
  /**
51
- * @kind string
52
- * @required true
53
- * @default -
54
- * @description 多选框字段名
55
- * @group basicFormItem
48
+ *
56
49
  */
57
- accessor name: string | undefined;
50
+ accessor value: CheckboxValueType[] | undefined;
58
51
  /**
59
- * @kind string
60
- * @required false
61
- * @default -
62
- * @description 多选框字段说明
63
- * @group basic
52
+ * 多选框选项表
53
+ * @required
64
54
  */
65
- accessor label: string | undefined;
55
+ accessor options: CheckboxOptionType[];
66
56
  /**
67
- * @kind string
68
- * @required false
69
- * @default -
70
- * @description 多选框类型
71
- * @group basic
57
+ * 类型
58
+ * @default "default"
72
59
  */
73
60
  accessor type: CheckboxType;
74
61
  /**
75
- * @kind boolean
76
- * @required false
77
- * @default -
78
- * @description 多选框字段说明
79
- * @group basic
62
+ * 是否禁用
63
+ */
64
+ accessor disabled: boolean | undefined;
65
+ /**
66
+ * 是否为自定义
67
+ * @default false
80
68
  */
81
69
  accessor isCustom: boolean;
70
+ /**
71
+ * 是否必填
72
+ */
73
+ accessor required: boolean | undefined;
74
+ /**
75
+ * 校验文本
76
+ */
77
+ accessor message: Record<string, string> | undefined;
78
+ handleCheckboxChange: (detail: CheckboxOptionType[]) => void;
82
79
  render(): JSX.Element;
83
80
  }
84
81
  export { Checkbox };
@@ -1,6 +1,6 @@
1
- /// <reference types="react" resolution-mode="require"/>
1
+ /// <reference types="react" />
2
2
  import { CodeEditorProps, HighlightTokenSettings, Annotation } from "./interfaces.js";
3
- import { FormItemElement } from "../form-item/FormItemElement.js";
3
+ import { FormItemElementBase } from "@next-shared/form";
4
4
  export interface Error {
5
5
  err: Annotation[];
6
6
  hasError: boolean;
@@ -13,7 +13,7 @@ export interface Error {
13
13
  * @author sailor
14
14
  * @noInheritDoc
15
15
  */
16
- declare class CodeEditor extends FormItemElement {
16
+ declare class CodeEditor extends FormItemElementBase {
17
17
  #private;
18
18
  /**
19
19
  * @description
@@ -1,7 +1,7 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
- import { FormItemElement } from "../form-item/FormItemElement.js";
1
+ /// <reference types="react" />
3
2
  import { UseBrickConf } from "@next-core/types";
4
3
  import "@next-core/theme";
4
+ import { FormItemElementBase } from "@next-shared/form";
5
5
  type DynamicFormValuesItem = Record<string, any>;
6
6
  /**
7
7
  * @id form.dynamic-form-item
@@ -11,21 +11,26 @@ type DynamicFormValuesItem = Record<string, any>;
11
11
  * @author sailor
12
12
  * @noInheritDoc
13
13
  */
14
- declare class DynamicFormItem extends FormItemElement {
14
+ declare class DynamicFormItem extends FormItemElementBase {
15
15
  #private;
16
+ /**
17
+ * 字段名称
18
+ */
16
19
  accessor name: string | undefined;
20
+ /**
21
+ * 字段说明
22
+ */
17
23
  accessor label: string | undefined;
18
24
  /**
19
- * @default
20
- * @required
21
- * @description
25
+ * 是否必填
22
26
  */
23
27
  accessor required: boolean | undefined;
28
+ /**
29
+ * 值
30
+ */
24
31
  accessor value: DynamicFormValuesItem[] | undefined;
25
32
  /**
26
- * @default
27
- * @required
28
- * @description
33
+ * 动态表单子项构件列表
29
34
  */
30
35
  accessor useBrick: UseBrickConf | undefined;
31
36
  handleDynamicFormChange: (values: DynamicFormValuesItem[]) => void;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" resolution-mode="require"/>
1
+ /// <reference types="react" />
2
2
  import { ReactNextElement } from "@next-core/react-element";
3
- import { FormStore } from "./formStore.js";
3
+ import { AbstractForm, FormStore } from "@next-shared/form";
4
4
  import { ComponentSize, Layout } from "../interface.js";
5
5
  interface FormProps {
6
6
  values?: Record<string, any>;
@@ -18,46 +18,49 @@ export interface FormMapEvents {
18
18
  onValidateError: "validate.error";
19
19
  }
20
20
  /**
21
- * @id form.general-form
22
- * @name form.general-form
23
- * @docKind brick
24
- * @description 通用输入框构件
21
+ * 表单构件
25
22
  * @author sailor
26
- * @noInheritDoc
23
+ * @slot - 表单内容
27
24
  */
28
- declare class Form extends ReactNextElement implements FormProps {
25
+ declare class Form extends ReactNextElement implements FormProps, AbstractForm {
29
26
  #private;
30
- readonly isFormElement = true;
31
27
  formStore: FormStore;
32
28
  defaultEmitValuesChange: boolean;
33
29
  constructor();
30
+ get isFormElement(): true;
34
31
  set values(value: Record<string, unknown>);
35
32
  get values(): Record<string, unknown>;
33
+ /**
34
+ * 布局方式
35
+ */
36
36
  accessor layout: Layout | undefined;
37
+ /**
38
+ * 表单组件尺寸
39
+ */
37
40
  accessor size: ComponentSize | undefined;
38
41
  handleValuesChange: (values: Record<string, unknown>) => void;
39
42
  /**
40
- * @description
43
+ * 表单校验方法
41
44
  */
42
45
  validate(): boolean | Record<string, unknown>;
43
46
  /**
44
- * @description
47
+ * 表单设置值方法
45
48
  */
46
49
  setInitValue(values: Record<string, unknown>): void;
47
50
  /**
48
- * @description
51
+ * 表单重置值方法
49
52
  */
50
53
  resetFields(name?: string): void;
51
54
  /**
52
- * @description
55
+ * 获取表单值方法
53
56
  */
54
- getFieldsValue(name: string): unknown;
57
+ getFieldsValue(name?: string): unknown;
55
58
  /**
56
- * @description
59
+ * 校验表单字段方法
57
60
  */
58
61
  validateField(name: string): void;
59
62
  /**
60
- * @description
63
+ * 重置表单校验状态方法
61
64
  */
62
65
  resetValidateState(): void;
63
66
  render(): JSX.Element;
@@ -1,8 +1,7 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
- import { FormItemElement } from "./FormItemElement.js";
1
+ /// <reference types="react" />
2
+ import { AbstractForm, FormItemElementBase, MessageBody } from "@next-shared/form";
3
3
  import type { Form } from "../form/index.jsx";
4
4
  import type { ComponentSize, Layout } from "../interface.js";
5
- import type { MessageBody } from "../form/formStore.js";
6
5
  import "@next-core/theme";
7
6
  type CurrentElement = HTMLElement & {
8
7
  size?: ComponentSize;
@@ -10,7 +9,7 @@ type CurrentElement = HTMLElement & {
10
9
  [key: string]: any;
11
10
  };
12
11
  export interface FormItemProps {
13
- formElement?: Form;
12
+ formElement?: AbstractForm | null;
14
13
  curElement: CurrentElement;
15
14
  name?: string;
16
15
  label?: string;
@@ -37,7 +36,7 @@ export interface FormItemProps {
37
36
  * @author sailor
38
37
  * @noInheritDoc
39
38
  */
40
- declare class FormItem extends FormItemElement implements FormItemProps {
39
+ declare class FormItem extends FormItemElementBase implements FormItemProps {
41
40
  /**
42
41
  * @default
43
42
  * @required
@@ -0,0 +1,15 @@
1
+ export declare enum K {
2
+ ICON = "ICON",
3
+ COLOR = "COLOR",
4
+ SELECT_ICON = "SELECT_ICON",
5
+ SEARCH_PLACEHOLDER = "SEARCH_PLACEHOLDER"
6
+ }
7
+ export declare const NS = "bricks/form/icon-select";
8
+ export declare const locales: {
9
+ en: Locale;
10
+ zh: Locale;
11
+ };
12
+ type Locale = {
13
+ [key in K]: string;
14
+ };
15
+ export {};
@@ -0,0 +1,53 @@
1
+ /// <reference types="react" />
2
+ import { FormItemElementBase } from "@next-shared/form";
3
+ import "@next-core/theme";
4
+ import type { FormItemProps } from "../form-item/index.js";
5
+ import type { GeneralIconProps } from "@next-bricks/icons/general-icon";
6
+ type Icon = GeneralIconProps & {
7
+ color?: string;
8
+ };
9
+ export interface IconSelectProps {
10
+ name?: string;
11
+ label?: string;
12
+ value?: Icon;
13
+ disabled?: boolean;
14
+ required?: boolean;
15
+ message?: Record<string, string>;
16
+ }
17
+ /**
18
+ * 图标选择构件
19
+ */
20
+ export declare class IconSelect extends FormItemElementBase implements IconSelectProps {
21
+ #private;
22
+ /**
23
+ * 字段名称
24
+ */
25
+ accessor name: string | undefined;
26
+ /**
27
+ * 字段说明
28
+ */
29
+ accessor label: string | undefined;
30
+ /**
31
+ * 值
32
+ */
33
+ accessor value: Icon | undefined;
34
+ /**
35
+ * 是否禁用
36
+ */
37
+ accessor disabled: boolean | undefined;
38
+ /**
39
+ * 是否必填
40
+ */
41
+ accessor required: boolean | undefined;
42
+ /**
43
+ * 是否必填
44
+ */
45
+ accessor message: Record<string, string> | undefined;
46
+ handleChange: (value?: Icon) => void;
47
+ render(): JSX.Element;
48
+ }
49
+ interface IconSelectComponentProps extends FormItemProps, IconSelectProps {
50
+ onChange?: (value?: Icon) => void;
51
+ }
52
+ export declare function IconSelectComponent(props: IconSelectComponentProps): JSX.Element;
53
+ export {};
@@ -0,0 +1 @@
1
+ import "./";
@@ -0,0 +1,25 @@
1
+ export declare enum Colors {
2
+ green = "green",
3
+ red = "red",
4
+ blue = "blue",
5
+ orange = "orange",
6
+ cyan = "cyan",
7
+ purple = "purple",
8
+ geekblue = "geekblue",
9
+ gray = "gray"
10
+ }
11
+ export declare const COLORS_MAP: Record<Colors, {
12
+ color: string;
13
+ background: string;
14
+ borderColor: string;
15
+ }>;
16
+ /**
17
+ * 如果提供的颜色值是平台提供的规范颜色,则转换为使用平台规范的颜色定义,包括color、background、borderColor,不是的话则原样输出。
18
+ * @param color {string} 颜色值
19
+ * @return {color:string;background:string;borderColor:string;} 返回处理后的对应颜色值
20
+ */
21
+ export declare function getColor(color?: string): {
22
+ color: string;
23
+ background: string;
24
+ borderColor: string;
25
+ };
@@ -1,27 +1,98 @@
1
1
  import React from "react";
2
2
  import { ComponentSize, InputType } from "../interface.js";
3
+ import { FormItemElementBase } from "@next-shared/form";
3
4
  import "@next-core/theme";
4
- import { Form } from "../form/index.js";
5
- interface InputProps {
6
- formElement?: Form;
7
- curElement: HTMLElement;
8
- name?: string;
9
- label?: string;
5
+ import type { FormItemProps } from "../form-item/index.jsx";
6
+ interface InputProps extends FormItemProps {
10
7
  value?: string;
11
8
  placeholder?: string;
12
9
  disabled?: boolean;
10
+ clearable?: boolean;
13
11
  type?: InputType;
14
12
  size?: ComponentSize;
15
13
  inputStyle?: React.CSSProperties;
16
14
  minLength?: number;
17
15
  maxLength?: number;
18
- required?: boolean;
19
- pattern?: string;
20
- min?: number;
21
- max?: number;
22
16
  validateState?: string;
23
17
  trigger?: string;
24
18
  onInputChange: (value: string) => void;
25
19
  }
20
+ /**
21
+ * 通用输入框构件
22
+ * @author sailor
23
+ * @slot prefix - 输入框前置插槽
24
+ * @slot suffix - 输入框后置插槽
25
+ */
26
+ declare class Input extends FormItemElementBase {
27
+ #private;
28
+ /**
29
+ * 字段名称
30
+ */
31
+ accessor name: string | undefined;
32
+ /**
33
+ * 标签文字
34
+ */
35
+ accessor label: string | undefined;
36
+ /**
37
+ * 输入框值
38
+ */
39
+ accessor value: string | undefined;
40
+ /**
41
+ * 占位说明
42
+ */
43
+ accessor placeholder: string | undefined;
44
+ /**
45
+ * 是否禁用
46
+ */
47
+ accessor disabled: boolean | undefined;
48
+ /**
49
+ * 是否显示清除按钮
50
+ */
51
+ accessor clearable: boolean | undefined;
52
+ /**
53
+ * 类型
54
+ * @default "text"
55
+ */
56
+ accessor type: InputType | undefined;
57
+ /**
58
+ * 大小
59
+ * @default "medium"
60
+ */
61
+ accessor size: ComponentSize | undefined;
62
+ /**
63
+ * 最小长度
64
+ */
65
+ accessor minLength: number | undefined;
66
+ /**
67
+ * 最大长度
68
+ */
69
+ accessor maxLength: number | undefined;
70
+ /**
71
+ * 是否必填
72
+ */
73
+ accessor required: boolean | undefined;
74
+ /**
75
+ * 正则校验规则
76
+ */
77
+ accessor pattern: string | undefined;
78
+ /**
79
+ * 表单校验最大长度
80
+ */
81
+ accessor max: number | undefined;
82
+ /**
83
+ * 表单校验最小长度
84
+ */
85
+ accessor min: number | undefined;
86
+ /**
87
+ * 错误时显示消息
88
+ */
89
+ accessor message: Record<string, string> | undefined;
90
+ /**
91
+ * 输入框样式
92
+ */
93
+ accessor inputStyle: React.CSSProperties | undefined;
94
+ handleInputChange: (value: string) => void;
95
+ render(): JSX.Element;
96
+ }
26
97
  export declare function InputComponent(props: InputProps): JSX.Element;
27
- export {};
98
+ export { Input };
@@ -0,0 +1 @@
1
+ import "./";
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import type { RadioType, GeneralOption, UIType, RadioGroupButtonStyle } from "../interface.js";
2
+ import { FormItemElementBase } from "@next-shared/form";
3
+ import type { RadioType, GeneralOption, GeneralComplexOption, UIType, RadioGroupButtonStyle, ComponentSize } from "../interface.js";
3
4
  import "@next-core/theme";
5
+ import type { FormItemProps } from "../form-item/index.jsx";
4
6
  import { UseSingleBrickConf } from "@next-core/types";
5
- import { FormItemElement } from "../form-item/FormItemElement.js";
6
- import type { Form } from "../form/index.jsx";
7
7
  interface CustomOptions {
8
8
  url: string;
9
9
  description?: string;
@@ -14,132 +14,94 @@ interface CustomOptions {
14
14
  }
15
15
  export interface RadioProps {
16
16
  type?: RadioType;
17
- curElement: HTMLElement;
18
- formElement: Form;
19
17
  options: GeneralOption[] | CustomOptions[] | undefined;
20
18
  value?: any;
21
- name?: string;
22
19
  disabled?: boolean;
23
20
  buttonStyle?: RadioGroupButtonStyle;
24
- size?: "large" | "medium" | "small";
21
+ size?: ComponentSize;
25
22
  ui?: UIType;
26
23
  useBrick?: UseSingleBrickConf;
27
24
  customStyle?: React.CSSProperties;
28
- label?: string;
29
- trigger?: string;
30
- onChange?: (value: any) => void;
31
- optionsChange?: (options: any, name: string) => void;
25
+ }
26
+ export interface RadioEvents {
27
+ change: CustomEvent<GeneralComplexOption["value"]>;
28
+ optionsChange: CustomEvent<{
29
+ options: GeneralComplexOption[];
30
+ name: string;
31
+ }>;
32
+ }
33
+ export interface RadioEventsMapping {
34
+ onValueChange: "change";
35
+ onOptionsChange: "optionsChange";
32
36
  }
33
37
  /**
34
- * @id form.general-radio
35
- * @name form.general-radio
36
- * @docKind brick
37
- * @description 通用单选构件
38
+ * 通用单选构件
38
39
  * @author sailor
39
- * @noInheritDoc
40
40
  */
41
- declare class Radio extends FormItemElement {
41
+ declare class Radio extends FormItemElementBase {
42
42
  #private;
43
43
  /**
44
- * @kind string
45
- * @required true
46
- * @default -
47
- * @description 下拉框字段名
48
- * @group basicFormItem
44
+ * 下拉框字段名
49
45
  */
50
46
  accessor name: string | undefined;
51
47
  /**
52
- * @kind string
53
- * @required false
54
- * @default -
55
- * @description 单选框字段说明
56
- * @group basic
48
+ * 单选框字段说明
57
49
  */
58
50
  accessor label: string | undefined;
59
51
  /**
60
- * @required true
61
- * @default -
62
- * @description 单选框选项表,RadioType为default时,如果设置了tooltip值,可以设置tooltipIcon图标(MenuIcon 类型),tooltipIcon颜色默认为--color-secondary-text。
63
- * @group basic
52
+ * 单选框选项表
53
+ * @required
64
54
  */
65
55
  accessor options: GeneralOption[] | undefined;
66
56
  /**
67
- * @kind string
68
- * @required true
69
- * @default -
70
- * @description 单选框当前选中始值
71
- * @group basic
57
+ * 单选框当前选中始值
72
58
  */
73
59
  accessor value: any | undefined;
74
60
  /**
75
- * @kind boolean
76
- * @required false
77
- * @default -
78
- * @description 是否必填项
79
- * @group basicFormItem
61
+ * 是否必填
80
62
  */
81
63
  accessor required: boolean | undefined;
82
64
  /**
83
- * @kind Record<string,string>
84
- * @required false
85
- * @default -
86
- * @description 校验文本信息
87
- * @group basicFormItem
65
+ * 校验文本信息
88
66
  */
89
67
  accessor message: Record<string, string> | undefined;
90
68
  /**
91
- * @kind boolean
92
- * @required false
93
- * @default false
94
- * @description 是否禁用
95
- * @group basic
69
+ * 是否禁用
96
70
  */
97
71
  accessor disabled: boolean | undefined;
98
72
  /**
99
- * @kind RadioType
100
- * @required false
101
- * @default default
102
- * @description 单选框样式类型
103
- * @enums "button"|"default"|"icon"|"icon-circle"|"icon-square"|"custom"
104
- * @group basic
73
+ * 单选框样式类型
74
+ * @default "default"
105
75
  */
106
76
  accessor type: RadioType | undefined;
107
77
  /**
108
- * @kind UIType
109
- * @required false
110
- * @default default
111
- * @description Ui样式,可选择 `dashboard` 样式,默认`default`
112
- * @group ui
78
+ * UI样式
79
+ * @default "default"
113
80
  */
114
81
  accessor ui: UIType | undefined;
115
82
  /**
116
- * @kind "large" | "medium" | "small"
117
- * @required false
118
- * @default -
119
- * @description 大小,只对按钮样式生效
120
- * @enums "large"|"medium"|"small"
121
- * @group ui
83
+ * 大小,只对按钮样式生效
84
+ * @default "medium"
122
85
  */
123
- accessor size: "large" | "medium" | "small" | undefined;
86
+ accessor size: ComponentSize | undefined;
124
87
  /**
125
- * @kind customStyle
126
- * @required false
127
- * @default -
128
- * @description 自定义radio的外层样式
129
- * @group ui
88
+ * 自定义radio的外层样式
130
89
  */
131
90
  accessor customStyle: React.CSSProperties | undefined;
132
91
  /**
133
- * @kind `{useBrick: UseSingleBrickConf }`
134
- * @required false
135
- * @default
136
- * @description 自定义radio的内容
137
- * @group advancedFormItem
92
+ * 自定义radio的内容
138
93
  */
139
94
  accessor useBrick: UseSingleBrickConf | undefined;
140
- private _handleChange;
141
- private _handleOptionsChange;
95
+ handleChange: (item: {
96
+ [key: string]: any;
97
+ label: string;
98
+ value: any;
99
+ }) => void;
142
100
  render(): JSX.Element;
143
101
  }
144
- export declare function RadioComponent(props: RadioProps): JSX.Element;
102
+ interface RadioComponentProps extends RadioProps, FormItemProps {
103
+ onChange?: (value: any) => void;
104
+ optionsChange?: (options: any, name: string) => void;
105
+ }
106
+ export declare function RadioComponent(props: RadioComponentProps): JSX.Element;
145
107
  export { Radio };