@next-bricks/form 0.7.0 → 0.9.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 (124) hide show
  1. package/dist/bricks.json +14 -3
  2. package/dist/chunks/1970.0822d198.js +3 -0
  3. package/dist/chunks/{1970.1bf0f5c1.js.map → 1970.0822d198.js.map} +1 -1
  4. package/dist/chunks/{2179.5d5ada16.js → 2179.3b96e562.js} +2 -2
  5. package/dist/chunks/{2179.5d5ada16.js.map → 2179.3b96e562.js.map} +1 -1
  6. package/dist/chunks/3494.9671fa1c.js +2 -0
  7. package/dist/chunks/{3494.81238413.js.map → 3494.9671fa1c.js.map} +1 -1
  8. package/dist/chunks/3914.8c8cac45.js +2 -0
  9. package/dist/chunks/3914.8c8cac45.js.map +1 -0
  10. package/dist/chunks/{4049.416a9754.js → 4049.6b24a76c.js} +2 -2
  11. package/dist/chunks/4049.6b24a76c.js.map +1 -0
  12. package/dist/chunks/4131.f90b50ba.js +2 -0
  13. package/dist/chunks/4131.f90b50ba.js.map +1 -0
  14. package/dist/chunks/4275.1ece246a.js +2 -0
  15. package/dist/chunks/4275.1ece246a.js.map +1 -0
  16. package/dist/chunks/5202.8f6dfe2d.js +2 -0
  17. package/dist/chunks/{5202.e887583f.js.map → 5202.8f6dfe2d.js.map} +1 -1
  18. package/dist/chunks/5456.0831262b.js +2 -0
  19. package/dist/chunks/5456.0831262b.js.map +1 -0
  20. package/dist/chunks/5637.8cd320b2.js +2 -0
  21. package/dist/chunks/{5637.2b1b90a3.js.map → 5637.8cd320b2.js.map} +1 -1
  22. package/dist/chunks/5725.24821b6b.js +2 -0
  23. package/dist/chunks/5725.24821b6b.js.map +1 -0
  24. package/dist/chunks/{6205.e5f8de3e.js → 6205.61d1edba.js} +2 -2
  25. package/dist/chunks/{6205.e5f8de3e.js.map → 6205.61d1edba.js.map} +1 -1
  26. package/dist/chunks/{6473.c342ff08.js → 6473.0f2dffe6.js} +2 -2
  27. package/dist/chunks/6473.0f2dffe6.js.map +1 -0
  28. package/dist/chunks/{7164.c5911296.js → 7164.af951c22.js} +2 -2
  29. package/dist/chunks/{7164.c5911296.js.map → 7164.af951c22.js.map} +1 -1
  30. package/dist/chunks/7325.90c2d158.js +2 -0
  31. package/dist/chunks/7325.90c2d158.js.map +1 -0
  32. package/dist/chunks/737.1aa717c1.js +2 -0
  33. package/dist/chunks/737.1aa717c1.js.map +1 -0
  34. package/dist/chunks/7672.2ce388a3.js +2 -0
  35. package/dist/chunks/7672.2ce388a3.js.map +1 -0
  36. package/dist/chunks/7822.423152e2.js +2 -0
  37. package/dist/chunks/{7822.8c36398f.js.map → 7822.423152e2.js.map} +1 -1
  38. package/dist/chunks/873.2b11a4db.js +2 -0
  39. package/dist/chunks/{873.cc3010b0.js.map → 873.2b11a4db.js.map} +1 -1
  40. package/dist/chunks/9549.35485e5a.js +2 -0
  41. package/dist/chunks/{9549.530da202.js.map → 9549.35485e5a.js.map} +1 -1
  42. package/dist/chunks/dynamic-form-item.ad6d3b10.js +2 -0
  43. package/dist/chunks/{dynamic-form-item.f3f40a4e.js.map → dynamic-form-item.ad6d3b10.js.map} +1 -1
  44. package/dist/chunks/general-checkbox.997a7827.js +3 -0
  45. package/dist/chunks/{general-checkbox.81d8d8d1.js.map → general-checkbox.997a7827.js.map} +1 -1
  46. package/dist/chunks/general-form.4d14b937.js +2 -0
  47. package/dist/chunks/{general-form.03de30e1.js.map → general-form.4d14b937.js.map} +1 -1
  48. package/dist/chunks/general-input.b61b949e.js +3 -0
  49. package/dist/chunks/{general-input.1e2be165.js.map → general-input.b61b949e.js.map} +1 -1
  50. package/dist/chunks/general-radio.612dda8e.js +3 -0
  51. package/dist/chunks/{general-radio.f5b2b849.js.map → general-radio.612dda8e.js.map} +1 -1
  52. package/dist/chunks/general-select.73da9dc8.js +3 -0
  53. package/dist/chunks/{general-select.b806fc3d.js.map → general-select.73da9dc8.js.map} +1 -1
  54. package/dist/chunks/general-switch.0463658f.js +3 -0
  55. package/dist/chunks/general-switch.0463658f.js.map +1 -0
  56. package/dist/chunks/general-textarea.82fcd5ff.js +3 -0
  57. package/dist/chunks/{general-textarea.ce42122f.js.map → general-textarea.82fcd5ff.js.map} +1 -1
  58. package/dist/chunks/icon-select.4a1e136f.js +3 -0
  59. package/dist/chunks/icon-select.4a1e136f.js.LICENSE.txt +5 -0
  60. package/dist/chunks/{icon-select.c1e34968.js.map → icon-select.4a1e136f.js.map} +1 -1
  61. package/dist/chunks/main.b90b1d65.js +2 -0
  62. package/dist/chunks/main.b90b1d65.js.map +1 -0
  63. package/dist/chunks/submit-buttons.95d58206.js +2 -0
  64. package/dist/chunks/{submit-buttons.0a2d1413.js.map → submit-buttons.95d58206.js.map} +1 -1
  65. package/dist/chunks/upload-image.4cb5e7d4.js +3 -0
  66. package/dist/chunks/upload-image.4cb5e7d4.js.LICENSE.txt +5 -0
  67. package/dist/chunks/upload-image.4cb5e7d4.js.map +1 -0
  68. package/dist/index.0cfc8b9e.js +2 -0
  69. package/dist/index.0cfc8b9e.js.map +1 -0
  70. package/dist/manifest.json +209 -90
  71. package/dist/types.json +920 -0
  72. package/dist-types/bootstrap.d.ts +2 -0
  73. package/dist-types/general-switch/index.d.ts +64 -0
  74. package/dist-types/general-switch/index.spec.d.ts +1 -0
  75. package/dist-types/upload/Upload.d.ts +22 -0
  76. package/dist-types/upload/Upload.spec.d.ts +1 -0
  77. package/dist-types/upload/upload-image/i18n.d.ts +13 -0
  78. package/dist-types/upload/upload-image/index.d.ts +55 -0
  79. package/dist-types/upload/upload-image/index.spec.d.ts +1 -0
  80. package/dist-types/upload/utils.d.ts +27 -0
  81. package/docs/general-switch.md +77 -0
  82. package/docs/upload-image.md +14 -0
  83. package/package.json +3 -3
  84. package/dist/chunks/1970.1bf0f5c1.js +0 -3
  85. package/dist/chunks/2323.2e361aa7.js +0 -2
  86. package/dist/chunks/2323.2e361aa7.js.map +0 -1
  87. package/dist/chunks/3494.81238413.js +0 -2
  88. package/dist/chunks/3914.2e2d5e08.js +0 -2
  89. package/dist/chunks/3914.2e2d5e08.js.map +0 -1
  90. package/dist/chunks/4049.416a9754.js.map +0 -1
  91. package/dist/chunks/4131.cd33579d.js +0 -2
  92. package/dist/chunks/4131.cd33579d.js.map +0 -1
  93. package/dist/chunks/4356.e66da273.js +0 -2
  94. package/dist/chunks/4356.e66da273.js.map +0 -1
  95. package/dist/chunks/4728.645efaf1.js +0 -2
  96. package/dist/chunks/4728.645efaf1.js.map +0 -1
  97. package/dist/chunks/4795.90b6991e.js +0 -2
  98. package/dist/chunks/4795.90b6991e.js.map +0 -1
  99. package/dist/chunks/5202.e887583f.js +0 -2
  100. package/dist/chunks/5637.2b1b90a3.js +0 -2
  101. package/dist/chunks/6473.c342ff08.js.map +0 -1
  102. package/dist/chunks/7822.8c36398f.js +0 -2
  103. package/dist/chunks/873.cc3010b0.js +0 -2
  104. package/dist/chunks/9549.530da202.js +0 -2
  105. package/dist/chunks/dynamic-form-item.f3f40a4e.js +0 -2
  106. package/dist/chunks/general-checkbox.81d8d8d1.js +0 -3
  107. package/dist/chunks/general-form.03de30e1.js +0 -2
  108. package/dist/chunks/general-input.1e2be165.js +0 -3
  109. package/dist/chunks/general-radio.f5b2b849.js +0 -3
  110. package/dist/chunks/general-select.b806fc3d.js +0 -3
  111. package/dist/chunks/general-textarea.ce42122f.js +0 -3
  112. package/dist/chunks/icon-select.c1e34968.js +0 -3
  113. package/dist/chunks/main.ba6d4ded.js +0 -2
  114. package/dist/chunks/main.ba6d4ded.js.map +0 -1
  115. package/dist/chunks/submit-buttons.0a2d1413.js +0 -2
  116. package/dist/index.a93d21e4.js +0 -2
  117. package/dist/index.a93d21e4.js.map +0 -1
  118. /package/dist/chunks/{1970.1bf0f5c1.js.LICENSE.txt → 1970.0822d198.js.LICENSE.txt} +0 -0
  119. /package/dist/chunks/{general-checkbox.81d8d8d1.js.LICENSE.txt → general-checkbox.997a7827.js.LICENSE.txt} +0 -0
  120. /package/dist/chunks/{general-input.1e2be165.js.LICENSE.txt → general-input.b61b949e.js.LICENSE.txt} +0 -0
  121. /package/dist/chunks/{general-radio.f5b2b849.js.LICENSE.txt → general-radio.612dda8e.js.LICENSE.txt} +0 -0
  122. /package/dist/chunks/{general-select.b806fc3d.js.LICENSE.txt → general-select.73da9dc8.js.LICENSE.txt} +0 -0
  123. /package/dist/chunks/{general-textarea.ce42122f.js.LICENSE.txt → general-switch.0463658f.js.LICENSE.txt} +0 -0
  124. /package/dist/chunks/{icon-select.c1e34968.js.LICENSE.txt → general-textarea.82fcd5ff.js.LICENSE.txt} +0 -0
@@ -10,3 +10,5 @@ import "./code-editor/index.js";
10
10
  import "./dynamic-form-item/index.js";
11
11
  import "./search/index.js";
12
12
  import "./icon-select/index.js";
13
+ import "./upload/upload-image/index.js";
14
+ import "./general-switch/index.js";
@@ -0,0 +1,64 @@
1
+ /// <reference types="react" />
2
+ import "@next-core/theme";
3
+ import { FormItemElementBase } from "@next-shared/form";
4
+ import type { FormItemProps } from "../form-item/index.js";
5
+ import type { GeneralIconProps } from "@next-bricks/icons/general-icon";
6
+ import type { ComponentSize } from "../interface.js";
7
+ interface SwitchProps extends FormItemProps {
8
+ curElement: HTMLElement;
9
+ onSwitch: (value: boolean) => void;
10
+ disabled?: boolean;
11
+ size?: ComponentSize;
12
+ value?: boolean;
13
+ checkedText?: string;
14
+ unCheckedText?: string;
15
+ checkedIcon?: GeneralIconProps;
16
+ unCheckedIcon?: GeneralIconProps;
17
+ }
18
+ /**
19
+ * 构件 general-switch
20
+ * @author zhendonghuang
21
+ */
22
+ export declare class GeneralSwitch extends FormItemElementBase {
23
+ #private;
24
+ /**
25
+ * 字段名称
26
+ */
27
+ accessor name: string | undefined;
28
+ /**
29
+ * 字段文本
30
+ */
31
+ accessor label: string | undefined;
32
+ /**
33
+ * 初始值
34
+ */
35
+ accessor value: boolean | undefined;
36
+ /**
37
+ * 是否禁用
38
+ */
39
+ accessor disabled: boolean | undefined;
40
+ /**
41
+ * 按钮大小,目前只支持small和非small两种大小。
42
+ */
43
+ accessor size: ComponentSize | undefined;
44
+ /**
45
+ * 选中时的文本
46
+ */
47
+ accessor checkedText: string | undefined;
48
+ /**
49
+ * 非选中时的文本
50
+ */
51
+ accessor unCheckedText: string | undefined;
52
+ /**
53
+ * 选中时的图标
54
+ */
55
+ accessor checkedIcon: GeneralIconProps | undefined;
56
+ /**
57
+ * 非选中时的文本
58
+ */
59
+ accessor unCheckedIcon: GeneralIconProps | undefined;
60
+ handleSwitch: (value: boolean) => void;
61
+ render(): JSX.Element;
62
+ }
63
+ export declare function GeneralSwitchComponent(props: SwitchProps): JSX.Element;
64
+ export {};
@@ -0,0 +1 @@
1
+ import "./";
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import "@next-core/theme";
3
+ import { type FileData } from "./utils.js";
4
+ export interface UploadActions {
5
+ upload: () => void;
6
+ }
7
+ export interface ItemActions {
8
+ remove: () => void;
9
+ }
10
+ export interface UploadProps {
11
+ uploadRender: (fileDataList: FileData[], actions: UploadActions) => React.ReactElement;
12
+ itemRender: (fileData: FileData, fileDataList: FileData[], actions: ItemActions) => React.ReactElement;
13
+ fileList?: FileData[];
14
+ autoUpload?: boolean;
15
+ uploadName?: string;
16
+ action?: string;
17
+ method?: string;
18
+ accept?: string;
19
+ multiple?: boolean;
20
+ onChange?: (fileDataList: FileData[]) => void;
21
+ }
22
+ export declare function Upload(props: UploadProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare enum K {
2
+ UPLOAD = "UPLOAD",
3
+ FILE_UPLOADING = "FILE_UPLOADING"
4
+ }
5
+ export declare const NS = "bricks/form/upload-image";
6
+ export declare const locales: {
7
+ en: Locale;
8
+ zh: Locale;
9
+ };
10
+ type Locale = {
11
+ [key in K]: string;
12
+ };
13
+ export {};
@@ -0,0 +1,55 @@
1
+ /// <reference types="react" />
2
+ import "@next-core/theme";
3
+ import { FormItemElementBase } from "@next-shared/form";
4
+ import type { FormItemProps } from "../../form-item/index.js";
5
+ import { type FileData } from "../utils.js";
6
+ export interface UploadImageProps {
7
+ label?: string;
8
+ name?: string;
9
+ required?: boolean;
10
+ message?: Record<string, string>;
11
+ value?: FileData[];
12
+ bucketName: string;
13
+ multiple?: boolean;
14
+ }
15
+ /**
16
+ * 上传图片构件
17
+ */
18
+ export declare class UploadImage extends FormItemElementBase implements UploadImageProps {
19
+ #private;
20
+ /**
21
+ * 字段名称
22
+ */
23
+ accessor name: string | undefined;
24
+ /**
25
+ * 字段说明
26
+ */
27
+ accessor label: string | undefined;
28
+ /**
29
+ * 值
30
+ */
31
+ accessor value: FileData[] | undefined;
32
+ /**
33
+ * 对象存储桶名字
34
+ */
35
+ accessor bucketName: string;
36
+ /**
37
+ * 是否支持选定的多张图片
38
+ */
39
+ accessor multiple: boolean | undefined;
40
+ /**
41
+ * 是否必填
42
+ */
43
+ accessor required: boolean | undefined;
44
+ /**
45
+ * 校验文本信息
46
+ */
47
+ accessor message: Record<string, string> | undefined;
48
+ handleChange: (fileDataList: FileData[]) => void;
49
+ render(): JSX.Element;
50
+ }
51
+ interface UploadImageComponentProps extends UploadImageProps, FormItemProps {
52
+ onChange?: (fileDataList: FileData[]) => void;
53
+ }
54
+ export declare function UploadImageComponent(props: UploadImageComponentProps): JSX.Element;
55
+ export {};
@@ -0,0 +1 @@
1
+ import "./index.jsx";
@@ -0,0 +1,27 @@
1
+ export declare const symbolForAbortController: unique symbol;
2
+ export declare const LIST_IGNORE: unique symbol;
3
+ export declare const getUid: () => string;
4
+ export declare const getImage: (file: string | File, revokeUrl?: boolean) => Promise<HTMLImageElement>;
5
+ export declare const acceptValidator: (file: File, accepts?: string | string[]) => boolean;
6
+ export declare const sizeValidator: (file: File, limitSize?: number) => Promise<unknown>;
7
+ export declare const imageValidator: (file: File, limit?: {
8
+ width?: number;
9
+ height?: number;
10
+ }) => Promise<unknown>;
11
+ export declare const getUserData: (file: File) => Promise<{
12
+ url: string;
13
+ naturalWidth: number;
14
+ naturalHeight: number;
15
+ }>;
16
+ export type UploadStatus = "uploading" | "done" | "error";
17
+ export interface FileData {
18
+ uid?: string;
19
+ file?: File & {
20
+ uid?: string;
21
+ };
22
+ response?: any;
23
+ userData?: any;
24
+ status?: UploadStatus;
25
+ errors?: Error[];
26
+ [symbolForAbortController]?: AbortController;
27
+ }
@@ -0,0 +1,77 @@
1
+ 开关构件
2
+
3
+ ## Examples
4
+
5
+ ### Basic
6
+
7
+ ```yaml preview
8
+ - brick: form.general-switch
9
+ events:
10
+ switch:
11
+ action: console.log
12
+ properties:
13
+ disabled: false
14
+ ```
15
+
16
+ ### Label
17
+
18
+ ```yaml preview
19
+ - brick: form.general-switch
20
+ events:
21
+ switch:
22
+ action: console.log
23
+ properties:
24
+ disabled: false
25
+ label: switch
26
+ ```
27
+
28
+ ### disabled
29
+
30
+ ```yaml preview
31
+ - brick: form.general-switch
32
+ properties:
33
+ disabled: true
34
+ value: true
35
+ label: switch
36
+ ```
37
+
38
+ ### size
39
+
40
+ ```yaml preview
41
+ - brick: form.general-switch
42
+ properties:
43
+ disabled: false
44
+ value: true
45
+ label: switch
46
+ size: small
47
+ ```
48
+
49
+ ### cheeckText、unCheckedText、checkedIcon、unCheckedIcon
50
+
51
+ ```yaml preview
52
+ - brick: form.general-switch
53
+ properties:
54
+ checkedText: 123
55
+ unCheckedText: 456
56
+ disabled: false
57
+ size: small
58
+ label: text
59
+ checkedIcon:
60
+ icon: plus-circle
61
+ lib: antd
62
+ theme: outlined
63
+ unCheckedIcon:
64
+ icon: plus-circle
65
+ lib: antd
66
+ ```
67
+
68
+ ### Event
69
+
70
+ ```yaml preview
71
+ - brick: form.general-switch
72
+ events:
73
+ switch:
74
+ action: console.log
75
+ properties:
76
+ disabled: false
77
+ ```
@@ -0,0 +1,14 @@
1
+ 上传图片构件
2
+
3
+ ## Examples
4
+
5
+ ### Basic
6
+
7
+ ```yaml preview
8
+ - brick: form.upload-image
9
+ events:
10
+ change:
11
+ action: console.log
12
+ args:
13
+ - "<% EVENT.detail %>"
14
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-bricks/form",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-bricks/tree/master/bricks/form",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "postpublish": "mv package.json.bak package.json"
35
35
  },
36
36
  "devDependencies": {
37
- "@next-core/build-next-bricks": "^1.7.2",
37
+ "@next-core/build-next-bricks": "^1.9.0",
38
38
  "@next-core/test-next": "^1.0.6"
39
39
  },
40
- "gitHead": "e0b6af107201669c9582d59553d8ef4316ce64f0"
40
+ "gitHead": "17a18f696648ddc1417ec395d5b46a28a9dc386c"
41
41
  }