@hitachivantara/uikit-react-core 5.36.10 → 5.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs +3 -1
- package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs.map +1 -1
- package/dist/cjs/components/Dropdown/Dropdown.cjs +4 -1
- package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Context.cjs +15 -2
- package/dist/cjs/components/QueryBuilder/Context.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs +35 -25
- package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs +10 -0
- package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Attribute/Attribute.cjs +2 -3
- package/dist/cjs/components/QueryBuilder/Rule/Attribute/Attribute.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Operator/Operator.cjs +2 -3
- package/dist/cjs/components/QueryBuilder/Rule/Operator/Operator.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs +16 -14
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs +1 -2
- package/dist/cjs/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +1 -2
- package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/utils.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +4 -5
- package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/TextValue/TextValue.cjs +1 -2
- package/dist/cjs/components/QueryBuilder/Rule/Value/TextValue/TextValue.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/Value.cjs +8 -3
- package/dist/cjs/components/QueryBuilder/Rule/Value/Value.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +19 -24
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/utils/index.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/utils/reducer.cjs +1 -1
- package/dist/cjs/components/QueryBuilder/utils/reducer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/providers/Provider.cjs +11 -3
- package/dist/cjs/providers/Provider.cjs.map +1 -1
- package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js +3 -1
- package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +5 -2
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Context.js +17 -4
- package/dist/esm/components/QueryBuilder/Context.js.map +1 -1
- package/dist/esm/components/QueryBuilder/QueryBuilder.js +37 -27
- package/dist/esm/components/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js +10 -0
- package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Attribute/Attribute.js +3 -4
- package/dist/esm/components/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Operator/Operator.js +4 -5
- package/dist/esm/components/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Rule.js +18 -16
- package/dist/esm/components/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js +3 -4
- package/dist/esm/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +3 -4
- package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/utils.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +6 -7
- package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/TextValue/TextValue.js +3 -4
- package/dist/esm/components/QueryBuilder/Rule/Value/TextValue/TextValue.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/Value.js +10 -5
- package/dist/esm/components/QueryBuilder/Rule/Value/Value.js.map +1 -1
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +21 -26
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/components/QueryBuilder/utils/index.js.map +1 -1
- package/dist/esm/components/QueryBuilder/utils/reducer.js +1 -1
- package/dist/esm/components/QueryBuilder/utils/reducer.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/Provider.js +11 -3
- package/dist/esm/providers/Provider.js.map +1 -1
- package/dist/types/index.d.ts +93 -37
- package/package.json +5 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback } from "react";
|
|
3
3
|
import { Add, Delete, Info } from "@hitachivantara/uikit-react-icons";
|
|
4
4
|
import { withTooltip } from "../../../hocs/withTooltip.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useQueryBuilderContext } from "../Context.js";
|
|
6
6
|
import { useClasses } from "../QueryBuilder.styles.js";
|
|
7
7
|
import { HvButton } from "../../Button/Button.js";
|
|
8
8
|
import { Rule } from "../Rule/Rule.js";
|
|
@@ -21,15 +21,15 @@ const RuleGroup = ({
|
|
|
21
21
|
classes,
|
|
22
22
|
cx
|
|
23
23
|
} = useClasses(classesProp);
|
|
24
|
-
const context = useContext(QueryBuilderContext);
|
|
25
24
|
const {
|
|
26
25
|
dispatchAction,
|
|
27
26
|
askAction,
|
|
28
27
|
maxDepth,
|
|
29
28
|
combinators,
|
|
30
29
|
labels,
|
|
31
|
-
readOnly
|
|
32
|
-
|
|
30
|
+
readOnly,
|
|
31
|
+
disableConfirmation
|
|
32
|
+
} = useQueryBuilderContext();
|
|
33
33
|
const normalizedMaxDepth = maxDepth - 1;
|
|
34
34
|
const actionButtons = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
35
35
|
/* @__PURE__ */ jsx("div", { className: classes.buttonBackground, children: /* @__PURE__ */ jsx(HvButton, { variant: "secondarySubtle", onClick: () => {
|
|
@@ -61,22 +61,23 @@ const RuleGroup = ({
|
|
|
61
61
|
}), children: [
|
|
62
62
|
/* @__PURE__ */ jsxs(HvGrid, { container: true, children: [
|
|
63
63
|
/* @__PURE__ */ jsx(HvGrid, { item: true, children: /* @__PURE__ */ jsx(HvMultiButton, { className: cx(classes.combinator, classes.topCombinator), disabled: readOnly, children: combinators && combinators.map((item) => /* @__PURE__ */ jsx(HvButton, { className: classes.combinatorButton, selected: item.operand === combinator, onClick: () => item.operand && onClickCombinator(item), disabled: readOnly, size: "xs", children: item.label }, item.operand)) }) }),
|
|
64
|
-
/* @__PURE__ */ jsx(HvGrid, { item: true, children: /* @__PURE__ */ jsx("div", { className: cx(classes.buttonBackground, classes.topRemoveButton), children: /* @__PURE__ */ jsx(HvButton, { icon: true, className: classes.removeButton, onClick: () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
64
|
+
/* @__PURE__ */ jsx(HvGrid, { item: true, children: /* @__PURE__ */ jsx("div", { className: cx(classes.buttonBackground, classes.topRemoveButton), children: /* @__PURE__ */ jsx(HvButton, { icon: true, className: classes.removeButton, onClick: () => disableConfirmation ? dispatchAction({
|
|
65
|
+
type: "remove-node",
|
|
66
|
+
id
|
|
67
|
+
}) : askAction({
|
|
68
|
+
actions: [{
|
|
69
|
+
type: "remove-node",
|
|
70
|
+
id
|
|
71
|
+
}],
|
|
72
|
+
dialog: level === 0 && labels.query?.delete != null ? labels.query.delete : labels.group.delete
|
|
73
|
+
}), "aria-label": level === 0 && labels.query?.delete?.ariaLabel ? labels.query?.delete?.ariaLabel : labels.group.delete.ariaLabel, disabled: readOnly, children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) }) })
|
|
73
74
|
] }),
|
|
74
75
|
rules?.length > 0 && /* @__PURE__ */ jsx("div", { className: cx(classes.rulesContainer, {
|
|
75
76
|
[classes.subRulesContainer]: level > 0,
|
|
76
77
|
[classes.topRulesContainer]: level === 0
|
|
77
78
|
}), children: rules.map((rule, index) => {
|
|
78
79
|
if ("combinator" in rule) {
|
|
79
|
-
return /* @__PURE__ */ jsx(RuleGroup, { level: level + 1, ...rule, id: rule.id, classes }, rule.id
|
|
80
|
+
return /* @__PURE__ */ jsx(RuleGroup, { level: level + 1, ...rule, id: rule.id, classes }, rule.id);
|
|
80
81
|
}
|
|
81
82
|
const isInvalid = combinator === "and" && rules.some((r, i) => {
|
|
82
83
|
if ("attribute" in r) {
|
|
@@ -86,29 +87,23 @@ const RuleGroup = ({
|
|
|
86
87
|
}
|
|
87
88
|
return false;
|
|
88
89
|
});
|
|
89
|
-
return /* @__PURE__ */ jsx(Rule, { ...rule, isInvalid, id: rule.id, combinator }, rule.id
|
|
90
|
+
return /* @__PURE__ */ jsx(Rule, { ...rule, isInvalid, id: rule.id, combinator }, rule.id);
|
|
90
91
|
}) }),
|
|
91
92
|
rules?.length === 0 && /* @__PURE__ */ jsx(HvEmptyState, { title: labels.empty?.title, message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
-
/* @__PURE__ */ jsx(HvTypography, {
|
|
93
|
+
/* @__PURE__ */ jsx(HvTypography, { link: true, component: "button", onClick: () => {
|
|
93
94
|
dispatchAction({
|
|
94
95
|
type: "add-rule",
|
|
95
96
|
id
|
|
96
97
|
});
|
|
97
|
-
},
|
|
98
|
-
cursor: "pointer",
|
|
99
|
-
textDecoration: "underline"
|
|
100
|
-
}, children: `${labels.empty?.createCondition}` }),
|
|
98
|
+
}, className: classes.createConditionButton, children: `${labels.empty?.createCondition}` }),
|
|
101
99
|
level <= normalizedMaxDepth && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
102
100
|
`${labels.empty?.spacer}`,
|
|
103
|
-
/* @__PURE__ */ jsx(HvTypography, {
|
|
101
|
+
/* @__PURE__ */ jsx(HvTypography, { link: true, component: "button", onClick: () => {
|
|
104
102
|
dispatchAction({
|
|
105
103
|
type: "add-group",
|
|
106
104
|
id
|
|
107
105
|
});
|
|
108
|
-
},
|
|
109
|
-
cursor: "pointer",
|
|
110
|
-
textDecoration: "underline"
|
|
111
|
-
}, children: `${labels.empty?.createGroup}` })
|
|
106
|
+
}, className: classes.createGroupButton, children: `${labels.empty?.createGroup}` })
|
|
112
107
|
] })
|
|
113
108
|
] }), icon: /* @__PURE__ */ jsx(Info, {}) }),
|
|
114
109
|
/* @__PURE__ */ jsx(HvGrid, { container: true, children: /* @__PURE__ */ jsx(HvGrid, { item: true, className: cx(classes.actionButtonContainer, classes.topActionButtonContainer), children: actionButtons }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleGroup.js","sources":["../../../../../src/components/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback, useContext } from \"react\";\n\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvEmptyState } from \"@core/components/EmptyState\";\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvMultiButton } from \"@core/components/MultiButton\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { QueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\n\nexport interface RuleGroupProps {\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: ExtractNames<typeof useClasses>;\n id?: number;\n level?: number;\n combinator?: string;\n rules?: any[];\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 context = useContext(QueryBuilderContext);\n\n const { dispatchAction, askAction, maxDepth, combinators, labels, readOnly } =\n context;\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 DeleteIcon = withTooltip(\n () => (\n <Delete className={cx({ [classes.topRemoveButtonDisabled]: readOnly })} />\n ),\n level === 0 && labels.query?.delete?.tooltip\n ? labels.query?.delete?.tooltip\n : labels.group.delete.tooltip,\n \"top\"\n );\n\n const onClickCombinator = useCallback(\n (item) => {\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 <HvGrid container>\n <HvGrid item>\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators &&\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 </HvGrid>\n <HvGrid item>\n <div\n className={cx(classes.buttonBackground, classes.topRemoveButton)}\n >\n <HvButton\n icon\n className={classes.removeButton}\n onClick={() => {\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 aria-label={\n level === 0 && labels.query?.delete?.ariaLabel\n ? labels.query?.delete?.ariaLabel\n : labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <DeleteIcon />\n </HvButton>\n </div>\n </HvGrid>\n </HvGrid>\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 ?? index}\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 ?? index}\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 variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n style={{ cursor: \"pointer\", textDecoration: \"underline\" }}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n style={{\n cursor: \"pointer\",\n textDecoration: \"underline\",\n }}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <HvGrid container>\n <HvGrid\n item\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </HvGrid>\n </HvGrid>\n </div>\n );\n};\n"],"names":["RuleGroup","level","id","combinator","rules","classes","classesProp","cx","useClasses","context","useContext","QueryBuilderContext","dispatchAction","askAction","maxDepth","combinators","labels","readOnly","normalizedMaxDepth","actionButtons","buttonBackground","type","query","addRule","label","group","addGroup","DeleteIcon","withTooltip","topRemoveButtonDisabled","delete","tooltip","onClickCombinator","useCallback","item","operand","root","topGroup","subGroup","topCombinator","map","combinatorButton","topRemoveButton","removeButton","actions","dialog","ariaLabel","length","rulesContainer","subRulesContainer","topRulesContainer","rule","index","isInvalid","some","r","i","attribute","empty","title","cursor","textDecoration","createCondition","spacer","createGroup","actionButtonContainer","topActionButtonContainer"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,YAAYA,CAAC;AAAA,EACxBC,QAAQ;AAAA,EACRC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AAS,MAAM;AACE,uBAAA;AAAA,UAAEtC,MAAM;AAAA,UAAYnB;AAAAA,QAAAA,CAAI;AAAA,SAEzC,OAAO;AAAA,QAAE0D,QAAQ;AAAA,QAAWC,gBAAgB;AAAA,MAAA,GAE1C,UAAA,GAAE7C,OAAO0C,OAAOI,eAAgB,IACpC;AAAA,MACC7D,SAASiB,sBAEJ,qBAAA,UAAA,EAAA,UAAA;AAAA,QAAEF,GAAAA,OAAO0C,OAAOK,MAAO;AAAA,4BACxB,cACC,EAAA,SAAQ,QACR,WAAU,KACV,SAAS,MAAM;AACE,yBAAA;AAAA,YAAE1C,MAAM;AAAA,YAAanB;AAAAA,UAAAA,CAAI;AAAA,WAE1C,OAAO;AAAA,UACL0D,QAAQ;AAAA,UACRC,gBAAgB;AAAA,QAAA,GAGhB,UAAA,GAAE7C,OAAO0C,OAAOM,WAAY,IAChC;AAAA,MAAA,GACF;AAAA,IAAA,EAEJ,CAAA,GAEF,MAAO,oBAAA,MAAA,CAAA,CAAO,EAEjB,CAAA;AAAA,wBACA,QAAO,EAAA,WAAS,MACf,UAAA,oBAAC,UACC,MAAI,MACJ,WAAWzD,GACTF,QAAQ4D,uBACR5D,QAAQ6D,wBACV,GAEC/C,wBACH,CAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"RuleGroup.js","sources":["../../../../../src/components/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvEmptyState } from \"@core/components/EmptyState\";\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvMultiButton } from \"@core/components/MultiButton\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { ExtractNames } from \"@core/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 DeleteIcon = withTooltip(\n () => (\n <Delete className={cx({ [classes.topRemoveButtonDisabled]: readOnly })} />\n ),\n level === 0 && labels.query?.delete?.tooltip\n ? labels.query?.delete?.tooltip\n : labels.group.delete.tooltip,\n \"top\"\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 <HvGrid container>\n <HvGrid item>\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators &&\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 </HvGrid>\n <HvGrid item>\n <div\n className={cx(classes.buttonBackground, classes.topRemoveButton)}\n >\n <HvButton\n icon\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 aria-label={\n level === 0 && labels.query?.delete?.ariaLabel\n ? labels.query?.delete?.ariaLabel\n : labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <DeleteIcon />\n </HvButton>\n </div>\n </HvGrid>\n </HvGrid>\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 <HvGrid container>\n <HvGrid\n item\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </HvGrid>\n </HvGrid>\n </div>\n );\n};\n"],"names":["RuleGroup","level","id","combinator","rules","classes","classesProp","cx","useClasses","dispatchAction","askAction","maxDepth","combinators","labels","readOnly","disableConfirmation","useQueryBuilderContext","normalizedMaxDepth","actionButtons","buttonBackground","type","query","addRule","label","group","addGroup","DeleteIcon","withTooltip","topRemoveButtonDisabled","delete","tooltip","onClickCombinator","useCallback","item","operand","root","topGroup","subGroup","topCombinator","map","combinatorButton","topRemoveButton","removeButton","actions","dialog","ariaLabel","length","rulesContainer","subRulesContainer","topRulesContainer","rule","index","isInvalid","some","r","i","attribute","empty","title","createConditionButton","createCondition","spacer","createGroupButton","createGroup","actionButtonContainer","topActionButtonContainer"],"mappings":";;;;;;;;;;;;AAwBO,MAAMA,YAAYA,CAAC;AAAA,EACxBC,QAAQ;AAAA,EACRC;AAAAA,EACAC,aAAa;AAAA,EACbC,QAAQ,CAAE;AAAA,EACVC,SAASC;AACK,MAAM;AACd,QAAA;AAAA,IAAED;AAAAA,IAASE;AAAAA,EAAAA,IAAOC,WAAWF,WAAW;AAExC,QAAA;AAAA,IACJG;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,MACEC,uBAAuB;AAE3B,QAAMC,qBAAqBN,WAAW;AAEtC,QAAMO,gBAEF,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,OAAA,EAAI,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AM;AAAA,YAAalB;AAAAA,UAAAA,CAAI;AAAA,QAAA,GAE1C,WAAWG,QAAQyD,mBAEjB,aAAEjD,OAAO4C,OAAOM,WAAY,IAChC;AAAA,MAAA,GACF;AAAA,IAAA,EAEJ,CAAA,GAEF,MAAO,oBAAA,MAAA,CAAA,CAAO,EAEjB,CAAA;AAAA,wBACA,QAAO,EAAA,WAAS,MACf,UAAA,oBAAC,UACC,MAAI,MACJ,WAAWxD,GACTF,QAAQ2D,uBACR3D,QAAQ4D,wBACV,GAEC/C,wBACH,CAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/QueryBuilder/utils/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/QueryBuilder/utils/index.tsx"],"sourcesContent":["import { HvQueryBuilderQueryGroup, HvQueryBuilderQueryRule } from \"../types\";\n\nexport const isBigList = (values: unknown[]) =>\n values != null && values?.length > 10;\n\nexport const emptyRule = () => ({\n id: Math.random(),\n});\n\nexport const emptyGroup = (createEmptyRule = false) => ({\n id: Math.random(),\n combinator: \"and\",\n rules: createEmptyRule ? [emptyRule()] : [],\n});\n\nexport const clearNodeIds = (\n original: HvQueryBuilderQueryGroup | HvQueryBuilderQueryRule\n) => {\n const rule = { ...original };\n\n // @ts-ignore\n delete rule.id;\n\n if (\"rules\" in rule) {\n rule.rules = rule.rules.map((r) => clearNodeIds(r));\n }\n\n return rule;\n};\n\nexport const findNodeById = (\n id: React.Key,\n node: HvQueryBuilderQueryGroup | HvQueryBuilderQueryRule\n) => {\n if (node.id === id) {\n return node;\n }\n if (\"rules\" in node) {\n for (let i = 0; i < node.rules.length; ++i) {\n const rule = node.rules[i];\n\n const found = findNodeById(id, rule);\n if (found) {\n return found;\n }\n }\n }\n\n return null;\n};\n\nexport const findParentById = (\n id: React.Key,\n node: HvQueryBuilderQueryGroup | HvQueryBuilderQueryRule,\n parent?: HvQueryBuilderQueryGroup\n) => {\n if (node.id === id) {\n return parent ?? null;\n }\n\n if (\"rules\" in node) {\n const group = node;\n\n for (let i = 0; i < group.rules.length; ++i) {\n const rule = group.rules[i];\n\n const found = findParentById(id, rule, group);\n if (found) {\n return found;\n }\n }\n }\n\n return null;\n};\n"],"names":["isBigList","values","length","emptyRule","id","Math","random","emptyGroup","createEmptyRule","combinator","rules","clearNodeIds","original","rule","map","r","findNodeById","node","i","found","findParentById","parent","group"],"mappings":"AAEO,MAAMA,YAAYA,CAACC,WACxBA,UAAU,QAAQA,QAAQC,SAAS;AAE9B,MAAMC,YAAYA,OAAO;AAAA,EAC9BC,IAAIC,KAAKC,OAAO;AAClB;AAEaC,MAAAA,aAAaA,CAACC,kBAAkB,WAAW;AAAA,EACtDJ,IAAIC,KAAKC,OAAO;AAAA,EAChBG,YAAY;AAAA,EACZC,OAAOF,kBAAkB,CAACL,UAAU,CAAC,IAAI,CAAA;AAC3C;AAEaQ,MAAAA,eAAeA,CAC1BC,aACG;AACH,QAAMC,OAAO;AAAA,IAAE,GAAGD;AAAAA,EAAAA;AAGlB,SAAOC,KAAKT;AAEZ,MAAI,WAAWS,MAAM;AACnBA,SAAKH,QAAQG,KAAKH,MAAMI,IAAKC,CAAMJ,MAAAA,aAAaI,CAAC,CAAC;AAAA,EACpD;AAEOF,SAAAA;AACT;AAEaG,MAAAA,eAAeA,CAC1BZ,IACAa,SACG;AACCA,MAAAA,KAAKb,OAAOA,IAAI;AACXa,WAAAA;AAAAA,EACT;AACA,MAAI,WAAWA,MAAM;AACnB,aAASC,IAAI,GAAGA,IAAID,KAAKP,MAAMR,QAAQ,EAAEgB,GAAG;AACpCL,YAAAA,OAAOI,KAAKP,MAAMQ,CAAC;AAEnBC,YAAAA,QAAQH,aAAaZ,IAAIS,IAAI;AACnC,UAAIM,OAAO;AACFA,eAAAA;AAAAA,MACT;AAAA,IACF;AAAA,EACF;AAEO,SAAA;AACT;AAEO,MAAMC,iBAAiBA,CAC5BhB,IACAa,MACAI,WACG;AACCJ,MAAAA,KAAKb,OAAOA,IAAI;AAClB,WAAOiB,UAAU;AAAA,EACnB;AAEA,MAAI,WAAWJ,MAAM;AACnB,UAAMK,QAAQL;AAEd,aAASC,IAAI,GAAGA,IAAII,MAAMZ,MAAMR,QAAQ,EAAEgB,GAAG;AACrCL,YAAAA,OAAOS,MAAMZ,MAAMQ,CAAC;AAE1B,YAAMC,QAAQC,eAAehB,IAAIS,MAAMS,KAAK;AAC5C,UAAIH,OAAO;AACFA,eAAAA;AAAAA,MACT;AAAA,IACF;AAAA,EACF;AAEO,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.js","sources":["../../../../../src/components/QueryBuilder/utils/reducer.tsx"],"sourcesContent":["import { emptyRule, emptyGroup, findNodeById, findParentById } from \"./index\";\n\nconst reducer = (state, action) => {\n const query = { ...state };\n\n switch (action.type) {\n case \"reset-query\": {\n return emptyGroup();\n }\n case \"reset-group\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n group.rules = [emptyRule()];\n\n return query;\n }\n break;\n }\n case \"add-rule\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n const rule = emptyRule();\n\n group.rules.push(rule);\n\n return query;\n }\n break;\n }\n case \"add-group\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n group.rules.push(emptyGroup(true));\n\n return query;\n }\n break;\n }\n case \"remove-node\": {\n const parent = findParentById(action.id, query);\n if (parent) {\n parent.rules = parent.rules.filter((rule) => rule.id !== action.id);\n\n return query;\n }\n\n // reset query if deleting top node\n return emptyGroup();\n }\n case \"set-combinator\": {\n const node = findNodeById(action.id, query);\n if (node && \"combinator\" in node) {\n if (node.combinator !== action.combinator) {\n node.combinator = action.combinator;\n\n return query;\n }\n }\n break;\n }\n case \"set-attribute\": {\n const node = findNodeById(action.id, query);\n if (node && node.attribute !== action.attribute) {\n node.attribute = action.attribute ?? undefined;\n\n // we keep the operator and value unless the operator is explicitly null (or set)\n if (action.operator !== undefined) {\n node.operator = action.operator ?? undefined;\n node.value = action.value ?? undefined;\n }\n\n return query;\n }\n break;\n }\n case \"set-operator\": {\n const node = findNodeById(action.id, query);\n if (node && \"attribute\" in node) {\n if (node.operator !== action.operator) {\n node.operator = action.operator;\n if (action.value !== undefined) {\n node.value = action.value ?? undefined;\n }\n\n return query;\n }\n }\n break;\n }\n case \"set-value\": {\n const node = findNodeById(action.id, query);\n if (node && \"operator\" in node) {\n node.value = action.value ?? undefined;\n\n return query;\n }\n break;\n }\n\n default:\n }\n\n //
|
|
1
|
+
{"version":3,"file":"reducer.js","sources":["../../../../../src/components/QueryBuilder/utils/reducer.tsx"],"sourcesContent":["import { Reducer } from \"react\";\n\nimport { emptyRule, emptyGroup, findNodeById, findParentById } from \"./index\";\nimport { HvQueryBuilderQuery, QueryAction } from \"../types\";\n\nconst reducer: Reducer<HvQueryBuilderQuery, QueryAction> = (state, action) => {\n const query = { ...state };\n\n switch (action.type) {\n case \"reset-query\": {\n return emptyGroup();\n }\n case \"reset-group\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n group.rules = [emptyRule()];\n\n return query;\n }\n break;\n }\n case \"add-rule\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n const rule = emptyRule();\n\n group.rules.push(rule);\n\n return query;\n }\n break;\n }\n case \"add-group\": {\n const group = findNodeById(action.id, query);\n if (group && \"rules\" in group) {\n group.rules.push(emptyGroup(true));\n\n return query;\n }\n break;\n }\n case \"remove-node\": {\n const parent = findParentById(action.id, query);\n if (parent) {\n parent.rules = parent.rules.filter((rule) => rule.id !== action.id);\n\n return query;\n }\n\n // reset query if deleting top node\n return emptyGroup();\n }\n case \"set-combinator\": {\n const node = findNodeById(action.id, query);\n if (node && \"combinator\" in node) {\n if (node.combinator !== action.combinator) {\n node.combinator = action.combinator;\n\n return query;\n }\n }\n break;\n }\n case \"set-attribute\": {\n const node = findNodeById(action.id, query);\n if (node && node.attribute !== action.attribute) {\n node.attribute = action.attribute ?? undefined;\n\n // we keep the operator and value unless the operator is explicitly null (or set)\n if (action.operator !== undefined) {\n node.operator = action.operator ?? undefined;\n node.value = action.value ?? undefined;\n }\n\n return query;\n }\n break;\n }\n case \"set-operator\": {\n const node = findNodeById(action.id, query);\n if (node && \"attribute\" in node) {\n if (node.operator !== action.operator) {\n node.operator = action.operator;\n if (action.value !== undefined) {\n node.value = action.value ?? undefined;\n }\n\n return query;\n }\n }\n break;\n }\n case \"set-value\": {\n const node = findNodeById(action.id, query);\n if (node && \"operator\" in node) {\n node.value = action.value ?? undefined;\n\n return query;\n }\n break;\n }\n\n default:\n }\n\n // Return existing state if nothing changed\n return query;\n};\n\nexport default reducer;\n"],"names":["reducer","state","action","query","type","emptyGroup","group","findNodeById","id","rules","emptyRule","rule","push","parent","findParentById","filter","node","combinator","attribute","undefined","operator","value"],"mappings":";AAKA,MAAMA,UAAqDA,CAACC,OAAOC,WAAW;AAC5E,QAAMC,QAAQ;AAAA,IAAE,GAAGF;AAAAA,EAAAA;AAEnB,UAAQC,OAAOE,MAAI;AAAA,IACjB,KAAK,eAAe;AAClB,aAAOC,WAAW;AAAA,IACpB;AAAA,IACA,KAAK,eAAe;AAClB,YAAMC,QAAQC,aAAaL,OAAOM,IAAIL,KAAK;AACvCG,UAAAA,SAAS,WAAWA,OAAO;AACvBG,cAAAA,QAAQ,CAACC,UAAAA,CAAW;AAEnBP,eAAAA;AAAAA,MACT;AACA;AAAA,IACF;AAAA,IACA,KAAK,YAAY;AACf,YAAMG,QAAQC,aAAaL,OAAOM,IAAIL,KAAK;AACvCG,UAAAA,SAAS,WAAWA,OAAO;AAC7B,cAAMK,OAAOD;AAEPD,cAAAA,MAAMG,KAAKD,IAAI;AAEdR,eAAAA;AAAAA,MACT;AACA;AAAA,IACF;AAAA,IACA,KAAK,aAAa;AAChB,YAAMG,QAAQC,aAAaL,OAAOM,IAAIL,K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,QACT;AAAA,MACF;AACA;AAAA,IACF;AAAA,IACA,KAAK,aAAa;AAChB,YAAMa,OAAOT,aAAaL,OAAOM,IAAIL,KAAK;AACtCa,UAAAA,QAAQ,cAAcA,MAAM;AACzBK,aAAAA,QAAQnB,OAAOmB,SAASF;AAEtBhB,eAAAA;AAAAA,MACT;AACA;AAAA,IACF;AAAA,EAGF;AAGOA,SAAAA;AACT;AAEA,MAAA,YAAeH;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -248,7 +248,7 @@ import { staticClasses as staticClasses107 } from "./components/InlineEditor/Inl
|
|
|
248
248
|
import { HvInlineEditor } from "./components/InlineEditor/InlineEditor.js";
|
|
249
249
|
import { staticClasses as staticClasses108 } from "./components/TimeAgo/TimeAgo.styles.js";
|
|
250
250
|
import { HvTimeAgo } from "./components/TimeAgo/TimeAgo.js";
|
|
251
|
-
import { defaultCombinators, defaultLabels, defaultOperators } from "./components/QueryBuilder/Context.js";
|
|
251
|
+
import { defaultCombinators, defaultLabels, defaultOperators, useQueryBuilderContext } from "./components/QueryBuilder/Context.js";
|
|
252
252
|
import { staticClasses as staticClasses109 } from "./components/QueryBuilder/QueryBuilder.styles.js";
|
|
253
253
|
import { HvQueryBuilder } from "./components/QueryBuilder/QueryBuilder.js";
|
|
254
254
|
import { staticClasses as staticClasses110 } from "./components/ColorPicker/ColorPicker.styles.js";
|
|
@@ -647,6 +647,7 @@ export {
|
|
|
647
647
|
useInstance,
|
|
648
648
|
useIsMounted,
|
|
649
649
|
useLabels,
|
|
650
|
+
useQueryBuilderContext,
|
|
650
651
|
useSavedState,
|
|
651
652
|
useScrollTo,
|
|
652
653
|
useSelectionPath,
|
|
@@ -26,7 +26,11 @@ const HvProvider = ({
|
|
|
26
26
|
prepend: true
|
|
27
27
|
}), [classNameKey]);
|
|
28
28
|
return /* @__PURE__ */ jsxs(CacheProvider, { value: emotionCache, children: [
|
|
29
|
-
/* @__PURE__ */ jsx(Global, { styles: /* @__PURE__ */ css(cssBaseline === "global" &&
|
|
29
|
+
/* @__PURE__ */ jsx(Global, { styles: /* @__PURE__ */ css(cssBaseline === "global" && {
|
|
30
|
+
[`@layer hv-uikit-baseline`]: {
|
|
31
|
+
...CssBaseline
|
|
32
|
+
}
|
|
33
|
+
}, " ", getThemesVars(themesList), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:HvProvider;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL2h2LXVpa2l0LXJlYWN0L2h2LXVpa2l0LXJlYWN0L3BhY2thZ2VzL2NvcmUvc3JjL3Byb3ZpZGVycy9Qcm92aWRlci50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0h3QiIsImZpbGUiOiIvaG9tZS9ydW5uZXIvd29yay9odi11aWtpdC1yZWFjdC9odi11aWtpdC1yZWFjdC9wYWNrYWdlcy9jb3JlL3NyYy9wcm92aWRlcnMvUHJvdmlkZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZU1lbW8gfSBmcm9tIFwicmVhY3RcIjtcblxuaW1wb3J0IGNyZWF0ZUNhY2hlIGZyb20gXCJAZW1vdGlvbi9jYWNoZVwiO1xuaW1wb3J0IHtcbiAgY3NzIGFzIGNzc1JlYWN0LFxuICBHbG9iYWwsXG4gIENhY2hlUHJvdmlkZXIsXG4gIENsYXNzTmFtZXMsXG59IGZyb20gXCJAZW1vdGlvbi9yZWFjdFwiO1xuXG5pbXBvcnQge1xuICBDc3NCYXNlbGluZSxcbiAgQ3NzU2NvcGVkQmFzZWxpbmUsXG4gIGdldFRoZW1lc1ZhcnMsXG4gIEh2VGhlbWVTdHJ1Y3R1cmUsXG59IGZyb20gXCJAaGl0YWNoaXZhbnRhcmEvdWlraXQtc3R5bGVzXCI7XG5cbmltcG9ydCB7IGdldEVsZW1lbnRCeUlkIH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GhlbWVzTGlzdCl9XG4gICAgICAgIGB9XG4gICAgICAvPlxuICAgICAgPEh2VGhlbWVQcm92aWRlclxuICAgICAgICB0aGVtZXM9e3RoZW1lc0xpc3R9XG4gICAgICAgIHRoZW1lPXt0aGVtZSB8fCB0aGVtZXNMaXN0WzBdLm5hbWV9XG4gICAgICAgIGVtb3Rpb25DYWNoZT17ZW1vdGlvbkNhY2hlfVxuICAgICAgICBjb2xvck1vZGU9e2NvbG9yTW9kZSB8fCBPYmplY3Qua2V5cyh0aGVtZXNMaXN0WzBdLmNvbG9ycy5tb2RlcylbMF19XG4gICAgICAgIHRoZW1lUm9vdElkPXtcbiAgICAgICAgICBjc3NUaGVtZSA9PT0gXCJzY29wZWRcIiA/IHJvb3RFbGVtZW50SWQgfHwgc2NvcGVkUm9vdElkIDogdW5kZWZpbmVkXG4gICAgICAgIH1cbiAgICAgID5cbiAgICAgICAgPENsYXNzTmFtZXM+XG4gICAgICAgICAgeyh7IGNzcyB9KSA9PiB7XG4gICAgICAgICAgICBpZiAoY3NzQmFzZWxpbmUgPT09IFwic2NvcGVkXCIpIHtcbiAgICAgICAgICAgICAgY29uc3Qgcm9vdEVsZW1lbnQgPSBnZXRFbGVtZW50QnlJZChyb290RWxlbWVudElkKTtcblxuICAgICAgICAgICAgICBpZiAocm9vdEVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICByb290RWxlbWVudC5jbGFzc0xpc3QuYWRkKFxuICAgICAgICAgICAgICAgICAgY3NzKHtcbiAgICAgICAgICAgICAgICAgICAgW2BAbGF5ZXIgJHtyb290RWxlbWVudElkfS1iYXNlbGluZWBdOiB7XG4gICAgICAgICAgICAgICAgICAgICAgLi4uQ3NzU2NvcGVkQmFzZWxpbmUsXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIChjc3NUaGVtZSA9PT0gXCJzY29wZWRcIiB8fCBjc3NCYXNlbGluZSA9PT0gXCJzY29wZWRcIikgJiZcbiAgICAgICAgICAgICAgIXJvb3RFbGVtZW50SWQgPyAoXG4gICAgICAgICAgICAgIDxkaXZcbiAgICAgICAgICAgICAgICBpZD17c2NvcGVkUm9vdElkfVxuICAgICAgICAgICAgICAgIGNsYXNzTmFtZT17XG4gICAgICAgICAgICAgICAgICBjc3NCYXNlbGluZSA9PT0gXCJzY29wZWRcIlxuICAgICAgICAgICAgICAgICAgICA/IGNzcyh7XG4gICAgICAgICAgICAgICAgICAgICAgICBbYEBsYXllciAke3Jvb3RFbGVtZW50SWR9LWJhc2VsaW5lYF06IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uQ3NzU2NvcGVkQmFzZWxpbmUsXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICA+XG4gICAgICAgICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICAgICAgICA8L2Rpdj5cbiAgICAgICAgICAgICkgOiAoXG4gICAgICAgICAgICAgIGNoaWxkcmVuXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH19XG4gICAgICAgIDwvQ2xhc3NOYW1lcz5cbiAgICAgIDwvSHZUaGVtZVByb3ZpZGVyPlxuICAgIDwvQ2FjaGVQcm92aWRlcj5cbiAgKTtcbn07XG4iXX0= */") }),
|
|
30
34
|
/* @__PURE__ */ jsx(HvThemeProvider, { themes: themesList, theme: theme || themesList[0].name, emotionCache, colorMode: colorMode || Object.keys(themesList[0].colors.modes)[0], themeRootId: cssTheme === "scoped" ? rootElementId || scopedRootId : void 0, children: /* @__PURE__ */ jsx(ClassNames, { children: ({
|
|
31
35
|
css: css2
|
|
32
36
|
}) => {
|
|
@@ -34,12 +38,16 @@ const HvProvider = ({
|
|
|
34
38
|
const rootElement = getElementById(rootElementId);
|
|
35
39
|
if (rootElement) {
|
|
36
40
|
rootElement.classList.add(css2({
|
|
37
|
-
|
|
41
|
+
[`@layer ${rootElementId}-baseline`]: {
|
|
42
|
+
...CssScopedBaseline
|
|
43
|
+
}
|
|
38
44
|
}));
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
return (cssTheme === "scoped" || cssBaseline === "scoped") && !rootElementId ? /* @__PURE__ */ jsx("div", { id: scopedRootId, className: cssBaseline === "scoped" ? css2({
|
|
42
|
-
|
|
48
|
+
[`@layer ${rootElementId}-baseline`]: {
|
|
49
|
+
...CssScopedBaseline
|
|
50
|
+
}
|
|
43
51
|
}) : void 0, children }) : children;
|
|
44
52
|
} }) })
|
|
45
53
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\n\nimport createCache from \"@emotion/cache\";\nimport {\n css as cssReact,\n Global,\n CacheProvider,\n ClassNames,\n} from \"@emotion/react\";\n\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { getElementById } from \"@core/utils/document\";\nimport { processThemes } from \"@core/utils/theme\";\nimport { HvTheme } from \"@core/types/theme\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\n\nimport {\n HvThemeProvider,\n defaultCacheKey,\n defaultEmotionCache,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If no value is provided, the default is `hv`.\n */\n classNameKey?: string;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const scopedRootId = useUniqueId(undefined, scopedRootPrefix);\n\n // Themes\n const themesList: (HvTheme | HvThemeStructure)[] = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(\n () =>\n classNameKey === defaultCacheKey\n ? defaultEmotionCache\n : createCache({ key: classNameKey, prepend: true }),\n [classNameKey]\n );\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${cssBaseline === \"global\" && CssBaseline}\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n ...CssScopedBaseline,\n })\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({ ...CssScopedBaseline
|
|
1
|
+
{"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\n\nimport createCache from \"@emotion/cache\";\nimport {\n css as cssReact,\n Global,\n CacheProvider,\n ClassNames,\n} from \"@emotion/react\";\n\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { getElementById } from \"@core/utils/document\";\nimport { processThemes } from \"@core/utils/theme\";\nimport { HvTheme } from \"@core/types/theme\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\n\nimport {\n HvThemeProvider,\n defaultCacheKey,\n defaultEmotionCache,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If no value is provided, the default is `hv`.\n */\n classNameKey?: string;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const scopedRootId = useUniqueId(undefined, scopedRootPrefix);\n\n // Themes\n const themesList: (HvTheme | HvThemeStructure)[] = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(\n () =>\n classNameKey === defaultCacheKey\n ? defaultEmotionCache\n : createCache({ key: classNameKey, prepend: true }),\n [classNameKey]\n );\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${\n cssBaseline === \"global\" && {\n [`@layer hv-uikit-baseline`]: {\n ...CssBaseline,\n },\n }\n }\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n : undefined\n }\n >\n {children}\n </div>\n ) : (\n children\n );\n }}\n </ClassNames>\n </HvThemeProvider>\n </CacheProvider>\n );\n};\n"],"names":["scopedRootPrefix","HvProvider","children","rootElementId","cssBaseline","cssTheme","themes","theme","colorMode","classNameKey","defaultCacheKey","scopedRootId","useUniqueId","undefined","themesList","processThemes","emotionCache","useMemo","defaultEmotionCache","createCache","key","prepend","CssBaseline","getThemesVars","process","env","NODE_ENV","name","Object","keys","colors","modes","css","rootElement","getElementById","classList","add","CssScopedBaseline"],"mappings":";;;;;;;;;;AAkFA,MAAMA,mBAAmB;AAKlB,MAAMC,aAAaA,CAAC;AAAA,EACzBC;AAAAA,EACAC;AAAAA,EACAC,cAAc;AAAA,EACdC,WAAW;AAAA,EACXC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,eAAeC;AACA,MAAM;AACfC,QAAAA,eAAeC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AAAAA,QACL;AAAA,MACD,CAAA,IACDxB,QAGLX,SACH,CAAA,IAEAA;AAAAA,OAGN,EACF,CAAA;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { ds5 } from '@hitachivantara/uikit-styles';
|
|
|
33
33
|
import { EmblaOptionsType } from 'embla-carousel-react';
|
|
34
34
|
import { EmotionCache } from '@emotion/cache';
|
|
35
35
|
import { EmotionContext } from '@hitachivantara/uikit-react-shared';
|
|
36
|
+
import { FC } from 'react';
|
|
36
37
|
import { ForwardRefExoticComponent } from 'react';
|
|
37
38
|
import { GridProps } from '@mui/material';
|
|
38
39
|
import { Hooks } from 'react-table';
|
|
@@ -238,6 +239,11 @@ export declare const appSwitcherClasses: {
|
|
|
238
239
|
|
|
239
240
|
export declare type Arrayable<T> = T | T[];
|
|
240
241
|
|
|
242
|
+
declare interface AskAction {
|
|
243
|
+
actions: QueryAction[];
|
|
244
|
+
dialog: DialogLabels;
|
|
245
|
+
}
|
|
246
|
+
|
|
241
247
|
declare type AsProp<C extends React.ElementType> = {
|
|
242
248
|
component?: C;
|
|
243
249
|
};
|
|
@@ -4742,7 +4748,7 @@ export declare interface HvProviderProps {
|
|
|
4742
4748
|
}
|
|
4743
4749
|
|
|
4744
4750
|
/**
|
|
4745
|
-
*
|
|
4751
|
+
* This component allows you to create conditions and group them using logical operators.
|
|
4746
4752
|
* It outputs a structured set of rules which can be easily parsed to create SQL/NoSQL/whatever queries.
|
|
4747
4753
|
*/
|
|
4748
4754
|
export declare const HvQueryBuilder: (props: HvQueryBuilderProps) => JSX_2.Element;
|
|
@@ -4751,12 +4757,29 @@ export declare interface HvQueryBuilderAttribute extends Record<string, unknown>
|
|
|
4751
4757
|
id?: string;
|
|
4752
4758
|
label: string;
|
|
4753
4759
|
type: string;
|
|
4754
|
-
|
|
4755
|
-
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4762
|
+
declare interface HvQueryBuilderChangedQuery extends Omit<HvQueryBuilderQuery, "id" | "rules"> {
|
|
4763
|
+
rules: Array<Omit<HvQueryBuilderQueryRule, "id"> | Omit<HvQueryBuilderQueryGroup, "id">>;
|
|
4756
4764
|
}
|
|
4757
4765
|
|
|
4758
4766
|
export declare type HvQueryBuilderClasses = ExtractNames<typeof useClasses_114>;
|
|
4759
4767
|
|
|
4768
|
+
declare interface HvQueryBuilderContextValue {
|
|
4769
|
+
dispatchAction: React.Dispatch<QueryAction>;
|
|
4770
|
+
askAction: React.Dispatch<React.SetStateAction<AskAction | undefined>>;
|
|
4771
|
+
selectLocation?: React.Dispatch<unknown>;
|
|
4772
|
+
attributes?: Record<string, HvQueryBuilderAttribute>;
|
|
4773
|
+
operators: Record<string, HvQueryBuilderQueryOperator[]>;
|
|
4774
|
+
combinators: HvQueryBuilderQueryCombinator[];
|
|
4775
|
+
maxDepth: number;
|
|
4776
|
+
labels: HvQueryBuilderLabels;
|
|
4777
|
+
initialTouched: boolean;
|
|
4778
|
+
readOnly: boolean;
|
|
4779
|
+
disableConfirmation: boolean;
|
|
4780
|
+
renderers?: HvQueryBuilderRenderers;
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4760
4783
|
export declare interface HvQueryBuilderDateTimeRange {
|
|
4761
4784
|
start?: HvQueryBuilderDateTimeStrings;
|
|
4762
4785
|
end?: HvQueryBuilderDateTimeStrings;
|
|
@@ -5038,54 +5061,43 @@ export declare interface HvQueryBuilderNumericRange {
|
|
|
5038
5061
|
}
|
|
5039
5062
|
|
|
5040
5063
|
export declare interface HvQueryBuilderProps {
|
|
5064
|
+
/** The query attribute types. */
|
|
5041
5065
|
attributes?: Record<string, HvQueryBuilderAttribute>;
|
|
5042
|
-
/**
|
|
5043
|
-
* The query rules operators by attribute type and combinator.
|
|
5044
|
-
*/
|
|
5066
|
+
/** The query rules operators by attribute type and combinator. */
|
|
5045
5067
|
operators?: Record<string, HvQueryBuilderQueryOperator[]>;
|
|
5046
|
-
/**
|
|
5047
|
-
* The query combinators operands.
|
|
5048
|
-
*/
|
|
5068
|
+
/** The query combinators operands. */
|
|
5049
5069
|
combinators?: HvQueryBuilderQueryCombinator[];
|
|
5050
|
-
/**
|
|
5051
|
-
* The initial query representation.
|
|
5052
|
-
*/
|
|
5070
|
+
/** The initial query representation. */
|
|
5053
5071
|
query?: HvQueryBuilderQuery;
|
|
5054
|
-
/**
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
*/
|
|
5058
|
-
onChange?: (value: HvQueryBuilderQuery) => void;
|
|
5059
|
-
/**
|
|
5060
|
-
* Max depth of nested query groups.
|
|
5061
|
-
*/
|
|
5072
|
+
/** Callback fired when query changes. */
|
|
5073
|
+
onChange?: (value: HvQueryBuilderChangedQuery) => void;
|
|
5074
|
+
/** Max depth of nested query groups. */
|
|
5062
5075
|
maxDepth?: number;
|
|
5063
|
-
/**
|
|
5064
|
-
* An object containing all the labels.
|
|
5065
|
-
*/
|
|
5076
|
+
/** Object containing all the labels. */
|
|
5066
5077
|
labels?: HvQueryBuilderLabels;
|
|
5067
|
-
/**
|
|
5068
|
-
* A flag indicating if the Query Builder is in read only mode.
|
|
5069
|
-
*/
|
|
5078
|
+
/** Whether the query builder is in read-only mode. */
|
|
5070
5079
|
readOnly?: boolean;
|
|
5071
|
-
/**
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5080
|
+
/** Renderers for custom attribute types. */
|
|
5081
|
+
renderers?: HvQueryBuilderRenderers;
|
|
5082
|
+
/** Whether to opt-out of the confirmation dialogs shown before removing rules and rule groups. Default to `false`. */
|
|
5083
|
+
disableConfirmation?: boolean;
|
|
5084
|
+
/** A Jss Object used to override or extend the styles applied. */
|
|
5075
5085
|
classes?: HvQueryBuilderClasses;
|
|
5076
5086
|
}
|
|
5077
5087
|
|
|
5078
|
-
export declare
|
|
5079
|
-
id?: number;
|
|
5080
|
-
combinator: string;
|
|
5081
|
-
rules: Array<HvQueryBuilderQueryRule>;
|
|
5082
|
-
}
|
|
5088
|
+
export declare type HvQueryBuilderQuery = HvQueryBuilderQueryGroup;
|
|
5083
5089
|
|
|
5084
5090
|
export declare interface HvQueryBuilderQueryCombinator {
|
|
5085
5091
|
operand: string;
|
|
5086
5092
|
label: string;
|
|
5087
5093
|
}
|
|
5088
5094
|
|
|
5095
|
+
declare interface HvQueryBuilderQueryGroup {
|
|
5096
|
+
id: React.Key;
|
|
5097
|
+
combinator: string;
|
|
5098
|
+
rules: Array<HvQueryBuilderQueryRule | HvQueryBuilderQueryGroup>;
|
|
5099
|
+
}
|
|
5100
|
+
|
|
5089
5101
|
export declare interface HvQueryBuilderQueryOperator {
|
|
5090
5102
|
operator: string;
|
|
5091
5103
|
label: string;
|
|
@@ -5093,7 +5105,7 @@ export declare interface HvQueryBuilderQueryOperator {
|
|
|
5093
5105
|
}
|
|
5094
5106
|
|
|
5095
5107
|
export declare interface HvQueryBuilderQueryRule {
|
|
5096
|
-
id
|
|
5108
|
+
id: React.Key;
|
|
5097
5109
|
attribute?: string;
|
|
5098
5110
|
operator?: string;
|
|
5099
5111
|
value?: HvQueryBuilderQueryRuleValue;
|
|
@@ -5101,6 +5113,15 @@ export declare interface HvQueryBuilderQueryRule {
|
|
|
5101
5113
|
|
|
5102
5114
|
export declare type HvQueryBuilderQueryRuleValue = string | number | boolean | HvQueryBuilderNumericRange | HvQueryBuilderDateTimeStrings | HvQueryBuilderDateTimeRange;
|
|
5103
5115
|
|
|
5116
|
+
export declare interface HvQueryBuilderRendererProps<V = any> {
|
|
5117
|
+
id: React.Key;
|
|
5118
|
+
attribute: string;
|
|
5119
|
+
operator?: string;
|
|
5120
|
+
value?: V;
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5123
|
+
export declare type HvQueryBuilderRenderers = Record<string, FC<HvQueryBuilderRendererProps>>;
|
|
5124
|
+
|
|
5104
5125
|
/**
|
|
5105
5126
|
* A Radio Button is a mechanism that allows user to select just an option from a group of options.
|
|
5106
5127
|
*
|
|
@@ -7629,12 +7650,43 @@ export declare const progressBarClasses: {
|
|
|
7629
7650
|
|
|
7630
7651
|
declare type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);
|
|
7631
7652
|
|
|
7653
|
+
declare type QueryAction = {
|
|
7654
|
+
type: "reset-query";
|
|
7655
|
+
} | {
|
|
7656
|
+
type: "reset-group";
|
|
7657
|
+
id: React.Key;
|
|
7658
|
+
} | {
|
|
7659
|
+
type: "add-rule" | "add-group" | "remove-node";
|
|
7660
|
+
id: React.Key;
|
|
7661
|
+
} | {
|
|
7662
|
+
type: "set-combinator";
|
|
7663
|
+
id: React.Key;
|
|
7664
|
+
combinator: string;
|
|
7665
|
+
} | {
|
|
7666
|
+
type: "set-attribute";
|
|
7667
|
+
id: React.Key;
|
|
7668
|
+
attribute?: string | null;
|
|
7669
|
+
operator?: string | null;
|
|
7670
|
+
value?: HvQueryBuilderQueryRuleValue | null;
|
|
7671
|
+
} | {
|
|
7672
|
+
type: "set-operator";
|
|
7673
|
+
id: React.Key;
|
|
7674
|
+
operator: string | null;
|
|
7675
|
+
value?: HvQueryBuilderQueryRuleValue | null;
|
|
7676
|
+
} | {
|
|
7677
|
+
type: "set-value";
|
|
7678
|
+
id: React.Key;
|
|
7679
|
+
value: HvQueryBuilderQueryRuleValue | null | any;
|
|
7680
|
+
};
|
|
7681
|
+
|
|
7632
7682
|
export declare const queryBuilderClasses: {
|
|
7633
7683
|
root: "HvQueryBuilder-root";
|
|
7634
7684
|
topGroup: "HvQueryBuilder-topGroup";
|
|
7635
7685
|
subGroup: "HvQueryBuilder-subGroup";
|
|
7636
7686
|
subRulesContainer: "HvQueryBuilder-subRulesContainer";
|
|
7637
7687
|
topActionButtonContainer: "HvQueryBuilder-topActionButtonContainer";
|
|
7688
|
+
createConditionButton: "HvQueryBuilder-createConditionButton";
|
|
7689
|
+
createGroupButton: "HvQueryBuilder-createGroupButton";
|
|
7638
7690
|
removeButton: "HvQueryBuilder-removeButton";
|
|
7639
7691
|
combinator: "HvQueryBuilder-combinator";
|
|
7640
7692
|
topCombinator: "HvQueryBuilder-topCombinator";
|
|
@@ -8445,13 +8497,15 @@ declare const useClasses_113: (classesProp?: Partial<Record<"root", string>>, ad
|
|
|
8445
8497
|
cx: (...args: any) => string;
|
|
8446
8498
|
};
|
|
8447
8499
|
|
|
8448
|
-
declare const useClasses_114: (classesProp?: Partial<Record<"root" | "topGroup" | "subGroup" | "subRulesContainer" | "topActionButtonContainer" | "removeButton" | "combinator" | "topCombinator" | "combinatorButton" | "topRemoveButton" | "topRemoveButtonDisabled" | "rulesContainer" | "actionButtonContainer" | "topRulesContainer" | "buttonBackground", string>>, addStatic?: boolean) => {
|
|
8500
|
+
declare const useClasses_114: (classesProp?: Partial<Record<"root" | "topGroup" | "subGroup" | "subRulesContainer" | "topActionButtonContainer" | "createConditionButton" | "createGroupButton" | "removeButton" | "combinator" | "topCombinator" | "combinatorButton" | "topRemoveButton" | "topRemoveButtonDisabled" | "rulesContainer" | "actionButtonContainer" | "topRulesContainer" | "buttonBackground", string>>, addStatic?: boolean) => {
|
|
8449
8501
|
classes: {
|
|
8450
8502
|
root: string;
|
|
8451
8503
|
topGroup: string;
|
|
8452
8504
|
subGroup: string;
|
|
8453
8505
|
subRulesContainer: string;
|
|
8454
8506
|
topActionButtonContainer: string;
|
|
8507
|
+
createConditionButton: string;
|
|
8508
|
+
createGroupButton: string;
|
|
8455
8509
|
removeButton: string;
|
|
8456
8510
|
combinator: string;
|
|
8457
8511
|
topCombinator: string;
|
|
@@ -10594,6 +10648,8 @@ export declare type UsePaginationProps = (<D extends object = Record<string, unk
|
|
|
10594
10648
|
pluginName: string;
|
|
10595
10649
|
};
|
|
10596
10650
|
|
|
10651
|
+
export declare const useQueryBuilderContext: () => HvQueryBuilderContextValue;
|
|
10652
|
+
|
|
10597
10653
|
export declare type UseRowExpandProps = (<D extends object = Record<string, unknown>>(hooks: Hooks<D>) => void) & {
|
|
10598
10654
|
pluginName: string;
|
|
10599
10655
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.37.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@emotion/css": "^11.11.0",
|
|
34
34
|
"@emotion/serialize": "^1.1.2",
|
|
35
35
|
"@emotion/utils": "^1.2.1",
|
|
36
|
-
"@hitachivantara/uikit-react-icons": "^5.7.
|
|
37
|
-
"@hitachivantara/uikit-react-shared": "^5.1.
|
|
38
|
-
"@hitachivantara/uikit-styles": "^5.16.
|
|
36
|
+
"@hitachivantara/uikit-react-icons": "^5.7.6",
|
|
37
|
+
"@hitachivantara/uikit-react-shared": "^5.1.19",
|
|
38
|
+
"@hitachivantara/uikit-styles": "^5.16.3",
|
|
39
39
|
"@internationalized/date": "^3.2.0",
|
|
40
40
|
"@mui/base": "^5.0.0-beta.4",
|
|
41
41
|
"@popperjs/core": "^2.11.8",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public",
|
|
65
65
|
"directory": "package"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "ccae7457cd79b27e3c30bf3865f1fd1e2fbca56d",
|
|
68
68
|
"main": "dist/cjs/index.cjs",
|
|
69
69
|
"exports": {
|
|
70
70
|
".": {
|