@hitachivantara/uikit-react-core 5.74.0 → 5.76.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 (29) hide show
  1. package/dist/cjs/Badge/Badge.cjs +18 -13
  2. package/dist/cjs/Badge/Badge.styles.cjs +25 -14
  3. package/dist/cjs/Dropdown/Dropdown.cjs +271 -276
  4. package/dist/cjs/InlineEditor/InlineEditor.cjs +4 -2
  5. package/dist/cjs/QueryBuilder/Rule/Attribute/Attribute.cjs +1 -1
  6. package/dist/cjs/QueryBuilder/Rule/Operator/Operator.cjs +1 -1
  7. package/dist/cjs/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs +1 -1
  8. package/dist/cjs/Table/renderers/DropdownColumnCell/DropdownColumnCell.cjs +3 -17
  9. package/dist/cjs/Table/renderers/renderers.cjs +2 -5
  10. package/dist/esm/Badge/Badge.js +18 -13
  11. package/dist/esm/Badge/Badge.js.map +1 -1
  12. package/dist/esm/Badge/Badge.styles.js +25 -14
  13. package/dist/esm/Badge/Badge.styles.js.map +1 -1
  14. package/dist/esm/Dropdown/Dropdown.js +272 -277
  15. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  16. package/dist/esm/InlineEditor/InlineEditor.js +4 -2
  17. package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
  18. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js +1 -1
  19. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
  20. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js +1 -1
  21. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
  22. package/dist/esm/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js +1 -1
  23. package/dist/esm/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js.map +1 -1
  24. package/dist/esm/Table/renderers/DropdownColumnCell/DropdownColumnCell.js +3 -17
  25. package/dist/esm/Table/renderers/DropdownColumnCell/DropdownColumnCell.js.map +1 -1
  26. package/dist/esm/Table/renderers/renderers.js +2 -5
  27. package/dist/esm/Table/renderers/renderers.js.map +1 -1
  28. package/dist/types/index.d.ts +27 -28
  29. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../src/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n isInvalid,\n} from \"../Forms\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListValue } from \"../List\";\nimport { HvTypography } from \"../Typography\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { getSelected, getSelectionLabel } from \"./utils\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport type HvDropdownStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvDropdownProps\n extends Omit<HvFormElementProps, \"value\" | \"onChange\">,\n Pick<\n HvBaseDropdownProps,\n | \"placement\"\n | \"popperProps\"\n | \"disablePortal\"\n | \"variableWidth\"\n | \"expanded\"\n | \"defaultExpanded\"\n > {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\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 will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabels;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\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?: Partial<HvDropdownListProps>;\n}\n\nconst DEFAULT_LABELS = {\n /** Label for overwrite the default header behavior. */\n select: undefined as string | undefined,\n /** Label used for the All checkbox action. */\n selectAll: \"All\",\n /** Cancel button label. */\n cancelLabel: \"Cancel\",\n /** Apply button label. */\n applyLabel: \"Apply\",\n /** The label used in the middle of the multiSelection count. */\n searchPlaceholder: \"Search\",\n /** The label used in search. */\n multiSelectionConjunction: \"/\",\n};\n\nexport type HvDropdownLabels = Partial<typeof DEFAULT_LABELS>;\n/** @deprecated use `HvDropdownLabels` instead */\nexport type HvDropdownLabelsProps = HvDropdownLabels;\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);\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\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":[],"mappings":";;;;;;;;;;;;;;;;;;;AA4JA,MAAM,iBAAiB;AAAA;AAAA,EAErB,QAAQ;AAAA;AAAA,EAER,WAAW;AAAA;AAAA,EAEX,aAAa;AAAA;AAAA,EAEb,YAAY;AAAA;AAAA,EAEZ,mBAAmB;AAAA;AAAA,EAEnB,2BAA2B;AAC7B;AASO,MAAM,aAAa;AAAA,EACxB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MAEA;AAAA,MACA;AAAA,MAEA,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MAEX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MAEpB,cAAc;AAAA,MAEd;AAAA,MAEA;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,MAErB;AAAA,MACA;AAAA,MAC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mBACE,CAAC,SAAS,MAAM,WAAW,OAAO,GAAG,cAAc,EAChD,KAAK,GAAG,EACR,UAAU;AAAA,cAEf,gBAAc,iBAAiB,OAAO;AAAA,cACtC,qBAAmB;AAAA,cACnB,oBACE,CAAC,eAAe,MAAM,WAAW,aAAa,GAAG,eAAe,EAC7D,KAAK,GAAG,EACR,UAAU;AAAA,cAEf;AAAA,cACA;AAAA,cACA,mBAAmB;AAAA,cAClB,GAAG;AAAA,cAEJ,UAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,IAAI,MAAM,WAAW,QAAQ;AAAA,kBAC7B,SAAS;AAAA,oBACP,UAAU,QAAQ;AAAA,oBAClB,uBAAuB,QAAQ;AAAA,kBACjC;AAAA,kBACA,QAAQ;AAAA,kBACR;AAAA,kBACA;AAAA,kBACA,UAAU;AAAA,kBACV,UAAU;AAAA,kBACV;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,cAAY;AAAA,kBACZ,mBAAiB,WAAW,MAAM,WAAW,OAAO,IAAI;AAAA,kBACxD;AAAA,kBACA;AAAA,kBACA;AAAA,kBACC,GAAG;AAAA,gBAAA;AAAA,cACN;AAAA,YAAA;AAAA,UACF;AAAA,UACC,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../../../src/Dropdown/Dropdown.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n isInvalid,\n} from \"../Forms\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListValue } from \"../List\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { getSelected, getSelectionLabel } from \"./utils\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport type HvDropdownStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvDropdownProps<\n // TODO: make default `false` in v6\n Multiple extends boolean = boolean,\n OptionValue extends HvListValue = HvListValue,\n> extends Omit<HvFormElementProps, \"value\" | \"onChange\">,\n Pick<\n HvBaseDropdownProps,\n | \"placement\"\n | \"popperProps\"\n | \"disablePortal\"\n | \"variableWidth\"\n | \"expanded\"\n | \"defaultExpanded\"\n > {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\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?: (\n selected: Multiple extends true ? OptionValue[] : OptionValue | undefined,\n ) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: OptionValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: Multiple;\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 will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabels;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\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?: Partial<HvDropdownListProps>;\n}\n\nconst DEFAULT_LABELS = {\n /** Label for overwrite the default header behavior. */\n select: undefined as string | undefined,\n /** Label used for the All checkbox action. */\n selectAll: \"All\",\n /** Cancel button label. */\n cancelLabel: \"Cancel\",\n /** Apply button label. */\n applyLabel: \"Apply\",\n /** The label used in the middle of the multiSelection count. */\n searchPlaceholder: \"Search\",\n /** The label used in search. */\n multiSelectionConjunction: \"/\",\n};\n\nexport type HvDropdownLabels = Partial<typeof DEFAULT_LABELS>;\n/** @deprecated use `HvDropdownLabels` instead */\nexport type HvDropdownLabelsProps = HvDropdownLabels;\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 = fixedForwardRef(function HvDropdown<\n Multiple extends boolean = false,\n OptionValue extends HvListValue = HvListValue,\n>(\n props: HvDropdownProps<Multiple, OptionValue>,\n ref: React.Ref<HTMLDivElement>,\n) {\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,\n expanded,\n defaultExpanded,\n notifyChangesOnFirstRender,\n labels: labelsProp,\n hasTooltips,\n disablePortal,\n singleSelectionToggle = true,\n placement,\n variableWidth,\n popperProps = {},\n height,\n maxHeight,\n virtualized,\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);\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\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(dropdownHeaderRefProp, dropdownHeaderRef);\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 as any);\n internalValuesRef.current = listValues as any;\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) {\n onChange?.((multiSelect ? selected : selected[0]) as any);\n }\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 ? [...containerRef.getElementsByTagName(\"li\")] : [];\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"],"names":["HvDropdown"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkKA,MAAM,iBAAiB;AAAA;AAAA,EAErB,QAAQ;AAAA;AAAA,EAER,WAAW;AAAA;AAAA,EAEX,aAAa;AAAA;AAAA,EAEb,YAAY;AAAA;AAAA,EAEZ,mBAAmB;AAAA;AAAA,EAEnB,2BAA2B;AAC7B;AASO,MAAM,aAAa,gBAAgB,SAASA,YAIjD,OACA,KACA;AACM,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IAEA;AAAA,IACA;AAAA,IAEA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IAEX;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IAEpB,cAAc;AAAA,IAEd;AAAA,IAEA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IAErB;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IAEA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,wBAAwB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,cAAc,CAAC;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,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IAAI,MAAM,WAAW,QAAQ;AAAA,gBAC7B,SAAS;AAAA,kBACP,UAAU,QAAQ;AAAA,kBAClB,uBAAuB,QAAQ;AAAA,gBACjC;AAAA,gBACA,QAAQ;AAAA,gBACR;AAAA,gBACA;AAAA,gBACA,UAAU;AAAA,gBACV,UAAU;AAAA,gBACV;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,cAAY;AAAA,gBACZ,mBAAiB,WAAW,MAAM,WAAW,OAAO,IAAI;AAAA,gBACxD;AAAA,gBACA;AAAA,gBACA;AAAA,gBACC,GAAG;AAAA,cAAA;AAAA,YACN;AAAA,UAAA;AAAA,QACF;AAAA,QACC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
@@ -55,11 +55,13 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
55
55
  onBlur?.(event, newValue);
56
56
  };
57
57
  const handleKeyDown = (event) => {
58
+ let newValue = value;
58
59
  if (isKey(event, "Esc")) {
60
+ newValue = cachedValue;
59
61
  setEditMode(false);
60
- setValue(cachedValue);
62
+ setValue(newValue);
61
63
  }
62
- onKeyDown?.(event);
64
+ onKeyDown?.(event, newValue);
63
65
  };
64
66
  const handleChange = (event, val) => {
65
67
  setValue(val);
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useEnhancedEffect } from \"../hooks/useEnhancedEffect\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n HvTypography,\n HvTypographyProps,\n HvTypographyVariants,\n} from \"../Typography\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./InlineEditor.styles\";\n\nexport { staticClasses as inlineEditorClasses };\n\nexport type HvInlineEditorClasses = ExtractNames<typeof useClasses>;\n\nexport type HvInlineEditorProps<C extends React.ElementType = typeof HvInput> =\n PolymorphicComponentRef<\n C,\n {\n /** The value of the form element. */\n value?: string;\n /** The default value of the form element. */\n defaultValue?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string,\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** Whether the editor is disabled or not. */\n disabled?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n /** The placeholder value of the input. */\n placeholder?: string;\n }\n >;\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = fixedForwardRef(function HvInlineEditor<\n C extends React.ElementType = typeof HvInput,\n>(props: HvInlineEditorProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n classes: classesProp,\n value: valueProp,\n defaultValue = \"\",\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n disabled,\n ...others\n } = useDefaultProps(\"HvInlineEditor\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n const { activeTheme } = useTheme();\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n useEnhancedEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur: HvInputProps[\"onBlur\"] = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown: HvInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event as any);\n };\n\n const handleChange: HvInputProps[\"onChange\"] = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <div className={cx(classes.root, className)}>\n {editMode && !disabled ? (\n <InputComponent\n ref={ref}\n inputRef={inputRef}\n classes={{\n root: classes.inputRoot,\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n endIcon={\n <Edit\n color=\"secondary_60\"\n className={cx(classes.icon, {\n [classes.iconVisible]: showIcon,\n })}\n />\n }\n className={cx(classes.button, {\n [classes.largeText]: parseInt(lineHeight as string, 10) >= 28,\n })}\n onClick={handleClick}\n disabled={disabled}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >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AAA,CAAA;AAEJ,CAAC;"}
1
+ {"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useEnhancedEffect } from \"../hooks/useEnhancedEffect\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n HvTypography,\n HvTypographyProps,\n HvTypographyVariants,\n} from \"../Typography\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./InlineEditor.styles\";\n\nexport { staticClasses as inlineEditorClasses };\n\nexport type HvInlineEditorClasses = ExtractNames<typeof useClasses>;\n\nexport type HvInlineEditorProps<C extends React.ElementType = typeof HvInput> =\n PolymorphicComponentRef<\n C,\n {\n /** The value of the form element. */\n value?: string;\n /** The default value of the form element. */\n defaultValue?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string,\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Called when there's a keydown event on the input. */\n onKeyDown?: (\n event:\n | React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>\n | React.MouseEvent,\n value: string,\n ) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** Whether the editor is disabled or not. */\n disabled?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n /** The placeholder value of the input. */\n placeholder?: string;\n }\n >;\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = fixedForwardRef(function HvInlineEditor<\n C extends React.ElementType = typeof HvInput,\n>(props: HvInlineEditorProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n classes: classesProp,\n value: valueProp,\n defaultValue = \"\",\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n disabled,\n ...others\n } = useDefaultProps(\"HvInlineEditor\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n const { activeTheme } = useTheme();\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n useEnhancedEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur: HvInputProps[\"onBlur\"] = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown: HvInputProps[\"onKeyDown\"] = (event) => {\n let newValue = value;\n if (isKey(event, \"Esc\")) {\n newValue = cachedValue;\n setEditMode(false);\n setValue(newValue);\n }\n onKeyDown?.(event, newValue);\n };\n\n const handleChange: HvInputProps[\"onChange\"] = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <div className={cx(classes.root, className)}>\n {editMode && !disabled ? (\n <InputComponent\n ref={ref}\n inputRef={inputRef}\n classes={{\n root: classes.inputRoot,\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n endIcon={\n <Edit\n color=\"secondary_60\"\n className={cx(classes.icon, {\n [classes.iconVisible]: showIcon,\n })}\n />\n }\n className={cx(classes.button, {\n [classes.largeText]: parseInt(lineHeight as string, 10) >= 28,\n })}\n onClick={handleClick}\n disabled={disabled}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n </HvButton>\n )}\n </div>\n );\n});\n"],"names":["HvInlineEditor"],"mappings":";;;;;;;;;;;;;AAwEO,MAAM,iBAAiB,gBAAgB,SAASA,gBAErD,OAA+B,KAAwB;AACjD,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,OAAO;AAAA,IACP,eAAe;AAAA,IACf;AAAA,IACA,WAAW,iBAAiB;AAAA,IAC5B,UAAU;AAAA,IACV,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,kBAAkB,KAAK;AAE3C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAI,cAAc,WAAW,YAAY;AAC/D,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,WAAW;AACX,QAAA,EAAE,gBAAgB;AAExB,QAAM,mBAAmB,aAAa,WAAW,OAAO,KAAK,CAAA;AACvD,QAAA,EAAE,WAAe,IAAA;AAEvB,oBAAkB,MAAM;AACtB,UAAM,QAAQ,SAA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B,CAAC,QAAQ,WAAW,GAAG;AAAA,UAAA,CACxB;AAAA,QAAA;AAAA,MACH;AAAA,MAEF,WAAW,GAAG,QAAQ,QAAQ;AAAA,QAC5B,CAAC,QAAQ,SAAS,GAAG,SAAS,YAAsB,EAAE,KAAK;AAAA,MAAA,CAC5D;AAAA,MACD,SAAS;AAAA,MACT;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,QAAM;AAAA,UACN,WAAW,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,SAAS,GAAG,CAAC,OAAO;AAAA,UAC1D,GAAG;AAAA,UAEH,UAAS,SAAA;AAAA,QAAA;AAAA,MACZ;AAAA,IAAA;AAAA,EAGN,EAAA,CAAA;AAEJ,CAAC;"}
@@ -31,7 +31,7 @@ const Attribute = ({
31
31
  status: isInvalid ? "invalid" : "valid",
32
32
  statusMessage: labels.rule.attribute.exists,
33
33
  onChange: (selected) => {
34
- if (selected && !Array.isArray(selected)) {
34
+ if (selected) {
35
35
  const attributeId = selected.id;
36
36
  const type = attributes && attributeId && attributes[attributeId]?.type;
37
37
  const typeOperators = type ? operators[type] : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"Attribute.js","sources":["../../../../../src/QueryBuilder/Rule/Attribute/Attribute.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface AttributeProps {\n id: React.Key;\n attribute?: string;\n disabled?: boolean;\n isInvalid?: boolean;\n}\n\nexport const Attribute = ({\n id,\n attribute,\n disabled,\n isInvalid,\n}: AttributeProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const values = useMemo(() => {\n if (!attributes) return [];\n\n return Object.keys(attributes).map((key) => ({\n id: key,\n label: attributes[key].label,\n selected: key === attribute,\n }));\n }, [attributes, attribute]);\n\n const currentType =\n attribute != null && attributes ? attributes[attribute]?.type : null;\n\n return (\n <HvDropdown\n singleSelectionToggle={false}\n label={labels.rule.attribute.label}\n placeholder={labels.rule.attribute.placeholder}\n values={values}\n disabled={disabled}\n readOnly={readOnly}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={labels.rule.attribute.exists}\n onChange={(selected) => {\n if (selected && !Array.isArray(selected)) {\n const attributeId = selected.id;\n\n const type =\n attributes && attributeId && attributes[attributeId]?.type;\n const typeOperators = type ? operators[type] : undefined;\n\n let operator;\n if (currentType === type) {\n operator = undefined;\n } else if (typeOperators?.length === 1) {\n operator = typeOperators[0].operator;\n } else {\n operator = null;\n }\n\n // default boolean attributes to true\n const value = type === \"boolean\" ? true : undefined;\n\n dispatchAction({\n type: \"set-attribute\",\n id,\n attribute: attributeId?.toString(),\n operator,\n value,\n });\n } else {\n dispatchAction({ type: \"set-attribute\", id, attribute: null });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(Attribute);\n"],"names":[],"mappings":";;;;;AAaO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAsB;AACpB,QAAM,EAAE,gBAAgB,YAAY,WAAW,QAAQ,SAAA,IACrD;AAEI,QAAA,SAAS,QAAQ,MAAM;AACvB,QAAA,CAAC,WAAY,QAAO;AAExB,WAAO,OAAO,KAAK,UAAU,EAAE,IAAI,CAAC,SAAS;AAAA,MAC3C,IAAI;AAAA,MACJ,OAAO,WAAW,GAAG,EAAE;AAAA,MACvB,UAAU,QAAQ;AAAA,IAClB,EAAA;AAAA,EAAA,GACD,CAAC,YAAY,SAAS,CAAC;AAE1B,QAAM,cACJ,aAAa,QAAQ,aAAa,WAAW,SAAS,GAAG,OAAO;AAGhE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,UAAU;AAAA,MAC7B,aAAa,OAAO,KAAK,UAAU;AAAA,MACnC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,YAAY,YAAY;AAAA,MAChC,eAAe,OAAO,KAAK,UAAU;AAAA,MACrC,UAAU,CAAC,aAAa;AACtB,YAAI,YAAY,CAAC,MAAM,QAAQ,QAAQ,GAAG;AACxC,gBAAM,cAAc,SAAS;AAE7B,gBAAM,OACJ,cAAc,eAAe,WAAW,WAAW,GAAG;AACxD,gBAAM,gBAAgB,OAAO,UAAU,IAAI,IAAI;AAE3C,cAAA;AACJ,cAAI,gBAAgB,MAAM;AACb,uBAAA;AAAA,UAAA,WACF,eAAe,WAAW,GAAG;AAC3B,uBAAA,cAAc,CAAC,EAAE;AAAA,UAAA,OACvB;AACM,uBAAA;AAAA,UACb;AAGM,gBAAA,QAAQ,SAAS,YAAY,OAAO;AAE3B,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,WAAW,aAAa,SAAS;AAAA,YACjC;AAAA,YACA;AAAA,UAAA,CACD;AAAA,QAAA,OACI;AACL,yBAAe,EAAE,MAAM,iBAAiB,IAAI,WAAW,MAAM;AAAA,QAC/D;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,SAAS;"}
1
+ {"version":3,"file":"Attribute.js","sources":["../../../../../src/QueryBuilder/Rule/Attribute/Attribute.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface AttributeProps {\n id: React.Key;\n attribute?: string;\n disabled?: boolean;\n isInvalid?: boolean;\n}\n\nexport const Attribute = ({\n id,\n attribute,\n disabled,\n isInvalid,\n}: AttributeProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const values = useMemo(() => {\n if (!attributes) return [];\n\n return Object.keys(attributes).map((key) => ({\n id: key,\n label: attributes[key].label,\n selected: key === attribute,\n }));\n }, [attributes, attribute]);\n\n const currentType =\n attribute != null && attributes ? attributes[attribute]?.type : null;\n\n return (\n <HvDropdown\n singleSelectionToggle={false}\n label={labels.rule.attribute.label}\n placeholder={labels.rule.attribute.placeholder}\n values={values}\n disabled={disabled}\n readOnly={readOnly}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={labels.rule.attribute.exists}\n onChange={(selected) => {\n if (selected) {\n const attributeId = selected.id;\n\n const type =\n attributes && attributeId && attributes[attributeId]?.type;\n const typeOperators = type ? operators[type] : undefined;\n\n let operator;\n if (currentType === type) {\n operator = undefined;\n } else if (typeOperators?.length === 1) {\n operator = typeOperators[0].operator;\n } else {\n operator = null;\n }\n\n // default boolean attributes to true\n const value = type === \"boolean\" ? true : undefined;\n\n dispatchAction({\n type: \"set-attribute\",\n id,\n attribute: attributeId?.toString(),\n operator,\n value,\n });\n } else {\n dispatchAction({ type: \"set-attribute\", id, attribute: null });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(Attribute);\n"],"names":[],"mappings":";;;;;AAaO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAsB;AACpB,QAAM,EAAE,gBAAgB,YAAY,WAAW,QAAQ,SAAA,IACrD;AAEI,QAAA,SAAS,QAAQ,MAAM;AACvB,QAAA,CAAC,WAAY,QAAO;AAExB,WAAO,OAAO,KAAK,UAAU,EAAE,IAAI,CAAC,SAAS;AAAA,MAC3C,IAAI;AAAA,MACJ,OAAO,WAAW,GAAG,EAAE;AAAA,MACvB,UAAU,QAAQ;AAAA,IAClB,EAAA;AAAA,EAAA,GACD,CAAC,YAAY,SAAS,CAAC;AAE1B,QAAM,cACJ,aAAa,QAAQ,aAAa,WAAW,SAAS,GAAG,OAAO;AAGhE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,UAAU;AAAA,MAC7B,aAAa,OAAO,KAAK,UAAU;AAAA,MACnC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,YAAY,YAAY;AAAA,MAChC,eAAe,OAAO,KAAK,UAAU;AAAA,MACrC,UAAU,CAAC,aAAa;AACtB,YAAI,UAAU;AACZ,gBAAM,cAAc,SAAS;AAE7B,gBAAM,OACJ,cAAc,eAAe,WAAW,WAAW,GAAG;AACxD,gBAAM,gBAAgB,OAAO,UAAU,IAAI,IAAI;AAE3C,cAAA;AACJ,cAAI,gBAAgB,MAAM;AACb,uBAAA;AAAA,UAAA,WACF,eAAe,WAAW,GAAG;AAC3B,uBAAA,cAAc,CAAC,EAAE;AAAA,UAAA,OACvB;AACM,uBAAA;AAAA,UACb;AAGM,gBAAA,QAAQ,SAAS,YAAY,OAAO;AAE3B,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,WAAW,aAAa,SAAS;AAAA,YACjC;AAAA,YACA;AAAA,UAAA,CACD;AAAA,QAAA,OACI;AACL,yBAAe,EAAE,MAAM,iBAAiB,IAAI,WAAW,MAAM;AAAA,QAC/D;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,SAAS;"}
@@ -34,7 +34,7 @@ const Operator = ({
34
34
  disabled: values.length === 0,
35
35
  readOnly,
36
36
  onChange: (selected) => {
37
- if (selected && !Array.isArray(selected) && selected.id) {
37
+ if (selected?.id) {
38
38
  dispatchAction({
39
39
  type: "set-operator",
40
40
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"Operator.js","sources":["../../../../../src/QueryBuilder/Rule/Operator/Operator.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface OperatorProps {\n id: React.Key;\n combinator: string;\n attribute: string;\n operator?: string;\n}\n\nexport const Operator = ({\n id,\n combinator,\n attribute,\n operator,\n}: OperatorProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const value = operator ?? null;\n\n const values = useMemo(() => {\n const attributeSpec =\n attribute && attributes ? attributes[attribute] : null;\n const options = attributeSpec\n ? (operators[attributeSpec.type].filter((o) =>\n o.combinators.includes(combinator),\n ) ?? [])\n : [];\n return options.map((key) => ({\n id: key.operator,\n label: key.label,\n selected: key.operator === value,\n }));\n }, [attribute, attributes, operators, combinator, value]);\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.operator.label}\n placeholder={labels.rule.operator.placeholder}\n values={values}\n disabled={values.length === 0}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected && !Array.isArray(selected) && selected.id) {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: selected.id.toString(),\n value:\n value === \"range\" || selected.id === \"range\" ? null : undefined,\n });\n } else {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: null,\n value: null,\n });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(Operator);\n"],"names":[],"mappings":";;;;;AAaO,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,EAAE,gBAAgB,YAAY,WAAW,QAAQ,SAAA,IACrD;AAEF,QAAM,QAAQ,YAAY;AAEpB,QAAA,SAAS,QAAQ,MAAM;AAC3B,UAAM,gBACJ,aAAa,aAAa,WAAW,SAAS,IAAI;AACpD,UAAM,UAAU,gBACX,UAAU,cAAc,IAAI,EAAE;AAAA,MAAO,CAAC,MACrC,EAAE,YAAY,SAAS,UAAU;AAAA,IAAA,KAC9B,CAAA,IACL,CAAA;AACG,WAAA,QAAQ,IAAI,CAAC,SAAS;AAAA,MAC3B,IAAI,IAAI;AAAA,MACR,OAAO,IAAI;AAAA,MACX,UAAU,IAAI,aAAa;AAAA,IAC3B,EAAA;AAAA,EAAA,GACD,CAAC,WAAW,YAAY,WAAW,YAAY,KAAK,CAAC;AAGtD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAQ;AAAA,MACR,QAAO;AAAA,MACP,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,SAAS;AAAA,MAC5B,aAAa,OAAO,KAAK,SAAS;AAAA,MAClC;AAAA,MACA,UAAU,OAAO,WAAW;AAAA,MAC5B;AAAA,MACA,UAAU,CAAC,aAAa;AACtB,YAAI,YAAY,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,IAAI;AACxC,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,UAAU,SAAS,GAAG,SAAS;AAAA,YAC/B,OACE,UAAU,WAAW,SAAS,OAAO,UAAU,OAAO;AAAA,UAAA,CACzD;AAAA,QAAA,OACI;AACU,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,UAAU;AAAA,YACV,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,QAAQ;"}
1
+ {"version":3,"file":"Operator.js","sources":["../../../../../src/QueryBuilder/Rule/Operator/Operator.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\n\nimport { HvDropdown } from \"../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../Context\";\nimport { isBigList } from \"../../utils\";\n\nexport interface OperatorProps {\n id: React.Key;\n combinator: string;\n attribute: string;\n operator?: string;\n}\n\nexport const Operator = ({\n id,\n combinator,\n attribute,\n operator,\n}: OperatorProps) => {\n const { dispatchAction, attributes, operators, labels, readOnly } =\n useQueryBuilderContext();\n\n const value = operator ?? null;\n\n const values = useMemo(() => {\n const attributeSpec =\n attribute && attributes ? attributes[attribute] : null;\n const options = attributeSpec\n ? (operators[attributeSpec.type].filter((o) =>\n o.combinators.includes(combinator),\n ) ?? [])\n : [];\n return options.map((key) => ({\n id: key.operator,\n label: key.label,\n selected: key.operator === value,\n }));\n }, [attribute, attributes, operators, combinator, value]);\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.operator.label}\n placeholder={labels.rule.operator.placeholder}\n values={values}\n disabled={values.length === 0}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected?.id) {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: selected.id.toString(),\n value:\n value === \"range\" || selected.id === \"range\" ? null : undefined,\n });\n } else {\n dispatchAction({\n type: \"set-operator\",\n id,\n operator: null,\n value: null,\n });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(Operator);\n"],"names":[],"mappings":";;;;;AAaO,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,EAAE,gBAAgB,YAAY,WAAW,QAAQ,SAAA,IACrD;AAEF,QAAM,QAAQ,YAAY;AAEpB,QAAA,SAAS,QAAQ,MAAM;AAC3B,UAAM,gBACJ,aAAa,aAAa,WAAW,SAAS,IAAI;AACpD,UAAM,UAAU,gBACX,UAAU,cAAc,IAAI,EAAE;AAAA,MAAO,CAAC,MACrC,EAAE,YAAY,SAAS,UAAU;AAAA,IAAA,KAC9B,CAAA,IACL,CAAA;AACG,WAAA,QAAQ,IAAI,CAAC,SAAS;AAAA,MAC3B,IAAI,IAAI;AAAA,MACR,OAAO,IAAI;AAAA,MACX,UAAU,IAAI,aAAa;AAAA,IAC3B,EAAA;AAAA,EAAA,GACD,CAAC,WAAW,YAAY,WAAW,YAAY,KAAK,CAAC;AAGtD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAQ;AAAA,MACR,QAAO;AAAA,MACP,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,SAAS;AAAA,MAC5B,aAAa,OAAO,KAAK,SAAS;AAAA,MAClC;AAAA,MACA,UAAU,OAAO,WAAW;AAAA,MAC5B;AAAA,MACA,UAAU,CAAC,aAAa;AACtB,YAAI,UAAU,IAAI;AACD,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,UAAU,SAAS,GAAG,SAAS;AAAA,YAC/B,OACE,UAAU,WAAW,SAAS,OAAO,UAAU,OAAO;AAAA,UAAA,CACzD;AAAA,QAAA,OACI;AACU,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,UAAU;AAAA,YACV,OAAO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,QAAQ;"}
@@ -21,7 +21,7 @@ const BooleanValue = ({ id, value = true }) => {
21
21
  values,
22
22
  readOnly,
23
23
  onChange: (selected) => {
24
- if (selected && !Array.isArray(selected) && selected.id) {
24
+ if (selected?.id) {
25
25
  dispatchAction({
26
26
  type: "set-value",
27
27
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"BooleanValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { HvDropdown } from \"../../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { isBigList } from \"../../../utils\";\n\nexport interface BooleanValueProps {\n id: React.Key;\n value?: boolean;\n}\n\nexport const BooleanValue = ({ id, value = true }: BooleanValueProps) => {\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const values = [\"true\", \"false\"].map((v) => ({\n id: v,\n label: labels.rule.value.boolean.options[v],\n selected: value === (v === \"true\"),\n }));\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.value.boolean.label}\n placeholder={labels.rule.value.boolean.placeholder}\n values={values}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected && !Array.isArray(selected) && selected.id) {\n dispatchAction({\n type: \"set-value\",\n id,\n value: selected.id === \"true\",\n });\n } else {\n dispatchAction({ type: \"set-value\", id, value: null });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(BooleanValue);\n"],"names":[],"mappings":";;;;;AAWO,MAAM,eAAe,CAAC,EAAE,IAAI,QAAQ,WAA8B;AACvE,QAAM,EAAE,QAAQ,gBAAgB,aAAa,uBAAuB;AAEpE,QAAM,SAAS,CAAC,QAAQ,OAAO,EAAE,IAAI,CAAC,OAAO;AAAA,IAC3C,IAAI;AAAA,IACJ,OAAO,OAAO,KAAK,MAAM,QAAQ,QAAQ,CAAC;AAAA,IAC1C,UAAU,WAAW,MAAM;AAAA,EAC3B,EAAA;AAGA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAQ;AAAA,MACR,QAAO;AAAA,MACP,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,MAAM,QAAQ;AAAA,MACjC,aAAa,OAAO,KAAK,MAAM,QAAQ;AAAA,MACvC;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aAAa;AACtB,YAAI,YAAY,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,IAAI;AACxC,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,OAAO,SAAS,OAAO;AAAA,UAAA,CACxB;AAAA,QAAA,OACI;AACL,yBAAe,EAAE,MAAM,aAAa,IAAI,OAAO,MAAM;AAAA,QACvD;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,YAAY;"}
1
+ {"version":3,"file":"BooleanValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { HvDropdown } from \"../../../../Dropdown\";\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { isBigList } from \"../../../utils\";\n\nexport interface BooleanValueProps {\n id: React.Key;\n value?: boolean;\n}\n\nexport const BooleanValue = ({ id, value = true }: BooleanValueProps) => {\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const values = [\"true\", \"false\"].map((v) => ({\n id: v,\n label: labels.rule.value.boolean.options[v],\n selected: value === (v === \"true\"),\n }));\n\n return (\n <HvDropdown\n required\n status=\"valid\"\n singleSelectionToggle={false}\n label={labels.rule.value.boolean.label}\n placeholder={labels.rule.value.boolean.placeholder}\n values={values}\n readOnly={readOnly}\n onChange={(selected) => {\n if (selected?.id) {\n dispatchAction({\n type: \"set-value\",\n id,\n value: selected.id === \"true\",\n });\n } else {\n dispatchAction({ type: \"set-value\", id, value: null });\n }\n }}\n showSearch={isBigList(values)}\n {...(isBigList(values) && { virtualized: true, height: 300 })}\n />\n );\n};\n\nexport default memo(BooleanValue);\n"],"names":[],"mappings":";;;;;AAWO,MAAM,eAAe,CAAC,EAAE,IAAI,QAAQ,WAA8B;AACvE,QAAM,EAAE,QAAQ,gBAAgB,aAAa,uBAAuB;AAEpE,QAAM,SAAS,CAAC,QAAQ,OAAO,EAAE,IAAI,CAAC,OAAO;AAAA,IAC3C,IAAI;AAAA,IACJ,OAAO,OAAO,KAAK,MAAM,QAAQ,QAAQ,CAAC;AAAA,IAC1C,UAAU,WAAW,MAAM;AAAA,EAC3B,EAAA;AAGA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAQ;AAAA,MACR,QAAO;AAAA,MACP,uBAAuB;AAAA,MACvB,OAAO,OAAO,KAAK,MAAM,QAAQ;AAAA,MACjC,aAAa,OAAO,KAAK,MAAM,QAAQ;AAAA,MACvC;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aAAa;AACtB,YAAI,UAAU,IAAI;AACD,yBAAA;AAAA,YACb,MAAM;AAAA,YACN;AAAA,YACA,OAAO,SAAS,OAAO;AAAA,UAAA,CACxB;AAAA,QAAA,OACI;AACL,yBAAe,EAAE,MAAM,aAAa,IAAI,OAAO,MAAM;AAAA,QACvD;AAAA,MACF;AAAA,MACA,YAAY,UAAU,MAAM;AAAA,MAC3B,GAAI,UAAU,MAAM,KAAK,EAAE,aAAa,MAAM,QAAQ,IAAI;AAAA,IAAA;AAAA,EAAA;AAGjE;AAEe,KAAK,YAAY;"}
@@ -1,24 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { HvDropdown } from "../../../Dropdown/Dropdown.js";
3
3
  const HvDropdownColumnCell = ({
4
- values,
5
- disabled,
6
- onChange,
7
- placeholder,
8
- dropdownProps
4
+ dropdownProps,
5
+ ...others
9
6
  }) => {
10
- return /* @__PURE__ */ jsx(
11
- HvDropdown,
12
- {
13
- onChange: (item) => {
14
- onChange?.(item);
15
- },
16
- placeholder,
17
- disabled,
18
- values,
19
- ...dropdownProps
20
- }
21
- );
7
+ return /* @__PURE__ */ jsx(HvDropdown, { ...dropdownProps, ...others });
22
8
  };
23
9
  export {
24
10
  HvDropdownColumnCell
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownColumnCell.js","sources":["../../../../../src/Table/renderers/DropdownColumnCell/DropdownColumnCell.tsx"],"sourcesContent":["import { HvDropdown, HvDropdownProps } from \"../../../Dropdown\";\nimport { HvListValue } from \"../../../List\";\n\nexport interface HvDropdownColumnCellProp {\n /** Values to render in the dropdown. */\n values?: HvListValue[];\n /** Placeholder text for when the dropdown is empty. */\n placeholder?: string;\n /** Whether the dropdown is disabled. */\n disabled?: boolean;\n /** Function called when there is change on the dropdown. */\n onChange?: (value: HvListValue) => void;\n /** Extra props to be passed onto the dropdown. */\n dropdownProps?: HvDropdownProps;\n}\n\nexport const HvDropdownColumnCell = ({\n values,\n disabled,\n onChange,\n placeholder,\n dropdownProps,\n}: HvDropdownColumnCellProp): JSX.Element => {\n return (\n <HvDropdown\n onChange={(item) => {\n onChange?.(item as HvListValue);\n }}\n placeholder={placeholder}\n disabled={disabled}\n values={values}\n {...dropdownProps}\n />\n );\n};\n"],"names":[],"mappings":";;AAgBO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6C;AAEzC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAU,CAAC,SAAS;AAClB,mBAAW,IAAmB;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
1
+ {"version":3,"file":"DropdownColumnCell.js","sources":["../../../../../src/Table/renderers/DropdownColumnCell/DropdownColumnCell.tsx"],"sourcesContent":["import { HvDropdown, HvDropdownProps } from \"../../../Dropdown\";\n\nexport interface HvDropdownColumnCellProp extends HvDropdownProps<false> {\n /** Extra props to be passed onto the dropdown. @deprecated pass props directly */\n dropdownProps?: HvDropdownProps<false>;\n}\n\nexport const HvDropdownColumnCell = ({\n dropdownProps,\n ...others\n}: HvDropdownColumnCellProp) => {\n return <HvDropdown {...dropdownProps} {...others} />;\n};\n"],"names":[],"mappings":";;AAOO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,SAAQ,oBAAA,YAAA,EAAY,GAAG,eAAgB,GAAG,OAAQ,CAAA;AACpD;"}
@@ -141,11 +141,8 @@ function hvDropdownColumn(col, id, placeholder, disabledPlaceholder, onChange, d
141
141
  placeholder: disabled ? disabledPlaceholder : placeholder,
142
142
  onChange: (val) => onChange?.(row.id, val),
143
143
  disabled,
144
- dropdownProps: {
145
- "aria-labelledby": setId(id, column.id) || column.id || id,
146
- // TODO - to be reviewed because it doesn't make much sense
147
- ...dropdownProps
148
- }
144
+ "aria-labelledby": setId(id, column.id) || column.id || id,
145
+ ...dropdownProps
149
146
  }
150
147
  );
151
148
  },
@@ -1 +1 @@
1
- {"version":3,"file":"renderers.js","sources":["../../../../src/Table/renderers/renderers.tsx"],"sourcesContent":["import { ClassNames } from \"@emotion/react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseSwitchProps } from \"../../BaseSwitch\";\nimport { HvButton } from \"../../Button\";\nimport { HvDropdownProps } from \"../../Dropdown\";\nimport { HvListValue } from \"../../List\";\nimport {\n HvOverflowTooltip,\n HvOverflowTooltipProps,\n} from \"../../OverflowTooltip\";\nimport { HvTag, HvTagProps } from \"../../Tag\";\nimport { HvTypography } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport {\n HvCellProps,\n HvRowInstance,\n HvTableColumnConfig,\n HvTableHeaderRenderer,\n} from \"../hooks/useTable\";\nimport { hvNumberFallback, hvStringFallback } from \"../utils\";\nimport { HvDateColumnCell } from \"./DateColumnCell\";\nimport { HvDropdownColumnCell } from \"./DropdownColumnCell\";\nimport { HvProgressColumnCell } from \"./ProgressColumnCell\";\nimport { HvSwitchColumnCell } from \"./SwitchColumnCell\";\n\nexport function hvTextColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n overflowTooltipProps: Omit<HvOverflowTooltipProps, \"data\"> = {},\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvOverflowTooltip\n data={hvStringFallback(value)}\n {...overflowTooltipProps}\n />\n ),\n sortType: \"alphanumeric\",\n ...col,\n };\n}\n\nexport function hvNumberColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(col: HvTableColumnConfig<D, H>): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => <>{hvNumberFallback(value)}</>,\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n}\n\nexport function hvDateColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n dateFormat?: string,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvDateColumnCell date={value} dateFormat={dateFormat} />\n ),\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n}\n\nexport function hvExpandColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n expandRowButtonAriaLabel: string,\n collapseRowButtonAriaLabel: string,\n getCanRowExpand?: (row: HvRowInstance<D, H>) => boolean,\n ExpandedIcon: React.ReactNode = <DropUpXS />,\n CollapsedIcon: React.ReactNode = <DropDownXS />,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n const expandedProps = row.getToggleRowExpandedProps?.();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <ClassNames>\n {({ css }) => (\n <>\n {hasContent && (\n <HvButton\n icon\n aria-label={\n row.isExpanded\n ? collapseRowButtonAriaLabel\n : expandRowButtonAriaLabel\n }\n aria-expanded={row.isExpanded}\n onClick={expandedProps?.onClick}\n classes={{\n root: css({\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n transform: \"translateY(-50%)\",\n }),\n }}\n >\n {row.isExpanded ? ExpandedIcon : CollapsedIcon}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n )}\n </ClassNames>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n A extends object = Record<string, unknown>,\n>(\n col: HvTableColumnConfig<D, H>,\n valueDataKey: keyof A,\n colorDataKey: keyof A,\n textColorDataKey: keyof A,\n fromRowData = false,\n tagProps?: HvTagProps,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n if (!value) {\n return <>—</>;\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"body\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\n// TODO - Review accessibility on the next renderers because they all differ\n\nexport function hvSwitchColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n switchLabel: string,\n falseLabel?: string,\n trueLabel?: string,\n switchProps?: HvBaseSwitchProps,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n return (\n <HvSwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n id: string | undefined,\n placeholder: string,\n disabledPlaceholder: string,\n onChange?: (identifier: string, value: HvListValue) => void,\n dropdownProps?: HvDropdownProps,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row, column } = cellProps;\n const disabled =\n !Array.isArray(value) || (Array.isArray(value) && value.length < 1);\n return (\n <HvDropdownColumnCell\n values={value}\n placeholder={disabled ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val)}\n disabled={disabled}\n dropdownProps={{\n \"aria-labelledby\": setId(id, column.id) || column.id || id, // TODO - to be reviewed because it doesn't make much sense\n ...dropdownProps,\n }}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n getPartial?: (row: HvRowInstance<D, H>) => number,\n getTotal?: (row: HvRowInstance<D, H>) => number,\n color?: \"primary\" | \"secondary\",\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { row, column } = cellProps;\n const partial = getPartial?.(row) || 0;\n const total = getTotal?.(row);\n\n if (total) {\n return (\n <HvProgressColumnCell\n partial={partial}\n total={total}\n color={color}\n aria-labelledby={column.id}\n />\n );\n }\n\n return <>—</>;\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0BO,SAAS,aAId,KACA,uBAA6D,IAClC;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,EAAE,MAAA,MACP;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAM,iBAAiB,KAAK;AAAA,QAC3B,GAAG;AAAA,MAAA;AA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A,eAC2B;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,cAAiC;AACtC,YAAM,EAAE,OAAO,KAAK,OAAA,IAAW;AACzB,YAAA,WACJ,CAAC,MAAM,QAAQ,KAAK,KAAM,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS;AAEjE,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,QAAQ;AAAA,UACR,aAAa,WAAW,sBAAsB;AAAA,UAC9C,UAAU,CAAC,QAAQ,WAAW,IAAI,IAAI,GAAG;AAAA,UACzC;AAAA,UACA,eAAe;AAAA,YACb,mBAAmB,MAAM,IAAI,OAAO,EAAE,KAAK,OAAO,MAAM;AAAA;AAAA,YACxD,GAAG;AAAA,UACL;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,eAAe;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EAAA;AAEP;AAEO,SAAS,iBAId,KACA,YACA,UACA,OAC2B;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,cAAiC;AAChC,YAAA,EAAE,KAAK,OAAW,IAAA;AAClB,YAAA,UAAU,aAAa,GAAG,KAAK;AAC/B,YAAA,QAAQ,WAAW,GAAG;AAE5B,UAAI,OAAO;AAEP,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,mBAAiB,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MAG9B;AAEA,6CAAS,UAAC,IAAA,CAAA;AAAA,IACZ;AAAA,IAEA,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,eAAe;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EAAA;AAEP;"}
1
+ {"version":3,"file":"renderers.js","sources":["../../../../src/Table/renderers/renderers.tsx"],"sourcesContent":["import { ClassNames } from \"@emotion/react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseSwitchProps } from \"../../BaseSwitch\";\nimport { HvButton } from \"../../Button\";\nimport { HvDropdownProps } from \"../../Dropdown\";\nimport { HvListValue } from \"../../List\";\nimport {\n HvOverflowTooltip,\n HvOverflowTooltipProps,\n} from \"../../OverflowTooltip\";\nimport { HvTag, HvTagProps } from \"../../Tag\";\nimport { HvTypography } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport {\n HvCellProps,\n HvRowInstance,\n HvTableColumnConfig,\n HvTableHeaderRenderer,\n} from \"../hooks/useTable\";\nimport { hvNumberFallback, hvStringFallback } from \"../utils\";\nimport { HvDateColumnCell } from \"./DateColumnCell\";\nimport { HvDropdownColumnCell } from \"./DropdownColumnCell\";\nimport { HvProgressColumnCell } from \"./ProgressColumnCell\";\nimport { HvSwitchColumnCell } from \"./SwitchColumnCell\";\n\nexport function hvTextColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n overflowTooltipProps: Omit<HvOverflowTooltipProps, \"data\"> = {},\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvOverflowTooltip\n data={hvStringFallback(value)}\n {...overflowTooltipProps}\n />\n ),\n sortType: \"alphanumeric\",\n ...col,\n };\n}\n\nexport function hvNumberColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(col: HvTableColumnConfig<D, H>): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => <>{hvNumberFallback(value)}</>,\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n}\n\nexport function hvDateColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n dateFormat?: string,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: ({ value }: HvCellProps<D, H>) => (\n <HvDateColumnCell date={value} dateFormat={dateFormat} />\n ),\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n}\n\nexport function hvExpandColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n expandRowButtonAriaLabel: string,\n collapseRowButtonAriaLabel: string,\n getCanRowExpand?: (row: HvRowInstance<D, H>) => boolean,\n ExpandedIcon: React.ReactNode = <DropUpXS />,\n CollapsedIcon: React.ReactNode = <DropDownXS />,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n const expandedProps = row.getToggleRowExpandedProps?.();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <ClassNames>\n {({ css }) => (\n <>\n {hasContent && (\n <HvButton\n icon\n aria-label={\n row.isExpanded\n ? collapseRowButtonAriaLabel\n : expandRowButtonAriaLabel\n }\n aria-expanded={row.isExpanded}\n onClick={expandedProps?.onClick}\n classes={{\n root: css({\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n transform: \"translateY(-50%)\",\n }),\n }}\n >\n {row.isExpanded ? ExpandedIcon : CollapsedIcon}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n )}\n </ClassNames>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n A extends object = Record<string, unknown>,\n>(\n col: HvTableColumnConfig<D, H>,\n valueDataKey: keyof A,\n colorDataKey: keyof A,\n textColorDataKey: keyof A,\n fromRowData = false,\n tagProps?: HvTagProps,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n if (!value) {\n return <>—</>;\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"body\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\n// TODO - Review accessibility on the next renderers because they all differ\n\nexport function hvSwitchColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n switchLabel: string,\n falseLabel?: string,\n trueLabel?: string,\n switchProps?: HvBaseSwitchProps,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row } = cellProps;\n return (\n <HvSwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n id: string | undefined,\n placeholder: string,\n disabledPlaceholder: string,\n onChange?: (identifier: string, value: HvListValue) => void,\n dropdownProps?: HvDropdownProps<false>,\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { value, row, column } = cellProps;\n const disabled =\n !Array.isArray(value) || (Array.isArray(value) && value.length < 1);\n return (\n <HvDropdownColumnCell\n values={value}\n placeholder={disabled ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val!)}\n disabled={disabled}\n aria-labelledby={setId(id, column.id) || column.id || id} // TODO - to be reviewed because it doesn't make much sense\n {...dropdownProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn<\n D extends object = Record<string, unknown>,\n H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer,\n>(\n col: HvTableColumnConfig<D, H>,\n getPartial?: (row: HvRowInstance<D, H>) => number,\n getTotal?: (row: HvRowInstance<D, H>) => number,\n color?: \"primary\" | \"secondary\",\n): HvTableColumnConfig<D, H> {\n return {\n Cell: (cellProps: HvCellProps<D, H>) => {\n const { row, column } = cellProps;\n const partial = getPartial?.(row) || 0;\n const total = getTotal?.(row);\n\n if (total) {\n return (\n <HvProgressColumnCell\n partial={partial}\n total={total}\n color={color}\n aria-labelledby={column.id}\n />\n );\n }\n\n return <>—</>;\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0BO,SAAS,aAId,KACA,uBAA6D,IAClC;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,EAAE,MAAA,MACP;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAM,iBAAiB,KAAK;AAAA,QAC3B,GAAG;AAAA,MAAA;AAAA,IACN;AAAA,IAEF,UAAU;AAAA,IACV,GAAG;AAAA,EAAA;AAEP;AAEO,SAAS,eAGd,KAA2D;AACpD,SAAA;AAAA,IACL,MAAM,CAAC,EAAE,MAAA,MAAkC,oBAAA,UAAA,EAAA,UAAA,iBAAiB,KAAK,GAAE;AAAA,IACnE,OAAO;AAAA,IACP,UAAU;AAAA,IACV,GAAG;AAAA,EAAA;AAEP;AAEgB,SAAA,aAId,KACA,YAC2B;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,EAAE,MAAA,MACN,oBAAA,kBAAA,EAAiB,MAAM,OAAO,YAAwB;AAAA,IAEzD,UAAU;AAAA,IACV,eAAe;AAAA,IACf,GAAG;AAAA,EAAA;AAEP;AAEO,SAAS,eAId,KACA,0BACA,4BACA,iBACA,eAAiC,oBAAA,UAAA,CAAA,CAAS,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IACA,GAAG;AAAA,EAAA;AAEP;AAEO,SAAS,iBAId,KACA,YACA,UACA,OAC2B;AACpB,SAAA;AAAA,IACL,MAAM,CAAC,cAAiC;AAChC,YAAA,EAAE,KAAK,OAAW,IAAA;AAClB,YAAA,UAAU,aAAa,GAAG,KAAK;AAC/B,YAAA,QAAQ,WAAW,GAAG;AAE5B,UAAI,OAAO;AAEP,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,mBAAiB,OAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MAG9B;AAEA,6CAAS,UAAC,IAAA,CAAA;AAAA,IACZ;AAAA,IAEA,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,eAAe;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EAAA;AAEP;"}
@@ -285,6 +285,7 @@ export declare const badgeClasses: {
285
285
  badgeContainer: string;
286
286
  badgePosition: string;
287
287
  badge: string;
288
+ badgeHidden: string;
288
289
  showCount: string;
289
290
  showLabel: string;
290
291
  badgeIcon: string;
@@ -1402,7 +1403,7 @@ export declare type HvAvatarVariant = "circular" | "square";
1402
1403
  /**
1403
1404
  * The badge is a component used to notify the user that something has occurred, in the app context.
1404
1405
  */
1405
- export declare const HvBadge: (props: HvBadgeProps) => JSX_3.Element;
1406
+ export declare const HvBadge: ForwardRefExoticComponent<HvBadgeProps & RefAttributes<HTMLDivElement>>;
1406
1407
 
1407
1408
  export declare type HvBadgeClasses = ExtractNames<typeof useClasses_28>;
1408
1409
 
@@ -1411,22 +1412,23 @@ export declare interface HvBadgeProps extends HvBaseProps {
1411
1412
  * Count is the number of unread notifications.
1412
1413
  * Note count and label are mutually exclusive.
1413
1414
  * count is ignored when label is specified at the same time.
1415
+ * @deprecated use numeric `label` instead
1414
1416
  */
1415
1417
  count?: number;
1416
1418
  /**
1417
- * True if count should be displayed.
1418
- * Note showCount and label are mutually exclusive.
1419
- * showCount is ignored when label is specified at the same time.
1419
+ * True if `count` should be displayed.
1420
+ *
1421
+ * NOTE: `showCount` is ignored when a **non-numeric** `label` is specified.
1420
1422
  */
1421
1423
  showCount?: boolean;
1422
1424
  /** The maximum number of unread notifications to be displayed */
1423
1425
  maxCount?: number;
1424
1426
  /**
1425
- * Custom text to show in place of count.
1426
- * Note showCount and label are mutually exclusive.
1427
- * showCount is ignored when label is specified at the same time.
1427
+ * Badge content to show in.
1428
+ *
1429
+ * If value is numeric, then `showCount` and `maxCount` will show or limit the value respectively.
1428
1430
  */
1429
- label?: string;
1431
+ label?: React.ReactNode;
1430
1432
  /** Icon which the notification will be attached. */
1431
1433
  icon?: React.ReactNode;
1432
1434
  /** Text which the notification will be attached. */
@@ -3118,25 +3120,17 @@ export declare interface HvDrawerProps extends Omit<DrawerProps, "classes"> {
3118
3120
  /**
3119
3121
  * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.
3120
3122
  */
3121
- export declare const HvDropdown: ForwardRefExoticComponent<HvDropdownProps & RefAttributes<HTMLDivElement>>;
3123
+ export declare const HvDropdown: <Multiple extends boolean = false, OptionValue extends HvListValue = HvListValue>(props: HvDropdownProps<Multiple, OptionValue> & RefAttributes<HTMLDivElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null;
3122
3124
 
3123
3125
  export declare type HvDropdownClasses = ExtractNames<typeof useClasses_58>;
3124
3126
 
3125
- export declare function hvDropdownColumn<D extends object = Record<string, unknown>, H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer>(col: HvTableColumnConfig<D, H>, id: string | undefined, placeholder: string, disabledPlaceholder: string, onChange?: (identifier: string, value: HvListValue) => void, dropdownProps?: HvDropdownProps): HvTableColumnConfig<D, H>;
3127
+ export declare function hvDropdownColumn<D extends object = Record<string, unknown>, H extends HvTableHeaderRenderer | undefined = HvTableHeaderRenderer>(col: HvTableColumnConfig<D, H>, id: string | undefined, placeholder: string, disabledPlaceholder: string, onChange?: (identifier: string, value: HvListValue) => void, dropdownProps?: HvDropdownProps<false>): HvTableColumnConfig<D, H>;
3126
3128
 
3127
- export declare const HvDropdownColumnCell: ({ values, disabled, onChange, placeholder, dropdownProps, }: HvDropdownColumnCellProp) => JSX.Element;
3129
+ export declare const HvDropdownColumnCell: ({ dropdownProps, ...others }: HvDropdownColumnCellProp) => JSX_3.Element;
3128
3130
 
3129
- export declare interface HvDropdownColumnCellProp {
3130
- /** Values to render in the dropdown. */
3131
- values?: HvListValue[];
3132
- /** Placeholder text for when the dropdown is empty. */
3133
- placeholder?: string;
3134
- /** Whether the dropdown is disabled. */
3135
- disabled?: boolean;
3136
- /** Function called when there is change on the dropdown. */
3137
- onChange?: (value: HvListValue) => void;
3138
- /** Extra props to be passed onto the dropdown. */
3139
- dropdownProps?: HvDropdownProps;
3131
+ export declare interface HvDropdownColumnCellProp extends HvDropdownProps<false> {
3132
+ /** Extra props to be passed onto the dropdown. @deprecated pass props directly */
3133
+ dropdownProps?: HvDropdownProps<false>;
3140
3134
  }
3141
3135
 
3142
3136
  export declare type HvDropdownLabels = Partial<typeof DEFAULT_LABELS_7>;
@@ -3265,7 +3259,7 @@ export declare interface HvDropDownMenuProps extends HvBaseProps<HTMLDivElement,
3265
3259
  labels?: Partial<typeof DEFAULT_LABELS>;
3266
3260
  }
3267
3261
 
3268
- export declare interface HvDropdownProps extends Omit<HvFormElementProps, "value" | "onChange">, Pick<HvBaseDropdownProps, "placement" | "popperProps" | "disablePortal" | "variableWidth" | "expanded" | "defaultExpanded"> {
3262
+ export declare interface HvDropdownProps<Multiple extends boolean = boolean, OptionValue extends HvListValue = HvListValue> extends Omit<HvFormElementProps, "value" | "onChange">, Pick<HvBaseDropdownProps, "placement" | "popperProps" | "disablePortal" | "variableWidth" | "expanded" | "defaultExpanded"> {
3269
3263
  /**
3270
3264
  * A Jss Object used to override or extend the component styles applied.
3271
3265
  */
@@ -3298,15 +3292,15 @@ export declare interface HvDropdownProps extends Omit<HvFormElementProps, "value
3298
3292
  /**
3299
3293
  * The callback fired when the value changes.
3300
3294
  */
3301
- onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;
3295
+ onChange?: (selected: Multiple extends true ? OptionValue[] : OptionValue | undefined) => void;
3302
3296
  /**
3303
3297
  * The list to be rendered by the dropdown.
3304
3298
  */
3305
- values?: HvListValue[];
3299
+ values?: OptionValue[];
3306
3300
  /**
3307
3301
  * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.
3308
3302
  */
3309
- multiSelect?: boolean;
3303
+ multiSelect?: Multiple;
3310
3304
  /**
3311
3305
  * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.
3312
3306
  */
@@ -4185,6 +4179,8 @@ export declare const HvInlineEditor: <C extends default_2.ElementType<any, keyof
4185
4179
  onBlur?: ((event: default_2.FocusEvent<HTMLTextAreaElement | HTMLInputElement>, value: string) => void) | undefined;
4186
4180
  /** Called when the input value changes. */
4187
4181
  onChange?: ((event: default_2.SyntheticEvent, value: string) => void) | undefined;
4182
+ /** Called when there's a keydown event on the input. */
4183
+ onKeyDown?: ((event: default_2.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement> | default_2.MouseEvent, value: string) => void) | undefined;
4188
4184
  /** Props passed to the HvButton component */
4189
4185
  buttonProps?: HvButtonProps | undefined;
4190
4186
  /** Props passed to the HvTypography text component */
@@ -4210,7 +4206,7 @@ export declare const HvInlineEditor: <C extends default_2.ElementType<any, keyof
4210
4206
  component?: C | undefined;
4211
4207
  } & {
4212
4208
  children?: default_2.ReactNode;
4213
- } & (Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> extends infer T ? T extends Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> ? T extends any ? T : never : never : never) & {
4209
+ } & (Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "onKeyDown" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> extends infer T ? T extends Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "onKeyDown" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> ? T extends any ? T : never : never : never) & {
4214
4210
  ref?: PolymorphicRef<C> | undefined; /** The default value of the form element. */
4215
4211
  } & default_2.RefAttributes<unknown>) => default_2.ReactElement<any, string | default_2.JSXElementConstructor<any>> | null;
4216
4212
 
@@ -4229,6 +4225,8 @@ export declare type HvInlineEditorProps<C extends default_2.ElementType = typeof
4229
4225
  onBlur?: (event: default_2.FocusEvent<HTMLTextAreaElement | HTMLInputElement>, value: string) => void;
4230
4226
  /** Called when the input value changes. */
4231
4227
  onChange?: (event: default_2.SyntheticEvent, value: string) => void;
4228
+ /** Called when there's a keydown event on the input. */
4229
+ onKeyDown?: (event: default_2.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement> | default_2.MouseEvent, value: string) => void;
4232
4230
  /** Props passed to the HvButton component */
4233
4231
  buttonProps?: HvButtonProps;
4234
4232
  /** Props passed to the HvTypography text component */
@@ -9130,12 +9128,13 @@ declare const useClasses_27: (classesProp?: Partial<Record<"root" | "row" | "col
9130
9128
  readonly cx: (...args: any) => string;
9131
9129
  };
9132
9130
 
9133
- declare const useClasses_28: (classesProp?: Partial<Record<"root" | "badge" | "showLabel" | "badgeContainer" | "badgePosition" | "showCount" | "badgeIcon" | "badgeOneDigit", string>>, addStatic?: boolean) => {
9131
+ declare const useClasses_28: (classesProp?: Partial<Record<"root" | "badgePosition" | "badge" | "showLabel" | "badgeContainer" | "badgeHidden" | "showCount" | "badgeIcon" | "badgeOneDigit", string>>, addStatic?: boolean) => {
9134
9132
  readonly classes: {
9135
9133
  root: string;
9136
9134
  badgeContainer: string;
9137
9135
  badgePosition: string;
9138
9136
  badge: string;
9137
+ badgeHidden: string;
9139
9138
  showCount: string;
9140
9139
  showLabel: string;
9141
9140
  badgeIcon: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.74.0",
3
+ "version": "5.76.0",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "Core React components for the NEXT Design System.",
@@ -32,10 +32,10 @@
32
32
  "dependencies": {
33
33
  "@emotion/cache": "^11.11.0",
34
34
  "@emotion/serialize": "^1.1.2",
35
- "@hitachivantara/uikit-react-icons": "^5.12.2",
36
- "@hitachivantara/uikit-react-shared": "^5.3.7",
37
- "@hitachivantara/uikit-react-utils": "^0.2.7",
38
- "@hitachivantara/uikit-styles": "^5.34.2",
35
+ "@hitachivantara/uikit-react-icons": "^5.12.3",
36
+ "@hitachivantara/uikit-react-shared": "^5.3.8",
37
+ "@hitachivantara/uikit-react-utils": "^0.2.8",
38
+ "@hitachivantara/uikit-styles": "^5.35.0",
39
39
  "@internationalized/date": "^3.2.0",
40
40
  "@mui/base": "^5.0.0-beta.40",
41
41
  "@popperjs/core": "^2.11.8",
@@ -62,7 +62,7 @@
62
62
  "access": "public",
63
63
  "directory": "package"
64
64
  },
65
- "gitHead": "ebde08a1ca68acb95e6d98d5c9b310eee919fed5",
65
+ "gitHead": "dc2be087e44b98c1d1dd9e0b3f4a19b4e7dafcb2",
66
66
  "exports": {
67
67
  ".": {
68
68
  "types": "./dist/types/index.d.ts",