@object-ui/fields 6.2.3 → 7.1.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/CHANGELOG.md +203 -0
- package/dist/complex-widgets.test.d.ts +1 -0
- package/dist/currency.d.ts +13 -0
- package/dist/datetime-widgets.test.d.ts +1 -0
- package/dist/field-type-coverage.test.d.ts +1 -0
- package/dist/index.cjs +4 -3
- package/dist/index.d.ts +300 -2
- package/dist/index.js +2460 -1274
- package/dist/standard-widgets.test.d.ts +0 -0
- package/dist/{packages/fields/src/widgets → widgets}/AddressField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/AutoNumberField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/AvatarField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/BooleanField.d.ts +2 -1
- package/dist/widgets/CheckboxesField.d.ts +8 -0
- package/dist/{packages/fields/src/widgets → widgets}/CodeField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/ColorField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/CurrencyField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/DateField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/DateTimeField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/EmailField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/FileField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/FormulaField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/GeolocationField.d.ts +2 -1
- package/dist/widgets/GridField.d.ts +123 -0
- package/dist/widgets/GridField.test.d.ts +1 -0
- package/dist/{packages/fields/src/widgets → widgets}/ImageField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/LocationField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/LookupField.d.ts +2 -1
- package/dist/widgets/MarkdownContent.d.ts +9 -0
- package/dist/{packages/fields/src/widgets → widgets}/MasterDetailField.d.ts +2 -1
- package/dist/widgets/MultiSelectField.d.ts +9 -0
- package/dist/{packages/fields/src/widgets → widgets}/NumberField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/ObjectField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/PasswordField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/PercentField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/PhoneField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/QRCodeField.d.ts +2 -1
- package/dist/widgets/RadioField.d.ts +8 -0
- package/dist/{packages/fields/src/widgets → widgets}/RatingField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/RecordPickerDialog.d.ts +8 -2
- package/dist/{packages/fields/src/widgets → widgets}/RichTextField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/SelectField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/SignatureField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/SliderField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/SummaryField.d.ts +2 -1
- package/dist/widgets/TagsField.d.ts +8 -0
- package/dist/{packages/fields/src/widgets → widgets}/TextAreaField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/TextField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/TimeField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/UrlField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/UserField.d.ts +2 -1
- package/dist/{packages/fields/src/widgets → widgets}/VectorField.d.ts +2 -1
- package/dist/widgets/deriveLookupColumns.d.ts +36 -0
- package/dist/widgets/deriveLookupColumns.test.d.ts +1 -0
- package/dist/widgets/recentLookups.d.ts +13 -0
- package/dist/widgets/recentLookups.test.d.ts +1 -0
- package/dist/{packages/fields/src/widgets → widgets}/types.d.ts +1 -1
- package/package.json +14 -11
- package/src/__tests__/registry-collision.test.ts +91 -0
- package/src/__tests__/resolveFieldCurrency.test.ts +20 -0
- package/src/coerce-safe-value.test.ts +34 -0
- package/src/complex-widgets.test.tsx +58 -7
- package/src/currency.ts +14 -0
- package/src/field-type-coverage.test.ts +65 -0
- package/src/index.tsx +372 -57
- package/src/widgets/CheckboxesField.tsx +53 -0
- package/src/widgets/CurrencyField.tsx +5 -1
- package/src/widgets/GridField.test.tsx +309 -0
- package/src/widgets/GridField.tsx +907 -33
- package/src/widgets/LookupField.tsx +258 -107
- package/src/widgets/MarkdownContent.tsx +19 -0
- package/src/widgets/MultiSelectField.tsx +59 -0
- package/src/widgets/PercentField.tsx +19 -7
- package/src/widgets/RadioField.tsx +41 -0
- package/src/widgets/RecordPickerDialog.tsx +22 -18
- package/src/widgets/SelectField.tsx +23 -2
- package/src/widgets/TagsField.tsx +67 -0
- package/src/widgets/deriveLookupColumns.test.ts +74 -0
- package/src/widgets/deriveLookupColumns.ts +104 -0
- package/src/widgets/recentLookups.test.ts +45 -0
- package/src/widgets/recentLookups.ts +47 -0
- package/src/widgets/useFieldTranslation.ts +30 -0
- package/dist/packages/fields/src/fields-edge-cases.stories.d.ts +0 -45
- package/dist/packages/fields/src/fields.stories.d.ts +0 -56
- package/dist/packages/fields/src/index.d.ts +0 -286
- package/dist/packages/fields/src/record-picker-dialog.stories.d.ts +0 -25
- package/dist/packages/fields/src/widgets/GridField.d.ts +0 -7
- package/src/fields-edge-cases.stories.tsx +0 -407
- package/src/fields.stories.tsx +0 -566
- package/src/record-picker-dialog.stories.tsx +0 -160
- /package/dist/{packages/fields/src/__tests__/validation-feedback.test.d.ts → __tests__/registry-collision.test.d.ts} +0 -0
- /package/dist/{packages/fields/src/complex-widgets.test.d.ts → __tests__/resolveFieldCurrency.test.d.ts} +0 -0
- /package/dist/{packages/fields/src/standard-widgets.test.d.ts → __tests__/validation-feedback.test.d.ts} +0 -0
- /package/dist/{packages/fields/src/datetime-widgets.test.d.ts → coerce-safe-value.test.d.ts} +0 -0
- /package/dist/{packages/fields/src/widgets → widgets}/ImageCropperDialog.d.ts +0 -0
- /package/dist/{packages/fields/src/widgets → widgets}/_cell-renderer-bridge.d.ts +0 -0
- /package/dist/{packages/fields/src/widgets → widgets}/useFieldTranslation.d.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recently-used lookup memory.
|
|
3
|
+
*
|
|
4
|
+
* Mainstream record pickers (Salesforce, Dataverse, SAP, ServiceNow) surface
|
|
5
|
+
* the user's recently-picked records the moment a lookup is focused — before
|
|
6
|
+
* any typing. We approximate that with a small per-object ring of the last few
|
|
7
|
+
* selected record ids, kept in localStorage (no backend dependency). When a
|
|
8
|
+
* recent-items API later exists, this module is the single seam to swap.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const KEY_PREFIX = 'objectui:lookup:recent:';
|
|
12
|
+
const MAX_RECENT = 5;
|
|
13
|
+
|
|
14
|
+
function storage(): Storage | null {
|
|
15
|
+
try {
|
|
16
|
+
return typeof localStorage !== 'undefined' ? localStorage : null;
|
|
17
|
+
} catch {
|
|
18
|
+
// Accessing localStorage can throw in sandboxed iframes / SSR.
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Most-recent-first list of record ids previously chosen for `objectName`. */
|
|
24
|
+
export function getRecentLookupIds(objectName: string): Array<string | number> {
|
|
25
|
+
const s = storage();
|
|
26
|
+
if (!objectName || !s) return [];
|
|
27
|
+
try {
|
|
28
|
+
const raw = s.getItem(KEY_PREFIX + objectName);
|
|
29
|
+
if (!raw) return [];
|
|
30
|
+
const arr = JSON.parse(raw);
|
|
31
|
+
return Array.isArray(arr) ? arr.slice(0, MAX_RECENT) : [];
|
|
32
|
+
} catch {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Record that `id` was just chosen for `objectName` (moves it to the front). */
|
|
38
|
+
export function pushRecentLookupId(objectName: string, id: string | number | null | undefined): void {
|
|
39
|
+
const s = storage();
|
|
40
|
+
if (!objectName || id === null || id === undefined || id === '' || !s) return;
|
|
41
|
+
try {
|
|
42
|
+
const next = [id, ...getRecentLookupIds(objectName).filter((x) => x !== id)].slice(0, MAX_RECENT);
|
|
43
|
+
s.setItem(KEY_PREFIX + objectName, JSON.stringify(next));
|
|
44
|
+
} catch {
|
|
45
|
+
// Ignore quota / serialization failures — recents are best-effort.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -8,7 +8,37 @@ const FIELD_DEFAULTS: Record<string, string> = {
|
|
|
8
8
|
'common.selectOption': 'Select an option',
|
|
9
9
|
'common.select': 'Select...',
|
|
10
10
|
'common.search': 'Search',
|
|
11
|
+
'common.loading': 'Loading...',
|
|
12
|
+
'common.noResults': 'No results found',
|
|
13
|
+
'common.cancel': 'Cancel',
|
|
14
|
+
'common.confirm': 'Confirm',
|
|
11
15
|
'table.selected': '{{count}} selected',
|
|
16
|
+
'table.search': 'Search...',
|
|
17
|
+
'lookup.loading': 'Loading…',
|
|
18
|
+
'lookup.noOptions': 'No options found',
|
|
19
|
+
'lookup.noRecords': 'No records found',
|
|
20
|
+
'lookup.recentlyUsed': 'Recently used',
|
|
21
|
+
'lookup.allResults': 'All results',
|
|
22
|
+
'lookup.createNew': 'Create new',
|
|
23
|
+
'lookup.createNamed': 'Create new "{{name}}"',
|
|
24
|
+
'lookup.showingResults': 'Showing {{shown}} of {{total}} results',
|
|
25
|
+
'lookup.showAllResults': 'Show all results ({{count}})',
|
|
26
|
+
'lookup.selectedBadge': 'Selected',
|
|
27
|
+
'lookup.browseAll': 'Browse all records',
|
|
28
|
+
'lookup.remove': 'Remove {{label}}',
|
|
29
|
+
'lookup.selectFirst': 'Select {{fields}} first',
|
|
30
|
+
'lookup.selectRecord': 'Select record',
|
|
31
|
+
'lookup.recordCount': '{{count}} records',
|
|
32
|
+
'lookup.recordCountOne': '1 record',
|
|
33
|
+
'lookup.pageOf': 'Page {{current}} of {{total}}',
|
|
34
|
+
'lookup.filters': 'Filters',
|
|
35
|
+
'lookup.clear': 'Clear',
|
|
36
|
+
'lookup.yes': 'Yes',
|
|
37
|
+
'lookup.filterPlaceholder': 'Filter {{label}}',
|
|
38
|
+
'lookup.prevPage': 'Previous page',
|
|
39
|
+
'lookup.nextPage': 'Next page',
|
|
40
|
+
'lookup.jumpToPage': 'Jump to page',
|
|
41
|
+
'lookup.retry': 'Retry',
|
|
12
42
|
};
|
|
13
43
|
|
|
14
44
|
export const useFieldTranslation = createSafeTranslation(
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from '@storybook/react';
|
|
2
|
-
/**
|
|
3
|
-
* **Field Widgets – Edge Cases** from `@object-ui/fields`.
|
|
4
|
-
*
|
|
5
|
-
* Stories that exercise boundary conditions: empty values, overflow text,
|
|
6
|
-
* RTL content, emoji-only input, error states, disabled state, and readonly
|
|
7
|
-
* variants across multiple field types.
|
|
8
|
-
*/
|
|
9
|
-
declare const meta: {
|
|
10
|
-
title: string;
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: string;
|
|
13
|
-
};
|
|
14
|
-
tags: string[];
|
|
15
|
-
argTypes: {
|
|
16
|
-
readonly: {
|
|
17
|
-
control: "boolean";
|
|
18
|
-
description: string;
|
|
19
|
-
};
|
|
20
|
-
disabled: {
|
|
21
|
-
control: "boolean";
|
|
22
|
-
description: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default meta;
|
|
27
|
-
type Story = StoryObj<any>;
|
|
28
|
-
export declare const EmptyText: Story;
|
|
29
|
-
export declare const NullNumber: Story;
|
|
30
|
-
export declare const EmptySelect: Story;
|
|
31
|
-
export declare const LongText: Story;
|
|
32
|
-
export declare const LongTextArea: Story;
|
|
33
|
-
export declare const LongUrl: Story;
|
|
34
|
-
export declare const RTLText: Story;
|
|
35
|
-
export declare const RTLTextArea: Story;
|
|
36
|
-
export declare const EmojiText: Story;
|
|
37
|
-
export declare const EmojiEmail: Story;
|
|
38
|
-
export declare const ErrorText: Story;
|
|
39
|
-
export declare const ErrorNumber: Story;
|
|
40
|
-
export declare const ErrorSelect: Story;
|
|
41
|
-
export declare const DisabledText: Story;
|
|
42
|
-
export declare const DisabledNumber: Story;
|
|
43
|
-
export declare const DisabledSelect: Story;
|
|
44
|
-
export declare const DisabledBoolean: Story;
|
|
45
|
-
export declare const ReadonlyGallery: Story;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from '@storybook/react';
|
|
2
|
-
/**
|
|
3
|
-
* **Field Widgets** from `@object-ui/fields`.
|
|
4
|
-
*
|
|
5
|
-
* These components handle data formatting, validation, and display logic for specific data types.
|
|
6
|
-
* They are typically used within `ObjectForm` or `ObjectGrid` but can be used standalone.
|
|
7
|
-
*
|
|
8
|
-
* Note: These widgets implement the `FieldWidgetProps` interface.
|
|
9
|
-
*/
|
|
10
|
-
declare const meta: {
|
|
11
|
-
title: string;
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: string;
|
|
14
|
-
};
|
|
15
|
-
tags: string[];
|
|
16
|
-
};
|
|
17
|
-
export default meta;
|
|
18
|
-
type Story = StoryObj<any>;
|
|
19
|
-
export declare const Text: Story;
|
|
20
|
-
export declare const TextArea: Story;
|
|
21
|
-
export declare const Email: Story;
|
|
22
|
-
export declare const Phone: Story;
|
|
23
|
-
export declare const Url: Story;
|
|
24
|
-
export declare const Password: Story;
|
|
25
|
-
export declare const AutoNumber: Story;
|
|
26
|
-
export declare const Number: Story;
|
|
27
|
-
export declare const Currency: Story;
|
|
28
|
-
export declare const Percent: Story;
|
|
29
|
-
export declare const Date: Story;
|
|
30
|
-
export declare const DateTime: Story;
|
|
31
|
-
export declare const Time: Story;
|
|
32
|
-
export declare const Boolean: Story;
|
|
33
|
-
export declare const Select: Story;
|
|
34
|
-
export declare const Lookup: Story;
|
|
35
|
-
export declare const MultiSelectLookup: Story;
|
|
36
|
-
export declare const User: Story;
|
|
37
|
-
export declare const File: Story;
|
|
38
|
-
export declare const Location: Story;
|
|
39
|
-
export declare const Formula: Story;
|
|
40
|
-
export declare const Summary: Story;
|
|
41
|
-
export declare const ReadOnly: Story;
|
|
42
|
-
export declare const RichText: Story;
|
|
43
|
-
export declare const Image: Story;
|
|
44
|
-
export declare const Color: Story;
|
|
45
|
-
export declare const Slider: Story;
|
|
46
|
-
export declare const Rating: Story;
|
|
47
|
-
export declare const Code: Story;
|
|
48
|
-
export declare const Avatar: Story;
|
|
49
|
-
export declare const Signature: Story;
|
|
50
|
-
export declare const QRCode: Story;
|
|
51
|
-
export declare const Address: Story;
|
|
52
|
-
export declare const Geolocation: Story;
|
|
53
|
-
export declare const Object: Story;
|
|
54
|
-
export declare const Grid: Story;
|
|
55
|
-
export declare const MasterDetail: Story;
|
|
56
|
-
export declare const Vector: Story;
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { FieldMetadata } from '../../types/src';
|
|
3
|
-
/**
|
|
4
|
-
* Heuristic: detect strings that look like opaque foreign-key IDs (e.g. nanoid
|
|
5
|
-
* or BSON ObjectId). Used so we don't display random gibberish to users when
|
|
6
|
-
* a lookup wasn't expanded.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isLikelyOpaqueId(v: unknown): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Cell renderer props
|
|
11
|
-
*/
|
|
12
|
-
export interface CellRendererProps {
|
|
13
|
-
value: any;
|
|
14
|
-
field: FieldMetadata;
|
|
15
|
-
isEditing?: boolean;
|
|
16
|
-
onChange?: (value: any) => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Coerce a value to a safe primitive for rendering.
|
|
20
|
-
* Handles MongoDB wrapper types ($numberDecimal, $oid, $date), expanded
|
|
21
|
-
* reference objects, and arrays so that no raw object is ever passed as
|
|
22
|
-
* a React child — preventing React error #310.
|
|
23
|
-
*/
|
|
24
|
-
export declare function coerceToSafeValue(value: unknown): string | number | boolean | null | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Format currency value. When `currency` is undefined, falls back to a
|
|
27
|
-
* plain number with thousands separators (no symbol). Silently assuming
|
|
28
|
-
* USD for unconfigured currency fields was the #1 source of "why is my
|
|
29
|
-
* RMB amount showing as dollars?" bug reports.
|
|
30
|
-
*
|
|
31
|
-
* Trailing `.00` is dropped when the value is a whole number — Salesforce
|
|
32
|
-
* convention: `$1,234.50` keeps cents; `$1,234` does not.
|
|
33
|
-
*/
|
|
34
|
-
export declare function formatCurrency(value: number, currency?: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Format currency value in compact form for mobile display.
|
|
37
|
-
* E.g., $150,000 → $150K, $1,200,000 → $1.2M
|
|
38
|
-
* When `currency` is undefined, returns a compact number without symbol.
|
|
39
|
-
*/
|
|
40
|
-
export declare function formatCompactCurrency(value: number, currency?: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Format a plain number with thousands separators, no currency symbol.
|
|
43
|
-
* Used as a safe fallback when a currency-typed field has no `currency`
|
|
44
|
-
* configured — we'd rather render `1,234.50` than silently assume USD.
|
|
45
|
-
*/
|
|
46
|
-
export declare function formatNumber(value: number, decimals?: number): string;
|
|
47
|
-
/**
|
|
48
|
-
* Format percent value
|
|
49
|
-
* Handles both decimal (0.8 = 80%) and whole number (80 = 80%) inputs.
|
|
50
|
-
*/
|
|
51
|
-
export declare function formatPercent(value: number, precision?: number): string;
|
|
52
|
-
/**
|
|
53
|
-
* Humanize a snake_case or kebab-case string into Title Case.
|
|
54
|
-
* Used as fallback label when no explicit option.label exists.
|
|
55
|
-
*
|
|
56
|
-
* Examples:
|
|
57
|
-
* "in_progress" → "In Progress"
|
|
58
|
-
* "high-priority" → "High Priority"
|
|
59
|
-
* "active" → "Active"
|
|
60
|
-
*/
|
|
61
|
-
export declare function humanizeLabel(value: string): string;
|
|
62
|
-
/**
|
|
63
|
-
* Format date as relative time (e.g., "2 days ago", "Today", "Overdue 3d")
|
|
64
|
-
*/
|
|
65
|
-
export declare function formatRelativeDate(value: string | Date | number): string;
|
|
66
|
-
/**
|
|
67
|
-
* Format date value
|
|
68
|
-
*/
|
|
69
|
-
export declare function formatDate(value: string | Date | number, style?: string): string;
|
|
70
|
-
/**
|
|
71
|
-
* Format datetime value
|
|
72
|
-
*/
|
|
73
|
-
export declare function formatDateTime(value: string | Date | number): string;
|
|
74
|
-
/**
|
|
75
|
-
* Text field cell renderer
|
|
76
|
-
*/
|
|
77
|
-
export declare function TextCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
78
|
-
/**
|
|
79
|
-
* Number field cell renderer
|
|
80
|
-
*/
|
|
81
|
-
export declare function NumberCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
82
|
-
/**
|
|
83
|
-
* Currency field cell renderer
|
|
84
|
-
*/
|
|
85
|
-
export declare function CurrencyCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
86
|
-
/**
|
|
87
|
-
* Percent field cell renderer with mini progress bar
|
|
88
|
-
*/
|
|
89
|
-
export declare function PercentCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
90
|
-
/**
|
|
91
|
-
* Boolean field cell renderer (Airtable-style checkbox)
|
|
92
|
-
* Supports semantic rendering for completion fields (green indicator)
|
|
93
|
-
* and warning badge for active/enabled fields when false.
|
|
94
|
-
*/
|
|
95
|
-
export declare function BooleanCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
96
|
-
/**
|
|
97
|
-
* Date field cell renderer
|
|
98
|
-
*/
|
|
99
|
-
export declare function DateCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
100
|
-
/**
|
|
101
|
-
* DateTime field cell renderer (Airtable-style with date and time visually separated)
|
|
102
|
-
*/
|
|
103
|
-
export declare function DateTimeCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
104
|
-
export declare function getBadgeColorClasses(color?: string, val?: unknown): string;
|
|
105
|
-
/**
|
|
106
|
-
* Resolve a semantic color name (e.g. "red", "green") for a value, suitable
|
|
107
|
-
* for callers that need a raw color token rather than CSS classes (for
|
|
108
|
-
* example, the Gantt renderer paints bars via inline styles).
|
|
109
|
-
*
|
|
110
|
-
* Resolution order: explicit option color → semantic value mapping →
|
|
111
|
-
* deterministic hash fallback. Returns `undefined` only when no value is
|
|
112
|
-
* supplied so the caller can fall back to its own default.
|
|
113
|
-
*/
|
|
114
|
-
export declare function getSemanticColorName(color?: string, val?: unknown): string | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Map a semantic color name to its Tailwind -500 hex value. Used by
|
|
117
|
-
* inline-style consumers (Gantt bars). Falls back to the supplied default
|
|
118
|
-
* (or the platform default blue) when the name is unrecognized.
|
|
119
|
-
*/
|
|
120
|
-
export declare function getSemanticHex(name?: string, fallback?: string): string;
|
|
121
|
-
/**
|
|
122
|
-
* Select field cell renderer.
|
|
123
|
-
*
|
|
124
|
-
* Two visual styles, controlled by `field.appearance` (renderer-level option,
|
|
125
|
-
* not part of the `@objectstack/spec` field schema):
|
|
126
|
-
* - `'badge'` (default for spec compatibility): soft-pill colored badge.
|
|
127
|
-
* - `'dot'`: a small colored dot followed by the option label. Used by
|
|
128
|
-
* dense list/grid contexts to keep the table visually quiet — repeated
|
|
129
|
-
* filled badges across many rows create heavy visual noise.
|
|
130
|
-
*
|
|
131
|
-
* Metadata always wins: callers can pass `appearance: 'badge'` on the field
|
|
132
|
-
* descriptor to force the legacy badge in any context.
|
|
133
|
-
*/
|
|
134
|
-
export declare function SelectCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
135
|
-
/**
|
|
136
|
-
* Email field cell renderer
|
|
137
|
-
*/
|
|
138
|
-
export declare function EmailCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
139
|
-
/**
|
|
140
|
-
* URL field cell renderer
|
|
141
|
-
*/
|
|
142
|
-
export declare function UrlCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
143
|
-
/**
|
|
144
|
-
* Phone field cell renderer
|
|
145
|
-
*/
|
|
146
|
-
export declare function PhoneCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
147
|
-
/**
|
|
148
|
-
* File field cell renderer
|
|
149
|
-
*/
|
|
150
|
-
export declare function FileCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
151
|
-
/**
|
|
152
|
-
* Image field cell renderer (with thumbnails)
|
|
153
|
-
*/
|
|
154
|
-
export declare function ImageCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
155
|
-
/**
|
|
156
|
-
* Lookup/Master-Detail field cell renderer.
|
|
157
|
-
*
|
|
158
|
-
* Display order:
|
|
159
|
-
* 1. Embedded record object (`{ id, name, ... }` from `$expand`) → use its name
|
|
160
|
-
* 2. Static `field.options[]` (e.g. when the lookup is a closed enum) → look up label
|
|
161
|
-
* 3. Fetch-on-demand: when the value is a primitive ID and `field.reference_to`
|
|
162
|
-
* is known, resolve via dataSource and show the related record's display name.
|
|
163
|
-
* Falls back to a muted placeholder while pending and on failure.
|
|
164
|
-
*/
|
|
165
|
-
export declare function LookupCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
166
|
-
/**
|
|
167
|
-
* Formula field cell renderer (read-only)
|
|
168
|
-
*/
|
|
169
|
-
export declare function FormulaCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
170
|
-
/**
|
|
171
|
-
* User/Owner field cell renderer (with avatars)
|
|
172
|
-
*/
|
|
173
|
-
export declare function UserCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
174
|
-
/**
|
|
175
|
-
* Register a custom field renderer
|
|
176
|
-
* @param type Field type (e.g. 'text', 'location', 'my-custom-type')
|
|
177
|
-
* @param renderer React component to render the field
|
|
178
|
-
*/
|
|
179
|
-
export declare function registerFieldRenderer(type: string, renderer: React.FC<CellRendererProps>): void;
|
|
180
|
-
/**
|
|
181
|
-
* Resolve the canonical cell-renderer key for a field. Accepts either a
|
|
182
|
-
* raw type string (back-compat) or a field-metadata object so that
|
|
183
|
-
* format hints (`format: 'phone'` etc.) can promote a plain `text`
|
|
184
|
-
* field to its richer renderer counterpart.
|
|
185
|
-
*/
|
|
186
|
-
export declare function resolveCellRendererType(fieldOrType: string | {
|
|
187
|
-
type?: string;
|
|
188
|
-
format?: string;
|
|
189
|
-
} | null | undefined): string;
|
|
190
|
-
/**
|
|
191
|
-
* Get the appropriate cell renderer for a field type
|
|
192
|
-
*/
|
|
193
|
-
export declare function getCellRenderer(fieldType: string): React.FC<CellRendererProps>;
|
|
194
|
-
/**
|
|
195
|
-
* Map field type to form component type
|
|
196
|
-
*
|
|
197
|
-
* @param fieldType - The ObjectQL field type identifier to convert
|
|
198
|
-
* (for example: `"text"`, `"number"`, `"date"`, `"lookup"`).
|
|
199
|
-
* @returns The normalized form field type string used in the form schema
|
|
200
|
-
* (for example: `"input"`, `"textarea"`, `"date-picker"`, `"select"`).
|
|
201
|
-
*/
|
|
202
|
-
export declare function mapFieldTypeToFormType(fieldType: string): string;
|
|
203
|
-
/**
|
|
204
|
-
* Formats file size in bytes to human-readable string
|
|
205
|
-
* @param bytes - File size in bytes (must be non-negative)
|
|
206
|
-
* @returns Formatted string (e.g., "5 MB", "1.5 GB")
|
|
207
|
-
*/
|
|
208
|
-
export declare function formatFileSize(bytes: number): string;
|
|
209
|
-
/**
|
|
210
|
-
* Build validation rules from field metadata
|
|
211
|
-
* @param field - Field metadata from ObjectStack
|
|
212
|
-
* @returns Validation rule object compatible with react-hook-form
|
|
213
|
-
*/
|
|
214
|
-
export declare function buildValidationRules(field: any): any;
|
|
215
|
-
/**
|
|
216
|
-
* Evaluate a conditional expression for field visibility
|
|
217
|
-
* @param condition - Condition object from field metadata
|
|
218
|
-
* @param formData - Current form values
|
|
219
|
-
* @returns Whether the condition is met
|
|
220
|
-
*/
|
|
221
|
-
export declare function evaluateCondition(condition: any, formData: any): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Register a specific field type lazily
|
|
224
|
-
* @param fieldType - The field type to register (e.g., 'text', 'number')
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* // Register only the text field
|
|
228
|
-
* registerField('text');
|
|
229
|
-
*/
|
|
230
|
-
export declare function registerField(fieldType: string): void;
|
|
231
|
-
/**
|
|
232
|
-
* Register all field types (for backward compatibility)
|
|
233
|
-
* This function auto-registers all field widgets on import.
|
|
234
|
-
*
|
|
235
|
-
* For better tree-shaking, use registerField() to register only needed fields.
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* // Register all fields at once
|
|
239
|
-
* registerAllFields();
|
|
240
|
-
*/
|
|
241
|
-
export declare function registerAllFields(): void;
|
|
242
|
-
/**
|
|
243
|
-
* Legacy function - kept for backward compatibility
|
|
244
|
-
* @deprecated Use registerAllFields() instead
|
|
245
|
-
*/
|
|
246
|
-
export declare function registerFields(): void;
|
|
247
|
-
export * from './widgets/types';
|
|
248
|
-
export * from './widgets/TextField';
|
|
249
|
-
export * from './widgets/NumberField';
|
|
250
|
-
export * from './widgets/BooleanField';
|
|
251
|
-
export * from './widgets/SelectField';
|
|
252
|
-
export * from './widgets/DateField';
|
|
253
|
-
export * from './widgets/DateTimeField';
|
|
254
|
-
export * from './widgets/TimeField';
|
|
255
|
-
export * from './widgets/EmailField';
|
|
256
|
-
export * from './widgets/PhoneField';
|
|
257
|
-
export * from './widgets/UrlField';
|
|
258
|
-
export * from './widgets/CurrencyField';
|
|
259
|
-
export * from './widgets/PercentField';
|
|
260
|
-
export * from './widgets/PasswordField';
|
|
261
|
-
export * from './widgets/TextAreaField';
|
|
262
|
-
export * from './widgets/RichTextField';
|
|
263
|
-
export * from './widgets/LookupField';
|
|
264
|
-
export * from './widgets/RecordPickerDialog';
|
|
265
|
-
export * from './widgets/FileField';
|
|
266
|
-
export * from './widgets/ImageField';
|
|
267
|
-
export { ImageCropperDialog } from './widgets/ImageCropperDialog';
|
|
268
|
-
export type { ImageCropperDialogProps } from './widgets/ImageCropperDialog';
|
|
269
|
-
export * from './widgets/LocationField';
|
|
270
|
-
export * from './widgets/FormulaField';
|
|
271
|
-
export * from './widgets/SummaryField';
|
|
272
|
-
export * from './widgets/AutoNumberField';
|
|
273
|
-
export * from './widgets/UserField';
|
|
274
|
-
export * from './widgets/ObjectField';
|
|
275
|
-
export * from './widgets/VectorField';
|
|
276
|
-
export * from './widgets/GridField';
|
|
277
|
-
export * from './widgets/ColorField';
|
|
278
|
-
export * from './widgets/SliderField';
|
|
279
|
-
export * from './widgets/RatingField';
|
|
280
|
-
export * from './widgets/CodeField';
|
|
281
|
-
export * from './widgets/AvatarField';
|
|
282
|
-
export * from './widgets/AddressField';
|
|
283
|
-
export * from './widgets/GeolocationField';
|
|
284
|
-
export * from './widgets/SignatureField';
|
|
285
|
-
export * from './widgets/QRCodeField';
|
|
286
|
-
export * from './widgets/MasterDetailField';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from '@storybook/react';
|
|
2
|
-
import { RecordPickerDialog } from './widgets/RecordPickerDialog';
|
|
3
|
-
/**
|
|
4
|
-
* **RecordPickerDialog** — Enterprise-grade record picker for lookup fields.
|
|
5
|
-
*
|
|
6
|
-
* Features: skeleton loading, sticky table header, column sort,
|
|
7
|
-
* keyboard navigation, page jump, inline filter bar, column resize,
|
|
8
|
-
* and responsive layout.
|
|
9
|
-
*/
|
|
10
|
-
declare const meta: {
|
|
11
|
-
title: string;
|
|
12
|
-
component: typeof RecordPickerDialog;
|
|
13
|
-
parameters: {
|
|
14
|
-
layout: string;
|
|
15
|
-
};
|
|
16
|
-
tags: string[];
|
|
17
|
-
};
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof RecordPickerDialog>;
|
|
20
|
-
/** Default single-select dialog with 4 columns, pagination, and search. */
|
|
21
|
-
export declare const Default: Story;
|
|
22
|
-
/** Multi-select mode with confirm/cancel footer. */
|
|
23
|
-
export declare const MultiSelect: Story;
|
|
24
|
-
/** With inline filter columns for interactive filtering. */
|
|
25
|
-
export declare const WithFilters: Story;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FieldWidgetProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* GridField - Sub-table/grid data display
|
|
4
|
-
* Shows tabular data in a simplified format
|
|
5
|
-
* For full editing capabilities, use the grid plugin
|
|
6
|
-
*/
|
|
7
|
-
export declare function GridField({ value, field, readonly, ...props }: FieldWidgetProps<any[]>): import("react/jsx-runtime").JSX.Element;
|