How to use the @ui5/webcomponents-react-base/lib/useConsolidatedRef.useConsolidatedRef function in @ui5/webcomponents-react-base

To help you get started, we’ve selected a few @ui5/webcomponents-react-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / ui5-webcomponents-react / packages / charts / src / components / LineChart / index.tsx View on Github external
label: formatTooltipLabel(categoryAxisFormatter, valueAxisFormatter)
        }
      },
      plugins: {
        datalabels: {
          formatter: formatDataLabel(valueAxisFormatter)
        }
      }
    };
  }, [categoryAxisFormatter, valueAxisFormatter]);
  const chartOptions = useMergedConfig(lineChartDefaultConfig, options);

  const theme: any = useTheme();
  const data = useChartData(labels, datasets, colors, theme.theme);

  const chartRef = useConsolidatedRef(ref);
  const handleLegendItemPress = useLegendItemClickHandler(chartRef, legendRef);
  useLegend(chartRef, legendRef, noLegend, handleLegendItemPress);

  return (
github SAP / ui5-webcomponents-react / packages / main / src / webComponents / Dialog / index.tsx View on Github external
(props: DialogPropTypes, dialogRef: RefObject) => {
    const localDialogRef = useConsolidatedRef(dialogRef);

    const setDialogOpen = (open) => {
      if (!localDialogRef.current || !localDialogRef.current.open) {
        return;
      }
      return open ? localDialogRef.current.open() : localDialogRef.current.close();
    };

    useEffect(() => {
      setDialogOpen(props.open);
    }, [props.open]);

    return ;
  }
);
github SAP / ui5-webcomponents-react / packages / charts / src / components / DonutChart / index.tsx View on Github external
}
      },
      plugins: {
        datalabels: {
          anchor: 'end',
          align: 'end',
          color: getCssVariableValue('--sapUiBaseText', '#32363a'),
          formatter: formatDataLabel(valueAxisFormatter)
        }
      }
    };
  }, [categoryAxisFormatter, valueAxisFormatter]);

  const mergedOptions = useMergedConfig(donutChartDefaultConfig, options);

  const chartRef = useConsolidatedRef(ref);

  const handleLegendItemPress = usePieLegendItemClickHandler(chartRef, legendRef);
  useLegend(chartRef, legendRef, noLegend, handleLegendItemPress);

  return (
    
  );
});
github SAP / ui5-webcomponents-react / packages / main / src / components / ObjectPageSubSection / index.tsx View on Github external
(props: ObjectPageSubSectionPropTypes, ref: RefObject) => {
    const { children, id, title, className, style, tooltip } = props;

    if (!id) {
      throw new EmptyIdPropException('ObjectPageSubSection requires a unique ID property!');
    }

    const htmlRef: RefObject = useConsolidatedRef(ref);
    const htmlId = `ObjectPageSubSection-${id}`;

    useScrollElement(htmlId, htmlRef, {
      spy: false
    });

    const classes = useStyles();
    const subSectionClassName = StyleClassHelper.of(classes.objectPageSubSection);
    if (className) {
      subSectionClassName.put(className);
    }

    return (
github SAP / ui5-webcomponents-react / packages / main / src / components / ActionSheet / index.tsx View on Github external
(props: ActionSheetPropTypes, ref: RefObject) => {
    const { children, placement, openBy, style, slot } = props;

    const classes = useStyles();

    const actionSheetClasses = StyleClassHelper.of(classes.actionSheet);
    if (Device.system.tablet) {
      actionSheetClasses.put(classes.tablet);
    } else if (Device.system.phone) {
      actionSheetClasses.put(classes.phone);
    }

    const popoverRef: RefObject = useConsolidatedRef(ref);

    const renderActionSheetButton = (element) => {
      if (element && element.props) {
        return (
          <div>
            {cloneElement(element, {
              design: ButtonDesign.Transparent,
              onClick: onActionButtonClicked(element.props.onClick)
            })}
          </div>
        );
      }
      return element;
    };

    const onActionButtonClicked = (handler) =&gt; () =&gt; {
github SAP / ui5-webcomponents-react / packages / main / src / webComponents / Popover / index.tsx View on Github external
(props: PopoverPropTypes, givenRef: RefObject) =&gt; {
    const { propagateOpenByClickEvent, openBy, openByStyle, open, ...rest } = props;

    const openByRef: RefObject = useRef(null);

    const internalPopoverRef = useConsolidatedRef(givenRef);

    const handleOpenPopover = useCallback(
      (e) =&gt; {
        internalPopoverRef.current.openBy &amp;&amp; internalPopoverRef.current.openBy(openByRef.current);
        if (e &amp;&amp; !propagateOpenByClickEvent) {
          e.stopPropagation();
        }
      },
      [internalPopoverRef, openByRef]
    );

    const closePopover = useCallback(() =&gt; {
      internalPopoverRef.current.close &amp;&amp; internalPopoverRef.current.close();
    }, [internalPopoverRef]);

    useEffect(() =&gt; {
github SAP / ui5-webcomponents-react / packages / main / src / components / ObjectPage / index.tsx View on Github external
const theme = useTheme();

  const objectPage: RefObject = useConsolidatedRef(ref);
  const fillerDivDomRef: RefObject = useRef();
  const scrollBar: RefObject = useRef();
  const contentContainer: RefObject = useRef();
  const topHeader: RefObject = useRef();
  const innerHeader: RefObject = useRef();
  const innerScrollBar: RefObject = useRef();
  const contentScrollContainer: RefObject = useRef();
  const collapsedHeaderFiller: RefObject = useRef();
  const lastScrolledContainer = useRef();
  const hideHeaderButtonPressed = useRef(false);
  const stableContentOnScrollRef = useRef(null);
  const stableBarOnScrollRef = useRef(null);
  const scroller = useConsolidatedRef(scrollerRef);
  const [scrollbarWidth, setScrollbarWidth] = useState(defaultScrollbarWidth);

  const classes = useStyles();

  const setScrollbarHeight = () =&gt; {
    requestAnimationFrame(() =&gt; {
      const scrollbarContainerHeight =
        contentScrollContainer.current.getBoundingClientRect().height +
        topHeader.current.getBoundingClientRect().height;
      innerScrollBar.current.style.height = `${scrollbarContainerHeight}px`;
    });
  };

  useEffect(() =&gt; {
    let selectedIndex = findSectionIndexById(children, selectedSectionId);
    if (selectedIndex === -1) {
github SAP / ui5-webcomponents-react / packages / main / src / components / SegmentedButton / index.tsx View on Github external
(props: SegmentedButtonPropTypes, ref: Ref) =&gt; {
    const { children, disabled, className, style, tooltip, slot, onItemSelected, selectedKey } = props;

    const listRef: RefObject = useConsolidatedRef(ref);

    const [internalSelectedKey, setSelectedKey] = useState(() =&gt; {
      if (selectedKey) return selectedKey;
      const firstChild: any = Children.toArray(children)[0];
      if (firstChild &amp;&amp; firstChild.props) {
        return firstChild.props.id;
      }
      return null;
    });

    useEffect(() =&gt; {
      if (selectedKey) {
        setSelectedKey(selectedKey);
      }
    }, [selectedKey, setSelectedKey]);
github SAP / ui5-webcomponents-react / packages / charts / src / components / BarChart / index.tsx View on Github external
options,
    categoryAxisFormatter,
    valueAxisFormatter,
    getDatasetAtEvent,
    getElementAtEvent,
    colors,
    width,
    height,
    noLegend,
    legendRef
  } = props as BarChartPropTypes &amp; InternalProps;

  const theme: any = useTheme();
  const data = useChartData(labels, datasets, colors, theme.theme);

  const chartRef = useConsolidatedRef(ref);

  const barChartDefaultConfig = useMemo(() =&gt; {
    return {
      scales: {
        xAxes: [
          {
            ...DEFAULT_OPTIONS.scales.yAxes[0],
            ticks: {
              callback: formatAxisCallback(valueAxisFormatter)
            }
          }
        ],
        yAxes: [
          {
            ...DEFAULT_OPTIONS.scales.xAxes[0],
            ticks: {
github SAP / ui5-webcomponents-react / packages / charts / src / components / PieChart / index.tsx View on Github external
plugins: {
        datalabels: {
          anchor: 'end',
          align: 'end',
          color: getCssVariableValue('--sapUiBaseText', '#32363a'),
          formatter: (val, context) =&gt; {
            return valueAxisFormatter(val, context.dataset, context);
          }
        }
      }
    };
  }, [categoryAxisFormatter, valueAxisFormatter]);

  const mergedOptions = useMergedConfig(pieChartDefaultConfig, options);

  const chartRef = useConsolidatedRef(ref);

  const handleLegendItemPress = usePieLegendItemClickHandler(chartRef, legendRef);
  useLegend(chartRef, legendRef, noLegend, handleLegendItemPress);

  return (
    
  );
});