@yenio-pld/blocks 1.2.0-rc.20 → 1.2.0-rc.22

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.d.cts CHANGED
@@ -775,8 +775,14 @@ type SearchablePickerProps = {
775
775
  onCreate?: (query: string) => void;
776
776
  /** Label for the create action. Defaults to `Add "{query}"`. */
777
777
  createLabel?: string;
778
+ /**
779
+ * Always-visible footer action (e.g. "Add client"), independent of the
780
+ * query. Closes the picker before calling `onAction`.
781
+ */
782
+ actionLabel?: string;
783
+ onAction?: () => void;
778
784
  };
779
- 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;
785
+ 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, actionLabel, onAction, }: SearchablePickerProps): react.JSX.Element;
780
786
 
781
787
  type PaginatedComboboxItem = {
782
788
  value: string;
package/dist/index.d.ts CHANGED
@@ -775,8 +775,14 @@ type SearchablePickerProps = {
775
775
  onCreate?: (query: string) => void;
776
776
  /** Label for the create action. Defaults to `Add "{query}"`. */
777
777
  createLabel?: string;
778
+ /**
779
+ * Always-visible footer action (e.g. "Add client"), independent of the
780
+ * query. Closes the picker before calling `onAction`.
781
+ */
782
+ actionLabel?: string;
783
+ onAction?: () => void;
778
784
  };
779
- 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;
785
+ 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, actionLabel, onAction, }: SearchablePickerProps): react.JSX.Element;
780
786
 
781
787
  type PaginatedComboboxItem = {
782
788
  value: string;
package/dist/index.js CHANGED
@@ -3683,7 +3683,9 @@ function SearchablePicker({
3683
3683
  "aria-invalid": ariaInvalid,
3684
3684
  onOpenChange,
3685
3685
  onCreate,
3686
- createLabel
3686
+ createLabel,
3687
+ actionLabel,
3688
+ onAction
3687
3689
  }) {
3688
3690
  const isMdUp = useMediaQuery(MD_UP2);
3689
3691
  const dialogPortalContainer = useDialogPortalContainer();
@@ -3738,6 +3740,21 @@ function SearchablePicker({
3738
3740
  children: createActionLabel
3739
3741
  }
3740
3742
  ) : null;
3743
+ const actionButton = actionLabel && onAction ? /* @__PURE__ */ jsx(
3744
+ Button,
3745
+ {
3746
+ className: "w-full justify-start",
3747
+ disabled,
3748
+ size: "sm",
3749
+ type: "button",
3750
+ variant: "ghost",
3751
+ onClick: () => {
3752
+ setOpenState(false);
3753
+ onAction();
3754
+ },
3755
+ children: actionLabel
3756
+ }
3757
+ ) : null;
3741
3758
  const loadMoreButton = hasMore && onLoadMore ? /* @__PURE__ */ jsx(
3742
3759
  Button,
3743
3760
  {
@@ -3750,6 +3767,16 @@ function SearchablePicker({
3750
3767
  children: loadMoreLabel
3751
3768
  }
3752
3769
  ) : null;
3770
+ function renderFooter(includeQueryActions) {
3771
+ const queryCreate = includeQueryActions ? createButton : null;
3772
+ const queryLoadMore = includeQueryActions ? loadMoreButton : null;
3773
+ if (!queryCreate && !actionButton && !queryLoadMore) return null;
3774
+ return /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-1", children: [
3775
+ queryCreate,
3776
+ actionButton,
3777
+ queryLoadMore
3778
+ ] });
3779
+ }
3753
3780
  if (isMdUp) {
3754
3781
  return /* @__PURE__ */ jsx("div", { className: cn("relative w-full", className), children: /* @__PURE__ */ jsxs(
3755
3782
  Combobox.Root,
@@ -3836,8 +3863,8 @@ function SearchablePicker({
3836
3863
  }
3837
3864
  ) }),
3838
3865
  loading ? /* @__PURE__ */ jsx(LoadingRows, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
3839
- /* @__PURE__ */ jsx(Combobox.Empty, { className: "px-3 py-3 text-sm text-muted-foreground", children: emptyLabel }),
3840
- /* @__PURE__ */ jsx(
3866
+ /* @__PURE__ */ jsx(Combobox.Empty, { className: "text-sm text-muted-foreground", children: /* @__PURE__ */ jsx("span", { className: "block px-3 py-3", children: emptyLabel }) }),
3867
+ options.length > 0 ? /* @__PURE__ */ jsx(
3841
3868
  Combobox.List,
3842
3869
  {
3843
3870
  className: "max-h-60 overflow-y-auto p-1 outline-none",
@@ -3847,23 +3874,20 @@ function SearchablePicker({
3847
3874
  {
3848
3875
  value: item,
3849
3876
  className: cn(
3850
- "relative flex cursor-default items-center gap-2 rounded-md py-2 pr-2 pl-8 text-sm outline-none select-none",
3877
+ "relative flex cursor-default items-center gap-2 rounded-md px-2 py-2 text-sm outline-none select-none",
3851
3878
  "data-highlighted:bg-accent data-highlighted:text-accent-foreground"
3852
3879
  ),
3853
3880
  children: [
3854
- /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) }),
3855
- /* @__PURE__ */ jsx(OptionBody, { option: item })
3881
+ /* @__PURE__ */ jsx(OptionBody, { option: item }),
3882
+ /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) })
3856
3883
  ]
3857
3884
  },
3858
3885
  item.id
3859
3886
  )
3860
3887
  }
3861
- ),
3862
- createButton || loadMoreButton ? /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-1", children: [
3863
- createButton,
3864
- loadMoreButton
3865
- ] }) : null
3866
- ] })
3888
+ ) : null
3889
+ ] }),
3890
+ renderFooter(!loading)
3867
3891
  ]
3868
3892
  }
3869
3893
  )
@@ -3979,6 +4003,7 @@ function SearchablePicker({
3979
4003
  ) }, option.id);
3980
4004
  }) }) : null,
3981
4005
  createButton,
4006
+ actionButton,
3982
4007
  loadMoreButton
3983
4008
  ] }) })
3984
4009
  ] }) })
@@ -4131,8 +4156,8 @@ function PaginatedCombobox({
4131
4156
  /* @__PURE__ */ jsx(Loader2Icon, { className: "size-4 animate-spin", "aria-hidden": true }),
4132
4157
  labels.loading
4133
4158
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
4134
- /* @__PURE__ */ jsx(Combobox.Empty, { className: "px-3 py-2 text-sm text-muted-foreground", children: labels.noResults }),
4135
- /* @__PURE__ */ jsx(
4159
+ /* @__PURE__ */ jsx(Combobox.Empty, { className: "text-sm text-muted-foreground", children: /* @__PURE__ */ jsx("span", { className: "block px-3 py-2", children: labels.noResults }) }),
4160
+ listItems.length > 0 ? /* @__PURE__ */ jsx(
4136
4161
  Combobox.List,
4137
4162
  {
4138
4163
  className: "max-h-60 overflow-y-auto p-1 outline-none",
@@ -4142,19 +4167,21 @@ function PaginatedCombobox({
4142
4167
  {
4143
4168
  value: item,
4144
4169
  className: cn(
4145
- "relative flex cursor-default flex-col gap-0.5 rounded-md py-1.5 pr-2 pl-8 text-sm outline-none select-none",
4170
+ "relative flex cursor-default items-start gap-2 rounded-md px-2 py-1.5 text-sm outline-none select-none",
4146
4171
  "data-highlighted:bg-accent data-highlighted:text-accent-foreground"
4147
4172
  ),
4148
4173
  children: [
4149
- /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "absolute top-2 left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) }),
4150
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: item.label }),
4151
- item.secondary ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.secondary }) : null
4174
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
4175
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: item.label }),
4176
+ item.secondary ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.secondary }) : null
4177
+ ] }),
4178
+ /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "mt-0.5 flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) })
4152
4179
  ]
4153
4180
  },
4154
4181
  item.value
4155
4182
  )
4156
4183
  }
4157
- )
4184
+ ) : null
4158
4185
  ] }),
4159
4186
  nextCursor && onLoadMore ? /* @__PURE__ */ jsx("div", { className: "border-t p-1", children: /* @__PURE__ */ jsxs(
4160
4187
  "button",