UNPKG

@zohodesk/components

Version:

Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development

68 lines (64 loc) 2 kB
import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import LibraryContextInit from "./LibraryContextInit"; import { getLibraryConfig } from "./Config"; const LibraryContextProvider = ({ isReducedMotion, direction, coloredTagVariant, hasTagColorInheritedToText, shouldIndicateSwitchState, shouldStrikeThroughDisabledButton, labelRequiredType, shouldHighlightRequiredLabel, children, buttonComponentVersion }) => { const [value, setValue] = useState({ isReducedMotion, direction, coloredTagVariant, hasTagColorInheritedToText, shouldIndicateSwitchState, shouldStrikeThroughDisabledButton, buttonComponentVersion, labelRequiredType, shouldHighlightRequiredLabel }); function setGlobalContext(key, data) { if (value[key] != data) { setValue({ ...value, [key]: data }); } } return /*#__PURE__*/React.createElement(LibraryContextInit.Provider, { value: { ...value, setGlobalContext } }, children); }; LibraryContextProvider.propTypes = { children: PropTypes.node.isRequired, isReducedMotion: PropTypes.bool, coloredTagVariant: PropTypes.oneOf(['bold', 'subtle', 'minimal']), hasTagColorInheritedToText: PropTypes.bool, direction: PropTypes.string, shouldIndicateSwitchState: PropTypes.bool, shouldStrikeThroughDisabledButton: PropTypes.bool, buttonComponentVersion: PropTypes.oneOf(['default', 'v1']), labelRequiredType: PropTypes.oneOf(['asterisk', 'text']), shouldHighlightRequiredLabel: PropTypes.bool }; LibraryContextProvider.defaultProps = { isReducedMotion: getLibraryConfig('isReducedMotion'), direction: getLibraryConfig('direction'), coloredTagVariant: 'bold', hasTagColorInheritedToText: true, shouldIndicateSwitchState: false, shouldStrikeThroughDisabledButton: false, buttonComponentVersion: 'v1', labelRequiredType: 'asterisk', shouldHighlightRequiredLabel: true }; export default LibraryContextProvider;