@gobolt/genesis 0.4.33 → 0.4.35

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.
@@ -3,6 +3,7 @@ export type GoBoltUser = {
3
3
  first_name: string;
4
4
  last_name: string;
5
5
  image_url?: string;
6
+ url?: string;
6
7
  };
7
8
  export interface AvatarProps {
8
9
  size?: number;
@@ -11,6 +12,8 @@ export interface AvatarProps {
11
12
  children?: string;
12
13
  backgroundColor?: string;
13
14
  user?: GoBoltUser | null;
15
+ url?: string;
16
+ alt?: string;
14
17
  }
15
- declare const Avatar: ({ size, shape, children, backgroundColor, user, }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
18
+ declare const Avatar: ({ size, shape, children, backgroundColor, user, url, alt, ...rest }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
16
19
  export default Avatar;
@@ -13,6 +13,7 @@ export interface OverflowMenuProps {
13
13
  style?: React.CSSProperties;
14
14
  onItemClick?: (item: OverflowMenuItemProps) => void;
15
15
  overrideTextColor?: string;
16
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
16
17
  }
17
18
  declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
18
19
  export default OverflowMenu;
@@ -12,6 +12,7 @@ export interface InfiniteScrollConfig<T = any> {
12
12
  scrollHeight?: number;
13
13
  scrollWidth?: number;
14
14
  useWindowScroll?: boolean;
15
+ filterFn: (data: T[]) => T[];
15
16
  }
16
17
  export interface TableProps<T extends Record<string, any>> {
17
18
  dataSource: T[];
package/dist/index.cjs CHANGED
@@ -60441,7 +60441,10 @@ const Avatar = ({
60441
60441
  shape = "circle",
60442
60442
  children: children2,
60443
60443
  backgroundColor = "#00282B",
60444
- user = null
60444
+ user = null,
60445
+ url: url3,
60446
+ alt,
60447
+ ...rest
60445
60448
  }) => {
60446
60449
  if (!user) {
60447
60450
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -60451,7 +60454,9 @@ const Avatar = ({
60451
60454
  shape,
60452
60455
  size,
60453
60456
  alt: "Default Avatar",
60454
- style: { backgroundColor }
60457
+ style: { backgroundColor },
60458
+ src: url3,
60459
+ ...rest
60455
60460
  }
60456
60461
  );
60457
60462
  }
@@ -60459,7 +60464,9 @@ const Avatar = ({
60459
60464
  if (user && !user?.image_url) {
60460
60465
  const simpleUser = {
60461
60466
  first_name: parseFirstName(user.first_name),
60462
- last_name: user.last_name
60467
+ last_name: user.last_name,
60468
+ image_url: user.image_url,
60469
+ url: user.url
60463
60470
  };
60464
60471
  const initials = createInitials(simpleUser);
60465
60472
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -60470,6 +60477,7 @@ const Avatar = ({
60470
60477
  size,
60471
60478
  alt: fullName,
60472
60479
  style: { backgroundColor },
60480
+ ...rest,
60473
60481
  children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "white", style: { fontWeight: 600 }, children: initials })
60474
60482
  }
60475
60483
  );
@@ -60481,9 +60489,10 @@ const Avatar = ({
60481
60489
  "data-testid": "avatar",
60482
60490
  shape,
60483
60491
  size,
60484
- src: user?.image_url,
60492
+ src: url3 || user?.image_url,
60485
60493
  alt: fullName,
60486
60494
  style: { backgroundColor },
60495
+ ...rest,
60487
60496
  children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", color: "white", style: { fontWeight: 600 }, children: children2 })
60488
60497
  }
60489
60498
  );
@@ -60491,10 +60500,11 @@ const Avatar = ({
60491
60500
  return /* @__PURE__ */ jsxRuntime.jsx(
60492
60501
  Avatar$1,
60493
60502
  {
60503
+ ...rest,
60494
60504
  "data-testid": "avatar",
60495
60505
  shape,
60496
60506
  size,
60497
- src: user?.image_url,
60507
+ src: url3 || user?.image_url,
60498
60508
  alt: fullName
60499
60509
  }
60500
60510
  );
@@ -81295,10 +81305,12 @@ const OverflowMenu = React.forwardRef(
81295
81305
  className,
81296
81306
  style: style2,
81297
81307
  onItemClick,
81298
- overrideTextColor
81308
+ overrideTextColor,
81309
+ getPopupContainer = () => document.body
81299
81310
  }, ref) => {
81300
81311
  const [internalIsOpen, setInternalIsOpen] = React.useState(false);
81301
81312
  const [isAnimating, setIsAnimating] = React.useState(false);
81313
+ const [triggerRect, setTriggerRect] = React.useState(null);
81302
81314
  const triggerRef = React.useRef(null);
81303
81315
  const menuRef = React.useRef(null);
81304
81316
  const { theme } = useGenesis();
@@ -81326,6 +81338,10 @@ const OverflowMenu = React.forwardRef(
81326
81338
  );
81327
81339
  React.useEffect(() => {
81328
81340
  if (isOpen) {
81341
+ if (getPopupContainer && triggerRef.current) {
81342
+ const rect = triggerRef.current.getBoundingClientRect();
81343
+ setTriggerRect(rect);
81344
+ }
81329
81345
  const timer2 = setTimeout(() => {
81330
81346
  setIsAnimating(true);
81331
81347
  }, 10);
@@ -81336,15 +81352,54 @@ const OverflowMenu = React.forwardRef(
81336
81352
  };
81337
81353
  } else {
81338
81354
  setIsAnimating(false);
81355
+ setTriggerRect(null);
81339
81356
  document.removeEventListener("mousedown", handleClickOutside);
81340
81357
  }
81341
- }, [isOpen, handleClickOutside]);
81358
+ }, [isOpen, handleClickOutside, getPopupContainer]);
81342
81359
  const getMenuStyle = React.useMemo(() => {
81343
81360
  const baseStyle = {
81344
- position: "absolute",
81361
+ position: getPopupContainer ? "fixed" : "absolute",
81345
81362
  zIndex: 1e3,
81346
81363
  ...style2
81347
81364
  };
81365
+ if (getPopupContainer && triggerRect) {
81366
+ const { top, left, right, bottom, width, height } = triggerRect;
81367
+ switch (placement) {
81368
+ case "bottom": {
81369
+ return {
81370
+ ...baseStyle,
81371
+ top: bottom + offset2,
81372
+ ...alignment === "right" ? { right: window.innerWidth - right } : { left }
81373
+ };
81374
+ }
81375
+ case "top": {
81376
+ return {
81377
+ ...baseStyle,
81378
+ bottom: window.innerHeight - top + offset2,
81379
+ ...alignment === "right" ? { right: window.innerWidth - right } : { left }
81380
+ };
81381
+ }
81382
+ case "left": {
81383
+ return {
81384
+ ...baseStyle,
81385
+ top,
81386
+ right: window.innerWidth - left + offset2,
81387
+ ...alignment === "right" ? { bottom: window.innerHeight - bottom } : {}
81388
+ };
81389
+ }
81390
+ case "right": {
81391
+ return {
81392
+ ...baseStyle,
81393
+ top,
81394
+ left: right + offset2,
81395
+ ...alignment === "right" ? { bottom: window.innerHeight - bottom } : {}
81396
+ };
81397
+ }
81398
+ default: {
81399
+ return baseStyle;
81400
+ }
81401
+ }
81402
+ }
81348
81403
  switch (placement) {
81349
81404
  case "bottom": {
81350
81405
  return {
@@ -81380,7 +81435,7 @@ const OverflowMenu = React.forwardRef(
81380
81435
  return baseStyle;
81381
81436
  }
81382
81437
  }
81383
- }, [placement, alignment, offset2, style2]);
81438
+ }, [placement, alignment, offset2, style2, getPopupContainer, triggerRect]);
81384
81439
  const handleItemClick = React.useCallback(
81385
81440
  (item) => {
81386
81441
  onItemClick?.(item);
@@ -81388,6 +81443,25 @@ const OverflowMenu = React.forwardRef(
81388
81443
  },
81389
81444
  [onItemClick, handleOpenChange]
81390
81445
  );
81446
+ const renderMenuContent = (content2) => /* @__PURE__ */ jsxRuntime.jsx(
81447
+ OverflowMenuContainer,
81448
+ {
81449
+ ref: menuRef,
81450
+ theme,
81451
+ className,
81452
+ style: getMenuStyle,
81453
+ $isAnimating: isAnimating,
81454
+ $placement: placement,
81455
+ children: content2
81456
+ }
81457
+ );
81458
+ const renderMenu = (content2) => {
81459
+ if (getPopupContainer && triggerRef.current) {
81460
+ const container = getPopupContainer(triggerRef.current);
81461
+ return ReactDOM.createPortal(renderMenuContent(content2), container);
81462
+ }
81463
+ return renderMenuContent(content2);
81464
+ };
81391
81465
  if (items && items.length > 0) {
81392
81466
  return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { ref, children: [
81393
81467
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: overrideTextColor ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -81396,41 +81470,21 @@ const OverflowMenu = React.forwardRef(
81396
81470
  overrideTextColor
81397
81471
  }
81398
81472
  ) : trigger }),
81399
- isOpen && /* @__PURE__ */ jsxRuntime.jsx(
81400
- OverflowMenuContainer,
81401
- {
81402
- ref: menuRef,
81403
- theme,
81404
- className,
81405
- style: getMenuStyle,
81406
- $isAnimating: isAnimating,
81407
- $placement: placement,
81408
- children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
81409
- OverflowMenuItem,
81410
- {
81411
- ...item,
81412
- onClick: () => handleItemClick(item)
81413
- },
81414
- item.id
81415
- ))
81416
- }
81473
+ isOpen && renderMenu(
81474
+ items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
81475
+ OverflowMenuItem,
81476
+ {
81477
+ ...item,
81478
+ onClick: () => handleItemClick(item)
81479
+ },
81480
+ item.id
81481
+ ))
81417
81482
  )
81418
81483
  ] });
81419
81484
  }
81420
81485
  return /* @__PURE__ */ jsxRuntime.jsxs(OverflowMenuWrapper, { ref, children: [
81421
81486
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: trigger }),
81422
- isOpen && /* @__PURE__ */ jsxRuntime.jsx(
81423
- OverflowMenuContainer,
81424
- {
81425
- ref: menuRef,
81426
- theme,
81427
- className,
81428
- style: getMenuStyle,
81429
- $isAnimating: isAnimating,
81430
- $placement: placement,
81431
- children: children2
81432
- }
81433
- )
81487
+ isOpen && renderMenu(children2)
81434
81488
  ] });
81435
81489
  }
81436
81490
  );
@@ -85163,7 +85217,8 @@ function Table({
85163
85217
  onChange: isInfiniteScroll ? onChange : onChange,
85164
85218
  onRowSelectionChange,
85165
85219
  onDataChange,
85166
- hasBulkSelection
85220
+ hasBulkSelection,
85221
+ filterFn: infiniteScrollConfig.filterFn
85167
85222
  }
85168
85223
  );
85169
85224
  }
package/dist/index.js CHANGED
@@ -60423,7 +60423,10 @@ const Avatar = ({
60423
60423
  shape = "circle",
60424
60424
  children: children2,
60425
60425
  backgroundColor = "#00282B",
60426
- user = null
60426
+ user = null,
60427
+ url: url3,
60428
+ alt,
60429
+ ...rest
60427
60430
  }) => {
60428
60431
  if (!user) {
60429
60432
  return /* @__PURE__ */ jsx(
@@ -60433,7 +60436,9 @@ const Avatar = ({
60433
60436
  shape,
60434
60437
  size,
60435
60438
  alt: "Default Avatar",
60436
- style: { backgroundColor }
60439
+ style: { backgroundColor },
60440
+ src: url3,
60441
+ ...rest
60437
60442
  }
60438
60443
  );
60439
60444
  }
@@ -60441,7 +60446,9 @@ const Avatar = ({
60441
60446
  if (user && !user?.image_url) {
60442
60447
  const simpleUser = {
60443
60448
  first_name: parseFirstName(user.first_name),
60444
- last_name: user.last_name
60449
+ last_name: user.last_name,
60450
+ image_url: user.image_url,
60451
+ url: user.url
60445
60452
  };
60446
60453
  const initials = createInitials(simpleUser);
60447
60454
  return /* @__PURE__ */ jsx(
@@ -60452,6 +60459,7 @@ const Avatar = ({
60452
60459
  size,
60453
60460
  alt: fullName,
60454
60461
  style: { backgroundColor },
60462
+ ...rest,
60455
60463
  children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "white", style: { fontWeight: 600 }, children: initials })
60456
60464
  }
60457
60465
  );
@@ -60463,9 +60471,10 @@ const Avatar = ({
60463
60471
  "data-testid": "avatar",
60464
60472
  shape,
60465
60473
  size,
60466
- src: user?.image_url,
60474
+ src: url3 || user?.image_url,
60467
60475
  alt: fullName,
60468
60476
  style: { backgroundColor },
60477
+ ...rest,
60469
60478
  children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "white", style: { fontWeight: 600 }, children: children2 })
60470
60479
  }
60471
60480
  );
@@ -60473,10 +60482,11 @@ const Avatar = ({
60473
60482
  return /* @__PURE__ */ jsx(
60474
60483
  Avatar$1,
60475
60484
  {
60485
+ ...rest,
60476
60486
  "data-testid": "avatar",
60477
60487
  shape,
60478
60488
  size,
60479
- src: user?.image_url,
60489
+ src: url3 || user?.image_url,
60480
60490
  alt: fullName
60481
60491
  }
60482
60492
  );
@@ -81277,10 +81287,12 @@ const OverflowMenu = forwardRef(
81277
81287
  className,
81278
81288
  style: style2,
81279
81289
  onItemClick,
81280
- overrideTextColor
81290
+ overrideTextColor,
81291
+ getPopupContainer = () => document.body
81281
81292
  }, ref) => {
81282
81293
  const [internalIsOpen, setInternalIsOpen] = useState(false);
81283
81294
  const [isAnimating, setIsAnimating] = useState(false);
81295
+ const [triggerRect, setTriggerRect] = useState(null);
81284
81296
  const triggerRef = useRef(null);
81285
81297
  const menuRef = useRef(null);
81286
81298
  const { theme } = useGenesis();
@@ -81308,6 +81320,10 @@ const OverflowMenu = forwardRef(
81308
81320
  );
81309
81321
  useEffect(() => {
81310
81322
  if (isOpen) {
81323
+ if (getPopupContainer && triggerRef.current) {
81324
+ const rect = triggerRef.current.getBoundingClientRect();
81325
+ setTriggerRect(rect);
81326
+ }
81311
81327
  const timer2 = setTimeout(() => {
81312
81328
  setIsAnimating(true);
81313
81329
  }, 10);
@@ -81318,15 +81334,54 @@ const OverflowMenu = forwardRef(
81318
81334
  };
81319
81335
  } else {
81320
81336
  setIsAnimating(false);
81337
+ setTriggerRect(null);
81321
81338
  document.removeEventListener("mousedown", handleClickOutside);
81322
81339
  }
81323
- }, [isOpen, handleClickOutside]);
81340
+ }, [isOpen, handleClickOutside, getPopupContainer]);
81324
81341
  const getMenuStyle = useMemo$1(() => {
81325
81342
  const baseStyle = {
81326
- position: "absolute",
81343
+ position: getPopupContainer ? "fixed" : "absolute",
81327
81344
  zIndex: 1e3,
81328
81345
  ...style2
81329
81346
  };
81347
+ if (getPopupContainer && triggerRect) {
81348
+ const { top, left, right, bottom, width, height } = triggerRect;
81349
+ switch (placement) {
81350
+ case "bottom": {
81351
+ return {
81352
+ ...baseStyle,
81353
+ top: bottom + offset2,
81354
+ ...alignment === "right" ? { right: window.innerWidth - right } : { left }
81355
+ };
81356
+ }
81357
+ case "top": {
81358
+ return {
81359
+ ...baseStyle,
81360
+ bottom: window.innerHeight - top + offset2,
81361
+ ...alignment === "right" ? { right: window.innerWidth - right } : { left }
81362
+ };
81363
+ }
81364
+ case "left": {
81365
+ return {
81366
+ ...baseStyle,
81367
+ top,
81368
+ right: window.innerWidth - left + offset2,
81369
+ ...alignment === "right" ? { bottom: window.innerHeight - bottom } : {}
81370
+ };
81371
+ }
81372
+ case "right": {
81373
+ return {
81374
+ ...baseStyle,
81375
+ top,
81376
+ left: right + offset2,
81377
+ ...alignment === "right" ? { bottom: window.innerHeight - bottom } : {}
81378
+ };
81379
+ }
81380
+ default: {
81381
+ return baseStyle;
81382
+ }
81383
+ }
81384
+ }
81330
81385
  switch (placement) {
81331
81386
  case "bottom": {
81332
81387
  return {
@@ -81362,7 +81417,7 @@ const OverflowMenu = forwardRef(
81362
81417
  return baseStyle;
81363
81418
  }
81364
81419
  }
81365
- }, [placement, alignment, offset2, style2]);
81420
+ }, [placement, alignment, offset2, style2, getPopupContainer, triggerRect]);
81366
81421
  const handleItemClick = useCallback(
81367
81422
  (item) => {
81368
81423
  onItemClick?.(item);
@@ -81370,6 +81425,25 @@ const OverflowMenu = forwardRef(
81370
81425
  },
81371
81426
  [onItemClick, handleOpenChange]
81372
81427
  );
81428
+ const renderMenuContent = (content2) => /* @__PURE__ */ jsx(
81429
+ OverflowMenuContainer,
81430
+ {
81431
+ ref: menuRef,
81432
+ theme,
81433
+ className,
81434
+ style: getMenuStyle,
81435
+ $isAnimating: isAnimating,
81436
+ $placement: placement,
81437
+ children: content2
81438
+ }
81439
+ );
81440
+ const renderMenu = (content2) => {
81441
+ if (getPopupContainer && triggerRef.current) {
81442
+ const container = getPopupContainer(triggerRef.current);
81443
+ return createPortal(renderMenuContent(content2), container);
81444
+ }
81445
+ return renderMenuContent(content2);
81446
+ };
81373
81447
  if (items && items.length > 0) {
81374
81448
  return /* @__PURE__ */ jsxs(OverflowMenuWrapper, { ref, children: [
81375
81449
  /* @__PURE__ */ jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: overrideTextColor ? /* @__PURE__ */ jsx(
@@ -81378,41 +81452,21 @@ const OverflowMenu = forwardRef(
81378
81452
  overrideTextColor
81379
81453
  }
81380
81454
  ) : trigger }),
81381
- isOpen && /* @__PURE__ */ jsx(
81382
- OverflowMenuContainer,
81383
- {
81384
- ref: menuRef,
81385
- theme,
81386
- className,
81387
- style: getMenuStyle,
81388
- $isAnimating: isAnimating,
81389
- $placement: placement,
81390
- children: items.map((item) => /* @__PURE__ */ jsx(
81391
- OverflowMenuItem,
81392
- {
81393
- ...item,
81394
- onClick: () => handleItemClick(item)
81395
- },
81396
- item.id
81397
- ))
81398
- }
81455
+ isOpen && renderMenu(
81456
+ items.map((item) => /* @__PURE__ */ jsx(
81457
+ OverflowMenuItem,
81458
+ {
81459
+ ...item,
81460
+ onClick: () => handleItemClick(item)
81461
+ },
81462
+ item.id
81463
+ ))
81399
81464
  )
81400
81465
  ] });
81401
81466
  }
81402
81467
  return /* @__PURE__ */ jsxs(OverflowMenuWrapper, { ref, children: [
81403
81468
  /* @__PURE__ */ jsx("div", { ref: triggerRef, onClick: handleTriggerClick, children: trigger }),
81404
- isOpen && /* @__PURE__ */ jsx(
81405
- OverflowMenuContainer,
81406
- {
81407
- ref: menuRef,
81408
- theme,
81409
- className,
81410
- style: getMenuStyle,
81411
- $isAnimating: isAnimating,
81412
- $placement: placement,
81413
- children: children2
81414
- }
81415
- )
81469
+ isOpen && renderMenu(children2)
81416
81470
  ] });
81417
81471
  }
81418
81472
  );
@@ -85145,7 +85199,8 @@ function Table({
85145
85199
  onChange: isInfiniteScroll ? onChange : onChange,
85146
85200
  onRowSelectionChange,
85147
85201
  onDataChange,
85148
- hasBulkSelection
85202
+ hasBulkSelection,
85203
+ filterFn: infiniteScrollConfig.filterFn
85149
85204
  }
85150
85205
  );
85151
85206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.33",
3
+ "version": "0.4.35",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",