@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.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/components/RemoteSelect.d.ts.map +1 -1
- package/dist/components/TagInput.d.ts.map +1 -1
- package/dist/filter/AssemblyFilter.d.ts.map +1 -1
- package/dist/filter/BoolFilter.d.ts.map +1 -1
- package/dist/filter/DateTimeFilter.d.ts.map +1 -1
- package/dist/filter/IdFilter.d.ts.map +1 -1
- package/dist/filter/NumberFilter.d.ts.map +1 -1
- package/dist/filter/SelectFilter.d.ts.map +1 -1
- package/dist/filter/TextFilter.d.ts.map +1 -1
- package/dist/filter/TypedFilter.d.ts +2 -2
- package/dist/filter/TypedFilter.d.ts.map +1 -1
- package/dist/filter/filterRegistry.d.ts +49 -47
- package/dist/filter/filterRegistry.d.ts.map +1 -1
- package/dist/filter/operator/locale/index.d.ts.map +1 -1
- package/dist/filter/operator/locale/operator.zh_CN.d.ts.map +1 -1
- package/dist/filter/panel/AvailableFilterSelect.d.ts.map +1 -1
- package/dist/filter/panel/AvailableFilterSelectModal.d.ts.map +1 -1
- package/dist/filter/panel/EditableFilterPanel.d.ts.map +1 -1
- package/dist/filter/panel/RemovableTypedFilter.d.ts.map +1 -1
- package/dist/filter/panel/index.d.ts.map +1 -1
- package/dist/filter/types.d.ts +1 -1
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/useFilterState.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1227 -841
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/registry/componentRegistry.d.ts +100 -0
- package/dist/registry/componentRegistry.d.ts.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/table/cell/AvatarCell.d.ts +122 -0
- package/dist/table/cell/AvatarCell.d.ts.map +1 -0
- package/dist/table/cell/CalendarTime.d.ts +178 -0
- package/dist/table/cell/CalendarTime.d.ts.map +1 -0
- package/dist/table/cell/CurrencyCell.d.ts +275 -0
- package/dist/table/cell/CurrencyCell.d.ts.map +1 -0
- package/dist/table/cell/DateTimeCell.d.ts +125 -0
- package/dist/table/cell/DateTimeCell.d.ts.map +1 -0
- package/dist/table/cell/ImageCell.d.ts +129 -0
- package/dist/table/cell/ImageCell.d.ts.map +1 -0
- package/dist/table/cell/ImageGroupCell.d.ts +129 -0
- package/dist/table/cell/ImageGroupCell.d.ts.map +1 -0
- package/dist/table/cell/LinkCell.d.ts +104 -0
- package/dist/table/cell/LinkCell.d.ts.map +1 -0
- package/dist/table/cell/TagCell.d.ts +101 -0
- package/dist/table/cell/TagCell.d.ts.map +1 -0
- package/dist/table/cell/TagsCell.d.ts +128 -0
- package/dist/table/cell/TagsCell.d.ts.map +1 -0
- package/dist/table/cell/TextCell.d.ts +101 -0
- package/dist/table/cell/TextCell.d.ts.map +1 -0
- package/dist/table/cell/TypedCell.d.ts +99 -0
- package/dist/table/cell/TypedCell.d.ts.map +1 -0
- package/dist/table/cell/cellRegistry.d.ts +40 -0
- package/dist/table/cell/cellRegistry.d.ts.map +1 -0
- package/dist/table/cell/currencyFormatter.d.ts +161 -0
- package/dist/table/cell/currencyFormatter.d.ts.map +1 -0
- package/dist/table/cell/index.d.ts +54 -0
- package/dist/table/cell/index.d.ts.map +1 -0
- package/dist/table/cell/types.d.ts +128 -0
- package/dist/table/cell/types.d.ts.map +1 -0
- package/dist/table/cell/utils.d.ts +24 -0
- package/dist/table/cell/utils.d.ts.map +1 -0
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { CellProps } from './types';
|
|
2
|
+
import { TagProps } from 'antd';
|
|
3
|
+
import { SpaceProps } from 'antd/es/space';
|
|
4
|
+
/**
|
|
5
|
+
* Constant representing the type identifier for tags cells.
|
|
6
|
+
*
|
|
7
|
+
* This constant is used to register and identify tags cell components
|
|
8
|
+
* in the cell registry system. It should be used when creating typed
|
|
9
|
+
* cell renderers for tags-based table cells.
|
|
10
|
+
*
|
|
11
|
+
* @constant
|
|
12
|
+
* @type {string}
|
|
13
|
+
* @default 'tags'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { typedCellRender, TAGS_CELL_TYPE } from './table/cell';
|
|
18
|
+
*
|
|
19
|
+
* const tagsRenderer = typedCellRender(TAGS_CELL_TYPE, {
|
|
20
|
+
* 'urgent': { color: 'red' },
|
|
21
|
+
* 'normal': { color: 'blue' }
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const TAGS_CELL_TYPE = "tags";
|
|
26
|
+
/**
|
|
27
|
+
* Props for the TagsCell component, extending CellProps with string array value type and tag attributes mapping.
|
|
28
|
+
*
|
|
29
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
30
|
+
* @interface TagsCellProps
|
|
31
|
+
* @extends CellProps<string[], RecordType, Record<string, TagProps>>
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* interface Product {
|
|
36
|
+
* id: number;
|
|
37
|
+
* name: string;
|
|
38
|
+
* tags: string[];
|
|
39
|
+
* category: string;
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* const props: TagsCellProps<Product> = {
|
|
43
|
+
* data: {
|
|
44
|
+
* value: ["electronics", "bestseller"],
|
|
45
|
+
* record: { id: 1, name: "Laptop", tags: ["electronics", "bestseller"], category: "computers" },
|
|
46
|
+
* index: 0
|
|
47
|
+
* },
|
|
48
|
+
* attributes: {
|
|
49
|
+
* "electronics": { color: "blue" },
|
|
50
|
+
* "bestseller": { color: "gold" }
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export interface TagsCellProps<RecordType = any> extends CellProps<string[], RecordType, Record<string, TagProps>> {
|
|
56
|
+
space?: SpaceProps;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Renders a tags cell using Ant Design's Space and Tag components.
|
|
60
|
+
*
|
|
61
|
+
* This component displays multiple string tags in table cells, with each tag
|
|
62
|
+
* rendered using the TagCell component. It supports individual tag styling
|
|
63
|
+
* through attributes mapping and automatically filters out empty or whitespace-only tags.
|
|
64
|
+
* Tags are displayed horizontally in a Space component for proper spacing.
|
|
65
|
+
*
|
|
66
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
67
|
+
* @param props - The props for the tags cell component.
|
|
68
|
+
* @param props.data - The cell data containing value array, record, and index.
|
|
69
|
+
* @param props.data.value - The array of string tags to display in the cell.
|
|
70
|
+
* @param props.data.record - The full record object for context.
|
|
71
|
+
* @param props.data.index - The index of the row in the table.
|
|
72
|
+
* @param props.attributes - Optional mapping of tag names to TagProps for individual tag styling.
|
|
73
|
+
* @returns A React element containing the tags wrapped in a Space component, or null if no valid tags.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <TagsCell
|
|
78
|
+
* data={{
|
|
79
|
+
* value: ["urgent", "frontend", "bug"],
|
|
80
|
+
* record: { id: 1, title: "Fix login issue", tags: ["urgent", "frontend", "bug"] },
|
|
81
|
+
* index: 0
|
|
82
|
+
* }}
|
|
83
|
+
* attributes={{
|
|
84
|
+
* "urgent": { color: "red" },
|
|
85
|
+
* "frontend": { color: "blue" },
|
|
86
|
+
* "bug": { color: "orange" }
|
|
87
|
+
* }}
|
|
88
|
+
* />
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* // With TypeScript
|
|
94
|
+
* interface Task {
|
|
95
|
+
* id: number;
|
|
96
|
+
* title: string;
|
|
97
|
+
* tags: string[];
|
|
98
|
+
* priority: string;
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* <TagsCell<Task>
|
|
102
|
+
* data={{
|
|
103
|
+
* value: ["urgent", "frontend"],
|
|
104
|
+
* record: { id: 1, title: "Task", tags: ["urgent", "frontend"], priority: "high" },
|
|
105
|
+
* index: 0
|
|
106
|
+
* }}
|
|
107
|
+
* attributes={{
|
|
108
|
+
* "urgent": { color: "red", closable: true },
|
|
109
|
+
* "frontend": { color: "geekblue" }
|
|
110
|
+
* }}
|
|
111
|
+
* />
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* // Empty tags array - renders nothing
|
|
117
|
+
* <TagsCell
|
|
118
|
+
* data={{
|
|
119
|
+
* value: [],
|
|
120
|
+
* record: { id: 1, title: "Task" },
|
|
121
|
+
* index: 0
|
|
122
|
+
* }}
|
|
123
|
+
* attributes={{}}
|
|
124
|
+
* />
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function TagsCell<RecordType = any>(props: TagsCellProps<RecordType>): import("react/jsx-runtime").JSX.Element | null;
|
|
128
|
+
//# sourceMappingURL=TagsCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagsCell.d.ts","sourceRoot":"","sources":["../../../src/table/cell/TagsCell.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAS,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,GAAG,GAAG,CAC7C,SAAQ,SAAS,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjE,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,kDAmB1E"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CellProps } from './types';
|
|
2
|
+
import { TextProps } from 'antd/es/typography/Text';
|
|
3
|
+
/**
|
|
4
|
+
* Constant representing the type identifier for text cells.
|
|
5
|
+
*
|
|
6
|
+
* This constant is used to register and identify text cell components
|
|
7
|
+
* in the cell registry system. It should be used when creating typed
|
|
8
|
+
* cell renderers for text-based table cells.
|
|
9
|
+
*
|
|
10
|
+
* @constant
|
|
11
|
+
* @type {string}
|
|
12
|
+
* @default 'text'
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { typedCellRender, TEXT_CELL_TYPE } from './table/cell';
|
|
17
|
+
*
|
|
18
|
+
* const textRenderer = typedCellRender(TEXT_CELL_TYPE, { ellipsis: true });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const TEXT_CELL_TYPE = "text";
|
|
22
|
+
/**
|
|
23
|
+
* Props for the TextCell component, extending CellProps with string value type and TextProps attributes.
|
|
24
|
+
*
|
|
25
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
26
|
+
* @interface TextCellProps
|
|
27
|
+
* @extends CellProps<string, RecordType, TextProps>
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* interface User {
|
|
32
|
+
* id: number;
|
|
33
|
+
* name: string;
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* const props: TextCellProps<User> = {
|
|
37
|
+
* data: {
|
|
38
|
+
* value: "John Doe",
|
|
39
|
+
* record: { id: 1, name: "John Doe" },
|
|
40
|
+
* index: 0
|
|
41
|
+
* },
|
|
42
|
+
* attributes: { ellipsis: true }
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export interface TextCellProps<RecordType = any> extends CellProps<string, RecordType, TextProps> {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Renders a text cell using Ant Design's Typography.Text component.
|
|
50
|
+
*
|
|
51
|
+
* This component displays string values in table cells with support for
|
|
52
|
+
* various text formatting options provided by Ant Design's Typography.Text.
|
|
53
|
+
* It handles the rendering of text content while allowing customization
|
|
54
|
+
* through attributes like ellipsis, styling, and other TextProps.
|
|
55
|
+
*
|
|
56
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
57
|
+
* @param props - The props for the text cell component.
|
|
58
|
+
* @param props.data - The cell data containing value, record, and index.
|
|
59
|
+
* @param props.data.value - The string value to display in the cell.
|
|
60
|
+
* @param props.data.record - The full record object for context.
|
|
61
|
+
* @param props.data.index - The index of the row in the table.
|
|
62
|
+
* @param props.attributes - Optional attributes to pass to Typography.Text component.
|
|
63
|
+
* @returns A React element representing the text cell.
|
|
64
|
+
*
|
|
65
|
+
* @throws {Error} If the value cannot be rendered as React children (e.g., objects).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* <TextCell
|
|
70
|
+
* data={{
|
|
71
|
+
* value: "Hello World",
|
|
72
|
+
* record: { id: 1, name: "John" },
|
|
73
|
+
* index: 0
|
|
74
|
+
* }}
|
|
75
|
+
* attributes={{
|
|
76
|
+
* ellipsis: true,
|
|
77
|
+
* style: { color: 'blue' }
|
|
78
|
+
* }}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* // With TypeScript
|
|
85
|
+
* interface User {
|
|
86
|
+
* id: number;
|
|
87
|
+
* name: string;
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* <TextCell<User>
|
|
91
|
+
* data={{
|
|
92
|
+
* value: "John Doe",
|
|
93
|
+
* record: { id: 1, name: "John Doe" },
|
|
94
|
+
* index: 0
|
|
95
|
+
* }}
|
|
96
|
+
* attributes={{ ellipsis: { tooltip: true } }}
|
|
97
|
+
* />
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function TextCell<RecordType = any>(props: TextCellProps<RecordType>): import("react/jsx-runtime").JSX.Element;
|
|
101
|
+
//# sourceMappingURL=TextCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextCell.d.ts","sourceRoot":"","sources":["../../../src/table/cell/TextCell.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,aAAa,CAAC,UAAU,GAAG,GAAG,CAC7C,SAAQ,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,2CAE1E"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the type identifier for different cell components.
|
|
4
|
+
*
|
|
5
|
+
* Cell types are string identifiers used to register and retrieve
|
|
6
|
+
* specific cell rendering components from the cell registry.
|
|
7
|
+
* Common types include 'text', 'number', 'date', etc.
|
|
8
|
+
*
|
|
9
|
+
* @typedef {string} CellType
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const textType: CellType = 'text';
|
|
14
|
+
* const customType: CellType = 'custom-cell';
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type CellType = string;
|
|
18
|
+
/**
|
|
19
|
+
* A function type for rendering typed cells, supporting both synchronous and asynchronous rendering.
|
|
20
|
+
*
|
|
21
|
+
* Cell renderers are functions that take cell data and return React nodes
|
|
22
|
+
* for display in table cells. They can be synchronous for immediate rendering
|
|
23
|
+
* or asynchronous for cases requiring data fetching or complex computations.
|
|
24
|
+
*
|
|
25
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
26
|
+
* @typedef CellRenderer
|
|
27
|
+
* @param value - The value to render in the cell. Can be any type depending on the cell implementation.
|
|
28
|
+
* @param record - The full record object providing context for the cell rendering.
|
|
29
|
+
* @param index - The zero-based index of the row in the table.
|
|
30
|
+
* @returns A React node for synchronous rendering, or a Promise resolving to a React node for asynchronous rendering.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // Synchronous renderer
|
|
35
|
+
* const textRenderer: CellRenderer<User> = (value, record, index) => {
|
|
36
|
+
* return <span>{String(value)}</span>;
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* // Asynchronous renderer
|
|
40
|
+
* const asyncRenderer: CellRenderer<User> = async (value, record, index) => {
|
|
41
|
+
* const formatted = await formatValue(value);
|
|
42
|
+
* return <span>{formatted}</span>;
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export type CellRenderer<RecordType = any> = (value: any, record: RecordType, index: number) => React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a typed cell renderer function for a given cell type.
|
|
49
|
+
*
|
|
50
|
+
* This function retrieves a cell component from the registry based on the
|
|
51
|
+
* provided type and returns a renderer function that can be used to render
|
|
52
|
+
* cells of that type. The returned renderer encapsulates the component and
|
|
53
|
+
* its attributes for repeated use.
|
|
54
|
+
*
|
|
55
|
+
* @template RecordType - The type of the record containing the cell data.
|
|
56
|
+
* @template Attributes - The type of additional attributes for the cell component.
|
|
57
|
+
* @param type - The cell type identifier to look up in the registry (e.g., 'text', 'number').
|
|
58
|
+
* @param attributes - Optional attributes object to pass to the cell component for customization.
|
|
59
|
+
* @returns A renderer function for the specified cell type, or undefined if the type is not registered.
|
|
60
|
+
*
|
|
61
|
+
* @throws {Error} This function itself doesn't throw, but the returned renderer may throw
|
|
62
|
+
* if the underlying component encounters rendering errors.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* // Create a text renderer with ellipsis
|
|
67
|
+
* const textRenderer = typedCellRender('text', { ellipsis: true });
|
|
68
|
+
*
|
|
69
|
+
* // Use the renderer to create cells
|
|
70
|
+
* const cell1 = textRenderer('Hello World', { id: 1 }, 0);
|
|
71
|
+
* const cell2 = textRenderer('Long text...', { id: 2 }, 1);
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* // With TypeScript types
|
|
77
|
+
* interface User {
|
|
78
|
+
* id: number;
|
|
79
|
+
* name: string;
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* const userNameRenderer = typedCellRender<User>('text', {
|
|
83
|
+
* style: { fontWeight: 'bold' }
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* const cell = userNameRenderer('John Doe', { id: 1, name: 'John Doe' }, 0);
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* // Handling unregistered types
|
|
92
|
+
* const unknownRenderer = typedCellRender('unknown-type');
|
|
93
|
+
* if (!unknownRenderer) {
|
|
94
|
+
* console.warn('Unknown cell type');
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function typedCellRender<RecordType = any, Attributes = any>(type: CellType, attributes?: Attributes): CellRenderer<RecordType> | undefined;
|
|
99
|
+
//# sourceMappingURL=TypedCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedCell.d.ts","sourceRoot":"","sources":["../../../src/table/cell/TypedCell.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAGpC;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,YAAY,CAAC,UAAU,GAAG,GAAG,IAAI,CAC3C,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,KACV,KAAK,CAAC,SAAS,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAChE,IAAI,EAAE,QAAQ,EACd,UAAU,CAAC,EAAE,UAAU,GACtB,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAgBtC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TypedComponentRegistry } from '../../registry';
|
|
2
|
+
import { CellProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Registry for cell components, mapping cell types to their corresponding components.
|
|
5
|
+
*
|
|
6
|
+
* This registry instance manages the available cell component types for table rendering.
|
|
7
|
+
* It is pre-initialized with the text cell component and can be extended with additional
|
|
8
|
+
* cell types as needed. The registry provides type-safe component resolution for
|
|
9
|
+
* dynamic cell rendering based on data types.
|
|
10
|
+
*
|
|
11
|
+
* @constant
|
|
12
|
+
* @type {TypedComponentRegistry<CellType, CellProps>}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // Get a registered component
|
|
17
|
+
* const TextCellComponent = cellRegistry.get('text');
|
|
18
|
+
*
|
|
19
|
+
* // Check if a type is registered
|
|
20
|
+
* if (cellRegistry.has('number')) {
|
|
21
|
+
* // Use number cell
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // Register a custom cell type
|
|
25
|
+
* cellRegistry.register('custom', CustomCellComponent);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Using with typedCellRender
|
|
31
|
+
* import { typedCellRender } from './TypedCell';
|
|
32
|
+
*
|
|
33
|
+
* const renderer = typedCellRender('text', { ellipsis: true });
|
|
34
|
+
* if (renderer) {
|
|
35
|
+
* const cell = renderer('Hello', { id: 1 }, 0);
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const cellRegistry: TypedComponentRegistry<string, CellProps<any, any, any>>;
|
|
40
|
+
//# sourceMappingURL=cellRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellRegistry.d.ts","sourceRoot":"","sources":["../../../src/table/cell/cellRegistry.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAYpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,YAAY,0DAWvB,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for currency formatting.
|
|
3
|
+
*
|
|
4
|
+
* This interface extends a subset of Intl.NumberFormatOptions with additional
|
|
5
|
+
* currency-specific formatting controls. It provides a comprehensive set of
|
|
6
|
+
* options for customizing how monetary values are displayed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const options: CurrencyFormatOptions = {
|
|
11
|
+
* currency: 'USD',
|
|
12
|
+
* currencyDisplay: 'symbol',
|
|
13
|
+
* decimals: 2,
|
|
14
|
+
* locale: 'en-US',
|
|
15
|
+
* useGrouping: true,
|
|
16
|
+
* fallback: 'N/A'
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface CurrencyFormatOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The currency code to use for formatting (ISO 4217 currency codes).
|
|
23
|
+
* Common values include 'USD', 'EUR', 'CNY', 'JPY', etc.
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @default 'CNY'
|
|
27
|
+
* @example 'USD', 'EUR', 'CNY', 'JPY'
|
|
28
|
+
*/
|
|
29
|
+
currency?: string;
|
|
30
|
+
/**
|
|
31
|
+
* How to display the currency in the formatted output.
|
|
32
|
+
* - 'symbol': Use currency symbol (e.g., $, €, ¥)
|
|
33
|
+
* - 'narrowSymbol': Use narrow currency symbol when available
|
|
34
|
+
* - 'code': Use currency code (e.g., USD, EUR, CNY)
|
|
35
|
+
* - 'name': Use currency name (e.g., US dollar, euro, Chinese yuan)
|
|
36
|
+
*
|
|
37
|
+
* @type {Intl.NumberFormatOptionsCurrencyDisplay}
|
|
38
|
+
* @default 'symbol'
|
|
39
|
+
*/
|
|
40
|
+
currencyDisplay?: Intl.NumberFormatOptionsCurrencyDisplay;
|
|
41
|
+
/**
|
|
42
|
+
* The number of decimal places to display.
|
|
43
|
+
* This controls both minimum and maximum fraction digits.
|
|
44
|
+
*
|
|
45
|
+
* @type {number}
|
|
46
|
+
* @default 2
|
|
47
|
+
* @example 2, 3, 0
|
|
48
|
+
*/
|
|
49
|
+
decimals?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The locale to use for formatting (BCP 47 language tag).
|
|
52
|
+
* This affects number formatting, currency symbols, and grouping separators.
|
|
53
|
+
*
|
|
54
|
+
* @type {string}
|
|
55
|
+
* @default 'zh-CN'
|
|
56
|
+
* @example 'en-US', 'zh-CN', 'ja-JP', 'de-DE'
|
|
57
|
+
*/
|
|
58
|
+
locale?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to use grouping separators (thousands separators).
|
|
61
|
+
* When true, large numbers will be formatted with separators (e.g., 1,234.56).
|
|
62
|
+
*
|
|
63
|
+
* @type {boolean}
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
useGrouping?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The fallback string to return when the input value is invalid, null, undefined, or NaN.
|
|
69
|
+
* This ensures consistent output for edge cases.
|
|
70
|
+
*
|
|
71
|
+
* @type {string}
|
|
72
|
+
* @default '-'
|
|
73
|
+
* @example '-', 'N/A', 'Invalid', ''
|
|
74
|
+
*/
|
|
75
|
+
fallback?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Default configuration options for currency formatting.
|
|
79
|
+
*
|
|
80
|
+
* These defaults are used when no options are provided to formatCurrency().
|
|
81
|
+
* They provide sensible defaults for Chinese Yuan (CNY) formatting with
|
|
82
|
+
* standard decimal places and grouping separators.
|
|
83
|
+
*
|
|
84
|
+
* @constant
|
|
85
|
+
* @type {CurrencyFormatOptions}
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Using defaults
|
|
90
|
+
* formatCurrency(1234.56); // Uses DEFAULT_CURRENCY_FORMAT_OPTIONS
|
|
91
|
+
*
|
|
92
|
+
* // Overriding specific options
|
|
93
|
+
* formatCurrency(1234.56, { currency: 'USD' }); // Merges with defaults
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare const DEFAULT_CURRENCY_FORMAT_OPTIONS: CurrencyFormatOptions;
|
|
97
|
+
/**
|
|
98
|
+
* Formats a numeric amount as a localized currency string.
|
|
99
|
+
*
|
|
100
|
+
* This function provides comprehensive currency formatting using the browser's
|
|
101
|
+
* Intl.NumberFormat API. It supports various currencies, locales, and formatting
|
|
102
|
+
* options while providing robust error handling and fallback behavior.
|
|
103
|
+
*
|
|
104
|
+
* @param {number | string} amount - The monetary amount to format. Can be a number or a string representation of a number.
|
|
105
|
+
* @param {CurrencyFormatOptions} [options=DEFAULT_CURRENCY_FORMAT_OPTIONS] - Formatting options to customize the output.
|
|
106
|
+
* @returns {string} The formatted currency string, or the fallback value if formatting fails.
|
|
107
|
+
*
|
|
108
|
+
* @throws {Error} May throw if the Intl.NumberFormat constructor fails with invalid options, but this is handled internally with fallback.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Basic usage with defaults (CNY, zh-CN locale)
|
|
113
|
+
* formatCurrency(1234.56); // "¥1,234.56"
|
|
114
|
+
* formatCurrency(0); // "¥0.00"
|
|
115
|
+
* formatCurrency(null); // "-"
|
|
116
|
+
*
|
|
117
|
+
* // Using USD with US locale
|
|
118
|
+
* formatCurrency(1234.56, {
|
|
119
|
+
* currency: 'USD',
|
|
120
|
+
* locale: 'en-US'
|
|
121
|
+
* }); // "$1,234.56"
|
|
122
|
+
*
|
|
123
|
+
* // Formatting with custom decimal places
|
|
124
|
+
* formatCurrency(1234.56789, {
|
|
125
|
+
* currency: 'EUR',
|
|
126
|
+
* decimals: 3,
|
|
127
|
+
* locale: 'de-DE'
|
|
128
|
+
* }); // "1.234,568 €"
|
|
129
|
+
*
|
|
130
|
+
* // Large numbers with grouping
|
|
131
|
+
* formatCurrency(1234567.89, {
|
|
132
|
+
* currency: 'CNY',
|
|
133
|
+
* useGrouping: true
|
|
134
|
+
* }); // "¥1,234,567.89"
|
|
135
|
+
*
|
|
136
|
+
* // Without grouping separators
|
|
137
|
+
* formatCurrency(1234567.89, {
|
|
138
|
+
* currency: 'CNY',
|
|
139
|
+
* useGrouping: false
|
|
140
|
+
* }); // "¥1234567.89"
|
|
141
|
+
*
|
|
142
|
+
* // Custom fallback for invalid values
|
|
143
|
+
* formatCurrency(NaN, {
|
|
144
|
+
* fallback: 'Invalid amount'
|
|
145
|
+
* }); // "Invalid amount"
|
|
146
|
+
*
|
|
147
|
+
* // String input (automatically parsed)
|
|
148
|
+
* formatCurrency('1234.56'); // "¥1,234.56"
|
|
149
|
+
* formatCurrency('$1,234.56'); // "¥1234.56" (non-numeric characters removed)
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* // Error handling - function gracefully handles edge cases
|
|
155
|
+
* formatCurrency(Infinity); // "-"
|
|
156
|
+
* formatCurrency(-Infinity); // "-"
|
|
157
|
+
* formatCurrency('not-a-number'); // "-"
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function formatCurrency(amount: number | string | null, options?: CurrencyFormatOptions): string;
|
|
161
|
+
//# sourceMappingURL=currencyFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currencyFormatter.d.ts","sourceRoot":"","sources":["../../../src/table/cell/currencyFormatter.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,IAAI,CAAC,kCAAkC,CAAC;IAE1D;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,+BAA+B,EAAE,qBAO7C,CAAC;AAaF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC9B,OAAO,GAAE,qBAAuD,GAC/D,MAAM,CAwBR"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module table/cell
|
|
3
|
+
*
|
|
4
|
+
* This module provides the core cell rendering system for tables, including:
|
|
5
|
+
* - Cell component types and interfaces
|
|
6
|
+
* - Text, tag and tags cell implementations
|
|
7
|
+
* - Typed cell rendering utilities
|
|
8
|
+
* - Cell registry for component management
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { TextCell, TagCell, TagsCell, typedCellRender, TEXT_CELL_TYPE, TAG_CELL_TYPE, TAGS_CELL_TYPE } from '@ahoo-wang/fetcher-viewer/table/cell';
|
|
13
|
+
*
|
|
14
|
+
* // Direct component usage
|
|
15
|
+
* <TextCell
|
|
16
|
+
* data={{ value: 'Hello', record: { id: 1 }, index: 0 }}
|
|
17
|
+
* attributes={{ ellipsis: true }}
|
|
18
|
+
* />
|
|
19
|
+
*
|
|
20
|
+
* <TagCell
|
|
21
|
+
* data={{ value: "urgent", record: { id: 1 }, index: 0 }}
|
|
22
|
+
* attributes={{ color: 'red' }}
|
|
23
|
+
* />
|
|
24
|
+
*
|
|
25
|
+
* <TagsCell
|
|
26
|
+
* data={{ value: ["urgent", "high"], record: { id: 1 }, index: 0 }}
|
|
27
|
+
* attributes={{ color: 'blue' }}
|
|
28
|
+
* />
|
|
29
|
+
*
|
|
30
|
+
* // Using typed renderer
|
|
31
|
+
* const textRenderer = typedCellRender(TEXT_CELL_TYPE, { ellipsis: true });
|
|
32
|
+
* const tagRenderer = typedCellRender(TAG_CELL_TYPE, { color: 'red' });
|
|
33
|
+
* const tagsRenderer = typedCellRender(TAGS_CELL_TYPE, { color: 'blue' });
|
|
34
|
+
* const textCell = textRenderer('Hello', { id: 1 }, 0);
|
|
35
|
+
* const tagCell = tagRenderer('urgent', { id: 1 }, 0);
|
|
36
|
+
* const tagsCell = tagsRenderer(['urgent', 'high'], { id: 1 }, 0);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export * from './AvatarCell';
|
|
40
|
+
export * from './CalendarTime';
|
|
41
|
+
export * from './cellRegistry';
|
|
42
|
+
export * from './currencyFormatter';
|
|
43
|
+
export * from './CurrencyCell';
|
|
44
|
+
export * from './DateTimeCell';
|
|
45
|
+
export * from './ImageCell';
|
|
46
|
+
export * from './ImageGroupCell';
|
|
47
|
+
export * from './LinkCell';
|
|
48
|
+
export * from './TagCell';
|
|
49
|
+
export * from './TagsCell';
|
|
50
|
+
export * from './TextCell';
|
|
51
|
+
export * from './TypedCell';
|
|
52
|
+
export * from './types';
|
|
53
|
+
export * from './utils';
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/cell/index.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|