react-antd-xform 1.0.4 → 1.0.6

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 (28) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_virtual/_commonjsHelpers.js +2 -0
  3. package/dist/_virtual/dayjs.min.js +4 -0
  4. package/dist/_virtual/isoWeek.js +4 -0
  5. package/dist/_virtual/weekOfYear.js +4 -0
  6. package/dist/_virtual/weekYear.js +4 -0
  7. package/dist/form/context/formEnvContext.js +2 -1
  8. package/dist/form/extend/form-layout.d.ts +1 -3
  9. package/dist/form/extend/form-layout.js +0 -10
  10. package/dist/form/form-item.js +9 -4
  11. package/dist/form/index.d.ts +1 -1
  12. package/dist/form/index.js +2 -1
  13. package/dist/form/type.d.ts +11 -12
  14. package/dist/form-ui/common-utils.d.ts +34 -0
  15. package/dist/form-ui/common-utils.js +272 -1
  16. package/dist/form-ui/default-component.d.ts +9 -2
  17. package/dist/form-ui/default-component.js +87 -58
  18. package/dist/node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js +282 -0
  19. package/dist/node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/isoWeek.js +33 -0
  20. package/dist/node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekOfYear.js +29 -0
  21. package/dist/node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekYear.js +19 -0
  22. package/dist/node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/useObserver.js +3 -3
  23. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js +3 -3
  24. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js +2 -2
  25. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +4 -4
  26. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +4 -4
  27. package/package.json +15 -16
  28. package/README.md +0 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 knowledge is limitless
3
+ Copyright (c) JHuaZhang
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,8 @@
1
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1
2
  function getDefaultExportFromCjs(x) {
2
3
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
3
4
  }
4
5
  export {
6
+ commonjsGlobal,
5
7
  getDefaultExportFromCjs
6
8
  };
@@ -0,0 +1,4 @@
1
+ var dayjs_min = { exports: {} };
2
+ export {
3
+ dayjs_min as __module
4
+ };
@@ -0,0 +1,4 @@
1
+ var isoWeek = { exports: {} };
2
+ export {
3
+ isoWeek as __module
4
+ };
@@ -0,0 +1,4 @@
1
+ var weekOfYear = { exports: {} };
2
+ export {
3
+ weekOfYear as __module
4
+ };
@@ -0,0 +1,4 @@
1
+ var weekYear = { exports: {} };
2
+ export {
3
+ weekYear as __module
4
+ };
@@ -6,7 +6,8 @@ const FormEnvContext = createContext({
6
6
  validateOnBlur: true,
7
7
  validateOnChange: true,
8
8
  writeDefaultValueToModel: false,
9
- autoUnmount: false
9
+ autoUnmount: false,
10
+ variant: "outlined"
10
11
  });
11
12
  FormEnvContext.displayName = "FormEnvContext";
12
13
  const useFormEnv = () => useContext(FormEnvContext);
@@ -1,4 +1,2 @@
1
- import { FormLayoutProps, FormItemGroupProps } from '../type';
1
+ import { FormLayoutProps } from '../type';
2
2
  export declare function FormLayout({ children, className, style, labelPosition, labelWidth, formItemGap, controlWidth, defaultLabelTopPosition, inlineError, containerProps, }: FormLayoutProps): import("react/jsx-runtime").JSX.Element;
3
- /** @deprecated 请使用 Form.ItemView 代替 ItemGroup */
4
- export declare const FormItemGroup: ({ label, asterisk, tip, children, labelWidth, controlWidth, className, style, inline, }: FormItemGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -165,16 +165,6 @@ function FormLayout({
165
165
  }
166
166
  );
167
167
  }
168
- styled.div`
169
- ${FormLayoutContainer}.horizontal & {
170
- display: flex;
171
- }
172
- &.inline {
173
- .form-item-group-content {
174
- display: flex;
175
- }
176
- }
177
- `;
178
168
  export {
179
169
  FormLayout
180
170
  };
@@ -1,5 +1,5 @@
1
1
  import { j as jsxRuntimeExports } from "../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
2
- import require$$0, { useLayoutEffect, useEffect } from "react";
2
+ import React, { useLayoutEffect, useEffect } from "react";
3
3
  import cx from "../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
4
4
  import "../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
5
5
  import stringifyObject from "../node_modules/.pnpm/stringify-object@5.0.0/node_modules/stringify-object/index.js";
@@ -12,7 +12,7 @@ import { useFormEnv } from "./context/formEnvContext.js";
12
12
  import { ALL_COMPONENTS } from "../form-ui/default-component.js";
13
13
  import { observer } from "../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
14
14
  function processCreationOptions(options) {
15
- const render = options.render ?? ((props) => require$$0.createElement(options.component, props));
15
+ const render = options.render ?? ((props) => React.createElement(options.component, props));
16
16
  return {
17
17
  name: options.name,
18
18
  hidden: options.hidden,
@@ -253,6 +253,8 @@ const Hidden = createFormItem({
253
253
  }
254
254
  });
255
255
  function FormItem({ use, component, ...props }) {
256
+ const formEnv = useFormEnv();
257
+ const variant = formEnv.variant;
256
258
  if (use === false) {
257
259
  return null;
258
260
  }
@@ -266,13 +268,16 @@ function FormItem({ use, component, ...props }) {
266
268
  if (Comp == null) {
267
269
  return /* @__PURE__ */ jsxRuntimeExports.jsx(NotFound, { ...props, componentProps: { $Component: component } });
268
270
  }
269
- return require$$0.createElement(Comp, props);
271
+ return React.createElement(Comp, {
272
+ ...props,
273
+ componentProps: { ...props.componentProps, variant }
274
+ });
270
275
  } else {
271
276
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
272
277
  AnonymousFormItem,
273
278
  {
274
279
  ...props,
275
- componentProps: { ...props.componentProps, $Component: component }
280
+ componentProps: { ...props.componentProps, variant, $Component: component }
276
281
  }
277
282
  );
278
283
  }
@@ -4,7 +4,7 @@ import { FormModel } from './model';
4
4
  import { FormItemView } from './form-item';
5
5
  import { FormLayout } from './extend/form-layout';
6
6
  import { FormSubmit } from './extend/form-submit';
7
- export declare function Form({ model: modelProp, defaultValue, children, className, style, layout, containerProps, htmlIdPrefix: htmlIdPrefixProp, ...restEnvProps }: FormProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Form({ model: modelProp, defaultValue, children, className, style, layout, containerProps, htmlIdPrefix: htmlIdPrefixProp, variant, ...restEnvProps }: FormProps): import("react/jsx-runtime").JSX.Element;
8
8
  export declare namespace Form {
9
9
  var Array: (<T extends unknown>({ name, children, layout, arrayModel: arrayModelProp, use, }: import("./extend/form-array").FormArrayProps<T>) => import("react/jsx-runtime").JSX.Element) & {
10
10
  displayName: string;
@@ -22,12 +22,13 @@ function Form({
22
22
  layout,
23
23
  containerProps,
24
24
  htmlIdPrefix: htmlIdPrefixProp,
25
+ variant,
25
26
  ...restEnvProps
26
27
  }) {
27
28
  const [_model] = useState(() => new FormModel(defaultValue));
28
29
  const model = composeValue(modelProp, _model);
29
30
  const htmlIdPrefix = useHtmlIdPrefix(htmlIdPrefixProp);
30
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormEnvProvider, { htmlIdPrefix, ...restEnvProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ModelProvider, { value: model, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { style, className, containerProps, ...layout, children }) }) });
31
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormEnvProvider, { htmlIdPrefix, variant, ...restEnvProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ModelProvider, { value: model, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { style, className, containerProps, ...layout, children }) }) });
31
32
  }
32
33
  Form.Array = FormArray;
33
34
  Form.Check = FormCheck;
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
2
2
  import { Field, FormModel } from './model';
3
3
  import { FieldType, ModelType } from './enum';
4
4
  import { AsyncValue } from './helpers/AsyncValue';
5
+ export declare const Variants: readonly ["outlined", "borderless", "filled", "underlined"];
6
+ export type Variant = (typeof Variants)[number];
5
7
  type valueOf<T> = T[keyof T];
6
8
  export type XName<D> = 0 extends D & 1 ? any : D extends (infer U)[] ? number | `${number}` | `${number}.${XName<U>}` : D extends object ? valueOf<{
7
9
  [K in keyof D & string]: K | `${K}.${XName<D[K]>}`;
@@ -117,6 +119,10 @@ export interface FormEnvContextType {
117
119
  * @see https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/label
118
120
  * */
119
121
  htmlIdPrefix?: string;
122
+ /**
123
+ * 表单样式参数 from antd
124
+ * */
125
+ variant?: Variant;
120
126
  }
121
127
  export interface FormLayoutParams {
122
128
  /** 标签位置,可选 'left' 或 'top' */
@@ -150,6 +156,10 @@ export interface FormProps extends FormEnvContextType {
150
156
  * */
151
157
  layout?: FormLayoutParams;
152
158
  children?: React.ReactNode;
159
+ /**
160
+ * 表单样式参数 from antd
161
+ * */
162
+ variant?: Variant;
153
163
  }
154
164
  export interface FormLayoutParams {
155
165
  /** 标签位置,可选 'left' 或 'top' */
@@ -170,18 +180,6 @@ export interface FormLayoutProps extends Partial<FormLayoutParams> {
170
180
  containerProps?: any;
171
181
  defaultLabelTopPosition?: number | string;
172
182
  }
173
- export interface FormItemGroupProps {
174
- label?: React.ReactNode;
175
- tip?: React.ReactNode;
176
- asterisk?: boolean;
177
- children?: React.ReactNode;
178
- labelWidth?: number | string;
179
- labelTopPosition?: number | string;
180
- controlWidth?: number | string;
181
- className?: string;
182
- style?: React.CSSProperties;
183
- inline?: boolean;
184
- }
185
183
  export interface FormItemComponentProps {
186
184
  value?: any;
187
185
  onChange?(...args: any[]): void;
@@ -237,6 +235,7 @@ export interface FormItemProps extends Omit<FieldConfig<any>, 'defaultValueProp'
237
235
  controlStyle?: React.CSSProperties;
238
236
  rightNode?: React.ReactNode;
239
237
  isPreview?: boolean;
238
+ variant?: Variant;
240
239
  }
241
240
  export interface FormItemViewProps {
242
241
  /** `<label />` 的 id 属性 */
@@ -1,3 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { ColorPicker } from 'antd';
3
+ import { ColorPickerProps } from 'antd/es/color-picker';
1
4
  export declare function isEmptyValue(value: any): boolean;
2
5
  /**
3
6
  * antd中某些组件的onChange并不是直接返回value,而是e.target.value
@@ -7,3 +10,34 @@ export declare const withValueChangeHandler: <T extends {
7
10
  }>(Component: React.ComponentType<T>) => (props: Omit<T, "onChange"> & {
8
11
  onChange?: (value: any) => void;
9
12
  }) => import("react/jsx-runtime").JSX.Element;
13
+ /**
14
+ * date日期选择器兼容
15
+ */
16
+ export declare const withDayjsTransformAntdDate: (Component: React.ComponentType<any>) => (props: any) => import("react/jsx-runtime").JSX.Element;
17
+ /**
18
+ * dateRangePicker兼容
19
+ */
20
+ export declare const withDayjsTransformAntdDateRangePicker: (Component: React.ComponentType<any>) => (props: any) => import("react/jsx-runtime").JSX.Element;
21
+ /**
22
+ * timer选择器兼容
23
+ */
24
+ export declare const withDayjsTransformAntdTime: (Component: React.ComponentType<any>) => (props: any) => import("react/jsx-runtime").JSX.Element;
25
+ /**
26
+ * timerPicker选择器兼容
27
+ */
28
+ export declare const withDayjsTransformAntdTimeRange: (Component: React.ComponentType<any>) => (props: any) => import("react/jsx-runtime").JSX.Element;
29
+ /**
30
+ * 向组件中注入props
31
+ */
32
+ export declare const withInjectedProps: (injectedProps: Record<string, any>) => (Component: React.ComponentType<any>) => React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<any>>;
33
+ /**
34
+ * 用于处理Antd ColorPicker的onChange返回值格式
35
+ * 根据 returnType 返回指定格式的值(如 hex、rgb、hsb)
36
+ */
37
+ type ColorReturnType = 'hex' | 'rgb' | 'hsv';
38
+ interface ColorPickerWrapperProps extends Omit<ColorPickerProps, 'onChange'> {
39
+ onChange?: (value: string) => void;
40
+ returnType?: ColorReturnType;
41
+ }
42
+ export declare const withColorPickerHandler: (Component: typeof ColorPicker) => ({ onChange, returnType, ...props }: ColorPickerWrapperProps) => import("react/jsx-runtime").JSX.Element;
43
+ export {};
@@ -1,7 +1,26 @@
1
1
  import { j as jsxRuntimeExports } from "../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
2
+ import React, { useMemo, useCallback } from "react";
3
+ import dayjs from "../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js";
4
+ import isoweek from "../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/isoWeek.js";
5
+ import weekYear from "../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekYear.js";
6
+ import weekOfYear from "../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekOfYear.js";
7
+ dayjs.extend(weekOfYear);
8
+ dayjs.extend(weekYear);
9
+ dayjs.extend(isoweek);
2
10
  function isEmptyValue(value) {
3
- return value == null || value === "";
11
+ return !value && value !== 0 || Array.isArray(value) && value.length === 0;
4
12
  }
13
+ const DEFAULT_FORMAT_TIME = "HH:mm:ss";
14
+ const DEFAULT_FORMATS = {
15
+ date: "YYYY-MM-DD",
16
+ week: "gggg-[W]W",
17
+ // 输出: 2025-W37
18
+ month: "YYYY-MM",
19
+ quarter: "YYYY-[Q]Q",
20
+ // 输出: 2025-Q3
21
+ year: "YYYY"
22
+ };
23
+ const isEmptyDateValue = (val) => val == null || val === "" || Array.isArray(val) && val.length === 2 && !val[0] && !val[1];
5
24
  const withValueChangeHandler = (Component) => {
6
25
  return (props) => {
7
26
  const handleChange = (e) => {
@@ -11,7 +30,259 @@ const withValueChangeHandler = (Component) => {
11
30
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...props, onChange: handleChange });
12
31
  };
13
32
  };
33
+ const withDayjsTransformAntdDate = (Component) => {
34
+ return (props) => {
35
+ const { value, onChange, picker, ...restProps } = props;
36
+ const parsedValue = useMemo(() => {
37
+ if (!value) return void 0;
38
+ if (picker === "week") {
39
+ const [year, weekStr] = value.split("-");
40
+ const weekNumber = parseInt(weekStr, 10);
41
+ if (year && !isNaN(weekNumber)) {
42
+ return dayjs().year(parseInt(year, 10)).week(weekNumber).startOf("week");
43
+ }
44
+ } else if (picker === "month") {
45
+ return dayjs(value, "YYYY-MM");
46
+ } else if (picker === "quarter") {
47
+ return dayjs(value, "YYYY-[Q]Q");
48
+ } else if (picker === "year") {
49
+ return dayjs(value, "YYYY");
50
+ } else {
51
+ return dayjs(value);
52
+ }
53
+ return void 0;
54
+ }, [value, picker]);
55
+ const handleChange = useCallback(
56
+ (dayjsDate, dateString) => {
57
+ if (!dayjsDate || !dayjsDate.isValid()) {
58
+ onChange == null ? void 0 : onChange(null);
59
+ return;
60
+ }
61
+ let formattedValue;
62
+ if (picker === "week") {
63
+ const year = dayjsDate.year();
64
+ const week = dayjsDate.week();
65
+ formattedValue = `${year}-${week}`;
66
+ } else if (picker === "month") {
67
+ formattedValue = dayjsDate.format("YYYY-MM");
68
+ } else if (picker === "quarter") {
69
+ formattedValue = dayjsDate.format("YYYY-Q");
70
+ } else if (picker === "year") {
71
+ formattedValue = dayjsDate.format("YYYY");
72
+ } else {
73
+ formattedValue = dayjsDate.format("YYYY-MM-DD");
74
+ }
75
+ onChange == null ? void 0 : onChange(formattedValue);
76
+ },
77
+ [onChange, picker]
78
+ );
79
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...restProps, picker, value: parsedValue, onChange: handleChange });
80
+ };
81
+ };
82
+ const withDayjsTransformAntdDateRangePicker = (Component) => {
83
+ return (props) => {
84
+ const { value, onChange, format, picker = "date", ...restProps } = props;
85
+ const resolvedFormat = format || DEFAULT_FORMATS[picker] || DEFAULT_FORMATS.date;
86
+ const parsedValue = useMemo(() => {
87
+ if (isEmptyDateValue(value)) {
88
+ return null;
89
+ }
90
+ if (!Array.isArray(value)) {
91
+ return null;
92
+ }
93
+ const [startStr, endStr] = value;
94
+ if (isEmptyDateValue([startStr, endStr])) {
95
+ return null;
96
+ }
97
+ const parseValue = (str, type) => {
98
+ if (!str) return null;
99
+ switch (type) {
100
+ case "week": {
101
+ const match = str.match(/^(\d{4})-?W?(\d+)$/i);
102
+ if (!match) return null;
103
+ const year = parseInt(match[1], 10);
104
+ const week = parseInt(match[2], 10);
105
+ return dayjs().year(year).week(week).startOf("week");
106
+ }
107
+ case "month":
108
+ return dayjs(str, "YYYY-MM", true);
109
+ case "quarter": {
110
+ const match = str.match(/^(\d{4})-?Q?([1-4])$/i);
111
+ if (!match) return null;
112
+ const year = parseInt(match[1], 10);
113
+ const quarter = parseInt(match[2], 10);
114
+ const month = (quarter - 1) * 3;
115
+ return dayjs(`${year}-${String(month + 1).padStart(2, "0")}-01`, "YYYY-MM-DD", true);
116
+ }
117
+ case "year":
118
+ return dayjs(str, "YYYY", true);
119
+ case "date":
120
+ default:
121
+ return dayjs(str, resolvedFormat, true);
122
+ }
123
+ };
124
+ const start = parseValue(startStr, picker);
125
+ const end = parseValue(endStr, picker);
126
+ const isValidStart = start && start.isValid();
127
+ const isValidEnd = end && end.isValid();
128
+ if (!isValidStart && !isValidEnd) {
129
+ return null;
130
+ }
131
+ return [isValidStart ? start : null, isValidEnd ? end : null];
132
+ }, [value, picker, resolvedFormat]);
133
+ const handleChange = useCallback(
134
+ (dates, dateStrings) => {
135
+ if (!dates || !dates[0] && !dates[1]) {
136
+ onChange == null ? void 0 : onChange(null);
137
+ return;
138
+ }
139
+ const [start, end] = dates;
140
+ const formatValue = (dayjsObj, type) => {
141
+ if (!dayjsObj || !dayjsObj.isValid()) return "";
142
+ switch (type) {
143
+ case "week":
144
+ return `${dayjsObj.year()}-W${dayjsObj.week()}`;
145
+ case "month":
146
+ return dayjsObj.format("YYYY-MM");
147
+ case "quarter": {
148
+ const year = dayjsObj.year();
149
+ const quarter = Math.floor(dayjsObj.month() / 3) + 1;
150
+ return `${year}-Q${quarter}`;
151
+ }
152
+ case "year":
153
+ return dayjsObj.format("YYYY");
154
+ case "date":
155
+ default:
156
+ return dayjsObj.format(resolvedFormat);
157
+ }
158
+ };
159
+ const formatted = [formatValue(start, picker), formatValue(end, picker)];
160
+ if (!formatted[0] && !formatted[1]) {
161
+ onChange == null ? void 0 : onChange(null);
162
+ } else {
163
+ onChange == null ? void 0 : onChange(formatted);
164
+ }
165
+ },
166
+ [onChange, picker, resolvedFormat]
167
+ );
168
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
169
+ Component,
170
+ {
171
+ ...restProps,
172
+ picker,
173
+ format: resolvedFormat,
174
+ value: parsedValue,
175
+ onChange: handleChange,
176
+ allowClear: restProps.allowClear ?? true
177
+ }
178
+ );
179
+ };
180
+ };
181
+ const withDayjsTransformAntdTime = (Component) => {
182
+ return (props) => {
183
+ const { value, onChange, format = DEFAULT_FORMAT_TIME, ...restProps } = props;
184
+ const parsedValue = useMemo(() => {
185
+ if (!value) return void 0;
186
+ const stringValue = String(value).trim();
187
+ if (!stringValue) return void 0;
188
+ const parsed = dayjs(stringValue, format, true);
189
+ return parsed.isValid() ? parsed : void 0;
190
+ }, [value, format]);
191
+ const handleChange = useCallback(
192
+ (time, timeString) => {
193
+ if (!time || !time.isValid()) {
194
+ onChange == null ? void 0 : onChange(null);
195
+ return;
196
+ }
197
+ const formatted = time.format(format);
198
+ onChange == null ? void 0 : onChange(formatted);
199
+ },
200
+ [onChange, format]
201
+ );
202
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...restProps, format, value: parsedValue, onChange: handleChange });
203
+ };
204
+ };
205
+ const withDayjsTransformAntdTimeRange = (Component) => {
206
+ return (props) => {
207
+ const { value, onChange, format = DEFAULT_FORMAT_TIME, ...restProps } = props;
208
+ const parsedValue = useMemo(() => {
209
+ if (!value || !Array.isArray(value)) return void 0;
210
+ const [startStr, endStr] = value;
211
+ if (!startStr && !endStr) return void 0;
212
+ const start = startStr ? dayjs(startStr, format, true) : null;
213
+ const end = endStr ? dayjs(endStr, format, true) : null;
214
+ const isValidStart = start && start.isValid();
215
+ const isValidEnd = end && end.isValid();
216
+ if (!isValidStart && !isValidEnd) return void 0;
217
+ return [isValidStart ? start : null, isValidEnd ? end : null];
218
+ }, [value, format]);
219
+ const handleChange = useCallback(
220
+ (times, timeStrings) => {
221
+ if (!times) {
222
+ onChange == null ? void 0 : onChange(null);
223
+ return;
224
+ }
225
+ const [start, end] = times;
226
+ const formatted = [
227
+ (start == null ? void 0 : start.isValid()) ? start.format(format) : "",
228
+ (end == null ? void 0 : end.isValid()) ? end.format(format) : ""
229
+ ];
230
+ if (!formatted[0] && !formatted[1]) {
231
+ onChange == null ? void 0 : onChange(null);
232
+ } else {
233
+ onChange == null ? void 0 : onChange(formatted);
234
+ }
235
+ },
236
+ [onChange, format]
237
+ );
238
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...restProps, format, value: parsedValue, onChange: handleChange });
239
+ };
240
+ };
241
+ const withInjectedProps = (injectedProps) => {
242
+ return (Component) => {
243
+ const WrappedComponent = React.forwardRef((props, ref) => {
244
+ const mergedProps = { ...injectedProps, ...props };
245
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ref, ...mergedProps });
246
+ });
247
+ WrappedComponent.displayName = `WithInjectedProps(${Component.displayName || Component.name})`;
248
+ return WrappedComponent;
249
+ };
250
+ };
251
+ const withColorPickerHandler = (Component) => {
252
+ return ({
253
+ onChange,
254
+ returnType = "hex",
255
+ ...props
256
+ }) => {
257
+ const handleChange = (color) => {
258
+ if (!onChange) return;
259
+ let value;
260
+ switch (returnType) {
261
+ case "hex":
262
+ value = color.toHexString();
263
+ break;
264
+ case "rgb":
265
+ value = color.toRgbString();
266
+ break;
267
+ case "hsv":
268
+ const hsv = color.toHsb();
269
+ value = `hsv(${hsv.h}, ${hsv.s * 100}%, ${hsv.b * 100}%)`;
270
+ break;
271
+ default:
272
+ value = color.toHexString();
273
+ }
274
+ onChange(value);
275
+ };
276
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...props, onChange: handleChange });
277
+ };
278
+ };
14
279
  export {
15
280
  isEmptyValue,
281
+ withColorPickerHandler,
282
+ withDayjsTransformAntdDate,
283
+ withDayjsTransformAntdDateRangePicker,
284
+ withDayjsTransformAntdTime,
285
+ withDayjsTransformAntdTimeRange,
286
+ withInjectedProps,
16
287
  withValueChangeHandler
17
288
  };
@@ -1,2 +1,9 @@
1
- import { FormItemCreationOptions } from '../form/type';
2
- export declare const ALL_COMPONENTS: FormItemCreationOptions[];
1
+ import { isEmptyValue } from './common-utils';
2
+ declare const ALL_COMPONENTS: {
3
+ name: "input" | "textArea" | "radio" | "inputNumber" | "slider" | "switch" | "datePicker" | "dateRangePicker" | "timePicker" | "timeRangePicker" | "colorPicker" | "multiSelect" | "select" | "singleSelect" | "checkbox" | "rate";
4
+ component: any;
5
+ defaultValue: any;
6
+ isEmpty: typeof isEmptyValue;
7
+ hasIntrinsicWidth: false;
8
+ }[];
9
+ export { ALL_COMPONENTS };
@@ -1,63 +1,92 @@
1
- import { Select, Checkbox, InputNumber, Slider, Switch, Input, Radio } from "antd";
2
- import { isEmptyValue, withValueChangeHandler } from "./common-utils.js";
3
- const ALL_COMPONENTS = [
4
- {
5
- name: "input",
6
- component: withValueChangeHandler(Input),
7
- defaultValue: "",
8
- isEmpty: isEmptyValue,
9
- hasIntrinsicWidth: false
10
- },
11
- {
12
- name: "textArea",
13
- component: withValueChangeHandler(Input.TextArea),
14
- defaultValue: "",
15
- isEmpty: isEmptyValue,
16
- hasIntrinsicWidth: false
17
- },
18
- {
19
- name: "select",
20
- component: Select,
21
- defaultValue: "",
22
- isEmpty: isEmptyValue,
23
- hasIntrinsicWidth: false
24
- },
25
- {
26
- name: "radio",
27
- component: withValueChangeHandler(Radio.Group),
28
- defaultValue: "",
29
- isEmpty: isEmptyValue,
30
- hasIntrinsicWidth: false
31
- },
32
- {
33
- name: "checkbox",
34
- component: Checkbox.Group,
35
- defaultValue: "",
36
- isEmpty: isEmptyValue,
37
- hasIntrinsicWidth: false
38
- },
39
- {
40
- name: "inputNumber",
41
- component: InputNumber,
42
- defaultValue: "",
43
- isEmpty: isEmptyValue,
44
- hasIntrinsicWidth: false
45
- },
46
- {
47
- name: "slider",
48
- component: Slider,
49
- defaultValue: "",
50
- isEmpty: isEmptyValue,
51
- hasIntrinsicWidth: false
52
- },
53
- {
54
- name: "switch",
55
- component: Switch,
56
- defaultValue: false,
1
+ import { ColorPicker, Rate, TimePicker, DatePicker, Switch, Slider, InputNumber, Checkbox, Radio, Select, Input } from "antd";
2
+ import { withInjectedProps, withColorPickerHandler, isEmptyValue, withValueChangeHandler, withDayjsTransformAntdDate, withDayjsTransformAntdDateRangePicker, withDayjsTransformAntdTime, withDayjsTransformAntdTimeRange } from "./common-utils.js";
3
+ const COMPONENT_MAP = {
4
+ input: Input,
5
+ textArea: Input.TextArea,
6
+ select: Select,
7
+ singleSelect: Select,
8
+ multiSelect: Select,
9
+ radio: Radio.Group,
10
+ checkbox: Checkbox.Group,
11
+ inputNumber: InputNumber,
12
+ slider: Slider,
13
+ switch: Switch,
14
+ datePicker: DatePicker,
15
+ dateRangePicker: DatePicker.RangePicker,
16
+ timePicker: TimePicker,
17
+ timeRangePicker: TimePicker.RangePicker,
18
+ rate: Rate,
19
+ colorPicker: ColorPicker
20
+ };
21
+ const HOC_RULES = {
22
+ // 需要withValueChangeHandler的组件
23
+ withValueChangeHandler: [
24
+ "input",
25
+ "textArea",
26
+ "radio",
27
+ "inputNumber",
28
+ "slider",
29
+ "switch"
30
+ ],
31
+ // 需要日期转换(Day.js)的组件
32
+ withDayjsTransformAntdDate: ["datePicker"],
33
+ withDayjsTransformAntdDateRangePicker: ["dateRangePicker"],
34
+ withDayjsTransformAntdTime: ["timePicker"],
35
+ withDayjsTransformAntdTimeRange: ["timeRangePicker"],
36
+ // 颜色选择处理
37
+ withColorPickerHandler: ["colorPicker"],
38
+ // 多选下拉框
39
+ multiSelect: ["multiSelect"]
40
+ };
41
+ const DEFAULT_VALUES = {
42
+ input: "",
43
+ textArea: "",
44
+ select: "",
45
+ singleSelect: "",
46
+ multiSelect: [],
47
+ radio: "",
48
+ checkbox: [],
49
+ inputNumber: null,
50
+ slider: null,
51
+ switch: false,
52
+ datePicker: null,
53
+ dateRangePicker: null,
54
+ timePicker: null,
55
+ timeRangePicker: null,
56
+ rate: 0,
57
+ colorPicker: ""
58
+ };
59
+ const ALL_COMPONENTS = Object.keys(COMPONENT_MAP).map((name) => {
60
+ let component = COMPONENT_MAP[name];
61
+ if (HOC_RULES.withValueChangeHandler.includes(name)) {
62
+ component = withValueChangeHandler(component);
63
+ }
64
+ if (HOC_RULES.withDayjsTransformAntdDate.includes(name)) {
65
+ component = withDayjsTransformAntdDate(component);
66
+ }
67
+ if (HOC_RULES.withDayjsTransformAntdDateRangePicker.includes(name)) {
68
+ component = withDayjsTransformAntdDateRangePicker(component);
69
+ }
70
+ if (HOC_RULES.withDayjsTransformAntdTime.includes(name)) {
71
+ component = withDayjsTransformAntdTime(component);
72
+ }
73
+ if (HOC_RULES.withDayjsTransformAntdTimeRange.includes(name)) {
74
+ component = withDayjsTransformAntdTimeRange(component);
75
+ }
76
+ if (HOC_RULES.multiSelect.includes(name)) {
77
+ component = withInjectedProps({ mode: "multiple" })(component);
78
+ }
79
+ if (HOC_RULES.withColorPickerHandler.includes(name)) {
80
+ component = withColorPickerHandler(component);
81
+ }
82
+ return {
83
+ name,
84
+ component,
85
+ defaultValue: DEFAULT_VALUES[name],
57
86
  isEmpty: isEmptyValue,
58
87
  hasIntrinsicWidth: false
59
- }
60
- ];
88
+ };
89
+ });
61
90
  export {
62
91
  ALL_COMPONENTS
63
92
  };
@@ -0,0 +1,282 @@
1
+ import { commonjsGlobal, getDefaultExportFromCjs } from "../../../../../_virtual/_commonjsHelpers.js";
2
+ import { __module as dayjs_min } from "../../../../../_virtual/dayjs.min.js";
3
+ (function(module, exports) {
4
+ !function(t, e) {
5
+ module.exports = e();
6
+ }(commonjsGlobal, function() {
7
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
8
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
9
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
10
+ } }, m = function(t2, e2, n2) {
11
+ var r2 = String(t2);
12
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
13
+ }, v = { s: m, z: function(t2) {
14
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
15
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
16
+ }, m: function t2(e2, n2) {
17
+ if (e2.date() < n2.date()) return -t2(n2, e2);
18
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
19
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
20
+ }, a: function(t2) {
21
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
22
+ }, p: function(t2) {
23
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
24
+ }, u: function(t2) {
25
+ return void 0 === t2;
26
+ } }, g = "en", D = {};
27
+ D[g] = M;
28
+ var p = "$isDayjsObject", S = function(t2) {
29
+ return t2 instanceof _ || !(!t2 || !t2[p]);
30
+ }, w = function t2(e2, n2, r2) {
31
+ var i2;
32
+ if (!e2) return g;
33
+ if ("string" == typeof e2) {
34
+ var s2 = e2.toLowerCase();
35
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
36
+ var u2 = e2.split("-");
37
+ if (!i2 && u2.length > 1) return t2(u2[0]);
38
+ } else {
39
+ var a2 = e2.name;
40
+ D[a2] = e2, i2 = a2;
41
+ }
42
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
43
+ }, O = function(t2, e2) {
44
+ if (S(t2)) return t2.clone();
45
+ var n2 = "object" == typeof e2 ? e2 : {};
46
+ return n2.date = t2, n2.args = arguments, new _(n2);
47
+ }, b = v;
48
+ b.l = w, b.i = S, b.w = function(t2, e2) {
49
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
50
+ };
51
+ var _ = function() {
52
+ function M2(t2) {
53
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
54
+ }
55
+ var m2 = M2.prototype;
56
+ return m2.parse = function(t2) {
57
+ this.$d = function(t3) {
58
+ var e2 = t3.date, n2 = t3.utc;
59
+ if (null === e2) return /* @__PURE__ */ new Date(NaN);
60
+ if (b.u(e2)) return /* @__PURE__ */ new Date();
61
+ if (e2 instanceof Date) return new Date(e2);
62
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
63
+ var r2 = e2.match($);
64
+ if (r2) {
65
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
66
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
67
+ }
68
+ }
69
+ return new Date(e2);
70
+ }(t2), this.init();
71
+ }, m2.init = function() {
72
+ var t2 = this.$d;
73
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
74
+ }, m2.$utils = function() {
75
+ return b;
76
+ }, m2.isValid = function() {
77
+ return !(this.$d.toString() === l);
78
+ }, m2.isSame = function(t2, e2) {
79
+ var n2 = O(t2);
80
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
81
+ }, m2.isAfter = function(t2, e2) {
82
+ return O(t2) < this.startOf(e2);
83
+ }, m2.isBefore = function(t2, e2) {
84
+ return this.endOf(e2) < O(t2);
85
+ }, m2.$g = function(t2, e2, n2) {
86
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
87
+ }, m2.unix = function() {
88
+ return Math.floor(this.valueOf() / 1e3);
89
+ }, m2.valueOf = function() {
90
+ return this.$d.getTime();
91
+ }, m2.startOf = function(t2, e2) {
92
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
93
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
94
+ return r2 ? i2 : i2.endOf(a);
95
+ }, $2 = function(t3, e3) {
96
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
97
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
98
+ switch (f2) {
99
+ case h:
100
+ return r2 ? l2(1, 0) : l2(31, 11);
101
+ case c:
102
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
103
+ case o:
104
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
105
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
106
+ case a:
107
+ case d:
108
+ return $2(v2 + "Hours", 0);
109
+ case u:
110
+ return $2(v2 + "Minutes", 1);
111
+ case s:
112
+ return $2(v2 + "Seconds", 2);
113
+ case i:
114
+ return $2(v2 + "Milliseconds", 3);
115
+ default:
116
+ return this.clone();
117
+ }
118
+ }, m2.endOf = function(t2) {
119
+ return this.startOf(t2, false);
120
+ }, m2.$set = function(t2, e2) {
121
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
122
+ if (o2 === c || o2 === h) {
123
+ var y2 = this.clone().set(d, 1);
124
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
125
+ } else l2 && this.$d[l2]($2);
126
+ return this.init(), this;
127
+ }, m2.set = function(t2, e2) {
128
+ return this.clone().$set(t2, e2);
129
+ }, m2.get = function(t2) {
130
+ return this[b.p(t2)]();
131
+ }, m2.add = function(r2, f2) {
132
+ var d2, l2 = this;
133
+ r2 = Number(r2);
134
+ var $2 = b.p(f2), y2 = function(t2) {
135
+ var e2 = O(l2);
136
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
137
+ };
138
+ if ($2 === c) return this.set(c, this.$M + r2);
139
+ if ($2 === h) return this.set(h, this.$y + r2);
140
+ if ($2 === a) return y2(1);
141
+ if ($2 === o) return y2(7);
142
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
143
+ return b.w(m3, this);
144
+ }, m2.subtract = function(t2, e2) {
145
+ return this.add(-1 * t2, e2);
146
+ }, m2.format = function(t2) {
147
+ var e2 = this, n2 = this.$locale();
148
+ if (!this.isValid()) return n2.invalidDate || l;
149
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
150
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
151
+ }, d2 = function(t3) {
152
+ return b.s(s2 % 12 || 12, t3, "0");
153
+ }, $2 = f2 || function(t3, e3, n3) {
154
+ var r3 = t3 < 12 ? "AM" : "PM";
155
+ return n3 ? r3.toLowerCase() : r3;
156
+ };
157
+ return r2.replace(y, function(t3, r3) {
158
+ return r3 || function(t4) {
159
+ switch (t4) {
160
+ case "YY":
161
+ return String(e2.$y).slice(-2);
162
+ case "YYYY":
163
+ return b.s(e2.$y, 4, "0");
164
+ case "M":
165
+ return a2 + 1;
166
+ case "MM":
167
+ return b.s(a2 + 1, 2, "0");
168
+ case "MMM":
169
+ return h2(n2.monthsShort, a2, c2, 3);
170
+ case "MMMM":
171
+ return h2(c2, a2);
172
+ case "D":
173
+ return e2.$D;
174
+ case "DD":
175
+ return b.s(e2.$D, 2, "0");
176
+ case "d":
177
+ return String(e2.$W);
178
+ case "dd":
179
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
180
+ case "ddd":
181
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
182
+ case "dddd":
183
+ return o2[e2.$W];
184
+ case "H":
185
+ return String(s2);
186
+ case "HH":
187
+ return b.s(s2, 2, "0");
188
+ case "h":
189
+ return d2(1);
190
+ case "hh":
191
+ return d2(2);
192
+ case "a":
193
+ return $2(s2, u2, true);
194
+ case "A":
195
+ return $2(s2, u2, false);
196
+ case "m":
197
+ return String(u2);
198
+ case "mm":
199
+ return b.s(u2, 2, "0");
200
+ case "s":
201
+ return String(e2.$s);
202
+ case "ss":
203
+ return b.s(e2.$s, 2, "0");
204
+ case "SSS":
205
+ return b.s(e2.$ms, 3, "0");
206
+ case "Z":
207
+ return i2;
208
+ }
209
+ return null;
210
+ }(t3) || i2.replace(":", "");
211
+ });
212
+ }, m2.utcOffset = function() {
213
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
214
+ }, m2.diff = function(r2, d2, l2) {
215
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
216
+ return b.m(y2, m3);
217
+ };
218
+ switch (M3) {
219
+ case h:
220
+ $2 = D2() / 12;
221
+ break;
222
+ case c:
223
+ $2 = D2();
224
+ break;
225
+ case f:
226
+ $2 = D2() / 3;
227
+ break;
228
+ case o:
229
+ $2 = (g2 - v2) / 6048e5;
230
+ break;
231
+ case a:
232
+ $2 = (g2 - v2) / 864e5;
233
+ break;
234
+ case u:
235
+ $2 = g2 / n;
236
+ break;
237
+ case s:
238
+ $2 = g2 / e;
239
+ break;
240
+ case i:
241
+ $2 = g2 / t;
242
+ break;
243
+ default:
244
+ $2 = g2;
245
+ }
246
+ return l2 ? $2 : b.a($2);
247
+ }, m2.daysInMonth = function() {
248
+ return this.endOf(c).$D;
249
+ }, m2.$locale = function() {
250
+ return D[this.$L];
251
+ }, m2.locale = function(t2, e2) {
252
+ if (!t2) return this.$L;
253
+ var n2 = this.clone(), r2 = w(t2, e2, true);
254
+ return r2 && (n2.$L = r2), n2;
255
+ }, m2.clone = function() {
256
+ return b.w(this.$d, this);
257
+ }, m2.toDate = function() {
258
+ return new Date(this.valueOf());
259
+ }, m2.toJSON = function() {
260
+ return this.isValid() ? this.toISOString() : null;
261
+ }, m2.toISOString = function() {
262
+ return this.$d.toISOString();
263
+ }, m2.toString = function() {
264
+ return this.$d.toUTCString();
265
+ }, M2;
266
+ }(), k = _.prototype;
267
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
268
+ k[t2[1]] = function(e2) {
269
+ return this.$g(e2, t2[0], t2[1]);
270
+ };
271
+ }), O.extend = function(t2, e2) {
272
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
273
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
274
+ return O(1e3 * t2);
275
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
276
+ });
277
+ })(dayjs_min);
278
+ var dayjs_minExports = dayjs_min.exports;
279
+ const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
280
+ export {
281
+ dayjs as default
282
+ };
@@ -0,0 +1,33 @@
1
+ import { commonjsGlobal, getDefaultExportFromCjs } from "../../../../../../_virtual/_commonjsHelpers.js";
2
+ import { __module as isoWeek } from "../../../../../../_virtual/isoWeek.js";
3
+ (function(module, exports) {
4
+ !function(e, t) {
5
+ module.exports = t();
6
+ }(commonjsGlobal, function() {
7
+ var e = "day";
8
+ return function(t, i, s) {
9
+ var a = function(t2) {
10
+ return t2.add(4 - t2.isoWeekday(), e);
11
+ }, d = i.prototype;
12
+ d.isoWeekYear = function() {
13
+ return a(this).year();
14
+ }, d.isoWeek = function(t2) {
15
+ if (!this.$utils().u(t2)) return this.add(7 * (t2 - this.isoWeek()), e);
16
+ var i2, d2, n2, o, r = a(this), u = (i2 = this.isoWeekYear(), d2 = this.$u, n2 = (d2 ? s.utc : s)().year(i2).startOf("year"), o = 4 - n2.isoWeekday(), n2.isoWeekday() > 4 && (o += 7), n2.add(o, e));
17
+ return r.diff(u, "week") + 1;
18
+ }, d.isoWeekday = function(e2) {
19
+ return this.$utils().u(e2) ? this.day() || 7 : this.day(this.day() % 7 ? e2 : e2 - 7);
20
+ };
21
+ var n = d.startOf;
22
+ d.startOf = function(e2, t2) {
23
+ var i2 = this.$utils(), s2 = !!i2.u(t2) || t2;
24
+ return "isoweek" === i2.p(e2) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n.bind(this)(e2, t2);
25
+ };
26
+ };
27
+ });
28
+ })(isoWeek);
29
+ var isoWeekExports = isoWeek.exports;
30
+ const isoweek = /* @__PURE__ */ getDefaultExportFromCjs(isoWeekExports);
31
+ export {
32
+ isoweek as default
33
+ };
@@ -0,0 +1,29 @@
1
+ import { commonjsGlobal, getDefaultExportFromCjs } from "../../../../../../_virtual/_commonjsHelpers.js";
2
+ import { __module as weekOfYear$1 } from "../../../../../../_virtual/weekOfYear.js";
3
+ (function(module, exports) {
4
+ !function(e, t) {
5
+ module.exports = t();
6
+ }(commonjsGlobal, function() {
7
+ var e = "week", t = "year";
8
+ return function(i, n, r) {
9
+ var f = n.prototype;
10
+ f.week = function(i2) {
11
+ if (void 0 === i2 && (i2 = null), null !== i2) return this.add(7 * (i2 - this.week()), "day");
12
+ var n2 = this.$locale().yearStart || 1;
13
+ if (11 === this.month() && this.date() > 25) {
14
+ var f2 = r(this).startOf(t).add(1, t).date(n2), s = r(this).endOf(e);
15
+ if (f2.isBefore(s)) return 1;
16
+ }
17
+ var a = r(this).startOf(t).date(n2).startOf(e).subtract(1, "millisecond"), o = this.diff(a, e, true);
18
+ return o < 0 ? r(this).startOf("week").week() : Math.ceil(o);
19
+ }, f.weeks = function(e2) {
20
+ return void 0 === e2 && (e2 = null), this.week(e2);
21
+ };
22
+ };
23
+ });
24
+ })(weekOfYear$1);
25
+ var weekOfYearExports = weekOfYear$1.exports;
26
+ const weekOfYear = /* @__PURE__ */ getDefaultExportFromCjs(weekOfYearExports);
27
+ export {
28
+ weekOfYear as default
29
+ };
@@ -0,0 +1,19 @@
1
+ import { commonjsGlobal, getDefaultExportFromCjs } from "../../../../../../_virtual/_commonjsHelpers.js";
2
+ import { __module as weekYear$1 } from "../../../../../../_virtual/weekYear.js";
3
+ (function(module, exports) {
4
+ !function(e, t) {
5
+ module.exports = t();
6
+ }(commonjsGlobal, function() {
7
+ return function(e, t) {
8
+ t.prototype.weekYear = function() {
9
+ var e2 = this.month(), t2 = this.week(), n = this.year();
10
+ return 1 === t2 && 11 === e2 ? n + 1 : 0 === e2 && t2 >= 52 ? n - 1 : n;
11
+ };
12
+ };
13
+ });
14
+ })(weekYear$1);
15
+ var weekYearExports = weekYear$1.exports;
16
+ const weekYear = /* @__PURE__ */ getDefaultExportFromCjs(weekYearExports);
17
+ export {
18
+ weekYear as default
19
+ };
@@ -1,5 +1,5 @@
1
1
  import { Reaction } from "mobx";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  import { printDebugValue } from "./utils/printDebugValue.js";
4
4
  import { observerFinalizationRegistry } from "./utils/observerFinalizationRegistry.js";
5
5
  import { s as shimExports } from "../../../../use-sync-external-store@1.5.0_react@18.3.1/node_modules/use-sync-external-store/shim/index.js";
@@ -14,7 +14,7 @@ function useObserver(render, baseComponentName) {
14
14
  if (baseComponentName === void 0) {
15
15
  baseComponentName = "observed";
16
16
  }
17
- var admRef = require$$0.useRef(null);
17
+ var admRef = React.useRef(null);
18
18
  if (!admRef.current) {
19
19
  var adm_1 = {
20
20
  reaction: null,
@@ -46,7 +46,7 @@ function useObserver(render, baseComponentName) {
46
46
  createReaction(adm);
47
47
  observerFinalizationRegistry.register(admRef, adm, adm);
48
48
  }
49
- require$$0.useDebugValue(adm.reaction, printDebugValue);
49
+ React.useDebugValue(adm.reaction, printDebugValue);
50
50
  shimExports.useSyncExternalStore(
51
51
  // Both of these must be stable, otherwise it would keep resubscribing every render.
52
52
  adm.subscribe,
@@ -1,5 +1,5 @@
1
1
  import { __exports as reactJsxRuntime_development } from "../../../../../../_virtual/react-jsx-runtime.development.js";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.development.js
@@ -15,7 +15,7 @@ function requireReactJsxRuntime_development() {
15
15
  hasRequiredReactJsxRuntime_development = 1;
16
16
  if (process.env.NODE_ENV !== "production") {
17
17
  (function() {
18
- var React = require$$0;
18
+ var React$1 = React;
19
19
  var REACT_ELEMENT_TYPE = Symbol.for("react.element");
20
20
  var REACT_PORTAL_TYPE = Symbol.for("react.portal");
21
21
  var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
@@ -41,7 +41,7 @@ function requireReactJsxRuntime_development() {
41
41
  }
42
42
  return null;
43
43
  }
44
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
44
+ var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
45
45
  function error(format) {
46
46
  {
47
47
  {
@@ -1,5 +1,5 @@
1
1
  import { __exports as reactJsxRuntime_production_min } from "../../../../../../_virtual/react-jsx-runtime.production.min.js";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -13,7 +13,7 @@ var hasRequiredReactJsxRuntime_production_min;
13
13
  function requireReactJsxRuntime_production_min() {
14
14
  if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
15
15
  hasRequiredReactJsxRuntime_production_min = 1;
16
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
16
+ var f = React, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
17
17
  function q(c, a, g) {
18
18
  var b, d = {}, e = null, h = null;
19
19
  void 0 !== g && (e = "" + g);
@@ -1,5 +1,5 @@
1
1
  import { __exports as useSyncExternalStoreShim_development } from "../../../../../../_virtual/use-sync-external-store-shim.development.js";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  /**
4
4
  * @license React
5
5
  * use-sync-external-store-shim.development.js
@@ -18,7 +18,7 @@ function requireUseSyncExternalStoreShim_development() {
18
18
  return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
19
19
  }
20
20
  function useSyncExternalStore$2(subscribe, getSnapshot) {
21
- didWarnOld18Alpha || void 0 === React.startTransition || (didWarnOld18Alpha = true, console.error(
21
+ didWarnOld18Alpha || void 0 === React$1.startTransition || (didWarnOld18Alpha = true, console.error(
22
22
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
23
23
  ));
24
24
  var value = getSnapshot();
@@ -66,8 +66,8 @@ function requireUseSyncExternalStoreShim_development() {
66
66
  return getSnapshot();
67
67
  }
68
68
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
69
- var React = require$$0, objectIs = "function" === typeof Object.is ? Object.is : is, useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
70
- useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
69
+ var React$1 = React, objectIs = "function" === typeof Object.is ? Object.is : is, useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
70
+ useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
71
71
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
72
72
  }();
73
73
  return useSyncExternalStoreShim_development;
@@ -1,5 +1,5 @@
1
1
  import { __exports as useSyncExternalStoreShim_production } from "../../../../../../_virtual/use-sync-external-store-shim.production.js";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  /**
4
4
  * @license React
5
5
  * use-sync-external-store-shim.production.js
@@ -13,11 +13,11 @@ var hasRequiredUseSyncExternalStoreShim_production;
13
13
  function requireUseSyncExternalStoreShim_production() {
14
14
  if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
15
15
  hasRequiredUseSyncExternalStoreShim_production = 1;
16
- var React = require$$0;
16
+ var React$1 = React;
17
17
  function is(x, y) {
18
18
  return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
19
19
  }
20
- var objectIs = "function" === typeof Object.is ? Object.is : is, useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
20
+ var objectIs = "function" === typeof Object.is ? Object.is : is, useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue;
21
21
  function useSyncExternalStore$2(subscribe, getSnapshot) {
22
22
  var value = getSnapshot(), _useState = useState({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
23
23
  useLayoutEffect(
@@ -54,7 +54,7 @@ function requireUseSyncExternalStoreShim_production() {
54
54
  return getSnapshot();
55
55
  }
56
56
  var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
57
- useSyncExternalStoreShim_production.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
57
+ useSyncExternalStoreShim_production.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
58
58
  return useSyncExternalStoreShim_production;
59
59
  }
60
60
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-antd-xform",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "基于mobx的form解决方案",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,20 +10,24 @@
10
10
  "files": [
11
11
  "dist"
12
12
  ],
13
- "keywords": [
14
- "form",
15
- "antd",
16
- "react",
17
- "mobx",
18
- "react-antd-xform"
19
- ],
13
+ "scripts": {
14
+ "build": "vite build",
15
+ "dev": "sb dev -p 6006",
16
+ "build-storybook": "sb build",
17
+ "docs:dev": "dumi dev",
18
+ "docs:build": "dumi build",
19
+ "docs:serve": "dumi serve"
20
+ },
21
+ "keywords": [],
20
22
  "author": "",
21
- "license": "MIT",
23
+ "license": "ISC",
24
+ "packageManager": "pnpm@10.12.1",
22
25
  "dependencies": {
23
26
  "@types/invariant": "^2.2.37",
24
27
  "@types/stringify-object": "^4.0.5",
25
28
  "antd": "^5.26.2",
26
29
  "classnames": "^2.5.1",
30
+ "dayjs": "^1.11.15",
27
31
  "invariant": "^2.2.4",
28
32
  "mobx": "^6.13.7",
29
33
  "mobx-react-lite": "^4.1.0",
@@ -41,10 +45,10 @@
41
45
  "@types/react-dom": "^18.2.22",
42
46
  "@types/react-syntax-highlighter": "^15.5.13",
43
47
  "@vitejs/plugin-react": "^4.6.0",
48
+ "dumi": "^2.4.21",
44
49
  "react": "^18.2.0",
45
50
  "react-dom": "^18.2.0",
46
51
  "react-json-view": "^1.21.3",
47
- "react-syntax-highlighter": "^15.6.1",
48
52
  "vite": "^5.2.0",
49
53
  "vite-plugin-dts": "^4.5.4"
50
54
  },
@@ -53,10 +57,5 @@
53
57
  "mobx-react-lite": "^4.1.0",
54
58
  "react": "^18.2.0",
55
59
  "react-dom": "^18.2.0"
56
- },
57
- "scripts": {
58
- "build": "vite build",
59
- "dev": "sb dev -p 6006",
60
- "build-storybook": "sb build"
61
60
  }
62
- }
61
+ }
package/README.md DELETED
@@ -1,2 +0,0 @@
1
- # react-antd-xform
2
- 基于react + mobx实现的antd表单方案