@smartspace/chat-ui 1.14.0-main.5f4f2ef → 1.14.0-main.b0380b4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Smartspace.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -277,7 +277,6 @@ type Workspace = {
277
277
  firstPrompt: string;
278
278
  outputSchema?: unknown;
279
279
  inputs?: unknown;
280
- isPromptAndResponseLoggingEnabled: boolean;
281
280
  variables: Variables;
282
281
  sandBoxThreadId?: string;
283
282
  supportsFiles: boolean;
@@ -623,7 +622,6 @@ declare const workspaceResponseSchema: z.ZodObject<{
623
622
  inputs: z.ZodRecord<z.ZodString, z.ZodObject<{
624
623
  schema: z.ZodRecord<z.ZodString, z.ZodAny>;
625
624
  }, z.core.$strip>>;
626
- isPromptAndResponseLoggingEnabled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
627
625
  modelConfigurations: z.ZodArray<z.ZodObject<{
628
626
  frequencyPenalty: z.ZodNumber;
629
627
  model: z.ZodObject<{
@@ -854,7 +852,6 @@ declare const workspacesListResponseSchema: z.ZodObject<{
854
852
  inputs: z.ZodRecord<z.ZodString, z.ZodObject<{
855
853
  schema: z.ZodRecord<z.ZodString, z.ZodAny>;
856
854
  }, z.core.$strip>>;
857
- isPromptAndResponseLoggingEnabled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
858
855
  modelConfigurations: z.ZodArray<z.ZodObject<{
859
856
  frequencyPenalty: z.ZodNumber;
860
857
  model: z.ZodObject<{
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import MuiButton from '@mui/material/Button';
2
2
  import IconButton from '@mui/material/IconButton';
3
3
  import { Loader2, Check, X, Paperclip, ArrowBigUp, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, ExternalLink, Copy, Download } from 'lucide-react';
4
- import * as React8 from 'react';
4
+ import * as React9 from 'react';
5
5
  import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, createElement, useContext } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { useQuery, queryOptions, useQueryClient, useMutation, skipToken } from '@tanstack/react-query';
@@ -1687,7 +1687,7 @@ var buttonVariants = cva(
1687
1687
  }
1688
1688
  }
1689
1689
  );
1690
- var Button = React8.forwardRef(
1690
+ var Button = React9.forwardRef(
1691
1691
  ({ className, variant, size, asChild = false, ...props }, ref) => {
1692
1692
  const Comp = asChild ? Slot : "button";
1693
1693
  return /* @__PURE__ */ jsx(
@@ -2902,6 +2902,128 @@ var modelIdRendererTester = rankWith(
2902
2902
  }
2903
2903
  );
2904
2904
  var ModelIdRendererControl = withJsonFormsControlProps(ModelIdRenderer);
2905
+ var NumberRenderer = ({
2906
+ data,
2907
+ handleChange,
2908
+ path: path2,
2909
+ label,
2910
+ description,
2911
+ errors,
2912
+ schema,
2913
+ uischema,
2914
+ visible,
2915
+ enabled,
2916
+ required
2917
+ }) => {
2918
+ const isInteger = schema?.type === "integer";
2919
+ const handleInputChange = useCallback(
2920
+ (event) => {
2921
+ const raw2 = event.target.value;
2922
+ if (raw2 === "") {
2923
+ handleChange(path2, void 0);
2924
+ return;
2925
+ }
2926
+ const parsed = isInteger ? parseInt(raw2, 10) : parseFloat(raw2);
2927
+ if (Number.isNaN(parsed)) {
2928
+ handleChange(path2, void 0);
2929
+ return;
2930
+ }
2931
+ handleChange(path2, parsed);
2932
+ },
2933
+ [handleChange, path2, isInteger]
2934
+ );
2935
+ if (!visible) return null;
2936
+ const readOnly = uischema?.access === "Read";
2937
+ const isDisabled = !enabled || readOnly;
2938
+ const hasError = !!errors && errors.length > 0;
2939
+ const fieldSchema = schema;
2940
+ const min = fieldSchema?.minimum;
2941
+ const max = fieldSchema?.maximum;
2942
+ const step = isInteger ? 1 : fieldSchema?.multipleOf ?? "any";
2943
+ return /* @__PURE__ */ jsxs(
2944
+ "div",
2945
+ {
2946
+ className: "ss-jsonforms-field ss-jsonforms-number",
2947
+ style: {
2948
+ display: "inline-flex",
2949
+ flexDirection: "row",
2950
+ alignItems: "center",
2951
+ gap: 8,
2952
+ minHeight: "40px"
2953
+ },
2954
+ children: [
2955
+ label && /* @__PURE__ */ jsxs(
2956
+ "label",
2957
+ {
2958
+ htmlFor: `number-${path2}`,
2959
+ style: {
2960
+ color: hasError ? "#ef4444" : "#475569",
2961
+ fontSize: "0.875rem",
2962
+ fontWeight: 500,
2963
+ whiteSpace: "nowrap",
2964
+ lineHeight: "24px"
2965
+ },
2966
+ children: [
2967
+ label,
2968
+ required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
2969
+ ]
2970
+ }
2971
+ ),
2972
+ /* @__PURE__ */ jsx(
2973
+ "input",
2974
+ {
2975
+ id: `number-${path2}`,
2976
+ type: "number",
2977
+ value: data ?? "",
2978
+ onChange: handleInputChange,
2979
+ disabled: isDisabled,
2980
+ min,
2981
+ max,
2982
+ step,
2983
+ style: {
2984
+ width: "80px",
2985
+ height: "24px",
2986
+ padding: "0 0.5rem",
2987
+ border: hasError ? "2px solid #ef4444" : "1px solid #d1d5db",
2988
+ borderRadius: "6px",
2989
+ fontSize: "0.875rem",
2990
+ lineHeight: "24px",
2991
+ fontFamily: "inherit",
2992
+ backgroundColor: isDisabled ? "#f9fafb" : "#ffffff",
2993
+ color: isDisabled ? "#9ca3af" : "#111827",
2994
+ outline: "none",
2995
+ boxSizing: "border-box"
2996
+ }
2997
+ }
2998
+ ),
2999
+ hasError && /* @__PURE__ */ jsx(
3000
+ "div",
3001
+ {
3002
+ style: {
3003
+ color: "#ef4444",
3004
+ fontSize: "0.75rem"
3005
+ },
3006
+ children: errors
3007
+ }
3008
+ )
3009
+ ]
3010
+ }
3011
+ );
3012
+ };
3013
+ var numberRendererTester = rankWith(
3014
+ 40,
3015
+ (uischema, schema) => {
3016
+ if (uischema.type !== "Control") return false;
3017
+ const propertyPath = uischema.scope.replace(
3018
+ "#/properties/",
3019
+ ""
3020
+ );
3021
+ const fieldSchema = schema?.properties?.[propertyPath];
3022
+ if (!fieldSchema) return false;
3023
+ return fieldSchema.type === "integer" || fieldSchema.type === "number";
3024
+ }
3025
+ );
3026
+ var NumberRendererControl = withJsonFormsControlProps(NumberRenderer);
2905
3027
  var TextareaRenderer = ({
2906
3028
  data,
2907
3029
  handleChange,
@@ -3071,6 +3193,7 @@ var renderers = [
3071
3193
  { tester: modelIdRendererTester, renderer: ModelIdRendererControl },
3072
3194
  { tester: booleanRendererTester, renderer: BooleanRendererControl },
3073
3195
  { tester: dropdownRendererTester, renderer: DropdownRendererControl },
3196
+ { tester: numberRendererTester, renderer: NumberRendererControl },
3074
3197
  { tester: textareaRendererTester, renderer: TextareaRendererControl },
3075
3198
  ...vanillaRenderers,
3076
3199
  { tester: jsonEditorTester, renderer: JsonEditorRendererControl }
@@ -3124,26 +3247,26 @@ function useChatVariablesFormVm({
3124
3247
  const { mutate: updateVariableMutation } = useUpdateFlowRunVariable();
3125
3248
  const querySettled = !isLoading && (threadVars !== void 0 || isError);
3126
3249
  const shouldUseDefaults = isError || threadVars && Object.keys(threadVars).length === 0;
3127
- const built = React8.useMemo(() => {
3250
+ const built = React9.useMemo(() => {
3128
3251
  return buildSimpleSchemaAndUi(
3129
3252
  workspace.variables,
3130
3253
  threadVars,
3131
3254
  shouldUseDefaults ?? false
3132
3255
  );
3133
3256
  }, [workspace.variables, threadVars, shouldUseDefaults]);
3134
- const [data, setData] = React8.useState(null);
3135
- React8.useEffect(() => {
3257
+ const [data, setData] = React9.useState(null);
3258
+ React9.useEffect(() => {
3136
3259
  if (querySettled) {
3137
3260
  setData(built.initialData);
3138
3261
  setVariables(built.initialData);
3139
3262
  }
3140
3263
  }, [querySettled, built.initialData, setVariables]);
3141
- const ajv = React8.useMemo(() => createAjv({ useDefaults: false }), []);
3142
- const prevRef = React8.useRef(null);
3143
- React8.useEffect(() => {
3264
+ const ajv = React9.useMemo(() => createAjv({ useDefaults: false }), []);
3265
+ const prevRef = React9.useRef(null);
3266
+ React9.useEffect(() => {
3144
3267
  prevRef.current = data;
3145
3268
  }, [data]);
3146
- const onChange = React8.useCallback(
3269
+ const onChange = React9.useCallback(
3147
3270
  ({ data: next2 }) => {
3148
3271
  if (prevRef.current && !isDraftThreadId(threadId)) {
3149
3272
  const keys2 = Object.keys(workspace.variables || {});
@@ -3164,7 +3287,7 @@ function useChatVariablesFormVm({
3164
3287
  },
3165
3288
  [workspace.variables, setVariables, updateVariableMutation, threadId]
3166
3289
  );
3167
- const config = React8.useMemo(
3290
+ const config = React9.useMemo(
3168
3291
  () => ({
3169
3292
  restrict: true,
3170
3293
  trim: false,
@@ -19077,7 +19200,7 @@ function getAvatarColour(name) {
19077
19200
  const textColor = brightness > 128 ? "#000000" : "#FFFFFF";
19078
19201
  return { backgroundColor, textColor };
19079
19202
  }
19080
- var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19203
+ var Avatar = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19081
19204
  "div",
19082
19205
  {
19083
19206
  ref,
@@ -19089,7 +19212,7 @@ var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
19089
19212
  }
19090
19213
  ));
19091
19214
  Avatar.displayName = "Avatar";
19092
- var AvatarImage = React8.forwardRef(({ className, alt, src, children: children2, ...props }, _ref) => /* @__PURE__ */ jsx(
19215
+ var AvatarImage = React9.forwardRef(({ className, alt, src, children: children2, ...props }, _ref) => /* @__PURE__ */ jsx(
19093
19216
  MuiAvatar,
19094
19217
  {
19095
19218
  className: cn("aspect-square h-full w-full", className),
@@ -19100,7 +19223,7 @@ var AvatarImage = React8.forwardRef(({ className, alt, src, children: children2,
19100
19223
  }
19101
19224
  ));
19102
19225
  AvatarImage.displayName = "AvatarImage";
19103
- var AvatarFallback = React8.forwardRef(
19226
+ var AvatarFallback = React9.forwardRef(
19104
19227
  ({ className, colored = true, ...props }, ref) => {
19105
19228
  const childText = String(props.children ?? "");
19106
19229
  const colours = colored ? getAvatarColour(childText) : void 0;
@@ -19690,7 +19813,8 @@ var MessageItem = ({
19690
19813
  groupType = v.type;
19691
19814
  const name = v.name.toLowerCase();
19692
19815
  switch (name) {
19693
- case "variables": {
19816
+ case "variables":
19817
+ case "userinfo": {
19694
19818
  continue;
19695
19819
  }
19696
19820
  case "status": {
@@ -20194,9 +20318,6 @@ function mapWorkspaceDtoToModel(dto) {
20194
20318
  firstPrompt: dto.firstPrompt ?? "",
20195
20319
  outputSchema: dto.outputSchema ?? void 0,
20196
20320
  inputs: dto.inputs ?? void 0,
20197
- isPromptAndResponseLoggingEnabled: truthy(
20198
- dto.isPromptAndResponseLoggingEnabled
20199
- ),
20200
20321
  variables,
20201
20322
  sandBoxThreadId: dto.sandBoxThreadId ?? void 0,
20202
20323
  supportsFiles: truthy(dto.supportsFiles),