formanitor 0.0.26 → 0.0.27
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 +21 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3325,8 +3325,9 @@ var AddInvestigationField = ({
|
|
|
3325
3325
|
const debounceRef = useRef(null);
|
|
3326
3326
|
const valueRef = useRef([]);
|
|
3327
3327
|
const searchInputRef = useRef(null);
|
|
3328
|
-
|
|
3329
|
-
|
|
3328
|
+
const safeValue = Array.isArray(value) ? value : [];
|
|
3329
|
+
valueRef.current = safeValue;
|
|
3330
|
+
const addedIds = new Set(safeValue.map((inv) => inv.id));
|
|
3330
3331
|
useEffect(() => {
|
|
3331
3332
|
if (!open) {
|
|
3332
3333
|
setQuery("");
|
|
@@ -3369,7 +3370,7 @@ var AddInvestigationField = ({
|
|
|
3369
3370
|
}, ADD_FEEDBACK_MS2);
|
|
3370
3371
|
}
|
|
3371
3372
|
function removeInvestigation(id) {
|
|
3372
|
-
onChange(
|
|
3373
|
+
onChange(safeValue.filter((inv) => inv.id !== id));
|
|
3373
3374
|
}
|
|
3374
3375
|
function handleRecentlyUsedToggle(result) {
|
|
3375
3376
|
if (addedIds.has(result.id)) {
|
|
@@ -3381,10 +3382,10 @@ var AddInvestigationField = ({
|
|
|
3381
3382
|
async function handleFrequentItemToggle(item) {
|
|
3382
3383
|
const id = String(item.id);
|
|
3383
3384
|
const addedById = addedIds.has(id);
|
|
3384
|
-
const addedByName =
|
|
3385
|
+
const addedByName = safeValue.some((inv) => inv.name === item.name);
|
|
3385
3386
|
if (addedById || addedByName) {
|
|
3386
3387
|
if (addedById) removeInvestigation(id);
|
|
3387
|
-
else onChange(
|
|
3388
|
+
else onChange(safeValue.filter((inv) => inv.name !== item.name));
|
|
3388
3389
|
return;
|
|
3389
3390
|
}
|
|
3390
3391
|
setAddingFrequentId(id);
|
|
@@ -3420,7 +3421,7 @@ var AddInvestigationField = ({
|
|
|
3420
3421
|
const limitedFrequentItems = frequentItems.slice(0, 25);
|
|
3421
3422
|
const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
|
|
3422
3423
|
const id = String(item.id);
|
|
3423
|
-
const isAdded =
|
|
3424
|
+
const isAdded = safeValue.some((inv) => inv.id === id) || safeValue.some((inv) => inv.name === item.name);
|
|
3424
3425
|
const isAdding = addingFrequentId === id;
|
|
3425
3426
|
return /* @__PURE__ */ jsxs(
|
|
3426
3427
|
"button",
|
|
@@ -3454,7 +3455,7 @@ var AddInvestigationField = ({
|
|
|
3454
3455
|
}
|
|
3455
3456
|
)
|
|
3456
3457
|
] }),
|
|
3457
|
-
|
|
3458
|
+
safeValue.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: safeValue.map((inv) => /* @__PURE__ */ jsxs(
|
|
3458
3459
|
"div",
|
|
3459
3460
|
{
|
|
3460
3461
|
className: "flex items-center justify-between px-3 py-2 bg-white hover:bg-gray-50",
|
|
@@ -3521,10 +3522,11 @@ var AddInvestigationWidget = ({ fieldId }) => {
|
|
|
3521
3522
|
const { value, setValue } = useField(fieldId);
|
|
3522
3523
|
const handlers = useFieldHandlers(fieldId);
|
|
3523
3524
|
const { investigations: frequentInvestigations } = useFrequentItems();
|
|
3525
|
+
const safeValue = Array.isArray(value) ? value : [];
|
|
3524
3526
|
return /* @__PURE__ */ jsx(
|
|
3525
3527
|
AddInvestigationField,
|
|
3526
3528
|
{
|
|
3527
|
-
value:
|
|
3529
|
+
value: safeValue,
|
|
3528
3530
|
onChange: setValue,
|
|
3529
3531
|
onSearch: handlers.onSearch,
|
|
3530
3532
|
recentlyUsed: handlers.recentlyUsed,
|
|
@@ -3561,9 +3563,10 @@ var AddProcedureField = ({
|
|
|
3561
3563
|
const debounceRef = useRef(null);
|
|
3562
3564
|
const valueRef = useRef([]);
|
|
3563
3565
|
const searchInputRef = useRef(null);
|
|
3564
|
-
|
|
3566
|
+
const safeValue = Array.isArray(value) ? value : [];
|
|
3567
|
+
valueRef.current = safeValue;
|
|
3565
3568
|
const addedIds = new Set(
|
|
3566
|
-
|
|
3569
|
+
safeValue.filter((proc) => !proc.is_custom).map((proc) => proc.id)
|
|
3567
3570
|
);
|
|
3568
3571
|
useEffect(() => {
|
|
3569
3572
|
if (!open) {
|
|
@@ -3607,10 +3610,10 @@ var AddProcedureField = ({
|
|
|
3607
3610
|
}, ADD_FEEDBACK_MS3);
|
|
3608
3611
|
}
|
|
3609
3612
|
function removeAt(index) {
|
|
3610
|
-
onChange(
|
|
3613
|
+
onChange(safeValue.filter((_, i) => i !== index));
|
|
3611
3614
|
}
|
|
3612
3615
|
function removeBySearchId(id) {
|
|
3613
|
-
onChange(
|
|
3616
|
+
onChange(safeValue.filter((proc) => proc.is_custom || proc.id !== id));
|
|
3614
3617
|
}
|
|
3615
3618
|
function handleAddCustom() {
|
|
3616
3619
|
const trimmed = query.trim();
|
|
@@ -3630,10 +3633,10 @@ var AddProcedureField = ({
|
|
|
3630
3633
|
async function handleFrequentItemToggle(item) {
|
|
3631
3634
|
const id = String(item.id);
|
|
3632
3635
|
const addedById = addedIds.has(id);
|
|
3633
|
-
const addedByName =
|
|
3636
|
+
const addedByName = safeValue.some((proc) => proc.name === item.name);
|
|
3634
3637
|
if (addedById || addedByName) {
|
|
3635
3638
|
if (addedById) removeBySearchId(id);
|
|
3636
|
-
else onChange(
|
|
3639
|
+
else onChange(safeValue.filter((proc) => proc.name !== item.name));
|
|
3637
3640
|
return;
|
|
3638
3641
|
}
|
|
3639
3642
|
setAddingFrequentId(id);
|
|
@@ -3669,7 +3672,7 @@ var AddProcedureField = ({
|
|
|
3669
3672
|
const limitedFrequentItems = frequentItems.slice(0, 25);
|
|
3670
3673
|
const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
|
|
3671
3674
|
const id = String(item.id);
|
|
3672
|
-
const isAdded =
|
|
3675
|
+
const isAdded = safeValue.some((proc) => !proc.is_custom && proc.id === id) || safeValue.some((proc) => proc.name === item.name);
|
|
3673
3676
|
const isAdding = addingFrequentId === id;
|
|
3674
3677
|
return /* @__PURE__ */ jsxs(
|
|
3675
3678
|
"button",
|
|
@@ -3703,7 +3706,7 @@ var AddProcedureField = ({
|
|
|
3703
3706
|
}
|
|
3704
3707
|
)
|
|
3705
3708
|
] }),
|
|
3706
|
-
|
|
3709
|
+
safeValue.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: safeValue.map((proc, index) => /* @__PURE__ */ jsxs(
|
|
3707
3710
|
"div",
|
|
3708
3711
|
{
|
|
3709
3712
|
className: "flex items-center justify-between px-3 py-2 bg-white hover:bg-gray-50",
|
|
@@ -3783,10 +3786,11 @@ var AddProcedureWidget = ({ fieldId }) => {
|
|
|
3783
3786
|
const { value, setValue } = useField(fieldId);
|
|
3784
3787
|
const handlers = useFieldHandlers(fieldId);
|
|
3785
3788
|
const { procedures: frequentProcedures } = useFrequentItems();
|
|
3789
|
+
const safeValue = Array.isArray(value) ? value : [];
|
|
3786
3790
|
return /* @__PURE__ */ jsx(
|
|
3787
3791
|
AddProcedureField,
|
|
3788
3792
|
{
|
|
3789
|
-
value:
|
|
3793
|
+
value: safeValue,
|
|
3790
3794
|
onChange: setValue,
|
|
3791
3795
|
onSearch: handlers.onSearch,
|
|
3792
3796
|
recentlyUsed: handlers.recentlyUsed,
|