@heliosgraphics/ui 2.0.0-alpha.90 → 2.0.0-alpha.92

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.
@@ -1,16 +1,15 @@
1
- import { forwardRef, memo, type ForwardedRef } from "react"
1
+ import { memo } from "react"
2
2
  import { getFlexUtility, getSafeFlexProps } from "../Flex/Flex.utils"
3
3
  import type { FlexProps } from "./Flex.types"
4
4
 
5
- export const Flex = memo(
6
- forwardRef<HTMLDivElement, FlexProps>((props: FlexProps, ref: ForwardedRef<HTMLDivElement>) => {
7
- const flexClasses: string = getFlexUtility(props)
8
- const safeProps = getSafeFlexProps(props)
5
+ export const Flex = memo((props: FlexProps) => {
6
+ const { ref, ...restProps } = props
7
+ const flexClasses: string = getFlexUtility(restProps)
8
+ const safeProps = getSafeFlexProps(restProps)
9
9
 
10
- return (
11
- <div {...safeProps} className={flexClasses} onClick={props.onClick} ref={ref}>
12
- {props.children}
13
- </div>
14
- )
15
- }),
16
- )
10
+ return (
11
+ <div {...safeProps} className={flexClasses} onClick={restProps.onClick} ref={ref}>
12
+ {restProps.children}
13
+ </div>
14
+ )
15
+ })
@@ -1,4 +1,4 @@
1
- import type { HTMLAttributes, MouseEventHandler, PropsWithChildren, ForwardedRef } from "react"
1
+ import type { HTMLAttributes, MouseEventHandler, PropsWithChildren, Ref } from "react"
2
2
  import type { HeliosScaleType, HeliosRadiusType } from "../../types/scale"
3
3
  import type { HeliosEmphasisType } from "../../types/intentions"
4
4
 
@@ -25,7 +25,7 @@ export interface FlexBaseProps {
25
25
  padding?: ResponsiveScaleType
26
26
  paddingX?: HeliosScaleType
27
27
  paddingY?: HeliosScaleType
28
- ref?: ForwardedRef<HTMLDivElement>
28
+ ref?: Ref<HTMLDivElement>
29
29
  withBackground?: HeliosEmphasisType
30
30
  withRadius?: ResponsiveRadiusType
31
31
  xAlign?: "start" | "end" | "center"
@@ -2,7 +2,6 @@
2
2
 
3
3
  import {
4
4
  type FC,
5
- type Ref,
6
5
  useState,
7
6
  useRef,
8
7
  useEffect,
@@ -19,10 +18,6 @@ import { SegmentButton } from "./components/SegmentButton"
19
18
  import type { SegmentsProps } from "./Segments.types"
20
19
  import type { SegmentButtonProps } from "./components/SegmentButton/SegmentButton.types"
21
20
 
22
- type SegmentButtonWithRef = SegmentButtonProps & {
23
- ref?: Ref<HTMLButtonElement>
24
- }
25
-
26
21
  export const Segments: FC<SegmentsProps> = ({ children, isFullWidth, isSmall }) => {
27
22
  const validChildren: ReactElement<SegmentButtonProps>[] = Children.toArray(children).filter(
28
23
  (child): child is ReactElement<SegmentButtonProps> => isValidElement(child) && child.type === SegmentButton,
@@ -74,7 +69,7 @@ export const Segments: FC<SegmentsProps> = ({ children, isFullWidth, isSmall })
74
69
  return (
75
70
  <Flex className={segmentedControlClasses} isYCentered={true} gap={2} isInline={!isFullWidth} ref={containerRef}>
76
71
  {validChildren.map((child: ReactElement<SegmentButtonProps>, index: number) =>
77
- cloneElement<SegmentButtonWithRef>(child, {
72
+ cloneElement<SegmentButtonProps>(child, {
78
73
  key: child.props.value,
79
74
  isActive: child.props.value === activeValue,
80
75
  onClick: () => {
@@ -26,6 +26,10 @@ export const meta: HeliosAttributeMeta<SegmentButtonProps> = {
26
26
  type: "() => void",
27
27
  isOptional: true,
28
28
  },
29
+ ref: {
30
+ type: "Ref<HTMLButtonElement>",
31
+ isOptional: true,
32
+ },
29
33
  value: {
30
34
  type: "string",
31
35
  },
@@ -1,24 +1,21 @@
1
1
  import styles from "./SegmentButton.module.css"
2
- import { forwardRef } from "react"
3
2
  import { getClasses } from "@heliosgraphics/utils"
4
3
  import { Icon } from "../../../Icon"
5
4
  import type { HeliosIconType } from "../../../../types/icons"
6
5
  import type { SegmentButtonProps } from "./SegmentButton.types"
7
6
 
8
- export const SegmentButton = forwardRef<HTMLButtonElement, SegmentButtonProps>(
9
- ({ isActive, value, icon, iconLeft, iconRight, onClick }, ref) => {
10
- const segmentButtonClasses: string = getClasses(styles.segmentButton, {
11
- [styles.segmentButtonActive]: isActive,
12
- })
7
+ export const SegmentButton = ({ isActive, value, icon, iconLeft, iconRight, onClick, ref }: SegmentButtonProps) => {
8
+ const segmentButtonClasses: string = getClasses(styles.segmentButton, {
9
+ [styles.segmentButtonActive]: isActive,
10
+ })
13
11
 
14
- const iconL: HeliosIconType | undefined = iconLeft || icon
12
+ const iconL: HeliosIconType | undefined = iconLeft || icon
15
13
 
16
- return (
17
- <button ref={ref} className={segmentButtonClasses} onClick={onClick} data-ui-component="SegmentButton">
18
- {iconL && <Icon icon={iconL} size={16} />}
19
- {value}
20
- {iconRight && <Icon icon={iconRight} size={16} />}
21
- </button>
22
- )
23
- },
24
- )
14
+ return (
15
+ <button ref={ref} className={segmentButtonClasses} onClick={onClick} data-ui-component="SegmentButton">
16
+ {iconL && <Icon icon={iconL} size={16} />}
17
+ {value}
18
+ {iconRight && <Icon icon={iconRight} size={16} />}
19
+ </button>
20
+ )
21
+ }
@@ -1,3 +1,4 @@
1
+ import type { Ref } from "react"
1
2
  import type { HeliosIconType } from "../../../../types/icons"
2
3
 
3
4
  export interface SegmentButtonProps {
@@ -6,5 +7,6 @@ export interface SegmentButtonProps {
6
7
  iconRight?: HeliosIconType
7
8
  isActive?: boolean
8
9
  onClick?: () => void
10
+ ref?: Ref<HTMLButtonElement>
9
11
  value: string
10
12
  }
@@ -13,4 +13,8 @@ export const meta: HeliosAttributeMeta<ResultListProps> = {
13
13
  type: "boolean",
14
14
  isOptional: true,
15
15
  },
16
+ ref: {
17
+ type: "Ref<HTMLOListElement>",
18
+ isOptional: true,
19
+ },
16
20
  }
@@ -4,11 +4,10 @@ import { Flex } from "../../Flex"
4
4
  import { Icon } from "../../Icon"
5
5
  import { Text } from "../../Text"
6
6
  import styles from "./ResultList.module.css"
7
- import { forwardRef } from "react"
8
7
  import type { ChangeEvent } from "react"
9
8
  import type { ResultListProps } from "./ResultList.types"
10
9
 
11
- export const ResultList = forwardRef<HTMLOListElement, ResultListProps>(({ items, isHidden }, ref) => {
10
+ export const ResultList = ({ items, isHidden, ref }: ResultListProps) => {
12
11
  if (!items?.length || isHidden) return null
13
12
 
14
13
  const resultListClasses: string = getClasses(styles.resultList, "elevation-lg")
@@ -63,4 +62,4 @@ export const ResultList = forwardRef<HTMLOListElement, ResultListProps>(({ items
63
62
  })}
64
63
  </ol>
65
64
  )
66
- })
65
+ }
@@ -15,4 +15,5 @@ export interface ResultItem {
15
15
  export interface ResultListProps {
16
16
  items?: Array<ResultItem>
17
17
  isHidden?: boolean
18
+ ref?: Ref<HTMLOListElement>
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliosgraphics/ui",
3
- "version": "2.0.0-alpha.90",
3
+ "version": "2.0.0-alpha.92",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "author": "Chris Puska <chris@puska.org>",
File without changes
File without changes
File without changes
File without changes
File without changes