@mesob/ui 0.5.6 → 0.5.8

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.
@@ -374,11 +374,13 @@ type EntityFormActionsProps = {
374
374
  isSubmitting?: boolean;
375
375
  isDeleting?: boolean;
376
376
  disabled?: boolean;
377
+ /** When set, overrides `disabled` for the delete trigger only. */
378
+ deleteDisabled?: boolean;
377
379
  submitLabel?: string;
378
380
  deleteLabel?: string;
379
381
  itemName?: string;
380
382
  };
381
- declare function EntityFormActions({ mode, onSubmit, onReset, onDelete, onCancel, isSubmitting, isDeleting, disabled, submitLabel, deleteLabel, itemName, }: EntityFormActionsProps): react_jsx_runtime.JSX.Element;
383
+ declare function EntityFormActions({ mode, onSubmit, onReset, onDelete, onCancel, isSubmitting, isDeleting, disabled, deleteDisabled, submitLabel, deleteLabel, itemName, }: EntityFormActionsProps): react_jsx_runtime.JSX.Element;
382
384
 
383
385
  type EntityHeaderProps = {
384
386
  title: ReactNode;
@@ -2336,7 +2338,7 @@ type FileInputProps = Omit<React$1.ComponentProps<'input'>, 'type'> & Omit<Input
2336
2338
  editImageOnSelect?: boolean;
2337
2339
  imageOutputScale?: number;
2338
2340
  };
2339
- declare function FileInput({ className, onFilesChange, clearable, multiple, files: filesProp, defaultFiles, previewItems, leftSection, placeholder, cropAspect, editImageOnSelect, imageOutputScale, label, description, error, required, withAsterisk, inputWrapperOrder, labelProps, descriptionProps, errorProps, inputContainer, disabled, ...props }: FileInputProps): react_jsx_runtime.JSX.Element;
2341
+ declare function FileInput({ className, onFilesChange, clearable, multiple, files: filesProp, defaultFiles, previewItems, leftSection, placeholder, cropAspect, editImageOnSelect, imageOutputScale, label, description, error, required, withAsterisk, inputWrapperOrder, labelProps, descriptionProps, errorProps, inputContainer, disabled, id: inputIdProp, ...props }: FileInputProps): react_jsx_runtime.JSX.Element;
2340
2342
 
2341
2343
  type FlexProps = React$1.ComponentProps<'div'> & {
2342
2344
  gap?: ComponentSize | number;
@@ -3040,17 +3040,15 @@ function Card({
3040
3040
  xl: "rounded-[var(--radius-xl)]",
3041
3041
  full: "rounded-full"
3042
3042
  };
3043
- const hasBelowHeader = footer != null || children != null;
3044
- const hasBodyAboveFooter = children != null;
3045
- const sectioned = header != null || footer != null || title != null || actions != null;
3043
+ const hasStructure = header != null || footer != null || title != null || actions != null;
3046
3044
  return /* @__PURE__ */ jsxs15(
3047
3045
  "div",
3048
3046
  {
3049
3047
  "data-slot": "card",
3050
- "data-sectioned": sectioned ? "" : void 0,
3048
+ "data-sectioned": hasStructure ? "" : void 0,
3051
3049
  "data-size": size,
3052
3050
  className: cn(
3053
- "cn-card group/card flex flex-col",
3051
+ "cn-card group/card",
3054
3052
  variant === "outline" && "cn-card-variant-outline",
3055
3053
  variant === "filled" && "cn-card-variant-filled",
3056
3054
  withBorder && "cn-card-with-border",
@@ -3060,15 +3058,9 @@ function Card({
3060
3058
  ),
3061
3059
  ...props,
3062
3060
  children: [
3063
- cardHeaderFromProps(hasBelowHeader, header, title, actions),
3064
- bodySlot(children, sectioned, padding !== void 0),
3065
- footer != null ? /* @__PURE__ */ jsx22(
3066
- CardFooter,
3067
- {
3068
- className: cn(hasBodyAboveFooter && "border-border/60 border-t"),
3069
- children: footer
3070
- }
3071
- ) : null
3061
+ cardHeaderFromProps(header, title, actions),
3062
+ bodySlot(children, hasStructure),
3063
+ footer != null ? /* @__PURE__ */ jsx22(CardFooter, { children: footer }) : null
3072
3064
  ]
3073
3065
  }
3074
3066
  );
@@ -3080,26 +3072,18 @@ function isSingleCardContent(children) {
3080
3072
  const only = Children.only(children);
3081
3073
  return isValidElement2(only) && only.props["data-slot"] === "card-content";
3082
3074
  }
3083
- function bodySlot(children, sectioned, hasRootPadding) {
3084
- if (children == null) {
3085
- return children;
3086
- }
3087
- if (isSingleCardContent(children)) {
3088
- return children;
3089
- }
3090
- const wrapBody = sectioned || !hasRootPadding;
3091
- if (!wrapBody) {
3075
+ function bodySlot(children, hasStructure) {
3076
+ if (children == null || !hasStructure || isSingleCardContent(children)) {
3092
3077
  return children;
3093
3078
  }
3094
3079
  return /* @__PURE__ */ jsx22(CardContent, { children });
3095
3080
  }
3096
- function cardHeaderFromProps(hasBelowHeader, header, title, actions) {
3097
- const divider = hasBelowHeader && "border-border/60 border-b";
3081
+ function cardHeaderFromProps(header, title, actions) {
3098
3082
  if (header != null) {
3099
- return /* @__PURE__ */ jsx22(CardHeader, { className: cn(divider), children: header });
3083
+ return /* @__PURE__ */ jsx22(CardHeader, { children: header });
3100
3084
  }
3101
3085
  if (title != null || actions != null) {
3102
- return /* @__PURE__ */ jsxs15(CardHeader, { className: cn(divider, "items-center"), children: [
3086
+ return /* @__PURE__ */ jsxs15(CardHeader, { className: "items-center", children: [
3103
3087
  title != null ? /* @__PURE__ */ jsx22(CardTitle, { children: title }) : null,
3104
3088
  actions != null ? /* @__PURE__ */ jsx22(CardAction, { children: actions }) : null
3105
3089
  ] });
@@ -3112,7 +3096,7 @@ function CardHeader({ className, ...props }) {
3112
3096
  {
3113
3097
  "data-slot": "card-header",
3114
3098
  className: cn(
3115
- "cn-card-header group/card-header @container/card-header grid auto-rows-min has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] has-data-[slot=card-description]:[&>[data-slot=card-action]]:row-span-2",
3099
+ "cn-card-header group/card-header @container/card-header grid auto-rows-min has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] has-data-[slot=card-description]:[&>[data-slot=card-action]]:row-span-2 [&:not(:last-child)]:border-border/60 [&:not(:last-child)]:border-b",
3116
3100
  className
3117
3101
  ),
3118
3102
  ...props
@@ -3167,7 +3151,10 @@ function CardFooter({ className, ...props }) {
3167
3151
  "div",
3168
3152
  {
3169
3153
  "data-slot": "card-footer",
3170
- className: cn("cn-card-footer flex items-center", className),
3154
+ className: cn(
3155
+ "cn-card-footer flex items-center [&:not(:first-child)]:border-border/60 [&:not(:first-child)]:border-t",
3156
+ className
3157
+ ),
3171
3158
  ...props
3172
3159
  }
3173
3160
  );
@@ -5032,10 +5019,12 @@ function EntityFormActions({
5032
5019
  isSubmitting = false,
5033
5020
  isDeleting = false,
5034
5021
  disabled = false,
5022
+ deleteDisabled,
5035
5023
  submitLabel,
5036
5024
  deleteLabel = "Delete",
5037
5025
  itemName = "item"
5038
5026
  }) {
5027
+ const deleteTriggerDisabled = deleteDisabled ?? disabled;
5039
5028
  const defaultSubmitLabel = mode === "new" ? "Create" : "Update";
5040
5029
  const label = submitLabel || defaultSubmitLabel;
5041
5030
  return /* @__PURE__ */ jsxs33("div", { className: "flex items-center gap-2", children: [
@@ -5071,7 +5060,7 @@ function EntityFormActions({
5071
5060
  Button,
5072
5061
  {
5073
5062
  variant: "destructive",
5074
- disabled,
5063
+ disabled: deleteTriggerDisabled,
5075
5064
  loading: isDeleting,
5076
5065
  className: "cursor-pointer",
5077
5066
  leftIcon: /* @__PURE__ */ jsx44(IconTrash3, { className: "size-4" })
@@ -19590,10 +19579,12 @@ function FileInput({
19590
19579
  errorProps,
19591
19580
  inputContainer,
19592
19581
  disabled,
19582
+ id: inputIdProp,
19593
19583
  ...props
19594
19584
  }) {
19595
19585
  const inputRef = useRef20(null);
19596
- const inputId = useId7();
19586
+ const generatedInputId = useId7();
19587
+ const inputId = inputIdProp ?? generatedInputId;
19597
19588
  const [internalFiles, setInternalFiles] = useState45(defaultFiles);
19598
19589
  const [pendingCropFile, setPendingCropFile] = useState45(null);
19599
19590
  const [cropOpen, setCropOpen] = useState45(false);
@@ -19645,7 +19636,14 @@ function FileInput({
19645
19636
  const hasWrapper = label || description || error || required || withAsterisk;
19646
19637
  const RootIcon = singleItem ? getFileIcon2(singleItem.type) : IconPaperclip;
19647
19638
  let metaContent = null;
19648
- if (items.length > 1) {
19639
+ if (multiple && items.length > 0) {
19640
+ metaContent = /* @__PURE__ */ jsxs95("div", { "data-slot": "file-input-meta", className: "cn-file-input-meta", children: [
19641
+ items.length,
19642
+ " file",
19643
+ items.length === 1 ? "" : "s",
19644
+ " selected"
19645
+ ] });
19646
+ } else if (!multiple && items.length > 1) {
19649
19647
  metaContent = /* @__PURE__ */ jsxs95("div", { "data-slot": "file-input-meta", className: "cn-file-input-meta", children: [
19650
19648
  items.length,
19651
19649
  " files selected"
@@ -19679,13 +19677,11 @@ function FileInput({
19679
19677
  }
19680
19678
  ),
19681
19679
  /* @__PURE__ */ jsx155(
19682
- "button",
19680
+ "label",
19683
19681
  {
19684
- type: "button",
19682
+ htmlFor: inputId,
19685
19683
  "data-slot": "file-input-root",
19686
19684
  className: "cn-file-input-root",
19687
- onClick: () => inputRef.current?.click(),
19688
- disabled,
19689
19685
  children: singleItem ? /* @__PURE__ */ jsxs95(Fragment29, { children: [
19690
19686
  /* @__PURE__ */ jsx155(
19691
19687
  "div",
@@ -19725,6 +19721,7 @@ function FileInput({
19725
19721
  variant: "ghost",
19726
19722
  size: "icon-sm",
19727
19723
  onClick: (event) => {
19724
+ event.preventDefault();
19728
19725
  event.stopPropagation();
19729
19726
  handleEdit();
19730
19727
  },
@@ -19740,6 +19737,7 @@ function FileInput({
19740
19737
  variant: "ghost",
19741
19738
  size: "icon-sm",
19742
19739
  onClick: (event) => {
19740
+ event.preventDefault();
19743
19741
  event.stopPropagation();
19744
19742
  handleClear();
19745
19743
  },
@@ -19782,7 +19780,7 @@ function FileInput({
19782
19780
  ] })
19783
19781
  }
19784
19782
  ),
19785
- !singleItem && items.length > 1 ? /* @__PURE__ */ jsx155("div", { "data-slot": "file-input-list", className: "cn-file-input-list", children: items.map((item) => {
19783
+ !singleItem && (multiple ? items.length > 0 : items.length > 1) ? /* @__PURE__ */ jsx155("div", { "data-slot": "file-input-list", className: "cn-file-input-list", children: items.map((item) => {
19786
19784
  const ItemIcon = getFileIcon2(item.type);
19787
19785
  return /* @__PURE__ */ jsxs95(
19788
19786
  "div",