@dyrected/admin 2.5.59 → 2.5.61

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.
@@ -0,0 +1,77 @@
1
+ import { BooleanFormat, DateFormat, DisplayTone, JsonFormat, LinkFormat, NumberFormat, OptionFormat, TextFormat } from '@dyrected/core';
2
+ /**
3
+ * Display-only formatting for `number` and `date`/`datetime`/`time` field values,
4
+ * driven by a field's `admin.format` option. Everything here is best-effort: an
5
+ * unparseable value or an unsupported option falls back to a plain string rather
6
+ * than throwing, because these run inside list-cell rendering.
7
+ */
8
+ type NumberFormatObject = Exclude<NumberFormat, string>;
9
+ type DateFormatObject = Exclude<DateFormat, string>;
10
+ /** Normalize the shorthand string form into the object form. */
11
+ export declare function resolveNumberFormat(format: NumberFormat | undefined): NumberFormatObject | null;
12
+ /** Normalize the shorthand string form into the object form. */
13
+ export declare function resolveDateFormat(format: DateFormat | undefined): DateFormatObject | null;
14
+ export interface RatingSpec {
15
+ value: number;
16
+ max: number;
17
+ }
18
+ /**
19
+ * When the field uses the `rating` format, return the numeric value and star
20
+ * count so the caller can render stars. Returns `null` for every other format,
21
+ * signalling that {@link formatNumber} should be used instead.
22
+ */
23
+ export declare function getRatingSpec(value: unknown, format: NumberFormat | undefined): RatingSpec | null;
24
+ /**
25
+ * Format a numeric field value for display. Returns a plain string for every
26
+ * format except `rating` (use {@link getRatingSpec} for that). Non-numeric input
27
+ * is stringified unchanged.
28
+ */
29
+ export declare function formatNumber(value: unknown, format: NumberFormat | undefined): string;
30
+ /**
31
+ * Format a date/datetime/time field value for display. `now` is injected so the
32
+ * `relative` format stays deterministic and testable. Unparseable input is
33
+ * stringified unchanged.
34
+ */
35
+ export declare function formatDate(value: unknown, format: DateFormat | undefined, fieldType: "date" | "datetime" | "time", now?: number): string;
36
+ /** The color classes for a tone, falling back to `neutral`. */
37
+ export declare function displayToneClass(tone: DisplayTone | undefined): string;
38
+ type OptionFormatObject = Exclude<OptionFormat, string>;
39
+ export declare function resolveOptionFormat(format: OptionFormat | undefined): OptionFormatObject | null;
40
+ /** Field `options` as they arrive at render time — bare strings or `{ label, value }`. */
41
+ type FieldOption = string | {
42
+ label?: string;
43
+ value?: unknown;
44
+ };
45
+ export interface BadgeSpec {
46
+ label: string;
47
+ tone: DisplayTone;
48
+ }
49
+ /**
50
+ * Resolve a single option value into a badge label + tone. Returns `null` when
51
+ * the field has no badge format, signalling the caller to render plainly.
52
+ */
53
+ export declare function getOptionBadge(value: unknown, format: OptionFormat | undefined, options?: FieldOption[]): BadgeSpec | null;
54
+ /**
55
+ * Resolve a boolean value into a custom label + tone. Returns `null` when the
56
+ * field has no boolean format, so the caller keeps the default Yes/No badge.
57
+ */
58
+ export declare function getBooleanBadge(value: unknown, format: BooleanFormat | undefined): BadgeSpec | null;
59
+ type TextFormatObject = Exclude<TextFormat, string>;
60
+ export declare function resolveTextFormat(format: TextFormat | undefined): TextFormatObject | null;
61
+ /** Apply a display-only transform to a text value. */
62
+ export declare function formatText(value: unknown, format: TextFormat | undefined): string;
63
+ /** Whether a text format should render in a monospace pill. */
64
+ export declare function isCodeText(format: TextFormat | undefined): boolean;
65
+ export interface LinkSpec {
66
+ href: string;
67
+ label: string;
68
+ newTab: boolean;
69
+ }
70
+ /**
71
+ * Resolve a url/email value into a link spec. Returns `null` when the field has
72
+ * no link format. `fieldType` selects between an `http` link and a `mailto:`.
73
+ */
74
+ export declare function getLinkSpec(value: unknown, format: LinkFormat | undefined, fieldType: "url" | "email"): LinkSpec | null;
75
+ /** Format a JSON value as a compact summary or truncated code preview. */
76
+ export declare function formatJson(value: unknown, format: JsonFormat | undefined): string;
77
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -54,34 +54,43 @@ export interface CollectionListSlotProps {
54
54
  };
55
55
  }
56
56
  /**
57
- * Custom component overrides passed to `<DyrectedAdmin />`.
57
+ * Custom component overrides passed to `<DyrectedAdmin />`. Each key is a
58
+ * registry: you reference a component by a string key in your schema config,
59
+ * then provide the real component under that same key here.
58
60
  *
59
61
  * @example
60
62
  * ```tsx
61
63
  * <DyrectedAdmin
62
64
  * components={{
63
- * fields: { color: ColorPickerField },
65
+ * // field's admin.component: 'brand-color'
66
+ * fields: { 'brand-color': ColorPickerField },
67
+ * // admin.components.beforeDashboard: ['analytics']
64
68
  * dashboard: { analytics: AnalyticsWidget },
65
- * collectionList: { posts: PostsListView },
69
+ * // collection admin.components.beforeList: ['posts-header']
70
+ * collectionList: { 'posts-header': PostsHeader },
66
71
  * }}
67
72
  * />
68
73
  * ```
69
74
  */
70
75
  export interface AdminComponents {
71
76
  /**
72
- * Custom field renderers keyed by field type name.
73
- * A component registered here replaces the built-in renderer for every
74
- * field whose `type` matches the key.
77
+ * Custom field inputs keyed by the `admin.component` string set on a field.
78
+ * A field opts in by setting `admin.component: '<key>'`; the component
79
+ * registered under that key replaces the built-in input for that field.
80
+ * Keys are arbitrary — this is a per-field override, not a per-type one.
75
81
  */
76
82
  fields?: Record<string, ComponentType<any>>;
77
83
  /**
78
- * Custom dashboard slot components keyed by a slot name of your choice.
79
- * All registered components are rendered inside the dashboard page.
84
+ * Dashboard slot components keyed by the slot-key names declared in the
85
+ * top-level `admin.components` (`beforeDashboard` / `afterDashboard`).
86
+ * The registered components render around the built-in dashboard.
80
87
  */
81
88
  dashboard?: Record<string, ComponentType<DashboardSlotProps>>;
82
89
  /**
83
- * Custom collection list slot components keyed by collection slug.
84
- * The registered component replaces the entire list view for that collection.
90
+ * Collection-list slot components keyed by the slot-key names declared in a
91
+ * collection's `admin.components` (`beforeList` / `beforeListTable` /
92
+ * `afterListTable` / `afterList`). They inject content around the built-in
93
+ * list — they do not replace it.
85
94
  */
86
95
  collectionList?: Record<string, ComponentType<CollectionListSlotProps>>;
87
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/admin",
3
- "version": "2.5.59",
3
+ "version": "2.5.61",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -56,7 +56,7 @@
56
56
  "papaparse": "^5.5.4",
57
57
  "react-blurhash": "^0.3.0",
58
58
  "react-datasheet-grid": "^4.1.2",
59
- "react-day-picker": "^9.14.0",
59
+ "react-day-picker": "^8.10.1",
60
60
  "react-dropzone": "^15.0.0",
61
61
  "react-hook-form": "^7.75.0",
62
62
  "react-image-crop": "^11.0.10",
@@ -64,9 +64,9 @@
64
64
  "tailwind-merge": "^3.5.0",
65
65
  "tailwindcss-animate": "^1.0.7",
66
66
  "zod": "^3.25.76",
67
- "@dyrected/core": "^2.5.59",
68
- "@dyrected/sdk": "^2.5.59",
69
- "@dyrected/knowledge": "^0.2.11"
67
+ "@dyrected/core": "^2.5.61",
68
+ "@dyrected/knowledge": "^0.2.13",
69
+ "@dyrected/sdk": "^2.5.61"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@tanstack/react-query": "^5.0.0",