@hitachivantara/uikit-react-core 5.36.10 → 5.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs +3 -1
  2. package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs.map +1 -1
  3. package/dist/cjs/components/Dropdown/Dropdown.cjs +4 -1
  4. package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
  5. package/dist/cjs/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.cjs.map +1 -1
  6. package/dist/cjs/components/QueryBuilder/Context.cjs +15 -2
  7. package/dist/cjs/components/QueryBuilder/Context.cjs.map +1 -1
  8. package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs +35 -25
  9. package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs.map +1 -1
  10. package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs +10 -0
  11. package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs.map +1 -1
  12. package/dist/cjs/components/QueryBuilder/Rule/Attribute/Attribute.cjs +2 -3
  13. package/dist/cjs/components/QueryBuilder/Rule/Attribute/Attribute.cjs.map +1 -1
  14. package/dist/cjs/components/QueryBuilder/Rule/Operator/Operator.cjs +2 -3
  15. package/dist/cjs/components/QueryBuilder/Rule/Operator/Operator.cjs.map +1 -1
  16. package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs +16 -14
  17. package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs.map +1 -1
  18. package/dist/cjs/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs +1 -2
  19. package/dist/cjs/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs.map +1 -1
  20. package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +1 -2
  21. package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs.map +1 -1
  22. package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/utils.cjs.map +1 -1
  23. package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +4 -5
  24. package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs.map +1 -1
  25. package/dist/cjs/components/QueryBuilder/Rule/Value/TextValue/TextValue.cjs +1 -2
  26. package/dist/cjs/components/QueryBuilder/Rule/Value/TextValue/TextValue.cjs.map +1 -1
  27. package/dist/cjs/components/QueryBuilder/Rule/Value/Value.cjs +8 -3
  28. package/dist/cjs/components/QueryBuilder/Rule/Value/Value.cjs.map +1 -1
  29. package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +19 -24
  30. package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
  31. package/dist/cjs/components/QueryBuilder/utils/index.cjs.map +1 -1
  32. package/dist/cjs/components/QueryBuilder/utils/reducer.cjs +1 -1
  33. package/dist/cjs/components/QueryBuilder/utils/reducer.cjs.map +1 -1
  34. package/dist/cjs/index.cjs +1 -0
  35. package/dist/cjs/index.cjs.map +1 -1
  36. package/dist/cjs/providers/Provider.cjs +11 -3
  37. package/dist/cjs/providers/Provider.cjs.map +1 -1
  38. package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js +3 -1
  39. package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  40. package/dist/esm/components/Dropdown/Dropdown.js +5 -2
  41. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  42. package/dist/esm/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.js.map +1 -1
  43. package/dist/esm/components/QueryBuilder/Context.js +17 -4
  44. package/dist/esm/components/QueryBuilder/Context.js.map +1 -1
  45. package/dist/esm/components/QueryBuilder/QueryBuilder.js +37 -27
  46. package/dist/esm/components/QueryBuilder/QueryBuilder.js.map +1 -1
  47. package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js +10 -0
  48. package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js.map +1 -1
  49. package/dist/esm/components/QueryBuilder/Rule/Attribute/Attribute.js +3 -4
  50. package/dist/esm/components/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
  51. package/dist/esm/components/QueryBuilder/Rule/Operator/Operator.js +4 -5
  52. package/dist/esm/components/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
  53. package/dist/esm/components/QueryBuilder/Rule/Rule.js +18 -16
  54. package/dist/esm/components/QueryBuilder/Rule/Rule.js.map +1 -1
  55. package/dist/esm/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js +3 -4
  56. package/dist/esm/components/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js.map +1 -1
  57. package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +3 -4
  58. package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
  59. package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/utils.js.map +1 -1
  60. package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +6 -7
  61. package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
  62. package/dist/esm/components/QueryBuilder/Rule/Value/TextValue/TextValue.js +3 -4
  63. package/dist/esm/components/QueryBuilder/Rule/Value/TextValue/TextValue.js.map +1 -1
  64. package/dist/esm/components/QueryBuilder/Rule/Value/Value.js +10 -5
  65. package/dist/esm/components/QueryBuilder/Rule/Value/Value.js.map +1 -1
  66. package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +21 -26
  67. package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
  68. package/dist/esm/components/QueryBuilder/utils/index.js.map +1 -1
  69. package/dist/esm/components/QueryBuilder/utils/reducer.js +1 -1
  70. package/dist/esm/components/QueryBuilder/utils/reducer.js.map +1 -1
  71. package/dist/esm/index.js +2 -1
  72. package/dist/esm/providers/Provider.js +11 -3
  73. package/dist/esm/providers/Provider.js.map +1 -1
  74. package/dist/types/index.d.ts +93 -37
  75. package/package.json +5 -5
@@ -113,7 +113,9 @@ const HvCheckBoxGroup = React.forwardRef((props, ref) => {
113
113
  }, [children, disabled, name, onChildChangeInterceptor, readOnly, selectedState]);
114
114
  const handleSelectAll = (event, selectAllChecked) => {
115
115
  let newValue;
116
- if (selectAllChecked) {
116
+ if (selectAllState === "some") {
117
+ newValue = [];
118
+ } else if (selectAllChecked) {
117
119
  newValue = [...allValues];
118
120
  } else {
119
121
  newValue = [];
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBoxGroup.cjs","sources":["../../../../src/components/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport { multiSelectionEventHandler } from \"@core/utils/multiSelectionEventHandler\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\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 /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\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 /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\".\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required = false,\n readOnly = false,\n disabled = false,\n showSelectAll = false,\n orientation = \"vertical\",\n selectAllLabel = \"All\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children)\n );\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvcheckboxgroup\");\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean\n ) => {\n let newValue: any[];\n if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n };\n\n const selectAllLabelComponent =\n selectedCount === 0 ? (\n <>\n <b>{selectAllLabel}</b>\n {` (${Children.toArray(children).length})`}\n </>\n ) : (\n <>\n <b>{selectedCount}</b>\n {` ${selectAllConjunctionLabel} ${Children.toArray(children).length}`}\n </>\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 errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={selectAllLabelComponent}\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["computeSelectAllState","selected","total","getValueFromSelectedChildren","children","selectedValues","Children","toArray","map","child","childIsControlled","props","checked","undefined","childIsSelected","defaultChecked","value","filter","v","HvCheckBoxGroup","forwardRef","ref","id","classes","classesProp","className","name","label","description","status","statusMessage","defaultValue","valueProp","required","readOnly","disabled","showSelectAll","orientation","selectAllLabel","selectAllConjunctionLabel","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","onChange","others","useDefaultProps","cx","useClasses","setValue","useControlled","validationState","setValidationState","validationMessage","elementId","useUniqueId","selectionAnchor","useRef","allValues","selectedState","selectedCount","useMemo","childValues","childSelectedState","childSelectedCounter","forEach","i","childValue","indexOf","selectAllState","length","onChildChangeInterceptor","useCallback","index","childOnChange","event","isChecked","newValue","multiSelectionEventHandler","modifiedChildren","cloneElement","handleSelectAll","selectAllChecked","selectAllLabelComponent","jsxs","Fragment","jsx","canShowError","errorMessageId","setId","HvFormElement","root","HvLabel","HvInfoMessage","join","trim","group","vertical","horizontal","invalid","HvCheckBox","selectAll","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAMA,wBAAwBA,CAACC,UAAkBC,UAAkB;AACjE,MAAID,aAAa,GAAG;AACX,WAAA;AAAA,EACT;AAEA,MAAIA,aAAaC,OAAO;AACf,WAAA;AAAA,EACT;AAEO,SAAA;AACT;AAEA,MAAMC,+BAA+BA,CAACC,aAA8B;AAClE,QAAMC,iBAAiBC,MAAAA,SAASC,QAAQH,QAAQ,EAC7CI,IAAI,CAACC,UAAe;AACbC,UAAAA,oBAAoBD,OAAOE,OAAOC,YAAYC;AACpD,UAAMC,kBAAkBJ,oBACpBD,OAAOE,OAAOC,UACdH,OAAOE,OAAOI;AAEXD,WAAAA,kBAAkBL,OAAOE,OAAOK,QAAQH;AAAAA,EAAAA,CAChD,EACAI,OAAQC,CAAAA,MAAMA,MAAML,MAAS;AAEzBR,SAAAA;AACT;AA+FO,MAAMc,kBAAkBC,MAAAA,WAC7B,CAACT,OAAOU,QAAQ;AACR,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACArB;AAAAA,IACAsB;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAf,OAAOgB;AAAAA,IACPC,W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AAK,SACL,cAAY5C,WACZ,mBACEC,kBAAmBd,SAAS8D,MAAAA,MAAMnC,WAAW,OAAO,KAAMzC,QAE5D,iBAAesB,WAAW,OAAOtB,QACjC,gBAAcsC,oBAAoB,YAAY,OAAOtC,QACrD,qBACEsC,oBAAoB,YAAYqC,iBAAiB3E,QAEnD,oBACE,CAACe,eAAe6D,MAAAA,MAAMnC,WAAW,aAAa,GAAGZ,eAAe,EAC7DoD,KAAK,GAAG,EACRC,KAAAA,KAAUlF,QAEf,WAAWkC,GAAGxB,QAAQyE,OAAO;AAAA,MAC3B,CAACzE,QAAQ0E,QAAQ,GAAG5D,gBAAgB;AAAA,MACpC,CAACd,QAAQ2E,UAAU,GAAG7D,gBAAgB;AAAA,MACtC,CAACd,QAAQ4E,OAAO,GAAGhD,oBAAoB;AAAA,IAAA,CACxC,GACD,GAAIN,QAEHT,UAAAA;AAAAA,MAAAA,gDACEgE,SAAAA,YACC,EAAA,SAAS/B,mBAAmB,OAC5B,eAAeA,mBAAmB,QAClC,OAAOc,yBACP,UACA,UACA,WAAW5D,QAAQ8E,WACnB,UAAUpB,iBAEb;AAAA,MACAF;AAAAA,IAAAA,GACH;AAAA,IAECQ,gBACCD,2BAAA,IAACgB,YACC,eAAA,EAAA,IAAIb,MAAAA,MAAMnC,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/B,QAAQgF,OAElBlD,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;;;"}
1
+ {"version":3,"file":"CheckBoxGroup.cjs","sources":["../../../../src/components/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport { multiSelectionEventHandler } from \"@core/utils/multiSelectionEventHandler\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\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 /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\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 /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\".\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required = false,\n readOnly = false,\n disabled = false,\n showSelectAll = false,\n orientation = \"vertical\",\n selectAllLabel = \"All\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children)\n );\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvcheckboxgroup\");\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean\n ) => {\n let newValue: any[];\n if (selectAllState === \"some\") {\n newValue = [];\n } else if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n };\n\n const selectAllLabelComponent =\n selectedCount === 0 ? (\n <>\n <b>{selectAllLabel}</b>\n {` (${Children.toArray(children).length})`}\n </>\n ) : (\n <>\n <b>{selectedCount}</b>\n {` ${selectAllConjunctionLabel} ${Children.toArray(children).length}`}\n </>\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 errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={selectAllLabelComponent}\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["computeSelectAllState","selected","total","getValueFromSelectedChildren","children","selectedValues","Children","toArray","map","child","childIsControlled","props","checked","undefined","childIsSelected","defaultChecked","value","filter","v","HvCheckBoxGroup","forwardRef","ref","id","classes","classesProp","className","name","label","description","status","statusMessage","defaultValue","valueProp","required","readOnly","disabled","showSelectAll","orientation","selectAllLabel","selectAllConjunctionLabel","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","onChange","others","useDefaultProps","cx","useClasses","setValue","useControlled","validationState","setValidationState","validationMessage","elementId","useUniqueId","selectionAnchor","useRef","allValues","selectedState","selectedCount","useMemo","childValues","childSelectedState","childSelectedCounter","forEach","i","childValue","indexOf","selectAllState","length","onChildChangeInterceptor","useCallback","index","childOnChange","event","isChecked","newValue","multiSelectionEventHandler","modifiedChildren","cloneElement","handleSelectAll","selectAllChecked","selectAllLabelComponent","jsxs","Fragment","jsx","canShowError","errorMessageId","setId","HvFormElement","root","HvLabel","HvInfoMessage","join","trim","group","vertical","horizontal","invalid","HvCheckBox","selectAll","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAMA,wBAAwBA,CAACC,UAAkBC,UAAkB;AACjE,MAAID,aAAa,GAAG;AACX,WAAA;AAAA,EACT;AAEA,MAAIA,aAAaC,OAAO;AACf,WAAA;AAAA,EACT;AAEO,SAAA;AACT;AAEA,MAAMC,+BAA+BA,CAACC,aAA8B;AACl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B,QAClC,OAAOc,yBACP,UACA,UACA,WAAW5D,QAAQ8E,WACnB,UAAUpB,iBAEb;AAAA,MACAF;AAAAA,IAAAA,GACH;AAAA,IAECQ,gBACCD,2BAAA,IAACgB,YACC,eAAA,EAAA,IAAIb,MAAAA,MAAMnC,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/B,QAAQgF,OAElBlD,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;;;"}
@@ -81,8 +81,10 @@ const HvDropdown = React.forwardRef((props, ref) => {
81
81
  const [isOpen, setIsOpen] = useControlled.useControlled(expanded, Boolean(defaultExpanded));
82
82
  const [selectionLabel, setSelectionLabel] = React.useState(utils.getSelectionLabel(labels, placeholder, multiSelect, values));
83
83
  const [internalValues, setInternalValues] = React.useState(values);
84
+ const internalValuesRef = React.useRef(values);
84
85
  React.useEffect(() => {
85
86
  setInternalValues(values);
87
+ internalValuesRef.current = values;
86
88
  }, [values]);
87
89
  React.useEffect(() => {
88
90
  setSelectionLabel(utils.getSelectionLabel(labels, placeholder, multiSelect, values));
@@ -101,7 +103,7 @@ const HvDropdown = React.forwardRef((props, ref) => {
101
103
  if (!open) {
102
104
  setValidationState(() => {
103
105
  if (required) {
104
- const hasSelection = utils.getSelected(internalValues).length > 0;
106
+ const hasSelection = utils.getSelected(internalValuesRef.current).length > 0;
105
107
  if (!hasSelection) {
106
108
  return "invalid";
107
109
  }
@@ -114,6 +116,7 @@ const HvDropdown = React.forwardRef((props, ref) => {
114
116
  const selected = utils.getSelected(listValues);
115
117
  if (commitChanges) {
116
118
  setInternalValues(listValues);
119
+ internalValuesRef.current = listValues;
117
120
  setSelectionLabel(utils.getSelectionLabel(labels, placeholder, multiSelect, listValues));
118
121
  setValidationState(() => {
119
122
  if (required && selected.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.cjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\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?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\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?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (import.meta.env.DEV && virtualized && !height) {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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 isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","jsx","HvTypography","selectionDisabled","placeholderClosed","jsxs","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","labelContainer","HvLabel","HvInfoMessage","HvBaseDropdown","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","HvDropdownList","rootList","dropdownListContainer","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,MAAAA,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,6BAA6B;AAAA,IAC7BC,QAAQC;AAAAA,IACRC,cAAc;AAAA,IACdC,gBAAgB;AAAA,IAChBC,wBAAwB;AAAA,IACxBC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,cAAc,CAAC;AAAA,IACfC;AAAAA,IACA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kH,KAAK,GAAG,EACRC,UAAUvI,QAEf,gBAAcqH,iBAAiB,OAAOrH,QACtC,qBAAmBuH,gBACnB,oBACE,CAAClG,eAAemG,MAAAA,MAAM/D,WAAW,aAAa,GAAGnC,eAAe,EAC7DgH,KAAK,GAAG,EACRC,KAAAA,KAAUvI,QAEf,SACA,QACA,mBAAmB8E,iBACnB,GAAID,wBAEJ,UAAA+B,2BAAAA,IAAC4B,KAAAA,kBACC,IAAIhB,MAAAA,MAAM/D,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACPgF,UAAU/H,QAAQ+H;AAAAA,MAClBC,uBAAuBhI,QAAQgI;AAAAA,IACjC,GACA,QAAQpE,gBACR,aACA,YACA,UAAUiB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAY7E,WACZ,mBAAiB+F,WAAWM,MAAAA,MAAM/D,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACCiE,gBACCR,2BAAA,IAAC+B,YACC,eAAA,EAAA,IAAInB,MAAAA,MAAM/D,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQkI,OAElB9E,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;;;"}
1
+ {"version":3,"file":"Dropdown.cjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\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?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\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?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n\n const [internalValues, setInternalValues] = useState(values);\n\n // Hack - Keeping track of internal values for validation purposes since useState is async\n const internalValuesRef = useRef(values);\n\n useEffect(() => {\n setInternalValues(values);\n internalValuesRef.current = values;\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (import.meta.env.DEV && virtualized && !height) {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection =\n getSelected(internalValuesRef.current).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n internalValuesRef.current = listValues;\n\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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 isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","internalValuesRef","useRef","useEffect","current","dropdownHeaderRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","jsx","HvTypography","selectionDisabled","placeholderClosed","jsxs","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","labelContainer","HvLabel","HvInfoMessage","HvBaseDropdown","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","HvDropdownList","rootList","dropdownListContainer","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,MAAAA,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,6BAA6B;AAAA,IAC7BC,QAAQC;AAAAA,IACRC,cAAc;AAAA,IACdC,gBAAgB;AAAA,IAChBC,wBAAwB;AAAA,IACxBC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,cAAc,CAAC;AAAA,IACfC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,oBAAoB,CAAC;AAAA,IACrBC,YAAY,CAAC;AAAA,IACb,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,cAAc7C,KAAK;AAEjC,QAAA;AAAA,IAAEE;AAAAA,IAAS4C;AAAAA,EAAAA,IAAOC,gBAAAA,W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,MAAMhE,WAAW,aAAa,GAAGnC,eAAe,EAC7DiH,KAAK,GAAG,EACRC,KAAAA,KAAUxI,QAEf,SACA,QACA,mBAAmBgF,iBACnB,GAAID,wBAEJ,UAAA8B,2BAAAA,IAAC4B,KAAAA,kBACC,IAAIhB,MAAAA,MAAMhE,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACPiF,UAAUhI,QAAQgI;AAAAA,MAClBC,uBAAuBjI,QAAQiI;AAAAA,IACjC,GACA,QAAQrE,gBACR,aACA,YACA,UAAUmB,iBACV,UAAUQ,cACV,QACA,4BACA,aACA,uBACA,cAAY9E,WACZ,mBAAiBgG,WAAWM,MAAAA,MAAMhE,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACCkE,gBACCR,2BAAA,IAAC+B,YACC,eAAA,EAAA,IAAInB,MAAAA,MAAMhE,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQmI,OAElB/E,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationDialog.cjs","sources":["../../../../../src/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { HvButton } from \"@core/components/Button\";\nimport {\n HvDialog,\n HvDialogActions,\n HvDialogContent,\n HvDialogTitle,\n} from \"@core/components/Dialog\";\n\nimport { useClasses } from \"./ConfirmationDialog.styles\";\n\nexport interface ConfirmationDialogProps {\n title?: string;\n message?: string;\n isOpen?: boolean;\n onConfirm?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onCancel?: () => void;\n confirmButtonLabel?: string;\n cancelButtonLabel?: string;\n closeButtonTooltip?: string;\n}\n\nexport const ConfirmationDialog = ({\n title,\n message,\n isOpen,\n onConfirm,\n onCancel,\n confirmButtonLabel,\n cancelButtonLabel,\n closeButtonTooltip,\n}: ConfirmationDialogProps) => {\n const { classes } = useClasses();\n\n const handleClose = (_, reason) => {\n if (reason !== \"backdropClick\") {\n onCancel?.();\n }\n };\n\n return (\n <HvDialog\n classes={{ paper: classes.paper }}\n open={isOpen}\n onClose={handleClose}\n firstFocusable=\"confirmation-dialog-cancel\"\n buttonTitle={closeButtonTooltip}\n >\n <HvDialogTitle variant=\"warning\">{title}</HvDialogTitle>\n <HvDialogContent indentContent>{message}</HvDialogContent>\n <HvDialogActions>\n <HvButton variant=\"primaryGhost\" onClick={onConfirm}>\n {confirmButtonLabel}\n </HvButton>\n <HvButton\n id=\"confirmation-dialog-cancel\"\n variant=\"primaryGhost\"\n onClick={() => onCancel?.()}\n >\n {cancelButtonLabel}\n </HvButton>\n </HvDialogActions>\n </HvDialog>\n );\n};\n"],"names":["ConfirmationDialog","title","message","isOpen","onConfirm","onCancel","confirmButtonLabel","cancelButtonLabel","closeButtonTooltip","classes","useClasses","handleClose","_","reason","jsxs","HvDialog","paper","jsx","HvDialogTitle","HvDialogContent","HvDialogActions","HvButton"],"mappings":";;;;;;;;;AAqBO,MAAMA,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACuB,MAAM;AACvB,QAAA;AAAA,IAAEC;AAAAA,MAAYC,0BAAW,WAAA;AAEzBC,QAAAA,cAAcA,CAACC,GAAGC,WAAW;AACjC,QAAIA,WAAW,iBAAiB;AACnB;IACb;AAAA,EAAA;AAIA,SAAAC,2BAAA,KAACC,mBACC,SAAS;AAAA,IAAEC,OAAOP,QAAQO;AAAAA,EAAAA,GAC1B,MAAMb,QACN,SAASQ,aACT,gBAAe,8BACf,aAAaH,oBAEb,UAAA;AAAA,IAACS,2BAAA,IAAAC,MAAA,eAAA,EAAc,SAAQ,WAAWjB,UAAM,OAAA;AAAA,IACvCgB,2BAAA,IAAAE,QAAA,iBAAA,EAAgB,eAAa,MAAEjB,UAAQ,SAAA;AAAA,oCACvCkB,QAAAA,iBACC,EAAA,UAAA;AAAA,MAAAH,+BAACI,OAAAA,UAAS,EAAA,SAAQ,gBAAe,SAASjB,WACvCE,UACH,oBAAA;AAAA,MACAW,2BAAAA,IAACI,OACC,UAAA,EAAA,IAAG,8BACH,SAAQ,gBACR,SAAS,MAAMhB,WAAW,GAEzBE,UACH,kBAAA,CAAA;AAAA,IAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
1
+ {"version":3,"file":"ConfirmationDialog.cjs","sources":["../../../../../src/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { HvButton, HvButtonProps } from \"@core/components/Button\";\nimport {\n HvDialog,\n HvDialogActions,\n HvDialogContent,\n HvDialogProps,\n HvDialogTitle,\n} from \"@core/components/Dialog\";\n\nimport { useClasses } from \"./ConfirmationDialog.styles\";\n\nexport interface ConfirmationDialogProps {\n title?: string;\n message?: string;\n isOpen?: boolean;\n onConfirm?: HvButtonProps[\"onClick\"];\n onCancel?: () => void;\n confirmButtonLabel?: string;\n cancelButtonLabel?: string;\n closeButtonTooltip?: string;\n}\n\nexport const ConfirmationDialog = ({\n title,\n message,\n isOpen,\n onConfirm,\n onCancel,\n confirmButtonLabel,\n cancelButtonLabel,\n closeButtonTooltip,\n}: ConfirmationDialogProps) => {\n const { classes } = useClasses();\n\n const handleClose: HvDialogProps[\"onClose\"] = (_, reason) => {\n if (reason !== \"backdropClick\") {\n onCancel?.();\n }\n };\n\n return (\n <HvDialog\n classes={{ paper: classes.paper }}\n open={isOpen}\n onClose={handleClose}\n firstFocusable=\"confirmation-dialog-cancel\"\n buttonTitle={closeButtonTooltip}\n >\n <HvDialogTitle variant=\"warning\">{title}</HvDialogTitle>\n <HvDialogContent indentContent>{message}</HvDialogContent>\n <HvDialogActions>\n <HvButton variant=\"primaryGhost\" onClick={onConfirm}>\n {confirmButtonLabel}\n </HvButton>\n <HvButton\n id=\"confirmation-dialog-cancel\"\n variant=\"primaryGhost\"\n onClick={() => onCancel?.()}\n >\n {cancelButtonLabel}\n </HvButton>\n </HvDialogActions>\n </HvDialog>\n );\n};\n"],"names":["ConfirmationDialog","title","message","isOpen","onConfirm","onCancel","confirmButtonLabel","cancelButtonLabel","closeButtonTooltip","classes","useClasses","handleClose","_","reason","jsxs","HvDialog","paper","jsx","HvDialogTitle","HvDialogContent","HvDialogActions","HvButton"],"mappings":";;;;;;;;;AAsBO,MAAMA,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACuB,MAAM;AACvB,QAAA;AAAA,IAAEC;AAAAA,MAAYC,0BAAW,WAAA;AAEzBC,QAAAA,cAAwCA,CAACC,GAAGC,WAAW;AAC3D,QAAIA,WAAW,iBAAiB;AACnB;IACb;AAAA,EAAA;AAIA,SAAAC,2BAAA,KAACC,mBACC,SAAS;AAAA,IAAEC,OAAOP,QAAQO;AAAAA,EAAAA,GAC1B,MAAMb,QACN,SAASQ,aACT,gBAAe,8BACf,aAAaH,oBAEb,UAAA;AAAA,IAACS,2BAAA,IAAAC,MAAA,eAAA,EAAc,SAAQ,WAAWjB,UAAM,OAAA;AAAA,IACvCgB,2BAAA,IAAAE,QAAA,iBAAA,EAAgB,eAAa,MAAEjB,UAAQ,SAAA;AAAA,oCACvCkB,QAAAA,iBACC,EAAA,UAAA;AAAA,MAAAH,+BAACI,OAAAA,UAAS,EAAA,SAAQ,gBAAe,SAASjB,WACvCE,UACH,oBAAA;AAAA,MACAW,2BAAAA,IAACI,OACC,UAAA,EAAA,IAAG,8BACH,SAAQ,gBACR,SAAS,MAAMhB,WAAW,GAEzBE,UACH,kBAAA,CAAA;AAAA,IAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@emotion/react/jsx-runtime");
3
4
  const React = require("react");
4
5
  const defaultOperators = {
5
6
  numeric: [{
@@ -262,7 +263,7 @@ const defaultLabels = {
262
263
  spacer: " or a "
263
264
  }
264
265
  };
265
- const QueryBuilderContext = React.createContext({
266
+ const HvQueryBuilderContext = React.createContext({
266
267
  dispatchAction: () => ({}),
267
268
  askAction: () => ({}),
268
269
  selectLocation: () => ({}),
@@ -272,10 +273,22 @@ const QueryBuilderContext = React.createContext({
272
273
  maxDepth: 1,
273
274
  labels: defaultLabels,
274
275
  initialTouched: false,
276
+ disableConfirmation: false,
275
277
  readOnly: false
276
278
  });
277
- exports.QueryBuilderContext = QueryBuilderContext;
279
+ const HvQueryBuilderProvider = ({
280
+ children,
281
+ value
282
+ }) => {
283
+ return /* @__PURE__ */ jsxRuntime.jsx(HvQueryBuilderContext.Provider, { value, children });
284
+ };
285
+ const useQueryBuilderContext = () => {
286
+ return React.useContext(HvQueryBuilderContext);
287
+ };
288
+ exports.HvQueryBuilderContext = HvQueryBuilderContext;
289
+ exports.HvQueryBuilderProvider = HvQueryBuilderProvider;
278
290
  exports.defaultCombinators = defaultCombinators;
279
291
  exports.defaultLabels = defaultLabels;
280
292
  exports.defaultOperators = defaultOperators;
293
+ exports.useQueryBuilderContext = useQueryBuilderContext;
281
294
  //# sourceMappingURL=Context.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.cjs","sources":["../../../../src/components/QueryBuilder/Context.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n QueryAction,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\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\ninterface QueryBuilderContextValue {\n dispatchAction: React.Dispatch<QueryAction>;\n askAction: React.Dispatch<React.SetStateAction<AskAction | undefined>>;\n selectLocation?: React.Dispatch<unknown>;\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}\n\nexport const QueryBuilderContext = createContext<QueryBuilderContextValue>({\n dispatchAction: () => ({}),\n askAction: () => ({}),\n selectLocation: () => ({}),\n attributes: {},\n operators: defaultOperators,\n combinators: defaultCombinators,\n maxDepth: 1,\n labels: defaultLabels,\n initialTouched: false,\n readOnly: false,\n});\n"],"names":["defaultOperators","numeric","operator","label","combinators","text","textarea","boolean","dateandtime","defaultCombinators","operand","defaultLabels","query","delete","ariaLabel","tooltip","dialogTitle","dialogMessage","dialogConfirm","dialogCancel","dialogCloseTooltip","rule","attribute","placeholder","exists","value","distance","connectorText","button","validation","required","invalid","options","true","false","equal","greaterThan","range","leftLabel","rightLabel","datetime","dateLabel","datePlaceholder","timeLabel","timePlaceholder","startDateLabel","startDatePlaceholder","startTimeLabel","startTimePlaceholder","endDateLabel","endDatePlaceholder","endTimeLabel","endTimePlaceholder","invalidInterval","group","reset","addRule","addGroup","empty","title","createCondition","createGroup","spacer","QueryBuilderContext","createContext","dispatchAction","askAction","selectLocation","attributes","operators","maxDepth","labels","initialTouched","readOnly"],"mappings":";;;AAWO,MAAMA,mBAAmB;AAAA,EAC9BC,SAAS,CACP;AAAA,IACEC,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,OAAO,IAAI;AAAA,EAAA,GAE3B;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,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ACVC,QAAQ5D;AAAAA,EACR6D,gBAAgB;AAAA,EAChBC,UAAU;AACZ,CAAC;;;;;"}
1
+ {"version":3,"file":"Context.cjs","sources":["../../../../src/components/QueryBuilder/Context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n QueryAction,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderRenderers,\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>;\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}\n\nexport const HvQueryBuilderContext = createContext<HvQueryBuilderContextValue>({\n dispatchAction: () => ({}),\n askAction: () => ({}),\n selectLocation: () => ({}),\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":["defaultOperators","numeric","operator","label","combinators","text","textarea","boolean","dateandtime","defaultCombinators","operand","defaultLabels","query","delete","ariaLabel","tooltip","dialogTitle","dialogMessage","dialogConfirm","dialogCancel","dialogCloseTooltip","rule","attribute","placeholder","exists","value","distance","connectorText","button","validation","required","invalid","options","true","false","equal","greaterThan","range","leftLabel","rightLabel","datetime","dateLabel","datePlaceholder","timeLabel","timePlaceholder","startDateLabel","startDatePlaceholder","startTimeLabel","startTimePlaceholder","endDateLabel","endDatePlaceholder","endTimeLabel","endTimePlaceholder","invalidInterval","group","reset","addRule","addGroup","empty","title","createCondition","createGroup","spacer","HvQueryBuilderContext","createContext","dispatchAction","askAction","selectLocation","attributes","operators","maxDepth","labels","initialTouched","disableConfirmation","readOnly","HvQueryBuilderProvider","children","jsx","useQueryBuilderContext","useContext"],"mappings":";;;;AAYO,MAAMA,mBAAmB;AAAA,EAC9BC,SAAS,CACP;AAAA,IACEC,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,OAAO,IAAI;AAAA,EAAA,GAE3B;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,GAErB;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,KAAK;AAAA,EAAA,CACpB;AAAA,EAEHC,MAAM,CACJ;AAAA,IACEH,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,aAAa,CAAC,OAAO,IAAI;AAAA,EAAA,GAE3B;AAAA,IACEF,UAAU;AAAA,IACVC,OAAO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17
17
  const HvQueryBuilder = (props) => {
18
18
  const {
19
19
  attributes,
20
+ renderers,
20
21
  query,
21
22
  onChange,
22
- operators,
23
- combinators,
23
+ disableConfirmation = false,
24
+ operators = Context.defaultOperators,
25
+ combinators = Context.defaultCombinators,
24
26
  maxDepth = 1,
25
- labels,
27
+ labels = Context.defaultLabels,
26
28
  readOnly = false,
27
29
  classes: classesProp
28
30
  } = useDefaultProps.useDefaultProps("HvQueryBuilder", props);
29
31
  const {
30
32
  classes
31
33
  } = QueryBuilder_styles.useClasses(classesProp);
32
- const [pendingAction, askAction] = React.useState();
33
34
  const currentAttributes = React.useRef(null);
34
- const [state, dispatchAction] = React.useReducer(reducer.default, query, (initialState2) => initialState2 || index.emptyGroup());
35
- const initialState = query === state;
36
- const [prevState, setPrevState] = React.useState();
37
- const defaultContext = React.useContext(Context.QueryBuilderContext);
38
- const context = React.useMemo(() => ({
35
+ const initialQuery = React.useRef(query ?? index.emptyGroup());
36
+ const [pendingAction, setPendingAction] = React.useState();
37
+ const [prevState, setPrevState] = React.useState(initialQuery.current);
38
+ const [initialState, setInitialState] = React.useState(true);
39
+ const [state, dispatchAction] = React.useReducer(
40
+ reducer.default,
41
+ // Deep clone is needed to make sure that the "query" prop and "initialQuery" are not mutated
42
+ cloneDeep__default.default(initialQuery.current)
43
+ );
44
+ const value = React.useMemo(() => ({
39
45
  dispatchAction,
40
- askAction,
46
+ askAction: setPendingAction,
41
47
  attributes,
42
- /* eslint-disable react/destructuring-assignment */
43
- operators: operators ?? defaultContext.operators,
44
- combinators: combinators ?? defaultContext.combinators,
45
- maxDepth: maxDepth ?? defaultContext.maxDepth,
46
- labels: labels ?? defaultContext.labels,
48
+ operators,
49
+ combinators,
50
+ maxDepth,
51
+ labels,
47
52
  initialTouched: initialState,
48
- readOnly
49
- }), [attributes, operators, defaultContext.operators, defaultContext.combinators, defaultContext.maxDepth, defaultContext.labels, combinators, maxDepth, labels, readOnly, initialState]);
53
+ readOnly,
54
+ renderers,
55
+ disableConfirmation
56
+ }), [attributes, operators, combinators, maxDepth, labels, readOnly, initialState, renderers, disableConfirmation]);
50
57
  React.useEffect(() => {
51
58
  if (currentAttributes.current == null) {
52
59
  currentAttributes.current = attributes;
@@ -58,23 +65,26 @@ const HvQueryBuilder = (props) => {
58
65
  }
59
66
  }, [attributes]);
60
67
  React.useEffect(() => {
61
- if (!initialState && !isEqual__default.default(state, prevState)) {
68
+ if (!isEqual__default.default(state, prevState)) {
69
+ if (initialState) {
70
+ setInitialState(false);
71
+ }
62
72
  onChange?.(index.clearNodeIds(state));
63
73
  setPrevState(cloneDeep__default.default(state));
64
74
  }
65
- }, [state, prevState, initialState, onChange]);
66
- const onConfirmHandler = () => {
75
+ }, [initialState, onChange, prevState, state]);
76
+ const handleConfirm = () => {
67
77
  if (pendingAction) {
68
- askAction(void 0);
78
+ setPendingAction(void 0);
69
79
  pendingAction.actions.forEach((action) => dispatchAction(action));
70
80
  }
71
81
  };
72
- const onCancelHandler = () => {
73
- askAction(void 0);
82
+ const handleCancel = () => {
83
+ setPendingAction(void 0);
74
84
  };
75
- return /* @__PURE__ */ jsxRuntime.jsxs(Context.QueryBuilderContext.Provider, { value: context, children: [
85
+ return /* @__PURE__ */ jsxRuntime.jsxs(Context.HvQueryBuilderProvider, { value, children: [
76
86
  /* @__PURE__ */ jsxRuntime.jsx(RuleGroup.RuleGroup, { level: 0, id: state.id, combinator: state.combinator, rules: state.rules, classes }),
77
- /* @__PURE__ */ jsxRuntime.jsx(ConfirmationDialog.ConfirmationDialog, { isOpen: pendingAction != null, onConfirm: onConfirmHandler, onCancel: onCancelHandler, title: pendingAction?.dialog.dialogTitle || "", message: pendingAction?.dialog.dialogMessage || "", confirmButtonLabel: pendingAction?.dialog.dialogConfirm || "", cancelButtonLabel: pendingAction?.dialog.dialogCancel || "", closeButtonTooltip: pendingAction?.dialog.dialogCloseTooltip || "" })
87
+ /* @__PURE__ */ jsxRuntime.jsx(ConfirmationDialog.ConfirmationDialog, { isOpen: pendingAction != null, onConfirm: handleConfirm, onCancel: handleCancel, title: pendingAction?.dialog.dialogTitle || "", message: pendingAction?.dialog.dialogMessage || "", confirmButtonLabel: pendingAction?.dialog.dialogConfirm || "", cancelButtonLabel: pendingAction?.dialog.dialogCancel || "", closeButtonTooltip: pendingAction?.dialog.dialogCloseTooltip || "" })
78
88
  ] });
79
89
  };
80
90
  exports.queryBuilderClasses = QueryBuilder_styles.staticClasses;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryBuilder.cjs","sources":["../../../../src/components/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import {\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"react\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport isEqual from \"lodash/isEqual\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport { QueryBuilderContext } from \"./Context\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n HvQueryBuilderQuery,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup } from \"./utils\";\nimport reducer from \"./utils/reducer\";\nimport { useClasses, staticClasses } from \"./QueryBuilder.styles\";\n\nexport { staticClasses as queryBuilderClasses };\n\nexport type HvQueryBuilderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvQueryBuilderProps {\n attributes?: Record<string, HvQueryBuilderAttribute>;\n /**\n * The query rules operators by attribute type and combinator.\n */\n operators?: Record<string, HvQueryBuilderQueryOperator[]>;\n /**\n * The query combinators operands.\n */\n combinators?: HvQueryBuilderQueryCombinator[];\n /**\n * The initial query representation.\n */\n query?: HvQueryBuilderQuery;\n /**\n * Callback fired when query changes.\n * @param value - the query representation.\n */\n onChange?: (value: HvQueryBuilderQuery) => void;\n /**\n * Max depth of nested query groups.\n */\n maxDepth?: number;\n /**\n * An object containing all the labels.\n */\n labels?: HvQueryBuilderLabels;\n /**\n * A flag indicating if the Query Builder is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: HvQueryBuilderClasses;\n}\n\n/**\n * **HvQueryBuilder** 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 */\nexport const HvQueryBuilder = (props: HvQueryBuilderProps) => {\n const {\n attributes,\n query,\n onChange,\n operators,\n combinators,\n maxDepth = 1,\n labels,\n readOnly = false,\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilder\", props);\n const { classes } = useClasses(classesProp);\n\n const [pendingAction, askAction] = useState<AskAction>();\n const currentAttributes = useRef<\n Record<string, HvQueryBuilderAttribute> | undefined | null\n >(null);\n const [state, dispatchAction] = useReducer(\n reducer,\n query,\n (initialState) => initialState || emptyGroup()\n );\n\n const initialState = query === state;\n const [prevState, setPrevState] = useState();\n\n const defaultContext = useContext(QueryBuilderContext);\n\n const context = useMemo(\n () => ({\n dispatchAction,\n askAction,\n attributes,\n /* eslint-disable react/destructuring-assignment */\n operators: operators ?? defaultContext.operators,\n combinators: combinators ?? defaultContext.combinators,\n maxDepth: maxDepth ?? defaultContext.maxDepth,\n labels: labels ?? defaultContext.labels,\n initialTouched: initialState,\n readOnly,\n }),\n [\n attributes,\n operators,\n defaultContext.operators,\n defaultContext.combinators,\n defaultContext.maxDepth,\n defaultContext.labels,\n combinators,\n maxDepth,\n labels,\n readOnly,\n initialState,\n ]\n );\n\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 certain invalid, so reset it\n currentAttributes.current = attributes;\n dispatchAction({ type: \"reset-query\" });\n }\n }, [attributes]);\n\n // Propagate the change if the query is modified.\n useEffect(() => {\n if (!initialState && !isEqual(state, prevState)) {\n onChange?.(clearNodeIds(state));\n setPrevState(cloneDeep(state));\n }\n }, [state, prevState, initialState, onChange]);\n\n const onConfirmHandler = () => {\n if (pendingAction) {\n askAction(undefined);\n pendingAction.actions.forEach((action) => dispatchAction(action));\n }\n };\n\n const onCancelHandler = () => {\n askAction(undefined);\n };\n\n return (\n <QueryBuilderContext.Provider value={context}>\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={onConfirmHandler}\n onCancel={onCancelHandler}\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 </QueryBuilderContext.Provider>\n );\n};\n"],"names":["HvQueryBuilder","props","attributes","query","onChange","operators","combinators","maxDepth","labels","readOnly","classes","classesProp","useDefaultProps","useClasses","pendingAction","askAction","useState","currentAttributes","useRef","state","dispatchAction","useReducer","reducer","initialState","emptyGroup","prevState","setPrevState","defaultContext","useContext","QueryBuilderContext","context","useMemo","initialTouched","useEffect","current","type","isEqual","clearNodeIds","cloneDeep","onConfirmHandler","undefined","actions","forEach","action","onCancelHandler","jsxs","jsx","RuleGroup","id","combinator","rules","ConfirmationDialog","dialog","dialogTitle","dialogMessage","dialogConfirm","dialogCancel","dialogCloseTooltip"],"mappings":";;;;;;;;;;;;;;;;AA4EaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC;AAAAA,IACAC,WAAW;AAAA,IACXC,SAASC;AAAAA,EAAAA,IACPC,gBAAgB,gBAAA,kBAAk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AAA,mBAAAA,QAAUnB,KAAK,CAAC;AAAA,IAC/B;AAAA,KACC,CAACA,OAAOM,WAAWF,cAAcnB,QAAQ,CAAC;AAE7C,QAAMmC,mBAAmBA,MAAM;AAC7B,QAAIzB,eAAe;AACjBC,gBAAUyB,MAAS;AACnB1B,oBAAc2B,QAAQC,QAASC,CAAWvB,WAAAA,eAAeuB,MAAM,CAAC;AAAA,IAClE;AAAA,EAAA;AAGF,QAAMC,kBAAkBA,MAAM;AAC5B7B,cAAUyB,MAAS;AAAA,EAAA;AAGrB,SACGK,2BAAAA,KAAAhB,QAAAA,oBAAoB,UAApB,EAA6B,OAAOC,SACnC,UAAA;AAAA,IAAAgB,2BAAA,IAACC,UACC,WAAA,EAAA,OAAO,GACP,IAAI5B,MAAM6B,IACV,YAAY7B,MAAM8B,YAClB,OAAO9B,MAAM+B,OACb,SAAiB;AAAA,IAElBJ,2BAAA,IAAAK,mBAAA,oBAAA,EACC,QAAQrC,iBAAiB,MACzB,WAAWyB,kBACX,UAAUK,iBACV,OAAO9B,eAAesC,OAAOC,eAAe,IAC5C,SAASvC,eAAesC,OAAOE,iBAAiB,IAChD,oBAAoBxC,eAAesC,OAAOG,iBAAiB,IAC3D,mBAAmBzC,eAAesC,OAAOI,gBAAgB,IACzD,oBAAoB1C,eAAesC,OAAOK,sBAAsB,IAAG;AAAA,EAEvE,EAAA,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"QueryBuilder.cjs","sources":["../../../../src/components/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import { useEffect, useMemo, useReducer, useRef, useState } from \"react\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport isEqual from \"lodash/isEqual\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport {\n HvQueryBuilderProvider,\n defaultCombinators,\n defaultLabels,\n defaultOperators,\n} from \"./Context\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n HvQueryBuilderAttribute,\n HvQueryBuilderQuery,\n HvQueryBuilderLabels,\n HvQueryBuilderQueryCombinator,\n HvQueryBuilderQueryOperator,\n HvQueryBuilderChangedQuery,\n HvQueryBuilderRenderers,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup } from \"./utils\";\nimport reducer from \"./utils/reducer\";\nimport { useClasses, staticClasses } from \"./QueryBuilder.styles\";\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 initial query representation. */\n query?: HvQueryBuilderQuery;\n /** Callback fired when query changes. */\n onChange?: (value: HvQueryBuilderChangedQuery) => 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 /** Renderers for custom attribute types. */\n renderers?: HvQueryBuilderRenderers;\n /** Whether to opt-out of the confirmation dialogs shown before removing rules and rule groups. Default to `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// - uncontrolled vs controlled: users should be able to control the state\n// - \"query\" renamed to \"initialQuery\" and \"query\" used to control the state\n// - \"query\" provided with ids by the user but removed through \"onChange\"\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 */\nexport const HvQueryBuilder = (props: HvQueryBuilderProps) => {\n const {\n attributes,\n renderers,\n query,\n onChange,\n disableConfirmation = false,\n operators = defaultOperators,\n combinators = defaultCombinators,\n maxDepth = 1,\n labels = defaultLabels,\n readOnly = false,\n classes: classesProp,\n } = useDefaultProps(\"HvQueryBuilder\", props);\n\n const { classes } = useClasses(classesProp);\n\n const currentAttributes = useRef<HvQueryBuilderProps[\"attributes\"] | null>(\n null\n );\n\n const initialQuery = useRef(query ?? emptyGroup());\n\n const [pendingAction, setPendingAction] = useState<AskAction>();\n const [prevState, setPrevState] = useState(initialQuery.current);\n const [initialState, setInitialState] = useState(true);\n\n const [state, dispatchAction] = useReducer(\n reducer,\n // Deep clone is needed to make sure that the \"query\" prop and \"initialQuery\" are not mutated\n cloneDeep(initialQuery.current)\n );\n\n const value = 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 }),\n [\n attributes,\n operators,\n combinators,\n maxDepth,\n labels,\n readOnly,\n initialState,\n renderers,\n disableConfirmation,\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 // Propagate the change if the query is modified\n useEffect(() => {\n if (!isEqual(state, prevState)) {\n if (initialState) {\n setInitialState(false);\n }\n\n onChange?.(clearNodeIds(state) as HvQueryBuilderChangedQuery);\n setPrevState(cloneDeep(state));\n }\n }, [initialState, onChange, prevState, 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={value}>\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":["HvQueryBuilder","props","attributes","renderers","query","onChange","disableConfirmation","operators","defaultOperators","combinators","defaultCombinators","maxDepth","labels","defaultLabels","readOnly","classes","classesProp","useDefaultProps","useClasses","currentAttributes","useRef","initialQuery","emptyGroup","pendingAction","setPendingAction","useState","prevState","setPrevState","current","initialState","setInitialState","state","dispatchAction","useReducer","reducer","cloneDeep","value","useMemo","askAction","initialTouched","useEffect","type","isEqual","clearNodeIds","handleConfirm","undefined","actions","forEach","action","handleCancel","jsxs","HvQueryBuilderProvider","jsx","RuleGroup","id","combinator","rules","ConfirmationDialog","dialog","dialogTitle","dialogMessage","dialogConfirm","dialogCancel","dialogCloseTooltip"],"mappings":";;;;;;;;;;;;;;;;AAmEaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,sBAAsB;AAAA,IACtBC,YAAYC,QAAAA;AAAAA,IACZC,cAAcC,QAAAA;AAAAA,IACdC,WAAW;AAAA,IACXC,SAASC,QAAAA;AAAAA,IACTC,WAAW;AAAA,IACXC,SAASC;AAAAA,EAAAA,IACPC,gBAAgB,gBAAA,kBAAkBhB,KAAK;AAErC,QAAA;AAAA,IAAEc;AAAAA,EAAAA,IAAYG,oBAAAA,WAAWF,WAAW;AAEpCG,QAAAA,oBAAoBC,aACxB,IACF;AAEA,QAAMC,eAAeD,MAAAA,OAAOhB,SAASkB,MAAAA,WAAY,CAAA;AAEjD,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,MAAoB,SAAA;AAC9D,QAAM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AAA,IAClE;AAAA,EAAA;AAGF,QAAMC,eAAeA,MAAM;AACzBzB,qBAAiBqB,MAAS;AAAA,EAAA;AAI1B,SAAAK,gCAACC,QAAAA,0BAAuB,OACtB,UAAA;AAAA,IAAAC,2BAAA,IAACC,UACC,WAAA,EAAA,OAAO,GACP,IAAItB,MAAMuB,IACV,YAAYvB,MAAMwB,YAClB,OAAOxB,MAAMyB,OACb,SAAiB;AAAA,IAElBJ,2BAAA,IAAAK,mBAAA,oBAAA,EACC,QAAQlC,iBAAiB,MACzB,WAAWqB,eACX,UAAUK,cACV,OAAO1B,eAAemC,OAAOC,eAAe,IAC5C,SAASpC,eAAemC,OAAOE,iBAAiB,IAChD,oBAAoBrC,eAAemC,OAAOG,iBAAiB,IAC3D,mBAAmBtC,eAAemC,OAAOI,gBAAgB,IACzD,oBAAoBvC,eAAemC,OAAOK,sBAAsB,IAAG;AAAA,EAEvE,EAAA,CAAA;AAEJ;;;"}
@@ -105,6 +105,16 @@ const {
105
105
  buttonBackground: {
106
106
  backgroundColor: uikitStyles.theme.colors.atmo2,
107
107
  display: "inline-flex"
108
+ },
109
+ createConditionButton: {
110
+ cursor: "pointer",
111
+ backgroundColor: "transparent",
112
+ padding: 0
113
+ },
114
+ createGroupButton: {
115
+ cursor: "pointer",
116
+ backgroundColor: "transparent",
117
+ padding: 0
108
118
  }
109
119
  });
110
120
  exports.staticClasses = staticClasses;