@e-llm-studio/instant-learning 1.3.23 → 1.3.24-alpha.3

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.
Files changed (49) hide show
  1. package/dist/cjs/features/LearningManagement/LearningManagement.js +27 -0
  2. package/dist/cjs/features/LearningManagement/LearningManagement.js.map +1 -1
  3. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +4 -2
  4. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js.map +1 -1
  5. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +11 -1
  6. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js.map +1 -1
  7. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +39 -29
  8. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  9. package/dist/cjs/features/LearningManagement/utils/learningFlow.js +92 -0
  10. package/dist/cjs/features/LearningManagement/utils/learningFlow.js.map +1 -1
  11. package/dist/cjs/schema-driven/components/FileUploadField.js +23 -5
  12. package/dist/cjs/schema-driven/components/FileUploadField.js.map +1 -1
  13. package/dist/cjs/schema-driven/components/FileUploadField.module.css.js +1 -1
  14. package/dist/cjs/schema-driven/components/PromptTextEditorField.js +99 -23
  15. package/dist/cjs/schema-driven/components/PromptTextEditorField.js.map +1 -1
  16. package/dist/cjs/schema-driven/utils/fileUploadService.js +13 -0
  17. package/dist/cjs/schema-driven/utils/fileUploadService.js.map +1 -1
  18. package/dist/features/LearningManagement/LearningManagement.js +27 -0
  19. package/dist/features/LearningManagement/LearningManagement.js.map +1 -1
  20. package/dist/features/LearningManagement/LearningTemplateLayout.js +4 -2
  21. package/dist/features/LearningManagement/LearningTemplateLayout.js.map +1 -1
  22. package/dist/features/LearningManagement/RuleContent/RuleContent.js +11 -1
  23. package/dist/features/LearningManagement/RuleContent/RuleContent.js.map +1 -1
  24. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +41 -31
  25. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  26. package/dist/features/LearningManagement/utils/learningFlow.js +92 -1
  27. package/dist/features/LearningManagement/utils/learningFlow.js.map +1 -1
  28. package/dist/schema-driven/components/FileUploadField.js +24 -6
  29. package/dist/schema-driven/components/FileUploadField.js.map +1 -1
  30. package/dist/schema-driven/components/FileUploadField.module.css.js +1 -1
  31. package/dist/schema-driven/components/PromptTextEditorField.js +99 -23
  32. package/dist/schema-driven/components/PromptTextEditorField.js.map +1 -1
  33. package/dist/schema-driven/utils/fileUploadService.js +13 -1
  34. package/dist/schema-driven/utils/fileUploadService.js.map +1 -1
  35. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +11 -1
  36. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  37. package/dist/types/src/features/LearningManagement/LearningManagementTest.d.ts.map +1 -1
  38. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts +9 -0
  39. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
  40. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts +9 -0
  41. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
  42. package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts.map +1 -1
  43. package/dist/types/src/features/LearningManagement/utils/learningFlow.d.ts +4 -0
  44. package/dist/types/src/features/LearningManagement/utils/learningFlow.d.ts.map +1 -1
  45. package/dist/types/src/schema-driven/components/FileUploadField.d.ts.map +1 -1
  46. package/dist/types/src/schema-driven/components/PromptTextEditorField.d.ts.map +1 -1
  47. package/dist/types/src/schema-driven/utils/fileUploadService.d.ts +5 -0
  48. package/dist/types/src/schema-driven/utils/fileUploadService.d.ts.map +1 -1
  49. package/package.json +4 -4
@@ -2,6 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var useDynamicFormStore = require('../../../schema-driven/store/useDynamicFormStore.js');
6
+ var useLearningTemplateStore = require('../store/useLearningTemplateStore.js');
7
+
5
8
  const resolveIsEditMode = ({
6
9
  flow,
7
10
  editingRule,
@@ -10,6 +13,95 @@ const resolveIsEditMode = ({
10
13
  if (flow) return flow === "edit";
11
14
  return !!(editingRule || editingVariants && editingVariants.length > 0);
12
15
  };
16
+ const seedHostFormValues = (schema, input) => {
17
+ var _a, _b, _c, _d, _e, _f;
18
+ if (!input || Object.keys(input).length === 0) return;
19
+ const globalValues = {};
20
+ const variantValues = {};
21
+ const learningMetadata = {
22
+ ...(_b = (_a = input.learningMetadata) != null ? _a : input.learning_metadata) != null ? _b : {}
23
+ };
24
+ const metadataValues = (_c = learningMetadata.properties) != null ? _c : learningMetadata;
25
+ const hasValue = (source, key) => Object.prototype.hasOwnProperty.call(source, key);
26
+ const normalizeFieldKey = (key) => key.replace(/[^a-z0-9]/gi, "").toLowerCase();
27
+ const unwrapValue = (value) => value && typeof value === "object" && !Array.isArray(value) && hasValue(value, "value") ? value.value : value;
28
+ const traverse = (properties = {}, inVariant = false) => {
29
+ Object.entries(properties).forEach(([propertyKey, node]) => {
30
+ var _a2, _b2, _c2, _d2;
31
+ const dataKey = node == null ? void 0 : node.data_key;
32
+ const cleanKey = typeof dataKey === "string" ? dataKey.replace(/^global\./, "") : propertyKey;
33
+ const sources = [input, metadataValues];
34
+ const aliases = {
35
+ rule_title: ["title", "ruleTitle"],
36
+ rule_description: ["description", "ruleDescription"],
37
+ wta: ["whenToApply", "when_to_apply"],
38
+ wnta: ["whenNotToApply", "when_not_to_apply"],
39
+ instruction_prompt: ["instructionPrompt"]
40
+ };
41
+ const candidateKeys = [cleanKey, dataKey, propertyKey, ...(_a2 = aliases[propertyKey]) != null ? _a2 : []].filter(Boolean);
42
+ let matchedKey;
43
+ let matchedSource;
44
+ for (const source of sources) {
45
+ matchedKey = candidateKeys.find((key) => hasValue(source, key));
46
+ if (!matchedKey) {
47
+ const normalizedCandidates = new Set(candidateKeys.map(normalizeFieldKey));
48
+ matchedKey = Object.keys(source).find((key) => normalizedCandidates.has(normalizeFieldKey(key)));
49
+ }
50
+ if (matchedKey) {
51
+ matchedSource = source;
52
+ break;
53
+ }
54
+ }
55
+ if (matchedKey) {
56
+ let value = unwrapValue(matchedSource[matchedKey]);
57
+ if ((node == null ? void 0 : node.bpa_ui_component) === "ConditionSection" && Array.isArray(value)) {
58
+ value = value.map((item) => typeof item === "string" ? item : item == null ? void 0 : item.text).filter((item) => typeof item === "string" && item.trim()).join(" OR ");
59
+ }
60
+ const isVariantField = inVariant && !String(dataKey != null ? dataKey : "").startsWith("global.");
61
+ if (isVariantField) {
62
+ (_b2 = variantValues.tier_1) != null ? _b2 : variantValues.tier_1 = {};
63
+ (_d2 = (_c2 = variantValues.tier_1)[0]) != null ? _d2 : _c2[0] = {};
64
+ variantValues.tier_1[0][cleanKey] = value;
65
+ } else {
66
+ globalValues[cleanKey] = value;
67
+ }
68
+ if ((node == null ? void 0 : node.core_field) === false) {
69
+ learningMetadata[propertyKey] = value;
70
+ }
71
+ if (propertyKey === "instruction_prompt" || cleanKey === "instructionPrompt") {
72
+ learningMetadata.instruction_prompt = value;
73
+ }
74
+ }
75
+ if (node == null ? void 0 : node.properties) {
76
+ const isVariantWrapper = (node == null ? void 0 : node.is_repeatable_variant) === true || (node == null ? void 0 : node.bpa_ui_component) === "VariantListWrapper";
77
+ traverse(node.properties, inVariant || isVariantWrapper);
78
+ }
79
+ });
80
+ };
81
+ const schemaRoot = (_d = schema == null ? void 0 : schema.teachMe) != null ? _d : schema;
82
+ if (schemaRoot == null ? void 0 : schemaRoot.properties) {
83
+ traverse(schemaRoot.properties);
84
+ } else {
85
+ Object.entries(input).forEach(([key, value]) => {
86
+ if (key !== "learningMetadata" && key !== "learning_metadata") globalValues[key] = value;
87
+ });
88
+ }
89
+ const explicitMetadata = (_e = input.learningMetadata) != null ? _e : input.learning_metadata;
90
+ if (explicitMetadata && typeof explicitMetadata === "object") {
91
+ Object.assign(learningMetadata, (_f = explicitMetadata.properties) != null ? _f : explicitMetadata);
92
+ }
93
+ if (hasValue(input, "instructionPrompt")) {
94
+ learningMetadata.instruction_prompt = input.instructionPrompt;
95
+ }
96
+ useDynamicFormStore.useDynamicFormStore.getState().initializeStore(globalValues, variantValues);
97
+ if (Object.keys(learningMetadata).length > 0) {
98
+ useLearningTemplateStore.useLearningTemplateStore.getState().setLearningMetadata({
99
+ ...useLearningTemplateStore.useLearningTemplateStore.getState().learningMetadata,
100
+ ...learningMetadata
101
+ });
102
+ }
103
+ };
13
104
 
14
105
  exports.resolveIsEditMode = resolveIsEditMode;
106
+ exports.seedHostFormValues = seedHostFormValues;
15
107
  //# sourceMappingURL=learningFlow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"learningFlow.js","sources":["../../../../../src/features/LearningManagement/utils/learningFlow.ts"],"sourcesContent":["import { RuleDefinition, RuleVariant } from '../types';\n\n/**\n * Explicit source of truth for which Teach Me flow the modal is in.\n *\n * - `\"create\"` → Create/Add UI, ALWAYS, regardless of whether the RHS has\n * pre-populated variant data (e.g. a draft variant seeded into `editingVariants`).\n * - `\"edit\"` → Edit UI for an existing rule/variant.\n *\n * Decoupling the flow from the mere presence of `editingVariants` is what lets a\n * draft variant be populated into the RHS while the form still behaves as a new\n * learning. See RuleContent's `handleEditVariant` for where a draft click sets\n * `flow = \"create\"`.\n */\nexport type InstantLearningFlow = 'create' | 'edit';\n\nexport interface ResolveIsEditModeArgs {\n /** Explicit flow. When provided it is the sole source of truth. */\n flow?: InstantLearningFlow | null;\n editingRule?: RuleDefinition | null;\n editingVariants?: RuleVariant[] | null;\n}\n\n/**\n * Single source of truth for \"is the modal in edit mode?\".\n *\n * When an explicit `flow` is provided it wins outright — so `flow === \"create\"`\n * always means Create/Add even when `editingVariants` is populated. When `flow`\n * is absent we fall back to the legacy heuristic (`editingRule || editingVariants`)\n * so existing callers that don't yet pass `flow` keep their exact behavior.\n */\nexport const resolveIsEditMode = ({\n flow,\n editingRule,\n editingVariants,\n}: ResolveIsEditModeArgs): boolean => {\n if (flow) return flow === 'edit';\n return !!(editingRule || (editingVariants && editingVariants.length > 0));\n};\n"],"names":[],"mappings":";;;;AA+BO,MAAM,oBAAoB,CAAC;AAAA,EAChC,IAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AACF,CAAsC,KAAA;AACpC,EAAI,IAAA,IAAA,SAAa,IAAS,KAAA,MAAA,CAAA;AAC1B,EAAA,OAAO,CAAC,EAAE,WAAgB,IAAA,eAAA,IAAmB,gBAAgB,MAAS,GAAA,CAAA,CAAA,CAAA;AACxE;;;;"}
1
+ {"version":3,"file":"learningFlow.js","sources":["../../../../../src/features/LearningManagement/utils/learningFlow.ts"],"sourcesContent":["import { useDynamicFormStore } from '../../../schema-driven/store/useDynamicFormStore';\nimport { useLearningTemplateStore } from '../store/useLearningTemplateStore';\nimport { RuleDefinition, RuleVariant } from '../types';\n\n/**\n * Explicit source of truth for which Teach Me flow the modal is in.\n *\n * - `\"create\"` → Create/Add UI, ALWAYS, regardless of whether the RHS has\n * pre-populated variant data (e.g. a draft variant seeded into `editingVariants`).\n * - `\"edit\"` → Edit UI for an existing rule/variant.\n *\n * Decoupling the flow from the mere presence of `editingVariants` is what lets a\n * draft variant be populated into the RHS while the form still behaves as a new\n * learning. See RuleContent's `handleEditVariant` for where a draft click sets\n * `flow = \"create\"`.\n */\nexport type InstantLearningFlow = 'create' | 'edit';\n\nexport interface ResolveIsEditModeArgs {\n /** Explicit flow. When provided it is the sole source of truth. */\n flow?: InstantLearningFlow | null;\n editingRule?: RuleDefinition | null;\n editingVariants?: RuleVariant[] | null;\n}\n\n/**\n * Single source of truth for \"is the modal in edit mode?\".\n *\n * When an explicit `flow` is provided it wins outright — so `flow === \"create\"`\n * always means Create/Add even when `editingVariants` is populated. When `flow`\n * is absent we fall back to the legacy heuristic (`editingRule || editingVariants`)\n * so existing callers that don't yet pass `flow` keep their exact behavior.\n */\n\nexport const resolveIsEditMode = ({\n flow,\n editingRule,\n editingVariants,\n}: ResolveIsEditModeArgs): boolean => {\n if (flow) return flow === 'edit';\n return !!(editingRule || (editingVariants && editingVariants.length > 0));\n};\n\n\n/** Seed host-provided values into both the schema-driven RHS store and legacy\n * learningMetadata store. Form values can be keyed by data_key or schema\n * property name; variant fields land in the first create variant. */\nexport const seedHostFormValues = (schema: any, input: Record<string, any>) => {\n if (!input || Object.keys(input).length === 0) return;\n\n const globalValues: Record<string, any> = {};\n const variantValues: Record<string, Record<number, Record<string, any>>> = {};\n const learningMetadata: Record<string, any> = {\n ...(input.learningMetadata ?? input.learning_metadata ?? {}),\n };\n const metadataValues = learningMetadata.properties ?? learningMetadata;\n const hasValue = (source: Record<string, any>, key: string) =>\n Object.prototype.hasOwnProperty.call(source, key);\n const normalizeFieldKey = (key: string) => key.replace(/[^a-z0-9]/gi, '').toLowerCase();\n const unwrapValue = (value: any) =>\n value && typeof value === 'object' && !Array.isArray(value) && hasValue(value, 'value')\n ? value.value\n : value;\n\n const traverse = (properties: Record<string, any> = {}, inVariant = false) => {\n Object.entries(properties).forEach(([propertyKey, node]) => {\n const dataKey = node?.data_key;\n const cleanKey = typeof dataKey === 'string' ? dataKey.replace(/^global\\./, '') : propertyKey;\n const sources = [input, metadataValues];\n const aliases: Record<string, string[]> = {\n rule_title: ['title', 'ruleTitle'],\n rule_description: ['description', 'ruleDescription'],\n wta: ['whenToApply', 'when_to_apply'],\n wnta: ['whenNotToApply', 'when_not_to_apply'],\n instruction_prompt: ['instructionPrompt'],\n };\n const candidateKeys = [cleanKey, dataKey, propertyKey, ...(aliases[propertyKey] ?? [])]\n .filter(Boolean) as string[];\n let matchedKey: string | undefined;\n let matchedSource: Record<string, any> | undefined;\n for (const source of sources) {\n matchedKey = candidateKeys.find((key) => hasValue(source, key));\n if (!matchedKey) {\n const normalizedCandidates = new Set(candidateKeys.map(normalizeFieldKey));\n matchedKey = Object.keys(source).find((key) => normalizedCandidates.has(normalizeFieldKey(key)));\n }\n if (matchedKey) {\n matchedSource = source;\n break;\n }\n }\n\n if (matchedKey) {\n let value = unwrapValue(matchedSource![matchedKey]);\n // ConditionSectionField displays conditions by splitting an OR-delimited\n // string. Accept host arrays too, so common formValues arrays render.\n if (node?.bpa_ui_component === 'ConditionSection' && Array.isArray(value)) {\n value = value\n .map((item: any) => typeof item === 'string' ? item : item?.text)\n .filter((item: any) => typeof item === 'string' && item.trim())\n .join(' OR ');\n }\n const isVariantField = inVariant && !String(dataKey ?? '').startsWith('global.');\n if (isVariantField) {\n variantValues.tier_1 ??= {};\n variantValues.tier_1[0] ??= {};\n variantValues.tier_1[0][cleanKey] = value;\n } else {\n globalValues[cleanKey] = value;\n }\n\n if (node?.core_field === false) {\n learningMetadata[propertyKey] = value;\n }\n if (propertyKey === 'instruction_prompt' || cleanKey === 'instructionPrompt') {\n learningMetadata.instruction_prompt = value;\n }\n }\n\n if (node?.properties) {\n const isVariantWrapper =\n node?.is_repeatable_variant === true || node?.bpa_ui_component === 'VariantListWrapper';\n traverse(node.properties, inVariant || isVariantWrapper);\n }\n });\n };\n\n const schemaRoot = schema?.teachMe ?? schema;\n if (schemaRoot?.properties) {\n traverse(schemaRoot.properties);\n } else {\n Object.entries(input).forEach(([key, value]) => {\n if (key !== 'learningMetadata' && key !== 'learning_metadata') globalValues[key] = value;\n });\n }\n\n // Preserve metadata supplied in its API shape while also accepting flat\n // property values from formValues.\n const explicitMetadata = input.learningMetadata ?? input.learning_metadata;\n if (explicitMetadata && typeof explicitMetadata === 'object') {\n Object.assign(learningMetadata, explicitMetadata.properties ?? explicitMetadata);\n }\n if (hasValue(input, 'instructionPrompt')) {\n learningMetadata.instruction_prompt = input.instructionPrompt;\n }\n\n useDynamicFormStore.getState().initializeStore(globalValues, variantValues);\n if (Object.keys(learningMetadata).length > 0) {\n useLearningTemplateStore.getState().setLearningMetadata({\n ...useLearningTemplateStore.getState().learningMetadata,\n ...learningMetadata,\n });\n }\n};"],"names":["_a","_b","_c","_d","useDynamicFormStore","useLearningTemplateStore"],"mappings":";;;;;;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,GACzB,MAAA;AACL,IAAO,MAAA,CAAA,OAAA,CAAQ,KAAK,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAM,KAAA;AAC9C,MAAA,IAAI,QAAQ,kBAAsB,IAAA,GAAA,KAAQ,mBAAqB,EAAA,YAAA,CAAa,GAAG,CAAI,GAAA,KAAA,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GACH;AAIA,EAAA,MAAM,gBAAmB,GAAA,CAAA,EAAA,GAAA,KAAA,CAAM,gBAAN,KAAA,IAAA,GAAA,EAAA,GAA0B,KAAM,CAAA,iBAAA,CAAA;AACzD,EAAI,IAAA,gBAAA,IAAoB,OAAO,gBAAA,KAAqB,QAAU,EAAA;AAC5D,IAAA,MAAA,CAAO,MAAO,CAAA,gBAAA,EAAA,CAAkB,EAAiB,GAAA,gBAAA,CAAA,UAAA,KAAjB,YAA+B,gBAAgB,CAAA,CAAA;AAAA,GACjF;AACA,EAAI,IAAA,QAAA,CAAS,KAAO,EAAA,mBAAmB,CAAG,EAAA;AACxC,IAAA,gBAAA,CAAiB,qBAAqB,KAAM,CAAA,iBAAA,CAAA;AAAA,GAC9C;AAEA,EAAAE,uCAAA,CAAoB,QAAS,EAAA,CAAE,eAAgB,CAAA,YAAA,EAAc,aAAa,CAAA,CAAA;AAC1E,EAAA,IAAI,MAAO,CAAA,IAAA,CAAK,gBAAgB,CAAA,CAAE,SAAS,CAAG,EAAA;AAC5C,IAAyBC,iDAAA,CAAA,QAAA,GAAW,mBAAoB,CAAA;AAAA,MACtD,GAAGA,iDAAyB,CAAA,QAAA,EAAW,CAAA,gBAAA;AAAA,MACvC,GAAG,gBAAA;AAAA,KACJ,CAAA,CAAA;AAAA,GACH;AACF;;;;;"}
@@ -82,6 +82,7 @@ function FileUploadField(props) {
82
82
  const [duplicateWarning, setDuplicateWarning] = React.useState(null);
83
83
  const [formatWarning, setFormatWarning] = React.useState(null);
84
84
  const [sizeWarning, setSizeWarning] = React.useState(null);
85
+ const [emptyFileWarning, setEmptyFileWarning] = React.useState(null);
85
86
  const [limitWarning, setLimitWarning] = React.useState(null);
86
87
  const [deleteWarning, setDeleteWarning] = React.useState(null);
87
88
  const [deletingFileIds, setDeletingFileIds] = React.useState(() => /* @__PURE__ */ new Set());
@@ -264,6 +265,7 @@ function FileUploadField(props) {
264
265
  setDuplicateWarning(null);
265
266
  setFormatWarning(null);
266
267
  setSizeWarning(null);
268
+ setEmptyFileWarning(null);
267
269
  setLimitWarning(null);
268
270
  setDeleteWarning(null);
269
271
  const remainingSlots = isFinite(effectiveMaxUploads) ? Math.max(0, effectiveMaxUploads - filesList.length) : Infinity;
@@ -289,8 +291,11 @@ function FileUploadField(props) {
289
291
  const validFiles = [];
290
292
  const invalidFiles = [];
291
293
  const oversizedFiles = [];
294
+ const emptyFiles = [];
292
295
  for (const file of filesToProcess) {
293
- if (!fileUploadService.isFileAccepted(file, normalizedAccept)) {
296
+ if (file.size === 0) {
297
+ emptyFiles.push(file);
298
+ } else if (!fileUploadService.isFileAccepted(file, normalizedAccept)) {
294
299
  invalidFiles.push(file);
295
300
  } else if (effectiveMaxFileSizeBytes !== null && file.size > effectiveMaxFileSizeBytes) {
296
301
  oversizedFiles.push(file);
@@ -308,14 +313,23 @@ function FileUploadField(props) {
308
313
  const message = oversizedFiles.length === 1 ? `File "${oversizedNames}" exceeds the ${maxFileSizeLabel} per-file size limit.` : `Files "${oversizedNames}" exceed the ${maxFileSizeLabel} per-file size limit.`;
309
314
  setSizeWarning(message);
310
315
  }
316
+ if (emptyFiles.length > 0) {
317
+ const emptyNames = emptyFiles.map((file) => file.name).join(", ");
318
+ const message = emptyFiles.length === 1 ? `File "${emptyNames}" is empty and cannot be uploaded.` : `Files "${emptyNames}" are empty and cannot be uploaded.`;
319
+ setEmptyFileWarning(message);
320
+ }
311
321
  if (validFiles.length === 0) {
312
322
  if (fileInputRef.current) {
313
323
  fileInputRef.current.value = "";
314
324
  }
315
325
  return;
316
326
  }
327
+ const uploadTimestamp = Date.now();
328
+ const filesForUpload = validFiles.map(
329
+ (file, index) => fileUploadService.createTimestampedFile(file, uploadTimestamp, index)
330
+ );
317
331
  setIsUploading(true);
318
- const optimisticItems = validFiles.map((file, i) => {
332
+ const optimisticItems = filesForUpload.map((file, i) => {
319
333
  const isImg = fileUploadService.isImageFile(file.name, file.type);
320
334
  let previewBlobUrl = void 0;
321
335
  try {
@@ -340,7 +354,7 @@ function FileUploadField(props) {
340
354
  try {
341
355
  const result = await fileUploadService.uploadFilesBatch({
342
356
  projectId: resolvedProjectId || "",
343
- files: validFiles,
357
+ files: filesForUpload,
344
358
  token: resolvedToken,
345
359
  artifactUserName: resolvedUserName,
346
360
  artifactUserEmail: resolvedUserEmail,
@@ -487,6 +501,7 @@ function FileUploadField(props) {
487
501
  setDuplicateWarning(null);
488
502
  setFormatWarning(null);
489
503
  setSizeWarning(null);
504
+ setEmptyFileWarning(null);
490
505
  setLimitWarning(null);
491
506
  setDeleteWarning(null);
492
507
  if (fileInputRef.current) {
@@ -536,6 +551,7 @@ function FileUploadField(props) {
536
551
  setDuplicateWarning(null);
537
552
  setFormatWarning(null);
538
553
  setSizeWarning(null);
554
+ setEmptyFileWarning(null);
539
555
  setLimitWarning(null);
540
556
  setDeleteWarning(null);
541
557
  inlineSnapshotRef.current = JSON.parse(JSON.stringify(filesList));
@@ -549,6 +565,7 @@ function FileUploadField(props) {
549
565
  setDuplicateWarning(null);
550
566
  setFormatWarning(null);
551
567
  setSizeWarning(null);
568
+ setEmptyFileWarning(null);
552
569
  setLimitWarning(null);
553
570
  setDeleteWarning(null);
554
571
  setActiveEditId == null ? void 0 : setActiveEditId(null);
@@ -685,10 +702,10 @@ function FileUploadField(props) {
685
702
  onChange: handleNativeFileChange
686
703
  }
687
704
  ),
688
- (duplicateWarning || formatWarning || sizeWarning || limitWarning || deleteWarning) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: FileUploadField_module["default"].warningBanner, role: "alert", children: [
705
+ (duplicateWarning || formatWarning || sizeWarning || emptyFileWarning || limitWarning || deleteWarning) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: FileUploadField_module["default"].warningBanner, role: "alert", children: [
689
706
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: FileUploadField_module["default"].warningContent, children: [
690
707
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 16, color: "#D97706", style: { flexShrink: 0 } }),
691
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: FileUploadField_module["default"].warningText, children: [duplicateWarning, formatWarning, sizeWarning, limitWarning, deleteWarning].filter(Boolean).join(" ") })
708
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: FileUploadField_module["default"].warningText, children: [duplicateWarning, formatWarning, sizeWarning, emptyFileWarning, limitWarning, deleteWarning].filter(Boolean).join(" ") })
692
709
  ] }),
693
710
  /* @__PURE__ */ jsxRuntime.jsx(
694
711
  "button",
@@ -698,6 +715,7 @@ function FileUploadField(props) {
698
715
  setDuplicateWarning(null);
699
716
  setFormatWarning(null);
700
717
  setSizeWarning(null);
718
+ setEmptyFileWarning(null);
701
719
  setLimitWarning(null);
702
720
  setDeleteWarning(null);
703
721
  },