@yenio-pld/blocks 1.2.0-rc.12 → 1.2.0-rc.13
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 +33 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3236,7 +3236,9 @@ function SearchablePicker({
|
|
|
3236
3236
|
id,
|
|
3237
3237
|
className,
|
|
3238
3238
|
"aria-invalid": ariaInvalid,
|
|
3239
|
-
onOpenChange
|
|
3239
|
+
onOpenChange,
|
|
3240
|
+
onCreate,
|
|
3241
|
+
createLabel
|
|
3240
3242
|
}) {
|
|
3241
3243
|
const isMdUp = useMediaQuery(MD_UP);
|
|
3242
3244
|
const dialogPortalContainer = dialog_js.useDialogPortalContainer();
|
|
@@ -3268,9 +3270,29 @@ function SearchablePicker({
|
|
|
3268
3270
|
onChange("");
|
|
3269
3271
|
onQueryChange("");
|
|
3270
3272
|
}
|
|
3273
|
+
const trimmedQuery = query.trim();
|
|
3274
|
+
const showCreate = Boolean(onCreate) && trimmedQuery !== "" && !loading;
|
|
3275
|
+
function handleCreate() {
|
|
3276
|
+
if (!onCreate || trimmedQuery === "") return;
|
|
3277
|
+
onCreate(trimmedQuery);
|
|
3278
|
+
setOpenState(false);
|
|
3279
|
+
}
|
|
3271
3280
|
const display = selectedLabel || selected?.label || "";
|
|
3272
3281
|
const sheetTitle = title || placeholder;
|
|
3273
3282
|
const searchLabel = searchPlaceholder || placeholder;
|
|
3283
|
+
const createActionLabel = createLabel ?? `Add "${trimmedQuery}"`;
|
|
3284
|
+
const createButton = showCreate ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3285
|
+
button_js.Button,
|
|
3286
|
+
{
|
|
3287
|
+
className: "w-full justify-start",
|
|
3288
|
+
disabled,
|
|
3289
|
+
size: "sm",
|
|
3290
|
+
type: "button",
|
|
3291
|
+
variant: "ghost",
|
|
3292
|
+
onClick: handleCreate,
|
|
3293
|
+
children: createActionLabel
|
|
3294
|
+
}
|
|
3295
|
+
) : null;
|
|
3274
3296
|
const loadMoreButton = hasMore && onLoadMore ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3275
3297
|
button_js.Button,
|
|
3276
3298
|
{
|
|
@@ -3392,7 +3414,10 @@ function SearchablePicker({
|
|
|
3392
3414
|
)
|
|
3393
3415
|
}
|
|
3394
3416
|
),
|
|
3395
|
-
loadMoreButton ? /* @__PURE__ */ jsxRuntime.
|
|
3417
|
+
createButton || loadMoreButton ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border p-1", children: [
|
|
3418
|
+
createButton,
|
|
3419
|
+
loadMoreButton
|
|
3420
|
+
] }) : null
|
|
3396
3421
|
] })
|
|
3397
3422
|
]
|
|
3398
3423
|
}
|
|
@@ -3479,8 +3504,9 @@ function SearchablePicker({
|
|
|
3479
3504
|
onChange: (event) => onQueryChange(event.target.value)
|
|
3480
3505
|
}
|
|
3481
3506
|
) }),
|
|
3482
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3483
|
-
|
|
3507
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto px-2 pb-4", children: loading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingRows, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3508
|
+
options.length === 0 && !showCreate ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: emptyLabel }) : null,
|
|
3509
|
+
options.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1 p-1", children: options.map((option) => {
|
|
3484
3510
|
const isSelected = option.id === value;
|
|
3485
3511
|
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3486
3512
|
"button",
|
|
@@ -3506,9 +3532,10 @@ function SearchablePicker({
|
|
|
3506
3532
|
]
|
|
3507
3533
|
}
|
|
3508
3534
|
) }, option.id);
|
|
3509
|
-
}) }),
|
|
3535
|
+
}) }) : null,
|
|
3536
|
+
createButton,
|
|
3510
3537
|
loadMoreButton
|
|
3511
|
-
] })
|
|
3538
|
+
] }) })
|
|
3512
3539
|
] }) })
|
|
3513
3540
|
] });
|
|
3514
3541
|
}
|