@aloudata/aloudata-design 3.0.0-beta.6 → 3.0.0-beta.7
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.
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
import { PickerProps, RangePickerProps as RcRangePickerProps, PickerRef } from 'rc-picker';
|
|
4
|
-
import { RangePickerRef } from 'rc-picker/es/interface';
|
|
4
|
+
import { PanelMode, RangePickerRef } from 'rc-picker/es/interface';
|
|
5
5
|
import { SizeType } from '../ConfigProvider/sizeContext';
|
|
6
6
|
export type RangeValue<T = Dayjs> = [T | null, T | null] | null;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* disabledDate compat: rc-picker v4 requires (date, info) => boolean,
|
|
9
|
+
* but antd v4 consumers pass (current) => boolean. We accept both.
|
|
10
|
+
*/
|
|
11
|
+
type DisabledDateCompat = (current: Dayjs, info?: {
|
|
12
|
+
type: PanelMode;
|
|
13
|
+
from?: Dayjs;
|
|
14
|
+
}) => boolean;
|
|
15
|
+
export interface DatePickerProps extends Omit<PickerProps<Dayjs>, 'generateConfig' | 'locale' | 'prefixCls' | 'onChange' | 'disabledDate'> {
|
|
8
16
|
/** Override size from ConfigProvider */
|
|
9
17
|
size?: SizeType;
|
|
10
18
|
/** Validation status */
|
|
@@ -13,16 +21,35 @@ export interface DatePickerProps extends Omit<PickerProps<Dayjs>, 'generateConfi
|
|
|
13
21
|
bordered?: boolean;
|
|
14
22
|
/** Custom prefixCls */
|
|
15
23
|
prefixCls?: string;
|
|
16
|
-
/**
|
|
17
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Narrowed onChange — single picker uses Dayjs | null, not Dayjs | Dayjs[].
|
|
26
|
+
* Uses import('dayjs').Dayjs to avoid duplicate-dayjs type conflicts.
|
|
27
|
+
*/
|
|
28
|
+
onChange?: (date: import('dayjs').Dayjs | null, dateString: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* disabledDate — accepts both rc-picker v4 signature and antd v4 compat
|
|
31
|
+
* signature `(current: Dayjs) => boolean`.
|
|
32
|
+
*/
|
|
33
|
+
disabledDate?: DisabledDateCompat;
|
|
34
|
+
/** Callback when a date is selected on the panel */
|
|
35
|
+
onSelect?: (date: Dayjs) => void;
|
|
36
|
+
/** @deprecated Use `classNames.popup` instead. Preserved for antd v4 compat. */
|
|
37
|
+
popupClassName?: string;
|
|
18
38
|
}
|
|
19
|
-
export interface RangePickerProps extends Omit<RcRangePickerProps<Dayjs>, 'generateConfig' | 'locale' | 'prefixCls' | 'onChange'> {
|
|
39
|
+
export interface RangePickerProps extends Omit<RcRangePickerProps<Dayjs>, 'generateConfig' | 'locale' | 'prefixCls' | 'onChange' | 'disabledDate'> {
|
|
20
40
|
size?: SizeType;
|
|
21
41
|
status?: 'error' | 'warning';
|
|
22
42
|
bordered?: boolean;
|
|
23
43
|
prefixCls?: string;
|
|
24
44
|
/** Narrowed onChange for RangePicker */
|
|
25
|
-
onChange?: (dates: [Dayjs | null, Dayjs | null] | null, dateStrings: [string, string]) => void;
|
|
45
|
+
onChange?: (dates: [import('dayjs').Dayjs | null, import('dayjs').Dayjs | null] | null, dateStrings: [string, string]) => void;
|
|
46
|
+
/**
|
|
47
|
+
* disabledDate — accepts both rc-picker v4 signature and antd v4 compat
|
|
48
|
+
* signature `(current: Dayjs) => boolean`.
|
|
49
|
+
*/
|
|
50
|
+
disabledDate?: DisabledDateCompat;
|
|
51
|
+
/** @deprecated Use `classNames.popup` instead. Preserved for antd v4 compat. */
|
|
52
|
+
popupClassName?: string;
|
|
26
53
|
}
|
|
27
54
|
export type YearPickerProps = DatePickerProps;
|
|
28
55
|
export type QuarterPickerProps = DatePickerProps;
|
package/dist/DatePicker/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import SizeContext from "../ConfigProvider/sizeContext.js";
|
|
|
4
4
|
import { LocaleContext } from "../locale/default.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
import enUSDatePicker from "rc-picker/es/locale/en_US";
|
|
7
|
-
import { forwardRef, useContext } from "react";
|
|
7
|
+
import React, { forwardRef, useContext } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
import { Picker, RangePicker } from "rc-picker";
|
|
10
10
|
import dayjsGenerateConfig from "rc-picker/es/generate/dayjs";
|
|
@@ -14,35 +14,79 @@ var SIZE_CLS = {
|
|
|
14
14
|
large: "ald-picker-lg"
|
|
15
15
|
};
|
|
16
16
|
var InternalDatePicker = forwardRef((props, ref) => {
|
|
17
|
-
const { size: customSize, disabled: customDisabled, className, status, bordered = true, prefixCls = "ald-picker", ...restProps } = props;
|
|
17
|
+
const { size: customSize, disabled: customDisabled, className, status, bordered = true, prefixCls = "ald-picker", onChange, disabledDate, onSelect: _onSelect, popupClassName, ...restProps } = props;
|
|
18
18
|
const ctxSize = useContext(SizeContext);
|
|
19
19
|
const size = customSize || ctxSize || "middle";
|
|
20
20
|
const ctxDisabled = useContext(DisabledContext);
|
|
21
21
|
const mergedDisabled = customDisabled ?? ctxDisabled;
|
|
22
|
+
const pickerLocale = useContext(LocaleContext)?.DatePicker || enUSDatePicker;
|
|
23
|
+
const sizeCls = SIZE_CLS[size] || "";
|
|
24
|
+
const rcOnChange = React.useMemo(() => {
|
|
25
|
+
if (!onChange) return void 0;
|
|
26
|
+
return (date, dateString) => {
|
|
27
|
+
onChange(Array.isArray(date) ? date[0] : date, Array.isArray(dateString) ? dateString[0] : dateString);
|
|
28
|
+
};
|
|
29
|
+
}, [onChange]);
|
|
30
|
+
const rcDisabledDate = React.useMemo(() => {
|
|
31
|
+
if (!disabledDate) return void 0;
|
|
32
|
+
return (date, info) => disabledDate(date, info);
|
|
33
|
+
}, [disabledDate]);
|
|
34
|
+
const mergedClassNames = React.useMemo(() => {
|
|
35
|
+
if (!popupClassName) return restProps.classNames;
|
|
36
|
+
return {
|
|
37
|
+
...restProps.classNames,
|
|
38
|
+
popup: cn(restProps.classNames?.popup, popupClassName)
|
|
39
|
+
};
|
|
40
|
+
}, [popupClassName, restProps.classNames]);
|
|
22
41
|
return /* @__PURE__ */ jsx(Picker, {
|
|
23
42
|
ref,
|
|
24
43
|
generateConfig: dayjsGenerateConfig,
|
|
25
|
-
locale:
|
|
44
|
+
locale: pickerLocale,
|
|
26
45
|
prefixCls,
|
|
27
46
|
disabled: mergedDisabled,
|
|
28
|
-
className: cn(
|
|
29
|
-
...restProps
|
|
47
|
+
className: cn(sizeCls, !bordered && "ald-picker-borderless", status === "error" && "ald-picker-status-error", status === "warning" && "ald-picker-status-warning", className),
|
|
48
|
+
...restProps,
|
|
49
|
+
classNames: mergedClassNames,
|
|
50
|
+
onChange: rcOnChange,
|
|
51
|
+
disabledDate: rcDisabledDate
|
|
30
52
|
});
|
|
31
53
|
});
|
|
32
54
|
var InternalRangePicker = forwardRef((props, ref) => {
|
|
33
|
-
const { size: customSize, disabled: customDisabled, className, status, bordered = true, prefixCls = "ald-picker", ...restProps } = props;
|
|
55
|
+
const { size: customSize, disabled: customDisabled, className, status, bordered = true, prefixCls = "ald-picker", onChange, disabledDate, popupClassName, ...restProps } = props;
|
|
34
56
|
const ctxSize = useContext(SizeContext);
|
|
35
57
|
const size = customSize || ctxSize || "middle";
|
|
36
58
|
const ctxDisabled = useContext(DisabledContext);
|
|
37
59
|
const mergedDisabled = customDisabled ?? ctxDisabled;
|
|
60
|
+
const pickerLocale = useContext(LocaleContext)?.DatePicker || enUSDatePicker;
|
|
61
|
+
const sizeCls = SIZE_CLS[size] || "";
|
|
62
|
+
const rcOnChange = React.useMemo(() => {
|
|
63
|
+
if (!onChange) return void 0;
|
|
64
|
+
return (dates, dateStrings) => {
|
|
65
|
+
onChange(dates, dateStrings);
|
|
66
|
+
};
|
|
67
|
+
}, [onChange]);
|
|
68
|
+
const rcDisabledDate = React.useMemo(() => {
|
|
69
|
+
if (!disabledDate) return void 0;
|
|
70
|
+
return (date, info) => disabledDate(date, info);
|
|
71
|
+
}, [disabledDate]);
|
|
72
|
+
const mergedClassNames = React.useMemo(() => {
|
|
73
|
+
if (!popupClassName) return restProps.classNames;
|
|
74
|
+
return {
|
|
75
|
+
...restProps.classNames,
|
|
76
|
+
popup: cn(restProps.classNames?.popup, popupClassName)
|
|
77
|
+
};
|
|
78
|
+
}, [popupClassName, restProps.classNames]);
|
|
38
79
|
return /* @__PURE__ */ jsx(RangePicker, {
|
|
39
80
|
ref,
|
|
40
81
|
generateConfig: dayjsGenerateConfig,
|
|
41
|
-
locale:
|
|
82
|
+
locale: pickerLocale,
|
|
42
83
|
prefixCls,
|
|
43
84
|
disabled: mergedDisabled,
|
|
44
|
-
className: cn(
|
|
45
|
-
...restProps
|
|
85
|
+
className: cn(sizeCls, !bordered && "ald-picker-borderless", status === "error" && "ald-picker-status-error", status === "warning" && "ald-picker-status-warning", className),
|
|
86
|
+
...restProps,
|
|
87
|
+
classNames: mergedClassNames,
|
|
88
|
+
onChange: rcOnChange,
|
|
89
|
+
disabledDate: rcDisabledDate
|
|
46
90
|
});
|
|
47
91
|
});
|
|
48
92
|
function createPickerVariant(pickerMode, defaultPlaceholder) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/DatePicker/index.tsx"],"sourcesContent":["import type { Dayjs } from 'dayjs';\nimport React, { forwardRef, useContext } from 'react';\nimport { Picker, RangePicker as RcRangePicker } from 'rc-picker';\nimport type {\n PickerProps,\n RangePickerProps as RcRangePickerProps,\n PickerRef,\n} from 'rc-picker';\nimport type { RangePickerRef } from 'rc-picker/es/interface';\nimport dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';\nimport enUS from 'rc-picker/es/locale/en_US';\nimport { LocaleContext } from '../locale/default';\nimport DisabledContext from '../ConfigProvider/DisabledContext';\nimport SizeContext, { type SizeType } from '../ConfigProvider/sizeContext';\nimport { cn } from '../lib/utils';\nimport './date-picker.css';\n\n// ---- Types ----\n// Re-export compatible types\nexport type RangeValue<T = Dayjs> = [T | null, T | null] | null;\n\nexport interface DatePickerProps\n extends Omit<\n PickerProps<Dayjs>,\n 'generateConfig' | 'locale' | 'prefixCls' | 'onChange'\n > {\n /** Override size from ConfigProvider */\n size?: SizeType;\n /** Validation status */\n status?: 'error' | 'warning';\n /** @deprecated Use `variant` or className instead */\n bordered?: boolean;\n /** Custom prefixCls */\n prefixCls?: string;\n /** Narrowed onChange — single picker uses Dayjs | null, not Dayjs | Dayjs[] */\n onChange?: (date: Dayjs | null, dateString: string) => void;\n}\n\nexport interface RangePickerProps\n extends Omit<\n RcRangePickerProps<Dayjs>,\n 'generateConfig' | 'locale' | 'prefixCls' | 'onChange'\n > {\n size?: SizeType;\n status?: 'error' | 'warning';\n bordered?: boolean;\n prefixCls?: string;\n /** Narrowed onChange for RangePicker */\n onChange?: (\n dates: [Dayjs | null, Dayjs | null] | null,\n dateStrings: [string, string],\n ) => void;\n}\n\nexport type YearPickerProps = DatePickerProps;\nexport type QuarterPickerProps = DatePickerProps;\nexport type MonthPickerProps = DatePickerProps;\nexport type WeekPickerProps = DatePickerProps;\nexport type TimePickerProps = DatePickerProps;\n\n// ---- Size mapping ----\nconst SIZE_CLS: Record<string, string> = {\n small: 'ald-picker-sm',\n large: 'ald-picker-lg',\n};\n\n// ---- DatePicker ----\nconst InternalDatePicker = forwardRef<PickerRef, DatePickerProps>(\n (props, ref) => {\n const {\n size: customSize,\n disabled: customDisabled,\n className,\n status,\n bordered = true,\n prefixCls = 'ald-picker',\n ...restProps\n } = props;\n\n const ctxSize = useContext(SizeContext);\n const size = customSize || ctxSize || 'middle';\n const ctxDisabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? ctxDisabled;\n const ctxLocale = useContext(LocaleContext);\n // antd locale 对象包含 DatePicker 字段(即 rc-picker 格式的 locale)\n const pickerLocale = ctxLocale?.DatePicker || enUS;\n\n const sizeCls = SIZE_CLS[size] || '';\n\n return (\n <Picker<Dayjs>\n ref={ref}\n generateConfig={dayjsGenerateConfig}\n locale={pickerLocale}\n prefixCls={prefixCls}\n disabled={mergedDisabled}\n className={cn(\n sizeCls,\n !bordered && 'ald-picker-borderless',\n status === 'error' && 'ald-picker-status-error',\n status === 'warning' && 'ald-picker-status-warning',\n className,\n )}\n {...(restProps as any)}\n />\n );\n },\n) as React.ForwardRefExoticComponent<\n DatePickerProps & React.RefAttributes<PickerRef>\n> & {\n RangePicker: typeof InternalRangePicker;\n WeekPicker: typeof WeekPicker;\n MonthPicker: typeof MonthPicker;\n YearPicker: typeof YearPicker;\n TimePicker: typeof TimePicker;\n QuarterPicker: typeof QuarterPicker;\n};\n\n// ---- RangePicker ----\nconst InternalRangePicker = forwardRef<RangePickerRef, RangePickerProps>(\n (props, ref) => {\n const {\n size: customSize,\n disabled: customDisabled,\n className,\n status,\n bordered = true,\n prefixCls = 'ald-picker',\n ...restProps\n } = props;\n\n const ctxSize = useContext(SizeContext);\n const size = customSize || ctxSize || 'middle';\n const ctxDisabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? ctxDisabled;\n const ctxLocale = useContext(LocaleContext);\n const pickerLocale = ctxLocale?.DatePicker || enUS;\n\n const sizeCls = SIZE_CLS[size] || '';\n\n return (\n <RcRangePicker<Dayjs>\n ref={ref}\n generateConfig={dayjsGenerateConfig}\n locale={pickerLocale}\n prefixCls={prefixCls}\n disabled={mergedDisabled}\n className={cn(\n sizeCls,\n !bordered && 'ald-picker-borderless',\n status === 'error' && 'ald-picker-status-error',\n status === 'warning' && 'ald-picker-status-warning',\n className,\n )}\n {...(restProps as any)}\n />\n );\n },\n);\n\n// ---- Picker variants ----\nfunction createPickerVariant(\n pickerMode: DatePickerProps['picker'],\n defaultPlaceholder: string,\n) {\n const PickerVariant = forwardRef<PickerRef, DatePickerProps>((props, ref) => (\n <InternalDatePicker\n ref={ref}\n picker={pickerMode}\n placeholder={props.placeholder ?? defaultPlaceholder}\n {...props}\n />\n ));\n PickerVariant.displayName = `DatePicker.${pickerMode}Picker`;\n return PickerVariant;\n}\n\nconst WeekPicker = createPickerVariant('week', 'Select week');\nconst MonthPicker = createPickerVariant('month', 'Select month');\nconst YearPicker = createPickerVariant('year', 'Select year');\nconst QuarterPicker = createPickerVariant('quarter', 'Select quarter');\n\nconst TimePicker = forwardRef<PickerRef, DatePickerProps>((props, ref) => (\n <InternalDatePicker\n ref={ref}\n picker=\"time\"\n placeholder={props.placeholder ?? 'Select time'}\n {...props}\n />\n));\nTimePicker.displayName = 'DatePicker.TimePicker';\n\n// ---- Attach sub-components ----\nInternalDatePicker.RangePicker = InternalRangePicker;\nInternalDatePicker.WeekPicker = WeekPicker;\nInternalDatePicker.MonthPicker = MonthPicker;\nInternalDatePicker.YearPicker = YearPicker;\nInternalDatePicker.TimePicker = TimePicker;\nInternalDatePicker.QuarterPicker = QuarterPicker;\n\nconst DatePicker = InternalDatePicker;\nexport default DatePicker;\n"],"mappings":";;;;;;;;;;;AA6DA,IAAM,WAAmC;CACvC,OAAO;CACP,OAAO;CACR;AAGD,IAAM,qBAAqB,YACxB,OAAO,QAAQ;CACd,MAAM,EACJ,MAAM,YACN,UAAU,gBACV,WACA,QACA,WAAW,MACX,YAAY,cACZ,GAAG,cACD;CAEJ,MAAM,UAAU,WAAW,YAAY;CACvC,MAAM,OAAO,cAAc,WAAW;CACtC,MAAM,cAAc,WAAW,gBAAgB;CAC/C,MAAM,iBAAiB,kBAAkB;AAOzC,QACE,oBAAC,QAAD;EACO;EACL,gBAAgB;EAChB,QAVc,WAAW,cAAc,EAEX,cAAc;EAS/B;EACX,UAAU;EACV,WAAW,GATC,SAAS,SAAS,IAW5B,CAAC,YAAY,yBACb,WAAW,WAAW,2BACtB,WAAW,aAAa,6BACxB,UACD;EACD,GAAK;EACL,CAAA;EAGP;AAYD,IAAM,sBAAsB,YACzB,OAAO,QAAQ;CACd,MAAM,EACJ,MAAM,YACN,UAAU,gBACV,WACA,QACA,WAAW,MACX,YAAY,cACZ,GAAG,cACD;CAEJ,MAAM,UAAU,WAAW,YAAY;CACvC,MAAM,OAAO,cAAc,WAAW;CACtC,MAAM,cAAc,WAAW,gBAAgB;CAC/C,MAAM,iBAAiB,kBAAkB;AAMzC,QACE,oBAAC,aAAD;EACO;EACL,gBAAgB;EAChB,QATc,WAAW,cAAc,EACX,cAAc;EAS/B;EACX,UAAU;EACV,WAAW,GATC,SAAS,SAAS,IAW5B,CAAC,YAAY,yBACb,WAAW,WAAW,2BACtB,WAAW,aAAa,6BACxB,UACD;EACD,GAAK;EACL,CAAA;EAGP;AAGD,SAAS,oBACP,YACA,oBACA;CACA,MAAM,gBAAgB,YAAwC,OAAO,QACnE,oBAAC,oBAAD;EACO;EACL,QAAQ;EACR,aAAa,MAAM,eAAe;EAClC,GAAI;EACJ,CAAA,CACF;AACF,eAAc,cAAc,cAAc,WAAW;AACrD,QAAO;;AAGT,IAAM,aAAa,oBAAoB,QAAQ,cAAc;AAC7D,IAAM,cAAc,oBAAoB,SAAS,eAAe;AAChE,IAAM,aAAa,oBAAoB,QAAQ,cAAc;AAC7D,IAAM,gBAAgB,oBAAoB,WAAW,iBAAiB;AAEtE,IAAM,aAAa,YAAwC,OAAO,QAChE,oBAAC,oBAAD;CACO;CACL,QAAO;CACP,aAAa,MAAM,eAAe;CAClC,GAAI;CACJ,CAAA,CACF;AACF,WAAW,cAAc;AAGzB,mBAAmB,cAAc;AACjC,mBAAmB,aAAa;AAChC,mBAAmB,cAAc;AACjC,mBAAmB,aAAa;AAChC,mBAAmB,aAAa;AAChC,mBAAmB,gBAAgB;AAEnC,IAAM,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/DatePicker/index.tsx"],"sourcesContent":["import type { Dayjs } from 'dayjs';\nimport React, { forwardRef, useContext } from 'react';\nimport { Picker, RangePicker as RcRangePicker } from 'rc-picker';\nimport type {\n PickerProps,\n RangePickerProps as RcRangePickerProps,\n PickerRef,\n} from 'rc-picker';\nimport type { PanelMode, RangePickerRef } from 'rc-picker/es/interface';\nimport dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';\nimport enUS from 'rc-picker/es/locale/en_US';\nimport { LocaleContext } from '../locale/default';\nimport DisabledContext from '../ConfigProvider/DisabledContext';\nimport SizeContext, { type SizeType } from '../ConfigProvider/sizeContext';\nimport { cn } from '../lib/utils';\nimport './date-picker.css';\n\n// ---- Types ----\n// Re-export compatible types\nexport type RangeValue<T = Dayjs> = [T | null, T | null] | null;\n\n/**\n * disabledDate compat: rc-picker v4 requires (date, info) => boolean,\n * but antd v4 consumers pass (current) => boolean. We accept both.\n */\ntype DisabledDateCompat = (\n current: Dayjs,\n info?: { type: PanelMode; from?: Dayjs },\n) => boolean;\n\nexport interface DatePickerProps\n extends Omit<\n PickerProps<Dayjs>,\n 'generateConfig' | 'locale' | 'prefixCls' | 'onChange' | 'disabledDate'\n > {\n /** Override size from ConfigProvider */\n size?: SizeType;\n /** Validation status */\n status?: 'error' | 'warning';\n /** @deprecated Use `variant` or className instead */\n bordered?: boolean;\n /** Custom prefixCls */\n prefixCls?: string;\n /**\n * Narrowed onChange — single picker uses Dayjs | null, not Dayjs | Dayjs[].\n * Uses import('dayjs').Dayjs to avoid duplicate-dayjs type conflicts.\n */\n onChange?: (date: import('dayjs').Dayjs | null, dateString: string) => void;\n /**\n * disabledDate — accepts both rc-picker v4 signature and antd v4 compat\n * signature `(current: Dayjs) => boolean`.\n */\n disabledDate?: DisabledDateCompat;\n /** Callback when a date is selected on the panel */\n onSelect?: (date: Dayjs) => void;\n /** @deprecated Use `classNames.popup` instead. Preserved for antd v4 compat. */\n popupClassName?: string;\n}\n\nexport interface RangePickerProps\n extends Omit<\n RcRangePickerProps<Dayjs>,\n 'generateConfig' | 'locale' | 'prefixCls' | 'onChange' | 'disabledDate'\n > {\n size?: SizeType;\n status?: 'error' | 'warning';\n bordered?: boolean;\n prefixCls?: string;\n /** Narrowed onChange for RangePicker */\n onChange?: (\n dates: [import('dayjs').Dayjs | null, import('dayjs').Dayjs | null] | null,\n dateStrings: [string, string],\n ) => void;\n /**\n * disabledDate — accepts both rc-picker v4 signature and antd v4 compat\n * signature `(current: Dayjs) => boolean`.\n */\n disabledDate?: DisabledDateCompat;\n /** @deprecated Use `classNames.popup` instead. Preserved for antd v4 compat. */\n popupClassName?: string;\n}\n\nexport type YearPickerProps = DatePickerProps;\nexport type QuarterPickerProps = DatePickerProps;\nexport type MonthPickerProps = DatePickerProps;\nexport type WeekPickerProps = DatePickerProps;\nexport type TimePickerProps = DatePickerProps;\n\n// ---- Size mapping ----\nconst SIZE_CLS: Record<string, string> = {\n small: 'ald-picker-sm',\n large: 'ald-picker-lg',\n};\n\n// ---- DatePicker ----\nconst InternalDatePicker = forwardRef<PickerRef, DatePickerProps>(\n (props, ref) => {\n const {\n size: customSize,\n disabled: customDisabled,\n className,\n status,\n bordered = true,\n prefixCls = 'ald-picker',\n onChange,\n disabledDate,\n onSelect: _onSelect,\n popupClassName,\n ...restProps\n } = props;\n\n const ctxSize = useContext(SizeContext);\n const size = customSize || ctxSize || 'middle';\n const ctxDisabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? ctxDisabled;\n const ctxLocale = useContext(LocaleContext);\n // antd locale 对象包含 DatePicker 字段(即 rc-picker 格式的 locale)\n const pickerLocale = ctxLocale?.DatePicker || enUS;\n\n const sizeCls = SIZE_CLS[size] || '';\n\n // Wrap narrowed onChange to match rc-picker's wider signature\n const rcOnChange = React.useMemo(() => {\n if (!onChange) return undefined;\n return (date: Dayjs | Dayjs[], dateString: string | string[]) => {\n onChange(\n (Array.isArray(date) ? date[0] : date) as Dayjs | null,\n Array.isArray(dateString) ? dateString[0] : dateString,\n );\n };\n }, [onChange]);\n\n // Wrap compat disabledDate to rc-picker v4 signature\n const rcDisabledDate = React.useMemo(() => {\n if (!disabledDate) return undefined;\n return (date: Dayjs, info: { type: PanelMode; from?: Dayjs }) =>\n disabledDate(date, info);\n }, [disabledDate]);\n\n // Merge popupClassName into classNames.popup for rc-picker v4\n const mergedClassNames = React.useMemo(() => {\n if (!popupClassName) return restProps.classNames;\n return {\n ...restProps.classNames,\n popup: cn(restProps.classNames?.popup, popupClassName),\n };\n }, [popupClassName, restProps.classNames]);\n\n return (\n <Picker<Dayjs>\n ref={ref}\n generateConfig={dayjsGenerateConfig}\n locale={pickerLocale}\n prefixCls={prefixCls}\n disabled={mergedDisabled}\n className={cn(\n sizeCls,\n !bordered && 'ald-picker-borderless',\n status === 'error' && 'ald-picker-status-error',\n status === 'warning' && 'ald-picker-status-warning',\n className,\n )}\n {...restProps}\n classNames={mergedClassNames}\n onChange={rcOnChange}\n disabledDate={rcDisabledDate}\n />\n );\n },\n) as React.ForwardRefExoticComponent<\n DatePickerProps & React.RefAttributes<PickerRef>\n> & {\n RangePicker: typeof InternalRangePicker;\n WeekPicker: typeof WeekPicker;\n MonthPicker: typeof MonthPicker;\n YearPicker: typeof YearPicker;\n TimePicker: typeof TimePicker;\n QuarterPicker: typeof QuarterPicker;\n};\n\n// ---- RangePicker ----\nconst InternalRangePicker = forwardRef<RangePickerRef, RangePickerProps>(\n (props, ref) => {\n const {\n size: customSize,\n disabled: customDisabled,\n className,\n status,\n bordered = true,\n prefixCls = 'ald-picker',\n onChange,\n disabledDate,\n popupClassName,\n ...restProps\n } = props;\n\n const ctxSize = useContext(SizeContext);\n const size = customSize || ctxSize || 'middle';\n const ctxDisabled = useContext(DisabledContext);\n const mergedDisabled = customDisabled ?? ctxDisabled;\n const ctxLocale = useContext(LocaleContext);\n const pickerLocale = ctxLocale?.DatePicker || enUS;\n\n const sizeCls = SIZE_CLS[size] || '';\n\n // Wrap narrowed onChange to match rc-picker's wider signature\n const rcOnChange = React.useMemo(() => {\n if (!onChange) return undefined;\n return (\n dates: [Dayjs | null, Dayjs | null] | null,\n dateStrings: [string, string],\n ) => {\n onChange(dates, dateStrings);\n };\n }, [onChange]);\n\n // Wrap compat disabledDate to rc-picker v4 signature\n const rcDisabledDate = React.useMemo(() => {\n if (!disabledDate) return undefined;\n return (date: Dayjs, info: { type: PanelMode; from?: Dayjs }) =>\n disabledDate(date, info);\n }, [disabledDate]);\n\n // Merge popupClassName into classNames.popup for rc-picker v4\n const mergedClassNames = React.useMemo(() => {\n if (!popupClassName) return restProps.classNames;\n return {\n ...restProps.classNames,\n popup: cn(restProps.classNames?.popup, popupClassName),\n };\n }, [popupClassName, restProps.classNames]);\n\n return (\n <RcRangePicker<Dayjs>\n ref={ref}\n generateConfig={dayjsGenerateConfig}\n locale={pickerLocale}\n prefixCls={prefixCls}\n disabled={mergedDisabled}\n className={cn(\n sizeCls,\n !bordered && 'ald-picker-borderless',\n status === 'error' && 'ald-picker-status-error',\n status === 'warning' && 'ald-picker-status-warning',\n className,\n )}\n {...restProps}\n classNames={mergedClassNames}\n onChange={rcOnChange}\n disabledDate={rcDisabledDate}\n />\n );\n },\n);\n\n// ---- Picker variants ----\nfunction createPickerVariant(\n pickerMode: DatePickerProps['picker'],\n defaultPlaceholder: string,\n) {\n const PickerVariant = forwardRef<PickerRef, DatePickerProps>((props, ref) => (\n <InternalDatePicker\n ref={ref}\n picker={pickerMode}\n placeholder={props.placeholder ?? defaultPlaceholder}\n {...props}\n />\n ));\n PickerVariant.displayName = `DatePicker.${pickerMode}Picker`;\n return PickerVariant;\n}\n\nconst WeekPicker = createPickerVariant('week', 'Select week');\nconst MonthPicker = createPickerVariant('month', 'Select month');\nconst YearPicker = createPickerVariant('year', 'Select year');\nconst QuarterPicker = createPickerVariant('quarter', 'Select quarter');\n\nconst TimePicker = forwardRef<PickerRef, DatePickerProps>((props, ref) => (\n <InternalDatePicker\n ref={ref}\n picker=\"time\"\n placeholder={props.placeholder ?? 'Select time'}\n {...props}\n />\n));\nTimePicker.displayName = 'DatePicker.TimePicker';\n\n// ---- Attach sub-components ----\nInternalDatePicker.RangePicker = InternalRangePicker;\nInternalDatePicker.WeekPicker = WeekPicker;\nInternalDatePicker.MonthPicker = MonthPicker;\nInternalDatePicker.YearPicker = YearPicker;\nInternalDatePicker.TimePicker = TimePicker;\nInternalDat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C7D,IAAM,cAAc,oBAAoB,SAAS,eAAe;AAChE,IAAM,aAAa,oBAAoB,QAAQ,cAAc;AAC7D,IAAM,gBAAgB,oBAAoB,WAAW,iBAAiB;AAEtE,IAAM,aAAa,YAAwC,OAAO,QAChE,oBAAC,oBAAD;CACO;CACL,QAAO;CACP,aAAa,MAAM,eAAe;CAClC,GAAI;CACJ,CAAA,CACF;AACF,WAAW,cAAc;AAGzB,mBAAmB,cAAc;AACjC,mBAAmB,aAAa;AAChC,mBAAmB,cAAc;AACjC,mBAAmB,aAAa;AAChC,mBAAmB,aAAa;AAChC,mBAAmB,gBAAgB;AAEnC,IAAM,aAAa"}
|
package/dist/Tree/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { default as RcTree, BasicDataNode, TreeNode } from 'rc-tree';
|
|
|
2
2
|
import { DataNode } from 'rc-tree/es/interface';
|
|
3
3
|
import { default as DirectoryTree } from './DirectoryTree.js';
|
|
4
4
|
import { TreeProps } from './Tree.js';
|
|
5
|
+
import type * as React from 'react';
|
|
5
6
|
export type { EventDataNode } from 'rc-tree/es/interface';
|
|
6
7
|
export type { ExpandAction as DirectoryTreeExpandAction, DirectoryTreeProps, } from './DirectoryTree.js';
|
|
7
8
|
export type { AldTreeNode, AldTreeNodeAttribute, AldTreeNodeCheckedEvent, AldTreeNodeExpandedEvent, AldTreeNodeMouseEvent, AldTreeNodeProps, AldTreeNodeSelectedEvent, TreeProps, } from './Tree.js';
|
|
8
9
|
export type { DataNode };
|
|
9
10
|
type CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(props: React.PropsWithChildren<TreeProps<T>> & {
|
|
10
|
-
ref?: React.Ref<RcTree> | React.RefObject<RcTree | null
|
|
11
|
+
ref?: React.Ref<RcTree> | React.RefObject<RcTree | null> | React.MutableRefObject<RcTree | null> | null | undefined;
|
|
11
12
|
}) => React.ReactElement) & {
|
|
12
13
|
TreeNode: typeof TreeNode;
|
|
13
14
|
DirectoryTree: typeof DirectoryTree;
|
package/dist/Tree/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/Tree/index.tsx"],"sourcesContent":["import type RcTree from 'rc-tree';\nimport type { BasicDataNode } from 'rc-tree';\nimport { TreeNode } from 'rc-tree';\nimport type { DataNode } from 'rc-tree/es/interface';\nimport DirectoryTree from './DirectoryTree';\nimport type { TreeProps } from './Tree';\nimport TreePure from './Tree';\n\nexport type { EventDataNode } from 'rc-tree/es/interface';\nexport type {\n ExpandAction as DirectoryTreeExpandAction,\n DirectoryTreeProps,\n} from './DirectoryTree';\nexport type {\n AldTreeNode,\n AldTreeNodeAttribute,\n AldTreeNodeCheckedEvent,\n AldTreeNodeExpandedEvent,\n AldTreeNodeMouseEvent,\n AldTreeNodeProps,\n AldTreeNodeSelectedEvent,\n TreeProps,\n} from './Tree';\nexport type { DataNode };\n\ntype CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(\n props: React.PropsWithChildren<TreeProps<T>> & {\n ref
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/Tree/index.tsx"],"sourcesContent":["import type * as React from 'react';\nimport type RcTree from 'rc-tree';\nimport type { BasicDataNode } from 'rc-tree';\nimport { TreeNode } from 'rc-tree';\nimport type { DataNode } from 'rc-tree/es/interface';\nimport DirectoryTree from './DirectoryTree';\nimport type { TreeProps } from './Tree';\nimport TreePure from './Tree';\n\nexport type { EventDataNode } from 'rc-tree/es/interface';\nexport type {\n ExpandAction as DirectoryTreeExpandAction,\n DirectoryTreeProps,\n} from './DirectoryTree';\nexport type {\n AldTreeNode,\n AldTreeNodeAttribute,\n AldTreeNodeCheckedEvent,\n AldTreeNodeExpandedEvent,\n AldTreeNodeMouseEvent,\n AldTreeNodeProps,\n AldTreeNodeSelectedEvent,\n TreeProps,\n} from './Tree';\nexport type { DataNode };\n\ntype CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(\n props: React.PropsWithChildren<TreeProps<T>> & {\n ref?:\n | React.Ref<RcTree>\n | React.RefObject<RcTree | null>\n | React.MutableRefObject<RcTree | null>\n | null\n | undefined;\n },\n) => React.ReactElement) & {\n TreeNode: typeof TreeNode;\n DirectoryTree: typeof DirectoryTree;\n};\n\nconst Tree = TreePure as unknown as CompoundedComponent;\nTree.DirectoryTree = DirectoryTree;\nTree.TreeNode = TreeNode;\n\nexport default Tree;\n"],"mappings":";;;;AAwCA,IAAM,OAAO;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aloudata/aloudata-design",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
"@xobotyi/scrollbar-width": "^1.9.5",
|
|
71
71
|
"ahooks": "^3.7.8",
|
|
72
72
|
"compare-func": "^2.0.0",
|
|
73
|
-
"dayjs": "^1.11.20",
|
|
74
73
|
"embla-carousel-autoplay": "^8.6.0",
|
|
75
74
|
"embla-carousel-react": "^8.6.0",
|
|
76
75
|
"immer": "^10.0.3",
|
|
@@ -115,6 +114,7 @@
|
|
|
115
114
|
"browserslist": "^4.21.9",
|
|
116
115
|
"class-variance-authority": "^0.7.1",
|
|
117
116
|
"clsx": "^2.1.1",
|
|
117
|
+
"dayjs": "^1.11.20",
|
|
118
118
|
"eslint": "^8.45.0",
|
|
119
119
|
"eslint-plugin-compat": "^4.1.4",
|
|
120
120
|
"eslint-plugin-i18n": "^2.3.1",
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"zx": "^7.1.1"
|
|
142
142
|
},
|
|
143
143
|
"peerDependencies": {
|
|
144
|
+
"dayjs": ">=1.11.0",
|
|
144
145
|
"react": ">=18.0.0",
|
|
145
146
|
"react-dom": ">=18.0.0"
|
|
146
147
|
},
|