@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.d.cts
CHANGED
|
@@ -704,8 +704,12 @@ type SearchablePickerProps = {
|
|
|
704
704
|
className?: string;
|
|
705
705
|
"aria-invalid"?: boolean;
|
|
706
706
|
onOpenChange?: (open: boolean) => void;
|
|
707
|
+
/** When set, a create action appears for a non-empty query (not while loading). Presentation only. */
|
|
708
|
+
onCreate?: (query: string) => void;
|
|
709
|
+
/** Label for the create action. Defaults to `Add "{query}"`. */
|
|
710
|
+
createLabel?: string;
|
|
707
711
|
};
|
|
708
|
-
declare function SearchablePicker({ value, selectedLabel, onChange, options, query, onQueryChange, loading, loadingMore, hasMore, onLoadMore, placeholder, emptyLabel, loadMoreLabel, clearLabel, searchPlaceholder, openLabel, disabled, allowClear, title, id, className, "aria-invalid": ariaInvalid, onOpenChange, }: SearchablePickerProps): react.JSX.Element;
|
|
712
|
+
declare function SearchablePicker({ value, selectedLabel, onChange, options, query, onQueryChange, loading, loadingMore, hasMore, onLoadMore, placeholder, emptyLabel, loadMoreLabel, clearLabel, searchPlaceholder, openLabel, disabled, allowClear, title, id, className, "aria-invalid": ariaInvalid, onOpenChange, onCreate, createLabel, }: SearchablePickerProps): react.JSX.Element;
|
|
709
713
|
|
|
710
714
|
type PaginatedComboboxItem = {
|
|
711
715
|
value: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -704,8 +704,12 @@ type SearchablePickerProps = {
|
|
|
704
704
|
className?: string;
|
|
705
705
|
"aria-invalid"?: boolean;
|
|
706
706
|
onOpenChange?: (open: boolean) => void;
|
|
707
|
+
/** When set, a create action appears for a non-empty query (not while loading). Presentation only. */
|
|
708
|
+
onCreate?: (query: string) => void;
|
|
709
|
+
/** Label for the create action. Defaults to `Add "{query}"`. */
|
|
710
|
+
createLabel?: string;
|
|
707
711
|
};
|
|
708
|
-
declare function SearchablePicker({ value, selectedLabel, onChange, options, query, onQueryChange, loading, loadingMore, hasMore, onLoadMore, placeholder, emptyLabel, loadMoreLabel, clearLabel, searchPlaceholder, openLabel, disabled, allowClear, title, id, className, "aria-invalid": ariaInvalid, onOpenChange, }: SearchablePickerProps): react.JSX.Element;
|
|
712
|
+
declare function SearchablePicker({ value, selectedLabel, onChange, options, query, onQueryChange, loading, loadingMore, hasMore, onLoadMore, placeholder, emptyLabel, loadMoreLabel, clearLabel, searchPlaceholder, openLabel, disabled, allowClear, title, id, className, "aria-invalid": ariaInvalid, onOpenChange, onCreate, createLabel, }: SearchablePickerProps): react.JSX.Element;
|
|
709
713
|
|
|
710
714
|
type PaginatedComboboxItem = {
|
|
711
715
|
value: string;
|
package/dist/index.js
CHANGED
|
@@ -3215,7 +3215,9 @@ function SearchablePicker({
|
|
|
3215
3215
|
id,
|
|
3216
3216
|
className,
|
|
3217
3217
|
"aria-invalid": ariaInvalid,
|
|
3218
|
-
onOpenChange
|
|
3218
|
+
onOpenChange,
|
|
3219
|
+
onCreate,
|
|
3220
|
+
createLabel
|
|
3219
3221
|
}) {
|
|
3220
3222
|
const isMdUp = useMediaQuery(MD_UP);
|
|
3221
3223
|
const dialogPortalContainer = useDialogPortalContainer();
|
|
@@ -3247,9 +3249,29 @@ function SearchablePicker({
|
|
|
3247
3249
|
onChange("");
|
|
3248
3250
|
onQueryChange("");
|
|
3249
3251
|
}
|
|
3252
|
+
const trimmedQuery = query.trim();
|
|
3253
|
+
const showCreate = Boolean(onCreate) && trimmedQuery !== "" && !loading;
|
|
3254
|
+
function handleCreate() {
|
|
3255
|
+
if (!onCreate || trimmedQuery === "") return;
|
|
3256
|
+
onCreate(trimmedQuery);
|
|
3257
|
+
setOpenState(false);
|
|
3258
|
+
}
|
|
3250
3259
|
const display = selectedLabel || selected?.label || "";
|
|
3251
3260
|
const sheetTitle = title || placeholder;
|
|
3252
3261
|
const searchLabel = searchPlaceholder || placeholder;
|
|
3262
|
+
const createActionLabel = createLabel ?? `Add "${trimmedQuery}"`;
|
|
3263
|
+
const createButton = showCreate ? /* @__PURE__ */ jsx(
|
|
3264
|
+
Button,
|
|
3265
|
+
{
|
|
3266
|
+
className: "w-full justify-start",
|
|
3267
|
+
disabled,
|
|
3268
|
+
size: "sm",
|
|
3269
|
+
type: "button",
|
|
3270
|
+
variant: "ghost",
|
|
3271
|
+
onClick: handleCreate,
|
|
3272
|
+
children: createActionLabel
|
|
3273
|
+
}
|
|
3274
|
+
) : null;
|
|
3253
3275
|
const loadMoreButton = hasMore && onLoadMore ? /* @__PURE__ */ jsx(
|
|
3254
3276
|
Button,
|
|
3255
3277
|
{
|
|
@@ -3371,7 +3393,10 @@ function SearchablePicker({
|
|
|
3371
3393
|
)
|
|
3372
3394
|
}
|
|
3373
3395
|
),
|
|
3374
|
-
loadMoreButton ? /* @__PURE__ */
|
|
3396
|
+
createButton || loadMoreButton ? /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-1", children: [
|
|
3397
|
+
createButton,
|
|
3398
|
+
loadMoreButton
|
|
3399
|
+
] }) : null
|
|
3375
3400
|
] })
|
|
3376
3401
|
]
|
|
3377
3402
|
}
|
|
@@ -3458,8 +3483,9 @@ function SearchablePicker({
|
|
|
3458
3483
|
onChange: (event) => onQueryChange(event.target.value)
|
|
3459
3484
|
}
|
|
3460
3485
|
) }),
|
|
3461
|
-
/* @__PURE__ */
|
|
3462
|
-
|
|
3486
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto px-2 pb-4", children: loading ? /* @__PURE__ */ jsx(LoadingRows, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3487
|
+
options.length === 0 && !showCreate ? /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: emptyLabel }) : null,
|
|
3488
|
+
options.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1 p-1", children: options.map((option) => {
|
|
3463
3489
|
const isSelected = option.id === value;
|
|
3464
3490
|
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
3465
3491
|
"button",
|
|
@@ -3485,9 +3511,10 @@ function SearchablePicker({
|
|
|
3485
3511
|
]
|
|
3486
3512
|
}
|
|
3487
3513
|
) }, option.id);
|
|
3488
|
-
}) }),
|
|
3514
|
+
}) }) : null,
|
|
3515
|
+
createButton,
|
|
3489
3516
|
loadMoreButton
|
|
3490
|
-
] })
|
|
3517
|
+
] }) })
|
|
3491
3518
|
] }) })
|
|
3492
3519
|
] });
|
|
3493
3520
|
}
|