@hitachivantara/uikit-react-core 5.64.0 → 5.64.2
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/MultiButton/MultiButton.cjs +6 -2
- package/dist/cjs/QueryBuilder/Context.cjs +6 -0
- package/dist/cjs/QueryBuilder/QueryBuilder.cjs +3 -1
- package/dist/cjs/Select/Select.cjs +4 -5
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +5 -4
- package/dist/cjs/hooks/useLabels.cjs +2 -1
- package/dist/cjs/utils/deepMerge.cjs +18 -0
- package/dist/esm/MultiButton/MultiButton.js +7 -3
- package/dist/esm/MultiButton/MultiButton.js.map +1 -1
- package/dist/esm/QueryBuilder/Context.js +6 -0
- package/dist/esm/QueryBuilder/Context.js.map +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js +4 -2
- package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/esm/QueryBuilder/types.js.map +1 -1
- package/dist/esm/Select/Select.js +4 -5
- package/dist/esm/Select/Select.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +5 -4
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
- package/dist/esm/hooks/useLabels.js +2 -1
- package/dist/esm/hooks/useLabels.js.map +1 -1
- package/dist/esm/utils/deepMerge.js +18 -0
- package/dist/esm/utils/deepMerge.js.map +1 -0
- package/dist/types/index.d.ts +37 -159
- package/package.json +2 -3
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const useDefaultProps = require("../hooks/useDefaultProps.cjs");
|
|
6
|
+
const setId = require("../utils/setId.cjs");
|
|
6
7
|
const MultiButton_styles = require("./MultiButton.styles.cjs");
|
|
7
8
|
const HvMultiButton = (props) => {
|
|
8
9
|
const {
|
|
10
|
+
id,
|
|
9
11
|
className,
|
|
10
12
|
children,
|
|
11
13
|
classes: classesProp,
|
|
@@ -35,6 +37,7 @@ const HvMultiButton = (props) => {
|
|
|
35
37
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
38
|
"div",
|
|
37
39
|
{
|
|
40
|
+
id,
|
|
38
41
|
className: cx(
|
|
39
42
|
classes.root,
|
|
40
43
|
{
|
|
@@ -50,7 +53,8 @@ const HvMultiButton = (props) => {
|
|
|
50
53
|
...others,
|
|
51
54
|
children: buttons.map((child, index) => {
|
|
52
55
|
const childIsSelected = !!child.props.selected;
|
|
53
|
-
|
|
56
|
+
const btnKey = setId.setId([id, index]);
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
54
58
|
React.cloneElement(child, {
|
|
55
59
|
variant,
|
|
56
60
|
disabled: disabled || child.props.disabled,
|
|
@@ -77,7 +81,7 @@ const HvMultiButton = (props) => {
|
|
|
77
81
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.split })
|
|
78
82
|
}
|
|
79
83
|
)
|
|
80
|
-
] });
|
|
84
|
+
] }, btnKey);
|
|
81
85
|
})
|
|
82
86
|
}
|
|
83
87
|
);
|
|
@@ -4,6 +4,7 @@ const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const useControlled = require("../hooks/useControlled.cjs");
|
|
6
6
|
const useDefaultProps = require("../hooks/useDefaultProps.cjs");
|
|
7
|
+
const useLabels = require("../hooks/useLabels.cjs");
|
|
7
8
|
const helpers = require("../utils/helpers.cjs");
|
|
8
9
|
const Context = require("./Context.cjs");
|
|
9
10
|
const QueryBuilder_styles = require("./QueryBuilder.styles.cjs");
|
|
@@ -24,7 +25,7 @@ const HvQueryBuilder = (props) => {
|
|
|
24
25
|
operators = Context.defaultOperators,
|
|
25
26
|
combinators = Context.defaultCombinators,
|
|
26
27
|
maxDepth = 1,
|
|
27
|
-
labels
|
|
28
|
+
labels: labelsProp,
|
|
28
29
|
readOnly = false,
|
|
29
30
|
emptyRenderer = ["Empty", "IsNotEmpty"],
|
|
30
31
|
classes: classesProp
|
|
@@ -45,6 +46,7 @@ const HvQueryBuilder = (props) => {
|
|
|
45
46
|
reducer.default,
|
|
46
47
|
index.setNodeIds(structuredClone(initialQuery.current))
|
|
47
48
|
);
|
|
49
|
+
const labels = useLabels.useLabels(Context.defaultLabels, labelsProp);
|
|
48
50
|
const contextValue = React.useMemo(
|
|
49
51
|
() => ({
|
|
50
52
|
dispatchAction,
|
|
@@ -162,13 +162,12 @@ const HvSelect = generic.fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
162
162
|
size,
|
|
163
163
|
variant,
|
|
164
164
|
"aria-label": ariaLabel,
|
|
165
|
-
"aria-labelledby": mergeIds(
|
|
165
|
+
"aria-labelledby": mergeIds(ariaLabelledBy, { [labelId]: label }),
|
|
166
166
|
"aria-invalid": isInvalid ? true : void 0,
|
|
167
167
|
"aria-errormessage": errorMessageId,
|
|
168
|
-
"aria-describedby": mergeIds(
|
|
169
|
-
description
|
|
170
|
-
|
|
171
|
-
),
|
|
168
|
+
"aria-describedby": mergeIds(ariaDescribedBy, {
|
|
169
|
+
[descriptionId]: description
|
|
170
|
+
}),
|
|
172
171
|
...getButtonProps(),
|
|
173
172
|
children: defaultRenderValue(actualValue) ?? placeholder
|
|
174
173
|
}
|
|
@@ -265,15 +265,16 @@ const HvVerticalNavigationTreeViewItem = React.forwardRef(
|
|
|
265
265
|
};
|
|
266
266
|
const hasChildren = !!children;
|
|
267
267
|
const showTooltip = !hasChildren && !isOpen && !disableTooltip;
|
|
268
|
+
const isLink = href !== void 0 && !disabled;
|
|
268
269
|
return /* @__PURE__ */ jsxRuntime.jsx(Tooltip.HvTooltip, { placement: "right", title: showTooltip && label, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
269
270
|
Typography.HvTypography,
|
|
270
271
|
{
|
|
271
272
|
id: setId.setId(id, "button"),
|
|
272
|
-
component:
|
|
273
|
-
...
|
|
273
|
+
component: isLink ? "a" : "div",
|
|
274
|
+
...isLink ? buttonLinkProps : null,
|
|
274
275
|
ref: contentRef,
|
|
275
276
|
className: cx(classes.content, {
|
|
276
|
-
[classes.link]:
|
|
277
|
+
[classes.link]: isLink,
|
|
277
278
|
[classes.minimized]: !isOpen
|
|
278
279
|
}),
|
|
279
280
|
variant: "body",
|
|
@@ -283,7 +284,7 @@ const HvVerticalNavigationTreeViewItem = React.forwardRef(
|
|
|
283
284
|
style: {
|
|
284
285
|
paddingLeft: (useIcons || !isOpen ? 0 : 10) + level * (collapsible ? 16 : 10)
|
|
285
286
|
},
|
|
286
|
-
role:
|
|
287
|
+
role: isLink ? void 0 : "button",
|
|
287
288
|
...treeviewMode ? {
|
|
288
289
|
tabIndex: -1,
|
|
289
290
|
onFocus: handleFocus
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
+
const deepMerge = require("../utils/deepMerge.cjs");
|
|
4
5
|
function useLabels(defaultLabels, labels) {
|
|
5
6
|
return React.useMemo(() => {
|
|
6
|
-
return
|
|
7
|
+
return deepMerge.deepMerge(defaultLabels, labels);
|
|
7
8
|
}, [defaultLabels, labels]);
|
|
8
9
|
}
|
|
9
10
|
exports.useLabels = useLabels;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
4
|
+
function merge(target, source) {
|
|
5
|
+
Object.keys(source || {}).forEach((key) => {
|
|
6
|
+
if (isObject(target[key]) && isObject(source?.[key])) {
|
|
7
|
+
merge(target[key], source?.[key]);
|
|
8
|
+
} else {
|
|
9
|
+
target[key] = source?.[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function deepMerge(target, source) {
|
|
14
|
+
const result = structuredClone(target);
|
|
15
|
+
merge(result, source);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.deepMerge = deepMerge;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx, jsxs
|
|
2
|
-
import { useMemo, Children, isValidElement, cloneElement } from "react";
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useMemo, Children, isValidElement, Fragment, cloneElement } from "react";
|
|
3
3
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
4
|
+
import { setId } from "../utils/setId.js";
|
|
4
5
|
import { useClasses, getSplitContainerColor, getSplitContainerHeight } from "./MultiButton.styles.js";
|
|
5
6
|
import { staticClasses } from "./MultiButton.styles.js";
|
|
6
7
|
const HvMultiButton = (props) => {
|
|
7
8
|
const {
|
|
9
|
+
id,
|
|
8
10
|
className,
|
|
9
11
|
children,
|
|
10
12
|
classes: classesProp,
|
|
@@ -34,6 +36,7 @@ const HvMultiButton = (props) => {
|
|
|
34
36
|
return /* @__PURE__ */ jsx(
|
|
35
37
|
"div",
|
|
36
38
|
{
|
|
39
|
+
id,
|
|
37
40
|
className: cx(
|
|
38
41
|
classes.root,
|
|
39
42
|
{
|
|
@@ -49,6 +52,7 @@ const HvMultiButton = (props) => {
|
|
|
49
52
|
...others,
|
|
50
53
|
children: buttons.map((child, index) => {
|
|
51
54
|
const childIsSelected = !!child.props.selected;
|
|
55
|
+
const btnKey = setId([id, index]);
|
|
52
56
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
57
|
cloneElement(child, {
|
|
54
58
|
variant,
|
|
@@ -76,7 +80,7 @@ const HvMultiButton = (props) => {
|
|
|
76
80
|
children: /* @__PURE__ */ jsx("div", { className: classes.split })
|
|
77
81
|
}
|
|
78
82
|
)
|
|
79
|
-
] });
|
|
83
|
+
] }, btnKey);
|
|
80
84
|
})
|
|
81
85
|
}
|
|
82
86
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiButton.js","sources":["../../../src/MultiButton/MultiButton.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n ReactElement,\n useMemo,\n} from \"react\";\n\nimport { HvButtonSize, HvButtonVariant } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport {\n getSplitContainerColor,\n getSplitContainerHeight,\n staticClasses,\n useClasses,\n} from \"./MultiButton.styles\";\n\nexport { staticClasses as multiButtonClasses };\nexport type HvMultiButtonClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvMultiButtonProps extends HvBaseProps {\n /** If all the buttons are disabled. */\n disabled?: boolean;\n /** If the MultiButton is to be displayed vertically. */\n vertical?: boolean;\n /** Category of button to use */\n variant?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvMultiButtonClasses;\n /** Button size. */\n size?: HvButtonSize;\n /** Add a split between buttons */\n split?: boolean;\n}\n\nexport const HvMultiButton = (props: HvMultiButtonProps) => {\n const {\n className,\n children,\n classes: classesProp,\n disabled = false,\n vertical = false,\n variant = \"secondarySubtle\",\n size,\n split,\n ...others\n } = useDefaultProps(\"HvMultiButton\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [color, type] = useMemo(() => {\n const result = variant.split(/(?=[A-Z])/);\n if (\n result[0] === \"ghost\" ||\n result[0] === \"semantic\" ||\n (result[0] === \"secondary\" && !result[1])\n )\n return [];\n return result.map((x) => x.toLowerCase());\n }, [variant]);\n\n // Filter children: remove invalid and undefined/null\n const buttons = useMemo(() => {\n const btns: ReactElement[] = [];\n Children.forEach(children, (child) => {\n if (child && isValidElement(child)) {\n btns.push(child);\n }\n });\n return btns;\n }, [children]);\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.multiple]: !split,\n [classes.vertical]: vertical,\n [classes[variant]]: variant, // TODO - remove in v6\n [classes.splitGroup]: split,\n [classes.splitGroupDisabled]: split && disabled,\n },\n className,\n )}\n {...others}\n >\n {buttons.map((child, index) => {\n const childIsSelected = !!child.props.selected;\n return (\n
|
|
1
|
+
{"version":3,"file":"MultiButton.js","sources":["../../../src/MultiButton/MultiButton.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n Fragment,\n isValidElement,\n ReactElement,\n useMemo,\n} from \"react\";\n\nimport { HvButtonSize, HvButtonVariant } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport {\n getSplitContainerColor,\n getSplitContainerHeight,\n staticClasses,\n useClasses,\n} from \"./MultiButton.styles\";\n\nexport { staticClasses as multiButtonClasses };\nexport type HvMultiButtonClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvMultiButtonProps extends HvBaseProps {\n /** If all the buttons are disabled. */\n disabled?: boolean;\n /** If the MultiButton is to be displayed vertically. */\n vertical?: boolean;\n /** Category of button to use */\n variant?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvMultiButtonClasses;\n /** Button size. */\n size?: HvButtonSize;\n /** Add a split between buttons */\n split?: boolean;\n}\n\nexport const HvMultiButton = (props: HvMultiButtonProps) => {\n const {\n id,\n className,\n children,\n classes: classesProp,\n disabled = false,\n vertical = false,\n variant = \"secondarySubtle\",\n size,\n split,\n ...others\n } = useDefaultProps(\"HvMultiButton\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [color, type] = useMemo(() => {\n const result = variant.split(/(?=[A-Z])/);\n if (\n result[0] === \"ghost\" ||\n result[0] === \"semantic\" ||\n (result[0] === \"secondary\" && !result[1])\n )\n return [];\n return result.map((x) => x.toLowerCase());\n }, [variant]);\n\n // Filter children: remove invalid and undefined/null\n const buttons = useMemo(() => {\n const btns: ReactElement[] = [];\n Children.forEach(children, (child) => {\n if (child && isValidElement(child)) {\n btns.push(child);\n }\n });\n return btns;\n }, [children]);\n\n return (\n <div\n id={id}\n className={cx(\n classes.root,\n {\n [classes.multiple]: !split,\n [classes.vertical]: vertical,\n [classes[variant]]: variant, // TODO - remove in v6\n [classes.splitGroup]: split,\n [classes.splitGroupDisabled]: split && disabled,\n },\n className,\n )}\n {...others}\n >\n {buttons.map((child, index) => {\n const childIsSelected = !!child.props.selected;\n const btnKey = setId([id, index]);\n return (\n <Fragment key={btnKey}>\n {cloneElement(child, {\n variant,\n disabled: disabled || child.props.disabled,\n size,\n className: cx(child.props.className, classes.button, {\n [classes.firstButton]: index === 0,\n [classes.lastButton]: index === buttons.length - 1,\n [classes.selected]: childIsSelected,\n }),\n })}\n {split && index < buttons.length - 1 && (\n <div\n className={cx(\n classes.splitContainer,\n color && css(getSplitContainerColor(color, type, disabled)),\n size && css(getSplitContainerHeight(size)),\n {\n [classes.splitDisabled]: disabled,\n },\n classes[variant], // TODO - remove in v6\n )}\n >\n <div className={classes.split} />\n </div>\n )}\n </Fragment>\n );\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAuCa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAC1C,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAEnD,QAAM,CAAC,OAAO,IAAI,IAAI,QAAQ,MAAM;AAC5B,UAAA,SAAS,QAAQ,MAAM,WAAW;AACxC,QACE,OAAO,CAAC,MAAM,WACd,OAAO,CAAC,MAAM,cACb,OAAO,CAAC,MAAM,eAAe,CAAC,OAAO,CAAC;AAEvC,aA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cACC,WAAW;AAAA,gBACT,QAAQ;AAAA,gBACR,SAAS,IAAI,uBAAuB,OAAO,MAAM,QAAQ,CAAC;AAAA,gBAC1D,QAAQ,IAAI,wBAAwB,IAAI,CAAC;AAAA,gBACzC;AAAA,kBACE,CAAC,QAAQ,aAAa,GAAG;AAAA,gBAC3B;AAAA,gBACA,QAAQ,OAAO;AAAA;AAAA,cACjB;AAAA,cAEA,UAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,OAAO;AAAA,YAAA;AAAA,UACjC;AAAA,QAAA,EAAA,GAxBW,MA0Bf;AAAA,MAAA,CAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sources":["../../../src/QueryBuilder/Context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderRenderers,\n QueryAction,\n} from \"./types\";\n\nexport const defaultOperators = {\n numeric: [\n {\n operator: \"greaterThan\",\n label: \"Greater than (>)\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThan\",\n label: \"Less than (<)\",\n combinators: [\"and\"],\n },\n {\n operator: \"equalsTo\",\n label: \"Equal to (=)\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"greaterThanEq\",\n label: \"Greater than or equal to (>=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThanEq\",\n label: \"Less than or equal to (<=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"notEqual\",\n label: \"Not equal to (!=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"range\",\n label: \"Range\",\n combinators: [\"and\"],\n },\n ],\n text: [\n {\n operator: \"equals\",\n label: \"Equals\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"equalsIgnoreCase\",\n label: \"Equals Ignore Case\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"Contains\",\n label: \"Contains\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"StartsWith\",\n label: \"A string begins with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"EndsWith\",\n label: \"A string ends with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"IsNotEmpty\",\n label: \"Is Not empty\",\n combinators: [\"and\"],\n },\n {\n operator: \"IsNot\",\n label: \"Is Not\",\n combinators: [\"and\"],\n },\n {\n operator: \"Empty\",\n label: \"Empty\",\n combinators: [\"and\"],\n },\n ],\n textarea: [\n {\n operator: \"equals\",\n label: \"Equals\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"equalsIgnoreCase\",\n label: \"Equals Ignore Case\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"Contains\",\n label: \"Contains\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"StartsWith\",\n label: \"A string begins with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"EndsWith\",\n label: \"A string ends with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"IsNotEmpty\",\n label: \"Is Not empty\",\n combinators: [\"and\"],\n },\n {\n operator: \"IsNot\",\n label: \"Is Not\",\n combinators: [\"and\"],\n },\n {\n operator: \"Empty\",\n label: \"Empty\",\n combinators: [\"and\"],\n },\n ],\n boolean: [\n {\n operator: \"equalsTo\",\n label: \"=\",\n combinators: [\"and\", \"or\"],\n },\n ],\n dateandtime: [\n {\n operator: \"greaterThan\",\n label: \"Greater than\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThan\",\n label: \"Less than\",\n combinators: [\"and\"],\n },\n {\n operator: \"equalsTo\",\n label: \"Equal to\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"greaterThanEq\",\n label: \"Greater than or equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThanEq\",\n label: \"Less than or equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"notEqual\",\n label: \"Not equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"range\",\n label: \"Range\",\n combinators: [\"and\"],\n },\n ],\n};\n\nexport const defaultCombinators = [\n { operand: \"and\", label: \"AND\" },\n { operand: \"or\", label: \"OR\" },\n];\n\nexport const defaultLabels = {\n query: {\n delete: {\n ariaLabel: \"Reset query\",\n tooltip: \"Reset query\",\n dialogTitle: \"Remove all conditions?\",\n dialogMessage:\n \"Are you sure you want to remove all the conditions? They will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n },\n rule: {\n attribute: {\n label: \"Attribute\",\n placeholder: \"Select attribute...\",\n exists: \"Attribute already exists.\",\n },\n operator: {\n label: \"Operator\",\n placeholder: \"Select operator...\",\n },\n value: {\n distance: {\n label: \"Value\",\n connectorText: \"radius miles from\",\n button: \"Select location\",\n validation: {\n required: \"The value is required.\",\n invalid: \"Value must be a positive number.\",\n },\n },\n text: {\n label: \"Value\",\n placeholder: \"Enter value...\",\n validation: {\n required: \"The value is required.\",\n },\n },\n boolean: {\n label: \"Value\",\n placeholder: \"Enter value\",\n options: {\n true: \"True\",\n false: \"False\",\n },\n },\n numeric: {\n label: \"Value\",\n placeholder: \"Enter value\",\n validation: {\n required: \"The value is required.\",\n invalid: \"Value must be a number.\",\n equal: \"Cannot be equal.\",\n greaterThan: \"Needs to be greater.\",\n },\n range: {\n leftLabel: \"From\",\n rightLabel: \"To\",\n },\n },\n datetime: {\n dateLabel: \"Date\",\n datePlaceholder: \"Select Date\",\n timeLabel: \"Time\",\n timePlaceholder: \"Select Time\",\n startDateLabel: \"Start Date\",\n startDatePlaceholder: \"Select Start Date\",\n startTimeLabel: \"Start Time\",\n startTimePlaceholder: \"Select Start Time\",\n endDateLabel: \"End Date\",\n endDatePlaceholder: \"Select End Date\",\n endTimeLabel: \"End Time\",\n endTimePlaceholder: \"Select End Time\",\n validation: {\n required: \"The value is required.\",\n invalidInterval:\n \"End date and time must be after start date and time.\",\n },\n },\n },\n delete: {\n ariaLabel: \"Remove condition\",\n tooltip: \"Remove condition\",\n dialogTitle: \"Remove condition?\",\n dialogMessage:\n \"Are you sure you want to remove the condition? It will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n },\n group: {\n delete: {\n ariaLabel: \"Remove group\",\n tooltip: \"Remove group\",\n dialogTitle: \"Remove group?\",\n dialogMessage:\n \"Are you sure you want to remove the group? It will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n reset: {\n ariaLabel: \"Change operator\",\n tooltip: \"Change operator query\",\n dialogTitle: \"Change conditional operator?\",\n dialogMessage:\n \"Do you want to change conditional operator? You won't be able to undo this operation. Conditions and/or groups will be removed.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n addRule: {\n label: \"Add condition\",\n },\n addGroup: {\n label: \"Add group\",\n },\n },\n empty: {\n title: \"No conditions created yet\",\n createCondition: \"Create a condition\",\n createGroup: \"condition group\",\n spacer: \" or a \",\n },\n};\n\nexport interface HvQueryBuilderContextValue {\n dispatchAction: React.Dispatch<QueryAction>;\n askAction: React.Dispatch<React.SetStateAction<AskAction | undefined>>;\n selectLocation?: React.Dispatch<unknown>; // TODO - remove in v6 (not used)\n attributes?: Record<string, HvQueryBuilderAttribute>;\n operators: Record<string, HvQueryBuilderQueryOperator[]>;\n combinators: HvQueryBuilderQueryCombinator[];\n maxDepth: number;\n labels: HvQueryBuilderLabels;\n initialTouched: boolean;\n readOnly: boolean;\n disableConfirmation: boolean;\n renderers?: HvQueryBuilderRenderers;\n emptyRenderer?: string[];\n}\n\nexport const HvQueryBuilderContext = createContext<HvQueryBuilderContextValue>({\n dispatchAction: () => ({}),\n askAction: () => ({}),\n selectLocation: () => ({}), // TODO - remove in v6 (not used)\n attributes: {},\n operators: defaultOperators,\n combinators: defaultCombinators,\n maxDepth: 1,\n labels: defaultLabels,\n initialTouched: false,\n disableConfirmation: false,\n readOnly: false,\n});\n\nexport interface HvQueryBuilderProviderProps {\n value: HvQueryBuilderContextValue;\n children: React.ReactNode;\n}\n\nexport const HvQueryBuilderProvider = ({\n children,\n value,\n}: HvQueryBuilderProviderProps) => {\n return (\n <HvQueryBuilderContext.Provider value={value}>\n {children}\n </HvQueryBuilderContext.Provider>\n );\n};\n\nexport const useQueryBuilderContext = () => {\n return useContext(HvQueryBuilderContext);\n};\n"],"names":[],"mappings":";;AAYO,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,IACP;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,OAAO,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,OAAO,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,OAAO,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,MACE,UAAU;AAAA,M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,eAAe;AAAA,MACf,cAAc;AAAA,MACd,oBAAoB;AAAA,IACtB;AAAA,IACA,OAAO;AAAA,MACL,WAAW;AAAA,MACX,SAAS;AAAA,MACT,aAAa;AAAA,MACb,eACE;AAAA,MACF,eAAe;AAAA,MACf,cAAc;AAAA,MACd,oBAAoB;AAAA,IACtB;AAAA,IACA,SAAS;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA,UAAU;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AACF;AAkBO,MAAM,wBAAwB,cAA0C;AAAA,EAC7E,gBAAgB,OAAO,CAAA;AAAA,EACvB,WAAW,OAAO,CAAA;AAAA,EAClB,gBAAgB,OAAO,CAAA;AAAA;AAAA,EACvB,YAAY,CAAC;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AAAA,EACb,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,UAAU;AACZ,CAAC;AAOM,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AACF,MAAmC;AACjC,SACG,oBAAA,sBAAsB,UAAtB,EAA+B,OAC7B,SACH,CAAA;AAEJ;AAEO,MAAM,yBAAyB,MAAM;AAC1C,SAAO,WAAW,qBAAqB;AACzC;"}
|
|
1
|
+
{"version":3,"file":"Context.js","sources":["../../../src/QueryBuilder/Context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderRenderers,\n QueryAction,\n} from \"./types\";\n\nexport const defaultOperators = {\n numeric: [\n {\n operator: \"greaterThan\",\n label: \"Greater than (>)\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThan\",\n label: \"Less than (<)\",\n combinators: [\"and\"],\n },\n {\n operator: \"equalsTo\",\n label: \"Equal to (=)\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"greaterThanEq\",\n label: \"Greater than or equal to (>=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThanEq\",\n label: \"Less than or equal to (<=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"notEqual\",\n label: \"Not equal to (!=)\",\n combinators: [\"and\"],\n },\n {\n operator: \"range\",\n label: \"Range\",\n combinators: [\"and\"],\n },\n ],\n text: [\n {\n operator: \"equals\",\n label: \"Equals\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"equalsIgnoreCase\",\n label: \"Equals Ignore Case\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"Contains\",\n label: \"Contains\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"StartsWith\",\n label: \"A string begins with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"EndsWith\",\n label: \"A string ends with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"IsNotEmpty\",\n label: \"Is Not empty\",\n combinators: [\"and\"],\n },\n {\n operator: \"IsNot\",\n label: \"Is Not\",\n combinators: [\"and\"],\n },\n {\n operator: \"Empty\",\n label: \"Empty\",\n combinators: [\"and\"],\n },\n ],\n textarea: [\n {\n operator: \"equals\",\n label: \"Equals\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"equalsIgnoreCase\",\n label: \"Equals Ignore Case\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"Contains\",\n label: \"Contains\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"StartsWith\",\n label: \"A string begins with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"EndsWith\",\n label: \"A string ends with\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"IsNotEmpty\",\n label: \"Is Not empty\",\n combinators: [\"and\"],\n },\n {\n operator: \"IsNot\",\n label: \"Is Not\",\n combinators: [\"and\"],\n },\n {\n operator: \"Empty\",\n label: \"Empty\",\n combinators: [\"and\"],\n },\n ],\n boolean: [\n {\n operator: \"equalsTo\",\n label: \"=\",\n combinators: [\"and\", \"or\"],\n },\n ],\n dateandtime: [\n {\n operator: \"greaterThan\",\n label: \"Greater than\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThan\",\n label: \"Less than\",\n combinators: [\"and\"],\n },\n {\n operator: \"equalsTo\",\n label: \"Equal to\",\n combinators: [\"and\", \"or\"],\n },\n {\n operator: \"greaterThanEq\",\n label: \"Greater than or equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"lessThanEq\",\n label: \"Less than or equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"notEqual\",\n label: \"Not equal to\",\n combinators: [\"and\"],\n },\n {\n operator: \"range\",\n label: \"Range\",\n combinators: [\"and\"],\n },\n ],\n};\n\nexport const defaultCombinators = [\n { operand: \"and\", label: \"AND\" },\n { operand: \"or\", label: \"OR\" },\n];\n\nexport const defaultLabels: HvQueryBuilderLabels = {\n query: {\n delete: {\n ariaLabel: \"Reset query\",\n tooltip: \"Reset query\",\n dialogTitle: \"Remove all conditions?\",\n dialogMessage:\n \"Are you sure you want to remove all the conditions? They will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n addRule: {\n label: \"Add condition\",\n },\n addGroup: {\n label: \"Add group\",\n },\n },\n rule: {\n attribute: {\n label: \"Attribute\",\n placeholder: \"Select attribute...\",\n exists: \"Attribute already exists.\",\n },\n operator: {\n label: \"Operator\",\n placeholder: \"Select operator...\",\n },\n value: {\n distance: {\n label: \"Value\",\n connectorText: \"radius miles from\",\n button: \"Select location\",\n validation: {\n required: \"The value is required.\",\n invalid: \"Value must be a positive number.\",\n },\n },\n text: {\n label: \"Value\",\n placeholder: \"Enter value...\",\n validation: {\n required: \"The value is required.\",\n },\n },\n boolean: {\n label: \"Value\",\n placeholder: \"Enter value\",\n options: {\n true: \"True\",\n false: \"False\",\n },\n },\n numeric: {\n label: \"Value\",\n placeholder: \"Enter value\",\n validation: {\n required: \"The value is required.\",\n invalid: \"Value must be a number.\",\n equal: \"Cannot be equal.\",\n greaterThan: \"Needs to be greater.\",\n },\n range: {\n leftLabel: \"From\",\n rightLabel: \"To\",\n },\n },\n datetime: {\n dateLabel: \"Date\",\n datePlaceholder: \"Select Date\",\n timeLabel: \"Time\",\n timePlaceholder: \"Select Time\",\n startDateLabel: \"Start Date\",\n startDatePlaceholder: \"Select Start Date\",\n startTimeLabel: \"Start Time\",\n startTimePlaceholder: \"Select Start Time\",\n endDateLabel: \"End Date\",\n endDatePlaceholder: \"Select End Date\",\n endTimeLabel: \"End Time\",\n endTimePlaceholder: \"Select End Time\",\n validation: {\n required: \"The value is required.\",\n invalidInterval:\n \"End date and time must be after start date and time.\",\n },\n },\n },\n delete: {\n ariaLabel: \"Remove condition\",\n tooltip: \"Remove condition\",\n dialogTitle: \"Remove condition?\",\n dialogMessage:\n \"Are you sure you want to remove the condition? It will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n },\n group: {\n delete: {\n ariaLabel: \"Remove group\",\n tooltip: \"Remove group\",\n dialogTitle: \"Remove group?\",\n dialogMessage:\n \"Are you sure you want to remove the group? It will be removed permanently.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n reset: {\n ariaLabel: \"Change operator\",\n tooltip: \"Change operator query\",\n dialogTitle: \"Change conditional operator?\",\n dialogMessage:\n \"Do you want to change conditional operator? You won't be able to undo this operation. Conditions and/or groups will be removed.\",\n dialogConfirm: \"Yes\",\n dialogCancel: \"No\",\n dialogCloseTooltip: \"Close\",\n },\n addRule: {\n label: \"Add condition\",\n },\n addGroup: {\n label: \"Add group\",\n },\n },\n empty: {\n title: \"No conditions created yet\",\n createCondition: \"Create a condition\",\n createGroup: \"condition group\",\n spacer: \" or a \",\n },\n};\n\nexport interface HvQueryBuilderContextValue {\n dispatchAction: React.Dispatch<QueryAction>;\n askAction: React.Dispatch<React.SetStateAction<AskAction | undefined>>;\n selectLocation?: React.Dispatch<unknown>; // TODO - remove in v6 (not used)\n attributes?: Record<string, HvQueryBuilderAttribute>;\n operators: Record<string, HvQueryBuilderQueryOperator[]>;\n combinators: HvQueryBuilderQueryCombinator[];\n maxDepth: number;\n labels: HvQueryBuilderLabels;\n initialTouched: boolean;\n readOnly: boolean;\n disableConfirmation: boolean;\n renderers?: HvQueryBuilderRenderers;\n emptyRenderer?: string[];\n}\n\nexport const HvQueryBuilderContext = createContext<HvQueryBuilderContextValue>({\n dispatchAction: () => ({}),\n askAction: () => ({}),\n selectLocation: () => ({}), // TODO - remove in v6 (not used)\n attributes: {},\n operators: defaultOperators,\n combinators: defaultCombinators,\n maxDepth: 1,\n labels: defaultLabels,\n initialTouched: false,\n disableConfirmation: false,\n readOnly: false,\n});\n\nexport interface HvQueryBuilderProviderProps {\n value: HvQueryBuilderContextValue;\n children: React.ReactNode;\n}\n\nexport const HvQueryBuilderProvider = ({\n children,\n value,\n}: HvQueryBuilderProviderProps) => {\n return (\n <HvQueryBuilderContext.Provider value={value}>\n {children}\n </HvQueryBuilderContext.Provider>\n );\n};\n\nexport const useQueryBuilderContext = () => {\n return useContext(HvQueryBuilderContext);\n};\n"],"names":[],"mappings":";;AAYO,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,IACP;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,KAAK;AAAA,IACrB;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,CAAC,OAAO,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,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AAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,UAAU;AACZ,CAAC;AAOM,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AACF,MAAmC;AACjC,SACG,oBAAA,sBAAsB,UAAtB,EAA+B,OAC7B,SACH,CAAA;AAEJ;AAEO,MAAM,yBAAyB,MAAM;AAC1C,SAAO,WAAW,qBAAqB;AACzC;"}
|
|
@@ -2,8 +2,9 @@ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { useRef, useState, useReducer, useMemo, useEffect } from "react";
|
|
3
3
|
import { useControlled } from "../hooks/useControlled.js";
|
|
4
4
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
5
|
+
import { useLabels } from "../hooks/useLabels.js";
|
|
5
6
|
import { isEqual } from "../utils/helpers.js";
|
|
6
|
-
import { HvQueryBuilderProvider, defaultOperators, defaultCombinators
|
|
7
|
+
import { defaultLabels, HvQueryBuilderProvider, defaultOperators, defaultCombinators } from "./Context.js";
|
|
7
8
|
import { useClasses } from "./QueryBuilder.styles.js";
|
|
8
9
|
import { staticClasses } from "./QueryBuilder.styles.js";
|
|
9
10
|
import { emptyGroup, setNodeIds, clearNodeIds } from "./utils/index.js";
|
|
@@ -23,7 +24,7 @@ const HvQueryBuilder = (props) => {
|
|
|
23
24
|
operators = defaultOperators,
|
|
24
25
|
combinators = defaultCombinators,
|
|
25
26
|
maxDepth = 1,
|
|
26
|
-
labels
|
|
27
|
+
labels: labelsProp,
|
|
27
28
|
readOnly = false,
|
|
28
29
|
emptyRenderer = ["Empty", "IsNotEmpty"],
|
|
29
30
|
classes: classesProp
|
|
@@ -44,6 +45,7 @@ const HvQueryBuilder = (props) => {
|
|
|
44
45
|
reducer,
|
|
45
46
|
setNodeIds(structuredClone(initialQuery.current))
|
|
46
47
|
);
|
|
48
|
+
const labels = useLabels(defaultLabels, labelsProp);
|
|
47
49
|
const contextValue = useMemo(
|
|
48
50
|
() => ({
|
|
49
51
|
dispatchAction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sources":["../../../src/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import { useEffect, useMemo, useReducer, useRef, useState } from \"react\";\n\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { isEqual } from \"../utils/helpers\";\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport {\n defaultCombinators,\n defaultLabels,\n defaultOperators,\n HvQueryBuilderProvider,\n} from \"./Context\";\nimport { staticClasses, useClasses } from \"./QueryBuilder.styles\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n defaultRendererKey,\n HvQueryBuilderAttribute,\n HvQueryBuilderLabels,\n HvQueryBuilderQuery,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderRenderers,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup, setNodeIds } from \"./utils\";\nimport reducer from \"./utils/reducer\";\n\nexport { staticClasses as queryBuilderClasses };\n\nexport type HvQueryBuilderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvQueryBuilderProps {\n /** The query attribute types. */\n attributes?: Record<string, HvQueryBuilderAttribute>;\n /** The query rules operators by attribute type and combinator. */\n operators?: Record<string, HvQueryBuilderQueryOperator[]>;\n /** The query combinators operands. */\n combinators?: HvQueryBuilderQueryCombinator[];\n /** The query when the component is controlled. */\n value?: HvQueryBuilderQuery;\n /** The initial query when the component is uncontrolled. */\n defaultValue?: HvQueryBuilderQuery;\n /**\n * The initial query when the component is uncontrolled.\n *\n * @deprecated Use `defaultValue` instead.\n * */\n query?: HvQueryBuilderQuery; // TODO - remove in v6\n /** Callback fired when the query changes. */\n onChange?: (value: HvQueryBuilderQuery) => void;\n /** Max depth of nested query groups. */\n maxDepth?: number;\n /** Object containing all the labels. */\n labels?: HvQueryBuilderLabels;\n /** Whether the query builder is in read-only mode. */\n readOnly?: boolean;\n /**\n * Operators that should use the empty value renderer when selected.\n *\n * When one of the listed operators is selected, the rule value is reset and an empty component is rendered.\n * This property takes priority over `renderers`.\n *\n * @default [\"Empty\", \"IsNotEmpty\"]\n * */\n emptyRenderer?: string[];\n /** Custom renderers for the rules' value. */\n renderers?: HvQueryBuilderRenderers;\n /** Whether to opt-out of the confirmation dialogs shown before removing rules and rule groups. @default false. */\n disableConfirmation?: boolean;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvQueryBuilderClasses;\n}\n\n// TODO - v6\n// - \"range\", \"Empty\", and \"IsNotEmpty\" operators with internal/built-in logic\n\n// Notes:\n// Deep clone is needed throughout the component to avoid undesired mutations in props, state, and ref values\n\n/**\n * This component allows you to create conditions and group them using logical operators.\n * It outputs a structured set of rules which can be easily parsed to create SQL/NoSQL/whatever queries.\n *\n * Take a look at the [usage page](https://lumada-design.github.io/uikit/master/?path=/docs/widgets-query-builder-usage--docs) to learn more about this component.\n */\nexport const HvQueryBuilder = (props: HvQueryBuilderProps) => {\n const {\n attributes,\n renderers,\n query: queryProp, // TODO - remove in v6\n value,\n defaultValue,\n onChange,\n disableConfirmation = false,\n operators = defaultOperators,\n combinators = defaultCombinators,\n maxDepth = 1,\n labels = defaultLabels,\n readOnly = false,\n emptyRenderer = [\"Empty\", \"IsNotEmpty\"],\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilder\", props);\n\n if (\n import.meta.env.DEV &&\n [\n Object.values(attributes || {}).map(({ type }) => type),\n Object.values(operators || {})\n .map((ops) => ops.map(({ operator }) => operator))\n .flat(),\n ]\n .flat()\n ?.find((key) => key === defaultRendererKey)\n ) {\n // eslint-disable-next-line no-console\n console.error(\n `${defaultRendererKey} is a restricted key and shouldn't be used as an attribute or operator type. Update the key to avoid unexpected behaviors.`,\n );\n }\n\n const { classes } = useClasses(classesProp);\n\n const currentAttributes = useRef<HvQueryBuilderProps[\"attributes\"] | null>(\n null,\n );\n\n const controlled = useRef(value != null);\n const initialQuery = useRef(\n value ?? defaultValue ?? queryProp ?? emptyGroup(),\n );\n const [query, setQuery] = useControlled(value, initialQuery.current);\n const prevQuery = useRef(query);\n\n const [pendingAction, setPendingAction] = useState<AskAction>();\n const [initialState, setInitialState] = useState(true);\n\n const [state, dispatchAction] = useReducer(\n reducer,\n setNodeIds(structuredClone(initialQuery.current)),\n );\n\n const contextValue = useMemo(\n () => ({\n dispatchAction,\n askAction: setPendingAction,\n attributes,\n operators,\n combinators,\n maxDepth,\n labels,\n initialTouched: initialState,\n readOnly,\n renderers,\n disableConfirmation,\n emptyRenderer,\n }),\n [\n attributes,\n operators,\n combinators,\n maxDepth,\n labels,\n readOnly,\n initialState,\n renderers,\n disableConfirmation,\n emptyRenderer,\n ],\n );\n\n // Keep track of attributes\n useEffect(() => {\n if (currentAttributes.current == null) {\n // First run, nothing to do\n currentAttributes.current = attributes;\n } else if (currentAttributes.current !== attributes) {\n // Attributes changed. The existing query is almost certainly invalid, so reset it\n currentAttributes.current = attributes;\n dispatchAction({ type: \"reset-query\" });\n }\n }, [attributes]);\n\n useEffect(() => {\n // \"value\" prop was updated by user (when controlled)\n if (!isEqual(prevQuery.current, query)) {\n dispatchAction({\n type: \"set-query\",\n query: setNodeIds(structuredClone(query), state),\n });\n prevQuery.current = query;\n } else if (\n !isEqual(\n clearNodeIds(structuredClone(state)),\n clearNodeIds(structuredClone(query)),\n )\n ) {\n setInitialState(false);\n\n // TODO - remove \"true\" from clearNodeIds in v6 (only keep else statement)\n // To avoid breaking changes, clearNodeIds will delete all ids provided by the user when uncontrolled\n // In the future if the user provides ids, it doesn't make sense to remove them with onChange\n if (!controlled.current) {\n onChange?.(\n clearNodeIds(structuredClone(state), true) as HvQueryBuilderQuery,\n );\n } else {\n // When controlled, the ids provided by the user are not removed. Only the auto generated ones.\n onChange?.(clearNodeIds(structuredClone(state)) as HvQueryBuilderQuery);\n }\n\n prevQuery.current = state;\n // This will only run if uncontrolled\n setQuery(state);\n }\n }, [onChange, query, setQuery, state]);\n\n const handleConfirm = () => {\n if (pendingAction) {\n setPendingAction(undefined);\n pendingAction.actions.forEach((action) => dispatchAction(action));\n }\n };\n\n const handleCancel = () => {\n setPendingAction(undefined);\n };\n\n return (\n <HvQueryBuilderProvider value={contextValue}>\n <RuleGroup\n level={0}\n id={state.id}\n combinator={state.combinator}\n rules={state.rules}\n classes={classes}\n />\n <ConfirmationDialog\n isOpen={pendingAction != null}\n onConfirm={handleConfirm}\n onCancel={handleCancel}\n title={pendingAction?.dialog.dialogTitle}\n message={pendingAction?.dialog.dialogMessage}\n confirmButtonLabel={pendingAction?.dialog.dialogConfirm}\n cancelButtonLabel={pendingAction?.dialog.dialogCancel}\n closeButtonTooltip={pendingAction?.dialog.dialogCloseTooltip}\n />\n </HvQueryBuilderProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAsFa,MAAA,iBAAiB,CAAC,UAA+B;AACtD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,WAAW;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,IACX,gBAAgB,CAAC,SAAS,YAAY;AAAA,IACtC,SAAS;AAAA,EAAA,IACP,gBAAgB,kBAAkB,KAAK;AAcjC,UACe,QAAA,IAAA,WAAA,WAAA;AACvB,QAAA,oBAAA;AAAA,IACF;AAAA,EAEA;AAEA,QAAM,aAAoB,OAAA,SAAA,IAAA;AACxB,QAAA,eAAA;AAAA,IACF,SAAA,gBAAA,aAAA,WAAA;AAAA,EAEA;AACA,QAAM,CAAe,OAAA,QAAA,IAAA,cAAA,OAAA,aAAA,OAAA;AACnB,QAAA,YAAyB,OAAA,KAAA;AAC3B,QAAA,CAAA,eAAA,gBAAA,IAAA,SAAA;AACA,QAAM,CAAC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,UAAA,KAAA,CAAA;AAEpB,QAAA,gBAAc,MAAA;AAChB,QAAA,eAAA;AACE,uBAAiB,MAAA;AAErB,4BAA4B,QAAA,CAAA,WAAA,eAAA,MAAA,CAAA;AAAA,IAC1B;AAAA,EACE;AACA,QAAA,qBAA8B;AAChC,qBAAA,MAAA;AAAA,EAAA;AAGF,SAA2B,qBAAA,wBAAA,EAAA,OAAA,cAAA,UAAA;AAAA,IACzB;AAAA,MACF;AAAA,MAGE;AAAA,QACE,OAAA;AAAA,QAAC,IAAA,MAAA;AAAA,QAAA,YAAA,MAAA;AAAA,QACC,OAAO,MAAA;AAAA,QACP;AAAA,MAAU;AAAA,IACQ;AAAA,IAElB;AAAA,MAAA;AAAA,MACF;AAAA,QACA,QAAA,iBAAA;AAAA,QAAC,WAAA;AAAA,QAAA,UAAA;AAAA,QACC,sBAAyB,OAAA;AAAA,QACzB,SAAW,eAAA,OAAA;AAAA,QACX,oBAAU,eAAA,OAAA;AAAA,QACV,kCAA6B,OAAA;AAAA,QAC7B,mCAA+B,OAAA;AAAA,MAC/B;AAAA,IACA;AAAA,EACA,EAAA,CAAA;AAA0C;"}
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sources":["../../../src/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import { useEffect, useMemo, useReducer, useRef, useState } from \"react\";\n\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { DeepPartial } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { isEqual } from \"../utils/helpers\";\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport {\n defaultCombinators,\n defaultLabels,\n defaultOperators,\n HvQueryBuilderProvider,\n} from \"./Context\";\nimport { staticClasses, useClasses } from \"./QueryBuilder.styles\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n defaultRendererKey,\n HvQueryBuilderAttribute,\n HvQueryBuilderLabels,\n HvQueryBuilderQuery,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderRenderers,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup, setNodeIds } from \"./utils\";\nimport reducer from \"./utils/reducer\";\n\nexport { staticClasses as queryBuilderClasses };\n\nexport type HvQueryBuilderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvQueryBuilderProps {\n /** The query attribute types. */\n attributes?: Record<string, HvQueryBuilderAttribute>;\n /** The query rules operators by attribute type and combinator. */\n operators?: Record<string, HvQueryBuilderQueryOperator[]>;\n /** The query combinators operands. */\n combinators?: HvQueryBuilderQueryCombinator[];\n /** The query when the component is controlled. */\n value?: HvQueryBuilderQuery;\n /** The initial query when the component is uncontrolled. */\n defaultValue?: HvQueryBuilderQuery;\n /**\n * The initial query when the component is uncontrolled.\n *\n * @deprecated Use `defaultValue` instead.\n * */\n query?: HvQueryBuilderQuery; // TODO - remove in v6\n /** Callback fired when the query changes. */\n onChange?: (value: HvQueryBuilderQuery) => void;\n /** Max depth of nested query groups. */\n maxDepth?: number;\n /** Object containing all the labels. */\n labels?: DeepPartial<HvQueryBuilderLabels>;\n /** Whether the query builder is in read-only mode. */\n readOnly?: boolean;\n /**\n * Operators that should use the empty value renderer when selected.\n *\n * When one of the listed operators is selected, the rule value is reset and an empty component is rendered.\n * This property takes priority over `renderers`.\n *\n * @default [\"Empty\", \"IsNotEmpty\"]\n * */\n emptyRenderer?: string[];\n /** Custom renderers for the rules' value. */\n renderers?: HvQueryBuilderRenderers;\n /** Whether to opt-out of the confirmation dialogs shown before removing rules and rule groups. @default false. */\n disableConfirmation?: boolean;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvQueryBuilderClasses;\n}\n\n// TODO - v6\n// - \"range\", \"Empty\", and \"IsNotEmpty\" operators with internal/built-in logic\n\n// Notes:\n// Deep clone is needed throughout the component to avoid undesired mutations in props, state, and ref values\n\n/**\n * This component allows you to create conditions and group them using logical operators.\n * It outputs a structured set of rules which can be easily parsed to create SQL/NoSQL/whatever queries.\n *\n * Take a look at the [usage page](https://lumada-design.github.io/uikit/master/?path=/docs/widgets-query-builder-usage--docs) to learn more about this component.\n */\nexport const HvQueryBuilder = (props: HvQueryBuilderProps) => {\n const {\n attributes,\n renderers,\n query: queryProp, // TODO - remove in v6\n value,\n defaultValue,\n onChange,\n disableConfirmation = false,\n operators = defaultOperators,\n combinators = defaultCombinators,\n maxDepth = 1,\n labels: labelsProp,\n readOnly = false,\n emptyRenderer = [\"Empty\", \"IsNotEmpty\"],\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilder\", props);\n\n if (\n import.meta.env.DEV &&\n [\n Object.values(attributes || {}).map(({ type }) => type),\n Object.values(operators || {})\n .map((ops) => ops.map(({ operator }) => operator))\n .flat(),\n ]\n .flat()\n ?.find((key) => key === defaultRendererKey)\n ) {\n // eslint-disable-next-line no-console\n console.error(\n `${defaultRendererKey} is a restricted key and shouldn't be used as an attribute or operator type. Update the key to avoid unexpected behaviors.`,\n );\n }\n\n const { classes } = useClasses(classesProp);\n\n const currentAttributes = useRef<HvQueryBuilderProps[\"attributes\"] | null>(\n null,\n );\n\n const controlled = useRef(value != null);\n const initialQuery = useRef(\n value ?? defaultValue ?? queryProp ?? emptyGroup(),\n );\n const [query, setQuery] = useControlled(value, initialQuery.current);\n const prevQuery = useRef(query);\n\n const [pendingAction, setPendingAction] = useState<AskAction>();\n const [initialState, setInitialState] = useState(true);\n\n const [state, dispatchAction] = useReducer(\n reducer,\n setNodeIds(structuredClone(initialQuery.current)),\n );\n\n const labels = useLabels(defaultLabels, labelsProp);\n\n const contextValue = useMemo(\n () => ({\n dispatchAction,\n askAction: setPendingAction,\n attributes,\n operators,\n combinators,\n maxDepth,\n labels,\n initialTouched: initialState,\n readOnly,\n renderers,\n disableConfirmation,\n emptyRenderer,\n }),\n [\n attributes,\n operators,\n combinators,\n maxDepth,\n labels,\n readOnly,\n initialState,\n renderers,\n disableConfirmation,\n emptyRenderer,\n ],\n );\n\n // Keep track of attributes\n useEffect(() => {\n if (currentAttributes.current == null) {\n // First run, nothing to do\n currentAttributes.current = attributes;\n } else if (currentAttributes.current !== attributes) {\n // Attributes changed. The existing query is almost certainly invalid, so reset it\n currentAttributes.current = attributes;\n dispatchAction({ type: \"reset-query\" });\n }\n }, [attributes]);\n\n useEffect(() => {\n // \"value\" prop was updated by user (when controlled)\n if (!isEqual(prevQuery.current, query)) {\n dispatchAction({\n type: \"set-query\",\n query: setNodeIds(structuredClone(query), state),\n });\n prevQuery.current = query;\n } else if (\n !isEqual(\n clearNodeIds(structuredClone(state)),\n clearNodeIds(structuredClone(query)),\n )\n ) {\n setInitialState(false);\n\n // TODO - remove \"true\" from clearNodeIds in v6 (only keep else statement)\n // To avoid breaking changes, clearNodeIds will delete all ids provided by the user when uncontrolled\n // In the future if the user provides ids, it doesn't make sense to remove them with onChange\n if (!controlled.current) {\n onChange?.(\n clearNodeIds(structuredClone(state), true) as HvQueryBuilderQuery,\n );\n } else {\n // When controlled, the ids provided by the user are not removed. Only the auto generated ones.\n onChange?.(clearNodeIds(structuredClone(state)) as HvQueryBuilderQuery);\n }\n\n prevQuery.current = state;\n // This will only run if uncontrolled\n setQuery(state);\n }\n }, [onChange, query, setQuery, state]);\n\n const handleConfirm = () => {\n if (pendingAction) {\n setPendingAction(undefined);\n pendingAction.actions.forEach((action) => dispatchAction(action));\n }\n };\n\n const handleCancel = () => {\n setPendingAction(undefined);\n };\n\n return (\n <HvQueryBuilderProvider value={contextValue}>\n <RuleGroup\n level={0}\n id={state.id}\n combinator={state.combinator}\n rules={state.rules}\n classes={classes}\n />\n <ConfirmationDialog\n isOpen={pendingAction != null}\n onConfirm={handleConfirm}\n onCancel={handleCancel}\n title={pendingAction?.dialog.dialogTitle}\n message={pendingAction?.dialog.dialogMessage}\n confirmButtonLabel={pendingAction?.dialog.dialogConfirm}\n cancelButtonLabel={pendingAction?.dialog.dialogCancel}\n closeButtonTooltip={pending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;AAAA,QACA,QAAA,iBAAA;AAAA,QAAC,WAAA;AAAA,QAAA,UAAA;AAAA,QACC,sBAAyB,OAAA;AAAA,QACzB,SAAW,eAAA,OAAA;AAAA,QACX,oBAAU,eAAA,OAAA;AAAA,QACV,kCAA6B,OAAA;AAAA,QAC7B,mCAA+B,OAAA;AAAA,MAC/B;AAAA,IACA;AAAA,EACA,EAAA,CAAA;AAA0C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/QueryBuilder/types.ts"],"sourcesContent":["import { HvOptional } from \"../types/generic\";\n\nexport const defaultRendererKey = \"DEFAULT\";\n\nconst defaultAttributes = [\n \"boolean\",\n \"numeric\",\n \"dateandtime\",\n \"text\",\n \"textarea\",\n] as const;\ntype DefaultAttributes = (typeof defaultAttributes)[number];\n\nexport interface HvQueryBuilderAttribute extends Record<string, unknown> {\n id?: string;\n label: string;\n type: DefaultAttributes | (string & {});\n}\n\nexport interface HvQueryBuilderNumericRange {\n from: number | string;\n to: number | string;\n}\n\nexport interface HvQueryBuilderDateTimeStrings {\n date?: string;\n time?: string;\n}\n\nexport interface HvQueryBuilderDateTimeRange {\n start?: HvQueryBuilderDateTimeStrings;\n end?: HvQueryBuilderDateTimeStrings;\n}\n\nexport type HvQueryBuilderQueryRuleValue =\n | string\n | number\n | boolean\n | HvQueryBuilderNumericRange\n | HvQueryBuilderDateTimeStrings\n | HvQueryBuilderDateTimeRange;\n\nexport type HvQueryBuilderQueryRule = HvOptional<QueryRule, \"id\">;\n\nexport interface HvQueryBuilderQueryGroup\n extends Omit<HvOptional<QueryGroup, \"id\">, \"rules\"> {\n rules: Array<HvQueryBuilderQueryRule | HvQueryBuilderQueryGroup>;\n}\n\nexport type HvQueryBuilderQuery = HvQueryBuilderQueryGroup;\n\nexport interface QueryRule {\n id: React.Key;\n attribute?: string;\n operator?: string;\n value?: HvQueryBuilderQueryRuleValue;\n}\n\nexport interface QueryGroup {\n id: React.Key;\n combinator: string;\n rules: Array<QueryRule | QueryGroup>;\n}\n\nexport type Query = QueryGroup;\n\n// TODO - remove this type in v6\n/** @deprecated */\nexport interface HvQueryBuilderChangedQuery\n extends Omit<HvQueryBuilderQuery, \"id\" | \"rules\"> {\n rules: Array<\n Omit<HvQueryBuilderQueryRule, \"id\"> | HvQueryBuilderChangedQuery\n >;\n}\n\nexport interface HvQueryBuilderQueryCombinator {\n operand: string;\n label: string;\n}\n\nexport interface HvQueryBuilderQueryOperator {\n operator: string;\n label: string;\n combinators: string[];\n}\n\ninterface DialogLabels {\n dialogTitle: string;\n dialogMessage: string;\n dialogConfirm: string;\n dialogCancel: string;\n dialogCloseTooltip: string;\n}\n\n/** @private label structure action icon buttons */\ninterface ActionIconLabels extends DialogLabels {\n // TODO: remove in v6 - duplicated labels - `tooltip` *is* the aria-label\n /** @deprecated use `tooltip` label instead */\n ariaLabel: string;\n tooltip?: string;\n}\n\nexport type QueryAction =\n | {\n type: \"reset-query\";\n }\n | {\n type: \"reset-group\";\n id: React.Key;\n }\n | {\n type: \"add-rule\" | \"add-group\" | \"remove-node\";\n id: React.Key;\n }\n | {\n type: \"set-combinator\";\n id: React.Key;\n combinator: string;\n }\n | {\n type: \"set-attribute\";\n id: React.Key;\n attribute?: string | null;\n operator?: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-operator\";\n id: React.Key;\n operator: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-value\";\n id: React.Key;\n value: HvQueryBuilderQueryRuleValue | null | any;\n }\n | {\n type: \"set-query\";\n // Query with ids\n query: Query;\n };\n\nexport interface AskAction {\n actions: QueryAction[];\n dialog: DialogLabels;\n}\n\nexport interface HvQueryBuilderLabels {\n query?: {\n delete?: ActionIconLabels;\n addRule?: {\n label: string;\n };\n addGroup?: {\n label: string;\n };\n };\n rule: {\n attribute: {\n exists: string;\n label: string;\n placeholder: string;\n };\n operator: {\n label: string;\n placeholder: string;\n };\n value: {\n distance: {\n label: string;\n placeholder?: string;\n connectorText: string;\n button: string;\n validation: {\n required: string;\n invalid: string;\n };\n };\n text: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n };\n };\n boolean: {\n label: string;\n placeholder: string;\n options: Record<string, string>;\n };\n numeric: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n invalid: string;\n equal: string;\n greaterThan: string;\n };\n range: {\n leftLabel: string;\n rightLabel: string;\n };\n };\n datetime: {\n dateLabel: string;\n datePlaceholder: string;\n timeLabel: string;\n timePlaceholder: string;\n startDateLabel: string;\n startDatePlaceholder: string;\n startTimeLabel: string;\n startTimePlaceholder: string;\n endDateLabel: string;\n endDatePlaceholder: string;\n endTimeLabel: string;\n endTimePlaceholder: string;\n validation: {\n required: string;\n invalidInterval: string;\n };\n };\n };\n delete: ActionIconLabels;\n };\n group: {\n delete: ActionIconLabels;\n reset: ActionIconLabels;\n addRule: {\n label: string;\n };\n addGroup: {\n label: string;\n };\n };\n empty: {\n title: string;\n createCondition: string;\n createGroup: string;\n spacer: string;\n };\n}\n\nexport interface HvQueryBuilderRendererProps<V = any> {\n id: React.Key;\n attribute: string;\n operator?: string;\n value?: V;\n}\n\nexport type ValueRenderer =\n | React.FC<HvQueryBuilderRendererProps>\n | Record<string, React.FC<HvQueryBuilderRendererProps>>;\n\nexport type HvQueryBuilderRenderers = Record<string, ValueRenderer>;\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/QueryBuilder/types.ts"],"sourcesContent":["import { HvOptional } from \"../types/generic\";\n\nexport const defaultRendererKey = \"DEFAULT\";\n\nconst defaultAttributes = [\n \"boolean\",\n \"numeric\",\n \"dateandtime\",\n \"text\",\n \"textarea\",\n] as const;\ntype DefaultAttributes = (typeof defaultAttributes)[number];\n\nexport interface HvQueryBuilderAttribute extends Record<string, unknown> {\n id?: string;\n label: string;\n type: DefaultAttributes | (string & {});\n}\n\nexport interface HvQueryBuilderNumericRange {\n from: number | string;\n to: number | string;\n}\n\nexport interface HvQueryBuilderDateTimeStrings {\n date?: string;\n time?: string;\n}\n\nexport interface HvQueryBuilderDateTimeRange {\n start?: HvQueryBuilderDateTimeStrings;\n end?: HvQueryBuilderDateTimeStrings;\n}\n\nexport type HvQueryBuilderQueryRuleValue =\n | string\n | number\n | boolean\n | HvQueryBuilderNumericRange\n | HvQueryBuilderDateTimeStrings\n | HvQueryBuilderDateTimeRange;\n\nexport type HvQueryBuilderQueryRule = HvOptional<QueryRule, \"id\">;\n\nexport interface HvQueryBuilderQueryGroup\n extends Omit<HvOptional<QueryGroup, \"id\">, \"rules\"> {\n rules: Array<HvQueryBuilderQueryRule | HvQueryBuilderQueryGroup>;\n}\n\nexport type HvQueryBuilderQuery = HvQueryBuilderQueryGroup;\n\nexport interface QueryRule {\n id: React.Key;\n attribute?: string;\n operator?: string;\n value?: HvQueryBuilderQueryRuleValue;\n}\n\nexport interface QueryGroup {\n id: React.Key;\n combinator: string;\n rules: Array<QueryRule | QueryGroup>;\n}\n\nexport type Query = QueryGroup;\n\n// TODO - remove this type in v6\n/** @deprecated */\nexport interface HvQueryBuilderChangedQuery\n extends Omit<HvQueryBuilderQuery, \"id\" | \"rules\"> {\n rules: Array<\n Omit<HvQueryBuilderQueryRule, \"id\"> | HvQueryBuilderChangedQuery\n >;\n}\n\nexport interface HvQueryBuilderQueryCombinator {\n operand: string;\n label: string;\n}\n\nexport interface HvQueryBuilderQueryOperator {\n operator: string;\n label: string;\n combinators: string[];\n}\n\ninterface DialogLabels {\n dialogTitle: string;\n dialogMessage: string;\n dialogConfirm: string;\n dialogCancel: string;\n dialogCloseTooltip: string;\n}\n\n/** @private label structure action icon buttons */\ninterface ActionIconLabels extends DialogLabels {\n // TODO: remove in v6 - duplicated labels - `tooltip` *is* the aria-label\n /** @deprecated use `tooltip` label instead */\n ariaLabel: string;\n tooltip?: string;\n}\n\nexport type QueryAction =\n | {\n type: \"reset-query\";\n }\n | {\n type: \"reset-group\";\n id: React.Key;\n }\n | {\n type: \"add-rule\" | \"add-group\" | \"remove-node\";\n id: React.Key;\n }\n | {\n type: \"set-combinator\";\n id: React.Key;\n combinator: string;\n }\n | {\n type: \"set-attribute\";\n id: React.Key;\n attribute?: string | null;\n operator?: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-operator\";\n id: React.Key;\n operator: string | null;\n value?: HvQueryBuilderQueryRuleValue | null;\n }\n | {\n type: \"set-value\";\n id: React.Key;\n value: HvQueryBuilderQueryRuleValue | null | any;\n }\n | {\n type: \"set-query\";\n // Query with ids\n query: Query;\n };\n\nexport interface AskAction {\n actions: QueryAction[];\n dialog: DialogLabels;\n}\n\n// TODO - Infer type from defaultLabels object and flatten the object to remove all the nesting in v6\nexport interface HvQueryBuilderLabels {\n query?: {\n delete?: ActionIconLabels;\n addRule?: {\n label: string;\n };\n addGroup?: {\n label: string;\n };\n };\n rule: {\n attribute: {\n exists: string;\n label: string;\n placeholder: string;\n };\n operator: {\n label: string;\n placeholder: string;\n };\n value: {\n distance: {\n label: string;\n placeholder?: string;\n connectorText: string;\n button: string;\n validation: {\n required: string;\n invalid: string;\n };\n };\n text: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n };\n };\n boolean: {\n label: string;\n placeholder: string;\n options: Record<string, string>;\n };\n numeric: {\n label: string;\n placeholder: string;\n validation: {\n required: string;\n invalid: string;\n equal: string;\n greaterThan: string;\n };\n range: {\n leftLabel: string;\n rightLabel: string;\n };\n };\n datetime: {\n dateLabel: string;\n datePlaceholder: string;\n timeLabel: string;\n timePlaceholder: string;\n startDateLabel: string;\n startDatePlaceholder: string;\n startTimeLabel: string;\n startTimePlaceholder: string;\n endDateLabel: string;\n endDatePlaceholder: string;\n endTimeLabel: string;\n endTimePlaceholder: string;\n validation: {\n required: string;\n invalidInterval: string;\n };\n };\n };\n delete: ActionIconLabels;\n };\n group: {\n delete: ActionIconLabels;\n reset: ActionIconLabels;\n addRule: {\n label: string;\n };\n addGroup: {\n label: string;\n };\n };\n empty: {\n title: string;\n createCondition: string;\n createGroup: string;\n spacer: string;\n };\n}\n\nexport interface HvQueryBuilderRendererProps<V = any> {\n id: React.Key;\n attribute: string;\n operator?: string;\n value?: V;\n}\n\nexport type ValueRenderer =\n | React.FC<HvQueryBuilderRendererProps>\n | Record<string, React.FC<HvQueryBuilderRendererProps>>;\n\nexport type HvQueryBuilderRenderers = Record<string, ValueRenderer>;\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB;"}
|
|
@@ -159,13 +159,12 @@ const HvSelect = fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
159
159
|
size,
|
|
160
160
|
variant,
|
|
161
161
|
"aria-label": ariaLabel,
|
|
162
|
-
"aria-labelledby": mergeIds(
|
|
162
|
+
"aria-labelledby": mergeIds(ariaLabelledBy, { [labelId]: label }),
|
|
163
163
|
"aria-invalid": isInvalid ? true : void 0,
|
|
164
164
|
"aria-errormessage": errorMessageId,
|
|
165
|
-
"aria-describedby": mergeIds(
|
|
166
|
-
description
|
|
167
|
-
|
|
168
|
-
),
|
|
165
|
+
"aria-describedby": mergeIds(ariaDescribedBy, {
|
|
166
|
+
[descriptionId]: description
|
|
167
|
+
}),
|
|
169
168
|
...getButtonProps(),
|
|
170
169
|
children: defaultRenderValue(actualValue) ?? placeholder
|
|
171
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport clsx from \"clsx\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { HvPanel } from \"../Panel\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: clsx.ClassValue[]) => clsx(ids) || undefined;\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : getOptionMetadata(value as OptionValue) ?? null;\n\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(label && labelId, ariaLabelledBy)}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(\n description && descriptionId,\n ariaDescribedBy,\n )}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={\n enablePortal\n ? document.getElementById(rootId || \"\") || document.body\n : undefined\n }\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvPanel\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n >\n <SelectProvider value={contextValue}>\n <HvListContainer condensed selectable {...getListboxProps()}>\n {children}\n </HvListContainer>\n </SelectProvider>\n </HvPanel>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC1B,QAAI,QAAQ,WAAW;AAAU,aAAA;AAC1B,WAAA,oBAAA,UAAA,EAAG,UAAQ,QAAA,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,CAAA;AAAA,EACnD;AAEA,SAAO,SAAS,SAAS;AAC3B;AAEA,MAAM,WAAW,IAAI,QAA2B,KAAK,GAAG,KAAK;AAmDtD,MAAM,WAAW,gBAAgB,SAASA,UAI/C,OACA,KACA;AACM,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;A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AoB;AAAA,YACxB;AAAA,YACC,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport clsx from \"clsx\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { HvPanel } from \"../Panel\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: clsx.ClassValue[]) => clsx(ids) || undefined;\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : getOptionMetadata(value as OptionValue) ?? null;\n\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(ariaLabelledBy, { [labelId]: label })}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(ariaDescribedBy, {\n [descriptionId]: description,\n })}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={\n enablePortal\n ? document.getElementById(rootId || \"\") || document.body\n : undefined\n }\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvPanel\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n >\n <SelectProvider value={contextValue}>\n <HvListContainer condensed selectable {...getListboxProps()}>\n {children}\n </HvListContainer>\n </SelectProvider>\n </HvPanel>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC1B,QAAI,QAAQ,WAAW;AAAU,aAAA;AAC1B,WAAA,oBAAA,UAAA,EAAG,UAAQ,QAAA,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,CAAA;AAAA,EACnD;AAEA,SAAO,SAAS,SAAS;AAC3B;AAEA,MAAM,WAAW,IAAI,QAA2B,KAAK,GAAG,KAAK;AAmDtD,MAAM,WAAW,gBAAgB,SAASA,UAI/C,OACA,KACA;AACM,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,YAAY,KAAK;AACrC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA,EAAE,WAAW;AAEnB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAoB,cAAc;AAE9D,QAAA,YAAY,OAA0B,IAAI;AAC1C,QAAA,kBAAkB,WAAW,KAAK,SAAS;AAE3C,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,I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;AAAA,YACA,WAAW;AAAA,cACT;AAAA,gBACE,SAAS;AAAA,gBACT,OAAO;AAAA,gBACP,IAAI,CAAC,EAAE,YAAY,aAAa,MAAM,SAAS;AAAA,cACjD;AAAA,YACF;AAAA,YAEA,UAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO;AAAA,kBACL,OAAO,gBACH,UACC,UAAU,SAAS,eAAe,KAAK;AAAA,gBAC9C;AAAA,gBACA,WAAW,GAAG,QAAQ,OAAO,WAAW;AAAA,kBACtC,CAAC,QAAQ,aAAa,GAAG,UAAU,SAAS,KAAK;AAAA,kBACjD,CAAC,QAAQ,eAAe,GAAG,UAAU,SAAS,QAAQ;AAAA,gBAAA,CACvD;AAAA,gBAED,UAAC,oBAAA,gBAAA,EAAe,OAAO,cACrB,8BAAC,iBAAgB,EAAA,WAAS,MAAC,YAAU,MAAE,GAAG,mBACvC,SACH,CAAA,GACF;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QACF;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAG,oBAAoB;AAAA,YACxB;AAAA,YACC,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
@@ -264,15 +264,16 @@ const HvVerticalNavigationTreeViewItem = forwardRef(
|
|
|
264
264
|
};
|
|
265
265
|
const hasChildren = !!children;
|
|
266
266
|
const showTooltip = !hasChildren && !isOpen && !disableTooltip;
|
|
267
|
+
const isLink = href !== void 0 && !disabled;
|
|
267
268
|
return /* @__PURE__ */ jsx(HvTooltip, { placement: "right", title: showTooltip && label, children: /* @__PURE__ */ jsxs(
|
|
268
269
|
HvTypography,
|
|
269
270
|
{
|
|
270
271
|
id: setId(id, "button"),
|
|
271
|
-
component:
|
|
272
|
-
...
|
|
272
|
+
component: isLink ? "a" : "div",
|
|
273
|
+
...isLink ? buttonLinkProps : null,
|
|
273
274
|
ref: contentRef,
|
|
274
275
|
className: cx(classes.content, {
|
|
275
|
-
[classes.link]:
|
|
276
|
+
[classes.link]: isLink,
|
|
276
277
|
[classes.minimized]: !isOpen
|
|
277
278
|
}),
|
|
278
279
|
variant: "body",
|
|
@@ -282,7 +283,7 @@ const HvVerticalNavigationTreeViewItem = forwardRef(
|
|
|
282
283
|
style: {
|
|
283
284
|
paddingLeft: (useIcons || !isOpen ? 0 : 10) + level * (collapsible ? 16 : 10)
|
|
284
285
|
},
|
|
285
|
-
role:
|
|
286
|
+
role: isLink ? void 0 : "button",
|
|
286
287
|
...treeviewMode ? {
|
|
287
288
|
tabIndex: -1,
|
|
288
289
|
onFocus: handleFocus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewItem.js","sources":["../../../../src/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { useForkRef } from \"../../hooks/useForkRef\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport { HvTypography } from \"../../Typography\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { setId } from \"../../utils/setId\";\nimport { VerticalNavigationContext } from \"../VerticalNavigationContext\";\nimport { DescendantProvider, useDescendant } from \"./descendants\";\nimport { IconWrapper } from \"./IconWrapper\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { staticClasses, useClasses } from \"./TreeViewItem.styles\";\n\nexport { staticClasses as treeViewItemClasses };\n\nexport type HvVerticalNavigationTreeViewItemClasses = ExtractNames<\n typeof useClasses\n>;\n\nexport interface HvVerticalNavigationTreeViewItemProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the Radio button.\n */\n classes?: HvVerticalNavigationTreeViewItemClasses;\n /**\n * Is the node disabled.\n */\n disabled?: boolean;\n /**\n * Can the node be selected.\n */\n selectable?: boolean;\n /**\n * The id of the node.\n */\n nodeId?: string;\n /**\n * The icon to display next to the node's label.\n */\n icon?: React.ReactNode;\n /**\n * The item label.\n */\n label?: React.ReactNode;\n /**\n * The url for the link.\n */\n href?: string;\n /**\n * The behavior when opening a link.\n */\n target?: string;\n /**\n * The node payload.\n */\n payload?: any;\n /**\n * @ignore\n */\n onClick?: any;\n /**\n * @ignore\n */\n onMouseDown?: any;\n /**\n * @ignore\n */\n onFocus?: any;\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n /**\n * @ignore\n */\n onMouseEnter?: any;\n /**\n * Disables the appearence of a tooltip on hovering an element ( Only applicable when the in collapsed mode)\n */\n disableTooltip?: boolean;\n}\n\nconst preventSelection = (event, disabled) => {\n if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {\n // Prevent text selection\n event.preventDefault();\n }\n};\n\nexport const HvVerticalNavigationTreeViewItem = forwardRef(\n (props: HvVerticalNavigationTreeViewItemProps, ref) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n\n disabled: disabledProp = false,\n\n selectable: selectableProp,\n\n nodeId,\n icon = null,\n label,\n href,\n target,\n payload,\n\n onClick,\n onMouseDown,\n onFocus,\n\n children,\n\n disableTooltip,\n\n ...others\n } = useDefaultProps(\"HvVerticalNavigationTreeViewItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const treeViewControlContext = useContext(TreeViewControlContext);\n const { isExpanded, isSelected, isFocused, isDisabled, isChildSelected } =\n useContext(TreeViewStateContext);\n\n const {\n treeId,\n mode,\n collapsible,\n toggleExpansion,\n multiSelect,\n selectNode,\n selectRange,\n disabledItemsFocusable,\n registerNode,\n unregisterNode,\n mapFirstChar,\n unMapFirstChar,\n focus,\n } = treeViewControlContext;\n\n const treeviewMode = mode === \"treeview\";\n\n let id: string | null = null;\n\n if (idProp != null) {\n id = idProp;\n } else if (treeId && nodeId) {\n id = `${treeId}-${nodeId}`;\n }\n\n const [treeitemElement, setTreeitemElement] = useState(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(setTreeitemElement, ref);\n\n const descendant = useMemo(\n () => ({\n element: treeitemElement,\n id: nodeId,\n }),\n [nodeId, treeitemElement],\n );\n\n const { isOpen, useIcons } = useContext(VerticalNavigationContext);\n\n const { index, parentId, level } = useDescendant(descendant);\n\n const expandable = collapsible && Array.isArray(children);\n const expanded = isExpanded ? isExpanded(nodeId) : false;\n const focused = isFocused ? isFocused(nodeId) : false;\n const selected = isSelected ? isSelected(nodeId) : false;\n const disabled = isDisabled ? isDisabled(nodeId) : false;\n\n const selectable =\n selectableProp != null\n ? selectableProp\n : !collapsible || !expandable || !isOpen;\n\n useEffect(() => {\n // On the first render a node's index will be -1. We want to wait for the real index.\n if (registerNode && unregisterNode && index !== -1) {\n registerNode({\n id: nodeId,\n idAttribute: id,\n index,\n parentId,\n selectable,\n expandable,\n disabled: disabledProp,\n onFocus,\n payload,\n });\n\n return () => {\n unregisterNode(nodeId);\n };\n }\n\n return undefined;\n }, [\n registerNode,\n unregisterNode,\n parentId,\n index,\n nodeId,\n expandable,\n disabledProp,\n id,\n selectable,\n onFocus,\n payload,\n ]);\n\n useEffect(() => {\n if (\n mapFirstChar &&\n unMapFirstChar &&\n label &&\n contentRef.current?.textContent\n ) {\n mapFirstChar(\n nodeId,\n contentRef.current?.textContent.substring(0, 1).toLowerCase(),\n );\n\n return () => {\n unMapFirstChar(nodeId);\n };\n }\n return undefined;\n }, [mapFirstChar, unMapFirstChar, nodeId, label]);\n\n let ariaSelected;\n if (multiSelect) {\n ariaSelected = selected;\n } else if (selected) {\n /* single-selection trees unset aria-selected on un-selected items.\n *\n * If the tree does not support multiple selection, aria-selected\n * is set to true for the selected node and it is not present on any other node in the tree.\n * Source: https://www.w3.org/TR/wai-aria-practices/#TreeView\n */\n ariaSelected = true;\n }\n\n const handleFocus = useCallback(\n (event) => {\n // DOM focus stays on the tree which manages focus with aria-activedescendant\n if (event.target === event.currentTarget) {\n (event.target.ownerDocument || document)\n .getElementById(treeId)\n .focus({ preventScroll: true });\n }\n\n const unfocusable = !disabledItemsFocusable && disabled;\n if (\n !focused &&\n event.currentTarget === event.target &&\n !unfocusable &&\n focus\n ) {\n focus(event, nodeId);\n }\n },\n [disabled, disabledItemsFocusable, focus, focused, nodeId, treeId],\n );\n\n const handleExpansion = useCallback(\n (event) => {\n if (!disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n // If already expanded and trying to toggle selection don't close\n if (\n expandable &&\n isOpen &&\n !(multiple && isExpanded && isExpanded(nodeId))\n ) {\n if (toggleExpansion) toggleExpansion(event, nodeId);\n }\n }\n },\n [\n disabled,\n expandable,\n focus,\n focused,\n isExpanded,\n multiSelect,\n nodeId,\n toggleExpansion,\n treeviewMode,\n isOpen,\n ],\n );\n\n const handleSelection = useCallback(\n (event) => {\n if (selectable && !disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n if (multiple) {\n if (event.shiftKey) {\n if (selectRange) return selectRange(event, { end: nodeId });\n } else if (selectNode) return selectNode(event, nodeId, true);\n } else if (selectNode) return selectNode(event, nodeId);\n } else {\n return false;\n }\n },\n [\n disabled,\n focus,\n focused,\n multiSelect,\n nodeId,\n selectNode,\n selectRange,\n selectable,\n treeviewMode,\n ],\n );\n\n const handleMouseDown = useCallback(\n (event) => {\n preventSelection(event, disabled);\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [disabled, onMouseDown],\n );\n\n const handleClick = useCallback(\n (event) => {\n if (!disabled) {\n if (expandable && isOpen) {\n handleExpansion(event);\n }\n\n if (selectable) {\n handleSelection(event);\n }\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [\n disabled,\n expandable,\n handleExpansion,\n handleSelection,\n onClick,\n selectable,\n isOpen,\n ],\n );\n\n const handleKeyDown = useCallback(\n (event) => {\n let isEventHandled = false;\n const { key } = event;\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.currentTarget !== event.target\n ) {\n return;\n }\n if (contentRef.current === event.currentTarget) {\n if (key === \"Enter\" || key === \" \") {\n if (expandable && isOpen) {\n isEventHandled = handleExpansion(event) as unknown as boolean;\n }\n\n if (selectable) {\n isEventHandled = handleSelection(event) as boolean;\n }\n }\n\n if (isEventHandled) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n },\n [expandable, handleExpansion, handleSelection, selectable, isOpen],\n );\n\n const renderedContent = useMemo(() => {\n const buttonLinkProps = {\n href,\n target,\n };\n\n const hasChildren = !!children;\n const showTooltip = !hasChildren && !isOpen && !disableTooltip;\n\n return (\n <HvTooltip placement=\"right\" title={showTooltip && label}>\n <HvTypography\n id={setId(id, \"button\")}\n component={href ? \"a\" : \"div\"}\n {...(href ? buttonLinkProps : null)}\n ref={contentRef}\n className={cx(classes.content, {\n [classes.link]: href != null,\n [classes.minimized]: !isOpen,\n })}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (useIcons || !isOpen ? 0 : 10) +\n level * (collapsible ? 16 : 10),\n }}\n role={href ? undefined : \"button\"}\n {...(treeviewMode\n ? {\n tabIndex: -1,\n onFocus: handleFocus,\n }\n : {\n tabIndex: selectable || expandable ? 0 : -1,\n onKeyDown: handleKeyDown,\n \"aria-current\":\n (selectable && selected) ||\n (!isOpen && isChildSelected?.(nodeId))\n ? href\n ? \"page\"\n : true\n : undefined,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-controls\":\n isOpen && expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n <IconWrapper\n icon={useIcons && icon}\n label={payload?.label}\n hasChildren={hasChildren}\n showAvatar={!icon && useIcons}\n isOpen={isOpen}\n />\n\n {isOpen && (\n <div\n className={cx(classes.label, {\n [classes.labelIcon]: useIcons,\n [classes.labelExpandable]: !!expandable,\n })}\n >\n <HvOverflowTooltip data={label} />\n </div>\n )}\n\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n </HvTypography>\n </HvTooltip>\n );\n }, [\n id,\n href,\n target,\n cx,\n classes.content,\n classes.link,\n classes.minimized,\n classes.label,\n classes.labelIcon,\n classes.labelExpandable,\n disabled,\n handleClick,\n handleMouseDown,\n expandable,\n icon,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n handleKeyDown,\n selected,\n expanded,\n label,\n disableTooltip,\n payload?.label,\n children,\n isOpen,\n useIcons,\n isChildSelected,\n nodeId,\n ]);\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <ul\n id={setId(id, \"group\")}\n className={classes.group}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </ul>\n ),\n [children, classes?.group, id, treeviewMode],\n );\n\n return (\n <li\n ref={handleRef}\n id={id ?? undefined}\n className={cx(classes.node, {\n [classes.disabled]: disabled,\n [classes.expandable]: expandable,\n [classes.collapsed]: expandable && !expanded,\n [classes.expanded]: expandable && expanded,\n [classes.selectable]: selectable && !disabled,\n [classes.unselectable]: !disabled && !selectable,\n [classes.selected]:\n (!disabled && selectable && selected) ||\n (!isOpen && useIcons && isChildSelected && isChildSelected(nodeId)),\n [classes.unselected]: !disabled && selectable && !selected,\n [classes.focused]: focused,\n [classes.hide]: !isOpen && !useIcons,\n className,\n })}\n data-hasicon={icon != null ? true : undefined}\n {...(mode === \"treeview\" && {\n role: \"treeitem\",\n \"aria-selected\": ariaSelected,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-disabled\": disabled ? true : undefined,\n })}\n {...others}\n >\n {renderedContent}\n {isOpen && (\n <DescendantProvider id={nodeId} level={level + 1}>\n {renderedChildren}\n </DescendantProvider>\n )}\n </li>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwGA,MAAM,mBAAmB,CAAC,OAAO,aAAa;AAC5C,MAAI,MAAM,YAAY,MAAM,WAAW,MAAM,WAAW,UAAU;AAEhE,UAAM,eAAe;AAAA,EACvB;AACF;AAEO,MAAM,mCAAmC;AAAA,EAC9C,CAAC,OAA8C,QAAQ;AAC/C,UAAA;AAAA,MACJ,IAAI;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MAET,UAAU,eAAe;AAAA,MAEzB,YAAY;AAAA,MAEZ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MAEA;AAAA,MAEA,GAAG;AAAA,IAAA,IACD,gBAAgB,oCAAoC,KAAK;AAE7D,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,UAAA,yBAAyB,WAAW,sBAAsB;AAC1D,UAAA,EAAE,YAAY,YAAY,WAAW,YAAY,gBAAgB,IACrE,WAAW,oBAAoB;AAE3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACE,IAAA;AAEJ,UAAM,eAAe,SAAS;AAE9B,QAAI,KAAoB;AAExB,QAAI,UAAU,MAAM;AACb,WAAA;AAAA,IAAA,WACI,UAAU,QAAQ;AACtB,WAAA,GAAG,MAAM,IAAI,MAAM;AAAA,IAC1B;AAEA,UAAM,CAAC,iBAAiB,kBAAkB,I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AAAA,MAEJ,CAAC,UAAU,SAAS,OAAO,IAAI,YAAY;AAAA,IAAA;AAI3C,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,IAAI,MAAM;AAAA,QACV,WAAW,GAAG,QAAQ,MAAM;AAAA,UAC1B,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACpB,CAAC,QAAQ,UAAU,GAAG;AAAA,UACtB,CAAC,QAAQ,SAAS,GAAG,cAAc,CAAC;AAAA,UACpC,CAAC,QAAQ,QAAQ,GAAG,cAAc;AAAA,UAClC,CAAC,QAAQ,UAAU,GAAG,cAAc,CAAC;AAAA,UACrC,CAAC,QAAQ,YAAY,GAAG,CAAC,YAAY,CAAC;AAAA,UACtC,CAAC,QAAQ,QAAQ,GACd,CAAC,YAAY,cAAc,YAC3B,CAAC,UAAU,YAAY,mBAAmB,gBAAgB,MAAM;AAAA,UACnE,CAAC,QAAQ,UAAU,GAAG,CAAC,YAAY,cAAc,CAAC;AAAA,UAClD,CAAC,QAAQ,OAAO,GAAG;AAAA,UACnB,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC;AAAA,UAC5B;AAAA,QAAA,CACD;AAAA,QACD,gBAAc,QAAQ,OAAO,OAAO;AAAA,QACnC,GAAI,SAAS,cAAc;AAAA,UAC1B,MAAM;AAAA,UACN,iBAAiB;AAAA,UACjB,iBAAiB,aAAa,WAAW;AAAA,UACzC,iBAAiB,WAAW,OAAO;AAAA,QACrC;AAAA,QACC,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,8BACE,oBAAmB,EAAA,IAAI,QAAQ,OAAO,QAAQ,GAC5C,UACH,iBAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
|
1
|
+
{"version":3,"file":"TreeViewItem.js","sources":["../../../../src/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { useForkRef } from \"../../hooks/useForkRef\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport { HvTypography } from \"../../Typography\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { setId } from \"../../utils/setId\";\nimport { VerticalNavigationContext } from \"../VerticalNavigationContext\";\nimport { DescendantProvider, useDescendant } from \"./descendants\";\nimport { IconWrapper } from \"./IconWrapper\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { staticClasses, useClasses } from \"./TreeViewItem.styles\";\n\nexport { staticClasses as treeViewItemClasses };\n\nexport type HvVerticalNavigationTreeViewItemClasses = ExtractNames<\n typeof useClasses\n>;\n\nexport interface HvVerticalNavigationTreeViewItemProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the Radio button.\n */\n classes?: HvVerticalNavigationTreeViewItemClasses;\n /**\n * Is the node disabled.\n */\n disabled?: boolean;\n /**\n * Can the node be selected.\n */\n selectable?: boolean;\n /**\n * The id of the node.\n */\n nodeId?: string;\n /**\n * The icon to display next to the node's label.\n */\n icon?: React.ReactNode;\n /**\n * The item label.\n */\n label?: React.ReactNode;\n /**\n * The url for the link.\n */\n href?: string;\n /**\n * The behavior when opening a link.\n */\n target?: string;\n /**\n * The node payload.\n */\n payload?: any;\n /**\n * @ignore\n */\n onClick?: any;\n /**\n * @ignore\n */\n onMouseDown?: any;\n /**\n * @ignore\n */\n onFocus?: any;\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n /**\n * @ignore\n */\n onMouseEnter?: any;\n /**\n * Disables the appearence of a tooltip on hovering an element ( Only applicable when the in collapsed mode)\n */\n disableTooltip?: boolean;\n}\n\nconst preventSelection = (event, disabled) => {\n if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {\n // Prevent text selection\n event.preventDefault();\n }\n};\n\nexport const HvVerticalNavigationTreeViewItem = forwardRef(\n (props: HvVerticalNavigationTreeViewItemProps, ref) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n\n disabled: disabledProp = false,\n\n selectable: selectableProp,\n\n nodeId,\n icon = null,\n label,\n href,\n target,\n payload,\n\n onClick,\n onMouseDown,\n onFocus,\n\n children,\n\n disableTooltip,\n\n ...others\n } = useDefaultProps(\"HvVerticalNavigationTreeViewItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const treeViewControlContext = useContext(TreeViewControlContext);\n const { isExpanded, isSelected, isFocused, isDisabled, isChildSelected } =\n useContext(TreeViewStateContext);\n\n const {\n treeId,\n mode,\n collapsible,\n toggleExpansion,\n multiSelect,\n selectNode,\n selectRange,\n disabledItemsFocusable,\n registerNode,\n unregisterNode,\n mapFirstChar,\n unMapFirstChar,\n focus,\n } = treeViewControlContext;\n\n const treeviewMode = mode === \"treeview\";\n\n let id: string | null = null;\n\n if (idProp != null) {\n id = idProp;\n } else if (treeId && nodeId) {\n id = `${treeId}-${nodeId}`;\n }\n\n const [treeitemElement, setTreeitemElement] = useState(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(setTreeitemElement, ref);\n\n const descendant = useMemo(\n () => ({\n element: treeitemElement,\n id: nodeId,\n }),\n [nodeId, treeitemElement],\n );\n\n const { isOpen, useIcons } = useContext(VerticalNavigationContext);\n\n const { index, parentId, level } = useDescendant(descendant);\n\n const expandable = collapsible && Array.isArray(children);\n const expanded = isExpanded ? isExpanded(nodeId) : false;\n const focused = isFocused ? isFocused(nodeId) : false;\n const selected = isSelected ? isSelected(nodeId) : false;\n const disabled = isDisabled ? isDisabled(nodeId) : false;\n\n const selectable =\n selectableProp != null\n ? selectableProp\n : !collapsible || !expandable || !isOpen;\n\n useEffect(() => {\n // On the first render a node's index will be -1. We want to wait for the real index.\n if (registerNode && unregisterNode && index !== -1) {\n registerNode({\n id: nodeId,\n idAttribute: id,\n index,\n parentId,\n selectable,\n expandable,\n disabled: disabledProp,\n onFocus,\n payload,\n });\n\n return () => {\n unregisterNode(nodeId);\n };\n }\n\n return undefined;\n }, [\n registerNode,\n unregisterNode,\n parentId,\n index,\n nodeId,\n expandable,\n disabledProp,\n id,\n selectable,\n onFocus,\n payload,\n ]);\n\n useEffect(() => {\n if (\n mapFirstChar &&\n unMapFirstChar &&\n label &&\n contentRef.current?.textContent\n ) {\n mapFirstChar(\n nodeId,\n contentRef.current?.textContent.substring(0, 1).toLowerCase(),\n );\n\n return () => {\n unMapFirstChar(nodeId);\n };\n }\n return undefined;\n }, [mapFirstChar, unMapFirstChar, nodeId, label]);\n\n let ariaSelected;\n if (multiSelect) {\n ariaSelected = selected;\n } else if (selected) {\n /* single-selection trees unset aria-selected on un-selected items.\n *\n * If the tree does not support multiple selection, aria-selected\n * is set to true for the selected node and it is not present on any other node in the tree.\n * Source: https://www.w3.org/TR/wai-aria-practices/#TreeView\n */\n ariaSelected = true;\n }\n\n const handleFocus = useCallback(\n (event) => {\n // DOM focus stays on the tree which manages focus with aria-activedescendant\n if (event.target === event.currentTarget) {\n (event.target.ownerDocument || document)\n .getElementById(treeId)\n .focus({ preventScroll: true });\n }\n\n const unfocusable = !disabledItemsFocusable && disabled;\n if (\n !focused &&\n event.currentTarget === event.target &&\n !unfocusable &&\n focus\n ) {\n focus(event, nodeId);\n }\n },\n [disabled, disabledItemsFocusable, focus, focused, nodeId, treeId],\n );\n\n const handleExpansion = useCallback(\n (event) => {\n if (!disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n // If already expanded and trying to toggle selection don't close\n if (\n expandable &&\n isOpen &&\n !(multiple && isExpanded && isExpanded(nodeId))\n ) {\n if (toggleExpansion) toggleExpansion(event, nodeId);\n }\n }\n },\n [\n disabled,\n expandable,\n focus,\n focused,\n isExpanded,\n multiSelect,\n nodeId,\n toggleExpansion,\n treeviewMode,\n isOpen,\n ],\n );\n\n const handleSelection = useCallback(\n (event) => {\n if (selectable && !disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n if (multiple) {\n if (event.shiftKey) {\n if (selectRange) return selectRange(event, { end: nodeId });\n } else if (selectNode) return selectNode(event, nodeId, true);\n } else if (selectNode) return selectNode(event, nodeId);\n } else {\n return false;\n }\n },\n [\n disabled,\n focus,\n focused,\n multiSelect,\n nodeId,\n selectNode,\n selectRange,\n selectable,\n treeviewMode,\n ],\n );\n\n const handleMouseDown = useCallback(\n (event) => {\n preventSelection(event, disabled);\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [disabled, onMouseDown],\n );\n\n const handleClick = useCallback(\n (event) => {\n if (!disabled) {\n if (expandable && isOpen) {\n handleExpansion(event);\n }\n\n if (selectable) {\n handleSelection(event);\n }\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [\n disabled,\n expandable,\n handleExpansion,\n handleSelection,\n onClick,\n selectable,\n isOpen,\n ],\n );\n\n const handleKeyDown = useCallback(\n (event) => {\n let isEventHandled = false;\n const { key } = event;\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.currentTarget !== event.target\n ) {\n return;\n }\n if (contentRef.current === event.currentTarget) {\n if (key === \"Enter\" || key === \" \") {\n if (expandable && isOpen) {\n isEventHandled = handleExpansion(event) as unknown as boolean;\n }\n\n if (selectable) {\n isEventHandled = handleSelection(event) as boolean;\n }\n }\n\n if (isEventHandled) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n },\n [expandable, handleExpansion, handleSelection, selectable, isOpen],\n );\n\n const renderedContent = useMemo(() => {\n const buttonLinkProps = {\n href,\n target,\n };\n\n const hasChildren = !!children;\n const showTooltip = !hasChildren && !isOpen && !disableTooltip;\n\n const isLink = href !== undefined && !disabled;\n\n return (\n <HvTooltip placement=\"right\" title={showTooltip && label}>\n <HvTypography\n id={setId(id, \"button\")}\n component={isLink ? \"a\" : \"div\"}\n {...(isLink ? buttonLinkProps : null)}\n ref={contentRef}\n className={cx(classes.content, {\n [classes.link]: isLink,\n [classes.minimized]: !isOpen,\n })}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (useIcons || !isOpen ? 0 : 10) +\n level * (collapsible ? 16 : 10),\n }}\n role={isLink ? undefined : \"button\"}\n {...(treeviewMode\n ? {\n tabIndex: -1,\n onFocus: handleFocus,\n }\n : {\n tabIndex: selectable || expandable ? 0 : -1,\n onKeyDown: handleKeyDown,\n \"aria-current\":\n (selectable && selected) ||\n (!isOpen && isChildSelected?.(nodeId))\n ? href\n ? \"page\"\n : true\n : undefined,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-controls\":\n isOpen && expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n <IconWrapper\n icon={useIcons && icon}\n label={payload?.label}\n hasChildren={hasChildren}\n showAvatar={!icon && useIcons}\n isOpen={isOpen}\n />\n\n {isOpen && (\n <div\n className={cx(classes.label, {\n [classes.labelIcon]: useIcons,\n [classes.labelExpandable]: !!expandable,\n })}\n >\n <HvOverflowTooltip data={label} />\n </div>\n )}\n\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n </HvTypography>\n </HvTooltip>\n );\n }, [\n id,\n href,\n target,\n cx,\n classes.content,\n classes.link,\n classes.minimized,\n classes.label,\n classes.labelIcon,\n classes.labelExpandable,\n disabled,\n handleClick,\n handleMouseDown,\n expandable,\n icon,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n handleKeyDown,\n selected,\n expanded,\n label,\n disableTooltip,\n payload?.label,\n children,\n isOpen,\n useIcons,\n isChildSelected,\n nodeId,\n ]);\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <ul\n id={setId(id, \"group\")}\n className={classes.group}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </ul>\n ),\n [children, classes?.group, id, treeviewMode],\n );\n\n return (\n <li\n ref={handleRef}\n id={id ?? undefined}\n className={cx(classes.node, {\n [classes.disabled]: disabled,\n [classes.expandable]: expandable,\n [classes.collapsed]: expandable && !expanded,\n [classes.expanded]: expandable && expanded,\n [classes.selectable]: selectable && !disabled,\n [classes.unselectable]: !disabled && !selectable,\n [classes.selected]:\n (!disabled && selectable && selected) ||\n (!isOpen && useIcons && isChildSelected && isChildSelected(nodeId)),\n [classes.unselected]: !disabled && selectable && !selected,\n [classes.focused]: focused,\n [classes.hide]: !isOpen && !useIcons,\n className,\n })}\n data-hasicon={icon != null ? true : undefined}\n {...(mode === \"treeview\" && {\n role: \"treeitem\",\n \"aria-selected\": ariaSelected,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-disabled\": disabled ? true : undefined,\n })}\n {...others}\n >\n {renderedContent}\n {isOpen && (\n <DescendantProvider id={nodeId} level={level + 1}>\n {renderedChildren}\n </DescendantProvider>\n )}\n </li>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwGA,MAAM,mBAAmB,CAAC,OAAO,aAAa;AAC5C,MAAI,MAAM,YAAY,MAAM,WAAW,MAAM,WAAW,UAAU;AAEhE,UAAM,eAAe;AAAA,EACvB;AACF;AAEO,MAAM,mCAAmC;AAAA,EAC9C,CAAC,OAA8C,QAAQ;AAC/C,UAAA;AAAA,MACJ,IAAI;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MAET,UAAU,eAAe;AAAA,MAEzB,YAAY;AAAA,MAEZ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MAEA;AAAA,MAEA,G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QAAQ,OAAO,GAAG;AAAA,UACnB,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC;AAAA,UAC5B;AAAA,QAAA,CACD;AAAA,QACD,gBAAc,QAAQ,OAAO,OAAO;AAAA,QACnC,GAAI,SAAS,cAAc;AAAA,UAC1B,MAAM;AAAA,UACN,iBAAiB;AAAA,UACjB,iBAAiB,aAAa,WAAW;AAAA,UACzC,iBAAiB,WAAW,OAAO;AAAA,QACrC;AAAA,QACC,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,8BACE,oBAAmB,EAAA,IAAI,QAAQ,OAAO,QAAQ,GAC5C,UACH,iBAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { deepMerge } from "../utils/deepMerge.js";
|
|
2
3
|
function useLabels(defaultLabels, labels) {
|
|
3
4
|
return useMemo(() => {
|
|
4
|
-
return
|
|
5
|
+
return deepMerge(defaultLabels, labels);
|
|
5
6
|
}, [defaultLabels, labels]);
|
|
6
7
|
}
|
|
7
8
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLabels.js","sources":["../../../src/hooks/useLabels.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nexport function useLabels<T>(defaultLabels: T, labels?:
|
|
1
|
+
{"version":3,"file":"useLabels.js","sources":["../../../src/hooks/useLabels.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { DeepPartial } from \"../types/generic\";\nimport { deepMerge } from \"../utils/deepMerge\";\n\nexport function useLabels<T>(defaultLabels: T, labels?: DeepPartial<T>): T {\n return useMemo(() => {\n return deepMerge(defaultLabels, labels);\n }, [defaultLabels, labels]);\n}\n"],"names":[],"mappings":";;AAKgB,SAAA,UAAa,eAAkB,QAA4B;AACzE,SAAO,QAAQ,MAAM;AACZ,WAAA,UAAU,eAAe,MAAM;AAAA,EAAA,GACrC,CAAC,eAAe,MAAM,CAAC;AAC5B;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2
|
+
function merge(target, source) {
|
|
3
|
+
Object.keys(source || {}).forEach((key) => {
|
|
4
|
+
if (isObject(target[key]) && isObject(source?.[key])) {
|
|
5
|
+
merge(target[key], source?.[key]);
|
|
6
|
+
} else {
|
|
7
|
+
target[key] = source?.[key];
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function deepMerge(target, source) {
|
|
12
|
+
const result = structuredClone(target);
|
|
13
|
+
merge(result, source);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
deepMerge
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepMerge.js","sources":["../../../src/utils/deepMerge.ts"],"sourcesContent":["import { DeepPartial } from \"../types/generic\";\n\nconst isObject = (val: any): val is Object =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\nfunction merge<T>(target: T, source?: DeepPartial<T>) {\n Object.keys(source || {}).forEach((key) => {\n if (isObject(target[key]) && isObject(source?.[key])) {\n merge(target[key], source?.[key]);\n } else {\n target[key] = source?.[key];\n }\n });\n}\n\n/** Merges recursively all keys of source into target returning the resulting object. */\nexport function deepMerge<T>(target: T, source?: DeepPartial<T>): T {\n const result = structuredClone(target);\n merge(result, source);\n return result;\n}\n"],"names":[],"mappings":"AAEA,MAAM,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAEtD,SAAS,MAAS,QAAW,QAAyB;AACpD,SAAO,KAAK,UAAU,CAAE,CAAA,EAAE,QAAQ,CAAC,QAAQ;AACrC,QAAA,SAAS,OAAO,GAAG,CAAC,KAAK,SAAS,SAAS,GAAG,CAAC,GAAG;AACpD,YAAM,OAAO,GAAG,GAAG,SAAS,GAAG,CAAC;AAAA,IAAA,OAC3B;AACE,aAAA,GAAG,IAAI,SAAS,GAAG;AAAA,IAC5B;AAAA,EAAA,CACD;AACH;AAGgB,SAAA,UAAa,QAAW,QAA4B;AAC5D,QAAA,SAAS,gBAAgB,MAAM;AACrC,QAAM,QAAQ,MAAM;AACb,SAAA;AACT;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { ComponentProps } from 'react';
|
|
|
15
15
|
import { ContainerProps } from '@mui/material/Container';
|
|
16
16
|
import { Context } from 'react';
|
|
17
17
|
import { CSSInterpolation } from '@emotion/serialize';
|
|
18
|
+
import { default as default_2 } from 'react';
|
|
19
|
+
import { default as default_3 } from 'embla-carousel-react';
|
|
18
20
|
import { defaultCacheKey } from '@hitachivantara/uikit-react-shared';
|
|
19
21
|
import { defaultEmotionCache } from '@hitachivantara/uikit-react-shared';
|
|
20
22
|
import { DialogActionsProps } from '@mui/material/DialogActions';
|
|
@@ -39,8 +41,8 @@ import { HvBreakpoints } from '@hitachivantara/uikit-styles';
|
|
|
39
41
|
import { HvCategoricalColor } from '@hitachivantara/uikit-styles';
|
|
40
42
|
import { HvColor } from '@hitachivantara/uikit-styles';
|
|
41
43
|
import { HvColorAny } from '@hitachivantara/uikit-styles';
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
+
import { HvExtraDeepProps } from '@hitachivantara/uikit-react-shared';
|
|
45
|
+
import { HvExtraProps } from '@hitachivantara/uikit-react-shared';
|
|
44
46
|
import { HvSemanticColor } from '@hitachivantara/uikit-styles';
|
|
45
47
|
import { HvSize } from '@hitachivantara/uikit-styles';
|
|
46
48
|
import { HvSupportColor } from '@hitachivantara/uikit-styles';
|
|
@@ -69,8 +71,7 @@ import { PopperProps } from 'react-popper';
|
|
|
69
71
|
import { PropGetter } from 'react-table';
|
|
70
72
|
import { PropsWithoutRef } from 'react';
|
|
71
73
|
import { RadioProps } from '@mui/material/Radio';
|
|
72
|
-
import
|
|
73
|
-
import * as React_3 from 'react';
|
|
74
|
+
import * as React_2 from 'react';
|
|
74
75
|
import { ReactElement } from 'react';
|
|
75
76
|
import { ReactNode } from 'react';
|
|
76
77
|
import { ReducerTableState } from 'react-table';
|
|
@@ -104,7 +105,6 @@ import { theme } from '@hitachivantara/uikit-styles';
|
|
|
104
105
|
import { themes } from '@hitachivantara/uikit-styles';
|
|
105
106
|
import { TooltipProps } from '@mui/material/Tooltip';
|
|
106
107
|
import { TransitionProps } from '@mui/material/transitions';
|
|
107
|
-
import useCarousel from 'embla-carousel-react';
|
|
108
108
|
import { UseColumnOrderInstanceProps } from 'react-table';
|
|
109
109
|
import { UseColumnOrderState } from 'react-table';
|
|
110
110
|
import { useEffect } from 'react';
|
|
@@ -403,7 +403,7 @@ export declare interface Breakpoint {
|
|
|
403
403
|
spacing?: Spacing;
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
export declare const buildAriaPropsFromContext: (props: any, context: any, isInvalid: any, inputId: any) =>
|
|
406
|
+
export declare const buildAriaPropsFromContext: (props: any, context: any, isInvalid: any, inputId: any) => default_2.AriaAttributes;
|
|
407
407
|
|
|
408
408
|
export declare const buildFormElementPropsFromContext: (name: any, disabled: any, readOnly: any, required: any, context: any) => {
|
|
409
409
|
name: any;
|
|
@@ -2367,7 +2367,7 @@ export declare interface HvCarouselProps extends HvBaseProps<HTMLDivElement, "ti
|
|
|
2367
2367
|
/** Thumbnails position. */
|
|
2368
2368
|
thumbnailsPosition?: "top" | "bottom";
|
|
2369
2369
|
/** Carousel configuration options. @see https://www.embla-carousel.com/api/options/ */
|
|
2370
|
-
carouselOptions?: Parameters<typeof
|
|
2370
|
+
carouselOptions?: Parameters<typeof default_3>[0];
|
|
2371
2371
|
/** Function that renders the thumbnail. */
|
|
2372
2372
|
renderThumbnail?: (index: number) => React.ReactNode;
|
|
2373
2373
|
/** The callback fired when the active slide changes. */
|
|
@@ -3396,13 +3396,13 @@ export declare type HvEmptyStateClasses = ExtractNames<typeof useClasses_67>;
|
|
|
3396
3396
|
|
|
3397
3397
|
export declare interface HvEmptyStateProps extends HvBaseProps<HTMLDivElement, "title"> {
|
|
3398
3398
|
/** Icon to be presented. */
|
|
3399
|
-
icon:
|
|
3399
|
+
icon: default_2.ReactNode;
|
|
3400
3400
|
/** The title to be shown. */
|
|
3401
|
-
title?:
|
|
3401
|
+
title?: default_2.ReactNode;
|
|
3402
3402
|
/** The message to be shown. */
|
|
3403
|
-
message?:
|
|
3403
|
+
message?: default_2.ReactNode;
|
|
3404
3404
|
/** The action message to be shown. */
|
|
3405
|
-
action?:
|
|
3405
|
+
action?: default_2.ReactNode;
|
|
3406
3406
|
/** A Jss Object used to override or extend the styles applied to the empty state component. */
|
|
3407
3407
|
classes?: HvEmptyStateClasses;
|
|
3408
3408
|
}
|
|
@@ -3739,38 +3739,38 @@ export declare const HvFormElement: {
|
|
|
3739
3739
|
|
|
3740
3740
|
export declare type HvFormElementClasses = ExtractNames<typeof useClasses_7>;
|
|
3741
3741
|
|
|
3742
|
-
export declare const HvFormElementContext:
|
|
3742
|
+
export declare const HvFormElementContext: default_2.Context<{
|
|
3743
3743
|
elementId?: string | undefined;
|
|
3744
3744
|
elementDisabled?: boolean | undefined;
|
|
3745
3745
|
elementRequired?: boolean | undefined;
|
|
3746
3746
|
elementStatus?: string | undefined;
|
|
3747
3747
|
}>;
|
|
3748
3748
|
|
|
3749
|
-
export declare const HvFormElementContextConsumer:
|
|
3749
|
+
export declare const HvFormElementContextConsumer: default_2.Consumer<{
|
|
3750
3750
|
elementId?: string | undefined;
|
|
3751
3751
|
elementDisabled?: boolean | undefined;
|
|
3752
3752
|
elementRequired?: boolean | undefined;
|
|
3753
3753
|
elementStatus?: string | undefined;
|
|
3754
3754
|
}>;
|
|
3755
3755
|
|
|
3756
|
-
export declare const HvFormElementContextProvider:
|
|
3756
|
+
export declare const HvFormElementContextProvider: default_2.Provider<{
|
|
3757
3757
|
elementId?: string | undefined;
|
|
3758
3758
|
elementDisabled?: boolean | undefined;
|
|
3759
3759
|
elementRequired?: boolean | undefined;
|
|
3760
3760
|
elementStatus?: string | undefined;
|
|
3761
3761
|
}>;
|
|
3762
3762
|
|
|
3763
|
-
export declare const HvFormElementDescriptorsContext:
|
|
3763
|
+
export declare const HvFormElementDescriptorsContext: default_2.Context<{
|
|
3764
3764
|
input?: any;
|
|
3765
3765
|
label?: any;
|
|
3766
3766
|
}>;
|
|
3767
3767
|
|
|
3768
|
-
export declare const HvFormElementDescriptorsContextConsumer:
|
|
3768
|
+
export declare const HvFormElementDescriptorsContextConsumer: default_2.Consumer<{
|
|
3769
3769
|
input?: any;
|
|
3770
3770
|
label?: any;
|
|
3771
3771
|
}>;
|
|
3772
3772
|
|
|
3773
|
-
export declare const HvFormElementDescriptorsContextProvider:
|
|
3773
|
+
export declare const HvFormElementDescriptorsContextProvider: default_2.Provider<{
|
|
3774
3774
|
input?: any;
|
|
3775
3775
|
label?: any;
|
|
3776
3776
|
}>;
|
|
@@ -3820,11 +3820,11 @@ export declare interface HvFormElementProps extends HvBaseProps<HTMLDivElement,
|
|
|
3820
3820
|
classes?: HvFormElementClasses;
|
|
3821
3821
|
}
|
|
3822
3822
|
|
|
3823
|
-
export declare const HvFormElementValueContext:
|
|
3823
|
+
export declare const HvFormElementValueContext: default_2.Context<undefined>;
|
|
3824
3824
|
|
|
3825
|
-
export declare const HvFormElementValueContextConsumer:
|
|
3825
|
+
export declare const HvFormElementValueContextConsumer: default_2.Consumer<undefined>;
|
|
3826
3826
|
|
|
3827
|
-
export declare const HvFormElementValueContextProvider:
|
|
3827
|
+
export declare const HvFormElementValueContextProvider: default_2.Provider<undefined>;
|
|
3828
3828
|
|
|
3829
3829
|
export declare type HvFormStatus = "standBy" | "valid" | "invalid" | "empty";
|
|
3830
3830
|
|
|
@@ -4960,129 +4960,7 @@ export declare const hvQueryBuilderDefaultCombinators: {
|
|
|
4960
4960
|
label: string;
|
|
4961
4961
|
}[];
|
|
4962
4962
|
|
|
4963
|
-
export declare const hvQueryBuilderDefaultLabels:
|
|
4964
|
-
query: {
|
|
4965
|
-
delete: {
|
|
4966
|
-
ariaLabel: string;
|
|
4967
|
-
tooltip: string;
|
|
4968
|
-
dialogTitle: string;
|
|
4969
|
-
dialogMessage: string;
|
|
4970
|
-
dialogConfirm: string;
|
|
4971
|
-
dialogCancel: string;
|
|
4972
|
-
dialogCloseTooltip: string;
|
|
4973
|
-
};
|
|
4974
|
-
};
|
|
4975
|
-
rule: {
|
|
4976
|
-
attribute: {
|
|
4977
|
-
label: string;
|
|
4978
|
-
placeholder: string;
|
|
4979
|
-
exists: string;
|
|
4980
|
-
};
|
|
4981
|
-
operator: {
|
|
4982
|
-
label: string;
|
|
4983
|
-
placeholder: string;
|
|
4984
|
-
};
|
|
4985
|
-
value: {
|
|
4986
|
-
distance: {
|
|
4987
|
-
label: string;
|
|
4988
|
-
connectorText: string;
|
|
4989
|
-
button: string;
|
|
4990
|
-
validation: {
|
|
4991
|
-
required: string;
|
|
4992
|
-
invalid: string;
|
|
4993
|
-
};
|
|
4994
|
-
};
|
|
4995
|
-
text: {
|
|
4996
|
-
label: string;
|
|
4997
|
-
placeholder: string;
|
|
4998
|
-
validation: {
|
|
4999
|
-
required: string;
|
|
5000
|
-
};
|
|
5001
|
-
};
|
|
5002
|
-
boolean: {
|
|
5003
|
-
label: string;
|
|
5004
|
-
placeholder: string;
|
|
5005
|
-
options: {
|
|
5006
|
-
true: string;
|
|
5007
|
-
false: string;
|
|
5008
|
-
};
|
|
5009
|
-
};
|
|
5010
|
-
numeric: {
|
|
5011
|
-
label: string;
|
|
5012
|
-
placeholder: string;
|
|
5013
|
-
validation: {
|
|
5014
|
-
required: string;
|
|
5015
|
-
invalid: string;
|
|
5016
|
-
equal: string;
|
|
5017
|
-
greaterThan: string;
|
|
5018
|
-
};
|
|
5019
|
-
range: {
|
|
5020
|
-
leftLabel: string;
|
|
5021
|
-
rightLabel: string;
|
|
5022
|
-
};
|
|
5023
|
-
};
|
|
5024
|
-
datetime: {
|
|
5025
|
-
dateLabel: string;
|
|
5026
|
-
datePlaceholder: string;
|
|
5027
|
-
timeLabel: string;
|
|
5028
|
-
timePlaceholder: string;
|
|
5029
|
-
startDateLabel: string;
|
|
5030
|
-
startDatePlaceholder: string;
|
|
5031
|
-
startTimeLabel: string;
|
|
5032
|
-
startTimePlaceholder: string;
|
|
5033
|
-
endDateLabel: string;
|
|
5034
|
-
endDatePlaceholder: string;
|
|
5035
|
-
endTimeLabel: string;
|
|
5036
|
-
endTimePlaceholder: string;
|
|
5037
|
-
validation: {
|
|
5038
|
-
required: string;
|
|
5039
|
-
invalidInterval: string;
|
|
5040
|
-
};
|
|
5041
|
-
};
|
|
5042
|
-
};
|
|
5043
|
-
delete: {
|
|
5044
|
-
ariaLabel: string;
|
|
5045
|
-
tooltip: string;
|
|
5046
|
-
dialogTitle: string;
|
|
5047
|
-
dialogMessage: string;
|
|
5048
|
-
dialogConfirm: string;
|
|
5049
|
-
dialogCancel: string;
|
|
5050
|
-
dialogCloseTooltip: string;
|
|
5051
|
-
};
|
|
5052
|
-
};
|
|
5053
|
-
group: {
|
|
5054
|
-
delete: {
|
|
5055
|
-
ariaLabel: string;
|
|
5056
|
-
tooltip: string;
|
|
5057
|
-
dialogTitle: string;
|
|
5058
|
-
dialogMessage: string;
|
|
5059
|
-
dialogConfirm: string;
|
|
5060
|
-
dialogCancel: string;
|
|
5061
|
-
dialogCloseTooltip: string;
|
|
5062
|
-
};
|
|
5063
|
-
reset: {
|
|
5064
|
-
ariaLabel: string;
|
|
5065
|
-
tooltip: string;
|
|
5066
|
-
dialogTitle: string;
|
|
5067
|
-
dialogMessage: string;
|
|
5068
|
-
dialogConfirm: string;
|
|
5069
|
-
dialogCancel: string;
|
|
5070
|
-
dialogCloseTooltip: string;
|
|
5071
|
-
};
|
|
5072
|
-
addRule: {
|
|
5073
|
-
label: string;
|
|
5074
|
-
};
|
|
5075
|
-
addGroup: {
|
|
5076
|
-
label: string;
|
|
5077
|
-
};
|
|
5078
|
-
};
|
|
5079
|
-
empty: {
|
|
5080
|
-
title: string;
|
|
5081
|
-
createCondition: string;
|
|
5082
|
-
createGroup: string;
|
|
5083
|
-
spacer: string;
|
|
5084
|
-
};
|
|
5085
|
-
};
|
|
4963
|
+
export declare const hvQueryBuilderDefaultLabels: HvQueryBuilderLabels;
|
|
5086
4964
|
|
|
5087
4965
|
export declare const hvQueryBuilderDefaultOperators: {
|
|
5088
4966
|
numeric: {
|
|
@@ -5235,7 +5113,7 @@ export declare interface HvQueryBuilderProps {
|
|
|
5235
5113
|
/** Max depth of nested query groups. */
|
|
5236
5114
|
maxDepth?: number;
|
|
5237
5115
|
/** Object containing all the labels. */
|
|
5238
|
-
labels?: HvQueryBuilderLabels
|
|
5116
|
+
labels?: DeepPartial<HvQueryBuilderLabels>;
|
|
5239
5117
|
/** Whether the query builder is in read-only mode. */
|
|
5240
5118
|
readOnly?: boolean;
|
|
5241
5119
|
/**
|
|
@@ -11279,18 +11157,18 @@ export declare function useHvTreeItem(nodeId: string): {
|
|
|
11279
11157
|
expanded: boolean;
|
|
11280
11158
|
selected: boolean;
|
|
11281
11159
|
focused: boolean;
|
|
11282
|
-
handleExpansion: (event:
|
|
11283
|
-
handleSelection: (event:
|
|
11284
|
-
preventSelection: (event:
|
|
11160
|
+
handleExpansion: (event: React_2.MouseEvent<HTMLDivElement>) => void;
|
|
11161
|
+
handleSelection: (event: React_2.MouseEvent<HTMLDivElement>) => void;
|
|
11162
|
+
preventSelection: (event: React_2.MouseEvent<HTMLDivElement>) => void;
|
|
11285
11163
|
};
|
|
11286
11164
|
|
|
11287
11165
|
export declare const useImageLoaded: (src?: string, srcSet?: string) => string | boolean;
|
|
11288
11166
|
|
|
11289
11167
|
export declare function useInstance(instance: any): void;
|
|
11290
11168
|
|
|
11291
|
-
export declare const useIsMounted: () =>
|
|
11169
|
+
export declare const useIsMounted: () => default_2.MutableRefObject<boolean>;
|
|
11292
11170
|
|
|
11293
|
-
export declare function useLabels<T>(defaultLabels: T, labels?:
|
|
11171
|
+
export declare function useLabels<T>(defaultLabels: T, labels?: DeepPartial<T>): T;
|
|
11294
11172
|
|
|
11295
11173
|
export declare type UsePaginationProps = (<D extends object = Record<string, unknown>>(hooks: Hooks<D>) => void) & {
|
|
11296
11174
|
pluginName: string;
|
|
@@ -11352,8 +11230,8 @@ declare interface UseTreeViewContextValueBuilderParameters {
|
|
|
11352
11230
|
declare interface UseTreeViewExpansionInstance {
|
|
11353
11231
|
isNodeExpanded: (nodeId: string) => boolean;
|
|
11354
11232
|
isNodeExpandable: (nodeId: string) => boolean;
|
|
11355
|
-
toggleNodeExpansion: (event:
|
|
11356
|
-
expandAllSiblings: (event:
|
|
11233
|
+
toggleNodeExpansion: (event: React_2.SyntheticEvent, value: string) => void;
|
|
11234
|
+
expandAllSiblings: (event: React_2.KeyboardEvent<HTMLUListElement>, nodeId: string) => void;
|
|
11357
11235
|
}
|
|
11358
11236
|
|
|
11359
11237
|
declare interface UseTreeViewExpansionParameters {
|
|
@@ -11373,12 +11251,12 @@ declare interface UseTreeViewExpansionParameters {
|
|
|
11373
11251
|
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
11374
11252
|
* @param {array} nodeIds The ids of the expanded nodes.
|
|
11375
11253
|
*/
|
|
11376
|
-
onNodeToggle?: (event:
|
|
11254
|
+
onNodeToggle?: (event: React_2.SyntheticEvent, nodeIds: string[]) => void;
|
|
11377
11255
|
}
|
|
11378
11256
|
|
|
11379
11257
|
declare interface UseTreeViewFocusInstance {
|
|
11380
11258
|
isNodeFocused: (nodeId: string) => boolean;
|
|
11381
|
-
focusNode: (event:
|
|
11259
|
+
focusNode: (event: React_2.SyntheticEvent, nodeId: string | null) => void;
|
|
11382
11260
|
}
|
|
11383
11261
|
|
|
11384
11262
|
declare interface UseTreeViewFocusParameters {
|
|
@@ -11388,7 +11266,7 @@ declare interface UseTreeViewFocusParameters {
|
|
|
11388
11266
|
* @param {string} nodeId The id of the node focused.
|
|
11389
11267
|
* @param {string} value of the focused node.
|
|
11390
11268
|
*/
|
|
11391
|
-
onNodeFocus?: (event:
|
|
11269
|
+
onNodeFocus?: (event: React_2.SyntheticEvent, nodeId: string) => void;
|
|
11392
11270
|
}
|
|
11393
11271
|
|
|
11394
11272
|
declare interface UseTreeViewKeyboardNavigationInstance {
|
|
@@ -11414,10 +11292,10 @@ declare interface UseTreeViewNodesParameters {
|
|
|
11414
11292
|
|
|
11415
11293
|
declare interface UseTreeViewSelectionInstance {
|
|
11416
11294
|
isNodeSelected: (nodeId: string) => boolean;
|
|
11417
|
-
selectNode: (event:
|
|
11418
|
-
selectRange: (event:
|
|
11419
|
-
rangeSelectToFirst: (event:
|
|
11420
|
-
rangeSelectToLast: (event:
|
|
11295
|
+
selectNode: (event: React_2.SyntheticEvent, nodeId: string, multiple?: boolean) => void;
|
|
11296
|
+
selectRange: (event: React_2.SyntheticEvent, nodes: TreeViewItemRange, stacked?: boolean) => void;
|
|
11297
|
+
rangeSelectToFirst: (event: React_2.KeyboardEvent<HTMLUListElement>, nodeId: string) => void;
|
|
11298
|
+
rangeSelectToLast: (event: React_2.KeyboardEvent<HTMLUListElement>, nodeId: string) => void;
|
|
11421
11299
|
}
|
|
11422
11300
|
|
|
11423
11301
|
declare interface UseTreeViewSelectionParameters<Multiple extends boolean | undefined> {
|
|
@@ -11448,7 +11326,7 @@ declare interface UseTreeViewSelectionParameters<Multiple extends boolean | unde
|
|
|
11448
11326
|
* @param {string[] | string} nodeIds Ids of the selected nodes. When `multiSelect` is true
|
|
11449
11327
|
* this is an array of strings; when false (default) a string.
|
|
11450
11328
|
*/
|
|
11451
|
-
onNodeSelect?: (event:
|
|
11329
|
+
onNodeSelect?: (event: React_2.SyntheticEvent, nodeIds: Exclude<TreeViewSelectionValue<Multiple>, null>) => void;
|
|
11452
11330
|
}
|
|
11453
11331
|
|
|
11454
11332
|
export declare const useUniqueId: (deterministicId?: string, idPrefix?: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.64.
|
|
3
|
+
"version": "5.64.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -62,8 +62,7 @@
|
|
|
62
62
|
"access": "public",
|
|
63
63
|
"directory": "package"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
-
"main": "dist/cjs/index.cjs",
|
|
65
|
+
"gitHead": "0e08b9389eab092cbaecf55b54cc37406e81f797",
|
|
67
66
|
"exports": {
|
|
68
67
|
".": {
|
|
69
68
|
"require": "./dist/cjs/index.cjs",
|