@redsift/design-system 11.6.0-muiv5-alpha.2 → 11.6.0-muiv5-alpha.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.
- package/components/alert/Alert.js +8 -8
- package/components/alert/Alert.js.map +1 -1
- package/components/app-bar/AppBar.js +11 -11
- package/components/app-bar/AppBar.js.map +1 -1
- package/components/app-container/AppContainer.js +16 -16
- package/components/app-container/AppContainer.js.map +1 -1
- package/components/app-container/context.js +2 -2
- package/components/app-container/context.js.map +1 -1
- package/components/app-content/AppContent.js +2 -2
- package/components/app-content/AppContent.js.map +1 -1
- package/components/app-side-panel/AppSidePanel.js +8 -8
- package/components/app-side-panel/AppSidePanel.js.map +1 -1
- package/components/app-side-panel/useAppSidePanel.js +2 -2
- package/components/app-side-panel/useAppSidePanel.js.map +1 -1
- package/components/badge/Badge.js +2 -2
- package/components/badge/Badge.js.map +1 -1
- package/components/breadcrumb-item/BreadcrumbItem.js +2 -2
- package/components/breadcrumb-item/BreadcrumbItem.js.map +1 -1
- package/components/breadcrumbs/Breadcrumbs.js +7 -7
- package/components/breadcrumbs/Breadcrumbs.js.map +1 -1
- package/components/button/Button.js +7 -7
- package/components/button/Button.js.map +1 -1
- package/components/button-group/ButtonGroup.js +4 -4
- package/components/button-group/ButtonGroup.js.map +1 -1
- package/components/button-link/ButtonLink.js +6 -6
- package/components/button-link/ButtonLink.js.map +1 -1
- package/components/card/Card.js +7 -7
- package/components/card/Card.js.map +1 -1
- package/components/card-actions/CardActions.js +2 -2
- package/components/card-actions/CardActions.js.map +1 -1
- package/components/card-body/CardBody.js +2 -2
- package/components/card-body/CardBody.js.map +1 -1
- package/components/card-header/CardHeader.js +7 -7
- package/components/card-header/CardHeader.js.map +1 -1
- package/components/checkbox/Checkbox.js +7 -7
- package/components/checkbox/Checkbox.js.map +1 -1
- package/components/checkbox-group/CheckboxGroup.js +7 -7
- package/components/checkbox-group/CheckboxGroup.js.map +1 -1
- package/components/checkbox-group/context.js +2 -2
- package/components/checkbox-group/context.js.map +1 -1
- package/components/conditional-wrapper/ConditionalWrapper.js +2 -2
- package/components/conditional-wrapper/ConditionalWrapper.js.map +1 -1
- package/components/detailed-card/DetailedCard.js +20 -20
- package/components/detailed-card/DetailedCard.js.map +1 -1
- package/components/detailed-card/types.d.ts +10 -1
- package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js +3 -3
- package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js.map +1 -1
- package/components/detailed-card-header/DetailedCardHeader.js +4 -4
- package/components/detailed-card-header/DetailedCardHeader.js.map +1 -1
- package/components/detailed-card-section/DetailedCardSection.js +10 -10
- package/components/detailed-card-section/DetailedCardSection.js.map +1 -1
- package/components/detailed-card-section-item/DetailedCardSectionItem.js +12 -12
- package/components/detailed-card-section-item/DetailedCardSectionItem.js.map +1 -1
- package/components/flexbox/Flexbox.js +3 -3
- package/components/flexbox/Flexbox.js.map +1 -1
- package/components/focus-within-group/FocusWithinGroup.js +2 -2
- package/components/focus-within-group/FocusWithinGroup.js.map +1 -1
- package/components/focus-within-group/context.js +2 -2
- package/components/focus-within-group/context.js.map +1 -1
- package/components/grid/Grid.js +3 -3
- package/components/grid/Grid.js.map +1 -1
- package/components/grid-item/GridItem.js +2 -2
- package/components/grid-item/GridItem.js.map +1 -1
- package/components/heading/Heading.js +2 -2
- package/components/heading/Heading.js.map +1 -1
- package/components/icon/Icon.js +5 -5
- package/components/icon/Icon.js.map +1 -1
- package/components/icon-button/IconButton.js +6 -6
- package/components/icon-button/IconButton.js.map +1 -1
- package/components/icon-button-link/IconButtonLink.js +5 -5
- package/components/icon-button-link/IconButtonLink.js.map +1 -1
- package/components/item/Item.js +19 -19
- package/components/item/Item.js.map +1 -1
- package/components/link/Link.js +5 -5
- package/components/link/Link.js.map +1 -1
- package/components/link-button/LinkButton.js +5 -5
- package/components/link-button/LinkButton.js.map +1 -1
- package/components/listbox/ActiveDescendantListbox.d.ts +1 -1
- package/components/listbox/ActiveDescendantListbox.js +3 -3
- package/components/listbox/ActiveDescendantListbox.js.map +1 -1
- package/components/listbox/Listbox.js +8 -8
- package/components/listbox/Listbox.js.map +1 -1
- package/components/listbox/RovingTabindexListbox.d.ts +1 -1
- package/components/listbox/RovingTabindexListbox.js +3 -3
- package/components/listbox/RovingTabindexListbox.js.map +1 -1
- package/components/listbox/context.js +2 -2
- package/components/listbox/context.js.map +1 -1
- package/components/number/Number.js +2 -2
- package/components/number/Number.js.map +1 -1
- package/components/number-field/NumberField.js +16 -16
- package/components/number-field/NumberField.js.map +1 -1
- package/components/pill/Pill.js +10 -10
- package/components/pill/Pill.js.map +1 -1
- package/components/progress-bar/ProgressBar.js +2 -2
- package/components/progress-bar/ProgressBar.js.map +1 -1
- package/components/radio/Radio.js +6 -6
- package/components/radio/Radio.js.map +1 -1
- package/components/radio-group/RadioGroup.js +7 -7
- package/components/radio-group/RadioGroup.js.map +1 -1
- package/components/radio-group/context.js +2 -2
- package/components/radio-group/context.js.map +1 -1
- package/components/shield/Shield.js +5 -5
- package/components/shield/Shield.js.map +1 -1
- package/components/side-navigation-menu/SideNavigationMenu.js +16 -16
- package/components/side-navigation-menu/SideNavigationMenu.js.map +1 -1
- package/components/side-navigation-menu/context.js +2 -2
- package/components/side-navigation-menu/context.js.map +1 -1
- package/components/side-navigation-menu-bar/SideNavigationMenuBar.js +7 -7
- package/components/side-navigation-menu-bar/SideNavigationMenuBar.js.map +1 -1
- package/components/side-navigation-menu-bar/context.js +2 -2
- package/components/side-navigation-menu-bar/context.js.map +1 -1
- package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js +4 -4
- package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js.map +1 -1
- package/components/side-navigation-menu-item/SideNavigationMenuItem.js +9 -9
- package/components/side-navigation-menu-item/SideNavigationMenuItem.js.map +1 -1
- package/components/skeleton/Skeleton.js +4 -4
- package/components/skeleton/Skeleton.js.map +1 -1
- package/components/skeleton-circle/SkeletonCircle.js +4 -4
- package/components/skeleton-circle/SkeletonCircle.js.map +1 -1
- package/components/skeleton-text/SkeletonText.js +4 -4
- package/components/skeleton-text/SkeletonText.js.map +1 -1
- package/components/spinner/Spinner.js +2 -2
- package/components/spinner/Spinner.js.map +1 -1
- package/components/switch/Switch.js +9 -9
- package/components/switch/Switch.js.map +1 -1
- package/components/switch-group/SwitchGroup.js +7 -7
- package/components/switch-group/SwitchGroup.js.map +1 -1
- package/components/switch-group/context.js +2 -2
- package/components/switch-group/context.js.map +1 -1
- package/components/text/Text.js +2 -2
- package/components/text/Text.js.map +1 -1
- package/components/text-area/TextArea.js +11 -11
- package/components/text-area/TextArea.js.map +1 -1
- package/components/text-field/TextField.js +13 -13
- package/components/text-field/TextField.js.map +1 -1
- package/components/theme/context.js +2 -2
- package/components/theme/context.js.map +1 -1
- package/package.json +6 -2
- package/react-aria/react-aria/focus/useFocusable.js +2 -2
- package/react-aria/react-aria/focus/useFocusable.js.map +1 -1
- package/react-aria/react-aria/i18n/context.js +4 -4
- package/react-aria/react-aria/i18n/context.js.map +1 -1
- package/react-aria/react-aria/interactions/context.js +2 -2
- package/react-aria/react-aria/interactions/context.js.map +1 -1
- package/react-aria/react-aria/ssr/SSRProvider.js +13 -13
- package/react-aria/react-aria/ssr/SSRProvider.js.map +1 -1
- package/react-aria/react-aria/utils/mergeProps.js +2 -2
- package/react-aria/react-aria/utils/mergeProps.js.map +1 -1
- package/react-aria/react-aria/utils/useLayoutEffect.js +2 -2
- package/react-aria/react-aria/utils/useLayoutEffect.js.map +1 -1
- package/utils/filterComponents.js +2 -2
- package/utils/filterComponents.js.map +1 -1
- package/utils/isComponent.js +2 -2
- package/utils/isComponent.js.map +1 -1
- package/utils/useId.js +4 -4
- package/utils/useId.js.map +1 -1
- package/_virtual/jsx-runtime.js +0 -4
- package/_virtual/jsx-runtime.js.map +0 -1
- package/_virtual/react-jsx-runtime.development.js +0 -4
- package/_virtual/react-jsx-runtime.development.js.map +0 -1
- package/_virtual/react-jsx-runtime.production.min.js +0 -4
- package/_virtual/react-jsx-runtime.production.min.js.map +0 -1
- package/packages/popovers/src/components/tooltip/Tooltip.js +0 -62
- package/packages/popovers/src/components/tooltip/Tooltip.js.map +0 -1
- package/packages/popovers/src/components/tooltip/context.js +0 -6
- package/packages/popovers/src/components/tooltip/context.js.map +0 -1
- package/packages/popovers/src/components/tooltip/types.js +0 -28
- package/packages/popovers/src/components/tooltip/types.js.map +0 -1
- package/packages/popovers/src/components/tooltip/useTooltip.js +0 -78
- package/packages/popovers/src/components/tooltip/useTooltip.js.map +0 -1
- package/packages/popovers/src/components/tooltip/useTooltipContext.js +0 -13
- package/packages/popovers/src/components/tooltip/useTooltipContext.js.map +0 -1
- package/packages/popovers/src/components/tooltip-content/TooltipContent.js +0 -80
- package/packages/popovers/src/components/tooltip-content/TooltipContent.js.map +0 -1
- package/packages/popovers/src/components/tooltip-content/styles.js +0 -128
- package/packages/popovers/src/components/tooltip-content/styles.js.map +0 -1
- package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js +0 -47
- package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef, useRef, useContext, useState, useEffect } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound.js';
|
|
5
5
|
import { SideNavigationMenuBarContext } from '../side-navigation-menu-bar/context.js';
|
|
@@ -67,15 +67,15 @@ const SideNavigationMenuItem = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
67
67
|
};
|
|
68
68
|
}, [menuItems]);
|
|
69
69
|
const sideNavigationVariant = sideNavigationMenuBarContext === null || sideNavigationMenuBarContext === void 0 ? void 0 : sideNavigationMenuBarContext.sideNavigationMenuBarVariant;
|
|
70
|
-
return /*#__PURE__*/
|
|
70
|
+
return /*#__PURE__*/React.createElement(Flexbox, {
|
|
71
71
|
flexDirection: "column",
|
|
72
72
|
gap: "0px"
|
|
73
|
-
}, /*#__PURE__*/
|
|
73
|
+
}, /*#__PURE__*/React.createElement(Flexbox, {
|
|
74
74
|
flexDirection: "row",
|
|
75
75
|
gap: "0px"
|
|
76
|
-
}, !isSecondLevel ? /*#__PURE__*/
|
|
76
|
+
}, !isSecondLevel ? /*#__PURE__*/React.createElement(StyledSideNavigationMenuItemIndicatorContainer, null, isCurrent ? /*#__PURE__*/React.createElement(StyledSideNavigationMenuItemIndicator, {
|
|
77
77
|
$theme: theme
|
|
78
|
-
}) : null) : null, /*#__PURE__*/
|
|
78
|
+
}) : null) : null, /*#__PURE__*/React.createElement(StyledSideNavigationMenuItem, _extends({
|
|
79
79
|
as: as,
|
|
80
80
|
role: "menuitem"
|
|
81
81
|
}, forwardedProps, {
|
|
@@ -94,19 +94,19 @@ const SideNavigationMenuItem = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
94
94
|
onKeyDown: isDisabled ? undefined : onKeyDown,
|
|
95
95
|
ref: menuItemRef,
|
|
96
96
|
tabIndex: tabIndex !== undefined ? tabIndex : !sideNavigationMenuContext && isFirstChild ? 0 : -1
|
|
97
|
-
}), !isSecondLevel || icon ? /*#__PURE__*/
|
|
97
|
+
}), !isSecondLevel || icon ? /*#__PURE__*/React.createElement(Icon, _extends({
|
|
98
98
|
color: `var(--redsift-side-navigation-color-menu-item-text-${isSecondLevel || isDisabled ? 'disabled' : 'resting'})`
|
|
99
99
|
}, iconProps, {
|
|
100
100
|
icon: icon,
|
|
101
101
|
ref: iconRef,
|
|
102
102
|
className: "first",
|
|
103
103
|
size: isSecondLevel ? IconSize.small : IconSize.medium
|
|
104
|
-
})) : null, /*#__PURE__*/
|
|
104
|
+
})) : null, /*#__PURE__*/React.createElement("span", {
|
|
105
105
|
className: "content"
|
|
106
|
-
}, children), badge ? /*#__PURE__*/
|
|
106
|
+
}, children), badge ? /*#__PURE__*/React.createElement(Badge, _extends({
|
|
107
107
|
variant: BadgeVariant.standard,
|
|
108
108
|
color: "error"
|
|
109
|
-
}, badgeProps), badge) : null)), isSecondLevel && hasBorder ? /*#__PURE__*/
|
|
109
|
+
}, badgeProps), badge) : null)), isSecondLevel && hasBorder ? /*#__PURE__*/React.createElement(StyledSideNavigationMenuItemBorder, null) : null);
|
|
110
110
|
});
|
|
111
111
|
SideNavigationMenuItem.className = CLASSNAME;
|
|
112
112
|
SideNavigationMenuItem.displayName = COMPONENT_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNavigationMenuItem.js","sources":["../../../src/components/side-navigation-menu-item/SideNavigationMenuItem.tsx"],"sourcesContent":["import React, { forwardRef, MutableRefObject, useContext, useEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { Comp } from '../../types';\nimport { Icon, IconSize } from '../icon';\nimport { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound';\nimport { SideNavigationMenuBarContext } from '../side-navigation-menu-bar/context';\nimport { SideNavigationMenuContext } from '../side-navigation-menu/context';\nimport {\n StyledSideNavigationMenuItem,\n StyledSideNavigationMenuItemBorder,\n StyledSideNavigationMenuItemIndicator,\n StyledSideNavigationMenuItemIndicatorContainer,\n} from './styles';\nimport { SideNavigationMenuItemProps } from './types';\nimport { Badge, BadgeVariant } from '../badge';\nimport { Flexbox } from '../flexbox';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SideNavigationMenuItem';\nconst CLASSNAME = 'redsift-side-navigation-menu-item';\n\n/**\n * The SideNavigationMenuItem component.\n */\nexport const SideNavigationMenuItem: Comp<SideNavigationMenuItemProps, HTMLAnchorElement> = forwardRef((props, ref) => {\n const menuItemRef = ref || useRef<HTMLAnchorElement>();\n\n const {\n as,\n badge,\n badgeProps,\n children,\n className,\n color,\n hasBorder,\n href,\n icon,\n iconProps,\n iconRef = useRef<HTMLElement>(),\n isCurrent,\n isDisabled,\n isSecondLevel,\n onClick,\n onKeyDown,\n tabIndex,\n theme: propsTheme,\n ...forwardedProps\n } = props;\n\n warnIfNoAccessibleLabelFound(props, [children], 'SideNavigationMenuItem');\n\n const sideNavigationMenuBarContext = useContext(SideNavigationMenuBarContext);\n const sideNavigationMenuContext = useContext(SideNavigationMenuContext);\n const theme = useTheme(propsTheme);\n\n const [isFirstChild, setIsFirstChild] = useState(false);\n const { menuItems } = sideNavigationMenuContext || sideNavigationMenuBarContext || {};\n\n useEffect(() => {\n if (!(sideNavigationMenuContext || sideNavigationMenuBarContext)) {\n setIsFirstChild(true);\n return;\n }\n\n const menuItemNode = (menuItemRef as MutableRefObject<HTMLAnchorElement>).current;\n\n if (menuItemNode) {\n if (!menuItems.size) {\n setIsFirstChild(true);\n }\n\n menuItems.add(menuItemNode);\n }\n\n return () => {\n menuItems.delete(menuItemNode);\n };\n }, [menuItems]);\n\n const sideNavigationVariant = sideNavigationMenuBarContext?.sideNavigationMenuBarVariant;\n\n return (\n <Flexbox flexDirection=\"column\" gap=\"0px\">\n <Flexbox flexDirection=\"row\" gap=\"0px\">\n {!isSecondLevel ? (\n <StyledSideNavigationMenuItemIndicatorContainer>\n {isCurrent ? <StyledSideNavigationMenuItemIndicator $theme={theme} /> : null}\n </StyledSideNavigationMenuItemIndicatorContainer>\n ) : null}\n <StyledSideNavigationMenuItem\n as={as as any}\n role=\"menuitem\"\n {...forwardedProps}\n $color={color}\n $hasIcon={icon !== undefined}\n $isCurrent={isCurrent}\n $isDisabled={isDisabled}\n $isSecondLevel={isSecondLevel}\n $theme={theme}\n $variant={sideNavigationVariant}\n aria-current={isCurrent ? 'page' : undefined}\n aria-disabled={isDisabled}\n className={classNames(SideNavigationMenuItem.className, className)}\n href={!isDisabled ? href : undefined}\n onClick={isDisabled ? undefined : onClick}\n onKeyDown={isDisabled ? undefined : onKeyDown}\n ref={menuItemRef as MutableRefObject<HTMLAnchorElement>}\n tabIndex={tabIndex !== undefined ? tabIndex : !sideNavigationMenuContext && isFirstChild ? 0 : -1}\n >\n {!isSecondLevel || icon ? (\n <Icon\n color={`var(--redsift-side-navigation-color-menu-item-text-${\n isSecondLevel || isDisabled ? 'disabled' : 'resting'\n })`}\n {...iconProps}\n icon={icon!}\n ref={iconRef as MutableRefObject<HTMLElement>}\n className=\"first\"\n size={isSecondLevel ? IconSize.small : IconSize.medium}\n />\n ) : null}\n <span className=\"content\">{children}</span>\n {badge ? (\n <Badge variant={BadgeVariant.standard} color=\"error\" {...badgeProps}>\n {badge}\n </Badge>\n ) : null}\n </StyledSideNavigationMenuItem>\n </Flexbox>\n {isSecondLevel && hasBorder ? <StyledSideNavigationMenuItemBorder /> : null}\n </Flexbox>\n );\n});\nSideNavigationMenuItem.className = CLASSNAME;\nSideNavigationMenuItem.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SideNavigationMenuItem","forwardRef","props","ref","menuItemRef","useRef","as","badge","badgeProps","children","className","color","hasBorder","href","icon","iconProps","iconRef","isCurrent","isDisabled","isSecondLevel","onClick","onKeyDown","tabIndex","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","warnIfNoAccessibleLabelFound","sideNavigationMenuBarContext","useContext","SideNavigationMenuBarContext","sideNavigationMenuContext","SideNavigationMenuContext","useTheme","isFirstChild","setIsFirstChild","useState","menuItems","useEffect","menuItemNode","current","size","add","delete","sideNavigationVariant","sideNavigationMenuBarVariant","React","createElement","Flexbox","flexDirection","gap","StyledSideNavigationMenuItemIndicatorContainer","StyledSideNavigationMenuItemIndicator","$theme","StyledSideNavigationMenuItem","_extends","role","$color","$hasIcon","undefined","$isCurrent","$isDisabled","$isSecondLevel","$variant","classNames","Icon","IconSize","small","medium","Badge","variant","BadgeVariant","standard","StyledSideNavigationMenuItemBorder","displayName"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,wBAAwB,CAAA;AAC/C,MA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O,CAAA;AAEjF,IAAA,IAAID,YAAY,EAAE;AAChB,MAAA,IAAI,CAACF,SAAS,CAACI,IAAI,EAAE;QACnBN,eAAe,CAAC,IAAI,CAAC,CAAA;AACvB,OAAA;AAEAE,MAAAA,SAAS,CAACK,GAAG,CAACH,YAAY,CAAC,CAAA;AAC7B,KAAA;AAEA,IAAA,OAAO,MAAM;AACXF,MAAAA,SAAS,CAACM,MAAM,CAACJ,YAAY,CAAC,CAAA;KAC/B,CAAA;AACH,GAAC,EAAE,CAACF,SAAS,CAAC,CAAC,CAAA;EAEf,MAAMO,qBAAqB,GAAGhB,4BAA4B,KAAA,IAAA,IAA5BA,4BAA4B,KAA5BA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,4BAA4B,CAAEiB,4BAA4B,CAAA;AAExF,EAAA,oBACEC,
|
|
1
|
+
{"version":3,"file":"SideNavigationMenuItem.js","sources":["../../../src/components/side-navigation-menu-item/SideNavigationMenuItem.tsx"],"sourcesContent":["import React, { forwardRef, MutableRefObject, useContext, useEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { Comp } from '../../types';\nimport { Icon, IconSize } from '../icon';\nimport { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound';\nimport { SideNavigationMenuBarContext } from '../side-navigation-menu-bar/context';\nimport { SideNavigationMenuContext } from '../side-navigation-menu/context';\nimport {\n StyledSideNavigationMenuItem,\n StyledSideNavigationMenuItemBorder,\n StyledSideNavigationMenuItemIndicator,\n StyledSideNavigationMenuItemIndicatorContainer,\n} from './styles';\nimport { SideNavigationMenuItemProps } from './types';\nimport { Badge, BadgeVariant } from '../badge';\nimport { Flexbox } from '../flexbox';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SideNavigationMenuItem';\nconst CLASSNAME = 'redsift-side-navigation-menu-item';\n\n/**\n * The SideNavigationMenuItem component.\n */\nexport const SideNavigationMenuItem: Comp<SideNavigationMenuItemProps, HTMLAnchorElement> = forwardRef((props, ref) => {\n const menuItemRef = ref || useRef<HTMLAnchorElement>();\n\n const {\n as,\n badge,\n badgeProps,\n children,\n className,\n color,\n hasBorder,\n href,\n icon,\n iconProps,\n iconRef = useRef<HTMLElement>(),\n isCurrent,\n isDisabled,\n isSecondLevel,\n onClick,\n onKeyDown,\n tabIndex,\n theme: propsTheme,\n ...forwardedProps\n } = props;\n\n warnIfNoAccessibleLabelFound(props, [children], 'SideNavigationMenuItem');\n\n const sideNavigationMenuBarContext = useContext(SideNavigationMenuBarContext);\n const sideNavigationMenuContext = useContext(SideNavigationMenuContext);\n const theme = useTheme(propsTheme);\n\n const [isFirstChild, setIsFirstChild] = useState(false);\n const { menuItems } = sideNavigationMenuContext || sideNavigationMenuBarContext || {};\n\n useEffect(() => {\n if (!(sideNavigationMenuContext || sideNavigationMenuBarContext)) {\n setIsFirstChild(true);\n return;\n }\n\n const menuItemNode = (menuItemRef as MutableRefObject<HTMLAnchorElement>).current;\n\n if (menuItemNode) {\n if (!menuItems.size) {\n setIsFirstChild(true);\n }\n\n menuItems.add(menuItemNode);\n }\n\n return () => {\n menuItems.delete(menuItemNode);\n };\n }, [menuItems]);\n\n const sideNavigationVariant = sideNavigationMenuBarContext?.sideNavigationMenuBarVariant;\n\n return (\n <Flexbox flexDirection=\"column\" gap=\"0px\">\n <Flexbox flexDirection=\"row\" gap=\"0px\">\n {!isSecondLevel ? (\n <StyledSideNavigationMenuItemIndicatorContainer>\n {isCurrent ? <StyledSideNavigationMenuItemIndicator $theme={theme} /> : null}\n </StyledSideNavigationMenuItemIndicatorContainer>\n ) : null}\n <StyledSideNavigationMenuItem\n as={as as any}\n role=\"menuitem\"\n {...forwardedProps}\n $color={color}\n $hasIcon={icon !== undefined}\n $isCurrent={isCurrent}\n $isDisabled={isDisabled}\n $isSecondLevel={isSecondLevel}\n $theme={theme}\n $variant={sideNavigationVariant}\n aria-current={isCurrent ? 'page' : undefined}\n aria-disabled={isDisabled}\n className={classNames(SideNavigationMenuItem.className, className)}\n href={!isDisabled ? href : undefined}\n onClick={isDisabled ? undefined : onClick}\n onKeyDown={isDisabled ? undefined : onKeyDown}\n ref={menuItemRef as MutableRefObject<HTMLAnchorElement>}\n tabIndex={tabIndex !== undefined ? tabIndex : !sideNavigationMenuContext && isFirstChild ? 0 : -1}\n >\n {!isSecondLevel || icon ? (\n <Icon\n color={`var(--redsift-side-navigation-color-menu-item-text-${\n isSecondLevel || isDisabled ? 'disabled' : 'resting'\n })`}\n {...iconProps}\n icon={icon!}\n ref={iconRef as MutableRefObject<HTMLElement>}\n className=\"first\"\n size={isSecondLevel ? IconSize.small : IconSize.medium}\n />\n ) : null}\n <span className=\"content\">{children}</span>\n {badge ? (\n <Badge variant={BadgeVariant.standard} color=\"error\" {...badgeProps}>\n {badge}\n </Badge>\n ) : null}\n </StyledSideNavigationMenuItem>\n </Flexbox>\n {isSecondLevel && hasBorder ? <StyledSideNavigationMenuItemBorder /> : null}\n </Flexbox>\n );\n});\nSideNavigationMenuItem.className = CLASSNAME;\nSideNavigationMenuItem.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SideNavigationMenuItem","forwardRef","props","ref","menuItemRef","useRef","as","badge","badgeProps","children","className","color","hasBorder","href","icon","iconProps","iconRef","isCurrent","isDisabled","isSecondLevel","onClick","onKeyDown","tabIndex","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","warnIfNoAccessibleLabelFound","sideNavigationMenuBarContext","useContext","SideNavigationMenuBarContext","sideNavigationMenuContext","SideNavigationMenuContext","useTheme","isFirstChild","setIsFirstChild","useState","menuItems","useEffect","menuItemNode","current","size","add","delete","sideNavigationVariant","sideNavigationMenuBarVariant","React","createElement","Flexbox","flexDirection","gap","StyledSideNavigationMenuItemIndicatorContainer","StyledSideNavigationMenuItemIndicator","$theme","StyledSideNavigationMenuItem","_extends","role","$color","$hasIcon","undefined","$isCurrent","$isDisabled","$isSecondLevel","$variant","classNames","Icon","IconSize","small","medium","Badge","variant","B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A,CACxD,CAAC,GACA,IAAI,eACRtB,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMtC,IAAAA,SAAS,EAAC,SAAA;GAAWD,EAAAA,QAAe,CAAC,EAC1CF,KAAK,gBACJwC,KAAA,CAAAC,aAAA,CAACsB,KAAK,EAAAd,QAAA,CAAA;IAACe,OAAO,EAAEC,YAAY,CAACC,QAAS;AAAC9D,IAAAA,KAAK,EAAC,OAAA;GAAYH,EAAAA,UAAU,GAChED,KACI,CAAC,GACN,IACwB,CACvB,CAAC,EACTY,aAAa,IAAIP,SAAS,gBAAGmC,KAAA,CAAAC,aAAA,CAAC0B,kCAAkC,EAAE,IAAA,CAAC,GAAG,IAChE,CAAC,CAAA;AAEd,CAAC,EAAC;AACF1E,sBAAsB,CAACU,SAAS,GAAGX,SAAS,CAAA;AAC5CC,sBAAsB,CAAC2E,WAAW,GAAG7E,cAAc;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { StyledSkeleton } from './styles.js';
|
|
5
5
|
import { SkeletonCircle } from '../skeleton-circle/SkeletonCircle.js';
|
|
@@ -23,13 +23,13 @@ const BaseSkeleton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
23
23
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
24
24
|
const theme = useTheme(propsTheme);
|
|
25
25
|
if (isLoaded) {
|
|
26
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
27
27
|
}
|
|
28
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/React.createElement(StyledSkeleton, _extends({}, forwardedProps, {
|
|
29
29
|
$theme: theme,
|
|
30
30
|
className: classNames(BaseSkeleton.className, className),
|
|
31
31
|
ref: ref
|
|
32
|
-
}), typeof children === 'string' ? /*#__PURE__*/
|
|
32
|
+
}), typeof children === 'string' ? /*#__PURE__*/React.createElement("span", null, children) : children);
|
|
33
33
|
});
|
|
34
34
|
BaseSkeleton.className = CLASSNAME;
|
|
35
35
|
BaseSkeleton.displayName = COMPONENT_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.js","sources":["../../../src/components/skeleton/Skeleton.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeleton } from './styles';\nimport { SkeletonProps } from './types';\nimport { SkeletonCircle } from '../skeleton-circle';\nimport { SkeletonText } from '../skeleton-text';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Skeleton';\nconst CLASSNAME = 'redsift-skeleton';\n\n/**\n * The Skeleton component.\n */\nexport const BaseSkeleton: Comp<SkeletonProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, isLoaded, theme: propsTheme, ...forwardedProps } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeleton\n {...forwardedProps}\n $theme={theme}\n className={classNames(BaseSkeleton.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeleton>\n );\n});\nBaseSkeleton.className = CLASSNAME;\nBaseSkeleton.displayName = COMPONENT_NAME;\n\nexport const Skeleton = Object.assign(BaseSkeleton, {\n Circle: SkeletonCircle,\n Text: SkeletonText,\n});\n"],"names":["COMPONENT_NAME","CLASSNAME","BaseSkeleton","forwardRef","props","ref","children","className","isLoaded","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeleton","_extends","$theme","classNames","displayName","Skeleton","Object","assign","Circle","SkeletonCircle","Text","SkeletonText"],"mappings":";;;;;;;;;AAUA,MAAMA,cAAc,GAAG,UAAU,CAAA;AACjC,MAAMC,SAAS,GAAG,kBAAkB,CAAA;;AAEpC;AACA;AACA;AACO,MAAMC,YAAiD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC1F,MAAM;MAAEC,QAAQ;MAAEC,SAAS;MAAEC,QAAQ;AAAEC,MAAAA,KAAK,EAAEC,UAAAA;AAA8B,KAAC,GAAGN,KAAK;AAAxBO,IAAAA,cAAc,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA,CAAA,CAAA;AAErF,EAAA,MAAMJ,KAAK,GAAGK,QAAQ,CAACJ,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIF,QAAQ,EAAE;IACZ,oBAAOO,
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sources":["../../../src/components/skeleton/Skeleton.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeleton } from './styles';\nimport { SkeletonProps } from './types';\nimport { SkeletonCircle } from '../skeleton-circle';\nimport { SkeletonText } from '../skeleton-text';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Skeleton';\nconst CLASSNAME = 'redsift-skeleton';\n\n/**\n * The Skeleton component.\n */\nexport const BaseSkeleton: Comp<SkeletonProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, isLoaded, theme: propsTheme, ...forwardedProps } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeleton\n {...forwardedProps}\n $theme={theme}\n className={classNames(BaseSkeleton.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeleton>\n );\n});\nBaseSkeleton.className = CLASSNAME;\nBaseSkeleton.displayName = COMPONENT_NAME;\n\nexport const Skeleton = Object.assign(BaseSkeleton, {\n Circle: SkeletonCircle,\n Text: SkeletonText,\n});\n"],"names":["COMPONENT_NAME","CLASSNAME","BaseSkeleton","forwardRef","props","ref","children","className","isLoaded","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeleton","_extends","$theme","classNames","displayName","Skeleton","Object","assign","Circle","SkeletonCircle","Text","SkeletonText"],"mappings":";;;;;;;;;AAUA,MAAMA,cAAc,GAAG,UAAU,CAAA;AACjC,MAAMC,SAAS,GAAG,kBAAkB,CAAA;;AAEpC;AACA;AACA;AACO,MAAMC,YAAiD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC1F,MAAM;MAAEC,QAAQ;MAAEC,SAAS;MAAEC,QAAQ;AAAEC,MAAAA,KAAK,EAAEC,UAAAA;AAA8B,KAAC,GAAGN,KAAK;AAAxBO,IAAAA,cAAc,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA,CAAA,CAAA;AAErF,EAAA,MAAMJ,KAAK,GAAGK,QAAQ,CAACJ,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIF,QAAQ,EAAE;IACZ,oBAAOO,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAGX,IAAAA,EAAAA,QAAW,CAAC,CAAA;AACxB,GAAA;EAEA,oBACES,KAAA,CAAAC,aAAA,CAACE,cAAc,EAAAC,QAAA,KACTR,cAAc,EAAA;AAClBS,IAAAA,MAAM,EAAEX,KAAM;IACdF,SAAS,EAAEc,UAAU,CAACnB,YAAY,CAACK,SAAS,EAAEA,SAAS,CAAE;AACzDF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErC,OAAOC,QAAQ,KAAK,QAAQ,gBAAGS,KAAA,CAAAC,aAAA,CAAOV,MAAAA,EAAAA,IAAAA,EAAAA,QAAe,CAAC,GAAGA,QAC5C,CAAC,CAAA;AAErB,CAAC,EAAC;AACFJ,YAAY,CAACK,SAAS,GAAGN,SAAS,CAAA;AAClCC,YAAY,CAACoB,WAAW,GAAGtB,cAAc,CAAA;AAElC,MAAMuB,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACvB,YAAY,EAAE;AAClDwB,EAAAA,MAAM,EAAEC,cAAc;AACtBC,EAAAA,IAAI,EAAEC,YAAAA;AACR,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { StyledSkeletonCircle } from './styles.js';
|
|
5
5
|
import { useTheme } from '../theme/useTheme.js';
|
|
@@ -21,13 +21,13 @@ const SkeletonCircle = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
21
21
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
22
22
|
const theme = useTheme(propsTheme);
|
|
23
23
|
if (isLoaded) {
|
|
24
|
-
return /*#__PURE__*/
|
|
24
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
25
25
|
}
|
|
26
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/React.createElement(StyledSkeletonCircle, _extends({}, forwardedProps, {
|
|
27
27
|
$theme: theme,
|
|
28
28
|
className: classNames(SkeletonCircle.className, className),
|
|
29
29
|
ref: ref
|
|
30
|
-
}), typeof children === 'string' ? /*#__PURE__*/
|
|
30
|
+
}), typeof children === 'string' ? /*#__PURE__*/React.createElement("span", null, children) : children);
|
|
31
31
|
});
|
|
32
32
|
SkeletonCircle.className = CLASSNAME;
|
|
33
33
|
SkeletonCircle.displayName = COMPONENT_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkeletonCircle.js","sources":["../../../src/components/skeleton-circle/SkeletonCircle.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeletonCircle } from './styles';\nimport { SkeletonCircleProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SkeletonCircle';\nconst CLASSNAME = 'redsift-skeleton-circle';\n\n/**\n * The SkeletonCircle component.\n */\nexport const SkeletonCircle: Comp<SkeletonCircleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, isLoaded, theme: propsTheme, ...forwardedProps } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeletonCircle\n {...forwardedProps}\n $theme={theme}\n className={classNames(SkeletonCircle.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeletonCircle>\n );\n});\nSkeletonCircle.className = CLASSNAME;\nSkeletonCircle.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SkeletonCircle","forwardRef","props","ref","children","className","isLoaded","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeletonCircle","_extends","$theme","classNames","displayName"],"mappings":";;;;;;;AAQA,MAAMA,cAAc,GAAG,gBAAgB,CAAA;AACvC,MAAMC,SAAS,GAAG,yBAAyB,CAAA;;AAE3C;AACA;AACA;AACO,MAAMC,cAAyD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAClG,MAAM;MAAEC,QAAQ;MAAEC,SAAS;MAAEC,QAAQ;AAAEC,MAAAA,KAAK,EAAEC,UAAAA;AAA8B,KAAC,GAAGN,KAAK;AAAxBO,IAAAA,cAAc,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA,CAAA,CAAA;AAErF,EAAA,MAAMJ,KAAK,GAAGK,QAAQ,CAACJ,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIF,QAAQ,EAAE;IACZ,oBAAOO,
|
|
1
|
+
{"version":3,"file":"SkeletonCircle.js","sources":["../../../src/components/skeleton-circle/SkeletonCircle.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeletonCircle } from './styles';\nimport { SkeletonCircleProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SkeletonCircle';\nconst CLASSNAME = 'redsift-skeleton-circle';\n\n/**\n * The SkeletonCircle component.\n */\nexport const SkeletonCircle: Comp<SkeletonCircleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, isLoaded, theme: propsTheme, ...forwardedProps } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeletonCircle\n {...forwardedProps}\n $theme={theme}\n className={classNames(SkeletonCircle.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeletonCircle>\n );\n});\nSkeletonCircle.className = CLASSNAME;\nSkeletonCircle.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SkeletonCircle","forwardRef","props","ref","children","className","isLoaded","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeletonCircle","_extends","$theme","classNames","displayName"],"mappings":";;;;;;;AAQA,MAAMA,cAAc,GAAG,gBAAgB,CAAA;AACvC,MAAMC,SAAS,GAAG,yBAAyB,CAAA;;AAE3C;AACA;AACA;AACO,MAAMC,cAAyD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAClG,MAAM;MAAEC,QAAQ;MAAEC,SAAS;MAAEC,QAAQ;AAAEC,MAAAA,KAAK,EAAEC,UAAAA;AAA8B,KAAC,GAAGN,KAAK;AAAxBO,IAAAA,cAAc,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA,CAAA,CAAA;AAErF,EAAA,MAAMJ,KAAK,GAAGK,QAAQ,CAACJ,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIF,QAAQ,EAAE;IACZ,oBAAOO,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAGX,IAAAA,EAAAA,QAAW,CAAC,CAAA;AACxB,GAAA;EAEA,oBACES,KAAA,CAAAC,aAAA,CAACE,oBAAoB,EAAAC,QAAA,KACfR,cAAc,EAAA;AAClBS,IAAAA,MAAM,EAAEX,KAAM;IACdF,SAAS,EAAEc,UAAU,CAACnB,cAAc,CAACK,SAAS,EAAEA,SAAS,CAAE;AAC3DF,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAErC,OAAOC,QAAQ,KAAK,QAAQ,gBAAGS,KAAA,CAAAC,aAAA,CAAOV,MAAAA,EAAAA,IAAAA,EAAAA,QAAe,CAAC,GAAGA,QACtC,CAAC,CAAA;AAE3B,CAAC,EAAC;AACFJ,cAAc,CAACK,SAAS,GAAGN,SAAS,CAAA;AACpCC,cAAc,CAACoB,WAAW,GAAGtB,cAAc;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { StyledSkeletonText } from './styles.js';
|
|
5
5
|
import { useTheme } from '../theme/useTheme.js';
|
|
@@ -24,16 +24,16 @@ const SkeletonText = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24
24
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
25
25
|
const theme = useTheme(propsTheme);
|
|
26
26
|
if (isLoaded) {
|
|
27
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
28
28
|
}
|
|
29
|
-
return /*#__PURE__*/
|
|
29
|
+
return /*#__PURE__*/React.createElement(StyledSkeletonText, _extends({}, forwardedProps, {
|
|
30
30
|
className: classNames(SkeletonText.className, className),
|
|
31
31
|
ref: ref,
|
|
32
32
|
$fontSize: fontSize,
|
|
33
33
|
$lineHeight: lineHeight,
|
|
34
34
|
$theme: theme,
|
|
35
35
|
$variant: variant
|
|
36
|
-
}), typeof children === 'string' ? /*#__PURE__*/
|
|
36
|
+
}), typeof children === 'string' ? /*#__PURE__*/React.createElement("span", null, children) : children);
|
|
37
37
|
});
|
|
38
38
|
SkeletonText.className = CLASSNAME;
|
|
39
39
|
SkeletonText.displayName = COMPONENT_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkeletonText.js","sources":["../../../src/components/skeleton-text/SkeletonText.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeletonText } from './styles';\nimport { SkeletonTextProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SkeletonText';\nconst CLASSNAME = 'redsift-skeleton-text';\n\n/**\n * The SkeletonText component.\n */\nexport const SkeletonText: Comp<SkeletonTextProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fontSize,\n isLoaded,\n lineHeight,\n theme: propsTheme,\n variant = 'body',\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeletonText\n {...forwardedProps}\n className={classNames(SkeletonText.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n $fontSize={fontSize}\n $lineHeight={lineHeight}\n $theme={theme}\n $variant={variant}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeletonText>\n );\n});\nSkeletonText.className = CLASSNAME;\nSkeletonText.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SkeletonText","forwardRef","props","ref","children","className","fontSize","isLoaded","lineHeight","theme","propsTheme","variant","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeletonText","_extends","classNames","$fontSize","$lineHeight","$theme","$variant","displayName"],"mappings":";;;;;;;AAQA,MAAMA,cAAc,GAAG,cAAc,CAAA;AACrC,MAAMC,SAAS,GAAG,uBAAuB,CAAA;;AAEzC;AACA;AACA;AACO,MAAMC,YAAqD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC9F,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,QAAQ;MACRC,QAAQ;MACRC,UAAU;AACVC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,OAAO,GAAG,MAAA;AAEZ,KAAC,GAAGT,KAAK;AADJU,IAAAA,cAAc,GAAAC,wBAAA,CACfX,KAAK,EAAAY,SAAA,CAAA,CAAA;AAET,EAAA,MAAML,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIH,QAAQ,EAAE;IACZ,oBAAOS,
|
|
1
|
+
{"version":3,"file":"SkeletonText.js","sources":["../../../src/components/skeleton-text/SkeletonText.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp } from '../../types';\nimport { StyledSkeletonText } from './styles';\nimport { SkeletonTextProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SkeletonText';\nconst CLASSNAME = 'redsift-skeleton-text';\n\n/**\n * The SkeletonText component.\n */\nexport const SkeletonText: Comp<SkeletonTextProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fontSize,\n isLoaded,\n lineHeight,\n theme: propsTheme,\n variant = 'body',\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n if (isLoaded) {\n return <>{children}</>;\n }\n\n return (\n <StyledSkeletonText\n {...forwardedProps}\n className={classNames(SkeletonText.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n $fontSize={fontSize}\n $lineHeight={lineHeight}\n $theme={theme}\n $variant={variant}\n >\n {typeof children === 'string' ? <span>{children}</span> : children}\n </StyledSkeletonText>\n );\n});\nSkeletonText.className = CLASSNAME;\nSkeletonText.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SkeletonText","forwardRef","props","ref","children","className","fontSize","isLoaded","lineHeight","theme","propsTheme","variant","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","Fragment","StyledSkeletonText","_extends","classNames","$fontSize","$lineHeight","$theme","$variant","displayName"],"mappings":";;;;;;;AAQA,MAAMA,cAAc,GAAG,cAAc,CAAA;AACrC,MAAMC,SAAS,GAAG,uBAAuB,CAAA;;AAEzC;AACA;AACA;AACO,MAAMC,YAAqD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC9F,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,QAAQ;MACRC,QAAQ;MACRC,UAAU;AACVC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,OAAO,GAAG,MAAA;AAEZ,KAAC,GAAGT,KAAK;AADJU,IAAAA,cAAc,GAAAC,wBAAA,CACfX,KAAK,EAAAY,SAAA,CAAA,CAAA;AAET,EAAA,MAAML,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,IAAIH,QAAQ,EAAE;IACZ,oBAAOS,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAGd,IAAAA,EAAAA,QAAW,CAAC,CAAA;AACxB,GAAA;EAEA,oBACEY,KAAA,CAAAC,aAAA,CAACE,kBAAkB,EAAAC,QAAA,KACbR,cAAc,EAAA;IAClBP,SAAS,EAAEgB,UAAU,CAACrB,YAAY,CAACK,SAAS,EAAEA,SAAS,CAAE;AACzDF,IAAAA,GAAG,EAAEA,GAAiC;AACtCmB,IAAAA,SAAS,EAAEhB,QAAS;AACpBiB,IAAAA,WAAW,EAAEf,UAAW;AACxBgB,IAAAA,MAAM,EAAEf,KAAM;AACdgB,IAAAA,QAAQ,EAAEd,OAAAA;AAAQ,GAAA,CAAA,EAEjB,OAAOP,QAAQ,KAAK,QAAQ,gBAAGY,KAAA,CAAAC,aAAA,CAAOb,MAAAA,EAAAA,IAAAA,EAAAA,QAAe,CAAC,GAAGA,QACxC,CAAC,CAAA;AAEzB,CAAC,EAAC;AACFJ,YAAY,CAACK,SAAS,GAAGN,SAAS,CAAA;AAClCC,YAAY,CAAC0B,WAAW,GAAG5B,cAAc;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import intlMessages from './intl/index.js';
|
|
5
5
|
import { SpinnerSize } from './types.js';
|
|
@@ -61,7 +61,7 @@ const Spinner = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
61
61
|
height
|
|
62
62
|
} = sizeToDimension(size);
|
|
63
63
|
const stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
64
|
-
return /*#__PURE__*/
|
|
64
|
+
return /*#__PURE__*/React.createElement(StyledSpinner, _extends({
|
|
65
65
|
alt: stringFormatter.format('loading')
|
|
66
66
|
}, forwardedProps, {
|
|
67
67
|
"aria-hidden": ariaLabel ? ariaHidden ? ariaHidden : undefined : true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","sources":["../../../src/components/spinner/Spinner.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\nimport { Comp } from '../../types';\n\nimport { useLocalizedStringFormatter } from '../../react-aria/react-aria/i18n';\nimport intlMessages from './intl';\n\nimport { SpinnerProps, SpinnerSize } from './types';\nimport { StyledSpinner } from './styles';\n\nimport spinnerPrimaryN from './images/spinner-primary-n.svg';\nimport spinnerGreyL1 from './images/spinner-grey-l1.svg';\nimport spinnerGreyL2 from './images/spinner-grey-l2.svg';\nimport spinnerGreyL3 from './images/spinner-grey-l3.svg';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Spinner';\nconst CLASSNAME = 'redsift-shield';\n\nconst sizeToDimension = (size: SpinnerSize): { width: number; height: number } => {\n switch (size) {\n case SpinnerSize.xsmall:\n return { width: 15, height: 15 };\n case SpinnerSize.small:\n return { width: 24, height: 24 };\n case SpinnerSize.large:\n return { width: 56, height: 56 };\n case SpinnerSize.medium:\n default:\n return { width: 40, height: 40 };\n }\n};\n\n/**\n * The Spinner component.\n */\nexport const Spinner: Comp<SpinnerProps, HTMLImageElement> = forwardRef((props, ref) => {\n const {\n 'aria-hidden': ariaHidden,\n 'aria-label': ariaLabel,\n className,\n color: propsColor,\n isColored = true,\n size = SpinnerSize.medium,\n theme: propsTheme,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const color = propsColor ?? (isColored ? 'primary' : 'grey-l3');\n\n const { width, height } = sizeToDimension(size!);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages);\n\n return (\n <StyledSpinner\n alt={stringFormatter.format('loading')}\n {...forwardedProps}\n aria-hidden={ariaLabel ? (ariaHidden ? ariaHidden : undefined) : true}\n aria-label={ariaLabel}\n className={classNames(Spinner.className, className)}\n height={height}\n ref={ref as RefObject<HTMLImageElement>}\n src={\n color === 'primary'\n ? spinnerPrimaryN\n : color === 'grey-l1'\n ? spinnerGreyL1\n : color === 'grey-l2'\n ? spinnerGreyL2\n : spinnerGreyL3\n }\n width={width}\n $size={size}\n $theme={theme}\n />\n );\n});\nSpinner.className = CLASSNAME;\nSpinner.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","sizeToDimension","size","SpinnerSize","xsmall","width","height","small","large","medium","Spinner","forwardRef","props","ref","ariaHidden","ariaLabel","className","color","propsColor","isColored","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","stringFormatter","useLocalizedStringFormatter","intlMessages","React","createElement","StyledSpinner","_extends","alt","format","undefined","classNames","src","spinnerPrimaryN","spinnerGreyL1","spinnerGreyL2","spinnerGreyL3","$size","$theme","displayName"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,cAAc,GAAG,SAAS,CAAA;AAChC,MAAMC,SAAS,GAAG,gBAAgB,CAAA;AAElC,MAAMC,eAAe,GAAIC,IAAiB,IAAwC;AAChF,EAAA,QAAQA,IAAI;IACV,KAAKC,WAAW,CAACC,MAAM;MACrB,OAAO;AAAEC,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,EAAA;OAAI,CAAA;IAClC,KAAKH,WAAW,CAACI,KAAK;MACpB,OAAO;AAAEF,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,EAAA;OAAI,CAAA;IAClC,KAAKH,WAAW,CAACK,KAAK;MACpB,OAAO;AAAEH,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,EAAA;OAAI,CAAA;IAClC,KAAKH,WAAW,CAACM,MAAM,CAAA;AACvB,IAAA;MACE,OAAO;AAAEJ,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,EAAA;OAAI,CAAA;AACpC,GAAA;AACF,CAAC,CAAA;;AAED;AACA;AACA;AACO,MAAMI,OAA6C,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACtF,MAAM;AACJ,MAAA,aAAa,EAAEC,UAAU;AACzB,MAAA,YAAY,EAAEC,SAAS;MACvBC,SAAS;AACTC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,SAAS,GAAG,IAAI;MAChBjB,IAAI,GAAGC,WAAW,CAACM,MAAM;AACzBW,MAAAA,KAAK,EAAEC,UAAAA;AAET,KAAC,GAAGT,KAAK;AADJU,IAAAA,cAAc,GAAAC,wBAAA,CACfX,KAAK,EAAAY,SAAA,CAAA,CAAA;AAET,EAAA,MAAMJ,KAAK,GAAGK,QAAQ,CAACJ,UAAU,CAAC,CAAA;AAElC,EAAA,MAAMJ,KAAK,GAAGC,UAAU,KAAA,IAAA,IAAVA,UAAU,KAAA,KAAA,CAAA,GAAVA,UAAU,GAAKC,SAAS,GAAG,SAAS,GAAG,SAAU,CAAA;EAE/D,MAAM;IAAEd,KAAK;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAGL,eAAe,CAACC,IAAK,CAAC,CAAA;AAEhD,EAAA,MAAMwB,eAAe,GAAGC,2BAA2B,CAACC,YAAY,CAAC,CAAA;AAEjE,EAAA,oBACEC,
|
|
1
|
+
{"version":3,"file":"Spinner.js","sources":["../../../src/components/spinner/Spinner.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\nimport { Comp } from '../../types';\n\nimport { useLocalizedStringFormatter } from '../../react-aria/react-aria/i18n';\nimport intlMessages from './intl';\n\nimport { SpinnerProps, SpinnerSize } from './types';\nimport { StyledSpinner } from './styles';\n\nimport spinnerPrimaryN from './images/spinner-primary-n.svg';\nimport spinnerGreyL1 from './images/spinner-grey-l1.svg';\nimport spinnerGreyL2 from './images/spinner-grey-l2.svg';\nimport spinnerGreyL3 from './images/spinner-grey-l3.svg';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Spinner';\nconst CLASSNAME = 'redsift-shield';\n\nconst sizeToDimension = (size: SpinnerSize): { width: number; height: number } => {\n switch (size) {\n case SpinnerSize.xsmall:\n return { width: 15, height: 15 };\n case SpinnerSize.small:\n return { width: 24, height: 24 };\n case SpinnerSize.large:\n return { width: 56, height: 56 };\n case SpinnerSize.medium:\n default:\n return { width: 40, height: 40 };\n }\n};\n\n/**\n * The Spinner component.\n */\nexport const Spinner: Comp<SpinnerProps, HTMLImageElement> = forwardRef((props, ref) => {\n const {\n 'aria-hidden': ariaHidden,\n 'aria-label': ariaLabel,\n className,\n color: propsColor,\n isColored = true,\n size = SpinnerSize.medium,\n theme: propsTheme,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const color = propsColor ?? (isColored ? 'primary' : 'grey-l3');\n\n const { width, height } = sizeToDimension(size!);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages);\n\n return (\n <StyledSpinner\n alt={stringFormatter.format('loading')}\n {...forwardedProps}\n aria-hidden={ariaLabel ? (ariaHidden ? ariaHidden : undefined) : true}\n aria-label={ariaLabel}\n className={classNames(Spinner.className, className)}\n height={height}\n ref={ref as RefObject<HTMLImageElement>}\n src={\n color === 'primary'\n ? spinnerPrimaryN\n : color === 'grey-l1'\n ? spinnerGreyL1\n : color === 'grey-l2'\n ? spinnerGreyL2\n : spinnerGreyL3\n }\n width={width}\n $size={size}\n $theme={theme}\n />\n );\n});\nSpinner.className = CLASSNAME;\nSpinner.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","sizeToDimension","size","SpinnerSize","xsmall","width","height","small","large","medium","Spinner","forwardRef","props","ref","ariaHidden","ariaLabel","className","color","propsColor","isColored","theme","propsTheme","forwardedProps","_objectWithoutProperties","_excluded","useTheme","stringFormatter","useLocalizedStringFormatter","intlMessages","React","createElement","StyledSpinner","_extends","alt","format","undefined","classNames","src","spinnerPrimaryN","spinnerGreyL1","spinnerGreyL2","spinnerGreyL3","$size","$theme","displayName"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,cAAc,GAAG,SAAS,CAAA;AAChC,MAAMC,SAAS,GAAG,gBAAgB,CAAA;AAElC,MAAMC,eAAe,GAAIC,IAAiB,IAAwC;AAChF,EAAA,QAAQA,IAAI;IACV,KAAKC,WAAW,CAACC,MAAM;MACrB,OAAO;AAAEC,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,EAAA;OAAI,CAAA;IAClC,KAAKH,WAAW,CAACI,KAAK;MACpB,OAAO;AAAEF,QAAAA,KAAK,EAAE,EAAE;AAAEC,QAAAA,MAAM,EAAE,E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nCZ,cAAc,EAAA;IAClB,aAAaP,EAAAA,SAAS,GAAID,UAAU,GAAGA,UAAU,GAAGqB,SAAS,GAAI,IAAK;AACtE,IAAA,YAAA,EAAYpB,SAAU;IACtBC,SAAS,EAAEoB,UAAU,CAAC1B,OAAO,CAACM,SAAS,EAAEA,SAAS,CAAE;AACpDV,IAAAA,MAAM,EAAEA,MAAO;AACfO,IAAAA,GAAG,EAAEA,GAAmC;AACxCwB,IAAAA,GAAG,EACDpB,KAAK,KAAK,SAAS,GACfqB,eAAe,GACfrB,KAAK,KAAK,SAAS,GACnBsB,aAAa,GACbtB,KAAK,KAAK,SAAS,GACnBuB,aAAa,GACbC,aACL;AACDpC,IAAAA,KAAK,EAAEA,KAAM;AACbqC,IAAAA,KAAK,EAAExC,IAAK;AACZyC,IAAAA,MAAM,EAAEvB,KAAAA;AAAM,GAAA,CACf,CAAC,CAAA;AAEN,CAAC,EAAC;AACFV,OAAO,CAACM,SAAS,GAAGhB,SAAS,CAAA;AAC7BU,OAAO,CAACkC,WAAW,GAAG7C,cAAc;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef, useContext, useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { SwitchGroupContext } from '../switch-group/context.js';
|
|
5
5
|
import { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound.js';
|
|
@@ -89,7 +89,7 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
89
89
|
onChange === null || onChange === void 0 ? void 0 : onChange(!isSelected, value, name, event, groupState);
|
|
90
90
|
}
|
|
91
91
|
}, [onChange, groupState, isSelected, propsIsSelected]);
|
|
92
|
-
return /*#__PURE__*/
|
|
92
|
+
return /*#__PURE__*/React.createElement(StyledSwitch, _extends({}, forwardedProps, {
|
|
93
93
|
$isColored: isColored,
|
|
94
94
|
$isDisabled: isDisabled,
|
|
95
95
|
$isFocusVisible: isFocusVisible,
|
|
@@ -99,19 +99,19 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
99
99
|
$theme: theme,
|
|
100
100
|
className: classNames(Switch.className, className),
|
|
101
101
|
ref: ref
|
|
102
|
-
}), /*#__PURE__*/
|
|
102
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
103
103
|
className: `${Switch.className}__slide`
|
|
104
|
-
}, /*#__PURE__*/
|
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
105
105
|
className: `${Switch.className}-slide__inner`
|
|
106
|
-
}), /*#__PURE__*/
|
|
106
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
107
107
|
className: `${Switch.className}-slide__knob-wrapper`
|
|
108
|
-
}, /*#__PURE__*/
|
|
108
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
109
109
|
className: `${Switch.className}-slide-knob-wrapper__elevation`
|
|
110
|
-
}), /*#__PURE__*/
|
|
110
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
111
111
|
className: `${Switch.className}-slide-knob-wrapper__knob`
|
|
112
|
-
}))), children ? /*#__PURE__*/
|
|
112
|
+
}))), children ? /*#__PURE__*/React.createElement("span", {
|
|
113
113
|
className: "label"
|
|
114
|
-
}, children) : null, /*#__PURE__*/
|
|
114
|
+
}, children) : null, /*#__PURE__*/React.createElement("input", _extends({}, inputProps, focusProps, {
|
|
115
115
|
"aria-checked": isSelected || isControlled && propsIsSelected ? 'true' : 'false',
|
|
116
116
|
"aria-disabled": isDisabled,
|
|
117
117
|
"aria-invalid": isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../src/components/switch/Switch.tsx"],"sourcesContent":["import React, {\n ComponentProps,\n forwardRef,\n MutableRefObject,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport classNames from 'classnames';\nimport { useFocusRing } from '../../react-aria/react-aria/focus';\nimport { Comp } from '../../types';\nimport { SwitchGroupContext } from '../switch-group/context';\nimport { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound';\nimport { SwitchProps } from './types';\nimport { StyledSwitch } from './styles';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Switch';\nconst CLASSNAME = 'redsift-switch';\n\n/**\n * The Switch component.\n * Works both inside a SwitchGroup or as standalone.\n * Can be used as controlled or uncontrolled.\n */\nexport const Switch: Comp<SwitchProps, HTMLLabelElement> = forwardRef((props, ref) => {\n const groupState = useContext(SwitchGroupContext);\n\n let {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n autoFocus,\n children,\n className,\n defaultSelected,\n inputProps,\n inputRef,\n isColored = true,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n isSelected: propsIsSelected,\n name,\n onChange,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const { isFocusVisible, focusProps } = useFocusRing({ autoFocus });\n isDisabled = isDisabled ?? groupState?.isDisabled;\n isReadOnly = isReadOnly ?? groupState?.isReadOnly;\n\n const [isSelected, setSelected] = useState(\n Boolean(propsIsSelected ?? defaultSelected ?? groupState?.value.includes(value as string))\n );\n const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;\n\n useEffect(() => {\n setSelected(Boolean(propsIsSelected ?? defaultSelected));\n }, [propsIsSelected, defaultSelected]);\n\n useEffect(() => {\n if (groupState) {\n setSelected(groupState.value.includes(value as string));\n }\n }, [groupState?.value]);\n\n warnIfNoAccessibleLabelFound(props as ComponentProps<'label'>, [children], 'Switch');\n\n if (groupState) {\n if (propsIsSelected != null) {\n console.warn(\n 'isSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (defaultSelected != null) {\n console.warn(\n 'defaultSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (props.value == null) {\n console.warn(\n 'A <Switch> element within a <SwitchGroup> requires a `value` property unless the <Switch> is controlled.'\n );\n }\n }\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n if (groupState) {\n if (!groupState.value.includes(value as string)) {\n groupState.addValue(value as string);\n } else {\n groupState.removeValue(value as string);\n }\n }\n\n if (isControlled) {\n onChange?.(!propsIsSelected, value, name, event, groupState!);\n } else {\n setSelected(!isSelected);\n onChange?.(!isSelected, value, name, event, groupState!);\n }\n },\n [onChange, groupState, isSelected, propsIsSelected]\n );\n\n return (\n <StyledSwitch\n {...forwardedProps}\n $isColored={isColored}\n $isDisabled={isDisabled}\n $isFocusVisible={isFocusVisible}\n $isInvalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n $isRequired={isRequired}\n $isSelected={isSelected || (isControlled && propsIsSelected)}\n $theme={theme}\n className={classNames(Switch.className, className)}\n ref={ref as MutableRefObject<HTMLLabelElement>}\n >\n <div className={`${Switch.className}__slide`}>\n <div className={`${Switch.className}-slide__inner`} />\n <div className={`${Switch.className}-slide__knob-wrapper`}>\n <div className={`${Switch.className}-slide-knob-wrapper__elevation`} />\n <div className={`${Switch.className}-slide-knob-wrapper__knob`} />\n </div>\n </div>\n {children ? <span className=\"label\">{children}</span> : null}\n <input\n {...inputProps}\n {...focusProps}\n aria-checked={isSelected || (isControlled && propsIsSelected) ? 'true' : 'false'}\n aria-disabled={isDisabled}\n aria-invalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-readonly={isReadOnly}\n aria-required={isRequired}\n autoFocus={autoFocus}\n checked={isSelected || (isControlled && propsIsSelected) ? true : false}\n disabled={isDisabled}\n name={name}\n onChange={handleChange}\n ref={inputRef as MutableRefObject<HTMLInputElement>}\n role=\"switch\"\n type=\"checkbox\"\n value={value}\n />\n </StyledSwitch>\n );\n});\nSwitch.className = CLASSNAME;\nSwitch.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Switch","forwardRef","props","ref","_isDisabled","_isReadOnly","_ref","groupState","useContext","SwitchGroupContext","ariaLabel","ariaLabelledby","autoFocus","children","className","defaultSelected","inputProps","inputRef","isColored","isDisabled","isInvalid","isReadOnly","isRequired","isSelected","propsIsSelected","name","onChange","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","isFocusVisible","focusProps","useFocusRing","setSelected","useState","Boolean","includes","isControlled","undefined","useEffect","warnIfNoAccessibleLabelFound","console","warn","handleChange","useCallback","event","addValue","removeValue","React","createElement","StyledSwitch","_extends","$isColored","$isDisabled","$isFocusVisible","$isInvalid","$isRequired","$isSelected","$theme","classNames","checked","disabled","role","type","displayName"],"mappings":";;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAMC,SAAS,GAAG,gBAAgB,CAAA;;AAElC;AACA;AACA;AACA;AACA;AACO,MAAMC,MAA2C,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;AAAA,EAAA,IAAAC,WAAA,EAAAC,WAAA,EAAAC,IAAA,CAAA;AACpF,EAAA,MAAMC,UAAU,GAAGC,UAAU,CAACC,kBAAkB,CAAC,CAAA;EAEjD,IAAI;AACF,MAAA,YAAY,EAAEC,SAAS;AACvB,MAAA,iBAAiB,EAAEC,cAAc;MACjCC,SAAS;MACTC,QAAQ;MACRC,SAAS;MACTC,eAAe;MACfC,UAAU;MACVC,QAAQ;AACRC,MAAAA,SAAS,GAAG,IAAI;MAChBC,UAAU;MACVC,SAAS;MACTC,UAAU;MACVC,UAAU;AACVC,MAAAA,UAAU,EAAEC,eAAe;MAC3BC,IAAI;MACJC,QAAQ;AAC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eAAA,EAAeC,UAAW;AAC1BV,IAAAA,SAAS,EAAEA,SAAU;IACrBoD,OAAO,EAAEzC,UAAU,IAAKkB,YAAY,IAAIjB,eAAgB,GAAG,IAAI,GAAG,KAAM;AACxEyC,IAAAA,QAAQ,EAAE9C,UAAW;AACrBM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEqB,YAAa;AACvB5C,IAAAA,GAAG,EAAEc,QAA+C;AACpDiD,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,UAAU;AACftC,IAAAA,KAAK,EAAEA,KAAAA;AAAM,GAAA,CACd,CACW,CAAC,CAAA;AAEnB,CAAC,EAAC;AACF7B,MAAM,CAACc,SAAS,GAAGf,SAAS,CAAA;AAC5BC,MAAM,CAACoE,WAAW,GAAGtE,cAAc;;;;"}
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../src/components/switch/Switch.tsx"],"sourcesContent":["import React, {\n ComponentProps,\n forwardRef,\n MutableRefObject,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport classNames from 'classnames';\nimport { useFocusRing } from '../../react-aria/react-aria/focus';\nimport { Comp } from '../../types';\nimport { SwitchGroupContext } from '../switch-group/context';\nimport { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound';\nimport { SwitchProps } from './types';\nimport { StyledSwitch } from './styles';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Switch';\nconst CLASSNAME = 'redsift-switch';\n\n/**\n * The Switch component.\n * Works both inside a SwitchGroup or as standalone.\n * Can be used as controlled or uncontrolled.\n */\nexport const Switch: Comp<SwitchProps, HTMLLabelElement> = forwardRef((props, ref) => {\n const groupState = useContext(SwitchGroupContext);\n\n let {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n autoFocus,\n children,\n className,\n defaultSelected,\n inputProps,\n inputRef,\n isColored = true,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n isSelected: propsIsSelected,\n name,\n onChange,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const { isFocusVisible, focusProps } = useFocusRing({ autoFocus });\n isDisabled = isDisabled ?? groupState?.isDisabled;\n isReadOnly = isReadOnly ?? groupState?.isReadOnly;\n\n const [isSelected, setSelected] = useState(\n Boolean(propsIsSelected ?? defaultSelected ?? groupState?.value.includes(value as string))\n );\n const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;\n\n useEffect(() => {\n setSelected(Boolean(propsIsSelected ?? defaultSelected));\n }, [propsIsSelected, defaultSelected]);\n\n useEffect(() => {\n if (groupState) {\n setSelected(groupState.value.includes(value as string));\n }\n }, [groupState?.value]);\n\n warnIfNoAccessibleLabelFound(props as ComponentProps<'label'>, [children], 'Switch');\n\n if (groupState) {\n if (propsIsSelected != null) {\n console.warn(\n 'isSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (defaultSelected != null) {\n console.warn(\n 'defaultSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (props.value == null) {\n console.warn(\n 'A <Switch> element within a <SwitchGroup> requires a `value` property unless the <Switch> is controlled.'\n );\n }\n }\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n if (groupState) {\n if (!groupState.value.includes(value as string)) {\n groupState.addValue(value as string);\n } else {\n groupState.removeValue(value as string);\n }\n }\n\n if (isControlled) {\n onChange?.(!propsIsSelected, value, name, event, groupState!);\n } else {\n setSelected(!isSelected);\n onChange?.(!isSelected, value, name, event, groupState!);\n }\n },\n [onChange, groupState, isSelected, propsIsSelected]\n );\n\n return (\n <StyledSwitch\n {...forwardedProps}\n $isColored={isColored}\n $isDisabled={isDisabled}\n $isFocusVisible={isFocusVisible}\n $isInvalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n $isRequired={isRequired}\n $isSelected={isSelected || (isControlled && propsIsSelected)}\n $theme={theme}\n className={classNames(Switch.className, className)}\n ref={ref as MutableRefObject<HTMLLabelElement>}\n >\n <div className={`${Switch.className}__slide`}>\n <div className={`${Switch.className}-slide__inner`} />\n <div className={`${Switch.className}-slide__knob-wrapper`}>\n <div className={`${Switch.className}-slide-knob-wrapper__elevation`} />\n <div className={`${Switch.className}-slide-knob-wrapper__knob`} />\n </div>\n </div>\n {children ? <span className=\"label\">{children}</span> : null}\n <input\n {...inputProps}\n {...focusProps}\n aria-checked={isSelected || (isControlled && propsIsSelected) ? 'true' : 'false'}\n aria-disabled={isDisabled}\n aria-invalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-readonly={isReadOnly}\n aria-required={isRequired}\n autoFocus={autoFocus}\n checked={isSelected || (isControlled && propsIsSelected) ? true : false}\n disabled={isDisabled}\n name={name}\n onChange={handleChange}\n ref={inputRef as MutableRefObject<HTMLInputElement>}\n role=\"switch\"\n type=\"checkbox\"\n value={value}\n />\n </StyledSwitch>\n );\n});\nSwitch.className = CLASSNAME;\nSwitch.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Switch","forwardRef","props","ref","_isDisabled","_isReadOnly","_ref","groupState","useContext","SwitchGroupContext","ariaLabel","ariaLabelledby","autoFocus","children","className","defaultSelected","inputProps","inputRef","isColored","isDisabled","isInvalid","isReadOnly","isRequired","isSelected","propsIsSelected","name","onChange","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","isFocusVisible","focusProps","useFocusRing","setSelected","useState","Boolean","includes","isControlled","undefined","useEffect","warnIfNoAccessibleLabelFound","console","warn","handleChange","useCallback","event","addValue","removeValue","React","createElement","StyledSwitch","_extends","$isColored","$isDisabled","$isFocusVisible","$isInvalid","$isRequired","$isS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outProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef, useState, useEffect } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { SwitchGroupOrientation } from './types.js';
|
|
5
5
|
import { SwitchGroupContext } from './context.js';
|
|
@@ -68,11 +68,11 @@ const SwitchGroup = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
return /*#__PURE__*/
|
|
71
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
72
72
|
value: {
|
|
73
73
|
theme
|
|
74
74
|
}
|
|
75
|
-
}, /*#__PURE__*/
|
|
75
|
+
}, /*#__PURE__*/React.createElement(StyledSwitchGroup, _extends({
|
|
76
76
|
color: color
|
|
77
77
|
}, forwardedProps, {
|
|
78
78
|
$isDisabled: isDisabled,
|
|
@@ -84,13 +84,13 @@ const SwitchGroup = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
84
84
|
className: classNames(SwitchGroup.className, className),
|
|
85
85
|
ref: ref,
|
|
86
86
|
role: "group"
|
|
87
|
-
}), /*#__PURE__*/
|
|
87
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
88
88
|
className: `${SwitchGroup.className}-label`
|
|
89
|
-
}, label, isRequired ? ' *' : null), /*#__PURE__*/
|
|
89
|
+
}, label, isRequired ? ' *' : null), /*#__PURE__*/React.createElement("div", {
|
|
90
90
|
className: `${SwitchGroup.className}-switches`
|
|
91
|
-
}, /*#__PURE__*/
|
|
91
|
+
}, /*#__PURE__*/React.createElement(SwitchGroupContext.Provider, {
|
|
92
92
|
value: state
|
|
93
|
-
}, children)), /*#__PURE__*/
|
|
93
|
+
}, children)), /*#__PURE__*/React.createElement("span", {
|
|
94
94
|
className: `${SwitchGroup.className}-description`
|
|
95
95
|
}, description)));
|
|
96
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchGroup.js","sources":["../../../src/components/switch-group/SwitchGroup.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport { Comp, ColorPalette } from '../../types';\nimport { SwitchGroupOrientation, SwitchGroupProps } from './types';\nimport { SwitchGroupContext } from './context';\nimport { StyledSwitchGroup } from './styles';\nimport { ThemeProvider, useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SwitchGroup';\nconst CLASSNAME = 'redsift-switch-group';\n\n/**\n * The SwitchGroup component.\n * Can be used as controlled or uncontrolled.\n */\nexport const SwitchGroup: Comp<SwitchGroupProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n color = ColorPalette.primary,\n defaultValues,\n description,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n label,\n onChange,\n orientation = SwitchGroupOrientation.vertical,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const [selectedValues, setValue] = useState<string[]>(value || defaultValues || []);\n useEffect(() => {\n if (value) {\n state.setValue(value);\n }\n }, [value]);\n\n const state = {\n value: selectedValues,\n isDisabled: isDisabled || false,\n isReadOnly: isReadOnly || false,\n setValue(values: string[]) {\n if (isReadOnly || isDisabled) {\n return;\n }\n\n setValue(values);\n },\n addValue(value: string) {\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n if (onChange) {\n onChange(selectedValues.concat(value));\n }\n }\n },\n removeValue(value: string) {\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter((existingValue) => existingValue !== value));\n if (onChange) {\n onChange(selectedValues.filter((existingValue) => existingValue !== value));\n }\n }\n },\n };\n\n return (\n <ThemeProvider value={{ theme }}>\n <StyledSwitchGroup\n color={color}\n {...forwardedProps}\n $isDisabled={isDisabled}\n $isInvalid={isInvalid || (isRequired && selectedValues.length === 0)}\n $isReadOnly={isReadOnly}\n $orientation={orientation}\n $theme={theme}\n aria-disabled={isDisabled}\n className={classNames(SwitchGroup.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n role=\"group\"\n >\n <span className={`${SwitchGroup.className}-label`}>\n {label}\n {isRequired ? ' *' : null}\n </span>\n <div className={`${SwitchGroup.className}-switches`}>\n <SwitchGroupContext.Provider value={state}>{children}</SwitchGroupContext.Provider>\n </div>\n <span className={`${SwitchGroup.className}-description`}>{description}</span>\n </StyledSwitchGroup>\n </ThemeProvider>\n );\n});\nSwitchGroup.className = CLASSNAME;\nSwitchGroup.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SwitchGroup","forwardRef","props","ref","children","className","color","ColorPalette","primary","defaultValues","description","isDisabled","isInvalid","isReadOnly","isRequired","label","onChange","orientation","SwitchGroupOrientation","vertical","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","selectedValues","setValue","useState","useEffect","state","values","addValue","includes","concat","removeValue","filter","existingValue","React","createElement","ThemeProvider","StyledSwitchGroup","_extends","$isDisabled","$isInvalid","length","$isReadOnly","$orientation","$theme","classNames","role","SwitchGroupContext","Provider","displayName"],"mappings":";;;;;;;;;;;AAQA,MAAMA,cAAc,GAAG,aAAa,CAAA;AACpC,MAAMC,SAAS,GAAG,sBAAsB,CAAA;;AAExC;AACA;AACA;AACA;AACO,MAAMC,WAAmD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC5F,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,KAAK,GAAGC,YAAY,CAACC,OAAO;MAC5BC,aAAa;MACbC,WAAW;MACXC,UAAU;MACVC,SAAS;MACTC,UAAU;MACVC,UAAU;MACVC,KAAK;MACLC,QAAQ;MACRC,WAAW,GAAGC,sBAAsB,CAACC,QAAQ;AAC7CC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,KAAAA;AAEF,KAAC,GAAGpB,KAAK;AADJqB,IAAAA,cAAc,GAAAC,wBAAA,CACftB,KAAK,EAAAu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,CAACU,MAAM,CAAEC,aAAa,IAAKA,aAAa,KAAKhB,KAAK,CAAC,CAAC,CAAA;AAC7E,SAAA;AACF,OAAA;AACF,KAAA;GACD,CAAA;AAED,EAAA,oBACEiB,
|
|
1
|
+
{"version":3,"file":"SwitchGroup.js","sources":["../../../src/components/switch-group/SwitchGroup.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport { Comp, ColorPalette } from '../../types';\nimport { SwitchGroupOrientation, SwitchGroupProps } from './types';\nimport { SwitchGroupContext } from './context';\nimport { StyledSwitchGroup } from './styles';\nimport { ThemeProvider, useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SwitchGroup';\nconst CLASSNAME = 'redsift-switch-group';\n\n/**\n * The SwitchGroup component.\n * Can be used as controlled or uncontrolled.\n */\nexport const SwitchGroup: Comp<SwitchGroupProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n color = ColorPalette.primary,\n defaultValues,\n description,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n label,\n onChange,\n orientation = SwitchGroupOrientation.vertical,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const [selectedValues, setValue] = useState<string[]>(value || defaultValues || []);\n useEffect(() => {\n if (value) {\n state.setValue(value);\n }\n }, [value]);\n\n const state = {\n value: selectedValues,\n isDisabled: isDisabled || false,\n isReadOnly: isReadOnly || false,\n setValue(values: string[]) {\n if (isReadOnly || isDisabled) {\n return;\n }\n\n setValue(values);\n },\n addValue(value: string) {\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n if (onChange) {\n onChange(selectedValues.concat(value));\n }\n }\n },\n removeValue(value: string) {\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter((existingValue) => existingValue !== value));\n if (onChange) {\n onChange(selectedValues.filter((existingValue) => existingValue !== value));\n }\n }\n },\n };\n\n return (\n <ThemeProvider value={{ theme }}>\n <StyledSwitchGroup\n color={color}\n {...forwardedProps}\n $isDisabled={isDisabled}\n $isInvalid={isInvalid || (isRequired && selectedValues.length === 0)}\n $isReadOnly={isReadOnly}\n $orientation={orientation}\n $theme={theme}\n aria-disabled={isDisabled}\n className={classNames(SwitchGroup.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n role=\"group\"\n >\n <span className={`${SwitchGroup.className}-label`}>\n {label}\n {isRequired ? ' *' : null}\n </span>\n <div className={`${SwitchGroup.className}-switches`}>\n <SwitchGroupContext.Provider value={state}>{children}</SwitchGroupContext.Provider>\n </div>\n <span className={`${SwitchGroup.className}-description`}>{description}</span>\n </StyledSwitchGroup>\n </ThemeProvider>\n );\n});\nSwitchGroup.className = CLASSNAME;\nSwitchGroup.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SwitchGroup","forwardRef","props","ref","children","className","color","ColorPalette","primary","defaultValues","description","isDisabled","isInvalid","isReadOnly","isRequired","label","onChange","orientation","SwitchGroupOrientation","vertical","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","selectedValues","setValue","useState","useEffect","state","values","addValue","includes","concat","removeValue","filter","existingValue","React","createElement","ThemeProvider","StyledSwitchGroup","_extends","$isDisabled","$isInvalid","length","$isReadOnly","$orientation","$theme","classNames","role","SwitchGroupContext","Provider","displayName"],"mappings":";;;;;;;;;;;AAQA,MAAMA,cAAc,GAAG,aAAa,CAAA;AACpC,MAAMC,SAAS,GAAG,sBAAsB,CAAA;;AAExC;AACA;AACA;AACA;AACO,MAAMC,WAAmD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC5F,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,KAAK,GAAGC,YAAY,CAACC,OAAO;MAC5BC,aAAa;MACbC,WAAW;MACXC,UAAU;MACVC,SAAS;MACTC,UAAU;MACVC,UAAU;MACVC,KAAK;MACLC,QAAQ;MACRC,WAAW,GAAGC,sBAAs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SAAA,CAAA;AAAW,GAAA,eAClDkC,KAAA,CAAAC,aAAA,CAACY,kBAAkB,CAACC,QAAQ,EAAA;AAAC/B,IAAAA,KAAK,EAAES,KAAAA;AAAM,GAAA,EAAE3B,QAAsC,CAC/E,CAAC,eACNmC,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMnC,IAAAA,SAAS,EAAG,CAAA,EAAEL,WAAW,CAACK,SAAU,CAAA,YAAA,CAAA;GAAgBK,EAAAA,WAAkB,CAC3D,CACN,CAAC,CAAA;AAEpB,CAAC,EAAC;AACFV,WAAW,CAACK,SAAS,GAAGN,SAAS,CAAA;AACjCC,WAAW,CAACsD,WAAW,GAAGxD,cAAc;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
|
-
const SwitchGroupContext = /*#__PURE__*/
|
|
3
|
+
const SwitchGroupContext = /*#__PURE__*/React.createContext(null);
|
|
4
4
|
|
|
5
5
|
export { SwitchGroupContext };
|
|
6
6
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../src/components/switch-group/context.ts"],"sourcesContent":["import React from 'react';\nimport { SwitchGroupState } from './types';\n\nexport const SwitchGroupContext =\n React.createContext<SwitchGroupState | null>(null);\n"],"names":["SwitchGroupContext","React","createContext"],"mappings":";;AAGO,MAAMA,kBAAkB,gBAC7BC,
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../src/components/switch-group/context.ts"],"sourcesContent":["import React from 'react';\nimport { SwitchGroupState } from './types';\n\nexport const SwitchGroupContext =\n React.createContext<SwitchGroupState | null>(null);\n"],"names":["SwitchGroupContext","React","createContext"],"mappings":";;AAGO,MAAMA,kBAAkB,gBAC7BC,KAAK,CAACC,aAAa,CAA0B,IAAI;;;;"}
|
package/components/text/Text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { StyledText } from './styles.js';
|
|
5
5
|
import { FontFamily } from '../../types/fonts.js';
|
|
@@ -28,7 +28,7 @@ const Text = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28
28
|
} = props,
|
|
29
29
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
30
30
|
const theme = useTheme(propsTheme);
|
|
31
|
-
return /*#__PURE__*/
|
|
31
|
+
return /*#__PURE__*/React.createElement(StyledText, _extends({
|
|
32
32
|
as: as
|
|
33
33
|
}, forwardedProps, {
|
|
34
34
|
className: classNames(Text.className, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sources":["../../../src/components/text/Text.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\nimport { Comp, FontFamily } from '../../types';\nimport { StyledText } from './styles';\nimport { TextProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Text';\nconst CLASSNAME = 'redsift-text';\n\n/**\n * The Text component.\n */\nexport const Text: Comp<TextProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n as,\n children,\n className,\n color,\n fontFamily = FontFamily.poppins,\n fontSize,\n fontWeight,\n lineHeight,\n noWrap,\n theme: propsTheme,\n variant,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n return (\n <StyledText\n as={as}\n {...forwardedProps}\n className={classNames(Text.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n $as={as}\n $color={color}\n $fontFamily={fontFamily}\n $fontSize={fontSize}\n $fontWeight={fontWeight}\n $lineHeight={lineHeight}\n $noWrap={noWrap}\n $theme={theme}\n $variant={variant}\n >\n {children}\n </StyledText>\n );\n});\nText.className = CLASSNAME;\nText.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Text","forwardRef","props","ref","as","children","className","color","fontFamily","FontFamily","poppins","fontSize","fontWeight","lineHeight","noWrap","theme","propsTheme","variant","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","StyledText","_extends","classNames","$as","$color","$fontFamily","$fontSize","$fontWeight","$lineHeight","$noWrap","$theme","$variant","displayName"],"mappings":";;;;;;;;AAOA,MAAMA,cAAc,GAAG,MAAM,CAAA;AAC7B,MAAMC,SAAS,GAAG,cAAc,CAAA;;AAEhC;AACA;AACA;AACO,MAAMC,IAAqC,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC9E,MAAM;MACJC,EAAE;MACFC,QAAQ;MACRC,SAAS;MACTC,KAAK;MACLC,UAAU,GAAGC,UAAU,CAACC,OAAO;MAC/BC,QAAQ;MACRC,UAAU;MACVC,UAAU;MACVC,MAAM;AACNC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,OAAAA;AAEF,KAAC,GAAGf,KAAK;AADJgB,IAAAA,cAAc,GAAAC,wBAAA,CACfjB,KAAK,EAAAkB,SAAA,CAAA,CAAA;AAET,EAAA,MAAML,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,oBACEM,
|
|
1
|
+
{"version":3,"file":"Text.js","sources":["../../../src/components/text/Text.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\nimport classNames from 'classnames';\nimport { Comp, FontFamily } from '../../types';\nimport { StyledText } from './styles';\nimport { TextProps } from './types';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Text';\nconst CLASSNAME = 'redsift-text';\n\n/**\n * The Text component.\n */\nexport const Text: Comp<TextProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n as,\n children,\n className,\n color,\n fontFamily = FontFamily.poppins,\n fontSize,\n fontWeight,\n lineHeight,\n noWrap,\n theme: propsTheme,\n variant,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n return (\n <StyledText\n as={as}\n {...forwardedProps}\n className={classNames(Text.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n $as={as}\n $color={color}\n $fontFamily={fontFamily}\n $fontSize={fontSize}\n $fontWeight={fontWeight}\n $lineHeight={lineHeight}\n $noWrap={noWrap}\n $theme={theme}\n $variant={variant}\n >\n {children}\n </StyledText>\n );\n});\nText.className = CLASSNAME;\nText.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Text","forwardRef","props","ref","as","children","className","color","fontFamily","FontFamily","poppins","fontSize","fontWeight","lineHeight","noWrap","theme","propsTheme","variant","forwardedProps","_objectWithoutProperties","_excluded","useTheme","React","createElement","StyledText","_extends","classNames","$as","$color","$fontFamily","$fontSize","$fontWeight","$lineHeight","$noWrap","$theme","$variant","displayName"],"mappings":";;;;;;;;AAOA,MAAMA,cAAc,GAAG,MAAM,CAAA;AAC7B,MAAMC,SAAS,GAAG,cAAc,CAAA;;AAEhC;AACA;AACA;AACO,MAAMC,IAAqC,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC9E,MAAM;MACJC,EAAE;MACFC,QAAQ;MACRC,SAAS;MACTC,KAAK;MACLC,UAAU,GAAGC,UAAU,CAACC,OAAO;MAC/BC,QAAQ;MACRC,UAAU;MACVC,UAAU;MACVC,MAAM;AACNC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,OAAAA;AAEF,KAAC,GAAGf,KAAK;AADJgB,IAAAA,cAAc,GAAAC,wBAAA,CACfjB,KAAK,EAAAkB,SAAA,CAAA,CAAA;AAET,EAAA,MAAML,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,oBACEM,KAAA,CAAAC,aAAA,CAACC,UAAU,EAAAC,QAAA,CAAA;AACTrB,IAAAA,EAAE,EAAEA,EAAAA;AAAG,GAAA,EACHc,cAAc,EAAA;IAClBZ,SAAS,EAAEoB,UAAU,CAAC1B,IAAI,CAACM,SAAS,EAAEA,SAAS,CAAE;AACjDH,IAAAA,GAAG,EAAEA,GAAiC;AACtCwB,IAAAA,GAAG,EAAEvB,EAAG;AACRwB,IAAAA,MAAM,EAAErB,KAAM;AACdsB,IAAAA,WAAW,EAAErB,UAAW;AACxBsB,IAAAA,SAAS,EAAEnB,QAAS;AACpBoB,IAAAA,WAAW,EAAEnB,UAAW;AACxBoB,IAAAA,WAAW,EAAEnB,UAAW;AACxBoB,IAAAA,OAAO,EAAEnB,MAAO;AAChBoB,IAAAA,MAAM,EAAEnB,KAAM;AACdoB,IAAAA,QAAQ,EAAElB,OAAAA;AAAQ,GAAA,CAAA,EAEjBZ,QACS,CAAC,CAAA;AAEjB,CAAC,EAAC;AACFL,IAAI,CAACM,SAAS,GAAGP,SAAS,CAAA;AAC1BC,IAAI,CAACoC,WAAW,GAAGtC,cAAc;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import React, { forwardRef, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound.js';
|
|
5
5
|
import { TextAreaVariant } from './types.js';
|
|
@@ -55,7 +55,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
55
55
|
const theme = useTheme(propsTheme);
|
|
56
56
|
const color = Object.values(ButtonsColorPalette).includes(propsColor) ? propsColor : isColored ? 'primary' : 'grey';
|
|
57
57
|
const isGradient = color === ButtonsColorPalette.radar;
|
|
58
|
-
const _textareaRef =
|
|
58
|
+
const _textareaRef = React.useRef(null);
|
|
59
59
|
const textareaRef = propsTextareaRef !== null && propsTextareaRef !== void 0 ? propsTextareaRef : _textareaRef;
|
|
60
60
|
const {
|
|
61
61
|
isFocusVisible,
|
|
@@ -97,7 +97,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
97
97
|
recomputeNumberOfRows(textareaRef.current);
|
|
98
98
|
}
|
|
99
99
|
}, [textareaRef, recomputeNumberOfRows, value]);
|
|
100
|
-
return /*#__PURE__*/
|
|
100
|
+
return /*#__PURE__*/React.createElement(StyledTextArea, _extends({
|
|
101
101
|
width: width
|
|
102
102
|
}, focusWithinProps, forwardedProps, {
|
|
103
103
|
$hasContent: isFocusWithin || Boolean(isControlled ? propsValue : value) || Boolean(placeholder),
|
|
@@ -113,24 +113,24 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
113
113
|
$variant: variant,
|
|
114
114
|
className: classNames(TextArea.className, className),
|
|
115
115
|
ref: ref
|
|
116
|
-
}), /*#__PURE__*/
|
|
116
|
+
}), /*#__PURE__*/React.createElement("fieldset", {
|
|
117
117
|
"aria-hidden": "true",
|
|
118
118
|
className: `${TextArea.className}-text-area-wrapper__fieldset`
|
|
119
|
-
}, /*#__PURE__*/
|
|
119
|
+
}, /*#__PURE__*/React.createElement("legend", {
|
|
120
120
|
id: labelId,
|
|
121
121
|
className: `${TextArea.className}-text-area-wrapper-fieldset__legend`
|
|
122
|
-
}, label ? /*#__PURE__*/
|
|
122
|
+
}, label ? /*#__PURE__*/React.createElement("span", null, label) : null)), label ? /*#__PURE__*/React.createElement("label", {
|
|
123
123
|
className: `${TextArea.className}__label`
|
|
124
|
-
}, /*#__PURE__*/
|
|
124
|
+
}, /*#__PURE__*/React.createElement("span", null, label)) : null, /*#__PURE__*/React.createElement("div", {
|
|
125
125
|
className: `${TextArea.className}__text-area-wrapper`
|
|
126
|
-
}, leftIcon ? /*#__PURE__*/
|
|
126
|
+
}, leftIcon ? /*#__PURE__*/React.createElement(Icon, _extends({
|
|
127
127
|
color: isDisabled ? 'question' : 'black'
|
|
128
128
|
}, leftIcon, {
|
|
129
129
|
"aria-hidden": "true",
|
|
130
130
|
className: "left"
|
|
131
|
-
})) : null, /*#__PURE__*/
|
|
131
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
132
132
|
className: `${TextArea.className}-text-area-wrapper__text-area`
|
|
133
|
-
}, /*#__PURE__*/
|
|
133
|
+
}, /*#__PURE__*/React.createElement("textarea", _extends({}, textareaProps, {
|
|
134
134
|
onBlur: event => {
|
|
135
135
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
136
136
|
onBlurProps === null || onBlurProps === void 0 ? void 0 : onBlurProps(event);
|
|
@@ -153,7 +153,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
153
153
|
ref: textareaRef,
|
|
154
154
|
value: isControlled ? propsValue : value,
|
|
155
155
|
rows: rows
|
|
156
|
-
}))), after ? /*#__PURE__*/
|
|
156
|
+
}))), after ? /*#__PURE__*/React.createElement(Flexbox, {
|
|
157
157
|
className: `${TextArea.className}-text-area-wrapper__toolbar`,
|
|
158
158
|
gap: "8px"
|
|
159
159
|
}, typeof after === 'function' ? after(isControlled ? propsValue : value, isDisabled, isInvalid || isRequired && !(isControlled ? propsValue : value), isRequired) : after) : null));
|