@rebasepro/ui 0.2.1 → 0.2.4

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.
Files changed (36) hide show
  1. package/dist/components/Button.d.ts +2 -2
  2. package/dist/components/ErrorBoundary.d.ts +25 -3
  3. package/dist/components/VirtualTable/VirtualTable.d.ts +1 -1
  4. package/dist/components/VirtualTable/VirtualTableCell.d.ts +6 -6
  5. package/dist/components/VirtualTable/VirtualTableHeader.d.ts +8 -8
  6. package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
  7. package/dist/components/VirtualTable/VirtualTableProps.d.ts +11 -11
  8. package/dist/components/VirtualTable/VirtualTableRow.d.ts +1 -1
  9. package/dist/components/VirtualTable/types.d.ts +9 -9
  10. package/dist/hooks/useDebounceCallback.d.ts +1 -1
  11. package/dist/index.css +1 -1
  12. package/dist/index.es.js +135 -76
  13. package/dist/index.es.js.map +1 -1
  14. package/dist/index.umd.js +130 -71
  15. package/dist/index.umd.js.map +1 -1
  16. package/dist/util/debounce.d.ts +1 -1
  17. package/package.json +3 -2
  18. package/src/components/BooleanSwitch.tsx +1 -1
  19. package/src/components/Button.tsx +11 -11
  20. package/src/components/ErrorBoundary.tsx +171 -18
  21. package/src/components/IconButton.tsx +4 -4
  22. package/src/components/MultiSelect.tsx +6 -6
  23. package/src/components/SearchBar.tsx +1 -1
  24. package/src/components/TextareaAutosize.tsx +2 -2
  25. package/src/components/VirtualTable/VirtualTable.tsx +8 -8
  26. package/src/components/VirtualTable/VirtualTableCell.tsx +6 -6
  27. package/src/components/VirtualTable/VirtualTableHeader.tsx +15 -15
  28. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +6 -6
  29. package/src/components/VirtualTable/VirtualTableProps.tsx +11 -11
  30. package/src/components/VirtualTable/VirtualTableRow.tsx +2 -2
  31. package/src/components/VirtualTable/types.tsx +9 -9
  32. package/src/hooks/useDebounceCallback.tsx +2 -1
  33. package/src/index.css +1 -1
  34. package/src/util/debounce.ts +2 -1
  35. package/src/scripts/migrateIconImports.ts +0 -108
  36. package/src/scripts/test.ts +0 -6
package/dist/index.umd.js CHANGED
@@ -989,15 +989,15 @@
989
989
  "border border-transparent bg-surface-300 dark:bg-surface-500 opacity-40 bg-surface-300/40 dark:bg-surface-500/40": t25
990
990
  });
991
991
  const sizeClasses2 = cls({
992
- "py-1 px-2": size === "small",
993
- "py-2 px-4": size === "medium",
994
- "py-2.5 px-5": size === "large",
995
- "py-3 px-6": size === "xl",
996
- "py-4 px-10": size === "2xl"
992
+ "py-0.5 px-1.5": size === "small",
993
+ "py-1.5 px-3": size === "medium",
994
+ "py-2 px-4": size === "large",
995
+ "py-2.5 px-5": size === "xl",
996
+ "py-3 px-6": size === "2xl"
997
997
  });
998
998
  const iconColorClass = (color === "neutral" || color === "text") && !disabled ? "[&>svg]:text-surface-accent-500 dark:[&>svg]:text-surface-accent-300" : "";
999
999
  if (Component) {
1000
- t30 = /* @__PURE__ */ jsxRuntime.jsxs(Component, { ref, onClick: props.onClick, className: cls(startIcon ? "pl-3" : "", "typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-2 px-4 focus:outline-none transition-all ease-in-out duration-150 gap-2 active:scale-[0.98]", buttonClasses2, sizeClasses2, iconColorClass, className), ...props, children: [
1000
+ t30 = /* @__PURE__ */ jsxRuntime.jsxs(Component, { ref, onClick: props.onClick, className: cls(startIcon ? "pl-3" : "", "typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-1.5 px-3 focus:outline-none transition-all ease-in-out duration-150 gap-1.5 active:scale-[0.98]", buttonClasses2, sizeClasses2, iconColorClass, className), ...props, children: [
1001
1001
  startIcon,
1002
1002
  children
1003
1003
  ] });
@@ -1006,7 +1006,7 @@
1006
1006
  t26 = ref;
1007
1007
  t27 = props.type ?? "button";
1008
1008
  t28 = props.onClick;
1009
- t29 = cls(startIcon ? "pl-3" : "", "typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-2 px-4 focus:outline-none transition-all ease-in-out duration-150 gap-2 active:scale-[0.98]", buttonClasses2, sizeClasses2, iconColorClass, className);
1009
+ t29 = cls(startIcon ? "pl-3" : "", "typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-1.5 px-3 focus:outline-none transition-all ease-in-out duration-150 gap-1.5 active:scale-[0.98]", buttonClasses2, sizeClasses2, iconColorClass, className);
1010
1010
  }
1011
1011
  $[11] = Component;
1012
1012
  $[12] = children;
@@ -1552,11 +1552,18 @@
1552
1552
  disabled: "text-text-disabled dark:text-text-disabled-dark",
1553
1553
  error: "text-red-500"
1554
1554
  };
1555
+ function isPermissionError(error) {
1556
+ if (!error) return false;
1557
+ const msg = error.message?.toLowerCase() ?? "";
1558
+ const code = error.code?.toLowerCase() ?? "";
1559
+ return msg.includes("permission") || msg.includes("insufficient") || msg.includes("unauthorized") || msg.includes("forbidden") || msg.includes("access denied") || code === "permission_denied" || code === "insufficient_permissions" || error.status === 403;
1560
+ }
1555
1561
  class ErrorBoundary extends React.Component {
1556
1562
  constructor(props) {
1557
1563
  super(props);
1558
1564
  this.state = {
1559
- error: null
1565
+ error: null,
1566
+ showDetails: false
1560
1567
  };
1561
1568
  }
1562
1569
  static getDerivedStateFromError(error) {
@@ -1567,18 +1574,71 @@
1567
1574
  componentDidCatch(error, _errorInfo) {
1568
1575
  console.error(error);
1569
1576
  }
1577
+ handleReset = () => {
1578
+ this.setState({
1579
+ error: null,
1580
+ showDetails: false
1581
+ });
1582
+ this.props.onReset?.();
1583
+ };
1584
+ handleReload = () => {
1585
+ window.location.reload();
1586
+ };
1587
+ toggleDetails = () => {
1588
+ this.setState((prev) => ({
1589
+ showDetails: !prev.showDetails
1590
+ }));
1591
+ };
1570
1592
  render() {
1571
1593
  if (this.state.error) {
1572
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col m-2", children: [
1573
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center m-2", children: [
1574
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, { className: "text-red-500", size: iconSize.small }),
1575
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: "Error" })
1576
- ] }),
1577
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", children: this.state.error?.message ?? "See the error in the console" })
1578
- ] });
1594
+ if (this.props.fullPage) {
1595
+ return this.renderFullPage();
1596
+ }
1597
+ return this.renderInline();
1579
1598
  }
1580
1599
  return this.props.children;
1581
1600
  }
1601
+ renderInline() {
1602
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col m-2", children: [
1603
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center m-2", children: [
1604
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, { className: "text-red-500", size: iconSize.small }),
1605
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: "Error" })
1606
+ ] }),
1607
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", children: this.state.error?.message ?? "See the error in the console" })
1608
+ ] });
1609
+ }
1610
+ renderFullPage() {
1611
+ const {
1612
+ error,
1613
+ showDetails
1614
+ } = this.state;
1615
+ const isPermission = isPermissionError(error);
1616
+ const Icon = isPermission ? lucideReact.ShieldAlertIcon : lucideReact.AlertCircleIcon;
1617
+ const title = isPermission ? "Access denied" : "Something went wrong";
1618
+ const description = isPermission ? "You don't have permission to access this resource. Please check your account permissions or contact your administrator." : "An unexpected error occurred. You can try reloading the page or going back.";
1619
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("flex items-center justify-center min-h-[400px] h-full w-full", "bg-surface-50 dark:bg-surface-950"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center max-w-md px-6 py-10 text-center", children: [
1620
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("flex items-center justify-center w-14 h-14 rounded-2xl mb-6", isPermission ? "bg-amber-100 dark:bg-amber-900/30" : "bg-red-100 dark:bg-red-900/30"), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 28, className: isPermission ? "text-amber-600 dark:text-amber-400" : "text-red-500 dark:text-red-400" }) }),
1621
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h6", className: "text-text-primary dark:text-text-primary-dark mb-2", children: title }),
1622
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark mb-8", children: description }),
1623
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
1624
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outlined", color: "neutral", size: "medium", onClick: this.handleReset, children: [
1625
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeftIcon, { size: 16 }),
1626
+ "Try again"
1627
+ ] }),
1628
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "filled", color: "primary", size: "medium", onClick: this.handleReload, children: [
1629
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCwIcon, { size: 16 }),
1630
+ "Reload page"
1631
+ ] })
1632
+ ] }),
1633
+ error?.message && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-8 w-full", children: [
1634
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: this.toggleDetails, className: cls("flex items-center gap-1 mx-auto text-xs", "text-text-disabled dark:text-text-disabled-dark", "hover:text-text-secondary dark:hover:text-text-secondary-dark", "transition-colors cursor-pointer bg-transparent border-none p-0"), children: [
1635
+ "Technical details",
1636
+ showDetails ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUpIcon, { size: 14 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { size: 14 })
1637
+ ] }),
1638
+ showDetails && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("mt-3 p-3 rounded-lg text-left text-xs", "bg-surface-100 dark:bg-surface-800", "text-text-secondary dark:text-text-secondary-dark", "font-mono break-all"), children: error.message })
1639
+ ] })
1640
+ ] }) });
1641
+ }
1582
1642
  }
1583
1643
  const sizeClasses$2 = {
1584
1644
  large: "w-6 h-6 rounded flex items-center justify-center",
@@ -2091,10 +2151,10 @@
2091
2151
  const baseClasses = "inline-flex items-center justify-center p-2 text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150";
2092
2152
  const colorClasses$1 = "text-surface-accent-500 visited:text-surface-accent-500 dark:text-surface-accent-300 dark:visited:text-surface-300";
2093
2153
  const sizeClasses$1 = {
2094
- medium: "w-10 !h-10 min-w-10 min-h-10",
2095
- small: "w-8 !h-8 min-w-8 min-h-8",
2096
- smallest: "w-6 !h-6 min-w-6 min-h-6",
2097
- large: "w-12 !h-12 min-w-12 min-h-12"
2154
+ medium: "w-9 !h-9 min-w-9 min-h-9",
2155
+ small: "w-7 !h-7 min-w-7 min-h-7",
2156
+ smallest: "w-5 !h-5 min-w-5 min-h-5",
2157
+ large: "w-10 !h-10 min-w-10 min-h-10"
2098
2158
  };
2099
2159
  const shapeClasses = {
2100
2160
  circular: "rounded-full",
@@ -4325,7 +4385,7 @@
4325
4385
  if (selectedValues.some((v_0) => String(v_0) === String(newValue))) {
4326
4386
  newSelectedValues = selectedValues.filter((v) => String(v) !== String(newValue));
4327
4387
  } else {
4328
- newSelectedValues = [...selectedValues, newValue];
4388
+ newSelectedValues = [...selectedValues, String(newValue)];
4329
4389
  }
4330
4390
  updateValues(newSelectedValues);
4331
4391
  };
@@ -5247,88 +5307,87 @@
5247
5307
  t10 = $[17];
5248
5308
  }
5249
5309
  const t11 = searchText ?? "";
5250
- const t12 = inputRef;
5251
- const t13 = !onTextSearch;
5252
- let t14;
5310
+ const t12 = !onTextSearch;
5311
+ let t13;
5253
5312
  if ($[18] !== onTextSearch) {
5254
- t14 = onTextSearch ? (event) => {
5313
+ t13 = onTextSearch ? (event) => {
5255
5314
  setSearchText(event.target.value);
5256
5315
  } : void 0;
5257
5316
  $[18] = onTextSearch;
5258
- $[19] = t14;
5317
+ $[19] = t13;
5259
5318
  } else {
5260
- t14 = $[19];
5319
+ t13 = $[19];
5261
5320
  }
5321
+ let t14;
5262
5322
  let t15;
5263
- let t16;
5264
5323
  if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
5265
- t15 = () => setActive(true);
5266
- t16 = () => setActive(false);
5267
- $[20] = t15;
5268
- $[21] = t16;
5324
+ t14 = () => setActive(true);
5325
+ t15 = () => setActive(false);
5326
+ $[20] = t14;
5327
+ $[21] = t15;
5269
5328
  } else {
5270
- t15 = $[20];
5271
- t16 = $[21];
5329
+ t14 = $[20];
5330
+ t15 = $[21];
5272
5331
  }
5273
- const t17 = (disabled || loading) && "pointer-events-none";
5274
- const t18 = size === "small" ? "text-sm" : "";
5275
- const t19 = expandable ? active ? "w-[220px]" : "w-[180px]" : "";
5276
- let t20;
5277
- if ($[22] !== innerClassName || $[23] !== inputPaddingClass || $[24] !== t17 || $[25] !== t18 || $[26] !== t19) {
5278
- t20 = cls(t17, "placeholder-text-disabled dark:placeholder-text-disabled-dark", "relative flex items-center transition-all bg-transparent outline-none focus:outline-none focus:ring-0 appearance-none border-none focus:border-transparent", inputPaddingClass, "h-full w-full text-current", t18, t19, innerClassName);
5332
+ const t16 = (disabled || loading) && "pointer-events-none";
5333
+ const t17 = size === "small" ? "text-sm" : "";
5334
+ const t18 = expandable ? active ? "w-[220px]" : "w-[180px]" : "";
5335
+ let t19;
5336
+ if ($[22] !== innerClassName || $[23] !== inputPaddingClass || $[24] !== t16 || $[25] !== t17 || $[26] !== t18) {
5337
+ t19 = cls(t16, "placeholder-text-disabled dark:placeholder-text-disabled-dark", "relative flex items-center transition-all bg-transparent outline-none focus:outline-none focus:ring-0 appearance-none border-none focus:border-transparent", inputPaddingClass, "h-full w-full text-current", t17, t18, innerClassName);
5279
5338
  $[22] = innerClassName;
5280
5339
  $[23] = inputPaddingClass;
5281
- $[24] = t17;
5282
- $[25] = t18;
5283
- $[26] = t19;
5284
- $[27] = t20;
5340
+ $[24] = t16;
5341
+ $[25] = t17;
5342
+ $[26] = t18;
5343
+ $[27] = t19;
5285
5344
  } else {
5286
- t20 = $[27];
5345
+ t19 = $[27];
5287
5346
  }
5288
- let t21;
5289
- if ($[28] !== autoFocus || $[29] !== onClick || $[30] !== placeholder || $[31] !== t11 || $[32] !== t12 || $[33] !== t13 || $[34] !== t14 || $[35] !== t20) {
5290
- t21 = /* @__PURE__ */ jsxRuntime.jsx("input", { value: t11, ref: t12, onClick, placeholder, "aria-label": placeholder, readOnly: t13, onChange: t14, autoFocus, onFocus: t15, onBlur: t16, className: t20 });
5347
+ let t20;
5348
+ if ($[28] !== autoFocus || $[29] !== inputRef || $[30] !== onClick || $[31] !== placeholder || $[32] !== t11 || $[33] !== t12 || $[34] !== t13 || $[35] !== t19) {
5349
+ t20 = /* @__PURE__ */ jsxRuntime.jsx("input", { value: t11, ref: inputRef, onClick, placeholder, "aria-label": placeholder, readOnly: t12, onChange: t13, autoFocus, onFocus: t14, onBlur: t15, className: t19 });
5291
5350
  $[28] = autoFocus;
5292
- $[29] = onClick;
5293
- $[30] = placeholder;
5294
- $[31] = t11;
5295
- $[32] = t12;
5296
- $[33] = t13;
5297
- $[34] = t14;
5298
- $[35] = t20;
5299
- $[36] = t21;
5351
+ $[29] = inputRef;
5352
+ $[30] = onClick;
5353
+ $[31] = placeholder;
5354
+ $[32] = t11;
5355
+ $[33] = t12;
5356
+ $[34] = t13;
5357
+ $[35] = t19;
5358
+ $[36] = t20;
5300
5359
  } else {
5301
- t21 = $[36];
5360
+ t20 = $[36];
5302
5361
  }
5303
- let t22;
5362
+ let t21;
5304
5363
  if ($[37] !== clearText || $[38] !== searchText || $[39] !== size) {
5305
- t22 = searchText ? /* @__PURE__ */ jsxRuntime.jsx(IconButton, { className: `${size === "small" ? "mr-0 top-0" : "mr-1 top-0"} absolute right-0 z-10`, size: "small", "aria-label": "Clear search", onClick: clearText, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { size: iconSize.smallest }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5364
+ t21 = searchText ? /* @__PURE__ */ jsxRuntime.jsx(IconButton, { className: `${size === "small" ? "mr-0 top-0" : "mr-1 top-0"} absolute right-0 z-10`, size: "small", "aria-label": "Clear search", onClick: clearText, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { size: iconSize.smallest }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
5306
5365
  width: 26
5307
5366
  } });
5308
5367
  $[37] = clearText;
5309
5368
  $[38] = searchText;
5310
5369
  $[39] = size;
5311
- $[40] = t22;
5370
+ $[40] = t21;
5312
5371
  } else {
5313
- t22 = $[40];
5372
+ t21 = $[40];
5314
5373
  }
5315
- let t23;
5316
- if ($[41] !== onClick || $[42] !== t10 || $[43] !== t21 || $[44] !== t22 || $[45] !== t7) {
5317
- t23 = /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "search", "aria-label": "Search", onClick, className: t7, children: [
5374
+ let t22;
5375
+ if ($[41] !== onClick || $[42] !== t10 || $[43] !== t20 || $[44] !== t21 || $[45] !== t7) {
5376
+ t22 = /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "search", "aria-label": "Search", onClick, className: t7, children: [
5318
5377
  t10,
5319
- t21,
5320
- t22
5378
+ t20,
5379
+ t21
5321
5380
  ] });
5322
5381
  $[41] = onClick;
5323
5382
  $[42] = t10;
5324
- $[43] = t21;
5325
- $[44] = t22;
5383
+ $[43] = t20;
5384
+ $[44] = t21;
5326
5385
  $[45] = t7;
5327
- $[46] = t23;
5386
+ $[46] = t22;
5328
5387
  } else {
5329
- t23 = $[46];
5388
+ t22 = $[46];
5330
5389
  }
5331
- return t23;
5390
+ return t22;
5332
5391
  }
5333
5392
  const Select = React.forwardRef((t0, ref) => {
5334
5393
  const $ = reactCompilerRuntime.c(123);
@@ -8764,7 +8823,7 @@
8764
8823
  zIndex: 1
8765
8824
  }, children: endAdornment });
8766
8825
  }
8767
- const rowData = data && data[index];
8826
+ const rowData = data ? data[index] : void 0;
8768
8827
  return /* @__PURE__ */ jsxRuntime.jsxs(VirtualTableRow, { rowData, rowIndex: index, onRowClick, columns, hoverRow, rowClassName, style: {
8769
8828
  ...style,
8770
8829
  top: `calc(${style.top}px + ${headerHeight ?? 48}px)`