@hitachivantara/uikit-react-core 5.26.5 → 5.27.0
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/dist/cjs/components/ActionsGeneric/ActionsGeneric.cjs +2 -4
- package/dist/cjs/components/ActionsGeneric/ActionsGeneric.cjs.map +1 -1
- package/dist/cjs/components/AppSwitcher/Action/Action.cjs +1 -2
- package/dist/cjs/components/AppSwitcher/Action/Action.cjs.map +1 -1
- package/dist/cjs/components/Avatar/Avatar.cjs +4 -5
- package/dist/cjs/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/cjs/components/BulkActions/BulkActions.cjs +2 -3
- package/dist/cjs/components/BulkActions/BulkActions.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +2 -4
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Drawer/Drawer.cjs +2 -1
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/Loading/Loading.cjs +1 -4
- package/dist/cjs/components/Loading/Loading.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs +2 -2
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs +2 -2
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
- package/dist/cjs/components/Stack/Stack.cjs.map +1 -1
- package/dist/cjs/components/Table/TableCell/TableCell.cjs +2 -2
- package/dist/cjs/components/Table/TableCell/TableCell.cjs.map +1 -1
- package/dist/cjs/components/Table/TableHeader/TableHeader.cjs +6 -4
- package/dist/cjs/components/Table/TableHeader/TableHeader.cjs.map +1 -1
- package/dist/cjs/components/Table/TableRow/TableRow.cjs +3 -4
- package/dist/cjs/components/Table/TableRow/TableRow.cjs.map +1 -1
- package/dist/cjs/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.cjs +4 -2
- package/dist/cjs/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.cjs.map +1 -1
- package/dist/cjs/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.cjs +5 -2
- package/dist/cjs/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.cjs.map +1 -1
- package/dist/cjs/components/Table/renderers/renderers.cjs +6 -3
- package/dist/cjs/components/Table/renderers/renderers.cjs.map +1 -1
- package/dist/cjs/components/Tag/Tag.cjs +2 -5
- package/dist/cjs/components/Tag/Tag.cjs.map +1 -1
- package/dist/cjs/hooks/useTheme.cjs +12 -1
- package/dist/cjs/hooks/useTheme.cjs.map +1 -1
- package/dist/esm/components/ActionsGeneric/ActionsGeneric.js +2 -4
- package/dist/esm/components/ActionsGeneric/ActionsGeneric.js.map +1 -1
- package/dist/esm/components/AppSwitcher/Action/Action.js +1 -2
- package/dist/esm/components/AppSwitcher/Action/Action.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +1 -2
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/BulkActions/BulkActions.js +2 -3
- package/dist/esm/components/BulkActions/BulkActions.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +2 -4
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Drawer/Drawer.js +2 -1
- package/dist/esm/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/components/Loading/Loading.js +2 -5
- package/dist/esm/components/Loading/Loading.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js +2 -2
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js +2 -2
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/components/Stack/Stack.js.map +1 -1
- package/dist/esm/components/Table/TableCell/TableCell.js +2 -2
- package/dist/esm/components/Table/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/Table/TableHeader/TableHeader.js +6 -4
- package/dist/esm/components/Table/TableHeader/TableHeader.js.map +1 -1
- package/dist/esm/components/Table/TableRow/TableRow.js +3 -4
- package/dist/esm/components/Table/TableRow/TableRow.js.map +1 -1
- package/dist/esm/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.js +4 -2
- package/dist/esm/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.js.map +1 -1
- package/dist/esm/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.js +5 -2
- package/dist/esm/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.js.map +1 -1
- package/dist/esm/components/Table/renderers/renderers.js +6 -3
- package/dist/esm/components/Table/renderers/renderers.js.map +1 -1
- package/dist/esm/components/Tag/Tag.js +2 -5
- package/dist/esm/components/Tag/Tag.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +13 -2
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/types/index.d.ts +51 -21
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../../src/components/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport {\n staticClasses,\n useClasses,\n calculateOffset,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { withTooltip } from \"../withTooltip\";\nimport {\n HvScrollToTooltipPositions,\n HvScrollToVerticalOption,\n HvScrollToVerticalPositions,\n} from \"../types\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToVerticalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme,
|
|
1
|
+
{"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../../src/components/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport {\n staticClasses,\n useClasses,\n calculateOffset,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { withTooltip } from \"../withTooltip\";\nimport {\n HvScrollToTooltipPositions,\n HvScrollToVerticalOption,\n HvScrollToVerticalPositions,\n} from \"../types\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToVerticalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme, colors } = useTheme();\n\n const elementId = useUniqueId(id, \"hvVerticalScrollto\");\n\n const [selectedIndex, setScrollTo] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n href,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition, false);\n });\n }, [options, tooltipPosition]);\n\n const tabs = options.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvVerticalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n aria-label={option.label}\n />\n );\n });\n\n const positionOffset = calculateOffset(options.length);\n const backgroundColor = hexToRgbA(\n colors?.atmo2,\n activeTheme?.scrollTo.backgroundColorOpacity\n );\n\n return (\n <ol\n className={cx(\n css({ backgroundColor }),\n classes.root,\n {\n [classes.positionFixed]: position === \"fixed\",\n [classes.positionAbsolute]: position === \"absolute\",\n },\n className\n )}\n style={{ top: `calc(50% - ${positionOffset}px)`, ...style }}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["HvScrollToVertical","props","id","defaultSelectedIndex","scrollElementId","href","onChange","onClick","onEnter","className","classes","classesProp","options","offset","position","tooltipPosition","style","others","useDefaultProps","css","cx","useClasses","activeTheme","colors","useTheme","elementId","useUniqueId","selectedIndex","setScrollTo","useScrollTo","handleSelection","event","value","index","preventDefault","wrappedOnChange","tooltipWrappers","useMemo","map","option","withTooltip","label","tabs","selected","tooltipWrapper","HvVerticalScrollListItem","setId","onKeyDown","isKey","key","positionOffset","calculateOffset","length","backgroundColor","hexToRgbA","atmo2","scrollTo","backgroundColorOpacity","root","positionFixed","positionAbsolute","top","children"],"mappings":";;;;;;;;;;;;;;AA0EaA,MAAAA,qBAAqBA,CAACC,UAAmC;AAC9D,QAAA;AAAA,IACJC;AAAAA,IACAC,uBAAuB;AAAA,IACvBC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,SAAS;AAAA,IACTC,WAAW;AAAA,IACXC,kBAAkB;AAAA,IAClBC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,sBAAsBjB,KAAK;AAEzC,QAAA;AAAA,IAAES;AAAAA,IAASS;AAAAA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,OAAOE;AAAAA,IADdF,GAAAA,OAAOU,OAAOV,OAAOE,KAE3B;AAAA,EAAA,CAEJ;AAEKS,QAAAA,iBAAiBC,wBAAAA,gBAAgBvC,QAAQwC,MAAM;AACrD,QAAMC,kBAAkBC,UAAAA,UACtB/B,iCAAQgC,OACRjC,2CAAakC,SAASC,sBACxB;AAEA,wCACE,MAAA;AAAA,IACEhD,WAAWW,GACTD,IAAI;AAAA,MAAEkC;AAAAA,IAAAA,CAAiB,GACvB3C,QAAQgD,MACR;AAAA,MACE,CAAChD,QAAQiD,aAAa,GAAG7C,aAAa;AAAA,MACtC,CAACJ,QAAQkD,gBAAgB,GAAG9C,aAAa;AAAA,OAE3CL,SACF;AAAA,IACAO,OAAO;AAAA,MAAE6C,KAAM,cAAaX;AAAAA,MAAqB,GAAGlC;AAAAA,IAAM;AAAA,IAC1Dd,IAAIuB;AAAAA,IAAU,GACVR;AAAAA,IAAM6C,UAETpB;AAAAA,EAAAA,CACC;AAER;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.cjs","sources":["../../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import React, { useMemo, useRef, useCallback } from \"react\";\n\nimport { useTheme } from \"@mui/material/styles\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\n\nimport isString from \"lodash/isString\";\nimport isBoolean from \"lodash/isBoolean\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"Stack.cjs","sources":["../../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import React, { useMemo, useRef, useCallback } from \"react\";\n\nimport { useTheme } from \"@mui/material/styles\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\n\nimport isString from \"lodash/isString\";\nimport isBoolean from \"lodash/isBoolean\";\n\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\nimport { useWidth } from \"@core/hooks/useWidth\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvFocus } from \"@core/components/Focus\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useClasses, staticClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction, width, breakpoints) => {\n if (isString(direction)) return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const processedDirection = useMemo(\n () => getDirection(direction, width, breakpoints.keys),\n [direction, width, breakpoints]\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (isBoolean(divider) && divider) {\n return (\n <MuiDivider\n orientation={\n processedDirection === \"column\" ? \"horizontal\" : \"vertical\"\n }\n flexItem={processedDirection === \"row\"}\n role=\"separator\"\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [divider, dividerProps, processedDirection]);\n\n return (\n <div\n ref={containerRef}\n className={cx(\n classes.root,\n classes[processedDirection],\n classes[spacing],\n className\n )}\n {...others}\n >\n {React.Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent()}\n {withNavigation ? (\n <HvFocus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={\n processedDirection === \"column\"\n ? 1\n : React.Children.count(children) || 0\n }\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </HvFocus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n"],"names":["getDirection","direction","width","breakpoints","isString","i","indexOf","undefined","HvStack","props","classes","classesProp","className","children","spacing","divider","withNavigation","dividerProps","others","useDefaultProps","cx","useClasses","useWidth","containerRef","useRef","useTheme","processedDirection","useMemo","keys","getDividerComponent","useCallback","isBoolean","MuiDivider","orientation","flexItem","role","ref","root","React","Children","map","child","_Fragment","_jsx","HvFocus","rootRef","focusDisabled","strategy","navigationJump","count","filterClass"],"mappings":";;;;;;;;;;;;;;;;;AAmDA,MAAMA,eAAeA,CAACC,WAAWC,OAAOC,gBAAgB;AACtD,MAAIC,kBAAAA,QAASH,SAAS;AAAUA,WAAAA;AAEvBI,WAAAA,IAAIF,YAAYG,QAAQJ,KAAK,GAAGG,KAAK,GAAGA,KAAK,GAAG;AACvD,QAAIJ,UAAUE,YAA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4B,OAAOpC,MAAM;AAC1C,6CACEqC,WAAAA,UAAA;AAAA,QAAA7B,UACGE,CAAAA,WAAWV,MAAM,KAAKwB,uBACtBb,iBACC2B,2BAAAA,IAACC,eAAO;AAAA,UACNC,SAAStB;AAAAA,UACTuB,eAAe;AAAA,UACfC,UAAS;AAAA,UACTC,gBACEtB,uBAAuB,WACnB,IACAY,uBAAMC,SAASU,MAAMpC,QAAQ,KAAK;AAAA,UAExCqC,aAAY;AAAA,UAAOrC,yCAEnB,OAAA;AAAA,YAAKD,WAAU;AAAA,YAAOC,UAAE4B;AAAAA,UAAAA,CAAW;AAAA,QAC5B,CAAA,IAETA,KACD;AAAA,MAAA,CACD;AAAA,IAAA,CAEL;AAAA,EAAA,CACE;AAET;;;"}
|
|
@@ -44,7 +44,7 @@ const HvTableCell = React.forwardRef((props, externalRef) => {
|
|
|
44
44
|
css
|
|
45
45
|
} = TableCell_styles.useClasses(classesProp);
|
|
46
46
|
const {
|
|
47
|
-
|
|
47
|
+
colors,
|
|
48
48
|
rootId
|
|
49
49
|
} = useTheme.useTheme();
|
|
50
50
|
const tableContext = React.useContext(TableContext.default);
|
|
@@ -58,7 +58,7 @@ const HvTableCell = React.forwardRef((props, externalRef) => {
|
|
|
58
58
|
setSortedColorValue(theme.getVarValue(uikitStyles.theme.table.rowSortedColor, rootId));
|
|
59
59
|
setSortedColorAlpha(theme.getVarValue(uikitStyles.theme.table.rowSortedColorAlpha, rootId));
|
|
60
60
|
setSortedColor(getSortedColor(sortedColorValue, sortedColorAlpha));
|
|
61
|
-
}, [
|
|
61
|
+
}, [colors, sortedColorValue, sortedColorAlpha, rootId]);
|
|
62
62
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, {
|
|
63
63
|
ref: externalRef,
|
|
64
64
|
role: Component === defaultComponent ? null : "cell",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.cjs","sources":["../../../../../src/components/Table/TableCell/TableCell.tsx"],"sourcesContent":["import capitalize from \"lodash/capitalize\";\n\nimport {\n CSSProperties,\n forwardRef,\n TdHTMLAttributes,\n useContext,\n useEffect,\n useState,\n} from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableCell.styles\";\n\nexport { staticClasses as tableCellClasses };\n\nexport type HvTableCellClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableCellProps\n extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to td. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant | \"listcheckbox\" | \"listactions\";\n /** Specify the cell's type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** Whether or not the cell is part of a sorted column. */\n sorted?: boolean;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableCellClasses;\n}\n\nconst defaultComponent = \"td\";\n\nconst getSortedColor = (color?: string, alpha?: string) => {\n return checkValidHexColorValue(color) && alpha\n ? hexToRgbA(color, parseFloat(alpha))\n : color;\n};\n\n/**\n * `HvTableCell` acts as a `td` element and inherits styles from its context\n */\nexport const HvTableCell = forwardRef<HTMLElement, HvTableCellProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style,\n classes: classesProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sorted = false,\n resizable = false,\n resizing = false,\n ...others\n } = props;\n const { classes, cx, css } = useClasses(classesProp);\n const {
|
|
1
|
+
{"version":3,"file":"TableCell.cjs","sources":["../../../../../src/components/Table/TableCell/TableCell.tsx"],"sourcesContent":["import capitalize from \"lodash/capitalize\";\n\nimport {\n CSSProperties,\n forwardRef,\n TdHTMLAttributes,\n useContext,\n useEffect,\n useState,\n} from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableCell.styles\";\n\nexport { staticClasses as tableCellClasses };\n\nexport type HvTableCellClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableCellProps\n extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to td. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant | \"listcheckbox\" | \"listactions\";\n /** Specify the cell's type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** Whether or not the cell is part of a sorted column. */\n sorted?: boolean;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableCellClasses;\n}\n\nconst defaultComponent = \"td\";\n\nconst getSortedColor = (color?: string, alpha?: string) => {\n return checkValidHexColorValue(color) && alpha\n ? hexToRgbA(color, parseFloat(alpha))\n : color;\n};\n\n/**\n * `HvTableCell` acts as a `td` element and inherits styles from its context\n */\nexport const HvTableCell = forwardRef<HTMLElement, HvTableCellProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style,\n classes: classesProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sorted = false,\n resizable = false,\n resizing = false,\n ...others\n } = props;\n const { classes, cx, css } = useClasses(classesProp);\n const { colors, rootId } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const [sortedColorValue, setSortedColorValue] = useState<string>();\n const [sortedColorAlpha, setSortedColorAlpha] = useState<string>();\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n\n const Component =\n component || tableContext?.components?.Td || defaultComponent;\n\n const [sortedColor, setSortedColor] = useState(\n getSortedColor(sortedColorValue, sortedColorAlpha)\n );\n\n useEffect(() => {\n setSortedColorValue(getVarValue(theme.table.rowSortedColor, rootId));\n setSortedColorAlpha(getVarValue(theme.table.rowSortedColorAlpha, rootId));\n\n setSortedColor(getSortedColor(sortedColorValue, sortedColorAlpha));\n }, [colors, sortedColorValue, sortedColorAlpha, rootId]);\n\n return (\n <Component\n ref={externalRef}\n role={Component === defaultComponent ? null : \"cell\"}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: sortedColor,\n },\n }),\n stickyColumn &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundImage: `linear-gradient(to right, ${sortedColor}, ${sortedColor})`,\n },\n }),\n {\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes.variantListHead]:\n tableContext.variant === \"listrow\" && type !== \"body\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n [classes.sorted]: sorted,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n },\n className\n )}\n {...others}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["defaultComponent","getSortedColor","color","alpha","checkValidHexColorValue","hexToRgbA","parseFloat","HvTableCell","forwardRef","props","externalRef","children","component","className","style","classes","classesProp","align","variant","type","typeProp","stickyColumn","stickyColumnMostLeft","stickyColumnLeastRight","groupColumnMostLeft","groupColumnMostRight","sorted","resizable","resizing","others","cx","css","useClasses","colors","rootId","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","sortedColorValue","setSortedColorValue","useState","sortedColorAlpha","setSortedColorAlpha","Component","components","Td","sortedColor","setSortedColor","useEffect","getVarValue","theme","table","rowSortedColor","rowSortedColorAlpha","ref","role","root","staticClasses","backgroundColor","backgroundImage","capitalize","variantList","variantListHead"],"mappings":";;;;;;;;;;;;;;;AAkEA,MAAMA,mBAAmB;AAEzB,MAAMC,iBAAiBA,CAACC,OAAgBC,UAAmB;AAClDC,SAAAA,wBAAAA,wBAAwBF,KAAK,KAAKC,QACrCE,UAAAA,UAAUH,OAAOI,WAAWH,KAAK,CAAC,IAClCD;AACN;AAKO,MAAMK,cAAcC,MAAAA,WACzB,CAACC,OAAOC,gBAAgB;;AAChB,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC,QAAQ;AAAA,IACRC,UAAU;AAAA,IACVC,MAAMC;AAAAA,IACNC,eAAe;AAAA,IACfC,uBAAuB;AAAA,IACvBC,yBAAyB;AAAA,IACzBC,sBAAsB;AAAA,IACtBC,uBAAuB;AAAA,IACvBC,SAAS;AAAA,IACTC,YAAY;AAAA,IACZC,WAAW;AAAA,IACX,GAAGC;AAAAA,EACDpB,IAAAA;AACE,QAAA;AAAA,IAAEM;AAAAA,IAASe;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,iBAAAA,WAAWhB,WAAW;AAC7C,QAAA;AAAA,IAAEiB;AAAAA,IAAQC;AAAAA,MAAWC,SAAS,SAAA;AAC9BC,QAAAA,eAAeC,iBAAWC,aAAAA,OAAY;AACtCC,QAAAA,sBAAsBF,iBAAWG,oBAAAA,OAAmB;AAE1D,QAAM,CAACC,kBAAkBC,mBAAmB,IAAIC,MAAiB,SAAA;AACjE,QAAM,CAACC,kBAAkBC,mBAAmB,IAAIF,MAAiB,SAAA;AAE3DxB,QAAAA,OAAOC,aAAYmB,2DAAqBpB,SAAQ;AAEtD,QAAM2B,YACJlC,eAAawB,kDAAcW,eAAdX,mBAA0BY,OAAMhD;A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,sBAAsB,GAAGA;AAAAA,MAClC,CAACR,QAAQS,mBAAmB,GAAGA;AAAAA,MAC/B,CAACT,QAAQU,oBAAoB,GAAGA;AAAAA,MAChC,CAACV,QAAQY,SAAS,GAAGA;AAAAA,MACrB,CAACZ,QAAQa,QAAQ,GAAGA;AAAAA,OAEtBf,SACF;AAAA,IAAE,GACEgB;AAAAA,IAAMlB;AAAAA,EAAAA,CAGD;AAEf,CACF;;;"}
|
|
@@ -37,17 +37,17 @@ const HvTableHeader = React.forwardRef(({
|
|
|
37
37
|
resizerProps = {},
|
|
38
38
|
resizable = false,
|
|
39
39
|
resizing = false,
|
|
40
|
+
sortButtonProps,
|
|
40
41
|
...others
|
|
41
42
|
}, externalRef) => {
|
|
42
|
-
var _a
|
|
43
|
+
var _a;
|
|
43
44
|
const {
|
|
44
45
|
classes,
|
|
45
46
|
cx,
|
|
46
47
|
css
|
|
47
48
|
} = TableHeader_styles.useClasses(classesProp);
|
|
48
49
|
const {
|
|
49
|
-
|
|
50
|
-
selectedMode
|
|
50
|
+
colors
|
|
51
51
|
} = useTheme.useTheme();
|
|
52
52
|
const tableContext = React.useContext(TableContext.default);
|
|
53
53
|
const tableSectionContext = React.useContext(TableSectionContext.default);
|
|
@@ -65,7 +65,7 @@ const HvTableHeader = React.forwardRef(({
|
|
|
65
65
|
style,
|
|
66
66
|
className: cx(classes.root, classes[type], type === "body" && css({
|
|
67
67
|
[`&.${TableHeader_styles.staticClasses.sorted}`]: {
|
|
68
|
-
backgroundColor: material.alpha(material.hexToRgb((
|
|
68
|
+
backgroundColor: material.alpha(material.hexToRgb((colors == null ? void 0 : colors.atmo1) || uikitStyles.theme.colors.atmo1), 0.4)
|
|
69
69
|
}
|
|
70
70
|
}), {
|
|
71
71
|
[classes.groupColumnMostLeft]: groupColumnMostLeft,
|
|
@@ -91,6 +91,8 @@ const HvTableHeader = React.forwardRef(({
|
|
|
91
91
|
className: classes.sortButton,
|
|
92
92
|
icon: true,
|
|
93
93
|
overrideIconColors: false,
|
|
94
|
+
"aria-label": "Sort",
|
|
95
|
+
...sortButtonProps,
|
|
94
96
|
children: /* @__PURE__ */ jsxRuntime.jsx(Sort, {
|
|
95
97
|
className: classes.sortIcon
|
|
96
98
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeader.cjs","sources":["../../../../../src/components/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n ThHTMLAttributes,\n useContext,\n useMemo,\n} from \"react\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { hexToRgb, alpha } from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTypography, HvTypographyProps } from \"@core/components/Typography\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvButton } from \"@core/components/Button\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { getSortIcon, isParagraph } from \"./utils\";\nimport { useClasses, staticClasses } from \"./TableHeader.styles\";\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\n\nexport { staticClasses as tableHeaderClasses };\n\nexport type HvTableHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableHeaderProps\n extends Omit<ThHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to th. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** The scope of cells that the header element relates to. */\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\";\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant;\n /** Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is sorted */\n sorted?: boolean;\n /** Whether or not the cell is sortable */\n sortable?: boolean;\n /** Set sort direction icon and aria-sort. */\n sortDirection?: \"ascending\" | \"descending\" | false;\n /** Extra props to be passed onto the text in the header. */\n headerTextProps?: HvTypographyProps;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** The resize props injected in the resize handler */\n resizerProps?: HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableHeaderClasses;\n}\n\nconst defaultComponent = \"th\";\n\n/**\n * `HvTableHeader` acts as a `th` element and inherits styles from its context\n */\nexport const HvTableHeader = forwardRef<HTMLElement, HvTableHeaderProps>(\n (\n {\n children,\n component,\n className,\n style,\n classes: classesProp,\n scope: scopeProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sortDirection = \"none\",\n sorted,\n sortable,\n headerTextProps,\n resizerProps = {},\n resizable = false,\n resizing = false,\n ...others\n },\n externalRef\n ) => {\n const { classes, cx, css } = useClasses(classesProp);\n\n const { activeTheme, selectedMode } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n const isHeadCell = type === \"head\";\n\n const scope = scopeProp ?? isHeadCell ? \"col\" : \"row\";\n\n const Sort = useMemo(\n () => getSortIcon(sorted && sortDirection),\n [sorted, sortDirection]\n );\n\n const Component =\n component || tableContext?.components?.Th || defaultComponent;\n\n const role =\n Component === defaultComponent\n ? null\n : isHeadCell\n ? \"columnheader\"\n : \"rowheader\";\n const paragraph = isParagraph(children);\n\n return (\n <Component\n ref={externalRef}\n role={role}\n scope={scope}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: alpha(\n hexToRgb(\n activeTheme?.colors?.modes[selectedMode].atmo1 ||\n theme.colors.atmo1\n ),\n 0.4\n ),\n },\n }),\n {\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.sortable]: sortable,\n [classes.sorted]: sorted,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n },\n className\n )}\n aria-sort={sortable ? sortDirection : undefined}\n {...others}\n >\n <div\n className={cx(classes.headerContent, {\n [classes[`alignFlex${capitalize(align)}`]]: align !== \"inherit\",\n })}\n >\n {isHeadCell && sortable && (\n <HvButton\n className={classes.sortButton}\n icon\n overrideIconColors={false}\n >\n <Sort className={classes.sortIcon} />\n </HvButton>\n )}\n <HvTypography\n component=\"div\"\n className={cx({\n [classes.headerText]: !paragraph,\n [classes.headerParagraph]: paragraph,\n [classes.sortableHeaderText]: sortable,\n })}\n variant=\"label\"\n {...headerTextProps}\n >\n {children}\n </HvTypography>\n {resizable && <div {...resizerProps} className={classes.resizer} />}\n </div>\n </Component>\n );\n }\n);\n"],"names":["defaultComponent","HvTableHeader","forwardRef","children","component","className","style","classes","classesProp","scope","scopeProp","align","variant","type","typeProp","stickyColumn","stickyColumnMostLeft","stickyColumnLeastRight","groupColumnMostLeft","groupColumnMostRight","sortDirection","sorted","sortable","headerTextProps","resizerProps","resizable","resizing","others","externalRef","cx","css","useClasses","activeTheme","selectedMode","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","isHeadCell","Sort","useMemo","getSortIcon","Component","components","Th","role","paragraph","isParagraph","ref","root","staticClasses","backgroundColor","alpha","hexToRgb","colors","modes","atmo1","theme","variantList","capitalize","undefined","headerContent","HvButton","sortButton","icon","overrideIconColors","sortIcon","_jsx","HvTypography","headerText","headerParagraph","sortableHeaderText","resizer"],"mappings":";;;;;;;;;;;;;;;;AA2EA,MAAMA,mBAAmB;AAKZC,MAAAA,gBAAgBC,iBAC3B,CACE;AAAA,EACEC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC,OAAOC;AAAAA,EACPC,QAAQ;AAAA,EACRC,UAAU;AAAA,EACVC,MAAMC;AAAAA,EACNC,eAAe;AAAA,EACfC,uBAAuB;AAAA,EACvBC,yBAAyB;AAAA,EACzBC,sBAAsB;AAAA,EACtBC,uBAAuB;AAAA,EACvBC,gBAAgB;AAAA,EAChBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,eAAe,CAAC;AAAA,EAChBC,YAAY;AAAA,EACZC,WAAW;AAAA,EACX,GAAGC;AACL,GACAC,gBACG;;AACG,QAAA;AAAA,IAAErB;AAAAA,IAASsB;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,mBAAAA,WAAWvB,WAAW;AAE7C,QAAA;AAAA,IAAEwB;AAAAA,IAAaC;AAAAA,MAAiBC,SAAS,SAAA;AACzCC,QAAAA,eAAeC,iBAAWC,aAAAA,OAAY;AACtCC,QAAAA,sBAAsBF,iBAAWG,oBAAAA,OAAmB;AAEpD1B,QAAAA,OAAOC,aAAYwB,2DAAqBzB,SAAQ;AACtD,QAAM2B,aAAa3B,SAAS;AAEtBJ,QAAAA,QAAQC,aAAa8B,aAAa,QAAQ;AAE1CC,QAAAA,OAAOC,cACX,MAAMC,kBAAYtB,UAAUD,aAAa,GACzC,CAACC,QAAQD,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AAAA,IAAMxB,0CAEV,OAAA;AAAA,MACEE,WAAWwB,GAAGtB,QAAQwD,eAAe;AAAA,QACnC,CAACxD,QAAS,YAAWsD,oBAAAA,QAAWlD,KAAK,GAAG,CAAC,GAAGA,UAAU;AAAA,MAAA,CACvD;AAAA,MAAER,WAEFqC,cAAclB,2CACZ0C,OAAAA,UAAQ;AAAA,QACP3D,WAAWE,QAAQ0D;AAAAA,QACnBC,MAAI;AAAA,QACJC,oBAAoB;AAAA,QAAMhE,yCAEzBsC,MAAI;AAAA,UAACpC,WAAWE,QAAQ6D;AAAAA,QAAAA,CAAW;AAAA,MAAA,CAC5B,GAEZC,2BAAAA,IAACC,yBAAY;AAAA,QACXlE,WAAU;AAAA,QACVC,WAAWwB,GAAG;AAAA,UACZ,CAACtB,QAAQgE,UAAU,GAAG,CAACvB;AAAAA,UACvB,CAACzC,QAAQiE,eAAe,GAAGxB;AAAAA,UAC3B,CAACzC,QAAQkE,kBAAkB,GAAGnD;AAAAA,QAAAA,CAC/B;AAAA,QACDV,SAAQ;AAAA,QAAO,GACXW;AAAAA,QAAepB;AAAAA,MAAAA,CAGP,GACbsB,aAAa4C,2BAAAA,IAAA,OAAA;AAAA,QAAA,GAAS7C;AAAAA,QAAcnB,WAAWE,QAAQmE;AAAAA,MAAAA,CAAU,CAAC;AAAA,IAAA,CAChE;AAAA,EAAA,CACI;AAEf,CACF;;;"}
|
|
1
|
+
{"version":3,"file":"TableHeader.cjs","sources":["../../../../../src/components/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n ThHTMLAttributes,\n useContext,\n useMemo,\n} from \"react\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { hexToRgb, alpha } from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTypography, HvTypographyProps } from \"@core/components/Typography\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvButton, HvButtonProps } from \"@core/components/Button\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { getSortIcon, isParagraph } from \"./utils\";\nimport { useClasses, staticClasses } from \"./TableHeader.styles\";\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\n\nexport { staticClasses as tableHeaderClasses };\n\nexport type HvTableHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableHeaderProps\n extends Omit<ThHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to th. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** The scope of cells that the header element relates to. */\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\";\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant;\n /** Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is sorted */\n sorted?: boolean;\n /** Whether or not the cell is sortable */\n sortable?: boolean;\n /** Set sort direction icon and aria-sort. */\n sortDirection?: \"ascending\" | \"descending\" | false;\n /** Extra props to be passed onto the text in the header. */\n headerTextProps?: HvTypographyProps;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** The resize props injected in the resize handler */\n resizerProps?: HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableHeaderClasses;\n /** Extra props to be passed onto the sort button in the header. */\n sortButtonProps?: HvButtonProps;\n}\n\nconst defaultComponent = \"th\";\n\n/**\n * `HvTableHeader` acts as a `th` element and inherits styles from its context\n */\nexport const HvTableHeader = forwardRef<HTMLElement, HvTableHeaderProps>(\n (\n {\n children,\n component,\n className,\n style,\n classes: classesProp,\n scope: scopeProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sortDirection = \"none\",\n sorted,\n sortable,\n headerTextProps,\n resizerProps = {},\n resizable = false,\n resizing = false,\n sortButtonProps,\n ...others\n },\n externalRef\n ) => {\n const { classes, cx, css } = useClasses(classesProp);\n\n const { colors } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n const isHeadCell = type === \"head\";\n\n const scope = scopeProp ?? isHeadCell ? \"col\" : \"row\";\n\n const Sort = useMemo(\n () => getSortIcon(sorted && sortDirection),\n [sorted, sortDirection]\n );\n\n const Component =\n component || tableContext?.components?.Th || defaultComponent;\n\n const role =\n Component === defaultComponent\n ? null\n : isHeadCell\n ? \"columnheader\"\n : \"rowheader\";\n const paragraph = isParagraph(children);\n\n return (\n <Component\n ref={externalRef}\n role={role}\n scope={scope}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: alpha(\n hexToRgb(colors?.atmo1 || theme.colors.atmo1),\n 0.4\n ),\n },\n }),\n {\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.sortable]: sortable,\n [classes.sorted]: sorted,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n },\n className\n )}\n aria-sort={sortable ? sortDirection : undefined}\n {...others}\n >\n <div\n className={cx(classes.headerContent, {\n [classes[`alignFlex${capitalize(align)}`]]: align !== \"inherit\",\n })}\n >\n {isHeadCell && sortable && (\n <HvButton\n className={classes.sortButton}\n icon\n overrideIconColors={false}\n aria-label=\"Sort\"\n {...sortButtonProps}\n >\n <Sort className={classes.sortIcon} />\n </HvButton>\n )}\n <HvTypography\n component=\"div\"\n className={cx({\n [classes.headerText]: !paragraph,\n [classes.headerParagraph]: paragraph,\n [classes.sortableHeaderText]: sortable,\n })}\n variant=\"label\"\n {...headerTextProps}\n >\n {children}\n </HvTypography>\n {resizable && <div {...resizerProps} className={classes.resizer} />}\n </div>\n </Component>\n );\n }\n);\n"],"names":["defaultComponent","HvTableHeader","forwardRef","children","component","className","style","classes","classesProp","scope","scopeProp","align","variant","type","typeProp","stickyColumn","stickyColumnMostLeft","stickyColumnLeastRight","groupColumnMostLeft","groupColumnMostRight","sortDirection","sorted","sortable","headerTextProps","resizerProps","resizable","resizing","sortButtonProps","others","externalRef","cx","css","useClasses","colors","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","isHeadCell","Sort","useMemo","getSortIcon","Component","components","Th","role","paragraph","isParagraph","ref","root","staticClasses","backgroundColor","alpha","hexToRgb","atmo1","theme","variantList","capitalize","undefined","headerContent","HvButton","sortButton","icon","overrideIconColors","sortIcon","_jsx","HvTypography","headerText","headerParagraph","sortableHeaderText","resizer"],"mappings":";;;;;;;;;;;;;;;;AA6EA,MAAMA,mBAAmB;AAKZC,MAAAA,gBAAgBC,iBAC3B,CACE;AAAA,EACEC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC,OAAOC;AAAAA,EACPC,QAAQ;AAAA,EACRC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Z,CAACvB,QAAQ8D,UAAU,GAAG,CAACrB;AAAAA,UACvB,CAACzC,QAAQ+D,eAAe,GAAGtB;AAAAA,UAC3B,CAACzC,QAAQgE,kBAAkB,GAAGjD;AAAAA,QAAAA,CAC/B;AAAA,QACDV,SAAQ;AAAA,QAAO,GACXW;AAAAA,QAAepB;AAAAA,MAAAA,CAGP,GACbsB,aAAa0C,2BAAAA,IAAA,OAAA;AAAA,QAAA,GAAS3C;AAAAA,QAAcnB,WAAWE,QAAQiE;AAAAA,MAAAA,CAAU,CAAC;AAAA,IAAA,CAChE;AAAA,EAAA,CACI;AAEf,CACF;;;"}
|
|
@@ -15,7 +15,7 @@ const getStripedColor = (color, opacity = 0.6) => {
|
|
|
15
15
|
return checkValidHexColorValue.checkValidHexColorValue(color) ? hexToRgbA.hexToRgbA(color, opacity) : color;
|
|
16
16
|
};
|
|
17
17
|
const HvTableRow = React.forwardRef((props, externalRef) => {
|
|
18
|
-
var _a
|
|
18
|
+
var _a;
|
|
19
19
|
const {
|
|
20
20
|
classes: classesProp,
|
|
21
21
|
className,
|
|
@@ -32,8 +32,7 @@ const HvTableRow = React.forwardRef((props, externalRef) => {
|
|
|
32
32
|
css
|
|
33
33
|
} = TableRow_styles.useClasses(classesProp);
|
|
34
34
|
const {
|
|
35
|
-
|
|
36
|
-
selectedMode,
|
|
35
|
+
colors,
|
|
37
36
|
rootId
|
|
38
37
|
} = useTheme.useTheme();
|
|
39
38
|
const tableContext = React.useContext(TableContext.default);
|
|
@@ -50,7 +49,7 @@ const HvTableRow = React.forwardRef((props, externalRef) => {
|
|
|
50
49
|
setOdd(theme.getVarValue(uikitStyles.theme.table.rowStripedBackgroundColorOdd, rootId));
|
|
51
50
|
setStripedColorEven(getStripedColor(even));
|
|
52
51
|
setStripedColorOdd(getStripedColor(odd));
|
|
53
|
-
}, [
|
|
52
|
+
}, [colors, even, odd, rootId]);
|
|
54
53
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, {
|
|
55
54
|
ref: externalRef,
|
|
56
55
|
className: cx(tableSectionContext.filterClassName, classes.root, classes[type], striped && css({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.cjs","sources":["../../../../../src/components/Table/TableRow/TableRow.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableRow.styles\";\n\nexport { staticClasses as tableRowClasses };\n\nexport type HvTableRowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableRowProps\n extends HvBaseProps<HTMLTableRowElement, \"children\"> {\n /** Content to be rendered */\n children: React.ReactNode;\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to tbody. */\n component?: React.ElementType;\n /** Whether the table row will shade on hover. */\n hover?: boolean;\n /** Whether the table row will have the selected shading. */\n selected?: boolean;\n /** Whether the table row is expanded. */\n expanded?: boolean;\n /** Whether the table row background is striped. */\n striped?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableRowClasses;\n}\n\nconst defaultComponent = \"tr\";\n\nconst getStripedColor = (color?: string, opacity: number = 0.6) => {\n return checkValidHexColorValue(color) ? hexToRgbA(color, opacity) : color;\n};\n\n/**\n * `HvTableRow` acts as a `tr` element and inherits styles from its context\n */\nexport const HvTableRow = forwardRef<HTMLElement, HvTableRowProps>(\n (props, externalRef) => {\n const {\n classes: classesProp,\n className,\n component,\n hover = false,\n selected = false,\n expanded = false,\n striped = false,\n ...others\n } = props;\n const { classes, cx, css } = useClasses(classesProp);\n const {
|
|
1
|
+
{"version":3,"file":"TableRow.cjs","sources":["../../../../../src/components/Table/TableRow/TableRow.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableRow.styles\";\n\nexport { staticClasses as tableRowClasses };\n\nexport type HvTableRowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableRowProps\n extends HvBaseProps<HTMLTableRowElement, \"children\"> {\n /** Content to be rendered */\n children: React.ReactNode;\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to tbody. */\n component?: React.ElementType;\n /** Whether the table row will shade on hover. */\n hover?: boolean;\n /** Whether the table row will have the selected shading. */\n selected?: boolean;\n /** Whether the table row is expanded. */\n expanded?: boolean;\n /** Whether the table row background is striped. */\n striped?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableRowClasses;\n}\n\nconst defaultComponent = \"tr\";\n\nconst getStripedColor = (color?: string, opacity: number = 0.6) => {\n return checkValidHexColorValue(color) ? hexToRgbA(color, opacity) : color;\n};\n\n/**\n * `HvTableRow` acts as a `tr` element and inherits styles from its context\n */\nexport const HvTableRow = forwardRef<HTMLElement, HvTableRowProps>(\n (props, externalRef) => {\n const {\n classes: classesProp,\n className,\n component,\n hover = false,\n selected = false,\n expanded = false,\n striped = false,\n ...others\n } = props;\n const { classes, cx, css } = useClasses(classesProp);\n const { colors, rootId } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const [even, setEven] = useState<string | undefined>();\n const [odd, setOdd] = useState<string | undefined>();\n\n const type = tableSectionContext?.type || \"body\";\n\n const isList = tableContext.variant === \"listrow\";\n\n const Component =\n component || tableContext?.components?.Tr || defaultComponent;\n\n const [stripedColorEven, setStripedColorEven] = useState(\n getStripedColor(even)\n );\n const [stripedColorOdd, setStripedColorOdd] = useState(\n getStripedColor(odd)\n );\n\n useEffect(() => {\n setEven(getVarValue(theme.table.rowStripedBackgroundColorEven, rootId));\n setOdd(getVarValue(theme.table.rowStripedBackgroundColorOdd, rootId));\n\n setStripedColorEven(getStripedColor(even));\n setStripedColorOdd(getStripedColor(odd));\n }, [colors, even, odd, rootId]);\n\n return (\n <Component\n ref={externalRef}\n className={cx(\n tableSectionContext.filterClassName,\n classes.root,\n classes[type],\n striped &&\n css({\n \"&:nth-of-type(even)\": {\n backgroundColor: stripedColorEven,\n \"&:hover\": {\n backgroundColor: theme.table.rowHoverColor,\n },\n },\n \"&:nth-of-type(odd)\": {\n backgroundColor: stripedColorOdd,\n \"&:hover\": {\n backgroundColor: theme.table.rowHoverColor,\n },\n },\n }),\n {\n [classes.hover]: hover,\n [classes.selected]: selected,\n [classes.expanded]: expanded,\n [classes.striped]: striped,\n [classes.variantList]: isList && type === \"body\",\n [classes.variantListHead]: isList && type === \"head\",\n },\n className\n )}\n role={Component === defaultComponent ? null : \"row\"}\n {...others}\n />\n );\n }\n);\n"],"names":["defaultComponent","getStripedColor","color","opacity","checkValidHexColorValue","hexToRgbA","HvTableRow","forwardRef","props","externalRef","classes","classesProp","className","component","hover","selected","expanded","striped","others","cx","css","useClasses","colors","rootId","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","even","setEven","useState","odd","setOdd","type","isList","variant","Component","components","Tr","stripedColorEven","setStripedColorEven","stripedColorOdd","setStripedColorOdd","useEffect","getVarValue","theme","table","rowStripedBackgroundColorEven","rowStripedBackgroundColorOdd","ref","filterClassName","root","backgroundColor","rowHoverColor","variantList","variantListHead","role"],"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M,CAAC;AAEhDtB,wBAAAA,gBAAgB6B,IAAI,CAAC;AACtB7B,uBAAAA,gBAAgBgC,GAAG,CAAC;AAAA,KACtC,CAACX,QAAQQ,MAAMG,KAAKV,MAAM,CAAC;AAE9B,wCACGe,WAAS;AAAA,IACRa,KAAK1C;AAAAA,IACLG,WAAWO,GACTS,oBAAoBwB,iBACpB1C,QAAQ2C,MACR3C,QAAQyB,IAAI,GACZlB,WACEG,IAAI;AAAA,MACF,uBAAuB;AAAA,QACrBkC,iBAAiBb;AAAAA,QACjB,WAAW;AAAA,UACTa,iBAAiBP,YAAAA,MAAMC,MAAMO;AAAAA,QAC/B;AAAA,MACF;AAAA,MACA,sBAAsB;AAAA,QACpBD,iBAAiBX;AAAAA,QACjB,WAAW;AAAA,UACTW,iBAAiBP,YAAAA,MAAMC,MAAMO;AAAAA,QAC/B;AAAA,MACF;AAAA,IAAA,CACD,GACH;AAAA,MACE,CAAC7C,QAAQI,KAAK,GAAGA;AAAAA,MACjB,CAACJ,QAAQK,QAAQ,GAAGA;AAAAA,MACpB,CAACL,QAAQM,QAAQ,GAAGA;AAAAA,MACpB,CAACN,QAAQO,OAAO,GAAGA;AAAAA,MACnB,CAACP,QAAQ8C,WAAW,GAAGpB,UAAUD,SAAS;AAAA,MAC1C,CAACzB,QAAQ+C,eAAe,GAAGrB,UAAUD,SAAS;AAAA,OAEhDvB,SACF;AAAA,IACA8C,MAAMpB,cAActC,mBAAmB,OAAO;AAAA,IAAM,GAChDkB;AAAAA,EAAAA,CACL;AAEL,CACF;;;"}
|
|
@@ -11,7 +11,8 @@ const normalizeProgressBar = (value, max) => {
|
|
|
11
11
|
const HvProgressColumnCell = ({
|
|
12
12
|
partial,
|
|
13
13
|
total,
|
|
14
|
-
color = "primary"
|
|
14
|
+
color = "primary",
|
|
15
|
+
"aria-labelledby": ariaLabelledBy
|
|
15
16
|
}) => {
|
|
16
17
|
const {
|
|
17
18
|
classes
|
|
@@ -31,7 +32,8 @@ const HvProgressColumnCell = ({
|
|
|
31
32
|
},
|
|
32
33
|
color,
|
|
33
34
|
variant: "determinate",
|
|
34
|
-
value: percentage
|
|
35
|
+
value: percentage,
|
|
36
|
+
"aria-labelledby": ariaLabelledBy
|
|
35
37
|
})
|
|
36
38
|
})
|
|
37
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressColumnCell.cjs","sources":["../../../../../../src/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.tsx"],"sourcesContent":["import MuiLinearProgress from \"@mui/material/LinearProgress\";\n\nimport { useClasses } from \"./ProgressColumnCell.styles\";\n\nexport interface HvProgressColumnCellProp {\n /** Current value of the bar. */\n partial: number;\n /** Maximum value of the bar. */\n total: number;\n /** The color of the bar. */\n color?: \"primary\" | \"secondary\";\n}\n\nexport const normalizeProgressBar = (value: number, max: number) => {\n return max > 0 ? Math.floor((value * 100) / max) : 0;\n};\n\nexport const HvProgressColumnCell = ({\n partial,\n total,\n color = \"primary\",\n}: HvProgressColumnCellProp): JSX.Element => {\n const { classes } = useClasses();\n\n const percentage = normalizeProgressBar(partial, total);\n\n return (\n <div className={classes.root}>\n <div className={classes.linearProgressContainer}>\n <MuiLinearProgress\n className={classes.linearProgress}\n classes={{\n root: classes.linearProgressRoot,\n colorPrimary: classes.linearProgressColorPrimary,\n barColorPrimary: classes.linearProgressBarColorPrimary,\n barColorSecondary: classes.linearProgressBarColorSecondary,\n }}\n color={color}\n variant=\"determinate\"\n value={percentage}\n />\n </div>\n </div>\n );\n};\n"],"names":["normalizeProgressBar","value","max","Math","floor","HvProgressColumnCell","partial","total","color","classes","useClasses","percentage","className","root","children","linearProgressContainer","MuiLinearProgress","linearProgress","linearProgressRoot","colorPrimary","linearProgressColorPrimary","barColorPrimary","linearProgressBarColorPrimary","barColorSecondary","linearProgressBarColorSecondary","variant"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"ProgressColumnCell.cjs","sources":["../../../../../../src/components/Table/renderers/ProgressColumnCell/ProgressColumnCell.tsx"],"sourcesContent":["import MuiLinearProgress from \"@mui/material/LinearProgress\";\n\nimport { useClasses } from \"./ProgressColumnCell.styles\";\n\nexport interface HvProgressColumnCellProp {\n /** Current value of the bar. */\n partial: number;\n /** Maximum value of the bar. */\n total: number;\n /** The color of the bar. */\n color?: \"primary\" | \"secondary\";\n \"aria-labelledby\"?: string;\n}\n\nexport const normalizeProgressBar = (value: number, max: number) => {\n return max > 0 ? Math.floor((value * 100) / max) : 0;\n};\n\nexport const HvProgressColumnCell = ({\n partial,\n total,\n color = \"primary\",\n \"aria-labelledby\": ariaLabelledBy,\n}: HvProgressColumnCellProp): JSX.Element => {\n const { classes } = useClasses();\n\n const percentage = normalizeProgressBar(partial, total);\n\n return (\n <div className={classes.root}>\n <div className={classes.linearProgressContainer}>\n <MuiLinearProgress\n className={classes.linearProgress}\n classes={{\n root: classes.linearProgressRoot,\n colorPrimary: classes.linearProgressColorPrimary,\n barColorPrimary: classes.linearProgressBarColorPrimary,\n barColorSecondary: classes.linearProgressBarColorSecondary,\n }}\n color={color}\n variant=\"determinate\"\n value={percentage}\n aria-labelledby={ariaLabelledBy}\n />\n </div>\n </div>\n );\n};\n"],"names":["normalizeProgressBar","value","max","Math","floor","HvProgressColumnCell","partial","total","color","ariaLabelledBy","classes","useClasses","percentage","className","root","children","linearProgressContainer","MuiLinearProgress","linearProgress","linearProgressRoot","colorPrimary","linearProgressColorPrimary","barColorPrimary","linearProgressBarColorPrimary","barColorSecondary","linearProgressBarColorSecondary","variant"],"mappings":";;;;;;;AAcaA,MAAAA,uBAAuBA,CAACC,OAAeC,QAAgB;AAClE,SAAOA,MAAM,IAAIC,KAAKC,MAAOH,QAAQ,MAAOC,GAAG,IAAI;AACrD;AAEO,MAAMG,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC,QAAQ;AAAA,EACR,mBAAmBC;AACK,MAAmB;AACrC,QAAA;AAAA,IAAEC;AAAAA,MAAYC,0BAAW,WAAA;AAEzBC,QAAAA,aAAaZ,qBAAqBM,SAASC,KAAK;AAEtD,wCACE,OAAA;AAAA,IAAKM,WAAWH,QAAQI;AAAAA,IAAKC,yCAC3B,OAAA;AAAA,MAAKF,WAAWH,QAAQM;AAAAA,MAAwBD,yCAC7CE,oCAAiB;AAAA,QAChBJ,WAAWH,QAAQQ;AAAAA,QACnBR,SAAS;AAAA,UACPI,MAAMJ,QAAQS;AAAAA,UACdC,cAAcV,QAAQW;AAAAA,UACtBC,iBAAiBZ,QAAQa;AAAAA,UACzBC,mBAAmBd,QAAQe;AAAAA,QAC7B;AAAA,QACAjB;AAAAA,QACAkB,SAAQ;AAAA,QACRzB,OAAOW;AAAAA,QACP,mBAAiBH;AAAAA,MAAAA,CAClB;AAAA,IAAA,CACE;AAAA,EAAA,CACF;AAET;;;"}
|
|
@@ -22,10 +22,13 @@ const HvSwitchColumnCell = ({
|
|
|
22
22
|
className: classes.switchNo,
|
|
23
23
|
children: falseLabel
|
|
24
24
|
}), /* @__PURE__ */ jsxRuntime.jsx(BaseSwitch.HvBaseSwitch, {
|
|
25
|
-
"aria-label": switchLabel,
|
|
26
25
|
checked,
|
|
27
26
|
value,
|
|
28
|
-
...switchProps
|
|
27
|
+
...switchProps,
|
|
28
|
+
inputProps: {
|
|
29
|
+
"aria-label": switchLabel,
|
|
30
|
+
...switchProps == null ? void 0 : switchProps.inputProps
|
|
31
|
+
}
|
|
29
32
|
}), trueLabel != null && /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, {
|
|
30
33
|
"aria-hidden": "true",
|
|
31
34
|
variant: "body",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchColumnCell.cjs","sources":["../../../../../../src/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.tsx"],"sourcesContent":["import { HvBaseSwitch, HvBaseSwitchProps } from \"@core/components/BaseSwitch\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { useClasses } from \"./SwitchColumnCell.styles\";\n\nexport interface HvSwitchColumnCellProp {\n /** Whether the switch is checked or not. */\n checked: boolean;\n /** The switch label. */\n value: number | string | undefined;\n /** The value of the switch. */\n switchLabel: string;\n /** The right switch label. */\n falseLabel?: string;\n /** The left switch label. */\n trueLabel?: string;\n /** Extra props to be passed to the switch. */\n switchProps?: HvBaseSwitchProps;\n}\n\nexport const HvSwitchColumnCell = ({\n checked,\n value,\n switchLabel,\n falseLabel,\n trueLabel,\n switchProps,\n}: HvSwitchColumnCellProp): JSX.Element => {\n const { classes } = useClasses();\n\n return (\n <>\n {falseLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"body\"\n className={classes.switchNo}\n >\n {falseLabel}\n </HvTypography>\n )}\n <HvBaseSwitch\n
|
|
1
|
+
{"version":3,"file":"SwitchColumnCell.cjs","sources":["../../../../../../src/components/Table/renderers/SwitchColumnCell/SwitchColumnCell.tsx"],"sourcesContent":["import { HvBaseSwitch, HvBaseSwitchProps } from \"@core/components/BaseSwitch\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { useClasses } from \"./SwitchColumnCell.styles\";\n\nexport interface HvSwitchColumnCellProp {\n /** Whether the switch is checked or not. */\n checked: boolean;\n /** The switch label. */\n value: number | string | undefined;\n /** The value of the switch. */\n switchLabel: string;\n /** The right switch label. */\n falseLabel?: string;\n /** The left switch label. */\n trueLabel?: string;\n /** Extra props to be passed to the switch. */\n switchProps?: HvBaseSwitchProps;\n}\n\nexport const HvSwitchColumnCell = ({\n checked,\n value,\n switchLabel,\n falseLabel,\n trueLabel,\n switchProps,\n}: HvSwitchColumnCellProp): JSX.Element => {\n const { classes } = useClasses();\n\n return (\n <>\n {falseLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"body\"\n className={classes.switchNo}\n >\n {falseLabel}\n </HvTypography>\n )}\n <HvBaseSwitch\n checked={checked}\n value={value}\n {...switchProps}\n inputProps={{ \"aria-label\": switchLabel, ...switchProps?.inputProps }}\n />\n {trueLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"body\"\n className={classes.switchYes}\n >\n {trueLabel}\n </HvTypography>\n )}\n </>\n );\n};\n"],"names":["HvSwitchColumnCell","checked","value","switchLabel","falseLabel","trueLabel","switchProps","classes","useClasses","_Fragment","children","HvTypography","variant","className","switchNo","_jsx","HvBaseSwitch","inputProps","switchYes"],"mappings":";;;;;;AAoBO,MAAMA,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACsB,MAAmB;AACnC,QAAA;AAAA,IAAEC;AAAAA,MAAYC,wBAAW,WAAA;AAE/B,yCACEC,WAAAA,UAAA;AAAA,IAAAC,WACGN,cAAc,uCACZO,WAAAA,cAAY;AAAA,MACX,eAAY;AAAA,MACZC,SAAQ;AAAA,MACRC,WAAWN,QAAQO;AAAAA,MAASJ,UAE3BN;AAAAA,IAAAA,CACW,GAEhBW,2BAAAA,IAACC,yBAAY;AAAA,MACXf;AAAAA,MACAC;AAAAA,MAAa,GACTI;AAAAA,MACJW,YAAY;AAAA,QAAE,cAAcd;AAAAA,QAAa,GAAGG,2CAAaW;AAAAA,MAAW;AAAA,IACrE,CAAA,GACAZ,aAAa,uCACXM,WAAAA,cAAY;AAAA,MACX,eAAY;AAAA,MACZC,SAAQ;AAAA,MACRC,WAAWN,QAAQW;AAAAA,MAAUR,UAE5BL;AAAAA,IAAAA,CACW,CACf;AAAA,EAAA,CACD;AAEN;;"}
|
|
@@ -167,7 +167,8 @@ function hvDropdownColumn(col, id, placeholder, disabledPlaceholder, onChange) {
|
|
|
167
167
|
onChange: (val) => onChange == null ? void 0 : onChange(row.id, val),
|
|
168
168
|
disabled: dsbld,
|
|
169
169
|
dropdownProps: {
|
|
170
|
-
"aria-labelledby": setId.setId(id, column.id)
|
|
170
|
+
"aria-labelledby": setId.setId(id, column.id) || column.id || id
|
|
171
|
+
// TODO - to be reviewed because it doesn't make much sense
|
|
171
172
|
}
|
|
172
173
|
});
|
|
173
174
|
},
|
|
@@ -182,7 +183,8 @@ function hvProgressColumn(col, getPartial, getTotal, color) {
|
|
|
182
183
|
return {
|
|
183
184
|
Cell: (cellProps) => {
|
|
184
185
|
const {
|
|
185
|
-
row
|
|
186
|
+
row,
|
|
187
|
+
column
|
|
186
188
|
} = cellProps;
|
|
187
189
|
const partial = (getPartial == null ? void 0 : getPartial(row)) || 0;
|
|
188
190
|
const total = getTotal == null ? void 0 : getTotal(row);
|
|
@@ -190,7 +192,8 @@ function hvProgressColumn(col, getPartial, getTotal, color) {
|
|
|
190
192
|
return /* @__PURE__ */ jsxRuntime.jsx(ProgressColumnCell.HvProgressColumnCell, {
|
|
191
193
|
partial,
|
|
192
194
|
total,
|
|
193
|
-
color
|
|
195
|
+
color,
|
|
196
|
+
"aria-labelledby": column.id
|
|
194
197
|
});
|
|
195
198
|
}
|
|
196
199
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.cjs","sources":["../../../../../src/components/Table/renderers/renderers.tsx"],"sourcesContent":["import { ClassNames } from \"@emotion/react\";\n\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTag, HvTagProps } from \"@core/components/Tag\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport {\n HvOverflowTooltip,\n HvOverflowTooltipProps,\n} from \"@core/components/OverflowTooltip\";\nimport { HvBaseSwitchProps } from \"@core/components/BaseSwitch\";\nimport { HvListValue } from \"@core/components/List\";\n\nimport {\n HvTableHeaderRenderer,\n HvCellProps,\n HvTableColumnConfig,\n HvRowInstance,\n} from \"../hooks/useTable\";\nimport { HvDateColumnCell } from \"./DateColumnCell\";\nimport { HvSwitchColumnCell } from \"./SwitchColumnCell\";\nimport { HvProgressColumnCell } from \"./ProgressColumnCell\";\nimport { HvDropdownColumnCell } from \"./DropdownColumnCell\";\nimport { hvStringFallback, hvNumberFallback } from \"../utils\";\n\nexport function hvTextColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n overflowTooltipProps: Omit<HvOverflowTooltipProps, \"data\"> = {}\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvOverflowTooltip\n data={hvStringFallback(value)}\n {...overflowTooltipProps}\n />\n ),\n sortType: \"alphanumeric\",\n ...col,\n };\n}\n\nexport function hvNumberColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(col: HvTableColumnConfig<D, H>): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => <>{hvNumberFallback(value)}</>,\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n}\n\nexport function hvDateColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n dateFormat?: string\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvDateColumnCell date={value} dateFormat={dateFormat} />\n ),\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n}\n\nexport function hvExpandColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n expandRowButtonAriaLabel: string,\n collapseRowButtonAriaLabel: string,\n getCanRowExpand?: (row: HvRowInstance<D, H>) => boolean,\n ExpandedIcon: React.ReactNode = <DropUpXS />,\n CollapsedIcon: React.ReactNode = <DropDownXS />\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n const expandedProps = row.getToggleRowExpandedProps?.();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <ClassNames>\n {({ css }) => (\n <>\n {hasContent && (\n <HvButton\n icon\n aria-label={\n row.isExpanded\n ? collapseRowButtonAriaLabel\n : expandRowButtonAriaLabel\n }\n aria-expanded={row.isExpanded}\n onClick={expandedProps?.onClick}\n classes={{\n root: css({\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n transform: \"translateY(-50%)\",\n }),\n }}\n >\n {row.isExpanded ? ExpandedIcon : CollapsedIcon}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n )}\n </ClassNames>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n A extends object = Record<string, unknown>\n>(\n col: HvTableColumnConfig<D, H>,\n valueDataKey: keyof A,\n colorDataKey: keyof A,\n textColorDataKey: keyof A,\n fromRowData: boolean = false,\n tagProps?: HvTagProps\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n if (!value) {\n return <>—</>;\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"body\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvSwitchColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n switchLabel: string,\n falseLabel?: string,\n trueLabel?: string,\n switchProps?: HvBaseSwitchProps\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n return (\n <HvSwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n id: string,\n placeholder: string,\n disabledPlaceholder: string,\n onChange?: (identifier: string, value: HvListValue) => void\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row, column } = cellProps;\n const dsbld = value.length < 1;\n return (\n <HvDropdownColumnCell\n values={value}\n placeholder={dsbld ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val)}\n disabled={dsbld}\n dropdownProps={{\n \"aria-labelledby\": setId(id, column.id),\n }}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n getPartial?: (row: HvRowInstance<D, H>) => number,\n getTotal?: (row: HvRowInstance<D, H>) => number,\n color?: \"primary\" | \"secondary\"\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { row } = cellProps;\n const partial = getPartial?.(row) || 0;\n const total = getTotal?.(row);\n\n if (total) {\n return (\n <HvProgressColumnCell partial={partial} total={total} color={color} />\n );\n }\n\n return <>—</>;\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"names":["hvTextColumn","col","overflowTooltipProps","Cell","value","HvOverflowTooltip","data","hvStringFallback","sortType","hvNumberColumn","_Fragment","children","hvNumberFallback","align","hvDateColumn","dateFormat","HvDateColumnCell","date","sortDescFirst","hvExpandColumn","expandRowButtonAriaLabel","collapseRowButtonAriaLabel","getCanRowExpand","ExpandedIcon","DropUpXS","CollapsedIcon","_jsx","DropDownXS","cellProps","row","expandedProps","getToggleRowExpandedProps","hasContent","ClassNames","css","HvButton","icon","isExpanded","onClick","classes","root","position","left","top","transform","cellStyle","hvTagColumn","valueDataKey","colorDataKey","textColorDataKey","fromRowData","tagProps","name","color","textColor","original","HvTag","label","HvTypography","variant","type","style","tabIndex","paddingTop","paddingBottom","hvSwitchColumn","switchLabel","falseLabel","trueLabel","switchProps","HvSwitchColumnCell","checked","id","hvDropdownColumn","placeholder","disabledPlaceholder","onChange","column","dsbld","length","HvDropdownColumnCell","values","val","disabled","dropdownProps","setId","hvProgressColumn","getPartial","getTotal","partial","total","HvProgressColumnCell"],"mappings":";;;;;;;;;;;;;;;AA2BO,SAASA,aAIdC,KACAC,uBAA6D,IAClC;AACpB,SAAA;AAAA,IACLC,MAAMA,CAAC;AAAA,MAAEC;AAAAA,IAAAA,qCACNC,gBAAAA,mBAAiB;AAAA,MAChBC,MAAMC,2BAAiBH,KAAK;AAAA,MAAE,GAC1BF;AAAAA,IAAAA,CACL;AAAA,IAEHM,UAAU;AAAA,IACV,GAAGP;AAAAA,EAAAA;AAEP;AAEO,SAASQ,eAGdR,KAA2D;AACpD,SAAA;AAAA,IACLE,MAAMA,CAAC;AAAA,MAAEC;AAAAA,IAAAA,qCAA+BM,WAAAA,UAAA;AAAA,MAAAC,UAAGC,2BAAiBR,KAAK;AAAA,IAAA,CAAI;AAAA,IACrES,OAAO;AAAA,IACPL,UAAU;AAAA,IACV,GAAGP;AAAAA,EAAAA;AAEP;AAEgBa,SAAAA,aAIdb,KACAc,YAC2B;AACpB,SAAA;AAAA,IACLZ,MAAMA,CAAC;AAAA,MAAEC;AAAAA,IAAAA,qCACNY,eAAAA,kBAAgB;AAAA,MAACC,MAAMb;AAAAA,M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ources":["../../../../../src/components/Table/renderers/renderers.tsx"],"sourcesContent":["import { ClassNames } from \"@emotion/react\";\n\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTag, HvTagProps } from \"@core/components/Tag\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport {\n HvOverflowTooltip,\n HvOverflowTooltipProps,\n} from \"@core/components/OverflowTooltip\";\nimport { HvBaseSwitchProps } from \"@core/components/BaseSwitch\";\nimport { HvListValue } from \"@core/components/List\";\n\nimport {\n HvTableHeaderRenderer,\n HvCellProps,\n HvTableColumnConfig,\n HvRowInstance,\n} from \"../hooks/useTable\";\nimport { HvDateColumnCell } from \"./DateColumnCell\";\nimport { HvSwitchColumnCell } from \"./SwitchColumnCell\";\nimport { HvProgressColumnCell } from \"./ProgressColumnCell\";\nimport { HvDropdownColumnCell } from \"./DropdownColumnCell\";\nimport { hvStringFallback, hvNumberFallback } from \"../utils\";\n\nexport function hvTextColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n overflowTooltipProps: Omit<HvOverflowTooltipProps, \"data\"> = {}\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvOverflowTooltip\n data={hvStringFallback(value)}\n {...overflowTooltipProps}\n />\n ),\n sortType: \"alphanumeric\",\n ...col,\n };\n}\n\nexport function hvNumberColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(col: HvTableColumnConfig<D, H>): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => <>{hvNumberFallback(value)}</>,\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n}\n\nexport function hvDateColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n dateFormat?: string\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvDateColumnCell date={value} dateFormat={dateFormat} />\n ),\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n}\n\nexport function hvExpandColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n expandRowButtonAriaLabel: string,\n collapseRowButtonAriaLabel: string,\n getCanRowExpand?: (row: HvRowInstance<D, H>) => boolean,\n ExpandedIcon: React.ReactNode = <DropUpXS />,\n CollapsedIcon: React.ReactNode = <DropDownXS />\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n const expandedProps = row.getToggleRowExpandedProps?.();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <ClassNames>\n {({ css }) => (\n <>\n {hasContent && (\n <HvButton\n icon\n aria-label={\n row.isExpanded\n ? collapseRowButtonAriaLabel\n : expandRowButtonAriaLabel\n }\n aria-expanded={row.isExpanded}\n onClick={expandedProps?.onClick}\n classes={{\n root: css({\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n transform: \"translateY(-50%)\",\n }),\n }}\n >\n {row.isExpanded ? ExpandedIcon : CollapsedIcon}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n )}\n </ClassNames>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n A extends object = Record<string, unknown>\n>(\n col: HvTableColumnConfig<D, H>,\n valueDataKey: keyof A,\n colorDataKey: keyof A,\n textColorDataKey: keyof A,\n fromRowData: boolean = false,\n tagProps?: HvTagProps\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n if (!value) {\n return <>—</>;\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"body\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\n// TODO - Review accessibility on the next renderers because they all differ\n\nexport function hvSwitchColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n switchLabel: string,\n falseLabel?: string,\n trueLabel?: string,\n switchProps?: HvBaseSwitchProps\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n return (\n <HvSwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n id: string | undefined,\n placeholder: string,\n disabledPlaceholder: string,\n onChange?: (identifier: string, value: HvListValue) => void\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row, column } = cellProps;\n const dsbld = value.length < 1;\n return (\n <HvDropdownColumnCell\n values={value}\n placeholder={dsbld ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val)}\n disabled={dsbld}\n dropdownProps={{\n \"aria-labelledby\": setId(id, column.id) || column.id || id, // TODO - to be reviewed because it doesn't make much sense\n }}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer\n>(\n col: HvTableColumnConfig<D, H>,\n getPartial?: (row: HvRowInstance<D, H>) => number,\n getTotal?: (row: HvRowInstance<D, H>) => number,\n color?: \"primary\" | \"secondary\"\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { row, column } = cellProps;\n const partial = getPartial?.(row) || 0;\n const total = getTotal?.(row);\n\n if (total) {\n return (\n <HvProgressColumnCell\n partial={partial}\n total={total}\n color={color}\n aria-labelledby={column.id}\n />\n );\n }\n\n return <>—</>;\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"names":["hvTextColumn","col","overflowTooltipProps","Cell","value","HvOverflowTooltip","data","hvStringFallback","sortType","hvNumberColumn","_Fragment","children","hvNumberFallback","align","hvDateColumn","dateFormat","HvDateColumnCell","date","sortDescFirst","hvExpandColumn","expandRowButtonAriaLabel","collapseRowButtonAriaLabel","getCanRowExpand","ExpandedIcon","DropUpXS","CollapsedIcon","_jsx","DropDownXS","cellProps","row","expandedProps","getToggleRowExpandedProps","hasContent","ClassNames","css","HvButton","icon","isExpanded","onClick","classes","root","position","left","top","transform","cellStyle","hvTagColumn","valueDataKey","colorDataKey","textColorDataKey","fromRowData","tagProps","name","color","textColor","original","HvTag","label","HvTypography","variant","type","style","tabIndex","paddingTop","paddingBottom","hvSwitchColumn","switchLabel","falseLabel","trueLabel","switchProps","HvSwitchColumnCell","checked","id","hvDropdownColumn","placeholder","disabledPlaceholder","onChange","column","dsbld","length","HvDropdownColumnCell","values","val","disabled","dropdownProps","setId","hvProgressColumn","getPartial","getTotal","partial","total","HvProgressColumnCell"],"mappings":";;;;;;;;;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AAAA,IAEL;AAAA,IACA3B,WAAW;AAAA,MACTkB,YAAY;AAAA,MACZC,eAAe;AAAA,IACjB;AAAA,IACA,GAAG/D;AAAAA,EAAAA;AAEP;AAEO,SAASqF,iBAIdrF,KACAsF,YACAC,UACAnC,OAC2B;AACpB,SAAA;AAAA,IACLlD,MAAMA,CAACyB,cAAiC;AAChC,YAAA;AAAA,QAAEC;AAAAA,QAAKgD;AAAAA,MAAWjD,IAAAA;AAClB6D,YAAAA,WAAUF,yCAAa1D,SAAQ;AAC/B6D,YAAAA,QAAQF,qCAAW3D;AAEzB,UAAI6D,OAAO;AACT,8CACGC,mBAAAA,sBAAoB;AAAA,UACnBF;AAAAA,UACAC;AAAAA,UACArC;AAAAA,UACA,mBAAiBwB,OAAOL;AAAAA,QAAAA,CACzB;AAAA,MAEL;AAEA,4CAAO9D,WAAAA,UAAA;AAAA,QAAAC,UAAE;AAAA,MAAA,CAAG;AAAA,IACd;AAAA,IAEAkC,WAAW;AAAA,MACTkB,YAAY;AAAA,MACZC,eAAe;AAAA,IACjB;AAAA,IACA,GAAG/D;AAAAA,EAAAA;AAEP;;;;;;;;;"}
|
|
@@ -25,7 +25,6 @@ const getColor = (customColor, type, colors) => {
|
|
|
25
25
|
return backgroundColor;
|
|
26
26
|
};
|
|
27
27
|
const HvTag = (props) => {
|
|
28
|
-
var _a;
|
|
29
28
|
const {
|
|
30
29
|
classes: classesProp,
|
|
31
30
|
className,
|
|
@@ -43,8 +42,7 @@ const HvTag = (props) => {
|
|
|
43
42
|
...others
|
|
44
43
|
} = useDefaultProps.useDefaultProps("HvTag", props);
|
|
45
44
|
const {
|
|
46
|
-
|
|
47
|
-
selectedMode
|
|
45
|
+
colors
|
|
48
46
|
} = useTheme.useTheme();
|
|
49
47
|
const {
|
|
50
48
|
classes,
|
|
@@ -85,11 +83,10 @@ const HvTag = (props) => {
|
|
|
85
83
|
const inlineStyle = {
|
|
86
84
|
...style
|
|
87
85
|
};
|
|
88
|
-
|
|
86
|
+
const categoricalBackgroundColor = type === "categorical" ? getColor(color, type, colors) : void 0;
|
|
89
87
|
if (type === "semantic") {
|
|
90
88
|
inlineStyle.backgroundColor = getColor(color, type, {});
|
|
91
89
|
} else if (type === "categorical") {
|
|
92
|
-
categoricalBackgroundColor = getColor(color, type, (_a = activeTheme == null ? void 0 : activeTheme.colors) == null ? void 0 : _a.modes[selectedMode]);
|
|
93
90
|
inlineStyle.backgroundColor = `${categoricalBackgroundColor}30`;
|
|
94
91
|
}
|
|
95
92
|
const [hover, setHover] = React.useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.cjs","sources":["../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import { CSSProperties, useState } from \"react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvSemanticColorKeys,\n HvCategoricalColorKeys,\n} from \"@core/types/tokens\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvButton, HvButtonProps } from \"@core/components/Button\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport { staticClasses, useClasses } from \"./Tag.styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\">,\n HvBaseProps<HTMLDivElement, \"children\"> {\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** The label of the tag element. */\n label?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** The type of the tag element. A tag can be of semantic or categoric type. */\n type?: \"semantic\" | \"categorical\";\n /** Background color to be applied to the tag */\n color?: HvSemanticColorKeys | HvCategoricalColorKeys | string;\n /** Icon used to customize the delete icon in the Chip element */\n deleteIcon?: React.ReactElement;\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component, in order to render the delete icon\n * */\n onDelete?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Callback triggered when any item is clicked. */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** The role of the element with an attributed event. */\n role?: string;\n /** Aria properties to apply to delete button in tag */\n deleteButtonArialLabel?: string; // TODO: fix typo \"ArialLabel\" in next version\n /** Props to apply to delete button */\n deleteButtonProps?: HvButtonProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n}\n\nconst getColor = (customColor, type, colors) => {\n const defaultSemanticColor = theme.colors.neutral_20;\n const defaultCategoricalColor = colors.cat1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor =\n theme.colors[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n colors[customColor] || customColor || defaultCategoricalColor;\n }\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nexport const HvTag = (props: HvTagProps) => {\n const {\n classes: classesProp,\n className,\n style,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = useDefaultProps(\"HvTag\", props);\n const { activeTheme, selectedMode } = useTheme();\n const { classes, cx, css } = useClasses(classesProp);\n\n const getDeleteIcon = () => {\n const disabledSemanticColor =\n type === \"semantic\" ? \"secondary_60\" : \"base_dark\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n const closeIconStyles = css({\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n \"& svg .color0\": {\n fill: theme.colors[disabled ? disabledSemanticColor : \"base_dark\"],\n },\n });\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n root: classes.button,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n variant=\"secondaryGhost\"\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n className={closeIconStyles}\n color={disabled ? disabledSemanticColor : \"base_dark\"}\n />\n </HvButton>\n );\n };\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(color, type, {});\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(\n color,\n type,\n activeTheme?.colors?.modes[selectedMode]\n );\n\n inlineStyle.backgroundColor = `${categoricalBackgroundColor}30`;\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={cx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled\n ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` }\n : null),\n }}\n classes={{\n root: cx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: cx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n"],"names":["getColor","customColor","type","colors","defaultSemanticColor","theme","neutral_20","defaultCategoricalColor","cat1","backgroundColor","HvTag","props","classes","classesProp","className","style","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","useDefaultProps","activeTheme","selectedMode","useTheme","cx","css","useClasses","getDeleteIcon","disabledSemanticColor","tabIndex","closeIconStyles","cursor","undefined","height","fill","HvButton","startIcon","tagButton","focusVisible","root","button","variant","children","CloseXS","iconSize","inlineStyle","categoricalBackgroundColor","modes","hover","setHover","useState","Chip","onMouseEnter","onMouseLeave","boxShadow","chipRoot","clickable","categorical","categoricalFocus","categoricalDisabled","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction"],"mappings":";;;;;;;;;;;;;;AAqDA,MAAMA,WAAWA,CAACC,aAAaC,MAAMC,WAAW;AACxCC,QAAAA,uBAAuBC,YAAAA,MAAMF,OAAOG;AAC1C,QAAMC,0BAA0BJ,OAAOK;AAEnCC,MAAAA;AAEJ,MAAIP,SAAS,YAAY;AACvBO,sBACEJ,YAAMF,MAAAA,OAAOF,WAAW,KAAKA,eAAeG;AAAAA,EAChD;AACA,MAAIF,SAAS,eAAe;AAExBC,sBAAAA,OAAOF,WAAW,KAAKA,eAAeM;AAAAA,EAC1C;AACOE,SAAAA;AACT;AAUaC,MAAAA,QAAQA,CAACC,UAAsB;;AACpC,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAf,OAAO;AAAA,IACPgB;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,yBAAyB;AAAA,IACzBC,oBAAoB,CAAC;AAAA,IACrB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,SAASf,KAAK;AAC5B,QAAA;AAAA,IAAEgB;AAAAA,IAAaC;AAAAA,MAAiBC,SAAS,SAAA;AACzC,QAAA;AAAA,IAAEjB;AAAAA,IAASkB;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAA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AAS;AAAA,IACrC4C,cAAcA,MAAM;AACT,eAAA,CAAC,CAACrC,OAAO;AAAA,IACpB;AAAA,IACAsC,cAAcA,MAAM;AAClBJ,eAAS,KAAK;AAAA,IAChB;AAAA,IACAxC,OAAO;AAAA,MACL,GAAIE,WAAW,OAAOkC;AAAAA,MACtB,GAAIG,SAAS,CAACrC,WACV;AAAA,QAAE2C,WAAY,aAAYR;AAAAA,MAAAA,IAC1B;AAAA,IACN;AAAA,IACAxC,SAAS;AAAA,MACPiC,MAAMf,GAAGlB,QAAQiD,UAAU;AAAA,QACzB,CAACjD,QAAQK,QAAQ,GAAGA;AAAAA,QACpB,CAACL,QAAQkD,SAAS,GAAG,CAAC,CAACzC;AAAAA,QACvB,CAACT,QAAQmD,WAAW,GAAG7D,SAAS;AAAA,QAChC,CAACU,QAAQoD,gBAAgB,GAAG9D,SAAS,iBAAiB,CAACe;AAAAA,QACvD,CAACL,QAAQqD,mBAAmB,GAAG/D,SAAS,iBAAiBe;AAAAA,MAAAA,CAC1D;AAAA,MACDD,OAAOJ,QAAQI;AAAAA,MACfG,YAAYW,GAAGlB,QAAQO,YAAY;AAAA,QACjC,CAACP,QAAQsD,kBAAkB,GAAGjD;AAAAA,MAAAA,CAC/B;AAAA,IACH;AAAA,IACAE,YAAagD,MAAAA,gBAAgB/C,QAAQ,KAAKD,cAAec,cAAc;AAAA,IACvEb,UAAUgD,MAAAA,oBAAoBnD,UAAUG,QAAQ;AAAA,IAChDC,SAASJ,WAAWqB,SAAYjB;AAAAA,IAChCC,MAAMA,SAAS+C,MAAehD,eAAAA,OAAO,IAAI,WAAWiB;AAAAA,IACpDH,UAAUgC,MAAAA,gBAAgB/C,QAAQ,IAAIkB,SAAY;AAAA,IAAE,GAChDb;AAAAA,EAAAA,CACL;AAEL;;;"}
|
|
1
|
+
{"version":3,"file":"Tag.cjs","sources":["../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import { CSSProperties, useState } from \"react\";\nimport { HvColorAny, theme } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvButton, HvButtonProps } from \"@core/components/Button\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport { staticClasses, useClasses } from \"./Tag.styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\">,\n HvBaseProps<HTMLDivElement, \"children\"> {\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** The label of the tag element. */\n label?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** The type of the tag element. A tag can be of semantic or categoric type. */\n type?: \"semantic\" | \"categorical\";\n /** Background color to be applied to the tag */\n color?: HvColorAny;\n /** Icon used to customize the delete icon in the Chip element */\n deleteIcon?: React.ReactElement;\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component, in order to render the delete icon\n * */\n onDelete?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Callback triggered when any item is clicked. */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** The role of the element with an attributed event. */\n role?: string;\n /** Aria properties to apply to delete button in tag */\n deleteButtonArialLabel?: string; // TODO: fix typo \"ArialLabel\" in next version\n /** Props to apply to delete button */\n deleteButtonProps?: HvButtonProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n}\n\nconst getColor = (customColor, type, colors) => {\n const defaultSemanticColor = theme.colors.neutral_20;\n const defaultCategoricalColor = colors.cat1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor =\n theme.colors[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n colors[customColor] || customColor || defaultCategoricalColor;\n }\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nexport const HvTag = (props: HvTagProps) => {\n const {\n classes: classesProp,\n className,\n style,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = useDefaultProps(\"HvTag\", props);\n const { colors } = useTheme();\n const { classes, cx, css } = useClasses(classesProp);\n\n const getDeleteIcon = () => {\n const disabledSemanticColor =\n type === \"semantic\" ? \"secondary_60\" : \"base_dark\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n const closeIconStyles = css({\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n \"& svg .color0\": {\n fill: theme.colors[disabled ? disabledSemanticColor : \"base_dark\"],\n },\n });\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n root: classes.button,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n variant=\"secondaryGhost\"\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n className={closeIconStyles}\n color={disabled ? disabledSemanticColor : \"base_dark\"}\n />\n </HvButton>\n );\n };\n\n const inlineStyle = {\n ...style,\n };\n\n const categoricalBackgroundColor =\n type === \"categorical\" ? getColor(color, type, colors) : undefined;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(color, type, {});\n } else if (type === \"categorical\") {\n inlineStyle.backgroundColor = `${categoricalBackgroundColor}30`;\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={cx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled\n ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` }\n : null),\n }}\n classes={{\n root: cx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: cx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n"],"names":["getColor","customColor","type","colors","defaultSemanticColor","theme","neutral_20","defaultCategoricalColor","cat1","backgroundColor","HvTag","props","classes","classesProp","className","style","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","useDefaultProps","useTheme","cx","css","useClasses","getDeleteIcon","disabledSemanticColor","tabIndex","closeIconStyles","cursor","undefined","height","fill","HvButton","startIcon","tagButton","focusVisible","root","button","variant","children","CloseXS","iconSize","inlineStyle","categoricalBackgroundColor","hover","setHover","useState","Chip","onMouseEnter","onMouseLeave","boxShadow","chipRoot","clickable","categorical","categoricalFocus","categoricalDisabled","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction"],"mappings":";;;;;;;;;;;;;;AAiDA,MAAMA,WAAWA,CAACC,aAAaC,MAAMC,WAAW;AACxCC,QAAAA,uBAAuBC,YAAAA,MAAMF,OAAOG;AAC1C,QAAMC,0BAA0BJ,OAAOK;AAEnCC,MAAAA;AAEJ,MAAIP,SAAS,YAAY;AACvBO,sBACEJ,YAAMF,M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