@dyrected/admin 2.5.34 → 2.5.36

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/dist/admin.css CHANGED
@@ -1058,6 +1058,10 @@
1058
1058
  bottom: 0.75rem;
1059
1059
  }
1060
1060
 
1061
+ .dy-bottom-4{
1062
+ bottom: 1rem;
1063
+ }
1064
+
1061
1065
  .dy-left-0{
1062
1066
  left: 0px;
1063
1067
  }
@@ -1178,6 +1182,10 @@
1178
1182
  z-index: 100;
1179
1183
  }
1180
1184
 
1185
+ .dy-z-\[150\]{
1186
+ z-index: 150;
1187
+ }
1188
+
1181
1189
  .dy-order-1{
1182
1190
  order: 1;
1183
1191
  }
@@ -1480,6 +1488,10 @@
1480
1488
  height: 0.875rem;
1481
1489
  }
1482
1490
 
1491
+ .dy-h-32{
1492
+ height: 8rem;
1493
+ }
1494
+
1483
1495
  .dy-h-4{
1484
1496
  height: 1rem;
1485
1497
  }
@@ -1592,6 +1604,10 @@
1592
1604
  max-height: 10rem;
1593
1605
  }
1594
1606
 
1607
+ .dy-max-h-60{
1608
+ max-height: 15rem;
1609
+ }
1610
+
1595
1611
  .dy-max-h-80{
1596
1612
  max-height: 20rem;
1597
1613
  }
@@ -1676,6 +1692,10 @@
1676
1692
  min-height: 180px;
1677
1693
  }
1678
1694
 
1695
+ .dy-min-h-\[200px\]{
1696
+ min-height: 200px;
1697
+ }
1698
+
1679
1699
  .dy-min-h-\[220px\]{
1680
1700
  min-height: 220px;
1681
1701
  }
@@ -1796,6 +1816,10 @@
1796
1816
  width: 2rem;
1797
1817
  }
1798
1818
 
1819
+ .dy-w-80{
1820
+ width: 20rem;
1821
+ }
1822
+
1799
1823
  .dy-w-9{
1800
1824
  width: 2.25rem;
1801
1825
  }
@@ -2108,6 +2132,10 @@
2108
2132
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
2109
2133
  }
2110
2134
 
2135
+ .dy-transform{
2136
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
2137
+ }
2138
+
2111
2139
  @keyframes dy-bounce{
2112
2140
 
2113
2141
  0%, 100%{
@@ -2187,6 +2215,10 @@
2187
2215
  resize: none;
2188
2216
  }
2189
2217
 
2218
+ .dy-resize-y{
2219
+ resize: vertical;
2220
+ }
2221
+
2190
2222
  .dy-list-inside{
2191
2223
  list-style-position: inside;
2192
2224
  }
@@ -2407,6 +2439,10 @@
2407
2439
  border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
2408
2440
  }
2409
2441
 
2442
+ .dy-divide-border > :not([hidden]) ~ :not([hidden]){
2443
+ border-color: hsl(var(--border));
2444
+ }
2445
+
2410
2446
  .dy-divide-border\/30 > :not([hidden]) ~ :not([hidden]){
2411
2447
  border-color: hsl(var(--border) / 0.3);
2412
2448
  }
@@ -2751,6 +2787,10 @@
2751
2787
  background-color: rgb(245 158 11 / var(--tw-bg-opacity, 1));
2752
2788
  }
2753
2789
 
2790
+ .dy-bg-amber-500\/5{
2791
+ background-color: rgb(245 158 11 / 0.05);
2792
+ }
2793
+
2754
2794
  .dy-bg-background{
2755
2795
  background-color: hsl(var(--background));
2756
2796
  }
@@ -4179,6 +4219,75 @@
4179
4219
  pointer-events: none;
4180
4220
  }
4181
4221
 
4222
+ /* React Datasheet Grid custom design system variables integration */
4223
+
4224
+ .dy-admin-ui .dsg-container {
4225
+ --dsg-border-color: hsl(var(--border) / 0.8) !important;
4226
+ --dsg-selection-border-color: hsl(var(--intelligence)) !important;
4227
+ --dsg-selection-border-radius: var(--radius) !important;
4228
+ --dsg-selection-border-width: 2px !important;
4229
+ --dsg-selection-background-color: hsl(var(--intelligence) / 0.04) !important;
4230
+ --dsg-selection-disabled-border-color: hsl(var(--muted-foreground) / 0.5) !important;
4231
+ --dsg-selection-disabled-background-color: hsl(var(--muted) / 0.2) !important;
4232
+ --dsg-corner-indicator-width: 8px !important;
4233
+ --dsg-header-text-color: hsl(var(--muted-foreground)) !important;
4234
+ --dsg-header-active-text-color: hsl(var(--foreground)) !important;
4235
+ --dsg-cell-background-color: hsl(var(--card)) !important;
4236
+ --dsg-cell-disabled-background-color: hsl(var(--muted) / 0.1) !important;
4237
+ --dsg-transition-duration: .15s !important;
4238
+ --dsg-expand-rows-indicator-width: 10px !important;
4239
+ --dsg-scroll-shadow-width: 8px !important;
4240
+ --dsg-scroll-shadow-color: rgba(0, 0, 0, 0.08) !important;
4241
+ border: 1px solid var(--dsg-border-color);
4242
+ border-radius: var(--radius);
4243
+ overflow: hidden;
4244
+ box-shadow: none;
4245
+ font-family: var(--font-sans) !important;
4246
+ }
4247
+
4248
+ .dy-admin-ui .dsg-row-header,
4249
+ .dy-admin-ui .dsg-corner-header {
4250
+ background-color: hsl(var(--muted) / 0.3) !important;
4251
+ font-size: 11px;
4252
+ font-weight: 500;
4253
+ text-transform: uppercase;
4254
+ letter-spacing: 0.05em;
4255
+ }
4256
+
4257
+ .dy-admin-ui .dsg-cell {
4258
+ font-size: 13px !important;
4259
+ color: hsl(var(--foreground)) !important;
4260
+ }
4261
+
4262
+ .dy-admin-ui .dsg-input {
4263
+ font-family: var(--font-sans) !important;
4264
+ font-size: 13px !important;
4265
+ color: hsl(var(--foreground)) !important;
4266
+ padding: 0 8px !important;
4267
+ }
4268
+
4269
+ .dy-admin-ui .dsg-container {
4270
+ border: solid 1px hsl(var(--border) / 0.8) !important;
4271
+ border-top: none !important;
4272
+ border-left: none !important;
4273
+ cursor: cell !important;
4274
+ -webkit-user-select: none !important;
4275
+ -moz-user-select: none !important;
4276
+ user-select: none !important;
4277
+ box-sizing: border-box !important;
4278
+ color: hsl(var(--foreground)) !important;
4279
+ background: hsl(var(--card)) !important;
4280
+ position: relative !important;
4281
+ width: 100% !important;
4282
+ overflow: auto !important;
4283
+ will-change: transform !important;
4284
+ direction: ltr !important;
4285
+ }
4286
+
4287
+ .dy-admin-ui .dsg-container .dsg-add-row {
4288
+ background: hsl(var(--card)) !important;
4289
+ }
4290
+
4182
4291
  .dy-admin-ui .hover\:dy-text-primary:hover {
4183
4292
  color: hsl(var(--intelligence));
4184
4293
  }
@@ -4554,6 +4663,10 @@
4554
4663
  background-color: hsl(var(--accent) / 0.7);
4555
4664
  }
4556
4665
 
4666
+ .hover\:dy-bg-amber-500\/10:hover{
4667
+ background-color: rgb(245 158 11 / 0.1);
4668
+ }
4669
+
4557
4670
  .hover\:dy-bg-background:hover{
4558
4671
  background-color: hsl(var(--background));
4559
4672
  }
@@ -1,5 +1,9 @@
1
1
  import { Field as FieldSchema } from '@dyrected/sdk';
2
2
  import * as z from "zod";
3
+ /**
4
+ * Normalises a field's `options` array to the canonical `{ label, value }` shape.
5
+ * Accepts either a shorthand string array or the full object form.
6
+ */
3
7
  export declare function normalizeOptions(options: string[] | {
4
8
  label: string;
5
9
  value: string;
@@ -7,10 +11,45 @@ export declare function normalizeOptions(options: string[] | {
7
11
  label: string;
8
12
  value: string;
9
13
  }[];
14
+ /**
15
+ * Builds a Zod schema shape from a collection's field definitions.
16
+ * Used by the form engine to validate the edit form before submission.
17
+ *
18
+ * @param fields - Field definitions from the collection schema.
19
+ * @param isEdit - When `true`, password fields accept an empty string (no change).
20
+ * @returns A record of Zod validators keyed by field name, suitable for `z.object(shape)`.
21
+ */
10
22
  export declare function buildSchemaShape(fields: FieldSchema[], isEdit?: boolean): Record<string, z.ZodTypeAny>;
23
+ /**
24
+ * Builds `react-hook-form` default values from a collection's field definitions
25
+ * and an existing document (or an empty object for new documents).
26
+ *
27
+ * Handles nested `object`, `array`, and `blocks` fields recursively.
28
+ * Relationship and image fields are normalised to their IDs.
29
+ * Password fields are always reset to `""` so they are never pre-filled.
30
+ *
31
+ * @param fields - Field definitions from the collection schema.
32
+ * @param defaults - Existing document data, or `{}` for a new document.
33
+ */
11
34
  export declare function buildDefaultValues(fields: FieldSchema[], defaults: any): any;
35
+ /**
36
+ * Flattens a nested `react-hook-form` errors object into a list of
37
+ * `{ path, message }` pairs for rendering under individual fields.
38
+ *
39
+ * @param errors - The `formState.errors` object from `react-hook-form`.
40
+ * @param path - Dot-notation prefix accumulated during recursion (omit when calling externally).
41
+ * @returns A flat array of field path / error message pairs.
42
+ */
12
43
  export declare function getFlatErrors(errors: Record<string, unknown>, path?: string): {
13
44
  path: string;
14
45
  message: string;
15
46
  }[];
47
+ /**
48
+ * Formats a dot-notation field path into a human-readable label.
49
+ * Array indices are converted to 1-based "Item N" labels.
50
+ *
51
+ * @example
52
+ * formatPath("address.street") // → "Address > Street"
53
+ * formatPath("items.0.name") // → "Items > Item 1 > Name"
54
+ */
16
55
  export declare function formatPath(path: string): string;
@@ -3,4 +3,5 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
3
  declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
4
4
  declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
5
  declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
6
- export { Popover, PopoverTrigger, PopoverContent };
6
+ declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
7
+ export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
@@ -0,0 +1,10 @@
1
+ import { CollectionConfig } from '@dyrected/core';
2
+ interface SpreadsheetEditorProps {
3
+ slug: string;
4
+ schema: CollectionConfig;
5
+ data: Record<string, unknown>[];
6
+ onSave: (updates: Record<string, Record<string, unknown>>, creates?: Record<string, unknown>[]) => Promise<void>;
7
+ isSaving: boolean;
8
+ }
9
+ export declare function SpreadsheetEditor({ slug, schema, data, onSave, isSaving, }: SpreadsheetEditorProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,8 +1,20 @@
1
1
  import { DyrectedProviderProps } from './providers/dyrected-provider';
2
2
  export type { AdminComponents, AdminSchemas, CollectionListSlotProps, DashboardSlotProps, } from './types/admin-components';
3
+ /**
4
+ * Props for the `<AdminUI />` embedded component.
5
+ *
6
+ * Use this when mounting the admin inside an existing React app or a
7
+ * framework-specific wrapper (Next.js, Nuxt, Astro, etc.).
8
+ */
3
9
  export interface AdminUIProps {
10
+ /** API key used to authenticate requests to the Dyrected backend. */
4
11
  apiKey?: string;
12
+ /**
13
+ * Base URL of the Dyrected backend API (e.g. `"https://example.com/dyrected"`).
14
+ * Defaults to `"/dyrected"` (same-origin).
15
+ */
5
16
  baseUrl?: string;
17
+ /** Site ID for multi-tenant deployments. Omit for single-site setups. */
6
18
  siteId?: string;
7
19
  /**
8
20
  * The base path where the admin is mounted in the host app.
@@ -22,22 +34,60 @@ export interface AdminUIProps {
22
34
  * <AdminUI onNavigate={(path) => navigateTo('/admin' + path)} ... />
23
35
  */
24
36
  onNavigate?: (path: string) => void;
37
+ /**
38
+ * Set to `true` when the admin is rendered inside a host app shell
39
+ * (e.g. inside a dashboard layout). Adjusts internal spacing and
40
+ * removes the standalone top-bar.
41
+ */
25
42
  isEmbedded?: boolean;
43
+ /** Custom component overrides for fields, dashboard slots, and collection list views. */
26
44
  components?: DyrectedProviderProps['components'];
27
45
  initialToken?: string;
28
46
  defaultTechStack?: string;
29
47
  }
48
+ /**
49
+ * The main admin UI component. Mount this inside your React app.
50
+ *
51
+ * Uses a `HashRouter` internally so it can be embedded without conflicting
52
+ * with the host app's router. If you need real URL history, use
53
+ * `renderAdminUI` with a custom router wrapper instead.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * <AdminUI baseUrl="/dyrected" apiKey="my-key" isEmbedded />
58
+ * ```
59
+ */
30
60
  export declare function AdminUI({ apiKey, baseUrl, siteId, onNavigate, isEmbedded, components, initialToken, defaultTechStack, }: AdminUIProps): import("react/jsx-runtime").JSX.Element;
31
61
  /**
32
- * Renders the Admin UI into a DOM element.
33
- * Useful for non-React frameworks like Nuxt, Svelte, or Vanilla JS.
62
+ * Imperatively renders the Admin UI into a DOM element.
63
+ * Useful for non-React frameworks (Nuxt, Svelte, Vanilla JS, Web Components).
64
+ *
65
+ * @param container - The DOM element to mount into.
66
+ * @param props - Same props as `<AdminUI />`.
67
+ * @returns A cleanup function that unmounts the React root.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const cleanup = renderAdminUI(document.getElementById('admin')!, { baseUrl: '/dyrected' });
72
+ * // Later:
73
+ * cleanup();
74
+ * ```
34
75
  */
35
76
  export declare function renderAdminUI(container: HTMLElement, props: AdminUIProps): () => void;
77
+ /** Props for the `<AdminStandalone />` self-contained iframe variant. */
36
78
  export interface AdminStandaloneProps {
79
+ /** API key for authenticating backend requests. */
37
80
  apiKey: string;
81
+ /** Base URL of the Dyrected backend API. */
38
82
  baseUrl: string;
83
+ /** Site ID for multi-tenant deployments. */
39
84
  siteId?: string;
40
85
  }
86
+ /**
87
+ * A fully self-contained admin UI that uses a `MemoryRouter`.
88
+ * Intended for iframe or self-hosted deployments where the admin owns
89
+ * the entire page and does not share URL history with a host app.
90
+ */
41
91
  export declare function AdminStandalone({ apiKey, baseUrl, siteId }: AdminStandaloneProps): import("react/jsx-runtime").JSX.Element;
42
92
  export { SetupPromptUI } from './pages/setup/setup-prompt';
43
93
  export type { SetupPromptProps } from './pages/setup/setup-prompt';