@hyddenlabs/hydn-ui 0.3.0-alpha.182 → 0.3.0-alpha.185

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
@@ -3923,7 +3923,7 @@ function Table({
3923
3923
  }
3924
3924
  ${hoverable ? `
3925
3925
  table tbody tr:hover {
3926
- background-color: hsl(var(--muted) / 0.5);
3926
+ background-color: hsl(var(--muted) / 0.6) !important;
3927
3927
  }
3928
3928
  ` : ""}
3929
3929
  .table-compact td,
@@ -3951,6 +3951,7 @@ function TableHeadCell({
3951
3951
  className = "",
3952
3952
  align = "left",
3953
3953
  scope = "col",
3954
+ wrapText = false,
3954
3955
  ...props
3955
3956
  }) {
3956
3957
  const alignClasses4 = {
@@ -3958,15 +3959,23 @@ function TableHeadCell({
3958
3959
  center: "text-center",
3959
3960
  right: "text-right"
3960
3961
  };
3961
- return /* @__PURE__ */ jsxRuntime.jsx("th", { scope, className: `px-6 py-3 font-medium ${alignClasses4[align]} ${className}`, ...props, children });
3962
+ const wrapClasses = wrapText ? "whitespace-normal break-words" : "whitespace-nowrap";
3963
+ return /* @__PURE__ */ jsxRuntime.jsx("th", { scope, className: `px-6 py-3 font-medium ${alignClasses4[align]} ${wrapClasses} ${className}`, ...props, children });
3962
3964
  }
3963
- function TableCell({ children, className = "", align = "left", ...props }) {
3965
+ function TableCell({
3966
+ children,
3967
+ className = "",
3968
+ align = "left",
3969
+ wrapText = false,
3970
+ ...props
3971
+ }) {
3964
3972
  const alignClasses4 = {
3965
3973
  left: "text-left",
3966
3974
  center: "text-center",
3967
3975
  right: "text-right"
3968
3976
  };
3969
- return /* @__PURE__ */ jsxRuntime.jsx("td", { className: `px-6 py-4 whitespace-nowrap ${alignClasses4[align]} ${className}`, ...props, children });
3977
+ const wrapClasses = wrapText ? "whitespace-normal break-words" : "whitespace-nowrap";
3978
+ return /* @__PURE__ */ jsxRuntime.jsx("td", { className: `px-6 py-4 ${wrapClasses} ${alignClasses4[align]} ${className}`, ...props, children });
3970
3979
  }
3971
3980
  var table_default = Table;
3972
3981
  function Checkbox({
@@ -4293,7 +4302,7 @@ function DataTable({
4293
4302
  columns.map((column) => {
4294
4303
  const value = row[column.key];
4295
4304
  const content = renderCellContent(value, column, row, actualIndex);
4296
- return /* @__PURE__ */ jsxRuntime.jsx(TableCell, { align: column.align, children: content }, String(column.key));
4305
+ return /* @__PURE__ */ jsxRuntime.jsx(TableCell, { align: column.align, wrapText: column.wrapText, children: content }, String(column.key));
4297
4306
  }),
4298
4307
  actions && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { align: "center", onClick: (e) => e.stopPropagation(), children: (() => {
4299
4308
  let rowActions;
@@ -5298,6 +5307,137 @@ function Code({ children, size = "md", variant = "default", className = "" }) {
5298
5307
  }
5299
5308
  Code.displayName = "Code";
5300
5309
  var code_default = Code;
5310
+ function EditableText({
5311
+ value: controlledValue,
5312
+ defaultValue = "",
5313
+ onSave,
5314
+ onChange,
5315
+ onCancel,
5316
+ onEdit,
5317
+ placeholder = "Click to edit",
5318
+ disabled = false,
5319
+ size = "md",
5320
+ validationState = "default",
5321
+ className = "",
5322
+ id,
5323
+ name,
5324
+ required = false,
5325
+ autoFocus = true,
5326
+ maxLength,
5327
+ saveOnEnter = true
5328
+ }) {
5329
+ const isControlled = controlledValue !== void 0;
5330
+ const [internalValue, setInternalValue] = React.useState(defaultValue);
5331
+ const [isEditing, setIsEditing] = React.useState(false);
5332
+ const [editValue, setEditValue] = React.useState("");
5333
+ const inputRef = React.useRef(null);
5334
+ const currentValue = isControlled ? controlledValue : internalValue;
5335
+ React.useEffect(() => {
5336
+ if (isEditing && autoFocus && inputRef.current) {
5337
+ inputRef.current.focus();
5338
+ inputRef.current.select();
5339
+ }
5340
+ }, [isEditing, autoFocus]);
5341
+ const handleClick = () => {
5342
+ if (disabled) return;
5343
+ setEditValue(currentValue);
5344
+ setIsEditing(true);
5345
+ onEdit?.();
5346
+ };
5347
+ const handleSave = () => {
5348
+ const trimmedValue = editValue.trim();
5349
+ if (!isControlled) {
5350
+ setInternalValue(trimmedValue);
5351
+ }
5352
+ onSave?.(trimmedValue);
5353
+ onChange?.(trimmedValue);
5354
+ setIsEditing(false);
5355
+ };
5356
+ const handleCancel = () => {
5357
+ setEditValue(currentValue);
5358
+ setIsEditing(false);
5359
+ onCancel?.();
5360
+ };
5361
+ const handleKeyDown = (e) => {
5362
+ if (e.key === "Escape") {
5363
+ e.preventDefault();
5364
+ handleCancel();
5365
+ } else if (e.key === "Enter" && saveOnEnter && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
5366
+ e.preventDefault();
5367
+ handleSave();
5368
+ }
5369
+ };
5370
+ const handleBlur = (e) => {
5371
+ setTimeout(() => {
5372
+ const relatedTarget = e.relatedTarget;
5373
+ const isClickingButton = relatedTarget?.closest("[data-editable-actions]");
5374
+ if (!isClickingButton) {
5375
+ handleCancel();
5376
+ }
5377
+ }, 0);
5378
+ };
5379
+ const handleChange = (e) => {
5380
+ setEditValue(e.target.value);
5381
+ };
5382
+ const sizeConfig = {
5383
+ xs: "text-sm sm:text-xs",
5384
+ sm: "text-base sm:text-sm",
5385
+ md: "text-base sm:text-sm",
5386
+ lg: "text-lg sm:text-base",
5387
+ xl: "text-xl sm:text-lg"
5388
+ }[size];
5389
+ if (isEditing) {
5390
+ const validationBorder = {
5391
+ default: "border-b-foreground/30 focus:border-b-foreground",
5392
+ error: "border-b-destructive focus:border-b-destructive",
5393
+ success: "border-b-success focus:border-b-success",
5394
+ warning: "border-b-warning focus:border-b-warning"
5395
+ }[validationState];
5396
+ const commonProps = {
5397
+ ref: inputRef,
5398
+ value: editValue,
5399
+ onChange: handleChange,
5400
+ onKeyDown: handleKeyDown,
5401
+ onBlur: handleBlur,
5402
+ placeholder,
5403
+ disabled,
5404
+ id,
5405
+ name,
5406
+ required,
5407
+ maxLength,
5408
+ className: `${sizeConfig} w-full border-0 border-b ${validationBorder} bg-transparent py-1 outline-none transition-colors placeholder:text-muted-foreground`
5409
+ };
5410
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5411
+ /* @__PURE__ */ jsxRuntime.jsx("input", { ...commonProps, type: "text" }),
5412
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-editable-actions": true, className: "flex items-center gap-1", children: [
5413
+ /* @__PURE__ */ jsxRuntime.jsx(icon_button_default, { icon: "IconX", ariaLabel: "Cancel", onClick: handleCancel, variant: "error", size: "xs" }),
5414
+ /* @__PURE__ */ jsxRuntime.jsx(icon_button_default, { icon: "IconCheck", ariaLabel: "Save", onClick: handleSave, variant: "success", size: "xs" })
5415
+ ] })
5416
+ ] });
5417
+ }
5418
+ const displayText = currentValue || placeholder;
5419
+ const isPlaceholder = !currentValue;
5420
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5421
+ "button",
5422
+ {
5423
+ type: "button",
5424
+ onClick: handleClick,
5425
+ disabled,
5426
+ className: `group ${sizeConfig} ${className} relative inline-flex items-center gap-2 cursor-text border-b border-transparent py-1 text-left transition-all hover:border-b-foreground/30 focus:outline-none focus:ring-2 focus:ring-ring/20 focus:rounded disabled:cursor-not-allowed disabled:opacity-50 ${isPlaceholder ? "text-muted-foreground" : "text-foreground"} w-fit max-w-full`,
5427
+ children: [
5428
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: displayText }),
5429
+ /* @__PURE__ */ jsxRuntime.jsx(
5430
+ Icon,
5431
+ {
5432
+ name: "IconPencil",
5433
+ className: "shrink-0 opacity-0 transition-opacity group-hover:opacity-50 group-focus:opacity-50",
5434
+ size: "xs"
5435
+ }
5436
+ )
5437
+ ]
5438
+ }
5439
+ );
5440
+ }
5301
5441
  var alignClasses3 = {
5302
5442
  start: "items-start",
5303
5443
  center: "items-center",
@@ -6310,6 +6450,7 @@ exports.Divider = divider_default;
6310
6450
  exports.Drawer = drawer_default;
6311
6451
  exports.Dropdown = dropdown_default;
6312
6452
  exports.DropdownItem = DropdownItem;
6453
+ exports.EditableText = EditableText;
6313
6454
  exports.EmptyState = empty_state_default;
6314
6455
  exports.FeatureSection = feature_section_default;
6315
6456
  exports.Fieldset = fieldset_default;