@elevasis/ui 2.25.6 → 2.26.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/dist/api/index.js +2 -2
- package/dist/app/index.css +15 -5
- package/dist/app/index.d.ts +61 -14
- package/dist/app/index.js +6 -6
- package/dist/charts/index.js +6 -5
- package/dist/chunk-3MEXPLWT.js +265 -0
- package/dist/{chunk-BDKM56TP.js → chunk-4KTLOK7K.js} +1 -1
- package/dist/{chunk-KMAXFJPH.js → chunk-CW3UNAF2.js} +5 -409
- package/dist/{chunk-HKBEURCV.js → chunk-G26INIF3.js} +1 -1
- package/dist/{chunk-7F3IQMLI.js → chunk-G66QFZXD.js} +11 -214
- package/dist/{chunk-QIW6OCEI.js → chunk-HLFFKKT3.js} +27 -373
- package/dist/chunk-JDNEWB5F.js +10 -0
- package/dist/{chunk-L7D6KNHV.js → chunk-JKBGDFX2.js} +890 -749
- package/dist/{chunk-YRKQNPK2.js → chunk-JPGX3533.js} +4 -3
- package/dist/chunk-KCGGA36K.js +73 -0
- package/dist/chunk-KEFWANZY.js +155 -0
- package/dist/chunk-LH4GPYDX.js +448 -0
- package/dist/{chunk-JXSBOG2R.js → chunk-LWKZ3BCC.js} +5 -4
- package/dist/chunk-OGXKOMUT.js +412 -0
- package/dist/chunk-OHXU5WWK.js +3731 -0
- package/dist/chunk-ONFKASZI.js +2004 -0
- package/dist/{chunk-U36X6NZM.js → chunk-RIFTUOPE.js} +2 -14
- package/dist/{chunk-T6INEVX6.js → chunk-SGS4CQ2B.js} +1 -1
- package/dist/{chunk-C7IBFI5B.js → chunk-UPMX5GJI.js} +5 -5
- package/dist/{chunk-ARJPZ66V.js → chunk-UY5I2KOZ.js} +208 -3124
- package/dist/chunk-W2ZTLH7Y.js +662 -0
- package/dist/{chunk-KNISO652.js → chunk-WUVR4QY6.js} +9 -9
- package/dist/{chunk-Q5BEODAT.js → chunk-X2SUMO3P.js} +2 -1
- package/dist/{chunk-SNHGSCKH.js → chunk-XBMCDGHA.js} +1 -1
- package/dist/{chunk-N55DVMAG.js → chunk-XQQEKWTL.js} +2 -6
- package/dist/{chunk-SBQ4MYQV.js → chunk-XZSEPJZQ.js} +5 -6
- package/dist/{chunk-CPAJXBTL.js → chunk-YHBPR67D.js} +490 -676
- package/dist/{chunk-QARSVM7Q.js → chunk-YO2YORW4.js} +4 -4
- package/dist/{chunk-TAIX4NO3.js → chunk-ZFLM2YVW.js} +2 -2
- package/dist/components/index.css +15 -5
- package/dist/components/index.d.ts +202 -383
- package/dist/components/index.js +43 -429
- package/dist/components/navigation/index.css +25 -15
- package/dist/execution/index.d.ts +0 -73
- package/dist/features/auth/index.css +25 -15
- package/dist/features/crm/index.css +25 -15
- package/dist/features/crm/index.d.ts +49 -49
- package/dist/features/crm/index.js +14 -15
- package/dist/features/dashboard/index.css +25 -15
- package/dist/features/dashboard/index.js +18 -16
- package/dist/features/delivery/index.css +15 -5
- package/dist/features/delivery/index.js +14 -15
- package/dist/features/knowledge/index.css +611 -0
- package/dist/features/knowledge/index.js +375 -72
- package/dist/features/lead-gen/index.css +25 -15
- package/dist/features/lead-gen/index.d.ts +60 -21
- package/dist/features/lead-gen/index.js +16 -16
- package/dist/features/monitoring/index.css +15 -5
- package/dist/features/monitoring/index.js +17 -17
- package/dist/features/monitoring/requests/index.css +25 -15
- package/dist/features/monitoring/requests/index.js +13 -14
- package/dist/features/operations/index.css +25 -15
- package/dist/features/operations/index.d.ts +16 -98
- package/dist/features/operations/index.js +26 -22
- package/dist/features/settings/index.css +25 -15
- package/dist/features/settings/index.d.ts +1 -0
- package/dist/features/settings/index.js +15 -16
- package/dist/hooks/delivery/index.css +25 -15
- package/dist/hooks/delivery/index.js +2 -2
- package/dist/hooks/index.css +15 -5
- package/dist/hooks/index.d.ts +172 -380
- package/dist/hooks/index.js +13 -14
- package/dist/hooks/published.css +15 -5
- package/dist/hooks/published.d.ts +172 -380
- package/dist/hooks/published.js +13 -14
- package/dist/index.css +15 -5
- package/dist/index.d.ts +988 -403
- package/dist/index.js +15 -15
- package/dist/initialization/index.d.ts +1 -0
- package/dist/knowledge/index.d.ts +981 -41
- package/dist/knowledge/index.js +5449 -294
- package/dist/layout/index.d.ts +2 -0
- package/dist/layout/index.js +3 -2
- package/dist/organization/index.css +25 -15
- package/dist/organization/index.d.ts +1 -0
- package/dist/provider/index.css +25 -15
- package/dist/provider/index.d.ts +818 -26
- package/dist/provider/index.js +11 -11
- package/dist/provider/published.css +25 -15
- package/dist/provider/published.d.ts +817 -25
- package/dist/provider/published.js +8 -9
- package/dist/test-utils/index.js +2 -2
- package/dist/test-utils/setup.js +1 -1
- package/dist/theme/index.js +3 -2
- package/dist/theme/presets/index.d.ts +97 -0
- package/dist/theme/presets/index.js +3 -0
- package/dist/types/index.d.ts +71 -126
- package/dist/utils/index.js +1 -1
- package/dist/vite/index.d.ts +7 -0
- package/dist/vite/index.js +10 -0
- package/dist/vite-plugin-knowledge/index.d.ts +1 -33
- package/dist/vite-plugin-knowledge/index.js +1 -66
- package/package.json +16 -3
- package/src/knowledge/README.md +8 -8
- package/src/theme/presets/README.md +19 -0
- package/dist/chunk-5RLYII6P.js +0 -314
- package/dist/chunk-6U7AIIHF.js +0 -880
- package/dist/chunk-HAEJ4M54.js +0 -94
- package/dist/chunk-LPM7O6XM.js +0 -293
- /package/dist/{chunk-SGXXJE52.js → chunk-QD4X4H5A.js} +0 -0
package/dist/api/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../chunk-XCYKC6OZ.js';
|
|
2
|
-
export { ApiClientProvider, useApiClient, useApiClientContext } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
export { ApiClientProvider, useApiClient, useApiClientContext } from '../chunk-SGS4CQ2B.js';
|
|
3
|
+
import '../chunk-QD4X4H5A.js';
|
|
4
4
|
import '../chunk-KRWALB24.js';
|
|
5
5
|
import '../chunk-DD3CCMCZ.js';
|
|
6
6
|
import '../chunk-I2KLQ2HA.js';
|
package/dist/app/index.css
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
}
|
|
12
12
|
.lead-gen-build-action-button:disabled,
|
|
13
13
|
.lead-gen-build-action-button[data-disabled] {
|
|
14
|
-
background-color:
|
|
15
|
-
border-color:
|
|
14
|
+
background-color: var(--surface-primary-muted) !important;
|
|
15
|
+
border-color: var(--border-primary-subtle) !important;
|
|
16
16
|
color: color-mix(in srgb, var(--color-text-subtle) 88%, var(--color-text-dimmed) 12%) !important;
|
|
17
17
|
opacity: 0.78;
|
|
18
18
|
}
|
|
19
19
|
.lead-gen-build-action-button:disabled:hover,
|
|
20
20
|
.lead-gen-build-action-button[data-disabled]:hover {
|
|
21
|
-
background-color:
|
|
21
|
+
background-color: var(--surface-primary-muted) !important;
|
|
22
22
|
}
|
|
23
23
|
.mantine-Accordion-control:hover {
|
|
24
24
|
background-color: var(--color-surface-hover);
|
|
@@ -26,8 +26,18 @@
|
|
|
26
26
|
.mantine-Menu-item:hover:not([data-disabled]) {
|
|
27
27
|
background-color: var(--color-surface-hover);
|
|
28
28
|
}
|
|
29
|
-
.mantine-Select-option:hover
|
|
30
|
-
|
|
29
|
+
.mantine-Select-option:hover,
|
|
30
|
+
.mantine-MultiSelect-option:hover,
|
|
31
|
+
.mantine-TagsInput-option:hover,
|
|
32
|
+
.mantine-Combobox-option:hover {
|
|
33
|
+
background-color: var(--surface-primary-muted) !important;
|
|
34
|
+
}
|
|
35
|
+
.mantine-Select-option[data-combobox-selected],
|
|
36
|
+
.mantine-MultiSelect-option[data-combobox-selected],
|
|
37
|
+
.mantine-TagsInput-option[data-combobox-selected],
|
|
38
|
+
.mantine-Combobox-option[data-combobox-selected] {
|
|
39
|
+
background-color: var(--surface-primary-subtle) !important;
|
|
40
|
+
color: var(--color-text);
|
|
31
41
|
}
|
|
32
42
|
[data-mantine-color-scheme=dark] .mantine-Tabs-root {
|
|
33
43
|
--tab-border-color: var(--color-border);
|
package/dist/app/index.d.ts
CHANGED
|
@@ -2912,9 +2912,6 @@ type Database = {
|
|
|
2912
2912
|
};
|
|
2913
2913
|
};
|
|
2914
2914
|
|
|
2915
|
-
/** Raw database row type for acq_deals table */
|
|
2916
|
-
type AcqDealRow = Database['public']['Tables']['acq_deals']['Row'];
|
|
2917
|
-
|
|
2918
2915
|
/**
|
|
2919
2916
|
* Single list as returned by /api/acquisition/lists/:id etc.
|
|
2920
2917
|
* Camel-cased domain shape matching AcqList in types.ts.
|
|
@@ -2958,7 +2955,6 @@ declare const AcqListResponseSchema: z$1.ZodObject<{
|
|
|
2958
2955
|
maxBatchSize: z$1.ZodNumber;
|
|
2959
2956
|
}, z$1.core.$strip>>;
|
|
2960
2957
|
}, z$1.core.$strip>>;
|
|
2961
|
-
stepConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2962
2958
|
}, z$1.core.$catchall<z$1.ZodUnknown>>;
|
|
2963
2959
|
launchedAt: z$1.ZodNullable<z$1.ZodString>;
|
|
2964
2960
|
completedAt: z$1.ZodNullable<z$1.ZodString>;
|
|
@@ -2988,6 +2984,9 @@ declare const AcqListResponseSchema: z$1.ZodObject<{
|
|
|
2988
2984
|
}, z$1.core.$strip>;
|
|
2989
2985
|
type AcqListResponse = z$1.infer<typeof AcqListResponseSchema>;
|
|
2990
2986
|
|
|
2987
|
+
/** Raw database row type for acq_deals table */
|
|
2988
|
+
type AcqDealRow = Database['public']['Tables']['acq_deals']['Row'];
|
|
2989
|
+
|
|
2991
2990
|
interface ActionDef {
|
|
2992
2991
|
key: string;
|
|
2993
2992
|
label: string;
|
|
@@ -3045,13 +3044,65 @@ interface ThemePreset {
|
|
|
3045
3044
|
}
|
|
3046
3045
|
type PresetName = 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'titanium' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-chrome' | 'cyber-void' | 'nirvana' | 'wave' | 'synapse' | 'cortex' | 'helios' | 'graphite' | 'quarry';
|
|
3047
3046
|
|
|
3047
|
+
/**
|
|
3048
|
+
* All valid dotted paths into T.
|
|
3049
|
+
* Arrays of primitives are treated as leaf (return K only).
|
|
3050
|
+
* Arrays of objects are also treated as leaf (no drilling into element shape).
|
|
3051
|
+
* Optional fields are unwrapped via NonNullable before recursing.
|
|
3052
|
+
*/
|
|
3053
|
+
type FieldPath<T> = T extends object ? {
|
|
3054
|
+
[K in keyof T & string]: T[K] extends ReadonlyArray<unknown> | unknown[] ? K : T[K] extends object | undefined ? K | `${K}.${FieldPath<NonNullable<T[K]>>}` : K;
|
|
3055
|
+
}[keyof T & string] : never;
|
|
3056
|
+
/** Discriminated string union of supported Mantine components. */
|
|
3057
|
+
type StepConfigComponent = 'segmented' | 'tags' | 'multiselect' | 'select' | 'textinput' | 'textarea' | 'numberinput' | 'switch' | 'json';
|
|
3058
|
+
/** Rendering hint for a single field within a section. */
|
|
3059
|
+
interface StepConfigFieldHint<T> {
|
|
3060
|
+
/** Typed dotted path into T — typo = TS error. */
|
|
3061
|
+
path: FieldPath<T>;
|
|
3062
|
+
/** Mantine component to render for this field. */
|
|
3063
|
+
component: StepConfigComponent;
|
|
3064
|
+
/** Overrides the field label derived from Zod .describe() or the key name. */
|
|
3065
|
+
label?: string;
|
|
3066
|
+
/** Help text shown below the field; overrides Zod .describe(). */
|
|
3067
|
+
description?: string;
|
|
3068
|
+
placeholder?: string;
|
|
3069
|
+
/** Required for 'segmented', 'select', 'multiselect'; ignored for others. */
|
|
3070
|
+
options?: ReadonlyArray<{
|
|
3071
|
+
value: string;
|
|
3072
|
+
label: string;
|
|
3073
|
+
}>;
|
|
3074
|
+
/** Minimum value — applies to 'numberinput'. */
|
|
3075
|
+
min?: number;
|
|
3076
|
+
/** Maximum value — applies to 'numberinput'. */
|
|
3077
|
+
max?: number;
|
|
3078
|
+
/** Stepper increment — applies to 'numberinput'. */
|
|
3079
|
+
step?: number;
|
|
3080
|
+
/** Per-field conditional visibility, evaluated against current form values. */
|
|
3081
|
+
when?: (values: T) => boolean;
|
|
3082
|
+
}
|
|
3083
|
+
/** An ordered group of fields, optionally shown conditionally. */
|
|
3084
|
+
interface StepConfigSection<T> {
|
|
3085
|
+
/** Stable key used for React rendering. */
|
|
3086
|
+
id: string;
|
|
3087
|
+
/** Section heading; omit for the top-level (untitled) section. */
|
|
3088
|
+
title?: string;
|
|
3089
|
+
description?: string;
|
|
3090
|
+
/** Section-level conditional visibility predicate. */
|
|
3091
|
+
when?: (values: T) => boolean;
|
|
3092
|
+
/** Fields rendered in order within this section. */
|
|
3093
|
+
fields: StepConfigFieldHint<T>[];
|
|
3094
|
+
}
|
|
3095
|
+
/** Top-level layout descriptor supplied by a per-integration registry entry. */
|
|
3096
|
+
interface StepConfigLayout<T> {
|
|
3097
|
+
/** Ordered top-level sections of the form. */
|
|
3098
|
+
sections: StepConfigSection<T>[];
|
|
3099
|
+
/** Optional single Advanced collapse rendered below all sections. */
|
|
3100
|
+
advanced?: StepConfigSection<T>;
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3048
3103
|
type ListBuilderWorkflowCategory = 'build' | 'enrich' | 'qualify' | 'scrape' | 'utility';
|
|
3049
3104
|
type LeadGenStageKey = string;
|
|
3050
3105
|
type LeadGenCapabilityKey = string;
|
|
3051
|
-
interface ListBuilderWorkflowFormProps {
|
|
3052
|
-
list: AcqListResponse;
|
|
3053
|
-
onSubmit: (input: unknown) => void | Promise<void>;
|
|
3054
|
-
}
|
|
3055
3106
|
interface ListBuilderWorkflow {
|
|
3056
3107
|
resourceId: string;
|
|
3057
3108
|
workflowId?: string;
|
|
@@ -3060,12 +3111,8 @@ interface ListBuilderWorkflow {
|
|
|
3060
3111
|
description: string;
|
|
3061
3112
|
category: ListBuilderWorkflowCategory;
|
|
3062
3113
|
stagesAffected: readonly LeadGenStageKey[];
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
value: Record<string, unknown>;
|
|
3066
|
-
onChange: (next: Record<string, unknown>) => void;
|
|
3067
|
-
}>;
|
|
3068
|
-
inputForm?: ComponentType<ListBuilderWorkflowFormProps>;
|
|
3114
|
+
schema: z.ZodTypeAny;
|
|
3115
|
+
layout: StepConfigLayout<any>;
|
|
3069
3116
|
defaultInput?: (list: AcqListResponse) => unknown;
|
|
3070
3117
|
}
|
|
3071
3118
|
type ListBuilderRegistry = readonly ListBuilderWorkflow[];
|
package/dist/app/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ElevasisUIProvider } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { ElevasisUIProvider } from '../chunk-JPGX3533.js';
|
|
2
|
+
import '../chunk-LH4GPYDX.js';
|
|
3
|
+
import '../chunk-HLFFKKT3.js';
|
|
3
4
|
import '../chunk-WLOQ4IBG.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-W2ZTLH7Y.js';
|
|
5
6
|
import '../chunk-SZHARWKU.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-T6INEVX6.js';
|
|
7
|
+
import '../chunk-SGS4CQ2B.js';
|
|
8
8
|
import '../chunk-HOIT677G.js';
|
|
9
9
|
import '../chunk-E565XMTQ.js';
|
|
10
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-QD4X4H5A.js';
|
|
11
11
|
import '../chunk-KRWALB24.js';
|
|
12
12
|
import { useInitialization } from '../chunk-WKJ47GIW.js';
|
|
13
13
|
import '../chunk-DD3CCMCZ.js';
|
package/dist/charts/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart,
|
|
1
|
+
export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart, HeroStatsRow } from '../chunk-OGXKOMUT.js';
|
|
2
|
+
export { CyberAreaChart, CyberDonut, CyberDonutTooltip, CyberLegendItem, getSeriesColor, useCyberColors } from '../chunk-CW3UNAF2.js';
|
|
2
3
|
import '../chunk-VKMNWHTL.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-NYBEU5TE.js';
|
|
5
|
-
import '../chunk-SZHARWKU.js';
|
|
4
|
+
import '../chunk-RIFTUOPE.js';
|
|
6
5
|
import '../chunk-3KMDHCAR.js';
|
|
6
|
+
import '../chunk-SZHARWKU.js';
|
|
7
|
+
import '../chunk-NYBEU5TE.js';
|
|
7
8
|
import '../chunk-2IFYDILW.js';
|
|
8
9
|
import '../chunk-Q7DJKLEN.js';
|
|
9
10
|
import '../chunk-DT3QYZVU.js';
|
|
10
|
-
import '../chunk-
|
|
11
|
+
import '../chunk-QD4X4H5A.js';
|
|
11
12
|
import '../chunk-KRWALB24.js';
|
|
12
13
|
import '../chunk-WFTNY755.js';
|
|
13
14
|
import '../chunk-WKJ47GIW.js';
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { TextInput, Textarea, Radio, Stack, Checkbox, Select, NumberInput, Button } from '@mantine/core';
|
|
2
|
+
import { useForm } from '@mantine/form';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
// src/components/forms/ZodFormRenderer.tsx
|
|
7
|
+
function FormFieldRenderer({ field, form, richTextRenderer }) {
|
|
8
|
+
const commonProps = {
|
|
9
|
+
label: field.label,
|
|
10
|
+
description: field.description,
|
|
11
|
+
placeholder: field.placeholder,
|
|
12
|
+
required: field.required,
|
|
13
|
+
...form.getInputProps(field.name)
|
|
14
|
+
};
|
|
15
|
+
switch (field.type) {
|
|
16
|
+
case "text":
|
|
17
|
+
return /* @__PURE__ */ jsx(TextInput, { ...commonProps });
|
|
18
|
+
case "textarea":
|
|
19
|
+
return /* @__PURE__ */ jsx(Textarea, { ...commonProps, minRows: 3, autosize: true });
|
|
20
|
+
case "number":
|
|
21
|
+
return /* @__PURE__ */ jsx(NumberInput, { ...commonProps, min: field.min, max: field.max });
|
|
22
|
+
case "select":
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Select,
|
|
25
|
+
{
|
|
26
|
+
...commonProps,
|
|
27
|
+
data: field.options?.map((opt) => ({
|
|
28
|
+
label: opt.label,
|
|
29
|
+
value: String(opt.value)
|
|
30
|
+
})) || []
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
case "checkbox":
|
|
34
|
+
return /* @__PURE__ */ jsx(Checkbox, { ...commonProps, ...form.getInputProps(field.name, { type: "checkbox" }) });
|
|
35
|
+
case "radio":
|
|
36
|
+
return /* @__PURE__ */ jsx(Radio.Group, { ...commonProps, children: /* @__PURE__ */ jsx(Stack, { gap: "xs", children: field.options?.map((opt) => /* @__PURE__ */ jsx(Radio, { value: String(opt.value), label: opt.label }, opt.value)) }) });
|
|
37
|
+
case "richtext": {
|
|
38
|
+
const inputProps = form.getInputProps(field.name);
|
|
39
|
+
if (richTextRenderer) {
|
|
40
|
+
return richTextRenderer({
|
|
41
|
+
content: inputProps.value || "",
|
|
42
|
+
onChange: (content) => form.setFieldValue(field.name, content),
|
|
43
|
+
placeholder: field.placeholder
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsx(Textarea, { ...commonProps, minRows: 5, autosize: true });
|
|
47
|
+
}
|
|
48
|
+
default:
|
|
49
|
+
return /* @__PURE__ */ jsx(TextInput, { ...commonProps });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function toJsonSchema(zodSchema) {
|
|
53
|
+
return z.toJSONSchema(zodSchema);
|
|
54
|
+
}
|
|
55
|
+
function humanizeKey(name) {
|
|
56
|
+
return name.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
57
|
+
}
|
|
58
|
+
function unwrapNullable(schema) {
|
|
59
|
+
if (Array.isArray(schema.anyOf)) {
|
|
60
|
+
const nonNull = schema.anyOf.filter((s) => s.type !== "null");
|
|
61
|
+
if (nonNull.length === 1) return { ...nonNull[0], description: schema.description ?? nonNull[0].description };
|
|
62
|
+
}
|
|
63
|
+
return schema;
|
|
64
|
+
}
|
|
65
|
+
function defaultForLeaf(schema) {
|
|
66
|
+
if (schema.default !== void 0) return schema.default;
|
|
67
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) return schema.enum[0];
|
|
68
|
+
switch (schema.type) {
|
|
69
|
+
case "string":
|
|
70
|
+
return "";
|
|
71
|
+
case "integer":
|
|
72
|
+
case "number":
|
|
73
|
+
return 0;
|
|
74
|
+
case "boolean":
|
|
75
|
+
return false;
|
|
76
|
+
case "array":
|
|
77
|
+
return [];
|
|
78
|
+
case "object":
|
|
79
|
+
return schema.properties ? extractDefaults(schema) : {};
|
|
80
|
+
default:
|
|
81
|
+
return void 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function extractDefaults(jsonSchema) {
|
|
85
|
+
if (jsonSchema.type !== "object" || !jsonSchema.properties) return {};
|
|
86
|
+
const result = {};
|
|
87
|
+
for (const [key, propSchema] of Object.entries(jsonSchema.properties)) {
|
|
88
|
+
result[key] = defaultForLeaf(unwrapNullable(propSchema));
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function propSchemaToFormField(name, raw, required) {
|
|
93
|
+
const schema = unwrapNullable(raw);
|
|
94
|
+
const label = humanizeKey(name);
|
|
95
|
+
const description = schema.description ?? "";
|
|
96
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
97
|
+
const values = schema.enum.filter((v) => typeof v === "string" || typeof v === "number");
|
|
98
|
+
return {
|
|
99
|
+
name,
|
|
100
|
+
label,
|
|
101
|
+
type: "select",
|
|
102
|
+
required,
|
|
103
|
+
placeholder: "",
|
|
104
|
+
description,
|
|
105
|
+
options: values.map((v) => ({ label: String(v), value: typeof v === "number" ? v : String(v) })),
|
|
106
|
+
defaultValue: schema.default ?? values[0]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
switch (schema.type) {
|
|
110
|
+
case "string": {
|
|
111
|
+
const isLong = (schema.maxLength ?? 0) > 200;
|
|
112
|
+
return {
|
|
113
|
+
name,
|
|
114
|
+
label,
|
|
115
|
+
type: isLong ? "textarea" : "text",
|
|
116
|
+
required,
|
|
117
|
+
placeholder: "",
|
|
118
|
+
description,
|
|
119
|
+
defaultValue: schema.default ?? ""
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
case "number":
|
|
123
|
+
case "integer": {
|
|
124
|
+
const field = {
|
|
125
|
+
name,
|
|
126
|
+
label,
|
|
127
|
+
type: "number",
|
|
128
|
+
required,
|
|
129
|
+
placeholder: "",
|
|
130
|
+
description,
|
|
131
|
+
defaultValue: schema.default ?? 0
|
|
132
|
+
};
|
|
133
|
+
if (typeof schema.minimum === "number" && schema.minimum > Number.MIN_SAFE_INTEGER) field.min = schema.minimum;
|
|
134
|
+
if (typeof schema.maximum === "number" && schema.maximum < Number.MAX_SAFE_INTEGER) field.max = schema.maximum;
|
|
135
|
+
return field;
|
|
136
|
+
}
|
|
137
|
+
case "boolean":
|
|
138
|
+
return {
|
|
139
|
+
name,
|
|
140
|
+
label,
|
|
141
|
+
type: "checkbox",
|
|
142
|
+
required,
|
|
143
|
+
placeholder: "",
|
|
144
|
+
description,
|
|
145
|
+
defaultValue: schema.default ?? false
|
|
146
|
+
};
|
|
147
|
+
default:
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function jsonSchemaToFormFields(jsonSchema) {
|
|
152
|
+
const fields = [];
|
|
153
|
+
const initialValues = {};
|
|
154
|
+
if (jsonSchema.type !== "object" || !jsonSchema.properties) {
|
|
155
|
+
fields.push({ name: "__input__", label: "Input (JSON)", fallback: true });
|
|
156
|
+
initialValues["__input__"] = jsonSchema.default !== void 0 ? JSON.stringify(jsonSchema.default, null, 2) : "";
|
|
157
|
+
return { fields, initialValues, isObject: false };
|
|
158
|
+
}
|
|
159
|
+
const required = new Set(jsonSchema.required ?? []);
|
|
160
|
+
for (const [name, propSchemaRaw] of Object.entries(jsonSchema.properties)) {
|
|
161
|
+
const propSchema = unwrapNullable(propSchemaRaw);
|
|
162
|
+
const isRequired = required.has(name) && propSchema.default === void 0;
|
|
163
|
+
const formField = propSchemaToFormField(name, propSchema, isRequired);
|
|
164
|
+
if (formField) {
|
|
165
|
+
fields.push(formField);
|
|
166
|
+
initialValues[name] = propSchema.default ?? formField.defaultValue;
|
|
167
|
+
} else {
|
|
168
|
+
fields.push({ name, label: humanizeKey(name), fallback: true });
|
|
169
|
+
initialValues[name] = propSchema.default !== void 0 ? JSON.stringify(propSchema.default, null, 2) : "";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return { fields, initialValues, isObject: true };
|
|
173
|
+
}
|
|
174
|
+
function sanitizeInput(schema, value) {
|
|
175
|
+
const jsonSchema = toJsonSchema(schema);
|
|
176
|
+
const emptyParse = schema.safeParse({});
|
|
177
|
+
const baseDefaults = emptyParse.success && emptyParse.data && typeof emptyParse.data === "object" && !Array.isArray(emptyParse.data) ? emptyParse.data : extractDefaults(jsonSchema);
|
|
178
|
+
if (value === null || value === void 0 || typeof value !== "object" || Array.isArray(value)) {
|
|
179
|
+
return baseDefaults;
|
|
180
|
+
}
|
|
181
|
+
if (jsonSchema.type !== "object" || !jsonSchema.properties) {
|
|
182
|
+
const parsed = schema.safeParse(value);
|
|
183
|
+
return parsed.success && parsed.data && typeof parsed.data === "object" && !Array.isArray(parsed.data) ? parsed.data : baseDefaults;
|
|
184
|
+
}
|
|
185
|
+
const raw = value;
|
|
186
|
+
const result = { ...baseDefaults };
|
|
187
|
+
if (schema instanceof z.ZodObject) {
|
|
188
|
+
const shape = schema.shape;
|
|
189
|
+
for (const key of Object.keys(jsonSchema.properties)) {
|
|
190
|
+
if (key in raw && shape[key]) {
|
|
191
|
+
const fieldParsed = shape[key].safeParse(raw[key]);
|
|
192
|
+
if (fieldParsed.success) {
|
|
193
|
+
result[key] = fieldParsed.data;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
function ZodFormRenderer({
|
|
201
|
+
schema,
|
|
202
|
+
defaults,
|
|
203
|
+
onSubmit,
|
|
204
|
+
submitLabel = "Submit",
|
|
205
|
+
isPending = false
|
|
206
|
+
}) {
|
|
207
|
+
const jsonSchema = toJsonSchema(schema);
|
|
208
|
+
const { fields, initialValues, isObject } = jsonSchemaToFormFields(jsonSchema);
|
|
209
|
+
const mergedInitialValues = { ...initialValues };
|
|
210
|
+
if (isObject && defaults) {
|
|
211
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
212
|
+
if (value !== void 0) mergedInitialValues[key] = value;
|
|
213
|
+
}
|
|
214
|
+
} else if (!isObject && defaults !== void 0) {
|
|
215
|
+
mergedInitialValues["__input__"] = JSON.stringify(defaults, null, 2);
|
|
216
|
+
}
|
|
217
|
+
const form = useForm({ initialValues: mergedInitialValues });
|
|
218
|
+
const handleSubmit = (values) => {
|
|
219
|
+
const coerced = {};
|
|
220
|
+
for (const field of fields) {
|
|
221
|
+
const raw = values[field.name];
|
|
222
|
+
if ("fallback" in field) {
|
|
223
|
+
try {
|
|
224
|
+
coerced[field.name] = raw !== "" && raw !== void 0 ? JSON.parse(raw) : void 0;
|
|
225
|
+
} catch {
|
|
226
|
+
coerced[field.name] = raw;
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
coerced[field.name] = raw;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const payload = isObject ? coerced : coerced["__input__"] ?? coerced;
|
|
233
|
+
const parsed = schema.safeParse(payload);
|
|
234
|
+
if (!parsed.success) {
|
|
235
|
+
for (const issue of parsed.error.issues) {
|
|
236
|
+
const path = issue.path.join(".");
|
|
237
|
+
if (path) form.setFieldError(path, issue.message);
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
void onSubmit(parsed.data);
|
|
242
|
+
};
|
|
243
|
+
return /* @__PURE__ */ jsx("form", { onSubmit: form.onSubmit(handleSubmit), children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
244
|
+
fields.map((field) => {
|
|
245
|
+
if ("fallback" in field) {
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
Textarea,
|
|
248
|
+
{
|
|
249
|
+
label: field.label,
|
|
250
|
+
placeholder: "Enter JSON value",
|
|
251
|
+
minRows: 3,
|
|
252
|
+
autosize: true,
|
|
253
|
+
...form.getInputProps(field.name),
|
|
254
|
+
error: form.errors[field.name]
|
|
255
|
+
},
|
|
256
|
+
field.name
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
return /* @__PURE__ */ jsx(FormFieldRenderer, { field, form }, field.name);
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", loading: isPending, fullWidth: true, children: submitLabel })
|
|
262
|
+
] }) });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { FormFieldRenderer, ZodFormRenderer, sanitizeInput };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayMetadataSchema, ModelIdSchema, DescriptionSchema } from './chunk-
|
|
1
|
+
import { DisplayMetadataSchema, ModelIdSchema, DescriptionSchema } from './chunk-W2ZTLH7Y.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
var ProspectingLifecycleStageSchema = DisplayMetadataSchema.extend({
|