@hitachivantara/uikit-react-core 4.0.1-next.3 → 4.0.1-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Tag/Tag.js +1 -13
- package/dist/Tag/Tag.js.map +1 -1
- package/dist/Tag/styles.js +5 -3
- package/dist/Tag/styles.js.map +1 -1
- package/dist/legacy/Tag/Tag.js +3 -15
- package/dist/legacy/Tag/Tag.js.map +1 -1
- package/dist/legacy/Tag/styles.js +5 -3
- package/dist/legacy/Tag/styles.js.map +1 -1
- package/dist/modern/Tag/Tag.js +3 -15
- package/dist/modern/Tag/Tag.js.map +1 -1
- package/dist/modern/Tag/styles.js +5 -3
- package/dist/modern/Tag/styles.js.map +1 -1
- package/package.json +2 -2
package/dist/Tag/Tag.js
CHANGED
|
@@ -95,8 +95,6 @@ var getColor = function getColor(theme, customColor, type) {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
var HvTag = function HvTag(props) {
|
|
98
|
-
var _HvTypography;
|
|
99
|
-
|
|
100
98
|
var classes = props.classes,
|
|
101
99
|
style = props.style,
|
|
102
100
|
className = props.className,
|
|
@@ -158,18 +156,8 @@ var HvTag = function HvTag(props) {
|
|
|
158
156
|
hover = _useState2[0],
|
|
159
157
|
setHover = _useState2[1];
|
|
160
158
|
|
|
161
|
-
var chipLabel = (0, _react.useMemo)(function () {
|
|
162
|
-
if (typeof label === "string") {
|
|
163
|
-
return _HvTypography || (_HvTypography = /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HvTypography, {
|
|
164
|
-
variant: "normalText",
|
|
165
|
-
children: label
|
|
166
|
-
}));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return label;
|
|
170
|
-
}, [label]);
|
|
171
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, _objectSpread({
|
|
172
|
-
label:
|
|
160
|
+
label: label,
|
|
173
161
|
className: (0, _clsx.default)(classes.root, className),
|
|
174
162
|
onMouseEnter: function onMouseEnter() {
|
|
175
163
|
setHover(!!onClick);
|
package/dist/Tag/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","useTheme","inlineStyle","categoricalBackgroundColor","fade","useState","hover","setHover","chipLabel","useMemo","clsx","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction","propTypes","PropTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","withStyles","styles","name"],"sources":["../../src/Tag/Tag.js"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton, HvTypography } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n const chipLabel = useMemo(() => {\n if (typeof label === \"string\") {\n return <HvTypography variant=\"normalText\">{label}</HvTypography>;\n }\n\n return label;\n }, [label]);\n\n return (\n <Chip\n label={chipLabel}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,EAA8B;EAC7C,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,IAAMC,uBAAuB,GAAGR,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCC,KAAjE;EAEA,IAAIC,eAAJ;;EAEA,IAAIV,IAAI,KAAK,UAAb,EAAyB;IACvBU,eAAe,GAAGZ,KAAK,CAACK,OAAN,CAAcJ,WAAd,KAA8BA,WAA9B,IAA6CE,oBAA/D;EACD;;EACD,IAAID,IA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EAAEM,kBAAA,CAAUE;EApEL,CAAhB,EAqENK,UAzEa;;EA2EhB;AACF;AACA;EACEnD,KAAK,EAAE4C,kBAAA,CAAUQ,UAAV,CAAqBC,MAArB,CA9ES;;EAgFhB;AACF;AACA;EACEpD,SAAS,EAAE2C,kBAAA,CAAUE,MAnFL;;EAqFhB;AACF;AACA;AACA;EACE5C,KAAK,EAAE0C,kBAAA,CAAUU,IAzFD;;EA2FhB;AACF;AACA;EACEnD,QAAQ,EAAEyC,kBAAA,CAAUW,IA9FJ;;EAgGhB;AACF;AACA;AACA;AACA;EACErE,IAAI,EAAE0D,kBAAA,CAAUY,KAAV,CAAgB,CAAC,UAAD,EAAa,aAAb,CAAhB,CArGU;;EAuGhB;AACF;AACA;EACEpD,KAAK,EAAEwC,kBAAA,CAAUE,MA1GD;;EA2GhB;AACF;AACA;EACEzC,UAAU,EAAEuC,kBAAA,CAAUU,IA9GN;;EAgHhB;AACF;AACA;AACA;AACA;EACEhD,QAAQ,EAAEsC,kBAAA,CAAUa,IArHJ;;EAsHhB;AACF;AACA;EACElD,OAAO,EAAEqC,kBAAA,CAAUa,IAzHH;;EA2HhB;AACF;AACA;EACEjD,IAAI,EAAEoC,kBAAA,CAAUE,MA9HA;;EA+HhB;AACF;AACA;EACErC,sBAAsB,EAAEmC,kBAAA,CAAUE,MAlIlB;;EAmIhB;AACF;AACA;EACEpC,iBAAiB,EAAEkC,kBAAA,CAAUQ,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;;eAyIe,IAAAK,kBAAA,EAAWC,gBAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAAsC/D,KAAtC,C"}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","useTheme","inlineStyle","categoricalBackgroundColor","fade","useState","hover","setHover","clsx","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction","propTypes","PropTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","withStyles","styles","name"],"sources":["../../src/Tag/Tag.js"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,EAA8B;EAC7C,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,IAAMC,uBAAuB,GAAGR,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCC,KAAjE;EAEA,IAAIC,eAAJ;;EAEA,IAAIV,IAAI,KAAK,UAAb,EAAyB;IACvBU,eAAe,GAAGZ,KAAK,CAACK,OAAN,CAAcJ,WAAd,KAA8BA,WAA9B,IAA6CE,oBAA/D;EACD;;EACD,IAAID,IAAI,KAAK,aAAb,EAA4B;IAC1BU,eAAe,GACbZ,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCT,WAAjC,KAAiDA,WAAjD,IAAgEO,uBADlE;EAED;;EAED,OAAOI,eAAP;AACD,CAfD;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAACC,KAAD,EAAW;EACvB,IACEC,OADF,GAeID,KAfJ,CACEC,OADF;EAAA,IAEEC,KAFF,GAeIF,KAfJ,CAEEE,KAFF;EAAA,IAGEC,SAHF,GAeIH,KAfJ,CAGEG,SAHF;EAAA,IAIEC,KAJF,GAeI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,IAzHH;;EA2HhB;AACF;AACA;EACE/C,IAAI,EAAEkC,kBAAA,CAAUE,MA9HA;;EA+HhB;AACF;AACA;EACEnC,sBAAsB,EAAEiC,kBAAA,CAAUE,MAlIlB;;EAmIhB;AACF;AACA;EACElC,iBAAiB,EAAEgC,kBAAA,CAAUQ,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;;eAyIe,IAAAK,kBAAA,EAAWC,gBAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAAsC7D,KAAtC,C"}
|
package/dist/Tag/styles.js
CHANGED
|
@@ -46,13 +46,15 @@ var styles = function styles(theme) {
|
|
|
46
46
|
primaryButton: {
|
|
47
47
|
background: "transparent"
|
|
48
48
|
},
|
|
49
|
-
label: {
|
|
49
|
+
label: _objectSpread(_objectSpread({
|
|
50
50
|
paddingLeft: theme.hv.spacing.xs,
|
|
51
|
-
paddingRight: theme.hv.spacing.xs
|
|
51
|
+
paddingRight: theme.hv.spacing.xs
|
|
52
|
+
}, theme.hv.typography.normalText), {}, {
|
|
53
|
+
color: theme.palette.base2,
|
|
52
54
|
"& p": {
|
|
53
55
|
color: theme.hv.palette.base.base2
|
|
54
56
|
}
|
|
55
|
-
},
|
|
57
|
+
}),
|
|
56
58
|
tagButton: {
|
|
57
59
|
width: 16,
|
|
58
60
|
height: 16,
|
package/dist/Tag/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","fade","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","fade","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","typography","normalText","color","base2","base","tagButton","width","minWidth","minHeight","padding","margin","deleteIcon","marginRight","outlineStyles","outline","boxShadow","disabledDeleteIcon","atmosphere","atmo3","outlineOffset","titleOverflow","whiteSpace","overflow","textOverflow","categorical","cursor","accent","acce1","clickable","categoricalFocus","disabled","atmo5","categoricalDisabled","semanticTextColor","categoricalTextColor"],"sources":["../../src/Tag/styles.js"],"sourcesContent":["import fade from \"../utils/hexToRgbA\";\nimport { outlineStyles } from \"../Focus/styles\";\n\nconst styles = (theme) => ({\n root: {},\n\n chipRoot: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n \"& $focusVisible\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n },\n\n focusVisible: {},\n\n primaryButton: {\n background: \"transparent\",\n },\n\n label: {\n paddingLeft: theme.hv.spacing.xs,\n paddingRight: theme.hv.spacing.xs,\n ...theme.hv.typography.normalText,\n color: theme.palette.base2,\n \"& p\": {\n color: theme.hv.palette.base.base2,\n },\n },\n\n tagButton: {\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n },\n\n deleteIcon: {\n marginRight: 0,\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n \"&:hover\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n \"&:focus\": {\n ...outlineStyles,\n borderRadius: 0,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n disabledDeleteIcon: {\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n outline: \"none\",\n boxShadow: \"none\",\n outlineOffset: 0,\n },\n },\n titleOverflow: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n categorical: {\n borderRadius: 8,\n \"&$clickable\": {\n cursor: \"pointer\",\n },\n \"&:hover\": {\n borderRadius: 8,\n },\n \"& $label > p\": {\n color: theme.hv.palette.accent.acce1,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n clickable: {},\n\n categoricalFocus: {\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n\n disabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n },\n\n categoricalDisabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n outline: \"none\",\n },\n },\n\n semanticTextColor: {\n color: theme.hv.palette.base.base2,\n },\n categoricalTextColor: {\n color: theme.hv.palette.accent.acce1,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;EAAA,OAAY;IACzBC,IAAI,EAAE,EADmB;IAGzBC,QAAQ,EAAE;MACRC,MAAM,EAAE,EADA;MAERC,YAAY,EAAE,CAFN;MAGRC,QAAQ,EAAE,GAHF;MAIR,mBAAmB;QACjBC,eAAe,EAAE,IAAAC,kBAAA,EAAKP,KAAK,CAACQ,OAAN,CAAcC,KAAnB,EAA0B,GAA1B;MADA;IAJX,CAHe;IAYzBC,YAAY,EAAE,EAZW;IAczBC,aAAa,EAAE;MACbC,UAAU,EAAE;IADC,CAdU;IAkBzBC,KAAK;MACHC,WAAW,EAAEd,KAAK,CAACe,EAAN,CAASC,OAAT,CAAiBC,EAD3B;MAEHC,YAAY,EAAElB,KAAK,CAACe,EAAN,CAASC,OAAT,CAAiBC;IAF5B,GAGAjB,KAAK,CAACe,EAAN,CAASI,UAAT,CAAoBC,UAHpB;MAIHC,KAAK,EAAErB,KAAK,CAACQ,OAAN,CAAcc,KAJlB;MAKH,OAAO;QACLD,KAAK,EAAErB,KAA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if (O
|
|
|
14
14
|
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, { useState } from "react";
|
|
18
18
|
import { Chip } from "@mui/material";
|
|
19
19
|
import { withStyles, useTheme } from "@mui/styles";
|
|
20
20
|
import PropTypes from "prop-types";
|
|
21
21
|
import clsx from "clsx";
|
|
22
22
|
import { CloseXS } from "@hitachivantara/uikit-react-icons";
|
|
23
23
|
import fade from "../utils/hexToRgbA";
|
|
24
|
-
import { HvButton
|
|
24
|
+
import { HvButton } from "..";
|
|
25
25
|
import styles from "./styles";
|
|
26
26
|
import { getOnDeleteCallback, hasDeleteAction, hasClickAction } from "./utils";
|
|
27
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -52,8 +52,6 @@ var getColor = function getColor(theme, customColor, type) {
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
var HvTag = function HvTag(props) {
|
|
55
|
-
var _HvTypography;
|
|
56
|
-
|
|
57
55
|
var classes = props.classes,
|
|
58
56
|
style = props.style,
|
|
59
57
|
className = props.className,
|
|
@@ -115,18 +113,8 @@ var HvTag = function HvTag(props) {
|
|
|
115
113
|
hover = _useState2[0],
|
|
116
114
|
setHover = _useState2[1];
|
|
117
115
|
|
|
118
|
-
var chipLabel = useMemo(function () {
|
|
119
|
-
if (typeof label === "string") {
|
|
120
|
-
return _HvTypography || (_HvTypography = /*#__PURE__*/_jsx(HvTypography, {
|
|
121
|
-
variant: "normalText",
|
|
122
|
-
children: label
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return label;
|
|
127
|
-
}, [label]);
|
|
128
116
|
return /*#__PURE__*/_jsx(Chip, _objectSpread({
|
|
129
|
-
label:
|
|
117
|
+
label: label,
|
|
130
118
|
className: clsx(classes.root, className),
|
|
131
119
|
onMouseEnter: function onMouseEnter() {
|
|
132
120
|
setHover(!!onClick);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["React","useMemo","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","HvTypography","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","chipLabel","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton, HvTypography } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n const chipLabel = useMemo(() => {\n if (typeof label === \"string\") {\n return <HvTypography variant=\"normalText\">{label}</HvTypography>;\n }\n\n return label;\n }, [label]);\n\n return (\n <Chip\n label={chipLabel}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,QAAzB,QAAyC,OAAzC;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,aAArC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,OAAT,QAAwB,mCAAxB;AAEA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,IAAvC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,mBAAT,EAA8BC,eAA9B,EAA+CC,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AAiB,EAAErC,SAAS,CAACsE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAezE,UAAU,CAACQ,MAAD,EAAS;EAAEsE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCpD,KAAtC,CAAf"}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["React","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,aAArC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,OAAT,QAAwB,mCAAxB;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,SAASC,QAAT,QAAyB,IAAzB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,mBAAT,EAA8BC,eAA9B,EAA+CC,cAA/C,QAAqE,SAArE;;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,EAA8B;EAC7C,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,IAAMC,uBAAuB,GAAGR,KAAK,C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AAK,EAAE1B,SAAS,CAACoE,UAAV,CAAqBC,MAArB,CA9ES;;EAgFhB;AACF;AACA;EACE1C,SAAS,EAAE3B,SAAS,CAAC8D,MAnFL;;EAqFhB;AACF;AACA;AACA;EACElC,KAAK,EAAE5B,SAAS,CAACsE,IAzFD;;EA2FhB;AACF;AACA;EACEzC,QAAQ,EAAE7B,SAAS,CAACuE,IA9FJ;;EAgGhB;AACF;AACA;AACA;AACA;EACE3D,IAAI,EAAEZ,SAAS,CAACwE,KAAV,CAAgB,CAAC,UAAD,EAAa,aAAb,CAAhB,CArGU;;EAuGhB;AACF;AACA;EACE1C,KAAK,EAAE9B,SAAS,CAAC8D,MA1GD;;EA2GhB;AACF;AACA;EACE/B,UAAU,EAAE/B,SAAS,CAACsE,IA9GN;;EAgHhB;AACF;AACA;AACA;AACA;EACEtC,QAAQ,EAAEhC,SAAS,CAACyE,IArHJ;;EAsHhB;AACF;AACA;EACExC,OAAO,EAAEjC,SAAS,CAACyE,IAzHH;;EA2HhB;AACF;AACA;EACEvC,IAAI,EAAElC,SAAS,CAAC8D,MA9HA;;EA+HhB;AACF;AACA;EACE3B,sBAAsB,EAAEnC,SAAS,CAAC8D,MAlIlB;;EAmIhB;AACF;AACA;EACE1B,iBAAiB,EAAEpC,SAAS,CAACoE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAevE,UAAU,CAACO,MAAD,EAAS;EAAEqE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCnD,KAAtC,CAAf"}
|
|
@@ -29,13 +29,15 @@ var styles = function styles(theme) {
|
|
|
29
29
|
primaryButton: {
|
|
30
30
|
background: "transparent"
|
|
31
31
|
},
|
|
32
|
-
label: {
|
|
32
|
+
label: _objectSpread(_objectSpread({
|
|
33
33
|
paddingLeft: theme.hv.spacing.xs,
|
|
34
|
-
paddingRight: theme.hv.spacing.xs
|
|
34
|
+
paddingRight: theme.hv.spacing.xs
|
|
35
|
+
}, theme.hv.typography.normalText), {}, {
|
|
36
|
+
color: theme.palette.base2,
|
|
35
37
|
"& p": {
|
|
36
38
|
color: theme.hv.palette.base.base2
|
|
37
39
|
}
|
|
38
|
-
},
|
|
40
|
+
}),
|
|
39
41
|
tagButton: {
|
|
40
42
|
width: 16,
|
|
41
43
|
height: 16,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","typography","normalText","color","base2","base","tagButton","width","minWidth","minHeight","padding","margin","deleteIcon","marginRight","outline","boxShadow","disabledDeleteIcon","atmosphere","atmo3","outlineOffset","titleOverflow","whiteSpace","overflow","textOverflow","categorical","cursor","accent","acce1","clickable","categoricalFocus","disabled","atmo5","categoricalDisabled","semanticTextColor","categoricalTextColor"],"sources":["../../../src/Tag/styles.js"],"sourcesContent":["import fade from \"../utils/hexToRgbA\";\nimport { outlineStyles } from \"../Focus/styles\";\n\nconst styles = (theme) => ({\n root: {},\n\n chipRoot: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n \"& $focusVisible\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n },\n\n focusVisible: {},\n\n primaryButton: {\n background: \"transparent\",\n },\n\n label: {\n paddingLeft: theme.hv.spacing.xs,\n paddingRight: theme.hv.spacing.xs,\n ...theme.hv.typography.normalText,\n color: theme.palette.base2,\n \"& p\": {\n color: theme.hv.palette.base.base2,\n },\n },\n\n tagButton: {\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n },\n\n deleteIcon: {\n marginRight: 0,\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n \"&:hover\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n \"&:focus\": {\n ...outlineStyles,\n borderRadius: 0,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n disabledDeleteIcon: {\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n outline: \"none\",\n boxShadow: \"none\",\n outlineOffset: 0,\n },\n },\n titleOverflow: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n categorical: {\n borderRadius: 8,\n \"&$clickable\": {\n cursor: \"pointer\",\n },\n \"&:hover\": {\n borderRadius: 8,\n },\n \"& $label > p\": {\n color: theme.hv.palette.accent.acce1,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n clickable: {},\n\n categoricalFocus: {\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n\n disabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n },\n\n categoricalDisabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n outline: \"none\",\n },\n },\n\n semanticTextColor: {\n color: theme.hv.palette.base.base2,\n },\n categoricalTextColor: {\n color: theme.hv.palette.accent.acce1,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,IAAP,MAAiB,oBAAjB;AACA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;EAAA,OAAY;I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AK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiB2B,UAAjB,CAA4Bc;MADrB,CAHG;MAMnB,WAAW;QACT1C,eAAe,EAAEN,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiB2B,UAAjB,CAA4BC;MADpC,CANQ;MASnB,WAAW;QACTJ,OAAO,EAAE;MADA;IATQ,CAxGI;IAsHzBmB,iBAAiB,EAAE;MACjB9B,KAAK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBe,IAAjB,CAAsBD;IADZ,CAtHM;IAyHzB8B,oBAAoB,EAAE;MACpB/B,KAAK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBoC,MAAjB,CAAwBC;IADX;EAzHG,CAAZ;AAAA,CAAf;;AA8HA,eAAe7C,MAAf"}
|
package/dist/modern/Tag/Tag.js
CHANGED
|
@@ -7,14 +7,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
7
|
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
9
|
|
|
10
|
-
import React, {
|
|
10
|
+
import React, { useState } from "react";
|
|
11
11
|
import { Chip } from "@mui/material";
|
|
12
12
|
import { withStyles, useTheme } from "@mui/styles";
|
|
13
13
|
import PropTypes from "prop-types";
|
|
14
14
|
import clsx from "clsx";
|
|
15
15
|
import { CloseXS } from "@hitachivantara/uikit-react-icons";
|
|
16
16
|
import fade from "../utils/hexToRgbA";
|
|
17
|
-
import { HvButton
|
|
17
|
+
import { HvButton } from "..";
|
|
18
18
|
import styles from "./styles";
|
|
19
19
|
import { getOnDeleteCallback, hasDeleteAction, hasClickAction } from "./utils";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -45,8 +45,6 @@ const getColor = (theme, customColor, type) => {
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
const HvTag = props => {
|
|
48
|
-
var _HvTypography;
|
|
49
|
-
|
|
50
48
|
const {
|
|
51
49
|
classes,
|
|
52
50
|
style,
|
|
@@ -104,18 +102,8 @@ const HvTag = props => {
|
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
const [hover, setHover] = useState(false);
|
|
107
|
-
const chipLabel = useMemo(() => {
|
|
108
|
-
if (typeof label === "string") {
|
|
109
|
-
return _HvTypography || (_HvTypography = /*#__PURE__*/_jsx(HvTypography, {
|
|
110
|
-
variant: "normalText",
|
|
111
|
-
children: label
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return label;
|
|
116
|
-
}, [label]);
|
|
117
105
|
return /*#__PURE__*/_jsx(Chip, _objectSpread({
|
|
118
|
-
label:
|
|
106
|
+
label: label,
|
|
119
107
|
className: clsx(classes.root, className),
|
|
120
108
|
onMouseEnter: () => {
|
|
121
109
|
setHover(!!onClick);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["React","useMemo","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","HvTypography","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","chipLabel","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton, HvTypography } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n const chipLabel = useMemo(() => {\n if (typeof label === \"string\") {\n return <HvTypography variant=\"normalText\">{label}</HvTypography>;\n }\n\n return label;\n }, [label]);\n\n return (\n <Chip\n label={chipLabel}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,QAAzB,QAAyC,OAAzC;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,aAArC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,OAAT,QAAwB,mCAAxB;AAEA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,IAAvC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,mBAAT,EAA8BC,eAA9B,EAA+CC,cAA/C,QAAqE,SAArE;;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,KAA8B;EAC7C,MAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,MAAMC,uBAAuB,GAAGR,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCC,KAAjE;EAEA,IAAIC,eAAJ;;EAEA,IAAIV,IAAI,KAAK,UAAb,EAAyB;IACvBU,eAAe,GAAGZ,KAAK,CAACK,OAAN,CAAcJ,WAAd,KAA8BA,WAA9B,IAA6CE,oBAA/D;EACD;;EACD,IAAID,IAAI,KAAK,aAAb,EAA4B;IAC1BU,eAAe,GACbZ,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCT,WAAjC,KAAiDA,WAAjD,IAAgEO,uBADlE;EAED;;EAED,OAAOI,eAAP;AACD,CAfD;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAM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lIlB;;EAmIhB;AACF;AACA;EACE3B,iBAAiB,EAAErC,SAAS,CAACsE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAezE,UAAU,CAACQ,MAAD,EAAS;EAAEsE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCpD,KAAtC,CAAf"}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["React","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Chip } from \"@mui/material\";\nimport { withStyles, useTheme } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport fade from \"../utils/hexToRgbA\";\nimport { HvButton } from \"..\";\nimport styles from \"./styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\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 */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\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 } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(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: clsx(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\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,aAArC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,OAAT,QAAwB,mCAAxB;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,SAASC,QAAT,QAAyB,IAAzB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,mBAAT,EAA8BC,eAA9B,EAA+CC,cAA/C,QAAqE,SAArE;;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,KAA8B;EAC7C,MAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,MAAMC,uBAAuB,G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IA9GN;;EAgHhB;AACF;AACA;AACA;AACA;EACEtC,QAAQ,EAAEhC,SAAS,CAACyE,IArHJ;;EAsHhB;AACF;AACA;EACExC,OAAO,EAAEjC,SAAS,CAACyE,IAzHH;;EA2HhB;AACF;AACA;EACEvC,IAAI,EAAElC,SAAS,CAAC8D,MA9HA;;EA+HhB;AACF;AACA;EACE3B,sBAAsB,EAAEnC,SAAS,CAAC8D,MAlIlB;;EAmIhB;AACF;AACA;EACE1B,iBAAiB,EAAEpC,SAAS,CAACoE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAevE,UAAU,CAACO,MAAD,EAAS;EAAEqE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCnD,KAAtC,CAAf"}
|
|
@@ -21,13 +21,15 @@ const styles = theme => ({
|
|
|
21
21
|
primaryButton: {
|
|
22
22
|
background: "transparent"
|
|
23
23
|
},
|
|
24
|
-
label: {
|
|
24
|
+
label: _objectSpread(_objectSpread({
|
|
25
25
|
paddingLeft: theme.hv.spacing.xs,
|
|
26
|
-
paddingRight: theme.hv.spacing.xs
|
|
26
|
+
paddingRight: theme.hv.spacing.xs
|
|
27
|
+
}, theme.hv.typography.normalText), {}, {
|
|
28
|
+
color: theme.palette.base2,
|
|
27
29
|
"& p": {
|
|
28
30
|
color: theme.hv.palette.base.base2
|
|
29
31
|
}
|
|
30
|
-
},
|
|
32
|
+
}),
|
|
31
33
|
tagButton: {
|
|
32
34
|
width: 16,
|
|
33
35
|
height: 16,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","typography","normalText","color","base2","base","tagButton","width","minWidth","minHeight","padding","margin","deleteIcon","marginRight","outline","boxShadow","disabledDeleteIcon","atmosphere","atmo3","outlineOffset","titleOverflow","whiteSpace","overflow","textOverflow","categorical","cursor","accent","acce1","clickable","categoricalFocus","disabled","atmo5","categoricalDisabled","semanticTextColor","categoricalTextColor"],"sources":["../../../src/Tag/styles.js"],"sourcesContent":["import fade from \"../utils/hexToRgbA\";\nimport { outlineStyles } from \"../Focus/styles\";\n\nconst styles = (theme) => ({\n root: {},\n\n chipRoot: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n \"& $focusVisible\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n },\n\n focusVisible: {},\n\n primaryButton: {\n background: \"transparent\",\n },\n\n label: {\n paddingLeft: theme.hv.spacing.xs,\n paddingRight: theme.hv.spacing.xs,\n ...theme.hv.typography.normalText,\n color: theme.palette.base2,\n \"& p\": {\n color: theme.hv.palette.base.base2,\n },\n },\n\n tagButton: {\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n },\n\n deleteIcon: {\n marginRight: 0,\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n \"&:hover\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n \"&:focus\": {\n ...outlineStyles,\n borderRadius: 0,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n disabledDeleteIcon: {\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n outline: \"none\",\n boxShadow: \"none\",\n outlineOffset: 0,\n },\n },\n titleOverflow: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n categorical: {\n borderRadius: 8,\n \"&$clickable\": {\n cursor: \"pointer\",\n },\n \"&:hover\": {\n borderRadius: 8,\n },\n \"& $label > p\": {\n color: theme.hv.palette.accent.acce1,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n clickable: {},\n\n categoricalFocus: {\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n\n disabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n },\n\n categoricalDisabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n outline: \"none\",\n },\n },\n\n semanticTextColor: {\n color: theme.hv.palette.base.base2,\n },\n categoricalTextColor: {\n color: theme.hv.palette.accent.acce1,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;AAAA,OAAOA,IAAP,MAAiB,oBAAjB;AACA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,MAAMC,MAAM,GAAIC,KAAD,KAAY;EACzBC,IAAI,EAAE,EADmB;EAGzBC,QAAQ,EAAE;IACRC,MAAM,EAAE,EADA;IAERC,YAAY,EAAE,CAFN;IAGRC,QAAQ,EAAE,GAHF;IAIR,mBAAmB;MACjBC,eAAe,EAAET,IAAI,CAACG,KAAK,CAACO,OAAN,CAAcC,KAAf,EAAsB,GAAtB;IADJ;EAJX,CAHe;EAYzBC,YAAY,EAAE,EAZW;EAczBC,aAAa,EAAE;IACbC,UAAU,EAAE;EADC,CAdU;EAkBzBC,KAAK;IACHC,WAAW,EAAEb,KAAK,CAACc,EAAN,CAASC,OAAT,CAAiBC,EAD3B;IAEHC,YAAY,EAAEjB,KAAK,CAACc,EAAN,CAASC,OAAT,CAAiBC;EAF5B,GAGAhB,KAAK,CAACc,EAAN,CAASI,UAAT,CAAoBC,UAHpB;IAIHC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HANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "4.0.1-next.
|
|
3
|
+
"version": "4.0.1-next.4",
|
|
4
4
|
"description": "A collection of React components for the Hitachi Vantara's Design System.",
|
|
5
5
|
"homepage": "https://github.com/lumada-design/hv-uikit-react",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "ca515e901bfbf02630f4f3b2ab3cbae4e0165b84"
|
|
87
87
|
}
|