formanitor 0.0.16 → 0.0.17
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/index.cjs +51 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +51 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -338,7 +338,7 @@ var FormStore = class {
|
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
340
|
this.config.onDraftChange?.(payload);
|
|
341
|
-
},
|
|
341
|
+
}, 5e3);
|
|
342
342
|
}
|
|
343
343
|
async save() {
|
|
344
344
|
const payload = {
|
|
@@ -3012,16 +3012,6 @@ function mapToInvestigation(result) {
|
|
|
3012
3012
|
fromAI: false
|
|
3013
3013
|
};
|
|
3014
3014
|
}
|
|
3015
|
-
function mapFrequentItemToInvestigation(item) {
|
|
3016
|
-
return {
|
|
3017
|
-
id: String(item.id),
|
|
3018
|
-
name: item.name,
|
|
3019
|
-
code: item.code ?? void 0,
|
|
3020
|
-
label: item.name,
|
|
3021
|
-
is_custom: false,
|
|
3022
|
-
fromAI: false
|
|
3023
|
-
};
|
|
3024
|
-
}
|
|
3025
3015
|
var AddInvestigationField = ({
|
|
3026
3016
|
label = "Investigations",
|
|
3027
3017
|
value,
|
|
@@ -3035,6 +3025,7 @@ var AddInvestigationField = ({
|
|
|
3035
3025
|
const [results, setResults] = useState([]);
|
|
3036
3026
|
const [loading, setLoading] = useState(false);
|
|
3037
3027
|
const [addingId, setAddingId] = useState(null);
|
|
3028
|
+
const [addingFrequentId, setAddingFrequentId] = useState(null);
|
|
3038
3029
|
const debounceRef = useRef(null);
|
|
3039
3030
|
const valueRef = useRef([]);
|
|
3040
3031
|
const searchInputRef = useRef(null);
|
|
@@ -3045,6 +3036,7 @@ var AddInvestigationField = ({
|
|
|
3045
3036
|
setQuery("");
|
|
3046
3037
|
setResults([]);
|
|
3047
3038
|
setAddingId(null);
|
|
3039
|
+
setAddingFrequentId(null);
|
|
3048
3040
|
}
|
|
3049
3041
|
}, [open]);
|
|
3050
3042
|
function handleQueryChange(q) {
|
|
@@ -3090,12 +3082,24 @@ var AddInvestigationField = ({
|
|
|
3090
3082
|
addInvestigation(result);
|
|
3091
3083
|
}
|
|
3092
3084
|
}
|
|
3093
|
-
function handleFrequentItemToggle(item) {
|
|
3085
|
+
async function handleFrequentItemToggle(item) {
|
|
3094
3086
|
const id = String(item.id);
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3087
|
+
const addedById = addedIds.has(id);
|
|
3088
|
+
const addedByName = value.some((inv) => inv.name === item.name);
|
|
3089
|
+
if (addedById || addedByName) {
|
|
3090
|
+
if (addedById) removeInvestigation(id);
|
|
3091
|
+
else onChange(value.filter((inv) => inv.name !== item.name));
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
setAddingFrequentId(id);
|
|
3095
|
+
try {
|
|
3096
|
+
const searchResults = await onSearch(item.name);
|
|
3097
|
+
const first = searchResults?.[0];
|
|
3098
|
+
if (first && !valueRef.current.some((inv) => inv.id === first.id)) {
|
|
3099
|
+
onChange([...valueRef.current, mapToInvestigation(first)]);
|
|
3100
|
+
}
|
|
3101
|
+
} finally {
|
|
3102
|
+
setAddingFrequentId(null);
|
|
3099
3103
|
}
|
|
3100
3104
|
}
|
|
3101
3105
|
const recentlyUsedChips = recentlyUsed.map((r) => {
|
|
@@ -3120,19 +3124,22 @@ var AddInvestigationField = ({
|
|
|
3120
3124
|
const limitedFrequentItems = frequentItems.slice(0, 25);
|
|
3121
3125
|
const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
|
|
3122
3126
|
const id = String(item.id);
|
|
3123
|
-
const isAdded =
|
|
3127
|
+
const isAdded = value.some((inv) => inv.id === id) || value.some((inv) => inv.name === item.name);
|
|
3128
|
+
const isAdding = addingFrequentId === id;
|
|
3124
3129
|
return /* @__PURE__ */ jsxs(
|
|
3125
3130
|
"button",
|
|
3126
3131
|
{
|
|
3127
3132
|
type: "button",
|
|
3133
|
+
disabled: isAdding,
|
|
3128
3134
|
onClick: () => handleFrequentItemToggle(item),
|
|
3129
3135
|
className: cn(
|
|
3130
3136
|
"rounded-full border text-xs px-3 py-1 transition-colors",
|
|
3131
|
-
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50"
|
|
3137
|
+
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50",
|
|
3138
|
+
isAdding && "opacity-70 pointer-events-none"
|
|
3132
3139
|
),
|
|
3133
3140
|
children: [
|
|
3134
3141
|
isAdded && /* @__PURE__ */ jsx("span", { className: "mr-1", children: "\u2713" }),
|
|
3135
|
-
item.name
|
|
3142
|
+
isAdding ? "\u2026" : item.name
|
|
3136
3143
|
]
|
|
3137
3144
|
},
|
|
3138
3145
|
item.id
|
|
@@ -3238,16 +3245,6 @@ function mapToProcedure(result) {
|
|
|
3238
3245
|
fromAI: false
|
|
3239
3246
|
};
|
|
3240
3247
|
}
|
|
3241
|
-
function mapFrequentItemToProcedure(item) {
|
|
3242
|
-
return {
|
|
3243
|
-
id: String(item.id),
|
|
3244
|
-
name: item.name,
|
|
3245
|
-
code: item.code ?? void 0,
|
|
3246
|
-
label: item.name,
|
|
3247
|
-
is_custom: false,
|
|
3248
|
-
fromAI: false
|
|
3249
|
-
};
|
|
3250
|
-
}
|
|
3251
3248
|
var AddProcedureField = ({
|
|
3252
3249
|
label = "Procedures",
|
|
3253
3250
|
value,
|
|
@@ -3261,6 +3258,7 @@ var AddProcedureField = ({
|
|
|
3261
3258
|
const [results, setResults] = useState([]);
|
|
3262
3259
|
const [loading, setLoading] = useState(false);
|
|
3263
3260
|
const [addingId, setAddingId] = useState(null);
|
|
3261
|
+
const [addingFrequentId, setAddingFrequentId] = useState(null);
|
|
3264
3262
|
const debounceRef = useRef(null);
|
|
3265
3263
|
const valueRef = useRef([]);
|
|
3266
3264
|
const searchInputRef = useRef(null);
|
|
@@ -3271,6 +3269,7 @@ var AddProcedureField = ({
|
|
|
3271
3269
|
setQuery("");
|
|
3272
3270
|
setResults([]);
|
|
3273
3271
|
setAddingId(null);
|
|
3272
|
+
setAddingFrequentId(null);
|
|
3274
3273
|
}
|
|
3275
3274
|
}, [open]);
|
|
3276
3275
|
function handleQueryChange(q) {
|
|
@@ -3316,12 +3315,24 @@ var AddProcedureField = ({
|
|
|
3316
3315
|
addProcedure(result);
|
|
3317
3316
|
}
|
|
3318
3317
|
}
|
|
3319
|
-
function handleFrequentItemToggle(item) {
|
|
3318
|
+
async function handleFrequentItemToggle(item) {
|
|
3320
3319
|
const id = String(item.id);
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3320
|
+
const addedById = addedIds.has(id);
|
|
3321
|
+
const addedByName = value.some((proc) => proc.name === item.name);
|
|
3322
|
+
if (addedById || addedByName) {
|
|
3323
|
+
if (addedById) removeProcedure(id);
|
|
3324
|
+
else onChange(value.filter((proc) => proc.name !== item.name));
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
setAddingFrequentId(id);
|
|
3328
|
+
try {
|
|
3329
|
+
const searchResults = await onSearch(item.name);
|
|
3330
|
+
const first = searchResults?.[0];
|
|
3331
|
+
if (first && !valueRef.current.some((proc) => proc.id === first.id)) {
|
|
3332
|
+
onChange([...valueRef.current, mapToProcedure(first)]);
|
|
3333
|
+
}
|
|
3334
|
+
} finally {
|
|
3335
|
+
setAddingFrequentId(null);
|
|
3325
3336
|
}
|
|
3326
3337
|
}
|
|
3327
3338
|
const recentlyUsedChips = recentlyUsed.map((r) => {
|
|
@@ -3346,19 +3357,22 @@ var AddProcedureField = ({
|
|
|
3346
3357
|
const limitedFrequentItems = frequentItems.slice(0, 25);
|
|
3347
3358
|
const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
|
|
3348
3359
|
const id = String(item.id);
|
|
3349
|
-
const isAdded =
|
|
3360
|
+
const isAdded = value.some((proc) => proc.id === id) || value.some((proc) => proc.name === item.name);
|
|
3361
|
+
const isAdding = addingFrequentId === id;
|
|
3350
3362
|
return /* @__PURE__ */ jsxs(
|
|
3351
3363
|
"button",
|
|
3352
3364
|
{
|
|
3353
3365
|
type: "button",
|
|
3366
|
+
disabled: isAdding,
|
|
3354
3367
|
onClick: () => handleFrequentItemToggle(item),
|
|
3355
3368
|
className: cn(
|
|
3356
3369
|
"rounded-full border text-xs px-3 py-1 transition-colors",
|
|
3357
|
-
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50"
|
|
3370
|
+
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50",
|
|
3371
|
+
isAdding && "opacity-70 pointer-events-none"
|
|
3358
3372
|
),
|
|
3359
3373
|
children: [
|
|
3360
3374
|
isAdded && /* @__PURE__ */ jsx("span", { className: "mr-1", children: "\u2713" }),
|
|
3361
|
-
item.name
|
|
3375
|
+
isAdding ? "\u2026" : item.name
|
|
3362
3376
|
]
|
|
3363
3377
|
},
|
|
3364
3378
|
item.id
|