@hitachivantara/uikit-react-core 5.7.0 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +8 -8
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/Card/Content/Content.cjs +3 -3
- package/dist/cjs/components/Card/Content/Content.cjs.map +1 -1
- package/dist/cjs/components/Card/Header/Header.cjs +10 -10
- package/dist/cjs/components/Card/Header/Header.cjs.map +1 -1
- package/dist/cjs/components/Card/Media/Media.cjs +4 -4
- package/dist/cjs/components/Card/Media/Media.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +21 -20
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +7 -7
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs +7 -6
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs +4 -4
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs +12 -12
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs +7 -7
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs +3 -3
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs +8 -7
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs +9 -9
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs +16 -14
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +5 -5
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs +5 -5
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs +11 -9
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs +4 -4
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +8 -7
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs.map +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js.map +1 -1
- package/dist/esm/components/Card/Card.js +8 -8
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/Content/Content.js +3 -3
- package/dist/esm/components/Card/Content/Content.js.map +1 -1
- package/dist/esm/components/Card/Header/Header.js +10 -10
- package/dist/esm/components/Card/Header/Header.js.map +1 -1
- package/dist/esm/components/Card/Media/Media.js +4 -4
- package/dist/esm/components/Card/Media/Media.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +21 -20
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +7 -7
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.js +7 -6
- package/dist/esm/components/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/components/FilterGroup/Counter/Counter.js +4 -4
- package/dist/esm/components/FilterGroup/Counter/Counter.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js +12 -12
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterGroup.js +7 -7
- package/dist/esm/components/FilterGroup/FilterGroup.js.map +1 -1
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js +3 -3
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js.map +1 -1
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js +8 -7
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.js +9 -9
- package/dist/esm/components/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js +16 -14
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +5 -5
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +5 -5
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js +11 -9
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js +4 -4
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +8 -7
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const filterGroupClasses = require("./filterGroupClasses.cjs");
|
|
4
|
-
const clsx = require("clsx");
|
|
5
4
|
const FilterGroup_styles = require("./FilterGroup.styles.cjs");
|
|
6
5
|
const FilterGroupContext = require("./FilterGroupContext.cjs");
|
|
7
6
|
const react = require("@emotion/react");
|
|
@@ -60,7 +59,8 @@ const HvFilterGroup = ({
|
|
|
60
59
|
const canShowError = status !== void 0 || required;
|
|
61
60
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ClassNames, {
|
|
62
61
|
children: ({
|
|
63
|
-
css
|
|
62
|
+
css,
|
|
63
|
+
cx
|
|
64
64
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormElement.HvFormElement, {
|
|
65
65
|
id,
|
|
66
66
|
name,
|
|
@@ -68,18 +68,18 @@ const HvFilterGroup = ({
|
|
|
68
68
|
status,
|
|
69
69
|
disabled,
|
|
70
70
|
required,
|
|
71
|
-
className:
|
|
71
|
+
className: cx(filterGroupClasses.default.root, className, classes == null ? void 0 : classes.root),
|
|
72
72
|
...others,
|
|
73
73
|
children: [(hasLabel || hasDescription) && /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
74
|
-
className:
|
|
74
|
+
className: cx(filterGroupClasses.default.labelContainer, css(FilterGroup_styles.styles.labelContainer), classes == null ? void 0 : classes.labelContainer),
|
|
75
75
|
children: [hasLabel && /* @__PURE__ */ jsxRuntime.jsx(Label.HvLabel, {
|
|
76
76
|
id: setId.setId(elementId, "label"),
|
|
77
77
|
htmlFor: setId.setId(elementId, "input"),
|
|
78
78
|
label,
|
|
79
|
-
className:
|
|
79
|
+
className: cx(filterGroupClasses.default.label, css(FilterGroup_styles.styles.label), classes == null ? void 0 : classes.label)
|
|
80
80
|
}), hasDescription && /* @__PURE__ */ jsxRuntime.jsx(InfoMessage.HvInfoMessage, {
|
|
81
81
|
id: setId.setId(elementId, "description"),
|
|
82
|
-
className:
|
|
82
|
+
className: cx(filterGroupClasses.default.description, classes == null ? void 0 : classes.description),
|
|
83
83
|
children: description
|
|
84
84
|
})]
|
|
85
85
|
}), /* @__PURE__ */ jsxRuntime.jsxs(FilterGroupContext.HvFilterGroupProvider, {
|
|
@@ -105,7 +105,7 @@ const HvFilterGroup = ({
|
|
|
105
105
|
}), canShowError && /* @__PURE__ */ jsxRuntime.jsx(WarningText.HvWarningText, {
|
|
106
106
|
id: setId.setId(elementId, "error"),
|
|
107
107
|
disableBorder: true,
|
|
108
|
-
className:
|
|
108
|
+
className: cx(filterGroupClasses.default.error, classes == null ? void 0 : classes.error),
|
|
109
109
|
children: validationMessage
|
|
110
110
|
})]
|
|
111
111
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterGroup.cjs","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components\";\nimport filterGroupClasses, { HvFilterGroupClasses } from \"./filterGroupClasses\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { clsx } from \"clsx\";\nimport { useControlled, useLabels, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./FilterGroup.styles\";\nimport { setId } from \"@core/utils\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport type HvFilterGroupValue = (string | number)[][];\n\nexport interface HvFilterGroupLabels {\n /** Apply button label. */\n applyLabel?: string;\n /** Cancel button label. */\n cancelLabel?: string;\n /** Cancel button label. */\n clearLabel?: string;\n /** Placeholder label. */\n placeholder?: string;\n /** SearchBox placeholder label. */\n searchBoxPlaceholder?: string;\n /** Select All placeholder label. */\n selectAll?: string;\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction?: string;\n}\n\nexport type HvFilterGroupFilters = {\n id: string;\n name: string;\n data: {\n id: string | number;\n name: string;\n }[];\n}[];\n\nexport type HvFilterGroupHorizontalPlacement = \"left\" | \"right\";\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = ({\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes,\n ...others\n}: HvFilterGroupProps) => {\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={clsx(className, classes?.root, filterGroupClasses.root)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div\n className={clsx(\n classes?.labelContainer,\n filterGroupClasses.labelContainer,\n css(styles.labelContainer)\n )}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={clsx(\n classes?.label,\n filterGroupClasses.label,\n css(styles.label)\n )}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={clsx(\n classes?.description,\n filterGroupClasses.description\n )}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={clsx(classes?.error, filterGroupClasses.error)}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n )}\n </ClassNames>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","others","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","ClassNames","children","css","HvFormElement","clsx","root","filterGroupClasses","labelContainer","styles","_jsx","HvLabel","setId","htmlFor","HvInfoMessage","_jsxs","HvFilterGroupProvider","HvFilterGroupContent","variableWidth","placement","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;;;;;;;AAk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,CAAA;AAAA,MAAA,CACqB,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGjB;AAEjB;;"}
|
|
1
|
+
{"version":3,"file":"FilterGroup.cjs","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components\";\nimport filterGroupClasses, { HvFilterGroupClasses } from \"./filterGroupClasses\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { useControlled, useLabels, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./FilterGroup.styles\";\nimport { setId } from \"@core/utils\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport type HvFilterGroupValue = (string | number)[][];\n\nexport interface HvFilterGroupLabels {\n /** Apply button label. */\n applyLabel?: string;\n /** Cancel button label. */\n cancelLabel?: string;\n /** Cancel button label. */\n clearLabel?: string;\n /** Placeholder label. */\n placeholder?: string;\n /** SearchBox placeholder label. */\n searchBoxPlaceholder?: string;\n /** Select All placeholder label. */\n selectAll?: string;\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction?: string;\n}\n\nexport type HvFilterGroupFilters = {\n id: string;\n name: string;\n data: {\n id: string | number;\n name: string;\n }[];\n}[];\n\nexport type HvFilterGroupHorizontalPlacement = \"left\" | \"right\";\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = ({\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes,\n ...others\n}: HvFilterGroupProps) => {\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(filterGroupClasses.root, className, classes?.root)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div\n className={cx(\n filterGroupClasses.labelContainer,\n css(styles.labelContainer),\n classes?.labelContainer\n )}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={cx(\n filterGroupClasses.label,\n css(styles.label),\n classes?.label\n )}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={cx(\n filterGroupClasses.description,\n classes?.description\n )}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={cx(filterGroupClasses.error, classes?.error)}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n )}\n </ClassNames>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","others","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","ClassNames","children","css","cx","HvFormElement","filterGroupClasses","root","labelContainer","styles","_jsx","HvLabel","setId","htmlFor","HvInfoMessage","_jsxs","HvFilterGroupProvider","HvFilterGroupContent","variableWidth","placement","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;;;;;;AAiHA,MAAMA,iBAAsC;AAAA,EAC1CC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,sBAAsB;AAAA,EACtBC,WAAW;AAAA,EACXC,2BAA2B;AAC7B;AAOO,MAAMC,gBAAgBA,CAAC;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,WAAW;AAAA,EACXC;AAAAA,EACA,cAAcC;AAAAA,EACd,mBAAmBC;AAAAA,EACnBC;AAAAA,EACA,oBAAoBC;AAAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,QAAQC;AAAAA,EACRC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,sBAAsB;AAAA,EACtBC,gB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jC,aACnBiB,mCAASjB,WAAW;AAAA,UACpB6B,UAED7B;AAAAA,QAAAA,CAEJ,CAAA;AAAA,MAAA,CAEJ,GACD0C,2BAAAA,KAACC,0CAAqB;AAAA,QACpBlC;AAAAA,QACAC;AAAAA,QACAC;AAAAA,QAAiBkB,UAAA,CAEjBQ,2BAAAA,IAACO,oCAAoB;AAAA,UACnBnD,IAAI4B;AAAAA,UACJzB;AAAAA,UACAiB;AAAAA,UACAgC,eAAa;AAAA,UACbC,WAAWlC;AAAAA,UACXE;AAAAA,UACA,cAAYhB;AAAAA,UACZ,mBAAiBC;AAAAA,UACjBM;AAAAA,UACAH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,UACAG;AAAAA,UACAQ;AAAAA,UAAe,GACXC;AAAAA,QAAAA,CAAkB,GAEvBU,gBACCW,2BAAAA,IAACU,2BAAa;AAAA,UACZtD,IAAI8C,MAAAA,MAAMlB,WAAW,OAAO;AAAA,UAC5B2B,eAAa;AAAA,UACbxD,WAAWuC,GAAGE,mBAAAA,QAAmBgB,OAAOhC,mCAASgC,KAAK;AAAA,UAAEpB,UAEvDV;AAAAA,QAAAA,CAEJ,CAAA;AAAA,MAAA,CACqB,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGjB;AAEjB;;"}
|
|
@@ -4,7 +4,6 @@ const React = require("react");
|
|
|
4
4
|
const FilterGroupContext = require("../FilterGroupContext.cjs");
|
|
5
5
|
const react = require("@emotion/react");
|
|
6
6
|
const LeftPanel_styles = require("./LeftPanel.styles.cjs");
|
|
7
|
-
const clsx = require("clsx");
|
|
8
7
|
const leftPanelClasses = require("./leftPanelClasses.cjs");
|
|
9
8
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
9
|
const Counter = require("../Counter/Counter.cjs");
|
|
@@ -26,7 +25,8 @@ const HvFilterGroupLeftPanel = ({
|
|
|
26
25
|
} = React.useContext(FilterGroupContext.HvFilterGroupContext);
|
|
27
26
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ClassNames, {
|
|
28
27
|
children: ({
|
|
29
|
-
css
|
|
28
|
+
css,
|
|
29
|
+
cx
|
|
30
30
|
}) => /* @__PURE__ */ jsxRuntime.jsx(Panel.HvPanel, {
|
|
31
31
|
id: setId.setId(id, "leftPanel"),
|
|
32
32
|
className,
|
|
@@ -38,7 +38,7 @@ const HvFilterGroupLeftPanel = ({
|
|
|
38
38
|
const ItemText = wrapperTooltip.wrapperTooltip(true, group.name, group.name);
|
|
39
39
|
return /* @__PURE__ */ jsxRuntime.jsx(ListItem.HvListItem, {
|
|
40
40
|
id: group.id,
|
|
41
|
-
className:
|
|
41
|
+
className: cx(leftPanelClasses.default.listItem, css(LeftPanel_styles.styles.listItem), classes == null ? void 0 : classes.listItem),
|
|
42
42
|
onClick: () => setActiveGroup(index),
|
|
43
43
|
selected: filterOptions[activeGroup].id === group.id,
|
|
44
44
|
endAdornment: /* @__PURE__ */ jsxRuntime.jsx(Counter.HvFilterGroupCounter, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeftPanel.cjs","sources":["../../../../../src/components/FilterGroup/LeftPanel/LeftPanel.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvListContainer, HvListItem, HvPanel } from \"@core/components\";\nimport { setId, wrapperTooltip } from \"@core/utils\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./LeftPanel.styles\";\nimport
|
|
1
|
+
{"version":3,"file":"LeftPanel.cjs","sources":["../../../../../src/components/FilterGroup/LeftPanel/LeftPanel.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvListContainer, HvListItem, HvPanel } from \"@core/components\";\nimport { setId, wrapperTooltip } from \"@core/utils\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./LeftPanel.styles\";\nimport filterGroupLeftPanelClasses, {\n HvFilterGroupLeftPanelClasses,\n} from \"./leftPanelClasses\";\n\nexport interface HvFilterGroupLeftPanelProps {\n id?: string;\n className?: string;\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupLeftPanelClasses;\n}\n\nexport const HvFilterGroupLeftPanel = ({\n id,\n className,\n emptyElement,\n classes,\n}: HvFilterGroupLeftPanelProps) => {\n const { filterOptions, activeGroup, setActiveGroup } =\n useContext(HvFilterGroupContext);\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvPanel id={setId(id, \"leftPanel\")} className={className}>\n {filterOptions.length > 0 ? (\n <HvListContainer\n id={setId(id, \"leftPanel-list\")}\n condensed\n interactive\n >\n {filterOptions.map((group, index) => {\n const ItemText = wrapperTooltip(true, group.name, group.name);\n\n return (\n <HvListItem\n id={group.id}\n key={group.name}\n className={cx(\n filterGroupLeftPanelClasses.listItem,\n css(styles.listItem),\n classes?.listItem\n )}\n onClick={() => setActiveGroup(index)}\n selected={filterOptions[activeGroup].id === group.id}\n endAdornment={<HvFilterGroupCounter id={group.id} />}\n >\n <ItemText />\n </HvListItem>\n );\n })}\n </HvListContainer>\n ) : (\n emptyElement\n )}\n </HvPanel>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupLeftPanel","id","className","emptyElement","classes","filterOptions","activeGroup","setActiveGroup","useContext","HvFilterGroupContext","ClassNames","children","css","cx","HvPanel","setId","length","HvListContainer","condensed","interactive","map","group","index","ItemText","wrapperTooltip","name","HvListItem","filterGroupLeftPanelClasses","listItem","styles","onClick","selected","endAdornment","HvFilterGroupCounter","_jsx"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,yBAAyBA,CAAC;AAAA,EACrCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAC2B,MAAM;AAC3B,QAAA;AAAA,IAAEC;AAAAA,IAAeC;AAAAA,IAAaC;AAAAA,EAAAA,IAClCC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAEjC,wCACGC,MAAAA,YAAU;AAAA,IAAAC,UACRA,CAAC;AAAA,MAAEC;AAAAA,MAAKC;AAAAA,IAAAA,qCACNC,MAAAA,SAAO;AAAA,MAACb,IAAIc,MAAAA,MAAMd,IAAI,WAAW;AAAA,MAAGC;AAAAA,MAAqBS,UACvDN,cAAcW,SAAS,mCACrBC,cAAAA,iBAAe;AAAA,QACdhB,IAAIc,MAAAA,MAAMd,IAAI,gBAAgB;AAAA,QAC9BiB,WAAS;AAAA,QACTC,aAAW;AAAA,QAAAR,UAEVN,cAAce,IAAI,CAACC,OAAOC,UAAU;AACnC,gBAAMC,WAAWC,eAAAA,eAAe,MAAMH,MAAMI,MAAMJ,MAAMI,IAAI;AAE5D,gDACGC,SAAAA,YAAU;AAAA,YACTzB,IAAIoB,MAAMpB;AAAAA,YAEVC,WAAWW,GACTc,iBAA4BC,QAAAA,UAC5BhB,IAAIiB,iBAAAA,OAAOD,QAAQ,GACnBxB,mCAASwB,QAAQ;AAAA,YAEnBE,SAASA,MAAMvB,eAAee,KAAK;AAAA,YACnCS,UAAU1B,cAAcC,WAAW,EAAEL,OAAOoB,MAAMpB;AAAAA,YAClD+B,6CAAeC,8BAAoB;AAAA,cAAChC,IAAIoB,MAAMpB;AAAAA,YAAAA,CAAO;AAAA,YAAAU,UAErDuB,2BAAAA,IAACX,UAAQ,EAAA;AAAA,UAAA,GAVJF,MAAMI,IAAI;AAAA,QAAA,CAapB;AAAA,MAAC,CAAA,IAGJtB;AAAAA,IAAAA,CACD;AAAA,EAAA,CAGM;AAEjB;;"}
|
|
@@ -5,7 +5,6 @@ const FilterGroupContext = require("../FilterGroupContext.cjs");
|
|
|
5
5
|
const cloneDeep = require("lodash/cloneDeep");
|
|
6
6
|
const react = require("@emotion/react");
|
|
7
7
|
const RightPanel_styles = require("./RightPanel.styles.cjs");
|
|
8
|
-
const clsx = require("clsx");
|
|
9
8
|
const rightPanelClasses = require("./rightPanelClasses.cjs");
|
|
10
9
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
10
|
const Typography = require("../../Typography/Typography.cjs");
|
|
@@ -88,14 +87,15 @@ const HvFilterGroupRightPanel = ({
|
|
|
88
87
|
});
|
|
89
88
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ClassNames, {
|
|
90
89
|
children: ({
|
|
91
|
-
css
|
|
90
|
+
css,
|
|
91
|
+
cx
|
|
92
92
|
}) => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
93
|
-
className:
|
|
93
|
+
className: cx(rightPanelClasses.default.selectAllContainer, css(RightPanel_styles.styles.selectAllContainer), classes == null ? void 0 : classes.selectAllContainer),
|
|
94
94
|
children: /* @__PURE__ */ jsxRuntime.jsx(CheckBox.HvCheckBox, {
|
|
95
95
|
id: setId.setId(id, "select-all"),
|
|
96
96
|
label: defaultLabel,
|
|
97
97
|
onChange: () => handleSelectAll(),
|
|
98
|
-
className:
|
|
98
|
+
className: cx(rightPanelClasses.default.selectAll, css(RightPanel_styles.styles.selectAll), classes == null ? void 0 : classes.selectAll),
|
|
99
99
|
indeterminate: anySelected && !allSelected,
|
|
100
100
|
checked: allSelected
|
|
101
101
|
})
|
|
@@ -104,7 +104,8 @@ const HvFilterGroupRightPanel = ({
|
|
|
104
104
|
}, [activeFilterValues == null ? void 0 : activeFilterValues.length, activeGroupOptions.length, allSelected, anySelected, handleSelectAll, id, labels]);
|
|
105
105
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ClassNames, {
|
|
106
106
|
children: ({
|
|
107
|
-
css
|
|
107
|
+
css,
|
|
108
|
+
cx
|
|
108
109
|
}) => /* @__PURE__ */ jsxRuntime.jsx(Panel.HvPanel, {
|
|
109
110
|
id: setId.setId(id, "rightPanel"),
|
|
110
111
|
className,
|
|
@@ -112,7 +113,7 @@ const HvFilterGroupRightPanel = ({
|
|
|
112
113
|
children: [/* @__PURE__ */ jsxRuntime.jsx(Input.HvInput, {
|
|
113
114
|
id: setId.setId(id, "search"),
|
|
114
115
|
classes: {
|
|
115
|
-
root:
|
|
116
|
+
root: cx(rightPanelClasses.default.search, css(RightPanel_styles.styles.search), classes == null ? void 0 : classes.search)
|
|
116
117
|
},
|
|
117
118
|
type: "search",
|
|
118
119
|
placeholder: labels == null ? void 0 : labels.searchBoxPlaceholder,
|
|
@@ -121,7 +122,7 @@ const HvFilterGroupRightPanel = ({
|
|
|
121
122
|
}), /* @__PURE__ */ jsxRuntime.jsx(SelectAll, {}), /* @__PURE__ */ jsxRuntime.jsx(List.HvList, {
|
|
122
123
|
id: setId.setId(id, "list"),
|
|
123
124
|
values: listValues,
|
|
124
|
-
className:
|
|
125
|
+
className: cx(rightPanelClasses.default.list, css(RightPanel_styles.styles.list), classes == null ? void 0 : classes.list),
|
|
125
126
|
multiSelect: true,
|
|
126
127
|
useSelector: true,
|
|
127
128
|
showSelectAll: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RightPanel.cjs","sources":["../../../../../src/components/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import {\n HvCheckBox,\n HvInput,\n HvList,\n HvPanel,\n HvTypography,\n} from \"@core/components\";\nimport { setId } from \"@core/utils\";\nimport { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./RightPanel.styles\";\nimport { clsx } from \"clsx\";\nimport filterGroupRightPanelClasses, {\n HvFilterGroupRightPanelClasses,\n} from \"./rightPanelClasses\";\n\nexport interface HvFilterGroupRightPanelProps {\n id?: string;\n className?: string;\n labels?: {\n searchBoxPlaceholder?: string;\n selectAll?: string;\n multiSelectionConjunction?: string;\n };\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupRightPanelClasses;\n}\n\nexport const HvFilterGroupRightPanel = ({\n id,\n className,\n labels,\n emptyElement,\n classes,\n}: HvFilterGroupRightPanelProps) => {\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n\n const {\n filterOptions,\n filterValues = [],\n setFilterValues,\n activeGroup,\n } = useContext(HvFilterGroupContext);\n\n const activeGroupOptions = useMemo(\n () => filterOptions[activeGroup]?.data.map((option) => option.id) || [],\n [filterOptions, activeGroup]\n );\n\n const activeFilterValues = useMemo(\n () =>\n filterValues[activeGroup]?.filter((value) =>\n activeGroupOptions.includes(value)\n ) || [],\n [filterValues, activeGroupOptions, activeGroup]\n );\n\n const listValues = useMemo(\n () =>\n filterOptions[activeGroup]?.data.map((option) => ({\n ...option,\n label: option.name,\n selected: filterValues[activeGroup]?.includes(option.id),\n isHidden:\n option.name.toLowerCase().indexOf(searchStr.toLowerCase()) < 0,\n })) || [],\n [filterOptions, filterValues, activeGroup, searchStr]\n );\n\n const updateSelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === activeGroupOptions.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n }, [activeFilterValues, activeGroupOptions]);\n\n useEffect(() => {\n updateSelectAll();\n }, [activeFilterValues, updateSelectAll]);\n\n useEffect(() => setSearchStr(\"\"), [activeGroup]);\n\n const onChangeHandler = (values) => {\n const newFilterValues = filterOptions.map((_, i) =>\n activeGroup === i\n ? values.filter((v) => v.selected).map((v) => v.id)\n : [...(filterValues[i] || [])]\n );\n setFilterValues(newFilterValues);\n };\n\n const handleSelectAll = useCallback(() => {\n const newFilterValues = cloneDeep(filterValues);\n newFilterValues[activeGroup] = anySelected ? [] : activeGroupOptions;\n\n setFilterValues(newFilterValues);\n }, [\n activeGroup,\n activeGroupOptions,\n anySelected,\n filterValues,\n setFilterValues,\n ]);\n\n /**\n * Create selectAll component.\n *\n * @returns {*}\n */\n const SelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${labels?.multiSelectionConjunction} ${activeGroupOptions.length}`}\n </>\n ) : (\n <>\n <b>{labels?.selectAll}</b>\n {` (${activeGroupOptions.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <ClassNames>\n {({ css }) => (\n <div\n className={clsx(\n filterGroupRightPanelClasses.selectAllContainer,\n css(styles.selectAllContainer),\n classes?.selectAllContainer\n )}\n >\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n className={clsx(\n filterGroupRightPanelClasses.selectAll,\n css(styles.selectAll),\n classes?.selectAll\n )}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n )}\n </ClassNames>\n );\n }, [\n activeFilterValues?.length,\n activeGroupOptions.length,\n allSelected,\n anySelected,\n handleSelectAll,\n id,\n labels,\n ]);\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvPanel id={setId(id, \"rightPanel\")} className={className}>\n {listValues.length > 0 ? (\n <>\n <HvInput\n id={setId(id, \"search\")}\n classes={{\n root: clsx(\n filterGroupRightPanelClasses.search,\n css(styles.search),\n classes?.search\n ),\n }}\n type=\"search\"\n placeholder={labels?.searchBoxPlaceholder}\n value={searchStr}\n onChange={(_, str) => setSearchStr(str)}\n />\n <SelectAll />\n <HvList\n key={activeGroup}\n id={setId(id, \"list\")}\n values={listValues}\n className={clsx(\n filterGroupRightPanelClasses.list,\n css(styles.list),\n classes?.list\n )}\n multiSelect\n useSelector\n showSelectAll={false}\n onChange={onChangeHandler}\n selectable\n condensed\n hasTooltips\n />\n </>\n ) : (\n emptyElement\n )}\n </HvPanel>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupRightPanel","id","className","labels","emptyElement","classes","searchStr","setSearchStr","useState","allSelected","setAllSelected","anySelected","setAnySelected","filterOptions","filterValues","setFilterValues","activeGroup","useContext","HvFilterGroupContext","activeGroupOptions","useMemo","data","map","option","activeFilterValues","filter","value","includes","listValues","label","name","selected","isHidden","toLowerCase","indexOf","updateSelectAll","useCallback","nbrSelected","length","hasSelection","allSelect","useEffect","onChangeHandler","values","newFilterValues","_","i","v","handleSelectAll","cloneDeep","SelectAll","defaultLabel","HvTypography","component","children","_jsxs","_Fragment","_jsx","multiSelectionConjunction","selectAll","ClassNames","css","clsx","filterGroupRightPanelClasses","selectAllContainer","styles","HvCheckBox","setId","onChange","indeterminate","checked","HvPanel","HvInput","root","search","type","placeholder","searchBoxPlaceholder","str","HvList","list","multiSelect","useSelector","showSelectAll","selectable","condensed","hasTooltips"],"mappings":";;;;;;;;;;;;;;;;;;AA8BO,MAAMA,0BAA0BA,CAAC;AAAA,EACtCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAC4B,MAAM;AAClC,QAAM,CAACC,WAAWC,YAAY,IAAIC,eAAiB,EAAE;AACrD,QAAM,CAACC,aAAaC,cAAc,IAAIF,eAAkB,KAAK;AAC7D,QAAM,CAACG,aAAaC,cAAc,IAAIJ,eAAkB,KAAK;AAEvD,QAAA;AAAA,IACJK;AAAAA,IACAC,eAAe,CAAE;AAAA,IACjBC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAEnC,QAAMC,qBAAqBC,MAAAA,QACzB,MAAA;;AAAMP,gCAAcG,WAAW,MAAzBH,mBAA4BQ,KAAKC,IAAKC,CAAWA,WAAAA,OAAOtB,QAAO,CAAA;AAAA,KACrE,CAACY,eAAeG,WAAW,CAAC;AAG9B,QAAMQ,qBAAqBJ,MAAAA,QACzB,MACEN;;AAAAA,+BAAaE,WAAW,MAAxBF,mBAA2BW,OAAQC,CACjCP,UAAAA,mBAAmBQ,SAASD,KAAK,OAC9B,CAAE;AAAA,KACT,CAACZ,cAAcK,oBAAoBH,WAAW,CAAC;AAG3CY,QAAAA,aAAaR,cACjB;;AACEP,gCAAcG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AqC,iBACA/C,IACAE,MAAM,CACP;AAED,wCACGyD,MAAAA,YAAU;AAAA,IAAAN,UACRA,CAAC;AAAA,MAAEO;AAAAA,IAAAA,qCACDU,MAAAA,SAAO;AAAA,MAACtE,IAAIkE,MAAAA,MAAMlE,IAAI,YAAY;AAAA,MAAGC;AAAAA,MAAqBoD,UACxD1B,WAAWU,SAAS,oCACnBkB,WAAAA,UAAA;AAAA,QAAAF,UAAA,CACEG,2BAAAA,IAACe,eAAO;AAAA,UACNvE,IAAIkE,MAAAA,MAAMlE,IAAI,QAAQ;AAAA,UACtBI,SAAS;AAAA,YACPoE,MAAMX,KAAAA,KACJC,kBAA6BW,QAAAA,QAC7Bb,IAAII,kBAAAA,OAAOS,MAAM,GACjBrE,mCAASqE,MAAM;AAAA,UAEnB;AAAA,UACAC,MAAK;AAAA,UACLC,aAAazE,iCAAQ0E;AAAAA,UACrBnD,OAAOpB;AAAAA,UACP8D,UAAUA,CAACvB,GAAGiC,QAAQvE,aAAauE,GAAG;AAAA,QAAA,CACtC,GACD5B,2BAAAA,IAAAA,+CACA6B,KAAAA,QAAM;AAAA,UAEL9E,IAAIkE,MAAAA,MAAMlE,IAAI,MAAM;AAAA,UACpB0C,QAAQf;AAAAA,UACR1B,WAAW4D,KAAAA,KACTC,kBAA6BiB,QAAAA,MAC7BnB,IAAII,kBAAAA,OAAOe,IAAI,GACf3E,mCAAS2E,IAAI;AAAA,UAEfC,aAAW;AAAA,UACXC,aAAW;AAAA,UACXC,eAAe;AAAA,UACff,UAAU1B;AAAAA,UACV0C,YAAU;AAAA,UACVC,WAAS;AAAA,UACTC,aAAW;AAAA,QAAA,GAdNtE,WAAW,CAehB;AAAA,MAAA,CAAA,IAGJZ;AAAAA,IAAAA,CACD;AAAA,EAAA,CAGM;AAEjB;;"}
|
|
1
|
+
{"version":3,"file":"RightPanel.cjs","sources":["../../../../../src/components/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import {\n HvCheckBox,\n HvInput,\n HvList,\n HvPanel,\n HvTypography,\n} from \"@core/components\";\nimport { setId } from \"@core/utils\";\nimport { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./RightPanel.styles\";\nimport filterGroupRightPanelClasses, {\n HvFilterGroupRightPanelClasses,\n} from \"./rightPanelClasses\";\n\nexport interface HvFilterGroupRightPanelProps {\n id?: string;\n className?: string;\n labels?: {\n searchBoxPlaceholder?: string;\n selectAll?: string;\n multiSelectionConjunction?: string;\n };\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupRightPanelClasses;\n}\n\nexport const HvFilterGroupRightPanel = ({\n id,\n className,\n labels,\n emptyElement,\n classes,\n}: HvFilterGroupRightPanelProps) => {\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n\n const {\n filterOptions,\n filterValues = [],\n setFilterValues,\n activeGroup,\n } = useContext(HvFilterGroupContext);\n\n const activeGroupOptions = useMemo(\n () => filterOptions[activeGroup]?.data.map((option) => option.id) || [],\n [filterOptions, activeGroup]\n );\n\n const activeFilterValues = useMemo(\n () =>\n filterValues[activeGroup]?.filter((value) =>\n activeGroupOptions.includes(value)\n ) || [],\n [filterValues, activeGroupOptions, activeGroup]\n );\n\n const listValues = useMemo(\n () =>\n filterOptions[activeGroup]?.data.map((option) => ({\n ...option,\n label: option.name,\n selected: filterValues[activeGroup]?.includes(option.id),\n isHidden:\n option.name.toLowerCase().indexOf(searchStr.toLowerCase()) < 0,\n })) || [],\n [filterOptions, filterValues, activeGroup, searchStr]\n );\n\n const updateSelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === activeGroupOptions.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n }, [activeFilterValues, activeGroupOptions]);\n\n useEffect(() => {\n updateSelectAll();\n }, [activeFilterValues, updateSelectAll]);\n\n useEffect(() => setSearchStr(\"\"), [activeGroup]);\n\n const onChangeHandler = (values) => {\n const newFilterValues = filterOptions.map((_, i) =>\n activeGroup === i\n ? values.filter((v) => v.selected).map((v) => v.id)\n : [...(filterValues[i] || [])]\n );\n setFilterValues(newFilterValues);\n };\n\n const handleSelectAll = useCallback(() => {\n const newFilterValues = cloneDeep(filterValues);\n newFilterValues[activeGroup] = anySelected ? [] : activeGroupOptions;\n\n setFilterValues(newFilterValues);\n }, [\n activeGroup,\n activeGroupOptions,\n anySelected,\n filterValues,\n setFilterValues,\n ]);\n\n /**\n * Create selectAll component.\n *\n * @returns {*}\n */\n const SelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${labels?.multiSelectionConjunction} ${activeGroupOptions.length}`}\n </>\n ) : (\n <>\n <b>{labels?.selectAll}</b>\n {` (${activeGroupOptions.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <div\n className={cx(\n filterGroupRightPanelClasses.selectAllContainer,\n css(styles.selectAllContainer),\n classes?.selectAllContainer\n )}\n >\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n className={cx(\n filterGroupRightPanelClasses.selectAll,\n css(styles.selectAll),\n classes?.selectAll\n )}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n )}\n </ClassNames>\n );\n }, [\n activeFilterValues?.length,\n activeGroupOptions.length,\n allSelected,\n anySelected,\n handleSelectAll,\n id,\n labels,\n ]);\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvPanel id={setId(id, \"rightPanel\")} className={className}>\n {listValues.length > 0 ? (\n <>\n <HvInput\n id={setId(id, \"search\")}\n classes={{\n root: cx(\n filterGroupRightPanelClasses.search,\n css(styles.search),\n classes?.search\n ),\n }}\n type=\"search\"\n placeholder={labels?.searchBoxPlaceholder}\n value={searchStr}\n onChange={(_, str) => setSearchStr(str)}\n />\n <SelectAll />\n <HvList\n key={activeGroup}\n id={setId(id, \"list\")}\n values={listValues}\n className={cx(\n filterGroupRightPanelClasses.list,\n css(styles.list),\n classes?.list\n )}\n multiSelect\n useSelector\n showSelectAll={false}\n onChange={onChangeHandler}\n selectable\n condensed\n hasTooltips\n />\n </>\n ) : (\n emptyElement\n )}\n </HvPanel>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupRightPanel","id","className","labels","emptyElement","classes","searchStr","setSearchStr","useState","allSelected","setAllSelected","anySelected","setAnySelected","filterOptions","filterValues","setFilterValues","activeGroup","useContext","HvFilterGroupContext","activeGroupOptions","useMemo","data","map","option","activeFilterValues","filter","value","includes","listValues","label","name","selected","isHidden","toLowerCase","indexOf","updateSelectAll","useCallback","nbrSelected","length","hasSelection","allSelect","useEffect","onChangeHandler","values","newFilterValues","_","i","v","handleSelectAll","cloneDeep","SelectAll","defaultLabel","HvTypography","component","children","_jsxs","_Fragment","_jsx","multiSelectionConjunction","selectAll","ClassNames","css","cx","filterGroupRightPanelClasses","selectAllContainer","styles","HvCheckBox","setId","onChange","indeterminate","checked","HvPanel","HvInput","root","search","type","placeholder","searchBoxPlaceholder","str","HvList","list","multiSelect","useSelector","showSelectAll","selectable","condensed","hasTooltips"],"mappings":";;;;;;;;;;;;;;;;;AA6BO,MAAMA,0BAA0BA,CAAC;AAAA,EACtCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAC4B,MAAM;AAClC,QAAM,CAACC,WAAWC,YAAY,IAAIC,eAAiB,EAAE;AACrD,QAAM,CAACC,aAAaC,cAAc,IAAIF,eAAkB,KAAK;AAC7D,QAAM,CAACG,aAAaC,cAAc,IAAIJ,eAAkB,KAAK;A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A,UAEL9E,IAAIkE,MAAAA,MAAMlE,IAAI,MAAM;AAAA,UACpB0C,QAAQf;AAAAA,UACR1B,WAAW4D,GACTC,kBAA6BiB,QAAAA,MAC7BnB,IAAII,kBAAAA,OAAOe,IAAI,GACf3E,mCAAS2E,IAAI;AAAA,UAEfC,aAAW;AAAA,UACXC,aAAW;AAAA,UACXC,eAAe;AAAA,UACff,UAAU1B;AAAAA,UACV0C,YAAU;AAAA,UACVC,WAAS;AAAA,UACTC,aAAW;AAAA,QAAA,GAdNtE,WAAW,CAehB;AAAA,MAAA,CAAA,IAGJZ;AAAAA,IAAAA,CACD;AAAA,EAAA,CAGM;AAEjB;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const clsx = require("clsx");
|
|
4
3
|
const react = require("@emotion/react");
|
|
5
4
|
const React = require("react");
|
|
6
5
|
const inlineEditorClasses = require("./inlineEditorClasses.cjs");
|
|
@@ -76,15 +75,16 @@ const HvInlineEditor = ({
|
|
|
76
75
|
};
|
|
77
76
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ClassNames, {
|
|
78
77
|
children: ({
|
|
79
|
-
css
|
|
78
|
+
css,
|
|
79
|
+
cx
|
|
80
80
|
}) => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
81
|
-
className:
|
|
81
|
+
className: cx(inlineEditorClasses.default.root, css(InlineEditor_styles.styles.root), className, classes == null ? void 0 : classes.root),
|
|
82
82
|
children: editMode ? /* @__PURE__ */ jsxRuntime.jsx(InputComponent, {
|
|
83
83
|
inputRef,
|
|
84
84
|
classes: {
|
|
85
|
-
root:
|
|
86
|
-
input:
|
|
87
|
-
inputBorderContainer:
|
|
85
|
+
root: cx(inlineEditorClasses.default.inputRoot, classes == null ? void 0 : classes.inputRoot),
|
|
86
|
+
input: cx(inlineEditorClasses.default.input, css(InlineEditor_styles.styles.input), classes == null ? void 0 : classes.input),
|
|
87
|
+
inputBorderContainer: cx(inlineEditorClasses.default.inputBorderContainer, css(InlineEditor_styles.styles.inputBorderContainer), classes == null ? void 0 : classes.inputBorderContainer)
|
|
88
88
|
},
|
|
89
89
|
inputProps: {
|
|
90
90
|
style: {
|
|
@@ -100,19 +100,19 @@ const HvInlineEditor = ({
|
|
|
100
100
|
}) : /* @__PURE__ */ jsxRuntime.jsxs(Button.HvButton, {
|
|
101
101
|
variant: "secondaryGhost",
|
|
102
102
|
overrideIconColors: false,
|
|
103
|
-
className:
|
|
103
|
+
className: cx(inlineEditorClasses.default.button, parseInt(lineHeight, 10) >= 28 && inlineEditorClasses.default.largeText, css(InlineEditor_styles.styles.button), parseInt(lineHeight, 10) >= 28 && css(InlineEditor_styles.styles.largeText), classes == null ? void 0 : classes.button, parseInt(lineHeight, 10) >= 28 && (classes == null ? void 0 : classes.largeText)),
|
|
104
104
|
onClick: handleClick,
|
|
105
105
|
...buttonProps,
|
|
106
106
|
children: [/* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, {
|
|
107
107
|
variant,
|
|
108
108
|
noWrap: true,
|
|
109
|
-
className:
|
|
109
|
+
className: cx(inlineEditorClasses.default.text, !value && inlineEditorClasses.default.textEmpty, css(InlineEditor_styles.styles.text), !value && css(InlineEditor_styles.styles.textEmpty), classes == null ? void 0 : classes.text, !value && (classes == null ? void 0 : classes.textEmpty)),
|
|
110
110
|
...typographyProps,
|
|
111
111
|
children: value || placeholder
|
|
112
112
|
}), /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Edit, {
|
|
113
113
|
color: "secondary_60",
|
|
114
114
|
role: "presentation",
|
|
115
|
-
className:
|
|
115
|
+
className: cx(inlineEditorClasses.default.icon, showIcon && inlineEditorClasses.default.iconVisible, css(InlineEditor_styles.styles.icon), showIcon && css(InlineEditor_styles.styles.iconVisible), classes == null ? void 0 : classes.icon, showIcon && (classes == null ? void 0 : classes.iconVisible))
|
|
116
116
|
})]
|
|
117
117
|
})
|
|
118
118
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEditor.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { ClassNames } from \"@emotion/react\";\nimport React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { HvBaseProps } from \"@core/types\";\nimport { useControlled } from \"@core/hooks\";\nimport { getVarValue, isKeypress, keyboardCodes } from \"@core/utils\";\nimport {\n HvButtonProps,\n HvTypographyVariants,\n HvTypographyProps,\n HvInput,\n HvButton,\n HvTypography,\n} from \"@core/components\";\nimport inlineEditorClasses, {\n HvInlineEditorClasses,\n} from \"./inlineEditorClasses\";\nimport { styles } from \"./InlineEditor.styles\";\nimport { HvThemeTypographyProps, theme } from \"@hitachivantara/uikit-styles\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\n\nexport interface HvInlineEditorProps\n extends HvBaseProps<HTMLDivElement, \"onBlur\" | \"onChange\"> {\n /** The value of the form element. */\n value?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Component to use as the input. The component \"inherit\" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */\n component?: React.ElementType;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n}\n\nconst getTypographyStyles = (typography): HvThemeTypographyProps => {\n let typographyStyles = {};\n Object.keys(typography).map((k) => {\n typographyStyles[k] = getVarValue(typography[k]);\n });\n return typographyStyles;\n};\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = ({\n className,\n classes,\n value: valueProp,\n defaultValue,\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n ...others\n}: HvInlineEditorProps) => {\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n\n const typographyStyles = getTypographyStyles(theme.typography[variant] || {});\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown = (event) => {\n if (isKeypress(event, keyboardCodes.Esc)) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event);\n };\n\n const handleChange = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <ClassNames>\n {({ css }) => (\n <div\n className={clsx(\n className,\n inlineEditorClasses.root,\n classes?.root,\n css(styles.root)\n )}\n >\n {editMode ? (\n <InputComponent\n inputRef={inputRef}\n classes={{\n root: clsx(classes?.inputRoot, inlineEditorClasses.inputRoot),\n input: clsx(\n classes?.input,\n inlineEditorClasses.input,\n css(styles.input)\n ),\n inputBorderContainer: clsx(\n classes?.inputBorderContainer,\n inlineEditorClasses.inputBorderContainer,\n css(styles.inputBorderContainer)\n ),\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n className={clsx(\n classes?.button,\n inlineEditorClasses.button,\n css(styles.button),\n parseInt(lineHeight as string, 10) >= 28 &&\n clsx(\n classes?.largeText,\n inlineEditorClasses.largeText,\n css(styles.largeText)\n )\n )}\n onClick={handleClick}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={clsx(\n classes?.text,\n inlineEditorClasses.text,\n css(styles.text),\n !value &&\n clsx(\n classes?.textEmpty,\n inlineEditorClasses.textEmpty,\n css(styles.textEmpty)\n )\n )}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n <Edit\n color=\"secondary_60\"\n role=\"presentation\"\n className={clsx(\n classes?.icon,\n inlineEditorClasses.icon,\n css(styles.icon),\n showIcon &&\n clsx(\n classes?.iconVisible,\n inlineEditorClasses.iconVisible,\n css(styles.iconVisible)\n )\n )}\n />\n </HvButton>\n )}\n </div>\n )}\n </ClassNames>\n );\n};\n"],"names":["getTypographyStyles","typography","typographyStyles","Object","keys","map","k","getVarValue","HvInlineEditor","className","classes","value","valueProp","defaultValue","showIcon","component","InputComponent","HvInput","variant","placeholder","onBlur","onChange","onKeyDown","buttonProps","typographyProps","others","setValue","useControlled","editMode","setEditMode","useState","cachedValue","setCachedValue","inputRef","useRef","theme","lineHeight","useLayoutEffect","input","current","focus","select","handleClick","handleBlur","event","newValue","handleKeyDown","isKeypress","keyboardCodes","Esc","handleChange","val","ClassNames","children","css","clsx","inlineEditorClasses","root","styles","_jsx","inputRoot","inputBorderContainer","inputProps","style","height","undefined","_jsxs","HvButton","overrideIconColors","button","parseInt","largeText","onClick","HvTypography","noWrap","text","textEmpty","Edit","color","role","icon","iconVisible"],"mappings":";;;;;;;;;;;;;;;;;AA8CA,MAAMA,sBAAsBA,CAACC,eAAuC;AAClE,MAAIC,mBAAmB,CAAA;AACvBC,SAAOC,KAAKH,UAAU,EAAEI,IAAKC,CAAM,MAAA;AACjCJ,qBAAiBI,CAAC,IAAIC,MAAAA,Y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B,IAAII,2BAAOa,SAAS,CAAC,CACtB;AAAA,QAELC,SAAS9B;AAAAA,QAAY,GACjBnB;AAAAA,QAAW8B,UAAA,CAEfM,2BAAAA,IAACc,yBAAY;AAAA,UACXvD;AAAAA,UACAwD,QAAM;AAAA,UACNjE,WAAW8C,KAAAA,KACT7C,mCAASiE,MACTnB,4BAAoBmB,MACpBrB,IAAII,2BAAOiB,IAAI,GACf,CAAChE,SACC4C,KAAAA,KACE7C,mCAASkE,WACTpB,oBAAAA,QAAoBoB,WACpBtB,IAAII,oBAAAA,OAAOkB,SAAS,CAAC,CACtB;AAAA,UACH,GACEpD;AAAAA,UAAe6B,UAElB1C,SAASQ;AAAAA,QAAAA,CACG,GACfwC,2BAAAA,IAACkB,sBAAI;AAAA,UACHC,OAAM;AAAA,UACNC,MAAK;AAAA,UACLtE,WAAW8C,KAAAA,KACT7C,mCAASsE,MACTxB,4BAAoBwB,MACpB1B,IAAII,2BAAOsB,IAAI,GACflE,YACEyC,UACE7C,mCAASuE,aACTzB,oBAAoByB,QAAAA,aACpB3B,IAAII,oBAAAA,OAAOuB,WAAW,CAAC,CACxB;AAAA,QAAA,CAEL,CAAA;AAAA,MAAA,CAAA;AAAA,IAAA,CAEL;AAAA,EAAA,CAGM;AAEjB;;"}
|
|
1
|
+
{"version":3,"file":"InlineEditor.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { ClassNames } from \"@emotion/react\";\nimport React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { HvBaseProps } from \"@core/types\";\nimport { useControlled } from \"@core/hooks\";\nimport { getVarValue, isKeypress, keyboardCodes } from \"@core/utils\";\nimport {\n HvButtonProps,\n HvTypographyVariants,\n HvTypographyProps,\n HvInput,\n HvButton,\n HvTypography,\n} from \"@core/components\";\nimport inlineEditorClasses, {\n HvInlineEditorClasses,\n} from \"./inlineEditorClasses\";\nimport { styles } from \"./InlineEditor.styles\";\nimport { HvThemeTypographyProps, theme } from \"@hitachivantara/uikit-styles\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\n\nexport interface HvInlineEditorProps\n extends HvBaseProps<HTMLDivElement, \"onBlur\" | \"onChange\"> {\n /** The value of the form element. */\n value?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Component to use as the input. The component \"inherit\" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */\n component?: React.ElementType;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n}\n\nconst getTypographyStyles = (typography): HvThemeTypographyProps => {\n let typographyStyles = {};\n Object.keys(typography).map((k) => {\n typographyStyles[k] = getVarValue(typography[k]);\n });\n return typographyStyles;\n};\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = ({\n className,\n classes,\n value: valueProp,\n defaultValue,\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n ...others\n}: HvInlineEditorProps) => {\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n\n const typographyStyles = getTypographyStyles(theme.typography[variant] || {});\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown = (event) => {\n if (isKeypress(event, keyboardCodes.Esc)) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event);\n };\n\n const handleChange = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <div\n className={cx(\n inlineEditorClasses.root,\n css(styles.root),\n className,\n classes?.root\n )}\n >\n {editMode ? (\n <InputComponent\n inputRef={inputRef}\n classes={{\n root: cx(inlineEditorClasses.inputRoot, classes?.inputRoot),\n input: cx(\n inlineEditorClasses.input,\n css(styles.input),\n classes?.input\n ),\n inputBorderContainer: cx(\n inlineEditorClasses.inputBorderContainer,\n css(styles.inputBorderContainer),\n classes?.inputBorderContainer\n ),\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n className={cx(\n inlineEditorClasses.button,\n parseInt(lineHeight as string, 10) >= 28 &&\n inlineEditorClasses.largeText,\n css(styles.button),\n parseInt(lineHeight as string, 10) >= 28 &&\n css(styles.largeText),\n classes?.button,\n parseInt(lineHeight as string, 10) >= 28 && classes?.largeText\n )}\n onClick={handleClick}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(\n inlineEditorClasses.text,\n !value && inlineEditorClasses.textEmpty,\n css(styles.text),\n !value && css(styles.textEmpty),\n classes?.text,\n !value && classes?.textEmpty\n )}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n <Edit\n color=\"secondary_60\"\n role=\"presentation\"\n className={cx(\n inlineEditorClasses.icon,\n showIcon && inlineEditorClasses.iconVisible,\n css(styles.icon),\n showIcon && css(styles.iconVisible),\n classes?.icon,\n showIcon && classes?.iconVisible\n )}\n />\n </HvButton>\n )}\n </div>\n )}\n </ClassNames>\n );\n};\n"],"names":["getTypographyStyles","typography","typographyStyles","Object","keys","map","k","getVarValue","HvInlineEditor","className","classes","value","valueProp","defaultValue","showIcon","component","InputComponent","HvInput","variant","placeholder","onBlur","onChange","onKeyDown","buttonProps","typographyProps","others","setValue","useControlled","editMode","setEditMode","useState","cachedValue","setCachedValue","inputRef","useRef","theme","lineHeight","useLayoutEffect","input","current","focus","select","handleClick","handleBlur","event","newValue","handleKeyDown","isKeypress","keyboardCodes","Esc","handleChange","val","ClassNames","children","css","cx","inlineEditorClasses","root","styles","_jsx","inputRoot","inputBorderContainer","inputProps","style","height","undefined","_jsxs","HvButton","overrideIconColors","button","parseInt","largeText","onClick","HvTypography","noWrap","text","textEmpty","Edit","color","role","icon","iconVisible"],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAMA,sBAAsBA,CAACC,eAAuC;AAClE,MAAIC,mBAAmB,CAAA;AACvBC,SAAOC,KAAKH,UAAU,EAAEI,IAAKC,CAAM,MAAA;AACjCJ,qBAAiBI,CAAC,IAAIC,MAAAA,YAAYN,WAAWK,CAAC,CAAC;AAAA,EAAA,CAChD;AACMJ,SAAAA;AACT;AAMO,MAAMM,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC,OAAOC;AAAAA,EACPC;AAAAA,EACAC;AAAAA,EACAC,WAAWC,iBAAiBC,MAAAA;AAAAA,EAC5BC,UAAU;AAAA,EACVC,cAAc;AAAA,EACdC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACgB,MAAM;AACzB,QAAM,CAACd,OAAOe,QAAQ,IAAIC,cAAAA,cAAcf,WAAWC,YAAY;AAC/D,QAAM,CAACe,UAAUC,WAAW,IAAIC,eAAS,KAAK;AAC9C,QAAM,CAACC,a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,UAElB1C,SAASQ;AAAAA,QAAAA,CACG,GACfwC,2BAAAA,IAACkB,sBAAI;AAAA,UACHC,OAAM;AAAA,UACNC,MAAK;AAAA,UACLtE,WAAW8C,GACTC,oBAAAA,QAAoBwB,MACpBlE,YAAY0C,4BAAoByB,aAChC3B,IAAII,2BAAOsB,IAAI,GACflE,YAAYwC,IAAII,2BAAOuB,WAAW,GAClCvE,mCAASsE,MACTlE,aAAYJ,mCAASuE,YAAW;AAAA,QAAA,CAElC,CAAA;AAAA,MAAA,CAAA;AAAA,IAAA,CAEL;AAAA,EAAA,CAGM;AAEjB;;"}
|
|
@@ -7,16 +7,14 @@ const inputClasses = require("../Input/inputClasses.cjs");
|
|
|
7
7
|
const styles = {
|
|
8
8
|
root: {
|
|
9
9
|
[`& .${baseInputClasses.default.inputRoot}.${inputClasses.default.inputRoot}`]: {
|
|
10
|
-
height: "100%"
|
|
10
|
+
height: "100%",
|
|
11
|
+
minHeight: "32px"
|
|
11
12
|
}
|
|
12
13
|
},
|
|
13
14
|
inputBorderContainer: {
|
|
14
15
|
top: "unset",
|
|
15
16
|
bottom: 0
|
|
16
17
|
},
|
|
17
|
-
input: {
|
|
18
|
-
padding: uikitStyles.theme.spacing([0, "8px"])
|
|
19
|
-
},
|
|
20
18
|
text: {
|
|
21
19
|
overflow: "hidden",
|
|
22
20
|
textOverflow: "ellipsis",
|
|
@@ -27,23 +25,26 @@ const styles = {
|
|
|
27
25
|
color: uikitStyles.theme.typography.placeholderText.color
|
|
28
26
|
},
|
|
29
27
|
button: {
|
|
30
|
-
padding: uikitStyles.theme.spacing([
|
|
28
|
+
padding: uikitStyles.theme.spacing(["6px", "8px", "5px", "8px"]),
|
|
29
|
+
minHeight: "32px",
|
|
31
30
|
boxSizing: "border-box",
|
|
32
31
|
cursor: "text",
|
|
33
32
|
height: "100%",
|
|
34
33
|
width: "100%",
|
|
35
34
|
maxWidth: "100%",
|
|
36
35
|
justifyContent: "flex-start",
|
|
36
|
+
alignItems: "center",
|
|
37
37
|
backgroundColor: "transparent",
|
|
38
|
+
border: `${uikitStyles.theme.inlineEditor.borderWidth} solid transparent`,
|
|
38
39
|
"&:hover, &:focus": {
|
|
39
|
-
|
|
40
|
+
border: `${uikitStyles.theme.inlineEditor.borderWidth} solid ${uikitStyles.theme.inlineEditor.hoverBorderColor}`,
|
|
40
41
|
backgroundColor: "transparent",
|
|
41
42
|
[`& .${inlineEditorClasses.default.icon}`]: {
|
|
42
43
|
visibility: "visible"
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"&:active": {
|
|
46
|
-
|
|
47
|
+
border: `${uikitStyles.theme.inlineEditor.borderWidth} solid ${uikitStyles.theme.inlineEditor.activeBorderColor}`,
|
|
47
48
|
backgroundColor: "transparent",
|
|
48
49
|
[`& .${inlineEditorClasses.default.icon}`]: {
|
|
49
50
|
visibility: "visible"
|
|
@@ -53,21 +54,22 @@ const styles = {
|
|
|
53
54
|
width: "100%"
|
|
54
55
|
},
|
|
55
56
|
"& > div > span": {
|
|
56
|
-
width: "100%"
|
|
57
|
-
overflow: "hidden"
|
|
57
|
+
width: "100%"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
icon: {
|
|
61
61
|
cursor: "pointer",
|
|
62
62
|
visibility: "hidden",
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
alignSelf: "center",
|
|
64
|
+
height: "16px",
|
|
65
|
+
width: "32px",
|
|
66
|
+
minWidth: "32px",
|
|
67
|
+
"& svg": {
|
|
68
|
+
margin: uikitStyles.theme.spacing([0, "8px"])
|
|
69
|
+
}
|
|
65
70
|
},
|
|
66
71
|
iconVisible: {
|
|
67
72
|
visibility: "visible"
|
|
68
|
-
},
|
|
69
|
-
largeText: {
|
|
70
|
-
margin: uikitStyles.theme.spacing([0, "8px"])
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
exports.styles = styles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEditor.styles.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { baseInputClasses, inputClasses } from \"@core/components\";\nimport inlineEditorClasses, {\n HvInlineEditorClasses,\n} from \"./inlineEditorClasses\";\n\nexport const styles: Partial<\n Record<keyof HvInlineEditorClasses, CSSInterpolation>\n> = {\n root: {\n [`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {\n height: \"100%\",\n },\n },\n inputBorderContainer: {\n top: \"unset\",\n bottom: 0,\n },\n
|
|
1
|
+
{"version":3,"file":"InlineEditor.styles.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { baseInputClasses, inputClasses } from \"@core/components\";\nimport inlineEditorClasses, {\n HvInlineEditorClasses,\n} from \"./inlineEditorClasses\";\n\nexport const styles: Partial<\n Record<keyof HvInlineEditorClasses, CSSInterpolation>\n> = {\n root: {\n [`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {\n height: \"100%\",\n minHeight: \"32px\",\n },\n },\n inputBorderContainer: {\n top: \"unset\",\n bottom: 0,\n },\n text: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n alignSelf: \"center\",\n },\n textEmpty: {\n color: theme.typography.placeholderText.color,\n },\n button: {\n padding: theme.spacing([\"6px\", \"8px\", \"5px\", \"8px\"]),\n minHeight: \"32px\",\n\n boxSizing: \"border-box\",\n cursor: \"text\",\n height: \"100%\",\n width: \"100%\",\n maxWidth: \"100%\",\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n\n backgroundColor: \"transparent\",\n border: `${theme.inlineEditor.borderWidth} solid transparent`,\n\n \"&:hover, &:focus\": {\n border: `${theme.inlineEditor.borderWidth} solid ${theme.inlineEditor.hoverBorderColor}`,\n backgroundColor: \"transparent\",\n\n [`& .${inlineEditorClasses.icon}`]: {\n visibility: \"visible\",\n },\n },\n\n \"&:active\": {\n border: `${theme.inlineEditor.borderWidth} solid ${theme.inlineEditor.activeBorderColor}`,\n backgroundColor: \"transparent\",\n\n [`& .${inlineEditorClasses.icon}`]: {\n visibility: \"visible\",\n },\n },\n\n \"& > div\": {\n width: \"100%\",\n },\n \"& > div > span\": {\n width: \"100%\",\n },\n },\n icon: {\n cursor: \"pointer\",\n visibility: \"hidden\",\n alignSelf: \"center\",\n height: \"16px\",\n width: \"32px\",\n minWidth: \"32px\",\n\n \"& svg\": {\n margin: theme.spacing([0, \"8px\"]),\n },\n },\n iconVisible: {\n visibility: \"visible\",\n },\n};\n"],"names":["styles","root","baseInputClasses","inputRoot","inputClasses","height","minHeight","inputBorderContainer","top","bottom","text","overflow","textOverflow","whiteSpace","alignSelf","textEmpty","color","theme","typography","placeholderText","button","padding","spacing","boxSizing","cursor","width","maxWidth","justifyContent","alignItems","backgroundColor","border","inlineEditor","borderWidth","hoverBorderColor","inlineEditorClasses","icon","visibility","activeBorderColor","minWidth","margin","iconVisible"],"mappings":";;;;;;AAOO,MAAMA,SAET;AAAA,EACFC,MAAM;AAAA,IACJ,CAAE,MAAKC,yBAAiBC,aAAaC,aAAAA,QAAaD,WAAW,GAAG;AAAA,MAC9DE,QAAQ;AAAA,MACRC,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,IACLC,QAAQ;AAAA,EACV;AAAA,EACAC,MAAM;AAAA,IACJC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC,YAAY;AAAA,IACZC,WAAW;AAAA,EACb;AAAA,EACAC,WAAW;AAAA,IACTC,OAAOC,YAAMC,MAAAA,WAAWC,gBAAgBH;AAAAA,EAC1C;AAAA,EACAI,QAAQ;AAAA,IACNC,SAASJ,kBAAMK,QAAQ,CAAC,OAAO,OAAO,OAAO,KAAK,CAAC;AAAA,IACnDhB,WAAW;AAAA,IAEXiB,WAAW;AAAA,IACXC,QAAQ;AAAA,IACRnB,QAAQ;AAAA,IACRoB,OAAO;AAAA,IACPC,UAAU;AAAA,IACVC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IAEZC,iBAAiB;AAAA,IACjBC,QAAS,GAAEb,YAAAA,MAAMc,aAAaC;AAAAA,IAE9B,oBAAoB;AAAA,MAClBF,QAAS,GAAEb,YAAAA,MAAMc,aAAaC,qBAAqBf,kBAAMc,aAAaE;AAAAA,MACtEJ,iBAAiB;AAAA,MAEjB,CAAE,MAAKK,4BAAoBC,MAAM,GAAG;AAAA,QAClCC,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,YAAY;AAAA,MACVN,QAAS,GAAEb,YAAAA,MAAMc,aAAaC,qBAAqBf,kBAAMc,aAAaM;AAAAA,MACtER,iBAAiB;AAAA,MAEjB,CAAE,MAAKK,4BAAoBC,MAAM,GAAG;AAAA,QAClCC,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACTX,OAAO;AAAA,IACT;AAAA,IACA,kBAAkB;AAAA,MAChBA,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACAU,MAAM;AAAA,IACJX,QAAQ;AAAA,IACRY,YAAY;AAAA,IACZtB,WAAW;AAAA,IACXT,QAAQ;AAAA,IACRoB,OAAO;AAAA,IACPa,UAAU;AAAA,IAEV,SAAS;AAAA,MACPC,QAAQtB,YAAAA,MAAMK,QAAQ,CAAC,GAAG,KAAK,CAAC;AAAA,IAClC;AAAA,EACF;AAAA,EACAkB,aAAa;AAAA,IACXJ,YAAY;AAAA,EACd;AACF;;"}
|
|
@@ -93,13 +93,13 @@ const RuleGroup = ({
|
|
|
93
93
|
}) => {
|
|
94
94
|
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
95
95
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
96
|
-
className: cx(queryBuilderClasses.default.root, css(RuleGroup_styles.styles.root), classes == null ? void 0 : classes.root, level === 0 ?
|
|
96
|
+
className: cx(queryBuilderClasses.default.root, level === 0 ? queryBuilderClasses.default.topGroup : queryBuilderClasses.default.subGroup, css(RuleGroup_styles.styles.root), level === 0 ? css(RuleGroup_styles.styles.topGroup) : css(RuleGroup_styles.styles.subGroup), classes == null ? void 0 : classes.root, level === 0 ? classes == null ? void 0 : classes.topGroup : classes == null ? void 0 : classes.subGroup),
|
|
97
97
|
children: [/* @__PURE__ */ jsxRuntime.jsxs(Grid.HvGrid, {
|
|
98
98
|
container: true,
|
|
99
99
|
children: [/* @__PURE__ */ jsxRuntime.jsx(Grid.HvGrid, {
|
|
100
100
|
item: true,
|
|
101
101
|
children: /* @__PURE__ */ jsxRuntime.jsx(MultiButton.HvMultiButton, {
|
|
102
|
-
className: cx(queryBuilderClasses.default.combinator, css(RuleGroup_styles.styles.combinator), classes == null ? void 0 : classes.combinator,
|
|
102
|
+
className: cx(queryBuilderClasses.default.combinator, queryBuilderClasses.default.topCombinator, css(RuleGroup_styles.styles.combinator), css(RuleGroup_styles.styles.topCombinator), classes == null ? void 0 : classes.combinator, classes == null ? void 0 : classes.topCombinator),
|
|
103
103
|
disabled: readOnly,
|
|
104
104
|
children: combinators && combinators.map((item) => /* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, {
|
|
105
105
|
className: cx(queryBuilderClasses.default.combinatorButton, css(RuleGroup_styles.styles.combinatorButton), classes == null ? void 0 : classes.combinatorButton),
|
|
@@ -113,7 +113,7 @@ const RuleGroup = ({
|
|
|
113
113
|
}), /* @__PURE__ */ jsxRuntime.jsx(Grid.HvGrid, {
|
|
114
114
|
item: true,
|
|
115
115
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
116
|
-
className: cx(queryBuilderClasses.default.buttonBackground, css(RuleGroup_styles.styles.buttonBackground), classes == null ? void 0 : classes.buttonBackground,
|
|
116
|
+
className: cx(queryBuilderClasses.default.buttonBackground, queryBuilderClasses.default.topRemoveButton, css(RuleGroup_styles.styles.buttonBackground), css(RuleGroup_styles.styles.topRemoveButton), classes == null ? void 0 : classes.buttonBackground, classes == null ? void 0 : classes.topRemoveButton),
|
|
117
117
|
children: /* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, {
|
|
118
118
|
icon: true,
|
|
119
119
|
className: cx(queryBuilderClasses.default.removeButton, css(RuleGroup_styles.styles.removeButton), classes == null ? void 0 : classes.removeButton),
|
|
@@ -135,7 +135,7 @@ const RuleGroup = ({
|
|
|
135
135
|
})
|
|
136
136
|
})]
|
|
137
137
|
}), (rules == null ? void 0 : rules.length) > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
138
|
-
className: cx(queryBuilderClasses.default.rulesContainer, css(RuleGroup_styles.styles.rulesContainer), classes == null ? void 0 : classes.rulesContainer, level > 0
|
|
138
|
+
className: cx(queryBuilderClasses.default.rulesContainer, level > 0 && queryBuilderClasses.default.subRulesContainer, level === 0 && queryBuilderClasses.default.topRulesContainer, css(RuleGroup_styles.styles.rulesContainer), level > 0 && css(RuleGroup_styles.styles.subRulesContainer), level === 0 && css(RuleGroup_styles.styles.topRulesContainer), classes == null ? void 0 : classes.rulesContainer, level > 0 && (classes == null ? void 0 : classes.subRulesContainer), level === 0 && (classes == null ? void 0 : classes.topRulesContainer)),
|
|
139
139
|
children: rules.map((rule, index) => {
|
|
140
140
|
if ("combinator" in rule) {
|
|
141
141
|
return /* @__PURE__ */ jsxRuntime.jsx(RuleGroup, {
|
|
@@ -200,7 +200,7 @@ const RuleGroup = ({
|
|
|
200
200
|
container: true,
|
|
201
201
|
children: /* @__PURE__ */ jsxRuntime.jsx(Grid.HvGrid, {
|
|
202
202
|
item: true,
|
|
203
|
-
className: cx(queryBuilderClasses.default.actionButtonContainer, css(RuleGroup_styles.styles.actionButtonContainer), classes == null ? void 0 : classes.actionButtonContainer,
|
|
203
|
+
className: cx(queryBuilderClasses.default.actionButtonContainer, queryBuilderClasses.default.topActionButtonContainer, css(RuleGroup_styles.styles.actionButtonContainer), css(RuleGroup_styles.styles.topActionButtonContainer), classes == null ? void 0 : classes.actionButtonContainer, classes == null ? void 0 : classes.topActionButtonContainer),
|
|
204
204
|
children: actionButtons
|
|
205
205
|
})
|
|
206
206
|
})]
|