@bubo-squared/ui-framework 0.2.21 → 0.2.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.cjs CHANGED
@@ -774,13 +774,14 @@ var Badge = React9.forwardRef(
774
774
  ...rest
775
775
  } = props;
776
776
  const Comp = asChild ? import_react_slot5.Slot : "div";
777
+ const hasValue = typeof value === "string" ? value.trim() !== "" : value != null;
777
778
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
778
779
  Comp,
779
780
  {
780
781
  ref,
781
782
  className: cn(badgeVariants({ size, variant }), className),
782
783
  ...rest,
783
- children: value ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
784
+ children: hasValue ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
784
785
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-normal", children: label }),
785
786
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-normal", children: ":" }),
786
787
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium", children: value })
@@ -961,7 +962,7 @@ var Divider = (props) => {
961
962
  className: _className,
962
963
  ...divProps
963
964
  } = props;
964
- const textLabel = label ? label : "OR";
965
+ const textLabel = label ?? "OR";
965
966
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
966
967
  "div",
967
968
  {
@@ -1109,13 +1110,15 @@ var Field = (props) => {
1109
1110
  className,
1110
1111
  children
1111
1112
  } = props;
1113
+ const hasLabel = label != null;
1114
+ const hasHint = hint != null;
1112
1115
  const fieldId = React14.useId();
1113
- const labelId = label ? `${fieldId}-label` : void 0;
1114
- const hintId = hint ? `${fieldId}-hint` : void 0;
1116
+ const labelId = hasLabel ? `${fieldId}-label` : void 0;
1117
+ const hintId = hasHint ? `${fieldId}-hint` : void 0;
1115
1118
  const hintColorClass = disabled ? "text-primary-disabled" : status === "success" ? "text-(--color-success)" : status === "error" ? "text-(--color-error)" : "text-(--color-secondary)";
1116
1119
  const labelColorClass = disabled ? "text-primary-disabled" : "text-primary";
1117
1120
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: cn(fieldBase, className), children: [
1118
- label && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full items-center justify-between", children: [
1121
+ hasLabel && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full items-center justify-between", children: [
1119
1122
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { id: labelId, className: cn("paragraph-sm", labelColorClass), children: label }),
1120
1123
  labelRight
1121
1124
  ] }),
@@ -1123,9 +1126,9 @@ var Field = (props) => {
1123
1126
  !hideHint && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1124
1127
  "p",
1125
1128
  {
1126
- id: hint ? hintId : void 0,
1127
- className: cn("caption", hint ? hintColorClass : "invisible"),
1128
- children: hint || "\xA0"
1129
+ id: hasHint ? hintId : void 0,
1130
+ className: cn("caption", hasHint ? hintColorClass : "invisible"),
1131
+ children: hasHint ? hint : "\xA0"
1129
1132
  }
1130
1133
  )
1131
1134
  ] });
@@ -1145,6 +1148,7 @@ var Progress = React15.forwardRef(
1145
1148
  value,
1146
1149
  label,
1147
1150
  hint,
1151
+ ariaLabel,
1148
1152
  showProgressLabel = true,
1149
1153
  hideHint,
1150
1154
  size = "lg",
@@ -1155,12 +1159,13 @@ var Progress = React15.forwardRef(
1155
1159
  } = props;
1156
1160
  const clamped = Number.isFinite(value) ? Math.min(100, Math.max(0, value)) : 0;
1157
1161
  const percentageLabel = `${Math.round(clamped)}%`;
1162
+ const resolvedAriaLabel = ariaLabel ?? (typeof label === "string" ? label : void 0);
1158
1163
  const barHeightClasses = sizeToBarClasses[size];
1159
1164
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1160
1165
  Field,
1161
1166
  {
1162
1167
  label,
1163
- labelRight: showProgressLabel && label ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "footnote text-(--color-secondary)", children: percentageLabel }) : void 0,
1168
+ labelRight: showProgressLabel && label != null ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "footnote text-(--color-secondary)", children: percentageLabel }) : void 0,
1164
1169
  hint,
1165
1170
  hideHint,
1166
1171
  status,
@@ -1174,7 +1179,7 @@ var Progress = React15.forwardRef(
1174
1179
  "aria-valuenow": clamped,
1175
1180
  "aria-valuemin": 0,
1176
1181
  "aria-valuemax": 100,
1177
- "aria-label": label,
1182
+ "aria-label": resolvedAriaLabel,
1178
1183
  ...rest,
1179
1184
  children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1180
1185
  "div",
@@ -1275,7 +1280,7 @@ var import_react_slot6 = require("@radix-ui/react-slot");
1275
1280
  var import_class_variance_authority11 = require("class-variance-authority");
1276
1281
  var import_jsx_runtime19 = require("react/jsx-runtime");
1277
1282
  var tagVariants = (0, import_class_variance_authority11.cva)(
1278
- "inline-flex flex-row items-center justify-center rounded-6 gap-2 px-3 overflow-hidden border-1 border-(--border-secondary) bg-(--background-neutral) hover:border-(--border-secondary-hover) focus:border-(--border-brand) focus-ring-primary ",
1283
+ "inline-flex flex-row items-center justify-center rounded-6 gap-2 px-3 overflow-hidden border-1 border-(--border-secondary) bg-(--background-neutral) focus:border-(--border-brand) focus-ring-primary ",
1279
1284
  {
1280
1285
  variants: {
1281
1286
  size: {
@@ -1301,6 +1306,7 @@ var Tag = React17.forwardRef(
1301
1306
  value,
1302
1307
  ...rest
1303
1308
  } = props;
1309
+ const hasValue = typeof value === "string" ? value.trim() !== "" : value != null;
1304
1310
  const Comp = asChild ? import_react_slot6.Slot : "div";
1305
1311
  const leading = props.leadingIcon && React17.isValidElement(props.leadingIcon) ? React17.cloneElement(props.leadingIcon, { disabled, ...props.leadingIcon.props }) : null;
1306
1312
  const trailing = props.trailingIcon && React17.isValidElement(props.trailingIcon) ? React17.cloneElement(props.trailingIcon, { disabled, ...props.trailingIcon.props }) : null;
@@ -1312,7 +1318,7 @@ var Tag = React17.forwardRef(
1312
1318
  ...rest,
1313
1319
  children: [
1314
1320
  leading && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: iconClasses, children: leading }),
1315
- value ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-row gap-1 items-center", children: [
1321
+ hasValue ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-row gap-1 items-center", children: [
1316
1322
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-primary paragraph-lg mb-0! cursor-default font-normal", children: label }),
1317
1323
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-primary paragraph-lg mb-0! cursor-default font-normal", children: ":" }),
1318
1324
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-primary paragraph-lg-medium mb-0! cursor-default font-medium", children: value })
@@ -1770,6 +1776,7 @@ var Autocomplete = React23.forwardRef((props, forwardedRef) => {
1770
1776
  inputValue,
1771
1777
  defaultInputValue,
1772
1778
  onInputChange,
1779
+ freeSolo = false,
1773
1780
  dropdownClassName,
1774
1781
  listboxClassName,
1775
1782
  placeholder = "Search\u2026",
@@ -1820,6 +1827,12 @@ var Autocomplete = React23.forwardRef((props, forwardedRef) => {
1820
1827
  }
1821
1828
  onInputChange?.(next);
1822
1829
  };
1830
+ const commitTypedValue = (next) => {
1831
+ if (!isValueControlled) {
1832
+ setInternalValue(next);
1833
+ }
1834
+ onChange?.(next);
1835
+ };
1823
1836
  const commitValue = (next) => {
1824
1837
  if (!isValueControlled) {
1825
1838
  setInternalValue(next);
@@ -1836,6 +1849,9 @@ var Autocomplete = React23.forwardRef((props, forwardedRef) => {
1836
1849
  const next = event.target.value;
1837
1850
  setInputText(next);
1838
1851
  setActiveIndex(-1);
1852
+ if (freeSolo) {
1853
+ commitTypedValue(next);
1854
+ }
1839
1855
  };
1840
1856
  const handleFocus = (event) => {
1841
1857
  setIsFocused(true);
@@ -1844,6 +1860,12 @@ var Autocomplete = React23.forwardRef((props, forwardedRef) => {
1844
1860
  const handleBlur = (event) => {
1845
1861
  setIsFocused(false);
1846
1862
  setActiveIndex(-1);
1863
+ if (freeSolo) {
1864
+ const trimmed = currentInput.trim();
1865
+ if (trimmed.length > 0 && currentInput !== currentValue) {
1866
+ commitTypedValue(currentInput);
1867
+ }
1868
+ }
1847
1869
  onBlur?.(event);
1848
1870
  };
1849
1871
  const handleKeyDown = (event) => {
@@ -1877,6 +1899,17 @@ var Autocomplete = React23.forwardRef((props, forwardedRef) => {
1877
1899
  event.preventDefault();
1878
1900
  commitValue(options[activeIndex]);
1879
1901
  setIsFocused(false);
1902
+ break;
1903
+ }
1904
+ if (freeSolo) {
1905
+ const trimmed = currentInput.trim();
1906
+ if (trimmed.length > 0) {
1907
+ event.preventDefault();
1908
+ if (currentInput !== currentValue) {
1909
+ commitTypedValue(currentInput);
1910
+ }
1911
+ setIsFocused(false);
1912
+ }
1880
1913
  }
1881
1914
  break;
1882
1915
  }
@@ -3306,6 +3339,8 @@ var Tooltip = (props) => {
3306
3339
  children,
3307
3340
  delayDuration = 200
3308
3341
  } = props;
3342
+ const hasStrapline = typeof strapline === "string" ? strapline.trim() !== "" : strapline != null;
3343
+ const hasDescription = typeof description === "string" ? description.trim() !== "" : description != null;
3309
3344
  const { side, align } = mapPlacementToSideAndAlign(placement);
3310
3345
  const tooltipClasses = "group bg-(--background-tooltip) max-w-[calc(100vw-2rem)] shadow-card-md border-none rounded-4 py-1.5 px-2.5 [&>span]:scale-200 data-[state=delayed-open]:animate-in data-[state=instant-open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=delayed-open]:fade-in-0 data-[state=instant-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=instant-open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";
3311
3346
  const tooltipArrowClasses = "relative fill-(--background-tooltip) transition-[filter,transform] group-data-[side=top]:top-[-2px] group-data-[side=top]:drop-shadow-[0px_1px_1px_color-mix(in_srgb,_var(--color-b-black-10)_66%,_transparent)] group-data-[side=bottom]:drop-shadow-[0px_1px_1px_color-mix(in_srgb,_var(--color-b-black-10)_66%,_transparent)] group-data-[side=left]:drop-shadow-[0px_2px_1px_color-mix(in_srgb,_var(--color-b-black-10)_66%,_transparent)] group-data-[side=right]:drop-shadow-[0px_2px_1px_color-mix(in_srgb,_var(--color-b-black-10)_66%,_transparent)]";
@@ -3329,9 +3364,9 @@ var Tooltip = (props) => {
3329
3364
  children: [
3330
3365
  showArrow && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TooltipArrow, { className: tooltipArrowClasses }),
3331
3366
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "grid", children: [
3332
- (strapline ?? "") !== "" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "caption text-secondary", children: strapline }),
3367
+ hasStrapline && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "caption text-secondary", children: strapline }),
3333
3368
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h4", { className: "paragraph-md text-primary", children: title }),
3334
- (description ?? "") !== "" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "paragraph-sm text-primary", children: description })
3369
+ hasDescription && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "paragraph-sm text-primary", children: description })
3335
3370
  ] })
3336
3371
  ]
3337
3372
  }
@@ -4238,6 +4273,8 @@ var Popover2 = (props) => {
4238
4273
  offset = 10,
4239
4274
  children
4240
4275
  } = props;
4276
+ const hasStrapline = typeof strapline === "string" ? strapline.trim() !== "" : strapline != null;
4277
+ const hasDescription = typeof description === "string" ? description.trim() !== "" : description != null;
4241
4278
  const [open, setOpen] = React40.useState(false);
4242
4279
  const handleCancel = () => {
4243
4280
  onCancel?.();
@@ -4293,9 +4330,9 @@ var Popover2 = (props) => {
4293
4330
  showArrow && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PopoverArrow, { className: popoverArrowClasses }),
4294
4331
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "grid gap-4", children: [
4295
4332
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "space-y-2", children: [
4296
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "caption text-secondary", children: strapline }),
4333
+ hasStrapline && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "caption text-secondary", children: strapline }),
4297
4334
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h4", { className: "subtitle-medium text-primary", children: title }),
4298
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "paragraph-sm text-primary", children: description })
4335
+ hasDescription && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "paragraph-sm text-primary", children: description })
4299
4336
  ] }),
4300
4337
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex justify-start items-center gap-4 flex-wrap", children: [
4301
4338
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Button, { size: "sm", variant: "secondary", onClick: handleCancel, children: cancelText || "Cancel" }),