@hitachivantara/uikit-react-core 5.40.0 → 5.41.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/QueryBuilder/QueryBuilder.styles.cjs +4 -2
- package/dist/cjs/QueryBuilder/QueryBuilder.styles.cjs.map +1 -1
- package/dist/cjs/QueryBuilder/RuleGroup/RuleGroup.cjs +2 -0
- package/dist/cjs/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/Tag/Tag.cjs +22 -2
- package/dist/cjs/Tag/Tag.cjs.map +1 -1
- package/dist/cjs/Tag/Tag.styles.cjs +24 -13
- package/dist/cjs/Tag/Tag.styles.cjs.map +1 -1
- package/dist/cjs/Typography/Typography.cjs +2 -1
- package/dist/cjs/Typography/Typography.cjs.map +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.styles.js +4 -2
- package/dist/esm/QueryBuilder/QueryBuilder.styles.js.map +1 -1
- package/dist/esm/QueryBuilder/RuleGroup/RuleGroup.js +2 -0
- package/dist/esm/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/Tag/Tag.js +23 -3
- package/dist/esm/Tag/Tag.js.map +1 -1
- package/dist/esm/Tag/Tag.styles.js +24 -13
- package/dist/esm/Tag/Tag.styles.js.map +1 -1
- package/dist/esm/Typography/Typography.js +2 -1
- package/dist/esm/Typography/Typography.js.map +1 -1
- package/dist/types/index.d.ts +11 -5
- package/package.json +2 -2
|
@@ -97,12 +97,14 @@ const { useClasses, staticClasses } = classes.createClasses("HvQueryBuilder", {
|
|
|
97
97
|
createConditionButton: {
|
|
98
98
|
cursor: "pointer",
|
|
99
99
|
backgroundColor: "transparent",
|
|
100
|
-
padding: 0
|
|
100
|
+
padding: 0,
|
|
101
|
+
"&:disabled": { cursor: "not-allowed", pointerEvents: "none" }
|
|
101
102
|
},
|
|
102
103
|
createGroupButton: {
|
|
103
104
|
cursor: "pointer",
|
|
104
105
|
backgroundColor: "transparent",
|
|
105
|
-
padding: 0
|
|
106
|
+
padding: 0,
|
|
107
|
+
"&:disabled": { cursor: "not-allowed", pointerEvents: "none" }
|
|
106
108
|
}
|
|
107
109
|
});
|
|
108
110
|
exports.staticClasses = staticClasses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.styles.cjs","sources":["../../../src/QueryBuilder/QueryBuilder.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvQueryBuilder\", {\n /** Styles applied to the component root class. */\n root: {\n position: \"relative\",\n padding: theme.space.sm,\n marginTop: 12,\n marginBottom: 32,\n border: `1px solid ${theme.colors.atmo4}`,\n },\n /** Styles applied to the top group container. */\n topGroup: {\n margin: theme.space.sm,\n backgroundColor: \"transparent\",\n maxWidth: \"100%\",\n paddingBottom: theme.space.lg,\n },\n /** Styles applied to the sub group containers. */\n subGroup: {\n margin: \"40px 14px 32px 20px\",\n minHeight: 120,\n paddingBottom: theme.space.md,\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: 21,\n height: 36,\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: -38,\n left: -38,\n },\n \":not($topRulesContainer)>&:last-child::after\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: 32,\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(${theme.space.sm} + 2)`,\n },\n },\n /** Styles applied to the radio button+label topGroup when the radio button is disabled. */\n combinator: { minWidth: 80 },\n /** Styles applied to the multi-button combinator container on the top group. */\n topCombinator: {\n position: \"absolute\",\n top: `calc(-1 * ${theme.space.sm})`,\n left: `calc(-1 * ${theme.space.sm})`,\n },\n /** Styles applied to each combinator button. */\n combinatorButton: {},\n /** Styles applied to the remove button. */\n removeButton: {},\n /** Styles applied to the remove button on the top group. */\n topRemoveButton: { position: \"absolute\", top: -16, right: -16 },\n /** Styles applied to the remove button when disabled on the top group. */\n topRemoveButtonDisabled: { backgroundColor: theme.colors.atmo2 },\n /** Styles applied to the rules container. */\n rulesContainer: {},\n /** Styles applied to the sub rules container. */\n subRulesContainer: {\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n marginLeft: theme.space.sm,\n marginBottom: theme.space.md,\n paddingLeft: theme.space.sm,\n paddingTop: 7,\n position: \"relative\",\n left: -33,\n width: \"100%\",\n },\n /** Styles applied to the action button container. */\n actionButtonContainer: {\n marginLeft: \"auto\",\n\n \"&>*\": {\n marginLeft: theme.space.sm,\n },\n },\n /** Styles applied to the top action button container. */\n topActionButtonContainer: {\n position: \"absolute\",\n bottom: `calc(-1 * ${theme.space.md} * 0.5 - 3px)`,\n right: `calc(${theme.space.sm} * 1.75 + 2px)`,\n },\n /** Styles applied to the top rules container. */\n topRulesContainer: {},\n /** Styles applied to the background of buttons to remove transparency */\n buttonBackground: {\n backgroundColor: theme.colors.atmo2,\n display: \"inline-flex\",\n },\n createConditionButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n },\n createGroupButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n },\n});\n"],"names":["createClasses","theme"],"mappings":";;;;AAIO,MAAM,EAAE,YAAY,kBAAkBA,QAAAA,cAAc,kBAAkB;AAAA;AAAA,EAE3E,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,SAASC,YAAAA,MAAM,MAAM;AAAA,IACrB,WAAW;AAAA,IACX,cAAc;AAAA,IACd,QAAQ,aAAaA,YAAM,MAAA,OAAO,KAAK;AAAA,EACzC;AAAA;AAAA,EAEA,UAAU;AAAA,IACR,QAAQA,YAAAA,MAAM,MAAM;AAAA,IACpB,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,eAAeA,YAAAA,MAAM,MAAM;AA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,IACzB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA;AAAA,EAEA,uBAAuB;AAAA,IACrB,YAAY;AAAA,IAEZ,OAAO;AAAA,MACL,YAAYA,YAAAA,MAAM,MAAM;AAAA,IAC1B;AAAA,EACF;AAAA;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAQ,aAAaA,YAAAA,MAAM,MAAM,EAAE;AAAA,IACnC,OAAO,QAAQA,YAAAA,MAAM,MAAM,EAAE;AAAA,EAC/B;AAAA;AAAA,EAEA,mBAAmB,CAAC;AAAA;AAAA,EAEpB,kBAAkB;AAAA,IAChB,iBAAiBA,YAAAA,MAAM,OAAO;AAAA,IAC9B,SAAS;AAAA,EACX;AAAA,EACA,uBAAuB;AAAA,IACrB,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,SAAS;AAAA,
|
|
1
|
+
{"version":3,"file":"QueryBuilder.styles.cjs","sources":["../../../src/QueryBuilder/QueryBuilder.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvQueryBuilder\", {\n /** Styles applied to the component root class. */\n root: {\n position: \"relative\",\n padding: theme.space.sm,\n marginTop: 12,\n marginBottom: 32,\n border: `1px solid ${theme.colors.atmo4}`,\n },\n /** Styles applied to the top group container. */\n topGroup: {\n margin: theme.space.sm,\n backgroundColor: \"transparent\",\n maxWidth: \"100%\",\n paddingBottom: theme.space.lg,\n },\n /** Styles applied to the sub group containers. */\n subGroup: {\n margin: \"40px 14px 32px 20px\",\n minHeight: 120,\n paddingBottom: theme.space.md,\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: 21,\n height: 36,\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: -38,\n left: -38,\n },\n \":not($topRulesContainer)>&:last-child::after\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: 32,\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(${theme.space.sm} + 2)`,\n },\n },\n /** Styles applied to the radio button+label topGroup when the radio button is disabled. */\n combinator: { minWidth: 80 },\n /** Styles applied to the multi-button combinator container on the top group. */\n topCombinator: {\n position: \"absolute\",\n top: `calc(-1 * ${theme.space.sm})`,\n left: `calc(-1 * ${theme.space.sm})`,\n },\n /** Styles applied to each combinator button. */\n combinatorButton: {},\n /** Styles applied to the remove button. */\n removeButton: {},\n /** Styles applied to the remove button on the top group. */\n topRemoveButton: { position: \"absolute\", top: -16, right: -16 },\n /** Styles applied to the remove button when disabled on the top group. */\n topRemoveButtonDisabled: { backgroundColor: theme.colors.atmo2 },\n /** Styles applied to the rules container. */\n rulesContainer: {},\n /** Styles applied to the sub rules container. */\n subRulesContainer: {\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n marginLeft: theme.space.sm,\n marginBottom: theme.space.md,\n paddingLeft: theme.space.sm,\n paddingTop: 7,\n position: \"relative\",\n left: -33,\n width: \"100%\",\n },\n /** Styles applied to the action button container. */\n actionButtonContainer: {\n marginLeft: \"auto\",\n\n \"&>*\": {\n marginLeft: theme.space.sm,\n },\n },\n /** Styles applied to the top action button container. */\n topActionButtonContainer: {\n position: \"absolute\",\n bottom: `calc(-1 * ${theme.space.md} * 0.5 - 3px)`,\n right: `calc(${theme.space.sm} * 1.75 + 2px)`,\n },\n /** Styles applied to the top rules container. */\n topRulesContainer: {},\n /** Styles applied to the background of buttons to remove transparency */\n buttonBackground: {\n backgroundColor: theme.colors.atmo2,\n display: \"inline-flex\",\n },\n createConditionButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n\n \"&:disabled\": { cursor: \"not-allowed\", pointerEvents: \"none\" },\n },\n createGroupButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n\n \"&:disabled\": { cursor: \"not-allowed\", pointerEvents: \"none\" },\n },\n});\n"],"names":["createClasses","theme"],"mappings":";;;;AAIO,MAAM,EAAE,YAAY,kBAAkBA,QAAAA,cAAc,kBAAkB;AAAA;AAAA,EAE3E,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,SAASC,YAAAA,MAAM,MAAM;AAAA,IACrB,WAAW;AAAA,IACX,cAAc;AAAA,IACd,QAAQ,aAAaA,YAAM,MAAA,OAAO,KAAK;AAAA,EACzC;AAAA;AAAA,EAEA,UAAU;AAAA,IACR,QAAQA,YAAAA,MAAM,MAAM;AAAA,IACpB,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,eAAeA,YAAAA,MAAM,MAAM;AAAA,EAC7B;AAAA;AAAA,EAEA,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,eAAeA,YAAAA,MAAM,MAAM;AAAA,IAE3B,aAAa;AAAA,MACX,SAAS;AAAA,MACT,UAAU;AAAA,MACV,QAAQ;AAAA,MAER,OAAO;AAAA,MACP,QAAQ;AAAA,MAER,cAAc,aAAaA,YAAM,MAAA,OAAO,KAAK;AAAA,MAC7C,YAAY,aAAaA,YAAM,MAAA,OAAO,KAAK;AAAA,MAE3C,KAAK;AAAA,MACL,MAAM;AAAA,IACR;AAAA,IACA,gDAAgD;AAAA,MAC9C,SAAS;AAAA,MACT,UAAU;AAAA,MACV,QAAQ;AAAA,MAER,OAAO;AAAA,MACP,QAAQ;AAAA,MAER,YAAY,aAAaA,YAAM,MAAA,OAAO,KAAK;AAAA,MAE3C,KAAK;AAAA,MACL,MAAM,QAAQA,YAAAA,MAAM,MAAM,EAAE;AAAA,IAC9B;AAAA,EACF;AAAA;AAAA,EAEA,YAAY,EAAE,UAAU,GAAG;AAAA;AAAA,EAE3B,eAAe;AAAA,IACb,UAAU;AAAA,IACV,KAAK,aAAaA,YAAAA,MAAM,MAAM,EAAE;AAAA,I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AO;AAAA,EAC/D;AACF,CAAC;;;"}
|
|
@@ -166,6 +166,7 @@ const RuleGroup = ({
|
|
|
166
166
|
dispatchAction({ type: "add-rule", id });
|
|
167
167
|
},
|
|
168
168
|
className: classes.createConditionButton,
|
|
169
|
+
disabled: readOnly,
|
|
169
170
|
children: `${labels.empty?.createCondition}`
|
|
170
171
|
}
|
|
171
172
|
),
|
|
@@ -180,6 +181,7 @@ const RuleGroup = ({
|
|
|
180
181
|
dispatchAction({ type: "add-group", id });
|
|
181
182
|
},
|
|
182
183
|
className: classes.createGroupButton,
|
|
184
|
+
disabled: readOnly,
|
|
183
185
|
children: `${labels.empty?.createGroup}`
|
|
184
186
|
}
|
|
185
187
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleGroup.cjs","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":["useClasses","useQueryBuilderContext","jsxs","Fragment","jsx","HvButton","Add","useCallback","HvMultiButton","IconButton","Delete","Rule","HvEmptyState","HvTypography","Info"],"mappings":";;;;;;;;;;;;;AAuBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,S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,UAAA;AAAA,cAAAC,2BAAA;AAAA,gBAACS,WAAA;AAAA,gBAAA;AAAA,kBACC,MAAI;AAAA,kBACJ,WAAU;AAAA,kBACV,SAAS,MAAM;AACb,mCAAe,EAAE,MAAM,YAAY,GAAI,CAAA;AAAA,kBACzC;AAAA,kBACA,WAAW,QAAQ;AAAA,kBAElB,UAAA,GAAG,OAAO,OAAO,eAAe;AAAA,gBAAA;AAAA,cACnC;AAAA,cACC,SAAS,sBAELX,2BAAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,gBAAG,GAAA,OAAO,OAAO,MAAM;AAAA,gBACxBC,2BAAA;AAAA,kBAACS,WAAA;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,WAAU;AAAA,oBACV,SAAS,MAAM;AACb,qCAAe,EAAE,MAAM,aAAa,GAAI,CAAA;AAAA,oBAC1C;AAAA,oBACA,WAAW,QAAQ;AAAA,oBAElB,UAAA,GAAG,OAAO,OAAO,WAAW;AAAA,kBAAA;AAAA,gBAC/B;AAAA,cAAA,GACF;AAAA,YAAA,GAEJ;AAAA,YAEF,qCAAOC,gBAAK,MAAA,EAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAEFV,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
|
1
|
+
{"version":3,"file":"RuleGroup.cjs","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":["useClasses","useQueryBuilderContext","jsxs","Fragment","jsx","HvButton","Add","useCallback","HvMultiButton","IconButton","Delete","Rule","HvEmptyState","HvTypography","Info"],"mappings":";;;;;;;;;;;;;AAsBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,SAAS;AACX,MAAsB;AACpB,QAAM,EAAE,SAAS,GAAG,IAAIA,+BAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACEC,QAAuB,uBAAA;AAE3B,QAAM,qBAAqB,WAAW;AAEtC,QAAM,gBAEFC,2BAAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,IAACC,2BAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,kBACtB,UAAAA,2BAAA;AAAA,MAACC,OAAA;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,yBAAe,EAAE,MAAM,YAAY,GAAI,CAAA;AAAA,QACzC;AAAA,QACA,UAAU;AAAA,QACV,0CAAYC,gBAAI,KAAA,EAAA;AAAA,QAEf,UAAU,UAAA,KAAK,OAAO,OAAO,SAAS,SAAS,OAC5C,OAAO,OAAO,SAAS,QACvB,OAAO,MAAM,QAAQ;AAAA,MAAA;AAAA,IAAA,GAE7B;AAAA,IACC,SAAS,sBACRF,2BAAAA,IAAC,OAAI,EAAA,WAAW,QAAQ,kBACtB,UA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BAAK,MAAA,EAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAEFV,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
package/dist/cjs/Tag/Tag.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const Chip = require("@mui/material/Chip");
|
|
|
6
6
|
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
7
7
|
const useTheme = require("../hooks/useTheme.cjs");
|
|
8
8
|
const useDefaultProps = require("../hooks/useDefaultProps.cjs");
|
|
9
|
+
const useControlled = require("../hooks/useControlled.cjs");
|
|
9
10
|
const Tag_styles = require("./Tag.styles.cjs");
|
|
10
11
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
12
|
const Chip__default = /* @__PURE__ */ _interopDefault(Chip);
|
|
@@ -20,6 +21,9 @@ const HvTag = (props) => {
|
|
|
20
21
|
label,
|
|
21
22
|
disabled,
|
|
22
23
|
type = "semantic",
|
|
24
|
+
selectable,
|
|
25
|
+
selected,
|
|
26
|
+
defaultSelected = false,
|
|
23
27
|
color,
|
|
24
28
|
deleteIcon,
|
|
25
29
|
onDelete,
|
|
@@ -32,13 +36,16 @@ const HvTag = (props) => {
|
|
|
32
36
|
} = useDefaultProps.useDefaultProps("HvTag", props);
|
|
33
37
|
const { colors } = useTheme.useTheme();
|
|
34
38
|
const { classes, cx, css } = Tag_styles.useClasses(classesProp);
|
|
39
|
+
const [isSelected, setIsSelected] = useControlled.useControlled(
|
|
40
|
+
selected,
|
|
41
|
+
Boolean(defaultSelected)
|
|
42
|
+
);
|
|
35
43
|
const defaultDeleteIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
44
|
uikitReactIcons.CloseXS,
|
|
37
45
|
{
|
|
38
46
|
role: "none",
|
|
39
47
|
className: cx(classes.button, classes.tagButton),
|
|
40
48
|
iconSize: "XS",
|
|
41
|
-
color: "base_dark",
|
|
42
49
|
...deleteButtonProps
|
|
43
50
|
}
|
|
44
51
|
);
|
|
@@ -50,6 +57,15 @@ const HvTag = (props) => {
|
|
|
50
57
|
boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}`
|
|
51
58
|
}
|
|
52
59
|
});
|
|
60
|
+
const onClickHandler = (event) => {
|
|
61
|
+
if (disabled)
|
|
62
|
+
return;
|
|
63
|
+
if (selectable)
|
|
64
|
+
setIsSelected(!isSelected);
|
|
65
|
+
onClick?.(event, !isSelected);
|
|
66
|
+
};
|
|
67
|
+
const colorOverride = disabled && ["atmo3", "secondary_60"] || void 0;
|
|
68
|
+
const avatarIcon = isSelected ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.CheckboxCheck, { color: colorOverride, iconSize: "XS" }) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Checkbox, { color: colorOverride, iconSize: "XS" });
|
|
53
69
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
70
|
Chip__default.default,
|
|
55
71
|
{
|
|
@@ -75,7 +91,11 @@ const HvTag = (props) => {
|
|
|
75
91
|
},
|
|
76
92
|
deleteIcon: deleteIcon || defaultDeleteIcon,
|
|
77
93
|
onDelete: disabled ? void 0 : onDelete,
|
|
78
|
-
onClick:
|
|
94
|
+
onClick: onClickHandler,
|
|
95
|
+
"aria-pressed": isSelected,
|
|
96
|
+
...selectable && type === "semantic" && {
|
|
97
|
+
avatar: avatarIcon
|
|
98
|
+
},
|
|
79
99
|
...others
|
|
80
100
|
}
|
|
81
101
|
);
|
package/dist/cjs/Tag/Tag.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.cjs","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import { HTMLAttributes } from \"react\";\nimport { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"Tag.cjs","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import React, { HTMLAttributes } from \"react\";\nimport { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\n\nimport {\n Checkbox,\n CheckboxCheck,\n CloseXS,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { useControlled } from \"../hooks/useControlled\";\n\nimport { staticClasses, useClasses } from \"./Tag.styles\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\" | \"onSelect\"> {\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>, selected?: boolean) => void;\n /** Aria properties to apply to delete button in tag\n * @deprecated no longer used\n */\n deleteButtonArialLabel?: string;\n /** Props to apply to delete icon */\n deleteButtonProps?: HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n /** @ignore */\n ref?: MuiChipProps[\"ref\"];\n /** @ignore */\n component?: MuiChipProps[\"component\"];\n /** Determines whether or not the tag is selectable. */\n selectable?: boolean;\n /** Defines if the tag is selected. When defined the tag state becomes controlled. */\n selected?: boolean;\n /** When uncontrolled, defines the initial selected state. */\n defaultSelected?: boolean;\n}\n\nconst getCategoricalColor = (customColor, colors) => {\n return (customColor && colors?.[customColor]) || customColor || colors?.cat1;\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 selectable,\n selected,\n defaultSelected = false,\n color,\n deleteIcon,\n onDelete,\n onClick,\n // TODO: remove from API\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 [isSelected, setIsSelected] = useControlled(\n selected,\n Boolean(defaultSelected)\n );\n\n const defaultDeleteIcon = (\n <CloseXS\n role=\"none\"\n className={cx(classes.button, classes.tagButton)}\n iconSize=\"XS\"\n {...deleteButtonProps}\n />\n );\n\n const categoricalBackgroundColor =\n type === \"categorical\" ? getCategoricalColor(color, colors) : undefined;\n\n const backgroundColor =\n (type === \"semantic\" && getColor(color, \"neutral_20\")) ||\n (type === \"categorical\" && `${categoricalBackgroundColor}30`) ||\n undefined;\n\n const isClickable = !!(onClick || onDelete) && !disabled;\n\n const clickableClass = css({\n \"&:hover\": {\n boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}`,\n },\n });\n\n const onClickHandler = (event) => {\n if (disabled) return;\n if (selectable) setIsSelected(!isSelected);\n onClick?.(event, !isSelected);\n };\n\n const colorOverride = (disabled && [\"atmo3\", \"secondary_60\"]) || undefined;\n\n const avatarIcon = isSelected ? (\n <CheckboxCheck color={colorOverride} iconSize=\"XS\" />\n ) : (\n <Checkbox color={colorOverride} iconSize=\"XS\" />\n );\n\n return (\n <Chip\n label={label}\n disabled={disabled}\n className={cx({ [clickableClass]: isClickable }, className)}\n style={{\n ...(disabled ? null : { backgroundColor }),\n ...style,\n }}\n classes={{\n root: cx(classes.root, classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: isClickable,\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={deleteIcon || defaultDeleteIcon}\n onDelete={disabled ? undefined : onDelete}\n onClick={onClickHandler}\n aria-pressed={isSelected}\n {...(selectable &&\n type === \"semantic\" && {\n avatar: avatarIcon,\n })}\n {...others}\n />\n );\n};\n"],"names":["useDefaultProps","useTheme","useClasses","useControlled","jsx","CloseXS","getColor","CheckboxCheck","Checkbox","Chip"],"mappings":";;;;;;;;;;;;AA6DA,MAAM,sBAAsB,CAAC,aAAa,WAAW;AACnD,SAAQ,eAAe,SAAS,WAAW,KAAM,eAAe,QAAQ;AAC1E;AAUa,MAAA,QAAQ,CAAC,UAAsB;AACpC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,yBAAyB;AAAA,IACzB,oBAAoB,CAAC;AAAA,IACrB,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,SAAS,KAAK;AAC5B,QAAA,EAAE,WAAWC,SAAAA;AACnB,QAAM,EAAE,SAAS,IAAI,IAAI,IAAIC,WAAAA,WAAW,WAAW;AAE7C,QAAA,CAAC,YAAY,aAAa,IAAIC,cAAA;AAAA,IAClC;AAAA,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Q,SAAS,GAAG;AAAA,UACrB,CAAC,QAAQ,WAAW,GAAG,SAAS;AAAA,UAChC,CAAC,QAAQ,gBAAgB,GAAG,SAAS,iBAAiB,CAAC;AAAA,UACvD,CAAC,QAAQ,mBAAmB,GAAG,SAAS,iBAAiB;AAAA,QAAA,CAC1D;AAAA,QACD,OAAO,QAAQ;AAAA,QACf,YAAY,GAAG,QAAQ,YAAY;AAAA,UACjC,CAAC,QAAQ,kBAAkB,GAAG;AAAA,QAAA,CAC/B;AAAA,MACH;AAAA,MACA,YAAY,cAAc;AAAA,MAC1B,UAAU,WAAW,SAAY;AAAA,MACjC,SAAS;AAAA,MACT,gBAAc;AAAA,MACb,GAAI,cACH,SAAS,cAAc;AAAA,QACrB,QAAQ;AAAA,MACV;AAAA,MACD,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;;"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
4
|
+
const Chip = require("@mui/material/Chip");
|
|
4
5
|
const focusUtils = require("../utils/focusUtils.cjs");
|
|
5
6
|
const classes = require("../utils/classes.cjs");
|
|
6
7
|
const { staticClasses, useClasses } = classes.createClasses("HvTag", {
|
|
7
|
-
root: {
|
|
8
|
+
root: {
|
|
9
|
+
color: uikitStyles.theme.colors.base_dark,
|
|
10
|
+
[`& .${Chip.chipClasses.avatar}`]: {
|
|
11
|
+
width: 12,
|
|
12
|
+
height: 12,
|
|
13
|
+
marginLeft: 2,
|
|
14
|
+
marginRight: 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
8
17
|
chipRoot: {
|
|
9
|
-
|
|
18
|
+
[`&.${Chip.chipClasses.root}`]: {
|
|
10
19
|
height: 16,
|
|
11
20
|
borderRadius: 0,
|
|
12
21
|
maxWidth: 180,
|
|
@@ -28,22 +37,24 @@ const { staticClasses, useClasses } = classes.createClasses("HvTag", {
|
|
|
28
37
|
color: uikitStyles.theme.colors.secondary_60
|
|
29
38
|
}
|
|
30
39
|
},
|
|
31
|
-
|
|
32
|
-
paddingLeft:
|
|
33
|
-
paddingRight:
|
|
34
|
-
...uikitStyles.theme.typography.
|
|
35
|
-
color:
|
|
36
|
-
"& p": {
|
|
37
|
-
color: uikitStyles.theme.colors.base_dark
|
|
38
|
-
}
|
|
40
|
+
[`& .${Chip.chipClasses.label}`]: {
|
|
41
|
+
paddingLeft: 4,
|
|
42
|
+
paddingRight: 4,
|
|
43
|
+
...uikitStyles.theme.typography.caption2,
|
|
44
|
+
color: "currentcolor"
|
|
39
45
|
},
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
[`& .${Chip.chipClasses.deleteIcon}`]: {
|
|
47
|
+
margin: 0,
|
|
42
48
|
width: 16,
|
|
43
49
|
height: 16,
|
|
44
50
|
padding: 0,
|
|
51
|
+
color: "currentColor",
|
|
52
|
+
"& svg .color0": {
|
|
53
|
+
fill: "currentcolor"
|
|
54
|
+
},
|
|
45
55
|
"&:hover": {
|
|
46
|
-
backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
|
|
56
|
+
backgroundColor: uikitStyles.theme.colors.containerBackgroundHover,
|
|
57
|
+
color: "unset"
|
|
47
58
|
},
|
|
48
59
|
"&:focus": {
|
|
49
60
|
...focusUtils.outlineStyles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.styles.cjs","sources":["../../../src/Tag/Tag.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTag\", {\n root: {},\n\n chipRoot: {\n
|
|
1
|
+
{"version":3,"file":"Tag.styles.cjs","sources":["../../../src/Tag/Tag.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { chipClasses } from \"@mui/material/Chip\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTag\", {\n root: {\n color: theme.colors.base_dark,\n\n [`& .${chipClasses.avatar}`]: {\n width: 12,\n height: 12,\n marginLeft: 2,\n marginRight: 0,\n },\n },\n\n chipRoot: {\n [`&.${chipClasses.root}`]: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n fontFamily: theme.fontFamily.body,\n \"&:focus-visible\": {\n backgroundColor: theme.alpha(\"base_light\", 0.3),\n },\n\n \"&$categorical\": {\n borderRadius: 8,\n \"& $label\": {\n color: theme.colors.secondary,\n },\n },\n },\n\n \"&$disabled\": {\n opacity: 1,\n backgroundColor: theme.colors.atmo3,\n \"& $label\": {\n color: theme.colors.secondary_60,\n },\n },\n\n [`& .${chipClasses.label}`]: {\n paddingLeft: 4,\n paddingRight: 4,\n ...(theme.typography.caption2 as CSSProperties),\n color: \"currentcolor\",\n },\n\n [`& .${chipClasses.deleteIcon}`]: {\n margin: 0,\n width: 16,\n height: 16,\n padding: 0,\n color: \"currentColor\",\n \"& svg .color0\": {\n fill: \"currentcolor\",\n },\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n color: \"unset\",\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 },\n\n disabled: {},\n\n clickable: {\n cursor: \"pointer\",\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n\n categorical: {},\n\n label: {},\n\n deleteIcon: {},\n\n // TODO: redundant - use deleteIcon. remove in v6\n button: {},\n tagButton: {},\n // TODO: redundant - use $clickable or :not($disabled). remove in v6\n focusVisible: {},\n disabledDeleteIcon: {},\n categoricalFocus: {},\n categoricalDisabled: {},\n});\n"],"names":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AA,MACT;AAAA,MACA,WAAW;AAAA,QACT,GAAGE,WAAA;AAAA,QACH,cAAc;AAAA,MAChB;AAAA,MACA,+BAA+B;AAAA,QAC7B,SAAS;AAAA,QACT,WAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAAA,EAEA,UAAU,CAAC;AAAA,EAEX,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,mBAAmB;AAAA,MACjB,GAAGA,WAAA;AAAA,IACL;AAAA,EACF;AAAA,EAEA,aAAa,CAAC;AAAA,EAEd,OAAO,CAAC;AAAA,EAER,YAAY,CAAC;AAAA;AAAA,EAGb,QAAQ,CAAC;AAAA,EACT,WAAW,CAAC;AAAA;AAAA,EAEZ,cAAc,CAAC;AAAA,EACf,oBAAoB,CAAC;AAAA,EACrB,kBAAkB,CAAC;AAAA,EACnB,qBAAqB,CAAC;AACxB,CAAC;;;"}
|
|
@@ -46,9 +46,9 @@ const HvTypography = React.forwardRef(
|
|
|
46
46
|
classes: classesProp,
|
|
47
47
|
variant: variantProp = "body",
|
|
48
48
|
link = false,
|
|
49
|
-
disabled = false,
|
|
50
49
|
noWrap = false,
|
|
51
50
|
paragraph = false,
|
|
51
|
+
disabled = false,
|
|
52
52
|
...others
|
|
53
53
|
} = useDefaultProps.useDefaultProps("HvTypography", props);
|
|
54
54
|
const { classes, cx } = Typography_styles.useClasses(classesProp);
|
|
@@ -69,6 +69,7 @@ const HvTypography = React.forwardRef(
|
|
|
69
69
|
},
|
|
70
70
|
className
|
|
71
71
|
),
|
|
72
|
+
disabled,
|
|
72
73
|
...others
|
|
73
74
|
}
|
|
74
75
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.cjs","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\
|
|
1
|
+
{"version":3,"file":"Typography.cjs","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /** If `true`, the text will have a bottom margin. */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography: <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>\n) => React.ReactElement | null = forwardRef(\n <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>,\n ref: PolymorphicRef<C>\n ) => {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n }\n);\n"],"names":["forwardRef","useDefaultProps","useClasses","useTheme","mapVariant","jsx"],"mappings":";;;;;;;;AAiBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAgCO,MAAM,eAEoBA,MAAA;AAAA,EAC/B,CACE,OACA,QACG;AACG,UAAA;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,MACT,SAAS,cAAc;AAAA,MACvB,OAAO;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,GAAG;AAAA,IAAA,IACDC,gBAAgB,gBAAA,gBAAgB,KAAK;AACzC,UAAM,EAAE,SAAS,GAAG,IAAIC,6BAAW,WAAW;AACxC,UAAA,EAAE,gBAAgBC,SAAAA;AAExB,UAAM,UAAUC,MAAA,WAAW,aAAa,aAAa,IAAI;AAEzD,UAAM,YACJ,iBAAkB,aAAa,OAAQ,gBAAgB,OAAO,KAAK;AAGnE,WAAAC,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,OAAO;AAAA,UACf;AAAA,YACE,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACtB;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;;;"}
|
|
@@ -95,12 +95,14 @@ const { useClasses, staticClasses } = createClasses("HvQueryBuilder", {
|
|
|
95
95
|
createConditionButton: {
|
|
96
96
|
cursor: "pointer",
|
|
97
97
|
backgroundColor: "transparent",
|
|
98
|
-
padding: 0
|
|
98
|
+
padding: 0,
|
|
99
|
+
"&:disabled": { cursor: "not-allowed", pointerEvents: "none" }
|
|
99
100
|
},
|
|
100
101
|
createGroupButton: {
|
|
101
102
|
cursor: "pointer",
|
|
102
103
|
backgroundColor: "transparent",
|
|
103
|
-
padding: 0
|
|
104
|
+
padding: 0,
|
|
105
|
+
"&:disabled": { cursor: "not-allowed", pointerEvents: "none" }
|
|
104
106
|
}
|
|
105
107
|
});
|
|
106
108
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.styles.js","sources":["../../../src/QueryBuilder/QueryBuilder.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvQueryBuilder\", {\n /** Styles applied to the component root class. */\n root: {\n position: \"relative\",\n padding: theme.space.sm,\n marginTop: 12,\n marginBottom: 32,\n border: `1px solid ${theme.colors.atmo4}`,\n },\n /** Styles applied to the top group container. */\n topGroup: {\n margin: theme.space.sm,\n backgroundColor: \"transparent\",\n maxWidth: \"100%\",\n paddingBottom: theme.space.lg,\n },\n /** Styles applied to the sub group containers. */\n subGroup: {\n margin: \"40px 14px 32px 20px\",\n minHeight: 120,\n paddingBottom: theme.space.md,\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: 21,\n height: 36,\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: -38,\n left: -38,\n },\n \":not($topRulesContainer)>&:last-child::after\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: 32,\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(${theme.space.sm} + 2)`,\n },\n },\n /** Styles applied to the radio button+label topGroup when the radio button is disabled. */\n combinator: { minWidth: 80 },\n /** Styles applied to the multi-button combinator container on the top group. */\n topCombinator: {\n position: \"absolute\",\n top: `calc(-1 * ${theme.space.sm})`,\n left: `calc(-1 * ${theme.space.sm})`,\n },\n /** Styles applied to each combinator button. */\n combinatorButton: {},\n /** Styles applied to the remove button. */\n removeButton: {},\n /** Styles applied to the remove button on the top group. */\n topRemoveButton: { position: \"absolute\", top: -16, right: -16 },\n /** Styles applied to the remove button when disabled on the top group. */\n topRemoveButtonDisabled: { backgroundColor: theme.colors.atmo2 },\n /** Styles applied to the rules container. */\n rulesContainer: {},\n /** Styles applied to the sub rules container. */\n subRulesContainer: {\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n marginLeft: theme.space.sm,\n marginBottom: theme.space.md,\n paddingLeft: theme.space.sm,\n paddingTop: 7,\n position: \"relative\",\n left: -33,\n width: \"100%\",\n },\n /** Styles applied to the action button container. */\n actionButtonContainer: {\n marginLeft: \"auto\",\n\n \"&>*\": {\n marginLeft: theme.space.sm,\n },\n },\n /** Styles applied to the top action button container. */\n topActionButtonContainer: {\n position: \"absolute\",\n bottom: `calc(-1 * ${theme.space.md} * 0.5 - 3px)`,\n right: `calc(${theme.space.sm} * 1.75 + 2px)`,\n },\n /** Styles applied to the top rules container. */\n topRulesContainer: {},\n /** Styles applied to the background of buttons to remove transparency */\n buttonBackground: {\n backgroundColor: theme.colors.atmo2,\n display: \"inline-flex\",\n },\n createConditionButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n },\n createGroupButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,YAAY,kBAAkB,cAAc,kBAAkB;AAAA;AAAA,EAE3E,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,SAAS,MAAM,MAAM;AAAA,IACrB,WAAW;AAAA,IACX,cAAc;AAAA,IACd,QAAQ,aAAa,MAAM,OAAO,KAAK;AAAA,EACzC;AAAA;AAAA,EAEA,UAAU;AAAA,IACR,QAAQ,MAAM,MAAM;AAAA,IACpB,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,eAAe,MAAM,MAAM;AAAA,EAC7B;AAAA;AAAA,EAEA,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,WAAW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AAM,MAAM;AAAA,IAC1B;AAAA,EACF;AAAA;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAQ,aAAa,MAAM,MAAM,EAAE;AAAA,IACnC,OAAO,QAAQ,MAAM,MAAM,EAAE;AAAA,EAC/B;AAAA;AAAA,EAEA,mBAAmB,CAAC;AAAA;AAAA,EAEpB,kBAAkB;AAAA,IAChB,iBAAiB,MAAM,OAAO;AAAA,IAC9B,SAAS;AAAA,EACX;AAAA,EACA,uBAAuB;AAAA,IACrB,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,SAAS;AAAA,
|
|
1
|
+
{"version":3,"file":"QueryBuilder.styles.js","sources":["../../../src/QueryBuilder/QueryBuilder.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvQueryBuilder\", {\n /** Styles applied to the component root class. */\n root: {\n position: \"relative\",\n padding: theme.space.sm,\n marginTop: 12,\n marginBottom: 32,\n border: `1px solid ${theme.colors.atmo4}`,\n },\n /** Styles applied to the top group container. */\n topGroup: {\n margin: theme.space.sm,\n backgroundColor: \"transparent\",\n maxWidth: \"100%\",\n paddingBottom: theme.space.lg,\n },\n /** Styles applied to the sub group containers. */\n subGroup: {\n margin: \"40px 14px 32px 20px\",\n minHeight: 120,\n paddingBottom: theme.space.md,\n\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 2,\n\n width: 21,\n height: 36,\n\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: -38,\n left: -38,\n },\n \":not($topRulesContainer)>&:last-child::after\": {\n content: '\"\"',\n position: \"absolute\",\n zIndex: 1,\n\n width: 32,\n height: \"100%\",\n\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n\n top: 0,\n left: `calc(${theme.space.sm} + 2)`,\n },\n },\n /** Styles applied to the radio button+label topGroup when the radio button is disabled. */\n combinator: { minWidth: 80 },\n /** Styles applied to the multi-button combinator container on the top group. */\n topCombinator: {\n position: \"absolute\",\n top: `calc(-1 * ${theme.space.sm})`,\n left: `calc(-1 * ${theme.space.sm})`,\n },\n /** Styles applied to each combinator button. */\n combinatorButton: {},\n /** Styles applied to the remove button. */\n removeButton: {},\n /** Styles applied to the remove button on the top group. */\n topRemoveButton: { position: \"absolute\", top: -16, right: -16 },\n /** Styles applied to the remove button when disabled on the top group. */\n topRemoveButtonDisabled: { backgroundColor: theme.colors.atmo2 },\n /** Styles applied to the rules container. */\n rulesContainer: {},\n /** Styles applied to the sub rules container. */\n subRulesContainer: {\n borderLeft: `1px solid ${theme.colors.atmo4}`,\n marginLeft: theme.space.sm,\n marginBottom: theme.space.md,\n paddingLeft: theme.space.sm,\n paddingTop: 7,\n position: \"relative\",\n left: -33,\n width: \"100%\",\n },\n /** Styles applied to the action button container. */\n actionButtonContainer: {\n marginLeft: \"auto\",\n\n \"&>*\": {\n marginLeft: theme.space.sm,\n },\n },\n /** Styles applied to the top action button container. */\n topActionButtonContainer: {\n position: \"absolute\",\n bottom: `calc(-1 * ${theme.space.md} * 0.5 - 3px)`,\n right: `calc(${theme.space.sm} * 1.75 + 2px)`,\n },\n /** Styles applied to the top rules container. */\n topRulesContainer: {},\n /** Styles applied to the background of buttons to remove transparency */\n buttonBackground: {\n backgroundColor: theme.colors.atmo2,\n display: \"inline-flex\",\n },\n createConditionButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n\n \"&:disabled\": { cursor: \"not-allowed\", pointerEvents: \"none\" },\n },\n createGroupButton: {\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n padding: 0,\n\n \"&:disabled\": { cursor: \"not-allowed\", pointerEvents: \"none\" },\n },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,YAAY,kBAAkB,cAAc,kBAAkB;AAAA;AAAA,EAE3E,MAAM;AAAA,IACJ,UAAU;A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jB,mBAAmB;AAAA,IACjB,YAAY,aAAa,MAAM,OAAO,KAAK;AAAA,IAC3C,YAAY,MAAM,MAAM;AAAA,IACxB,cAAc,MAAM,MAAM;AAAA,IAC1B,aAAa,MAAM,MAAM;AAAA,IACzB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA;AAAA,EAEA,uBAAuB;AAAA,IACrB,YAAY;AAAA,IAEZ,OAAO;AAAA,MACL,YAAY,MAAM,MAAM;AAAA,IAC1B;AAAA,EACF;AAAA;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAQ,aAAa,MAAM,MAAM,EAAE;AAAA,IACnC,OAAO,QAAQ,MAAM,MAAM,EAAE;AAAA,EAC/B;AAAA;AAAA,EAEA,mBAAmB,CAAC;AAAA;AAAA,EAEpB,kBAAkB;AAAA,IAChB,iBAAiB,MAAM,OAAO;AAAA,IAC9B,SAAS;AAAA,EACX;AAAA,EACA,uBAAuB;AAAA,IACrB,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,SAAS;AAAA,IAET,cAAc,EAAE,QAAQ,eAAe,eAAe,OAAO;AAAA,EAC/D;AAAA,EACA,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,SAAS;AAAA,IAET,cAAc,EAAE,QAAQ,eAAe,eAAe,OAAO;AAAA,EAC/D;AACF,CAAC;"}
|
|
@@ -164,6 +164,7 @@ const RuleGroup = ({
|
|
|
164
164
|
dispatchAction({ type: "add-rule", id });
|
|
165
165
|
},
|
|
166
166
|
className: classes.createConditionButton,
|
|
167
|
+
disabled: readOnly,
|
|
167
168
|
children: `${labels.empty?.createCondition}`
|
|
168
169
|
}
|
|
169
170
|
),
|
|
@@ -178,6 +179,7 @@ const RuleGroup = ({
|
|
|
178
179
|
dispatchAction({ type: "add-group", id });
|
|
179
180
|
},
|
|
180
181
|
className: classes.createGroupButton,
|
|
182
|
+
disabled: readOnly,
|
|
181
183
|
children: `${labels.empty?.createGroup}`
|
|
182
184
|
}
|
|
183
185
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleGroup.js","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAuBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,SAAS;AACX,MAAsB;AACpB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,uBAAuB;AAE3B,QAAM,qBAAqB,WAAW;AAEtC,QAAM,gBAEF,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,kBACtB,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,yBAAe,EAAE,MAAM,YAAY,GAAI,CAAA;AAAA,QACzC;AAAA,QACA,UAAU;AAAA,QACV,+BAAY,KAAI,EAAA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EF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"RuleGroup.js","sources":["../../../../src/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"../../Button\";\nimport { HvEmptyState } from \"../../EmptyState\";\nimport { HvMultiButton } from \"../../MultiButton\";\nimport { HvTypography } from \"../../Typography\";\nimport { IconButton } from \"../../utils/IconButton\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { Rule } from \"../Rule\";\nimport { useQueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\nimport { HvQueryBuilderQuery, HvQueryBuilderQueryCombinator } from \"../types\";\n\nexport interface RuleGroupProps {\n id: React.Key;\n level?: number;\n combinator?: string;\n rules?: HvQueryBuilderQuery[\"rules\"];\n classes?: ExtractNames<typeof useClasses>;\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const {\n dispatchAction,\n askAction,\n maxDepth,\n combinators,\n labels,\n readOnly,\n disableConfirmation,\n } = useQueryBuilderContext();\n\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const onClickCombinator = useCallback(\n (item: HvQueryBuilderQueryCombinator) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators?.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n <div className={cx(classes.buttonBackground, classes.topRemoveButton)}>\n <IconButton\n className={classes.removeButton}\n onClick={() =>\n disableConfirmation\n ? dispatchAction({ type: \"remove-node\", id })\n : askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n })\n }\n title={\n (level === 0 && labels.query?.delete?.tooltip) ||\n labels.group.delete.tooltip ||\n (level === 0 && labels.query?.delete?.ariaLabel) ||\n labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <Delete\n role=\"none\"\n className={cx({ [classes.topRemoveButtonDisabled]: readOnly })}\n />\n </IconButton>\n </div>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n className={classes.createConditionButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n link\n component=\"button\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n className={classes.createGroupButton}\n disabled={readOnly}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <div\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAsBO,MAAM,YAAY,CAAC;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,SAAS;AACX,MAAsB;AACpB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,uBAAuB;AAE3B,QAAM,qBAAqB,WAAW;AAEtC,QAAM,gBAEF,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,kBACtB,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAA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OAAO,OAAO,WAAW;AAAA,kBAAA;AAAA,gBAC/B;AAAA,cAAA,GACF;AAAA,YAAA,GAEJ;AAAA,YAEF,0BAAO,MAAK,EAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAEF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT,QAAQ;AAAA,cACR,QAAQ;AAAA,YACV;AAAA,YAEC,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
package/dist/esm/Tag/Tag.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { getColor } from "@hitachivantara/uikit-styles";
|
|
3
3
|
import Chip from "@mui/material/Chip";
|
|
4
|
-
import { CloseXS } from "@hitachivantara/uikit-react-icons";
|
|
4
|
+
import { CloseXS, CheckboxCheck, Checkbox } from "@hitachivantara/uikit-react-icons";
|
|
5
5
|
import { useTheme } from "../hooks/useTheme.js";
|
|
6
6
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
7
|
+
import { useControlled } from "../hooks/useControlled.js";
|
|
7
8
|
import { useClasses } from "./Tag.styles.js";
|
|
8
9
|
import { staticClasses } from "./Tag.styles.js";
|
|
9
10
|
const getCategoricalColor = (customColor, colors) => {
|
|
@@ -17,6 +18,9 @@ const HvTag = (props) => {
|
|
|
17
18
|
label,
|
|
18
19
|
disabled,
|
|
19
20
|
type = "semantic",
|
|
21
|
+
selectable,
|
|
22
|
+
selected,
|
|
23
|
+
defaultSelected = false,
|
|
20
24
|
color,
|
|
21
25
|
deleteIcon,
|
|
22
26
|
onDelete,
|
|
@@ -29,13 +33,16 @@ const HvTag = (props) => {
|
|
|
29
33
|
} = useDefaultProps("HvTag", props);
|
|
30
34
|
const { colors } = useTheme();
|
|
31
35
|
const { classes, cx, css } = useClasses(classesProp);
|
|
36
|
+
const [isSelected, setIsSelected] = useControlled(
|
|
37
|
+
selected,
|
|
38
|
+
Boolean(defaultSelected)
|
|
39
|
+
);
|
|
32
40
|
const defaultDeleteIcon = /* @__PURE__ */ jsx(
|
|
33
41
|
CloseXS,
|
|
34
42
|
{
|
|
35
43
|
role: "none",
|
|
36
44
|
className: cx(classes.button, classes.tagButton),
|
|
37
45
|
iconSize: "XS",
|
|
38
|
-
color: "base_dark",
|
|
39
46
|
...deleteButtonProps
|
|
40
47
|
}
|
|
41
48
|
);
|
|
@@ -47,6 +54,15 @@ const HvTag = (props) => {
|
|
|
47
54
|
boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}`
|
|
48
55
|
}
|
|
49
56
|
});
|
|
57
|
+
const onClickHandler = (event) => {
|
|
58
|
+
if (disabled)
|
|
59
|
+
return;
|
|
60
|
+
if (selectable)
|
|
61
|
+
setIsSelected(!isSelected);
|
|
62
|
+
onClick?.(event, !isSelected);
|
|
63
|
+
};
|
|
64
|
+
const colorOverride = disabled && ["atmo3", "secondary_60"] || void 0;
|
|
65
|
+
const avatarIcon = isSelected ? /* @__PURE__ */ jsx(CheckboxCheck, { color: colorOverride, iconSize: "XS" }) : /* @__PURE__ */ jsx(Checkbox, { color: colorOverride, iconSize: "XS" });
|
|
50
66
|
return /* @__PURE__ */ jsx(
|
|
51
67
|
Chip,
|
|
52
68
|
{
|
|
@@ -72,7 +88,11 @@ const HvTag = (props) => {
|
|
|
72
88
|
},
|
|
73
89
|
deleteIcon: deleteIcon || defaultDeleteIcon,
|
|
74
90
|
onDelete: disabled ? void 0 : onDelete,
|
|
75
|
-
onClick:
|
|
91
|
+
onClick: onClickHandler,
|
|
92
|
+
"aria-pressed": isSelected,
|
|
93
|
+
...selectable && type === "semantic" && {
|
|
94
|
+
avatar: avatarIcon
|
|
95
|
+
},
|
|
76
96
|
...others
|
|
77
97
|
}
|
|
78
98
|
);
|
package/dist/esm/Tag/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import { HTMLAttributes } from \"react\";\nimport { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import React, { HTMLAttributes } from \"react\";\nimport { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\n\nimport {\n Checkbox,\n CheckboxCheck,\n CloseXS,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { useControlled } from \"../hooks/useControlled\";\n\nimport { staticClasses, useClasses } from \"./Tag.styles\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\" | \"onSelect\"> {\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>, selected?: boolean) => void;\n /** Aria properties to apply to delete button in tag\n * @deprecated no longer used\n */\n deleteButtonArialLabel?: string;\n /** Props to apply to delete icon */\n deleteButtonProps?: HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n /** @ignore */\n ref?: MuiChipProps[\"ref\"];\n /** @ignore */\n component?: MuiChipProps[\"component\"];\n /** Determines whether or not the tag is selectable. */\n selectable?: boolean;\n /** Defines if the tag is selected. When defined the tag state becomes controlled. */\n selected?: boolean;\n /** When uncontrolled, defines the initial selected state. */\n defaultSelected?: boolean;\n}\n\nconst getCategoricalColor = (customColor, colors) => {\n return (customColor && colors?.[customColor]) || customColor || colors?.cat1;\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 selectable,\n selected,\n defaultSelected = false,\n color,\n deleteIcon,\n onDelete,\n onClick,\n // TODO: remove from API\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 [isSelected, setIsSelected] = useControlled(\n selected,\n Boolean(defaultSelected)\n );\n\n const defaultDeleteIcon = (\n <CloseXS\n role=\"none\"\n className={cx(classes.button, classes.tagButton)}\n iconSize=\"XS\"\n {...deleteButtonProps}\n />\n );\n\n const categoricalBackgroundColor =\n type === \"categorical\" ? getCategoricalColor(color, colors) : undefined;\n\n const backgroundColor =\n (type === \"semantic\" && getColor(color, \"neutral_20\")) ||\n (type === \"categorical\" && `${categoricalBackgroundColor}30`) ||\n undefined;\n\n const isClickable = !!(onClick || onDelete) && !disabled;\n\n const clickableClass = css({\n \"&:hover\": {\n boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}`,\n },\n });\n\n const onClickHandler = (event) => {\n if (disabled) return;\n if (selectable) setIsSelected(!isSelected);\n onClick?.(event, !isSelected);\n };\n\n const colorOverride = (disabled && [\"atmo3\", \"secondary_60\"]) || undefined;\n\n const avatarIcon = isSelected ? (\n <CheckboxCheck color={colorOverride} iconSize=\"XS\" />\n ) : (\n <Checkbox color={colorOverride} iconSize=\"XS\" />\n );\n\n return (\n <Chip\n label={label}\n disabled={disabled}\n className={cx({ [clickableClass]: isClickable }, className)}\n style={{\n ...(disabled ? null : { backgroundColor }),\n ...style,\n }}\n classes={{\n root: cx(classes.root, classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: isClickable,\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={deleteIcon || defaultDeleteIcon}\n onDelete={disabled ? undefined : onDelete}\n onClick={onClickHandler}\n aria-pressed={isSelected}\n {...(selectable &&\n type === \"semantic\" && {\n avatar: avatarIcon,\n })}\n {...others}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA6DA,MAAM,sBAAsB,CAAC,aAAa,WAAW;AACnD,SAAQ,eAAe,SAAS,WAAW,KAAM,eAAe,QAAQ;AAC1E;AAUa,MAAA,QAAQ,CAAC,UAAsB;AACpC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,yBAAyB;AAAA,IACzB,oBAAoB,CAAC;AAAA,IACrB,GAAG;AAAA,EAAA,IACD,gBAAgB,SAAS,KAAK;AAC5B,QAAA,EAAE,WAAW;AACnB,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAE7C,QAAA,CAAC,YAAY,aAAa,IAAI;AAAA,IAClC;AAAA,IACA,QAAQ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,gBAAgB,GAAG,SAAS,iBAAiB,CAAC;AAAA,UACvD,CAAC,QAAQ,mBAAmB,GAAG,SAAS,iBAAiB;AAAA,QAAA,CAC1D;AAAA,QACD,OAAO,QAAQ;AAAA,QACf,YAAY,GAAG,QAAQ,YAAY;AAAA,UACjC,CAAC,QAAQ,kBAAkB,GAAG;AAAA,QAAA,CAC/B;AAAA,MACH;AAAA,MACA,YAAY,cAAc;AAAA,MAC1B,UAAU,WAAW,SAAY;AAAA,MACjC,SAAS;AAAA,MACT,gBAAc;AAAA,MACb,GAAI,cACH,SAAS,cAAc;AAAA,QACrB,QAAQ;AAAA,MACV;AAAA,MACD,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
import { chipClasses } from "@mui/material/Chip";
|
|
2
3
|
import { outlineStyles } from "../utils/focusUtils.js";
|
|
3
4
|
import { createClasses } from "../utils/classes.js";
|
|
4
5
|
const { staticClasses, useClasses } = createClasses("HvTag", {
|
|
5
|
-
root: {
|
|
6
|
+
root: {
|
|
7
|
+
color: theme.colors.base_dark,
|
|
8
|
+
[`& .${chipClasses.avatar}`]: {
|
|
9
|
+
width: 12,
|
|
10
|
+
height: 12,
|
|
11
|
+
marginLeft: 2,
|
|
12
|
+
marginRight: 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
6
15
|
chipRoot: {
|
|
7
|
-
|
|
16
|
+
[`&.${chipClasses.root}`]: {
|
|
8
17
|
height: 16,
|
|
9
18
|
borderRadius: 0,
|
|
10
19
|
maxWidth: 180,
|
|
@@ -26,22 +35,24 @@ const { staticClasses, useClasses } = createClasses("HvTag", {
|
|
|
26
35
|
color: theme.colors.secondary_60
|
|
27
36
|
}
|
|
28
37
|
},
|
|
29
|
-
|
|
30
|
-
paddingLeft:
|
|
31
|
-
paddingRight:
|
|
32
|
-
...theme.typography.
|
|
33
|
-
color:
|
|
34
|
-
"& p": {
|
|
35
|
-
color: theme.colors.base_dark
|
|
36
|
-
}
|
|
38
|
+
[`& .${chipClasses.label}`]: {
|
|
39
|
+
paddingLeft: 4,
|
|
40
|
+
paddingRight: 4,
|
|
41
|
+
...theme.typography.caption2,
|
|
42
|
+
color: "currentcolor"
|
|
37
43
|
},
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
[`& .${chipClasses.deleteIcon}`]: {
|
|
45
|
+
margin: 0,
|
|
40
46
|
width: 16,
|
|
41
47
|
height: 16,
|
|
42
48
|
padding: 0,
|
|
49
|
+
color: "currentColor",
|
|
50
|
+
"& svg .color0": {
|
|
51
|
+
fill: "currentcolor"
|
|
52
|
+
},
|
|
43
53
|
"&:hover": {
|
|
44
|
-
backgroundColor: theme.colors.containerBackgroundHover
|
|
54
|
+
backgroundColor: theme.colors.containerBackgroundHover,
|
|
55
|
+
color: "unset"
|
|
45
56
|
},
|
|
46
57
|
"&:focus": {
|
|
47
58
|
...outlineStyles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.styles.js","sources":["../../../src/Tag/Tag.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTag\", {\n root: {},\n\n chipRoot: {\n
|
|
1
|
+
{"version":3,"file":"Tag.styles.js","sources":["../../../src/Tag/Tag.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { chipClasses } from \"@mui/material/Chip\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTag\", {\n root: {\n color: theme.colors.base_dark,\n\n [`& .${chipClasses.avatar}`]: {\n width: 12,\n height: 12,\n marginLeft: 2,\n marginRight: 0,\n },\n },\n\n chipRoot: {\n [`&.${chipClasses.root}`]: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n fontFamily: theme.fontFamily.body,\n \"&:focus-visible\": {\n backgroundColor: theme.alpha(\"base_light\", 0.3),\n },\n\n \"&$categorical\": {\n borderRadius: 8,\n \"& $label\": {\n color: theme.colors.secondary,\n },\n },\n },\n\n \"&$disabled\": {\n opacity: 1,\n backgroundColor: theme.colors.atmo3,\n \"& $label\": {\n color: theme.colors.secondary_60,\n },\n },\n\n [`& .${chipClasses.label}`]: {\n paddingLeft: 4,\n paddingRight: 4,\n ...(theme.typography.caption2 as CSSProperties),\n color: \"currentcolor\",\n },\n\n [`& .${chipClasses.deleteIcon}`]: {\n margin: 0,\n width: 16,\n height: 16,\n padding: 0,\n color: \"currentColor\",\n \"& svg .color0\": {\n fill: \"currentcolor\",\n },\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n color: \"unset\",\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 },\n\n disabled: {},\n\n clickable: {\n cursor: \"pointer\",\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n\n categorical: {},\n\n label: {},\n\n deleteIcon: {},\n\n // TODO: redundant - use deleteIcon. remove in v6\n button: {},\n tagButton: {},\n // TODO: redundant - use $clickable or :not($disabled). remove in v6\n focusVisible: {},\n disabledDeleteIcon: {},\n categoricalFocus: {},\n categoricalDisabled: {},\n});\n"],"names":[],"mappings":";;;;AAUO,MAAM,EAAE,eAAe,eAAe,cAAc,SAAS;AAAA,EAClE,MAAM;AAAA,IACJ,OAAO,MAAM,OAAO;AAAA,IAEpB,CAAC,MAAM,YAAY,MAAM,EAAE,GAAG;AAAA,MAC5B,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,EACF;AAA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EAGb,QAAQ,CAAC;AAAA,EACT,WAAW,CAAC;AAAA;AAAA,EAEZ,cAAc,CAAC;AAAA,EACf,oBAAoB,CAAC;AAAA,EACrB,kBAAkB,CAAC;AAAA,EACnB,qBAAqB,CAAC;AACxB,CAAC;"}
|
|
@@ -45,9 +45,9 @@ const HvTypography = forwardRef(
|
|
|
45
45
|
classes: classesProp,
|
|
46
46
|
variant: variantProp = "body",
|
|
47
47
|
link = false,
|
|
48
|
-
disabled = false,
|
|
49
48
|
noWrap = false,
|
|
50
49
|
paragraph = false,
|
|
50
|
+
disabled = false,
|
|
51
51
|
...others
|
|
52
52
|
} = useDefaultProps("HvTypography", props);
|
|
53
53
|
const { classes, cx } = useClasses(classesProp);
|
|
@@ -68,6 +68,7 @@ const HvTypography = forwardRef(
|
|
|
68
68
|
},
|
|
69
69
|
className
|
|
70
70
|
),
|
|
71
|
+
disabled,
|
|
71
72
|
...others
|
|
72
73
|
}
|
|
73
74
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\
|
|
1
|
+
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import { ElementType, forwardRef } from \"react\";\n\nimport { PolymorphicComponentRef, PolymorphicRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /** If `true`, the text will have a bottom margin. */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography: <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>\n) => React.ReactElement | null = forwardRef(\n <C extends React.ElementType = \"p\">(\n props: HvTypographyProps<C>,\n ref: PolymorphicRef<C>\n ) => {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;AAiBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAgCO,MAAM,eAEoB;AAAA,EAC/B,CACE,OACA,QACG;AACG,UAAA;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,MACT,SAAS,cAAc;AAAA,MACvB,OAAO;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,GAAG;AAAA,IAAA,IACD,gBAAgB,gBAAgB,KAAK;AACzC,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,UAAA,EAAE,gBAAgB;AAExB,UAAM,UAAU,WAAW,aAAa,aAAa,IAAI;AAEzD,UAAM,YACJ,iBAAkB,aAAa,OAAQ,gBAAgB,OAAO,KAAK;AAGnE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,OAAO;AAAA,UACf;AAAA,YACE,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACtB;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6398,9 +6398,9 @@ export declare type HvTagClasses = ExtractNames<typeof useClasses_107>;
|
|
|
6398
6398
|
|
|
6399
6399
|
export declare function hvTagColumn<D extends object = Record<string, unknown>, H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer, A extends object = Record<string, unknown>>(col: HvTableColumnConfig<D, H>, valueDataKey: keyof A, colorDataKey: keyof A, textColorDataKey: keyof A, fromRowData?: boolean, tagProps?: HvTagProps): HvTableColumnConfig<D, H>;
|
|
6400
6400
|
|
|
6401
|
-
export declare interface HvTagProps extends Omit<ChipProps, "color" | "classes"> {
|
|
6401
|
+
export declare interface HvTagProps extends Omit<ChipProps, "color" | "classes" | "onSelect"> {
|
|
6402
6402
|
/** The label of the tag element. */
|
|
6403
|
-
label?:
|
|
6403
|
+
label?: React_2.ReactNode;
|
|
6404
6404
|
/** Indicates that the form element is disabled. */
|
|
6405
6405
|
disabled?: boolean;
|
|
6406
6406
|
/** The type of the tag element. A tag can be of semantic or categoric type. */
|
|
@@ -6408,14 +6408,14 @@ export declare interface HvTagProps extends Omit<ChipProps, "color" | "classes">
|
|
|
6408
6408
|
/** Background color to be applied to the tag */
|
|
6409
6409
|
color?: HvColorAny;
|
|
6410
6410
|
/** Icon used to customize the delete icon in the Chip element */
|
|
6411
|
-
deleteIcon?:
|
|
6411
|
+
deleteIcon?: React_2.ReactElement;
|
|
6412
6412
|
/**
|
|
6413
6413
|
* The callback fired when the delete icon is pressed.
|
|
6414
6414
|
* This function has to be provided to the component, in order to render the delete icon
|
|
6415
6415
|
* */
|
|
6416
|
-
onDelete?: (event:
|
|
6416
|
+
onDelete?: (event: React_2.MouseEvent<HTMLElement>) => void;
|
|
6417
6417
|
/** Callback triggered when any item is clicked. */
|
|
6418
|
-
onClick?: (event:
|
|
6418
|
+
onClick?: (event: React_2.MouseEvent<HTMLElement>, selected?: boolean) => void;
|
|
6419
6419
|
/** Aria properties to apply to delete button in tag
|
|
6420
6420
|
* @deprecated no longer used
|
|
6421
6421
|
*/
|
|
@@ -6428,6 +6428,12 @@ export declare interface HvTagProps extends Omit<ChipProps, "color" | "classes">
|
|
|
6428
6428
|
ref?: ChipProps["ref"];
|
|
6429
6429
|
/** @ignore */
|
|
6430
6430
|
component?: ChipProps["component"];
|
|
6431
|
+
/** Determines whether or not the tag is selectable. */
|
|
6432
|
+
selectable?: boolean;
|
|
6433
|
+
/** Defines if the tag is selected. When defined the tag state becomes controlled. */
|
|
6434
|
+
selected?: boolean;
|
|
6435
|
+
/** When uncontrolled, defines the initial selected state. */
|
|
6436
|
+
defaultSelected?: boolean;
|
|
6431
6437
|
}
|
|
6432
6438
|
|
|
6433
6439
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.41.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public",
|
|
65
65
|
"directory": "package"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "5d2df079c4d3e8b19badd85be4e98b4d778e6d84",
|
|
68
68
|
"main": "dist/cjs/index.cjs",
|
|
69
69
|
"exports": {
|
|
70
70
|
".": {
|