@ahoo-wang/fetcher-viewer 3.1.8 → 3.2.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 (72) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/components/RemoteSelect.d.ts.map +1 -1
  4. package/dist/components/TagInput.d.ts.map +1 -1
  5. package/dist/filter/AssemblyFilter.d.ts.map +1 -1
  6. package/dist/filter/BoolFilter.d.ts.map +1 -1
  7. package/dist/filter/DateTimeFilter.d.ts.map +1 -1
  8. package/dist/filter/IdFilter.d.ts.map +1 -1
  9. package/dist/filter/NumberFilter.d.ts.map +1 -1
  10. package/dist/filter/SelectFilter.d.ts.map +1 -1
  11. package/dist/filter/TextFilter.d.ts.map +1 -1
  12. package/dist/filter/TypedFilter.d.ts +2 -2
  13. package/dist/filter/TypedFilter.d.ts.map +1 -1
  14. package/dist/filter/filterRegistry.d.ts +49 -47
  15. package/dist/filter/filterRegistry.d.ts.map +1 -1
  16. package/dist/filter/operator/locale/index.d.ts.map +1 -1
  17. package/dist/filter/operator/locale/operator.zh_CN.d.ts.map +1 -1
  18. package/dist/filter/panel/AvailableFilterSelect.d.ts.map +1 -1
  19. package/dist/filter/panel/AvailableFilterSelectModal.d.ts.map +1 -1
  20. package/dist/filter/panel/EditableFilterPanel.d.ts.map +1 -1
  21. package/dist/filter/panel/RemovableTypedFilter.d.ts.map +1 -1
  22. package/dist/filter/panel/index.d.ts.map +1 -1
  23. package/dist/filter/types.d.ts +1 -1
  24. package/dist/filter/types.d.ts.map +1 -1
  25. package/dist/filter/useFilterState.d.ts.map +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.es.js +1227 -841
  29. package/dist/index.es.js.map +1 -1
  30. package/dist/index.umd.js +1 -1
  31. package/dist/index.umd.js.map +1 -1
  32. package/dist/registry/componentRegistry.d.ts +100 -0
  33. package/dist/registry/componentRegistry.d.ts.map +1 -0
  34. package/dist/registry/index.d.ts +2 -0
  35. package/dist/registry/index.d.ts.map +1 -0
  36. package/dist/table/cell/AvatarCell.d.ts +122 -0
  37. package/dist/table/cell/AvatarCell.d.ts.map +1 -0
  38. package/dist/table/cell/CalendarTime.d.ts +178 -0
  39. package/dist/table/cell/CalendarTime.d.ts.map +1 -0
  40. package/dist/table/cell/CurrencyCell.d.ts +275 -0
  41. package/dist/table/cell/CurrencyCell.d.ts.map +1 -0
  42. package/dist/table/cell/DateTimeCell.d.ts +125 -0
  43. package/dist/table/cell/DateTimeCell.d.ts.map +1 -0
  44. package/dist/table/cell/ImageCell.d.ts +129 -0
  45. package/dist/table/cell/ImageCell.d.ts.map +1 -0
  46. package/dist/table/cell/ImageGroupCell.d.ts +129 -0
  47. package/dist/table/cell/ImageGroupCell.d.ts.map +1 -0
  48. package/dist/table/cell/LinkCell.d.ts +104 -0
  49. package/dist/table/cell/LinkCell.d.ts.map +1 -0
  50. package/dist/table/cell/TagCell.d.ts +101 -0
  51. package/dist/table/cell/TagCell.d.ts.map +1 -0
  52. package/dist/table/cell/TagsCell.d.ts +128 -0
  53. package/dist/table/cell/TagsCell.d.ts.map +1 -0
  54. package/dist/table/cell/TextCell.d.ts +101 -0
  55. package/dist/table/cell/TextCell.d.ts.map +1 -0
  56. package/dist/table/cell/TypedCell.d.ts +99 -0
  57. package/dist/table/cell/TypedCell.d.ts.map +1 -0
  58. package/dist/table/cell/cellRegistry.d.ts +40 -0
  59. package/dist/table/cell/cellRegistry.d.ts.map +1 -0
  60. package/dist/table/cell/currencyFormatter.d.ts +161 -0
  61. package/dist/table/cell/currencyFormatter.d.ts.map +1 -0
  62. package/dist/table/cell/index.d.ts +54 -0
  63. package/dist/table/cell/index.d.ts.map +1 -0
  64. package/dist/table/cell/types.d.ts +128 -0
  65. package/dist/table/cell/types.d.ts.map +1 -0
  66. package/dist/table/cell/utils.d.ts +24 -0
  67. package/dist/table/cell/utils.d.ts.map +1 -0
  68. package/dist/table/index.d.ts +2 -0
  69. package/dist/table/index.d.ts.map +1 -0
  70. package/dist/types.d.ts +3 -0
  71. package/dist/types.d.ts.map +1 -1
  72. package/package.json +3 -3
@@ -0,0 +1,100 @@
1
+ import { FunctionComponent } from 'react';
2
+ /**
3
+ * Interface for objects that have a type property.
4
+ * This is used to identify components or other typed entities in the registry.
5
+ *
6
+ * @template Type - The type of the type property, defaults to string.
7
+ */
8
+ export interface TypeCapable<Type = string> {
9
+ /**
10
+ * The type identifier for this object.
11
+ */
12
+ type: Type;
13
+ }
14
+ /**
15
+ * A registry class for storing and retrieving React components by type.
16
+ * This allows dynamic component resolution based on type identifiers, useful for
17
+ * rendering different components based on data types or configurations.
18
+ *
19
+ * @template Type - The type used as keys in the registry (e.g., string, number).
20
+ * @template Props - The props type that all registered components must accept.
21
+ */
22
+ export declare class TypedComponentRegistry<Type, Props> {
23
+ private readonly registry;
24
+ /**
25
+ * Gets an array of all registered types in the registry.
26
+ *
27
+ * @returns An array containing all type keys currently registered.
28
+ */
29
+ get types(): Type[];
30
+ /**
31
+ * Gets an array of all type-component pairs in the registry.
32
+ *
33
+ * @returns An array of tuples containing [type, component] pairs.
34
+ */
35
+ get entries(): [Type, FunctionComponent<Props>][];
36
+ /**
37
+ * Gets the number of registered components in the registry.
38
+ *
39
+ * @returns The total count of registered components.
40
+ */
41
+ get size(): number;
42
+ /**
43
+ * Checks if a component is registered for the given type.
44
+ *
45
+ * @param {Type} type - The type to check for registration.
46
+ * @returns {boolean} True if a component is registered for the type, false otherwise.
47
+ */
48
+ has(type: Type): boolean;
49
+ /**
50
+ * Removes all registered components from the registry.
51
+ */
52
+ clear(): void;
53
+ /**
54
+ * Registers a React component for a specific type.
55
+ * Each type can only have one component registered.
56
+ *
57
+ * @param {Type} type - The type identifier for the component.
58
+ * @param {FunctionComponent<Props>} component - The React functional component to register.
59
+ * @throws {Error} If a component is already registered for the given type.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const registry = new TypedComponentRegistry<string, { value: string }>();
64
+ * registry.register('text', ({ value }) => <span>{value}</span>);
65
+ * ```
66
+ */
67
+ register(type: Type, component: FunctionComponent<Props>): void;
68
+ /**
69
+ * Unregisters the component for the given type.
70
+ * If no component is registered for the type, this operation does nothing.
71
+ *
72
+ * @param {Type} type - The type identifier to unregister.
73
+ */
74
+ unregister(type: Type): void;
75
+ /**
76
+ * Retrieves the component registered for the given type.
77
+ *
78
+ * @param {Type} type - The type identifier to look up.
79
+ * @returns {FunctionComponent<Props> | undefined} The registered React component, or undefined if not found.
80
+ */
81
+ get(type: Type): FunctionComponent<Props> | undefined;
82
+ /**
83
+ * Creates a new TypedComponentRegistry instance and optionally registers initial components.
84
+ *
85
+ * @template Type - The type used as keys.
86
+ * @template Props - The props type for components.
87
+ * @param {Array<[Type, FunctionComponent<Props>]>} [components=[]] - An optional array of [type, component] pairs to register initially.
88
+ * @returns {TypedComponentRegistry<Type, Props>} A new TypedComponentRegistry instance with the specified components registered.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const registry = TypedComponentRegistry.create([
93
+ * ['text', ({ value }) => <span>{value}</span>],
94
+ * ['number', ({ value }) => <strong>{value}</strong>]
95
+ * ]);
96
+ * ```
97
+ */
98
+ static create<Type, Props>(components?: [Type, FunctionComponent<Props>][]): TypedComponentRegistry<Type, Props>;
99
+ }
100
+ //# sourceMappingURL=componentRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/componentRegistry.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,MAAM;IACxC;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAsB,CAAC,IAAI,EAAE,KAAK;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkD;IAE3E;;;;OAIG;IACH,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,CAEhD;IAED;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAIxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAO/D;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI5B;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,SAAS;IAIrD;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EACvB,UAAU,GAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAO,GAClD,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC;CAOvC"}
@@ -0,0 +1,2 @@
1
+ export * from './componentRegistry';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { CellProps } from './types';
2
+ import { AvatarProps } from 'antd/es/avatar';
3
+ /**
4
+ * Constant representing the type identifier for avatar cells.
5
+ *
6
+ * This constant is used to register and identify avatar cell components
7
+ * in the cell registry system. It should be used when creating typed
8
+ * cell renderers for avatar-based table cells.
9
+ *
10
+ * @constant
11
+ * @type {string}
12
+ * @default 'avatar'
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { typedCellRender, AVATAR_CELL_TYPE } from './table/cell';
17
+ *
18
+ * const avatarRenderer = typedCellRender(AVATAR_CELL_TYPE, {
19
+ * size: 32
20
+ * });
21
+ * ```
22
+ */
23
+ export declare const AVATAR_CELL_TYPE = "avatar";
24
+ /**
25
+ * Props for the AvatarCell component, extending CellProps with string value type and AvatarProps attributes.
26
+ *
27
+ * @template RecordType - The type of the record containing the cell data.
28
+ * @interface AvatarCellProps
29
+ * @extends CellProps<string, RecordType, AvatarProps>
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * interface User {
34
+ * id: number;
35
+ * name: string;
36
+ * avatarUrl: string;
37
+ * }
38
+ *
39
+ * const props: AvatarCellProps<User> = {
40
+ * data: {
41
+ * value: "https://example.com/avatar.jpg",
42
+ * record: { id: 1, name: "John", avatarUrl: "https://example.com/avatar.jpg" },
43
+ * index: 0
44
+ * },
45
+ * attributes: {
46
+ * size: 40,
47
+ * alt: "User avatar"
48
+ * }
49
+ * };
50
+ * ```
51
+ */
52
+ export interface AvatarCellProps<RecordType = any> extends CellProps<string, RecordType, AvatarProps> {
53
+ }
54
+ /**
55
+ * Renders an avatar cell using Ant Design's Avatar component.
56
+ *
57
+ * This component displays user avatars in table cells with support for
58
+ * images, fallback text, and all Avatar component features. It handles
59
+ * null/undefined values gracefully by showing initials from the record name.
60
+ *
61
+ * @template RecordType - The type of the record containing the cell data.
62
+ * @param props - The props for the avatar cell component.
63
+ * @param props.data - The cell data containing value, record, and index.
64
+ * @param props.data.value - The avatar URL string or name to display.
65
+ * @param props.data.record - The full record object for context.
66
+ * @param props.data.index - The index of the row in the table.
67
+ * @param props.attributes - Optional attributes for the Avatar component.
68
+ * @returns A React element representing the avatar cell.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * <AvatarCell
73
+ * data={{
74
+ * value: "https://example.com/avatar.jpg",
75
+ * record: { id: 1, name: "John", avatar: "https://example.com/avatar.jpg" },
76
+ * index: 0
77
+ * }}
78
+ * attributes={{
79
+ * size: 32
80
+ * }}
81
+ * />
82
+ * ```
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * // With fallback to initials
87
+ * <AvatarCell
88
+ * data={{
89
+ * value: "John Doe",
90
+ * record: { id: 1, name: "John Doe" },
91
+ * index: 0
92
+ * }}
93
+ * attributes={{
94
+ * size: 40,
95
+ * style: { backgroundColor: '#1890ff' }
96
+ * }}
97
+ * />
98
+ * ```
99
+ *
100
+ * @example
101
+ * ```tsx
102
+ * // With TypeScript
103
+ * interface User {
104
+ * id: number;
105
+ * name: string;
106
+ * avatar?: string;
107
+ * }
108
+ *
109
+ * <AvatarCell<User>
110
+ * data={{
111
+ * value: user.avatar || user.name,
112
+ * record: user,
113
+ * index: 0
114
+ * }}
115
+ * attributes={{
116
+ * size: 24
117
+ * }}
118
+ * />
119
+ * ```
120
+ */
121
+ export declare function AvatarCell<RecordType = any>(props: AvatarCellProps<RecordType>): import("react/jsx-runtime").JSX.Element;
122
+ //# sourceMappingURL=AvatarCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarCell.d.ts","sourceRoot":"","sources":["../../../src/table/cell/AvatarCell.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,eAAe,CAAC,UAAU,GAAG,GAAG,CAC/C,SAAQ,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC;CAAG;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAgB,UAAU,CAAC,UAAU,GAAG,GAAG,EACzC,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC,2CAenC"}
@@ -0,0 +1,178 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { CellProps } from './types';
3
+ import { TextProps } from 'antd/es/typography/Text';
4
+ /**
5
+ * Calendar format configuration for relative time display.
6
+ *
7
+ * Defines the format strings used by dayjs calendar plugin to display
8
+ * dates relative to the current time (e.g., "今天", "昨天", etc.).
9
+ *
10
+ * @interface CalendarFormats
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const customFormats: CalendarFormats = {
15
+ * sameDay: '[今天] HH:mm',
16
+ * lastDay: '[昨天] HH:mm',
17
+ * sameElse: 'YYYY-MM-DD HH:mm:ss'
18
+ * };
19
+ * ```
20
+ */
21
+ export interface CalendarFormats {
22
+ /** Format for dates that are today */
23
+ sameDay?: string;
24
+ /** Format for dates that are tomorrow */
25
+ nextDay?: string;
26
+ /** Format for dates in the next week */
27
+ nextWeek?: string;
28
+ /** Format for dates that were yesterday */
29
+ lastDay?: string;
30
+ /** Format for dates in the last week */
31
+ lastWeek?: string;
32
+ /** Format for all other dates */
33
+ sameElse?: string;
34
+ }
35
+ /**
36
+ * Constant representing the type identifier for calendar time cells.
37
+ *
38
+ * This constant is used to register and identify calendar time cell components
39
+ * in the cell registry system. It should be used when creating typed
40
+ * cell renderers for calendar-based datetime table cells.
41
+ *
42
+ * @constant
43
+ * @type {string}
44
+ * @default 'calendar-time'
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * import { typedCellRender, CALENDAR_CELL_TYPE } from './table/cell';
49
+ *
50
+ * const calendarRenderer = typedCellRender(CALENDAR_CELL_TYPE, {
51
+ * formats: {
52
+ * sameDay: '[今天] HH:mm',
53
+ * lastDay: '[昨天] HH:mm'
54
+ * }
55
+ * });
56
+ * ```
57
+ */
58
+ export declare const CALENDAR_CELL_TYPE = "calendar-time";
59
+ /**
60
+ * Default calendar formats for Chinese locale.
61
+ *
62
+ * Provides sensible defaults for displaying relative dates in Chinese,
63
+ * falling back to standard datetime format for older dates.
64
+ *
65
+ * @constant
66
+ * @type {CalendarFormats}
67
+ */
68
+ export declare const DEFAULT_CALENDAR_FORMATS: CalendarFormats;
69
+ /**
70
+ * Props for the CalendarTimeCell component, extending CellProps with datetime value type and TextProps attributes.
71
+ *
72
+ * @template RecordType - The type of the record containing the cell data.
73
+ * @interface CalendarTimeProps
74
+ * @extends CellProps<string | number | Date | Dayjs, RecordType, TextProps & { formats?: CalendarFormats }>
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * interface Event {
79
+ * id: number;
80
+ * title: string;
81
+ * createdAt: string;
82
+ * updatedAt: number;
83
+ * }
84
+ *
85
+ * const props: CalendarTimeProps<Event> = {
86
+ * data: {
87
+ * value: "2024-01-15T10:30:45Z",
88
+ * record: { id: 1, title: "Meeting", createdAt: "2024-01-15T10:30:45Z", updatedAt: 1705312200000 },
89
+ * index: 0
90
+ * },
91
+ * attributes: {
92
+ * formats: {
93
+ * sameDay: "[今天] HH:mm",
94
+ * lastDay: "[昨天] HH:mm"
95
+ * }
96
+ * }
97
+ * };
98
+ * ```
99
+ */
100
+ export interface CalendarTimeProps<RecordType = any> extends CellProps<string | number | Date | Dayjs, RecordType, TextProps & {
101
+ formats?: CalendarFormats;
102
+ }> {
103
+ }
104
+ /**
105
+ * Renders a calendar time cell using Ant Design's Typography.Text component with dayjs calendar formatting.
106
+ *
107
+ * This component displays datetime values in table cells using relative time formats
108
+ * (e.g., "今天 10:30", "昨天 15:45") based on the current date. It supports various input formats
109
+ * (string, number timestamp, Date object, or Dayjs object) and customizable calendar formats
110
+ * through the dayjs calendar plugin. It provides consistent relative time display with fallback handling
111
+ * for invalid dates.
112
+ *
113
+ * @template RecordType - The type of the record containing the cell data.
114
+ * @param props - The props for the calendar time cell component.
115
+ * @param props.data - The cell data containing value, record, and index.
116
+ * @param props.data.value - The datetime value to display (string, number, Date, or Dayjs).
117
+ * @param props.data.record - The full record object for context.
118
+ * @param props.data.index - The index of the row in the table.
119
+ * @param props.attributes - Optional attributes including calendar formats and TextProps.
120
+ * @param props.attributes.formats - Optional calendar format configuration (default: DEFAULT_CALENDAR_FORMATS).
121
+ * @returns A React element representing the formatted calendar time cell.
122
+ *
123
+ * @example
124
+ * ```tsx
125
+ * <CalendarTimeCell
126
+ * data={{
127
+ * value: "2024-01-15T10:30:45Z",
128
+ * record: { id: 1, title: "Event", createdAt: "2024-01-15T10:30:45Z" },
129
+ * index: 0
130
+ * }}
131
+ * attributes={{
132
+ * formats: {
133
+ * sameDay: "[今天] HH:mm",
134
+ * lastDay: "[昨天] HH:mm"
135
+ * }
136
+ * }}
137
+ * />
138
+ * ```
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * // With TypeScript and timestamp
143
+ * interface Log {
144
+ * id: number;
145
+ * message: string;
146
+ * timestamp: number;
147
+ * }
148
+ *
149
+ * <CalendarTimeCell<Log>
150
+ * data={{
151
+ * value: 1705312200000,
152
+ * record: { id: 1, message: "User login", timestamp: 1705312200000 },
153
+ * index: 0
154
+ * }}
155
+ * attributes={{
156
+ * formats: {
157
+ * sameDay: "[今天] HH:mm",
158
+ * lastDay: "[昨天] HH:mm"
159
+ * },
160
+ * style: { color: '#666' }
161
+ * }}
162
+ * />
163
+ * ```
164
+ *
165
+ * @example
166
+ * ```tsx
167
+ * // With Date object
168
+ * <CalendarTimeCell
169
+ * data={{
170
+ * value: new Date(),
171
+ * record: { id: 1, title: "Current time" },
172
+ * index: 0
173
+ * }}
174
+ * />
175
+ * ```
176
+ */
177
+ export declare function CalendarTimeCell<RecordType = any>(props: CalendarTimeProps<RecordType>): import("react/jsx-runtime").JSX.Element;
178
+ //# sourceMappingURL=CalendarTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalendarTime.d.ts","sourceRoot":"","sources":["../../../src/table/cell/CalendarTime.tsx"],"names":[],"mappings":"AAcA,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAOtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,iBAAiB,CAAC,UAAU,GAAG,GAAG,CACjD,SAAQ,SAAS,CACf,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,EAC9B,UAAU,EACV,SAAS,GAAG;IAAE,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,CAC1C;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAG,GAAG,EAC/C,KAAK,EAAE,iBAAiB,CAAC,UAAU,CAAC,2CAQrC"}
@@ -0,0 +1,275 @@
1
+ import { CellProps } from './types';
2
+ import { TextProps } from 'antd/es/typography/Text';
3
+ import { CurrencyFormatOptions } from './currencyFormatter';
4
+ /**
5
+ * Constant representing the type identifier for currency cells.
6
+ *
7
+ * This constant is used to register and identify currency cell components
8
+ * in the cell registry system. It should be used when creating typed
9
+ * cell renderers for currency-based table cells.
10
+ *
11
+ * @constant
12
+ * @type {string}
13
+ * @default 'currency'
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { typedCellRender, CURRENCY_CELL_TYPE } from './table/cell';
18
+ *
19
+ * const currencyRenderer = typedCellRender(CURRENCY_CELL_TYPE, {
20
+ * format: {
21
+ * currency: 'USD',
22
+ * decimals: 2,
23
+ * locale: 'en-US'
24
+ * },
25
+ * style: { fontWeight: 'bold' }
26
+ * });
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * // Using with cell registry
32
+ * import { cellRegistry, CURRENCY_CELL_TYPE } from './table/cell';
33
+ *
34
+ * const CurrencyCellComponent = cellRegistry.get(CURRENCY_CELL_TYPE);
35
+ * if (CurrencyCellComponent) {
36
+ * // Use the component for rendering currency cells
37
+ * }
38
+ * ```
39
+ */
40
+ export declare const CURRENCY_CELL_TYPE = "currency";
41
+ /**
42
+ * Attributes for currency cell formatting, extending TextProps with currency-specific options.
43
+ *
44
+ * This interface combines Ant Design's TextProps for text styling with
45
+ * a format property containing CurrencyFormatOptions for currency formatting configuration.
46
+ * The format property is optional and allows customization of how currency values are displayed.
47
+ *
48
+ * @interface CurrencyAttributes
49
+ * @extends TextProps
50
+ *
51
+ * @property {CurrencyFormatOptions} [format] - Optional currency formatting options.
52
+ * When not provided, uses default currency formatting (CNY, zh-CN locale, 2 decimals).
53
+ * @property {boolean} [ellipsis] - Whether to truncate text with ellipsis when it overflows.
54
+ * @property {React.CSSProperties} [style] - Custom CSS styles to apply to the text element.
55
+ * @property {string} [className] - Additional CSS class names to apply to the text element.
56
+ * @property {React.ReactNode} [children] - Custom content to display instead of the formatted currency value.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * const attributes: CurrencyAttributes = {
61
+ * format: {
62
+ * currency: 'USD',
63
+ * currencyDisplay: 'symbol',
64
+ * decimals: 2,
65
+ * locale: 'en-US',
66
+ * useGrouping: true
67
+ * },
68
+ * ellipsis: true,
69
+ * style: { color: 'green', fontWeight: 'bold' },
70
+ * className: 'currency-text'
71
+ * };
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```tsx
76
+ * // Using only text styling without currency formatting
77
+ * const attributes: CurrencyAttributes = {
78
+ * style: { color: 'red' },
79
+ * ellipsis: true
80
+ * };
81
+ * ```
82
+ */
83
+ export interface CurrencyAttributes extends TextProps {
84
+ format?: CurrencyFormatOptions;
85
+ }
86
+ /**
87
+ * Props for the CurrencyCell component, extending CellProps with numeric value type and CurrencyAttributes.
88
+ *
89
+ * This interface defines the complete props structure for the CurrencyCell component,
90
+ * combining cell data with optional formatting and styling attributes.
91
+ *
92
+ * @template RecordType - The type of the record containing the cell data.
93
+ * @interface CurrencyCellProps
94
+ * @extends CellProps<number | string, RecordType, CurrencyAttributes>
95
+ *
96
+ * @property {CellData<number | string, RecordType>} data - The cell data containing the value to format.
97
+ * @property {CurrencyAttributes} [attributes] - Optional attributes for currency formatting and text styling.
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * interface Product {
102
+ * id: number;
103
+ * name: string;
104
+ * price: number;
105
+ * }
106
+ *
107
+ * const props: CurrencyCellProps<Product> = {
108
+ * data: {
109
+ * value: 1234.56,
110
+ * record: { id: 1, name: "Widget", price: 1234.56 },
111
+ * index: 0
112
+ * },
113
+ * attributes: {
114
+ * format: {
115
+ * currency: 'USD',
116
+ * decimals: 2,
117
+ * locale: 'en-US'
118
+ * },
119
+ * ellipsis: true,
120
+ * style: { fontWeight: 'bold' }
121
+ * }
122
+ * };
123
+ * ```
124
+ *
125
+ * @example
126
+ * ```tsx
127
+ * // With string values (automatically parsed)
128
+ * const props: CurrencyCellProps = {
129
+ * data: {
130
+ * value: "999.99",
131
+ * record: { id: 1, amount: "999.99" },
132
+ * index: 0
133
+ * },
134
+ * attributes: {
135
+ * format: {
136
+ * currency: 'EUR',
137
+ * currencyDisplay: 'code'
138
+ * }
139
+ * }
140
+ * };
141
+ * ```
142
+ */
143
+ export interface CurrencyCellProps<RecordType = any> extends CellProps<number | string, RecordType, CurrencyAttributes> {
144
+ }
145
+ /**
146
+ * Renders a currency cell using the formatCurrency function and Ant Design's Typography.Text component.
147
+ *
148
+ * This component displays numeric values formatted as localized currency strings in table cells.
149
+ * It supports various currencies, locales, decimal precision, and formatting options while
150
+ * providing text styling capabilities through Ant Design's Typography.Text component.
151
+ *
152
+ * The component automatically handles invalid values (null, undefined, NaN, Infinity) by
153
+ * displaying a fallback string, and supports both numeric and string inputs that are
154
+ * automatically parsed.
155
+ *
156
+ * @template RecordType - The type of the record containing the cell data.
157
+ * @param {CurrencyCellProps<RecordType>} props - The props for the currency cell component.
158
+ * @param {CellData<number | string, RecordType>} props.data - The cell data containing value, record, and index.
159
+ * @param {number | string} props.data.value - The numeric or string value to format as currency.
160
+ * String values are automatically parsed, removing non-numeric characters except decimal points and minus signs.
161
+ * @param {RecordType} props.data.record - The full record object providing context for the cell.
162
+ * @param {number} props.data.index - The zero-based index of the row in the table.
163
+ * @param {CurrencyAttributes} [props.attributes] - Optional attributes for currency formatting and text styling.
164
+ * @param {CurrencyFormatOptions} [props.attributes.format] - Currency formatting options including currency code, locale, decimals, etc.
165
+ * @param {boolean} [props.attributes.ellipsis] - Whether to truncate text with ellipsis when it overflows.
166
+ * @param {React.CSSProperties} [props.attributes.style] - Custom CSS styles to apply to the text element.
167
+ * @param {string} [props.attributes.className] - Additional CSS class names to apply to the text element.
168
+ * @param {React.ReactNode} [props.attributes.children] - Custom content to display instead of the formatted currency value.
169
+ * @returns {React.ReactElement} A React element representing the formatted currency cell using Typography.Text.
170
+ *
171
+ * @throws {Error} This component does not throw errors directly, but may propagate errors from the formatCurrency function
172
+ * if invalid currency codes or locales are provided in the format options.
173
+ *
174
+ * @example
175
+ * ```tsx
176
+ * // Basic usage with USD formatting
177
+ * <CurrencyCell
178
+ * data={{
179
+ * value: 1234.56,
180
+ * record: { id: 1, name: "Product", price: 1234.56 },
181
+ * index: 0
182
+ * }}
183
+ * attributes={{
184
+ * format: {
185
+ * currency: 'USD',
186
+ * decimals: 2,
187
+ * locale: 'en-US'
188
+ * },
189
+ * ellipsis: true,
190
+ * style: { fontWeight: 'bold' }
191
+ * }}
192
+ * />
193
+ * ```
194
+ *
195
+ * @example
196
+ * ```tsx
197
+ * // With TypeScript and EUR currency
198
+ * interface Transaction {
199
+ * id: string;
200
+ * amount: number;
201
+ * currency: string;
202
+ * }
203
+ *
204
+ * <CurrencyCell<Transaction>
205
+ * data={{
206
+ * value: 999.99,
207
+ * record: { id: "tx-123", amount: 999.99, currency: "EUR" },
208
+ * index: 0
209
+ * }}
210
+ * attributes={{
211
+ * format: {
212
+ * currency: 'EUR',
213
+ * currencyDisplay: 'code',
214
+ * decimals: 2,
215
+ * locale: 'de-DE'
216
+ * },
217
+ * style: { color: 'green' }
218
+ * }}
219
+ * />
220
+ * ```
221
+ *
222
+ * @example
223
+ * ```tsx
224
+ * // Using string values (automatically parsed)
225
+ * <CurrencyCell
226
+ * data={{
227
+ * value: "1,234.56",
228
+ * record: { id: 1, amount: "1,234.56" },
229
+ * index: 0
230
+ * }}
231
+ * attributes={{
232
+ * format: {
233
+ * currency: 'CNY',
234
+ * useGrouping: true
235
+ * }
236
+ * }}
237
+ * />
238
+ * ```
239
+ *
240
+ * @example
241
+ * ```tsx
242
+ * // Handling invalid values (displays fallback)
243
+ * <CurrencyCell
244
+ * data={{
245
+ * value: NaN,
246
+ * record: { id: 1, amount: NaN },
247
+ * index: 0
248
+ * }}
249
+ * attributes={{
250
+ * format: {
251
+ * currency: 'USD',
252
+ * fallback: 'N/A'
253
+ * }
254
+ * }}
255
+ * />
256
+ * ```
257
+ *
258
+ * @example
259
+ * ```tsx
260
+ * // Custom content override
261
+ * <CurrencyCell
262
+ * data={{
263
+ * value: 100,
264
+ * record: { id: 1, amount: 100 },
265
+ * index: 0
266
+ * }}
267
+ * attributes={{
268
+ * format: { currency: 'USD' },
269
+ * children: <span style={{ color: 'red' }}>Custom Content</span>
270
+ * }}
271
+ * />
272
+ * ```
273
+ */
274
+ export declare function CurrencyCell<RecordType = any>(props: CurrencyCellProps<RecordType>): import("react/jsx-runtime").JSX.Element;
275
+ //# sourceMappingURL=CurrencyCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrencyCell.d.ts","sourceRoot":"","sources":["../../../src/table/cell/CurrencyCell.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAkB,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAI5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,WAAW,iBAAiB,CAAC,UAAU,GAAG,GAAG,CACjD,SAAQ,SAAS,CAAC,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,kBAAkB,CAAC;CAAG;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgIG;AACH,wBAAgB,YAAY,CAAC,UAAU,GAAG,GAAG,EAC3C,KAAK,EAAE,iBAAiB,CAAC,UAAU,CAAC,2CAMrC"}