@hitachivantara/uikit-react-core 5.26.1 → 5.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs +2 -3
  2. package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs.map +1 -1
  3. package/dist/cjs/components/ColorPicker/ColorPicker.cjs +4 -2
  4. package/dist/cjs/components/ColorPicker/ColorPicker.cjs.map +1 -1
  5. package/dist/cjs/components/ColorPicker/SavedColors/SavedColors.cjs +8 -3
  6. package/dist/cjs/components/ColorPicker/SavedColors/SavedColors.cjs.map +1 -1
  7. package/dist/cjs/components/FileUploader/DropZone/DropZone.cjs +29 -40
  8. package/dist/cjs/components/FileUploader/DropZone/DropZone.cjs.map +1 -1
  9. package/dist/cjs/components/FileUploader/DropZone/DropZone.styles.cjs +2 -2
  10. package/dist/cjs/components/FileUploader/DropZone/DropZone.styles.cjs.map +1 -1
  11. package/dist/cjs/components/Tag/Tag.cjs.map +1 -1
  12. package/dist/esm/components/BaseDropdown/BaseDropdown.js +2 -3
  13. package/dist/esm/components/BaseDropdown/BaseDropdown.js.map +1 -1
  14. package/dist/esm/components/ColorPicker/ColorPicker.js +4 -2
  15. package/dist/esm/components/ColorPicker/ColorPicker.js.map +1 -1
  16. package/dist/esm/components/ColorPicker/SavedColors/SavedColors.js +8 -3
  17. package/dist/esm/components/ColorPicker/SavedColors/SavedColors.js.map +1 -1
  18. package/dist/esm/components/FileUploader/DropZone/DropZone.js +29 -40
  19. package/dist/esm/components/FileUploader/DropZone/DropZone.js.map +1 -1
  20. package/dist/esm/components/FileUploader/DropZone/DropZone.styles.js +2 -2
  21. package/dist/esm/components/FileUploader/DropZone/DropZone.styles.js.map +1 -1
  22. package/dist/esm/components/Tag/Tag.js.map +1 -1
  23. package/dist/types/index.d.ts +2 -0
  24. package/package.json +2 -2
@@ -176,8 +176,7 @@ const HvBaseDropdown = (props) => {
176
176
  const headerComponent = (() => {
177
177
  if (component) {
178
178
  return React__default.default.cloneElement(component, {
179
- ref: handleDropdownHeaderRef,
180
- "aria-controls": isOpen ? setId.setId(elementId, "children-container") : void 0
179
+ ref: handleDropdownHeaderRef
181
180
  });
182
181
  }
183
182
  const ExpanderComponent = isOpen ? uikitReactIcons.DropUpXS : uikitReactIcons.DropDownXS;
@@ -194,7 +193,6 @@ const HvBaseDropdown = (props) => {
194
193
  style: disabled || readOnly ? {
195
194
  pointerEvents: "none"
196
195
  } : void 0,
197
- "aria-controls": isOpen ? setId.setId(elementId, "children-container") : void 0,
198
196
  "aria-label": others["aria-label"] ?? void 0,
199
197
  "aria-labelledby": others["aria-labelledby"] ?? void 0,
200
198
  "aria-required": required ?? void 0,
@@ -293,6 +291,7 @@ const HvBaseDropdown = (props) => {
293
291
  role: ariaRole,
294
292
  "aria-expanded": ariaExpanded,
295
293
  "aria-owns": isOpen ? setId.setId(elementId, "children-container") : void 0,
294
+ "aria-controls": isOpen ? setId.setId(elementId, "children-container") : void 0,
296
295
  "aria-required": required ?? void 0,
297
296
  "aria-readonly": readOnly ?? void 0,
298
297
  className: cx(classes.anchor, {
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDropdown.cjs","sources":["../../../../src/components/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import React, {\n useMemo,\n useState,\n useCallback,\n KeyboardEventHandler,\n} from \"react\";\n\nimport { createPortal } from \"react-dom\";\n\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n PopperPlacementType,\n PopperProps,\n} from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { usePopper } from \"react-popper\";\nimport { detectOverflow, ModifierArguments, Options } from \"@popperjs/core\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { isKey, isOneOfKeys } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getFirstAndLastFocus } from \"@core/utils/focusableElementFinder\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"placeholder\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: string | React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<any>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n}\n\nexport const HvBaseDropdown = (props: HvBaseDropdownProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded,\n disabled,\n readOnly,\n required,\n disablePortal,\n variableWidth,\n placement = \"right\",\n popperProps = {},\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n onContainerCreation,\n \"aria-expanded\": ariaExpandedProp,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(\n null\n );\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null);\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const elementId = useUniqueId(id, \"hvbasedropdown\");\n\n const bottom: PopperPlacementType =\n placement && `bottom-${placement === \"right\" ? \"start\" : \"end\"}`;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const onFirstUpdate = useCallback(() => {\n if (onContainerCreation) onContainerCreation(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n []\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n []\n );\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (width !== popperMaxSize?.width || height !== popperMaxSize?.height) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize]\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n []\n );\n\n const modifiers: PopperProps[\"modifiers\"] = useMemo(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ]\n );\n\n const { styles: popperStyles, attributes } = usePopper(\n referenceElement,\n popperElement,\n {\n placement: bottom,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n }\n );\n\n const popperPlacement =\n attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\";\n\n const handleToggle = useCallback(\n (event) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n const focusHeader = () => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n };\n setIsOpen(focusHeader());\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement]\n );\n\n const headerComponent = (() => {\n if (component) {\n return React.cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n \"aria-controls\": isOpen\n ? setId(elementId, \"children-container\")\n : undefined,\n });\n }\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n return (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement.includes(\"top\"),\n [classes.headerOpenDown]:\n isOpen && popperPlacement.includes(\"bottom\"),\n })}\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n aria-controls={\n isOpen ? setId(elementId, \"children-container\") : undefined\n }\n aria-label={others[\"aria-label\"] ?? undefined}\n aria-labelledby={others[\"aria-labelledby\"] ?? undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div className={classes.selection}>\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? theme.colors.secondary_60 : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n })();\n\n const containerComponent = (() => {\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n role=\"tooltip\"\n ref={setPopperElement}\n className={classes.container}\n style={popperStyles.popper}\n {...attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <BaseDropdownContext.Provider value={popperMaxSize}>\n <div\n id={setId(elementId, \"children-container\")}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n </BaseDropdownContext.Provider>\n {popperPlacement.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n }\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n id={id}\n role={ariaRole}\n aria-expanded={ariaExpanded}\n aria-owns={isOpen ? setId(elementId, \"children-container\") : undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerComponent}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n};\n"],"names":["HvBaseDropdown","props","id","className","classes","classesProp","children","role","placeholder","component","adornment","expanded","dropdownHeaderProps","defaultExpanded","disabled","readOnly","required","disablePortal","variableWidth","placement","popperProps","dropdownHeaderRef","dropdownHeaderRefProp","onToggle","onClickOutside","onContainerCreation","ariaExpandedProp","others","useDefaultProps","cx","useClasses","rootId","useTheme","isOpen","setIsOpen","useControlled","Boolean","referenceElement","setReferenceElement","useState","popperElement","setPopperElement","popperMaxSize","setPopperMaxSize","handleDropdownHeaderRefProp","useForkRef","ref","handleDropdownHeaderRef","ariaRole","undefined","ariaExpanded","elementId","useUniqueId","bottom","extensionWidth","offsetWidth","modifiers","popperPropsModifiers","otherPopperProps","onFirstUpdate","useCallback","widthCalculator","state","styles","popper","width","rects","reference","widthCalculatorEffect","elements","style","applyMaxSizeCalculator","height","modifiersData","maxSize","maxWidth","maxHeight","maxSizeCalculator","name","options","overflow","detectOverflow","x","preventOverflow","y","popperWidth","popperHeight","basePlacement","split","widthProp","heightProp","useMemo","enabled","phase","requires","fn","effect","requiresIfExists","popperStyles","attributes","usePopper","popperPlacement","handleToggle","event","isKey","preventDefault","notControlKey","code","isOneOfKeys","ignoredCombinations","newOpen","focusHeader","focus","preventScroll","headerComponent","React","cloneElement","setId","ExpanderComponent","DropUpXS","DropDownXS","header","headerDisabled","headerReadOnly","headerOpen","headerOpenUp","includes","headerOpenDown","pointerEvents","tabIndex","_jsx","selection","HvTypography","selectionDisabled","variant","arrowContainer","iconSize","color","theme","colors","secondary_60","arrow","containerComponent","handleContainerKeyDown","shiftKey","focusList","getFirstAndLastFocus","document","activeElement","last","first","handleOutside","isButtonClick","contains","target","container","ClickAwayListener","onClickAway","onKeyDown","inputExtensionOpen","inputExtensionLeftPosition","BaseDropdownContext","Provider","value","panel","panelOpenedUp","panelOpenedDown","inputExtensionOpenShadow","inputExtensionFloatRight","inputExtensionFloatLeft","createPortal","getElementById","body","root","anchor","rootDisabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkIaA,MAAAA,iBAAiBA,CAACC,UAA+B;;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAA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C1BX,SACF;AAAA,MAAE,GACG,CAACY,YAAY;AAAA,QAChB+I,WAAWxD;AAAAA,QACX0E,SAAS1E;AAAAA,MACX;AAAA;AAAA,MAEA2B,UAAU;AAAA,MAAG,GACTtG;AAAAA,MAAMrB,UAET4G;AAAAA,IAAAA,CACE,GACJjF,UAAU6G,kBAAkB;AAAA,EAAA,CAC1B;AAET;;;"}
1
+ {"version":3,"file":"BaseDropdown.cjs","sources":["../../../../src/components/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import React, {\n useMemo,\n useState,\n useCallback,\n KeyboardEventHandler,\n} from \"react\";\n\nimport { createPortal } from \"react-dom\";\n\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n PopperPlacementType,\n PopperProps,\n} from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { usePopper } from \"react-popper\";\nimport { detectOverflow, ModifierArguments, Options } from \"@popperjs/core\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { isKey, isOneOfKeys } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getFirstAndLastFocus } from \"@core/utils/focusableElementFinder\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"placeholder\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: string | React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<any>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n}\n\nexport const HvBaseDropdown = (props: HvBaseDropdownProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded,\n disabled,\n readOnly,\n required,\n disablePortal,\n variableWidth,\n placement = \"right\",\n popperProps = {},\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n onContainerCreation,\n \"aria-expanded\": ariaExpandedProp,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(\n null\n );\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null);\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const elementId = useUniqueId(id, \"hvbasedropdown\");\n\n const bottom: PopperPlacementType =\n placement && `bottom-${placement === \"right\" ? \"start\" : \"end\"}`;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const onFirstUpdate = useCallback(() => {\n if (onContainerCreation) onContainerCreation(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n []\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n []\n );\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (width !== popperMaxSize?.width || height !== popperMaxSize?.height) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize]\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n []\n );\n\n const modifiers: PopperProps[\"modifiers\"] = useMemo(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ]\n );\n\n const { styles: popperStyles, attributes } = usePopper(\n referenceElement,\n popperElement,\n {\n placement: bottom,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n }\n );\n\n const popperPlacement =\n attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\";\n\n const handleToggle = useCallback(\n (event) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n const focusHeader = () => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n };\n setIsOpen(focusHeader());\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement]\n );\n\n const headerComponent = (() => {\n if (component) {\n return React.cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n });\n }\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n return (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement.includes(\"top\"),\n [classes.headerOpenDown]:\n isOpen && popperPlacement.includes(\"bottom\"),\n })}\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n aria-label={others[\"aria-label\"] ?? undefined}\n aria-labelledby={others[\"aria-labelledby\"] ?? undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div className={classes.selection}>\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? theme.colors.secondary_60 : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n })();\n\n const containerComponent = (() => {\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n role=\"tooltip\"\n ref={setPopperElement}\n className={classes.container}\n style={popperStyles.popper}\n {...attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <BaseDropdownContext.Provider value={popperMaxSize}>\n <div\n id={setId(elementId, \"children-container\")}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n </BaseDropdownContext.Provider>\n {popperPlacement.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n }\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n id={id}\n role={ariaRole}\n aria-expanded={ariaExpanded}\n aria-owns={isOpen ? setId(elementId, \"children-container\") : undefined}\n aria-controls={\n isOpen ? setId(elementId, \"children-container\") : undefined\n }\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerComponent}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n};\n"],"names":["HvBaseDropdown","props","id","className","classes","classesProp","children","role","placeholder","component","adornment","expanded","dropdownHeaderProps","defaultExpanded","disabled","readOnly","required","disablePortal","variableWidth","placement","popperProps","dropdownHeaderRef","dropdownHeaderRefProp","onToggle","onClickOutside","onContainerCreation","ariaExpandedProp","others","useDefaultProps","cx","useClasses","rootId","useTheme","isOpen","setIsOpen","useControlled","Boolean","referenceElement","setReferenceElement","useState","popperElement","setPopperElement","popperMaxSize","setPopperMaxSize","handleDropdownHeaderRefProp","useForkRef","ref","handleDropdownHeaderRef","ariaRole","undefined","ariaExpanded","elementId","useUniqueId","bottom","extensionWidth","offsetWidth","modifiers","popperPropsModifiers","otherPopperProps","onFirstUpdate","useCallback","widthCalculator","state","styles","popper","width","rects","reference","widthCalculatorEffect","elements","style","applyMaxSizeCalculator","height","modifiersData","maxSize","maxWidth","maxHeight","maxSizeCalculator","name","options","overflow","detectOverflow","x","preventOverflow","y","popperWidth","popperHeight","basePlacement","split","widthProp","heightProp","useMemo","enabled","phase","requires","fn","effect","requiresIfExists","popperStyles","attributes","usePopper","popperPlacement","handleToggle","event","isKey","preventDefault","notControlKey","code","isOneOfKeys","ignoredCombinations","newOpen","focusHeader","focus","preventScroll","headerComponent","React","cloneElement","ExpanderComponent","DropUpXS","DropDownXS","setId","header","headerDisabled","headerReadOnly","headerOpen","headerOpenUp","includes","headerOpenDown","pointerEvents","tabIndex","_jsx","selection","HvTypography","selectionDisabled","variant","arrowContainer","iconSize","color","theme","colors","secondary_60","arrow","containerComponent","handleContainerKeyDown","shiftKey","focusList","getFirstAndLastFocus","document","activeElement","last","first","handleOutside","isButtonClick","contains","target","container","ClickAwayListener","onClickAway","onKeyDown","inputExtensionOpen","inputExtensionLeftPosition","BaseDropdownContext","Provider","value","panel","panelOpenedUp","panelOpenedDown","inputExtensionOpenShadow","inputExtensionFloatRight","inputExtensionFloatLeft","createPortal","getElementById","body","root","anchor","rootDisabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkIaA,MAAAA,iBAAiBA,CAACC,UAA+B;;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC,cAAc,CAAC;AAAA,IACfC,mBAAmBC;AAAAA,IACnBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,iBAAiBC;AAAAA,IACjB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,kBAAkB3B,KAAK;AACrC,QAAA;AAAA,IAAEG;AAAAA,IAASyB;AAAAA,EAAAA,IAAOC,oBAAAA,WAAWzB,WAAW;AAExC,QAAA;AAAA,IAAE0B;AAAAA,MAAWC,SAAS,SAAA;AAEtB,QAAA,CAACC,QAAQC,SAAS,IAAIC,cAAAA,cAAcxB,UAAUyB,QAAQvB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AA,CACE;AAAA,MAAA,CACY;AAAA,IAAA,CAChB;AAGH7G,QAAAA;AAAsB0I,aAAAA;AAEnBe,WAAAA,SAAAA,aACLf,WACAR,SAASwB,eAAe5I,UAAU,EAAE,KAAKoH,SAASyB,IACpD;AAAA,EAAA;AAGF,yCACE,OAAA;AAAA,IAAKzK,WAAWC,QAAQyK;AAAAA,IAAKvK,WAC3B4H,2BAAAA,IAAA,OAAA;AAAA,MACEhI;AAAAA,MACAK,MAAMyC;AAAAA,MACN,iBAAeE;AAAAA,MACf,aAAWjB,SAASuF,MAAMrE,MAAAA,WAAW,oBAAoB,IAAIF;AAAAA,MAC7D,iBACEhB,SAASuF,MAAMrE,MAAAA,WAAW,oBAAoB,IAAIF;AAAAA,MAEpD,iBAAejC,YAAYiC;AAAAA,MAC3B,iBAAelC,YAAYkC;AAAAA,MAC3B9C,WAAW0B,GACTzB,QAAQ0K,QACR;AAAA,QAAE,CAAC1K,QAAQ2K,YAAY,GAAGjK;AAAAA,SAC1BX,SACF;AAAA,MAAE,GACG,CAACY,YAAY;AAAA,QAChB+I,WAAWxD;AAAAA,QACX0E,SAAS1E;AAAAA,MACX;AAAA;AAAA,MAEA2B,UAAU;AAAA,MAAG,GACTtG;AAAAA,MAAMrB,UAET4G;AAAAA,IAAAA,CACE,GACJjF,UAAU6G,kBAAkB;AAAA,EAAA,CAC1B;AAET;;;"}
@@ -54,7 +54,8 @@ const HvColorPicker = (props) => {
54
54
  defaultSavedColorsValue = [],
55
55
  onSavedColorAdded,
56
56
  onSavedColorRemoved,
57
- deleteSavedColorButtonArialLabel = "Delete saved color"
57
+ deleteSavedColorButtonArialLabel = "Delete saved color",
58
+ addSavedColorButtonAriaLabel = "Add current color to saved colors"
58
59
  } = useDefaultProps.useDefaultProps("HvColorPicker", props);
59
60
  const {
60
61
  classes,
@@ -182,7 +183,8 @@ const HvColorPicker = (props) => {
182
183
  onAddColor: handleAddColor,
183
184
  onClickColor: handleSelect,
184
185
  onRemoveColor: handleRemoveColor,
185
- deleteButtonArialLabel: deleteSavedColorButtonArialLabel
186
+ deleteButtonAriaLabel: deleteSavedColorButtonArialLabel,
187
+ addButtonAriaLabel: addSavedColorButtonAriaLabel
186
188
  }), recommendedColorsPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(PresetColors.PresetColors, {
187
189
  colors: recommendedColors,
188
190
  onClick: handleSelect,
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.cjs","sources":["../../../../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import { Checkbox, ColorPicker } from \"@hitachivantara/uikit-react-icons\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { ColorState } from \"react-color\";\n\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useLabels } from \"@core/hooks/useLabels\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvPanel } from \"@core/components/Panel\";\nimport { HvFormElement, HvInfoMessage, HvLabel } from \"@core/components/Forms\";\nimport { HvBaseDropdown } from \"@core/components/BaseDropdown\";\nimport { HvDropdownProps } from \"@core/components/Dropdown\";\n\nimport { Picker } from \"./Picker\";\nimport { staticClasses, useClasses } from \"./ColorPicker.styles\";\nimport { PresetColors } from \"./PresetColors\";\nimport { SavedColors } from \"./SavedColors\";\n\nexport { staticClasses as colorPickerClasses };\n\nexport type HvColorPickerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvColorPickerProps {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n \"aria-describedby\"?: string;\n /** Class names to be applied. */\n className?: string;\n /** Id to be applied to the form element root node. */\n id?: string;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /** The value color, in HEX format. */\n value?: string;\n /** The default value color, in HEX format. */\n defaultValue?: string;\n /** If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled. */\n disabled?: boolean;\n /** If `true` the dropdown starts opened if `false` it starts closed. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** A function to be executed whenever the color changes. */\n onChange?: (color: string) => void;\n /** A function to be executed whenever the color change is complete. */\n onChangeComplete?: (color: string) => void;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvColorPickerClasses;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** Recommended colors. The colors are HEX values. */\n recommendedColors?: string[];\n /** Recommended colors position. */\n recommendedColorsPosition?: \"top\" | \"bottom\";\n /** If `true`, the labels are shown. If `false`, they are not shown. */\n showLabels?: boolean;\n /** An object containing all the labels. */\n labels?: {\n recommendedColorsLabel?: string;\n customColorsLabel?: string;\n };\n /** Icon type for the input's end adornment. */\n dropdownIcon?: \"arrow\" | \"colorPicker\";\n /** If `true`, the input only shows an icon. If `false`, the input shows text and icons. */\n iconOnly?: boolean;\n /** If `true`, the saved colors area is shown. If `false`, it is not shown. */\n showSavedColors?: boolean;\n /** If `true`, the custom colors area is shown. If `false`, it is not shown. */\n showCustomColors?: boolean;\n /** The saved colors. The colors are HEX values. */\n savedColorsValue?: string[];\n /** The default saved colors. The colors are HEX values. */\n defaultSavedColorsValue?: string[];\n /** Callback fired when a new saved color is added. */\n onSavedColorAdded?: (color?: string) => void;\n /** Callback fired when a new saved color is removed. */\n onSavedColorRemoved?: (color?: string) => void;\n /** Aria label to apply to delete saved color button. */\n deleteSavedColorButtonArialLabel?: string;\n}\n\nconst DEFAULT_LABELS: HvColorPickerProps[\"labels\"] = {\n recommendedColorsLabel: \"Recommended colors:\",\n customColorsLabel: \"Custom colors:\",\n};\n\n/**\n * A color picker component which allows the user to select a color from a list of pre-defined colors or freely select one color via the Hue and Saturation.\n * It receives a color string in HEX format and outputs an HEX formatted color.\n */\nexport const HvColorPicker = (props: HvColorPickerProps) => {\n const {\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n className,\n classes: classesProp,\n value,\n onChange,\n onChangeComplete,\n defaultValue = \"\",\n expanded,\n defaultExpanded = false,\n recommendedColorsPosition = \"top\",\n recommendedColors = [\n \"#95AFE8\",\n \"#E89E5D\",\n \"#83B8A6\",\n \"#70759C\",\n \"#C57E7E\",\n \"#FADA95\",\n \"#ADBFE8\",\n \"#E3B386\",\n \"#9AC6B7\",\n \"#8B90AF\",\n \"#CF9797\",\n \"#FAE1AA\",\n ],\n showLabels = true,\n labels: labelsProp,\n dropdownIcon = \"colorPicker\",\n placeholder = \"Select color...\",\n iconOnly = false,\n showSavedColors = true,\n showCustomColors = true,\n savedColorsValue,\n defaultSavedColorsValue = [],\n onSavedColorAdded,\n onSavedColorRemoved,\n deleteSavedColorButtonArialLabel = \"Delete saved color\",\n } = useDefaultProps(\"HvColorPicker\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const [color, setColor] = useControlled(value, defaultValue);\n const [savedColors, setSavedColors] = useControlled(\n savedColorsValue,\n defaultSavedColorsValue\n );\n const elementId = useUniqueId(id, \"hvdropdown\");\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n const handleToggle: HvDropdownProps[\"onToggle\"] = (_, open) => {\n setIsOpen(open);\n };\n\n const handleSelect = (val: ColorState | { hex: string; source: string }) => {\n onChange?.(val.hex);\n onChangeComplete?.(val.hex);\n setColor(val.hex);\n };\n\n const handleOnChange = (\n val: ColorState | { hex: string; source: string }\n ) => {\n onChange?.(val.hex);\n setColor(val.hex);\n };\n\n const handleOnChangeComplete = (\n val: ColorState | { hex: string; source: string }\n ) => {\n onChangeComplete?.(val.hex);\n setColor(val.hex);\n };\n\n const handleAddColor = () => {\n // When no color is provided, react-color sets the picker to #000000.\n // This is the color that should be added in this case.\n const colorToAdd = color || \"#000000\";\n\n onSavedColorAdded?.(colorToAdd);\n setSavedColors([...savedColors, colorToAdd]);\n };\n\n const handleRemoveColor = (val: string, position: number) => {\n if (savedColors[position] === val) {\n const sColors = [...savedColors];\n sColors.splice(position, 1);\n onSavedColorRemoved?.(val);\n setSavedColors(sColors);\n }\n };\n\n const setFocusToContent = (containerRef: HTMLElement | null) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n }\n };\n\n return (\n <HvFormElement\n id={id}\n name={name}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\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 variableWidth\n className={className}\n expanded={isOpen}\n onToggle={handleToggle}\n onContainerCreation={setFocusToContent}\n classes={{\n root: cx({ [classes.dropdownRootIconOnly]: iconOnly }),\n selection: cx(iconOnly && css({ padding: 0 })),\n }}\n adornment={\n iconOnly && color ? (\n <Checkbox\n className={classes.headerColorIconOnly}\n color={[color, \"transparent\"]}\n />\n ) : dropdownIcon === \"colorPicker\" ? (\n <ColorPicker className={classes.colorPickerIcon} />\n ) : undefined\n }\n placeholder={\n iconOnly ? undefined : color ? (\n <>\n <Checkbox\n className={classes.headerColorIcon}\n color={[color, \"transparent\"]}\n />\n <HvTypography\n className={classes.headerColorValue}\n variant={activeTheme?.colorPicker.inputValueVariant}\n >\n {color}\n </HvTypography>\n </>\n ) : (\n placeholder\n )\n }\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n >\n <HvPanel className={classes.panel}>\n <div className={classes.colorPicker}>\n {recommendedColorsPosition === \"top\" && (\n <PresetColors\n className={cx(\n (showCustomColors || showSavedColors) &&\n css({\n paddingBottom:\n activeTheme?.colorPicker.recommendedColorsBottomPadding,\n }),\n classes.recommendedColorsRoot\n )}\n colors={recommendedColors}\n onClick={handleSelect}\n title={showLabels ? labels?.recommendedColorsLabel : undefined}\n />\n )}\n {showCustomColors && (\n <Picker\n classes={{\n fields: cx({\n [classes.pickerFields]:\n recommendedColorsPosition === \"bottom\" || showSavedColors,\n }),\n }}\n title={showLabels ? labels?.customColorsLabel : undefined}\n color={color}\n onChange={handleOnChange}\n onChangeComplete={handleOnChangeComplete}\n />\n )}\n {showSavedColors && (\n <SavedColors\n colors={savedColors}\n onAddColor={handleAddColor}\n onClickColor={handleSelect}\n onRemoveColor={handleRemoveColor}\n deleteButtonArialLabel={deleteSavedColorButtonArialLabel}\n />\n )}\n {recommendedColorsPosition === \"bottom\" && (\n <PresetColors\n colors={recommendedColors}\n onClick={handleSelect}\n title={showLabels ? labels?.recommendedColorsLabel : undefined}\n />\n )}\n </div>\n </HvPanel>\n </HvBaseDropdown>\n </HvFormElement>\n );\n};\n"],"names":["DEFAULT_LABELS","recommendedColorsLabel","customColorsLabel","HvColorPicker","props","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","className","classes","classesProp","value","onChange","onChangeComplete","defaultValue","expanded","defaultExpanded","recommendedColorsPosition","recommendedColors","showLabels","labels","labelsProp","dropdownIcon","placeholder","iconOnly","showSavedColors","showCustomColors","savedColorsValue","defaultSavedColorsValue","onSavedColorAdded","onSavedColorRemoved","deleteSavedColorButtonArialLabel","useDefaultProps","css","cx","useClasses","activeTheme","useTheme","useLabels","isOpen","setIsOpen","useControlled","Boolean","color","setColor","savedColors","setSavedColors","elementId","useUniqueId","hasLabel","hasDescription","handleToggle","_","open","handleSelect","val","hex","handleOnChange","handleOnChangeComplete","handleAddColor","colorToAdd","handleRemoveColor","position","sColors","splice","setFocusToContent","containerRef","inputs","getElementsByTagName","length","focus","HvFormElement","root","children","labelContainer","_jsx","HvLabel","setId","HvInfoMessage","HvBaseDropdown","variableWidth","onToggle","onContainerCreation","dropdownRootIconOnly","selection","padding","adornment","Checkbox","headerColorIconOnly","ColorPicker","colorPickerIcon","undefined","_Fragment","headerColorIcon","HvTypography","headerColorValue","variant","colorPicker","inputValueVariant","join","trim","HvPanel","panel","PresetColors","paddingBottom","recommendedColorsBottomPadding","recommendedColorsRoot","colors","onClick","title","Picker","fields","pickerFields","SavedColors","onAddColor","onClickColor","onRemoveColor","deleteButtonArialLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgGA,MAAMA,iBAA+C;AAAA,EACnDC,wBAAwB;AAAA,EACxBC,mBAAmB;AACrB;AAMaC,MAAAA,gBAAgBA,CAACC,UAA8B;AACpD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,eAAe;AAAA,IACfC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,4BAA4B;AAAA,IAC5BC,oBAAoB,CAClB,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,SAAS;AAAA,IAEXC,aAAa;AAAA,IACbC,QAAQC;AAAAA,IACRC,eAAe;AAAA,IACfC,cAAc;AAAA,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pE,2CAAa6D,YAAYQ;AAAAA,YAAAA,CAC5B,GACHhG,QAAQiG,qBACV;AAAA,YACAC,QAAQzF;AAAAA,YACR0F,SAAStD;AAAAA,YACTuD,OAAO1F,aAAaC,iCAAQzB,yBAAyBgG;AAAAA,UAAAA,CACtD,GAEFjE,oBACCiD,2BAAAA,IAACmC,eAAM;AAAA,YACLrG,SAAS;AAAA,cACPsG,QAAQ7E,GAAG;AAAA,gBACT,CAACzB,QAAQuG,YAAY,GACnB/F,8BAA8B,YAAYQ;AAAAA,cAAAA,CAC7C;AAAA,YACH;AAAA,YACAoF,OAAO1F,aAAaC,iCAAQxB,oBAAoB+F;AAAAA,YAChDhD;AAAAA,YACA/B,UAAU6C;AAAAA,YACV5C,kBAAkB6C;AAAAA,UAAAA,CACnB,GAEFjC,mBACCkD,2BAAAA,IAACsC,yBAAW;AAAA,YACVN,QAAQ9D;AAAAA,YACRqE,YAAYvD;AAAAA,YACZwD,cAAc7D;AAAAA,YACd8D,eAAevD;AAAAA,YACfwD,wBAAwBtF;AAAAA,UACzB,CAAA,GAEFd,8BAA8B,2CAC5BsF,aAAAA,cAAY;AAAA,YACXI,QAAQzF;AAAAA,YACR0F,SAAStD;AAAAA,YACTuD,OAAO1F,aAAaC,iCAAQzB,yBAAyBgG;AAAAA,UAAAA,CACtD,CACF;AAAA,QAAA,CACE;AAAA,MAAA,CACE;AAAA,IAAA,CACK,CAAC;AAAA,EAAA,CACJ;AAEnB;;;"}
1
+ {"version":3,"file":"ColorPicker.cjs","sources":["../../../../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import { Checkbox, ColorPicker } from \"@hitachivantara/uikit-react-icons\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { ColorState } from \"react-color\";\n\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useLabels } from \"@core/hooks/useLabels\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvPanel } from \"@core/components/Panel\";\nimport { HvFormElement, HvInfoMessage, HvLabel } from \"@core/components/Forms\";\nimport { HvBaseDropdown } from \"@core/components/BaseDropdown\";\nimport { HvDropdownProps } from \"@core/components/Dropdown\";\n\nimport { Picker } from \"./Picker\";\nimport { staticClasses, useClasses } from \"./ColorPicker.styles\";\nimport { PresetColors } from \"./PresetColors\";\nimport { SavedColors } from \"./SavedColors\";\n\nexport { staticClasses as colorPickerClasses };\n\nexport type HvColorPickerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvColorPickerProps {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n \"aria-describedby\"?: string;\n /** Class names to be applied. */\n className?: string;\n /** Id to be applied to the form element root node. */\n id?: string;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /** The value color, in HEX format. */\n value?: string;\n /** The default value color, in HEX format. */\n defaultValue?: string;\n /** If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled. */\n disabled?: boolean;\n /** If `true` the dropdown starts opened if `false` it starts closed. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** A function to be executed whenever the color changes. */\n onChange?: (color: string) => void;\n /** A function to be executed whenever the color change is complete. */\n onChangeComplete?: (color: string) => void;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvColorPickerClasses;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** Recommended colors. The colors are HEX values. */\n recommendedColors?: string[];\n /** Recommended colors position. */\n recommendedColorsPosition?: \"top\" | \"bottom\";\n /** If `true`, the labels are shown. If `false`, they are not shown. */\n showLabels?: boolean;\n /** An object containing all the labels. */\n labels?: {\n recommendedColorsLabel?: string;\n customColorsLabel?: string;\n };\n /** Icon type for the input's end adornment. */\n dropdownIcon?: \"arrow\" | \"colorPicker\";\n /** If `true`, the input only shows an icon. If `false`, the input shows text and icons. */\n iconOnly?: boolean;\n /** If `true`, the saved colors area is shown. If `false`, it is not shown. */\n showSavedColors?: boolean;\n /** If `true`, the custom colors area is shown. If `false`, it is not shown. */\n showCustomColors?: boolean;\n /** The saved colors. The colors are HEX values. */\n savedColorsValue?: string[];\n /** The default saved colors. The colors are HEX values. */\n defaultSavedColorsValue?: string[];\n /** Callback fired when a new saved color is added. */\n onSavedColorAdded?: (color?: string) => void;\n /** Callback fired when a new saved color is removed. */\n onSavedColorRemoved?: (color?: string) => void;\n /** Aria label to apply to delete saved color button. */\n deleteSavedColorButtonArialLabel?: string; // TODO: fix typo \"ArialLabel\" in next version\n /** Aria label to apply to add saved color button. */\n addSavedColorButtonAriaLabel?: string;\n}\n\nconst DEFAULT_LABELS: HvColorPickerProps[\"labels\"] = {\n recommendedColorsLabel: \"Recommended colors:\",\n customColorsLabel: \"Custom colors:\",\n};\n\n/**\n * A color picker component which allows the user to select a color from a list of pre-defined colors or freely select one color via the Hue and Saturation.\n * It receives a color string in HEX format and outputs an HEX formatted color.\n */\nexport const HvColorPicker = (props: HvColorPickerProps) => {\n const {\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n className,\n classes: classesProp,\n value,\n onChange,\n onChangeComplete,\n defaultValue = \"\",\n expanded,\n defaultExpanded = false,\n recommendedColorsPosition = \"top\",\n recommendedColors = [\n \"#95AFE8\",\n \"#E89E5D\",\n \"#83B8A6\",\n \"#70759C\",\n \"#C57E7E\",\n \"#FADA95\",\n \"#ADBFE8\",\n \"#E3B386\",\n \"#9AC6B7\",\n \"#8B90AF\",\n \"#CF9797\",\n \"#FAE1AA\",\n ],\n showLabels = true,\n labels: labelsProp,\n dropdownIcon = \"colorPicker\",\n placeholder = \"Select color...\",\n iconOnly = false,\n showSavedColors = true,\n showCustomColors = true,\n savedColorsValue,\n defaultSavedColorsValue = [],\n onSavedColorAdded,\n onSavedColorRemoved,\n deleteSavedColorButtonArialLabel = \"Delete saved color\",\n addSavedColorButtonAriaLabel = \"Add current color to saved colors\",\n } = useDefaultProps(\"HvColorPicker\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const [color, setColor] = useControlled(value, defaultValue);\n const [savedColors, setSavedColors] = useControlled(\n savedColorsValue,\n defaultSavedColorsValue\n );\n const elementId = useUniqueId(id, \"hvdropdown\");\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n const handleToggle: HvDropdownProps[\"onToggle\"] = (_, open) => {\n setIsOpen(open);\n };\n\n const handleSelect = (val: ColorState | { hex: string; source: string }) => {\n onChange?.(val.hex);\n onChangeComplete?.(val.hex);\n setColor(val.hex);\n };\n\n const handleOnChange = (\n val: ColorState | { hex: string; source: string }\n ) => {\n onChange?.(val.hex);\n setColor(val.hex);\n };\n\n const handleOnChangeComplete = (\n val: ColorState | { hex: string; source: string }\n ) => {\n onChangeComplete?.(val.hex);\n setColor(val.hex);\n };\n\n const handleAddColor = () => {\n // When no color is provided, react-color sets the picker to #000000.\n // This is the color that should be added in this case.\n const colorToAdd = color || \"#000000\";\n\n onSavedColorAdded?.(colorToAdd);\n setSavedColors([...savedColors, colorToAdd]);\n };\n\n const handleRemoveColor = (val: string, position: number) => {\n if (savedColors[position] === val) {\n const sColors = [...savedColors];\n sColors.splice(position, 1);\n onSavedColorRemoved?.(val);\n setSavedColors(sColors);\n }\n };\n\n const setFocusToContent = (containerRef: HTMLElement | null) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n }\n };\n\n return (\n <HvFormElement\n id={id}\n name={name}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\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 variableWidth\n className={className}\n expanded={isOpen}\n onToggle={handleToggle}\n onContainerCreation={setFocusToContent}\n classes={{\n root: cx({ [classes.dropdownRootIconOnly]: iconOnly }),\n selection: cx(iconOnly && css({ padding: 0 })),\n }}\n adornment={\n iconOnly && color ? (\n <Checkbox\n className={classes.headerColorIconOnly}\n color={[color, \"transparent\"]}\n />\n ) : dropdownIcon === \"colorPicker\" ? (\n <ColorPicker className={classes.colorPickerIcon} />\n ) : undefined\n }\n placeholder={\n iconOnly ? undefined : color ? (\n <>\n <Checkbox\n className={classes.headerColorIcon}\n color={[color, \"transparent\"]}\n />\n <HvTypography\n className={classes.headerColorValue}\n variant={activeTheme?.colorPicker.inputValueVariant}\n >\n {color}\n </HvTypography>\n </>\n ) : (\n placeholder\n )\n }\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n >\n <HvPanel className={classes.panel}>\n <div className={classes.colorPicker}>\n {recommendedColorsPosition === \"top\" && (\n <PresetColors\n className={cx(\n (showCustomColors || showSavedColors) &&\n css({\n paddingBottom:\n activeTheme?.colorPicker.recommendedColorsBottomPadding,\n }),\n classes.recommendedColorsRoot\n )}\n colors={recommendedColors}\n onClick={handleSelect}\n title={showLabels ? labels?.recommendedColorsLabel : undefined}\n />\n )}\n {showCustomColors && (\n <Picker\n classes={{\n fields: cx({\n [classes.pickerFields]:\n recommendedColorsPosition === \"bottom\" || showSavedColors,\n }),\n }}\n title={showLabels ? labels?.customColorsLabel : undefined}\n color={color}\n onChange={handleOnChange}\n onChangeComplete={handleOnChangeComplete}\n />\n )}\n {showSavedColors && (\n <SavedColors\n colors={savedColors}\n onAddColor={handleAddColor}\n onClickColor={handleSelect}\n onRemoveColor={handleRemoveColor}\n deleteButtonAriaLabel={deleteSavedColorButtonArialLabel}\n addButtonAriaLabel={addSavedColorButtonAriaLabel}\n />\n )}\n {recommendedColorsPosition === \"bottom\" && (\n <PresetColors\n colors={recommendedColors}\n onClick={handleSelect}\n title={showLabels ? labels?.recommendedColorsLabel : undefined}\n />\n )}\n </div>\n </HvPanel>\n </HvBaseDropdown>\n </HvFormElement>\n );\n};\n"],"names":["DEFAULT_LABELS","recommendedColorsLabel","customColorsLabel","HvColorPicker","props","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","className","classes","classesProp","value","onChange","onChangeComplete","defaultValue","expanded","defaultExpanded","recommendedColorsPosition","recommendedColors","showLabels","labels","labelsProp","dropdownIcon","placeholder","iconOnly","showSavedColors","showCustomColors","savedColorsValue","defaultSavedColorsValue","onSavedColorAdded","onSavedColorRemoved","deleteSavedColorButtonArialLabel","addSavedColorButtonAriaLabel","useDefaultProps","css","cx","useClasses","activeTheme","useTheme","useLabels","isOpen","setIsOpen","useControlled","Boolean","color","setColor","savedColors","setSavedColors","elementId","useUniqueId","hasLabel","hasDescription","handleToggle","_","open","handleSelect","val","hex","handleOnChange","handleOnChangeComplete","handleAddColor","colorToAdd","handleRemoveColor","position","sColors","splice","setFocusToContent","containerRef","inputs","getElementsByTagName","length","focus","HvFormElement","root","children","labelContainer","_jsx","HvLabel","setId","HvInfoMessage","HvBaseDropdown","variableWidth","onToggle","onContainerCreation","dropdownRootIconOnly","selection","padding","adornment","Checkbox","headerColorIconOnly","ColorPicker","colorPickerIcon","undefined","_Fragment","headerColorIcon","HvTypography","headerColorValue","variant","colorPicker","inputValueVariant","join","trim","HvPanel","panel","PresetColors","paddingBottom","recommendedColorsBottomPadding","recommendedColorsRoot","colors","onClick","title","Picker","fields","pickerFields","SavedColors","onAddColor","onClickColor","onRemoveColor","deleteButtonAriaLabel","addButtonAriaLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkGA,MAAMA,iBAA+C;AAAA,EACnDC,wBAAwB;AAAA,EACxBC,mBAAmB;AACrB;AAMaC,MAAAA,gBAAgBA,CAACC,UAA8B;AACpD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,eAAe;AAAA,IACfC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,4BAA4B;AAAA,IAC5BC,oBAAoB,CAClB,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,SAAS;AAAA,IAEXC,aAAa;AAAA,IACbC,QAAQC;AAAAA,IACRC,eAAe;AAAA,IACfC,cAAc;AAAA,IACdC,WAAW;AAAA,IACXC,kBAAkB;AAAA,IAClBC,mBAAmB;AAAA,IACnBC;AAAAA,IACAC,0BAA0B,CAAE;AAAA,IAC5BC;AAAAA,IACAC;AAAAA,IACAC,mCAAmC;AAAA,IACnCC,+BAA+B;AAAA,EAAA,IAC7BC,gBAAgB,gBAAA,iBAAiBnC,KAAK;AAEpC,QAAA;AAAA,IAAEW;AAAAA,IAASyB;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,mBAAAA,WAAW1B,WAAW;AAC7C,QAAA;AAAA,IAAE2B;AAAAA,MAAgBC,SAAS,SAAA;AAE3BlB,QAAAA,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AAO3F,aAAaC,iCAAQxB,oBAAoBgG;AAAAA,YAChDhD;AAAAA,YACAhC,UAAU8C;AAAAA,YACV7C,kBAAkB8C;AAAAA,UAAAA,CACnB,GAEFlC,mBACCmD,2BAAAA,IAACsC,yBAAW;AAAA,YACVN,QAAQ9D;AAAAA,YACRqE,YAAYvD;AAAAA,YACZwD,cAAc7D;AAAAA,YACd8D,eAAevD;AAAAA,YACfwD,uBAAuBvF;AAAAA,YACvBwF,oBAAoBvF;AAAAA,UACrB,CAAA,GAEFf,8BAA8B,2CAC5BuF,aAAAA,cAAY;AAAA,YACXI,QAAQ1F;AAAAA,YACR2F,SAAStD;AAAAA,YACTuD,OAAO3F,aAAaC,iCAAQzB,yBAAyBiG;AAAAA,UAAAA,CACtD,CACF;AAAA,QAAA,CACE;AAAA,MAAA,CACE;AAAA,IAAA,CACK,CAAC;AAAA,EAAA,CACJ;AAEnB;;;"}
@@ -10,7 +10,8 @@ const SavedColors = ({
10
10
  onClickColor,
11
11
  onAddColor,
12
12
  onRemoveColor,
13
- deleteButtonArialLabel,
13
+ deleteButtonAriaLabel,
14
+ addButtonAriaLabel,
14
15
  classes: classesProp
15
16
  }) => {
16
17
  const {
@@ -29,7 +30,10 @@ const SavedColors = ({
29
30
  variant: "secondarySubtle",
30
31
  icon: true,
31
32
  onClick: onAddColor,
32
- children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Add, {})
33
+ "aria-label": addButtonAriaLabel,
34
+ children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Add, {
35
+ "aria-hidden": true
36
+ })
33
37
  }), colors.map((color, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", {
34
38
  className: classes.swatchRoot,
35
39
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -48,8 +52,9 @@ const SavedColors = ({
48
52
  variant: "secondarySubtle",
49
53
  onClick: () => onRemoveColor(color, index),
50
54
  tabIndex: 0,
51
- "aria-label": deleteButtonArialLabel,
55
+ "aria-label": deleteButtonAriaLabel,
52
56
  children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.CloseXS, {
57
+ "aria-hidden": true,
53
58
  iconSize: "XS"
54
59
  })
55
60
  })
@@ -1 +1 @@
1
- {"version":3,"file":"SavedColors.cjs","sources":["../../../../../src/components/ColorPicker/SavedColors/SavedColors.tsx"],"sourcesContent":["import { CloseXS, Add } from \"@hitachivantara/uikit-react-icons\";\n\n// @types/react-color seems to be broken\n// @ts-ignore\nimport { Swatch } from \"react-color/lib/components/common\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./SavedColors.styles\";\n\nexport { staticClasses as colorPickerSavedColorsClasses };\n\nexport type HvColorPickerSavedColorsClasses = ExtractNames<typeof useClasses>;\n\ninterface SavedColorsProps {\n colors: string[];\n onClickColor: (color: { hex: string; source: string }) => void;\n onAddColor: () => void;\n onRemoveColor: (color: string, index: number) => void;\n deleteButtonArialLabel?: string;\n classes?: HvColorPickerSavedColorsClasses;\n}\n\nexport const SavedColors = ({\n colors,\n onClickColor,\n onAddColor,\n onRemoveColor,\n deleteButtonArialLabel,\n classes: classesProp,\n}: SavedColorsProps) => {\n const { classes } = useClasses(classesProp);\n\n const handleClick = (hex: string) => {\n onClickColor({\n hex,\n source: \"hex\",\n });\n };\n\n return (\n <div className={classes.root}>\n <HvButton\n className={classes.addButton}\n variant=\"secondarySubtle\"\n icon\n onClick={onAddColor}\n >\n <Add />\n </HvButton>\n {colors.map((color, index) => (\n <div\n key={`saved-color-${color}-${index}`}\n className={classes.swatchRoot}\n >\n <div className={classes.swatchWrap}>\n <Swatch\n color={color}\n onClick={handleClick}\n focusStyle={{\n boxShadow: `inset 0 0 0 1px rgba(0,0,0,.15), 0 0 4px ${color}`,\n }}\n />\n </div>\n <div className={classes.removeButtonRoot}>\n <HvButton\n className={classes.removeButton}\n variant=\"secondarySubtle\"\n onClick={() => onRemoveColor(color, index)}\n tabIndex={0}\n aria-label={deleteButtonArialLabel}\n >\n <CloseXS iconSize=\"XS\" />\n </HvButton>\n </div>\n </div>\n ))}\n </div>\n );\n};\n"],"names":["SavedColors","colors","onClickColor","onAddColor","onRemoveColor","deleteButtonArialLabel","classes","classesProp","useClasses","handleClick","hex","source","className","root","children","_jsx","HvButton","addButton","variant","icon","onClick","Add","map","color","index","swatchRoot","swatchWrap","Swatch","focusStyle","boxShadow","removeButtonRoot","removeButton","tabIndex","CloseXS","iconSize"],"mappings":";;;;;;;AAwBO,MAAMA,cAAcA,CAAC;AAAA,EAC1BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AACO,MAAM;AAChB,QAAA;AAAA,IAAED;AAAAA,EAAAA,IAAYE,mBAAAA,WAAWD,WAAW;AAEpCE,QAAAA,cAAcA,CAACC,QAAgB;AACtB,iBAAA;AAAA,MACXA;AAAAA,MACAC,QAAQ;AAAA,IAAA,CACT;AAAA,EAAA;AAGH,yCACE,OAAA;AAAA,IAAKC,WAAWN,QAAQO;AAAAA,IAAKC,UAAA,CAC3BC,2BAAAA,IAACC,iBAAQ;AAAA,MACPJ,WAAWN,QAAQW;AAAAA,MACnBC,SAAQ;AAAA,MACRC,MAAI;AAAA,MACJC,SAASjB;AAAAA,MAAWW,UAEpBC,2BAAAA,IAACM,gBAAK,KAAA,EAAA;AAAA,IAAA,CACE,GACTpB,OAAOqB,IAAI,CAACC,OAAOC,0CAClB,OAAA;AAAA,MAEEZ,WAAWN,QAAQmB;AAAAA,MAAWX,WAE9BC,2BAAAA,IAAA,OAAA;AAAA,QAAKH,WAAWN,QAAQoB;AAAAA,QAAWZ,yCAChCa,eAAM;AAAA,UACLJ;AAAAA,UACAH,SAASX;AAAAA,UACTmB,YAAY;AAAA,YACVC,WAAY,4CAA2CN;AAAAA,UACzD;AAAA,QAAA,CACD;AAAA,MAAA,CACE,GACLR,2BAAAA,IAAA,OAAA;AAAA,QAAKH,WAAWN,QAAQwB;AAAAA,QAAiBhB,yCACtCE,iBAAQ;AAAA,UACPJ,WAAWN,QAAQyB;AAAAA,UACnBb,SAAQ;AAAA,UACRE,SAASA,MAAMhB,cAAcmB,OAAOC,KAAK;AAAA,UACzCQ,UAAU;AAAA,UACV,cAAY3B;AAAAA,UAAuBS,yCAElCmB,yBAAO;AAAA,YAACC,UAAS;AAAA,UAAA,CAAM;AAAA,QAAA,CAChB;AAAA,MAAA,CACP,CAAC;AAAA,IAAA,GAtBA,eAAcX,SAASC,OAuB1B,CACN,CAAC;AAAA,EAAA,CACC;AAET;;;"}
1
+ {"version":3,"file":"SavedColors.cjs","sources":["../../../../../src/components/ColorPicker/SavedColors/SavedColors.tsx"],"sourcesContent":["import { CloseXS, Add } from \"@hitachivantara/uikit-react-icons\";\n\n// @types/react-color seems to be broken\n// @ts-ignore\nimport { Swatch } from \"react-color/lib/components/common\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./SavedColors.styles\";\n\nexport { staticClasses as colorPickerSavedColorsClasses };\n\nexport type HvColorPickerSavedColorsClasses = ExtractNames<typeof useClasses>;\n\ninterface SavedColorsProps {\n colors: string[];\n onClickColor: (color: { hex: string; source: string }) => void;\n onAddColor: () => void;\n onRemoveColor: (color: string, index: number) => void;\n deleteButtonAriaLabel?: string;\n addButtonAriaLabel?: string;\n classes?: HvColorPickerSavedColorsClasses;\n}\n\nexport const SavedColors = ({\n colors,\n onClickColor,\n onAddColor,\n onRemoveColor,\n deleteButtonAriaLabel,\n addButtonAriaLabel,\n classes: classesProp,\n}: SavedColorsProps) => {\n const { classes } = useClasses(classesProp);\n\n const handleClick = (hex: string) => {\n onClickColor({\n hex,\n source: \"hex\",\n });\n };\n\n return (\n <div className={classes.root}>\n <HvButton\n className={classes.addButton}\n variant=\"secondarySubtle\"\n icon\n onClick={onAddColor}\n aria-label={addButtonAriaLabel}\n >\n <Add aria-hidden />\n </HvButton>\n {colors.map((color, index) => (\n <div\n key={`saved-color-${color}-${index}`}\n className={classes.swatchRoot}\n >\n <div className={classes.swatchWrap}>\n <Swatch\n color={color}\n onClick={handleClick}\n focusStyle={{\n boxShadow: `inset 0 0 0 1px rgba(0,0,0,.15), 0 0 4px ${color}`,\n }}\n />\n </div>\n <div className={classes.removeButtonRoot}>\n <HvButton\n className={classes.removeButton}\n variant=\"secondarySubtle\"\n onClick={() => onRemoveColor(color, index)}\n tabIndex={0}\n aria-label={deleteButtonAriaLabel}\n >\n <CloseXS aria-hidden iconSize=\"XS\" />\n </HvButton>\n </div>\n </div>\n ))}\n </div>\n );\n};\n"],"names":["SavedColors","colors","onClickColor","onAddColor","onRemoveColor","deleteButtonAriaLabel","addButtonAriaLabel","classes","classesProp","useClasses","handleClick","hex","source","className","root","children","_jsx","HvButton","addButton","variant","icon","onClick","Add","map","color","index","swatchRoot","swatchWrap","Swatch","focusStyle","boxShadow","removeButtonRoot","removeButton","tabIndex","CloseXS","iconSize"],"mappings":";;;;;;;AAyBO,MAAMA,cAAcA,CAAC;AAAA,EAC1BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AACO,MAAM;AAChB,QAAA;AAAA,IAAED;AAAAA,EAAAA,IAAYE,mBAAAA,WAAWD,WAAW;AAEpCE,QAAAA,cAAcA,CAACC,QAAgB;AACtB,iBAAA;AAAA,MACXA;AAAAA,MACAC,QAAQ;AAAA,IAAA,CACT;AAAA,EAAA;AAGH,yCACE,OAAA;AAAA,IAAKC,WAAWN,QAAQO;AAAAA,IAAKC,UAAA,CAC3BC,2BAAAA,IAACC,iBAAQ;AAAA,MACPJ,WAAWN,QAAQW;AAAAA,MACnBC,SAAQ;AAAA,MACRC,MAAI;AAAA,MACJC,SAASlB;AAAAA,MACT,cAAYG;AAAAA,MAAmBS,yCAE9BO,qBAAG;AAAA,QAAC,eAAA;AAAA,MAAA,CAAa;AAAA,IAAA,CACV,GACTrB,OAAOsB,IAAI,CAACC,OAAOC,0CAClB,OAAA;AAAA,MAEEZ,WAAWN,QAAQmB;AAAAA,MAAWX,WAE9BC,2BAAAA,IAAA,OAAA;AAAA,QAAKH,WAAWN,QAAQoB;AAAAA,QAAWZ,yCAChCa,eAAM;AAAA,UACLJ;AAAAA,UACAH,SAASX;AAAAA,UACTmB,YAAY;AAAA,YACVC,WAAY,4CAA2CN;AAAAA,UACzD;AAAA,QAAA,CACD;AAAA,MAAA,CACE,GACLR,2BAAAA,IAAA,OAAA;AAAA,QAAKH,WAAWN,QAAQwB;AAAAA,QAAiBhB,yCACtCE,iBAAQ;AAAA,UACPJ,WAAWN,QAAQyB;AAAAA,UACnBb,SAAQ;AAAA,UACRE,SAASA,MAAMjB,cAAcoB,OAAOC,KAAK;AAAA,UACzCQ,UAAU;AAAA,UACV,cAAY5B;AAAAA,UAAsBU,yCAEjCmB,yBAAO;AAAA,YAAC,eAAW;AAAA,YAACC,UAAS;AAAA,UAAA,CAAM;AAAA,QAAA,CAC5B;AAAA,MAAA,CACP,CAAC;AAAA,IAAA,GAtBA,eAAcX,SAASC,OAuB1B,CACN,CAAC;AAAA,EAAA,CACC;AAET;;;"}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const uniqueId = require("lodash/uniqueId");
5
5
  const accept = require("attr-accept");
6
- const keyboardUtils = require("../../../utils/keyboardUtils.cjs");
7
6
  const setId = require("../../../utils/setId.cjs");
8
7
  const useUniqueId = require("../../../hooks/useUniqueId.cjs");
9
8
  const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
@@ -67,7 +66,6 @@ const HvDropZone = ({
67
66
  children: [!hideLabels && /* @__PURE__ */ jsxRuntime.jsxs("div", {
68
67
  id,
69
68
  className: classes.dropZoneLabelsGroup,
70
- "aria-label": "File Dropzone",
71
69
  children: [/* @__PURE__ */ jsxRuntime.jsx(Label.HvLabel, {
72
70
  id: setId.setId(id, "input-file-label"),
73
71
  htmlFor: setId.setId(id, "input-file"),
@@ -78,50 +76,13 @@ const HvDropZone = ({
78
76
  children: [Number.isInteger(maxFileSize) && `${labels == null ? void 0 : labels.sizeWarning} ${utils.convertUnits(maxFileSize)}`, (labels == null ? void 0 : labels.acceptedFiles) && labels.acceptedFiles, !(labels == null ? void 0 : labels.acceptedFiles) && acceptedFiles.length > 0 && ` (${acceptedFiles.join(", ")})`]
79
77
  })]
80
78
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
81
- id: setId.setId(id, "button"),
79
+ id: setId.setId(id, "input-file-container"),
82
80
  className: cx(classes.dropZoneContainer, {
83
81
  [classes.dragAction]: dragState,
84
82
  [classes.dropZoneContainerDisabled]: disabled
85
83
  }),
86
- role: "button",
87
- tabIndex: 0,
88
- onDragEnter: (event) => {
89
- if (!disabled) {
90
- enterDropArea();
91
- event.stopPropagation();
92
- event.preventDefault();
93
- }
94
- },
95
- onDragLeave: leaveDropArea,
96
- onDropCapture: leaveDropArea,
97
- onDragOver: (event) => {
98
- if (!disabled) {
99
- enterDropArea();
100
- event.stopPropagation();
101
- event.preventDefault();
102
- }
103
- },
104
- onDrop: (event) => {
105
- if (!disabled) {
106
- const {
107
- files
108
- } = event.dataTransfer;
109
- if (multiple === true || files.length === 1) {
110
- event.stopPropagation();
111
- event.preventDefault();
112
- onChangeHandler(files);
113
- }
114
- }
115
- },
116
- onKeyDown: (e) => {
117
- var _a;
118
- if (keyboardUtils.isKey(e, "Enter") || keyboardUtils.isKey(e, "Space")) {
119
- (_a = inputRef.current) == null ? void 0 : _a.click();
120
- }
121
- },
122
84
  children: [/* @__PURE__ */ jsxRuntime.jsx("input", {
123
85
  id: setId.setId(id, "input-file"),
124
- tabIndex: -1,
125
86
  className: classes.inputArea,
126
87
  type: "file",
127
88
  multiple,
@@ -138,6 +99,34 @@ const HvDropZone = ({
138
99
  onChangeHandler(inputRef.current.files);
139
100
  }
140
101
  },
102
+ onDragEnter: (event) => {
103
+ if (!disabled) {
104
+ enterDropArea();
105
+ event.stopPropagation();
106
+ event.preventDefault();
107
+ }
108
+ },
109
+ onDragLeave: leaveDropArea,
110
+ onDropCapture: leaveDropArea,
111
+ onDragOver: (event) => {
112
+ if (!disabled) {
113
+ enterDropArea();
114
+ event.stopPropagation();
115
+ event.preventDefault();
116
+ }
117
+ },
118
+ onDrop: (event) => {
119
+ if (!disabled) {
120
+ const {
121
+ files
122
+ } = event.dataTransfer;
123
+ if (multiple === true || files.length === 1) {
124
+ event.stopPropagation();
125
+ event.preventDefault();
126
+ onChangeHandler(files);
127
+ }
128
+ }
129
+ },
141
130
  ref: inputRef,
142
131
  accept: acceptedFiles.join(","),
143
132
  ...inputProps
@@ -1 +1 @@
1
- {"version":3,"file":"DropZone.cjs","sources":["../../../../../src/components/FileUploader/DropZone/DropZone.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\n\nimport uniqueId from \"lodash/uniqueId\";\n\nimport accept from \"attr-accept\";\n\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { Doc } from \"@hitachivantara/uikit-react-icons\";\nimport { HvInfoMessage, HvLabel } from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { convertUnits } from \"../utils\";\nimport { HvFileData, HvFilesAddedEvent } from \"../File\";\n\nimport { staticClasses, useClasses } from \"./DropZone.styles\";\n\nexport { staticClasses as dropZoneClasses };\n\nexport type HvDropZoneClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropZoneLabels {\n /**\n * Extensions of the accepted file types\n */\n acceptedFiles?: string;\n /**\n * Dropzone area label.\n */\n dropzone?: string;\n /**\n * Size file warning label.\n */\n sizeWarning?: string;\n /**\n * Size file warning label.\n */\n drag?: string;\n /**\n * Size file warning label.\n */\n selectFiles?: string;\n /**\n * Theming sheet used to style components\n * */\n dropFiles?: string;\n /**\n * Message to display when file size is greater than allowed\n * */\n fileSizeError?: string;\n /**\n * Message to display when file type is greater than allowed\n * */\n fileTypeError?: string;\n}\n\nexport interface HvDropZoneProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Labels to present in FileUploader.\n */\n labels?: HvDropZoneLabels;\n /**\n * Whether the Dropzone should accept multiple files at once.\n */\n multiple?: boolean;\n /**\n * If the input is disabled or not\n */\n disabled?: boolean;\n /**\n * Files extensions accepted for upload.\n */\n acceptedFiles: string[];\n /**\n * Max upload size\n * */\n maxFileSize: number;\n /**\n * Function responsible for processing files added to the drop zone.\n */\n onFilesAdded?: HvFilesAddedEvent;\n /**\n * Whether the DropZone should hide labels or not.\n */\n hideLabels?: boolean;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvDropZoneClasses;\n}\n\nexport const HvDropZone = ({\n id: idProp,\n classes: classesProp,\n labels,\n acceptedFiles,\n maxFileSize,\n inputProps,\n hideLabels,\n multiple = true,\n disabled = false,\n onFilesAdded,\n}: HvDropZoneProps) => {\n const id = useUniqueId(idProp, \"dropzone\");\n\n const { classes, cx } = useClasses(classesProp);\n\n const [dragState, setDrag] = useState<boolean>(false);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const leaveDropArea = () => {\n setDrag(false);\n };\n\n const enterDropArea = () => {\n setDrag(true);\n };\n\n const onChangeHandler = (filesList: FileList) => {\n const filesToProcess = Object.keys(filesList).map((e) => filesList[e]);\n\n const newFiles: HvFileData[] = [];\n\n filesToProcess.forEach((file: File) => {\n const newFile: HvFileData = file;\n\n const isSizeAllowed = file.size <= maxFileSize;\n const isFileAccepted =\n !acceptedFiles.length ||\n acceptedFiles.indexOf(file.type.split(\"/\")[1]) > -1 ||\n acceptedFiles.some((acceptExtension) =>\n accept({ name: file.name, type: file.type }, acceptExtension)\n );\n\n if (!isFileAccepted) {\n newFile.errorMessage = labels?.fileTypeError;\n newFile.status = \"fail\";\n } else if (!isSizeAllowed) {\n newFile.errorMessage = labels?.fileSizeError;\n newFile.status = \"fail\";\n }\n\n newFile.id = uniqueId(\"uploaded-file-data-\");\n newFiles.push(newFile);\n });\n\n onFilesAdded?.(newFiles);\n };\n\n return (\n <>\n {!hideLabels && (\n <div\n id={id}\n className={classes.dropZoneLabelsGroup}\n aria-label=\"File Dropzone\"\n >\n <HvLabel\n id={setId(id, \"input-file-label\")}\n htmlFor={setId(id, \"input-file\")}\n label={labels?.dropzone}\n className={classes.dropZoneLabel}\n />\n <HvInfoMessage id={setId(id, \"description\")}>\n {Number.isInteger(maxFileSize) &&\n `${labels?.sizeWarning} ${convertUnits(maxFileSize)}`}\n {labels?.acceptedFiles && labels.acceptedFiles}\n {!labels?.acceptedFiles &&\n acceptedFiles.length > 0 &&\n `\\u00A0(${acceptedFiles.join(\", \")})`}\n </HvInfoMessage>\n </div>\n )}\n <div\n id={setId(id, \"button\")}\n className={cx(classes.dropZoneContainer, {\n [classes.dragAction]: dragState,\n [classes.dropZoneContainerDisabled]: disabled,\n })}\n role=\"button\"\n tabIndex={0}\n onDragEnter={(event) => {\n if (!disabled) {\n enterDropArea();\n event.stopPropagation();\n event.preventDefault();\n }\n }}\n onDragLeave={leaveDropArea}\n onDropCapture={leaveDropArea}\n onDragOver={(event) => {\n if (!disabled) {\n enterDropArea();\n event.stopPropagation();\n event.preventDefault();\n }\n }}\n onDrop={(event) => {\n if (!disabled) {\n const { files } = event.dataTransfer;\n if (multiple === true || files.length === 1) {\n event.stopPropagation();\n event.preventDefault();\n onChangeHandler(files);\n }\n }\n }}\n onKeyDown={(e) => {\n if (isKey(e, \"Enter\") || isKey(e, \"Space\")) {\n inputRef.current?.click();\n }\n }}\n >\n <input\n id={setId(id, \"input-file\")}\n tabIndex={-1}\n className={classes.inputArea}\n type=\"file\"\n multiple={multiple}\n disabled={disabled}\n title={!disabled ? `${labels?.drag}\\xa0${labels?.selectFiles}` : \"\"}\n onClick={() => {\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n }}\n onChange={() => {\n if (!disabled && inputRef.current?.files) {\n onChangeHandler(inputRef.current.files);\n }\n }}\n ref={inputRef}\n accept={acceptedFiles.join(\",\")}\n {...inputProps}\n />\n <div className={classes?.dropArea}>\n {dragState ? (\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.dropFiles}\n </HvTypography>\n </div>\n ) : (\n <>\n <Doc\n iconSize=\"M\"\n className={classes.dropZoneAreaIcon}\n color={disabled ? \"secondary_60\" : \"secondary\"}\n />\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.drag}\n <span\n className={classes.selectFilesText}\n >{`\\xa0${labels?.selectFiles}`}</span>\n </HvTypography>\n </div>\n </>\n )}\n </div>\n </div>\n </>\n );\n};\n"],"names":["HvDropZone","id","idProp","classes","classesProp","labels","acceptedFiles","maxFileSize","inputProps","hideLabels","multiple","disabled","onFilesAdded","useUniqueId","cx","useClasses","dragState","setDrag","useState","inputRef","useRef","leaveDropArea","enterDropArea","onChangeHandler","filesList","filesToProcess","Object","keys","map","e","newFiles","forEach","file","newFile","isSizeAllowed","size","isFileAccepted","length","indexOf","type","split","some","acceptExtension","accept","name","errorMessage","fileTypeError","status","fileSizeError","uniqueId","push","_Fragment","children","className","dropZoneLabelsGroup","_jsx","HvLabel","setId","htmlFor","label","dropzone","dropZoneLabel","_jsxs","HvInfoMessage","Number","isInteger","sizeWarning","convertUnits","join","dropZoneContainer","dragAction","dropZoneContainerDisabled","role","tabIndex","onDragEnter","event","stopPropagation","preventDefault","onDragLeave","onDropCapture","onDragOver","onDrop","files","dataTransfer","onKeyDown","isKey","current","click","inputArea","title","drag","selectFiles","onClick","value","onChange","ref","dropArea","dropZoneAreaLabels","HvTypography","dragText","dropFiles","Doc","iconSize","dropZoneAreaIcon","color","selectFilesText"],"mappings":";;;;;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AAAA,CACL,GACD+C,2BAAAA,IAAA,OAAA;AAAA,QAAKF,WAAWlD,mCAAS6F;AAAAA,QAAS5C,UAC/BpC,YACCuC,2BAAAA,IAAA,OAAA;AAAA,UAAKF,WAAWlD,QAAQ8F;AAAAA,UAAmB7C,yCACxC8C,yBAAY;AAAA,YAAC7C,WAAWlD,QAAQgG;AAAAA,YAAS/C,UACvC/C,iCAAQ+F;AAAAA,UAAAA,CACG;AAAA,QAAA,CACX,IAELtC,2BAAAA,KAAAX,qBAAA;AAAA,UAAAC,UAAA,CACEG,2BAAAA,IAAC8C,qBAAG;AAAA,YACFC,UAAS;AAAA,YACTjD,WAAWlD,QAAQoG;AAAAA,YACnBC,OAAO7F,WAAW,iBAAiB;AAAA,UAAA,CACpC,GACD4C,2BAAAA,IAAA,OAAA;AAAA,YAAKF,WAAWlD,QAAQ8F;AAAAA,YAAmB7C,0CACxC8C,yBAAY;AAAA,cAAC7C,WAAWlD,QAAQgG;AAAAA,cAAS/C,UACvC/C,CAAAA,iCAAQqF,qCACT,QAAA;AAAA,gBACErC,WAAWlD,QAAQsG;AAAAA,gBAAgBrD,UAClC,IAAM/C,iCAAQsF;AAAAA,cAAAA,CAAoB,CAAC;AAAA,YAAA,CAC1B;AAAA,UAAA,CACX,CAAC;AAAA,QAAA,CACN;AAAA,MAAA,CAED,CAAC;AAAA,IAAA,CACH,CAAC;AAAA,EAAA,CACN;AAEN;;;"}
1
+ {"version":3,"file":"DropZone.cjs","sources":["../../../../../src/components/FileUploader/DropZone/DropZone.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\n\nimport uniqueId from \"lodash/uniqueId\";\n\nimport accept from \"attr-accept\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { Doc } from \"@hitachivantara/uikit-react-icons\";\nimport { HvInfoMessage, HvLabel } from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { convertUnits } from \"../utils\";\nimport { HvFileData, HvFilesAddedEvent } from \"../File\";\n\nimport { staticClasses, useClasses } from \"./DropZone.styles\";\n\nexport { staticClasses as dropZoneClasses };\n\nexport type HvDropZoneClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropZoneLabels {\n /**\n * Extensions of the accepted file types\n */\n acceptedFiles?: string;\n /**\n * Dropzone area label.\n */\n dropzone?: string;\n /**\n * Size file warning label.\n */\n sizeWarning?: string;\n /**\n * Size file warning label.\n */\n drag?: string;\n /**\n * Size file warning label.\n */\n selectFiles?: string;\n /**\n * Theming sheet used to style components\n * */\n dropFiles?: string;\n /**\n * Message to display when file size is greater than allowed\n * */\n fileSizeError?: string;\n /**\n * Message to display when file type is greater than allowed\n * */\n fileTypeError?: string;\n}\n\nexport interface HvDropZoneProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Labels to present in FileUploader.\n */\n labels?: HvDropZoneLabels;\n /**\n * Whether the Dropzone should accept multiple files at once.\n */\n multiple?: boolean;\n /**\n * If the input is disabled or not\n */\n disabled?: boolean;\n /**\n * Files extensions accepted for upload.\n */\n acceptedFiles: string[];\n /**\n * Max upload size\n * */\n maxFileSize: number;\n /**\n * Function responsible for processing files added to the drop zone.\n */\n onFilesAdded?: HvFilesAddedEvent;\n /**\n * Whether the DropZone should hide labels or not.\n */\n hideLabels?: boolean;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvDropZoneClasses;\n}\n\nexport const HvDropZone = ({\n id: idProp,\n classes: classesProp,\n labels,\n acceptedFiles,\n maxFileSize,\n inputProps,\n hideLabels,\n multiple = true,\n disabled = false,\n onFilesAdded,\n}: HvDropZoneProps) => {\n const id = useUniqueId(idProp, \"dropzone\");\n\n const { classes, cx } = useClasses(classesProp);\n\n const [dragState, setDrag] = useState<boolean>(false);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const leaveDropArea = () => {\n setDrag(false);\n };\n\n const enterDropArea = () => {\n setDrag(true);\n };\n\n const onChangeHandler = (filesList: FileList) => {\n const filesToProcess = Object.keys(filesList).map((e) => filesList[e]);\n\n const newFiles: HvFileData[] = [];\n\n filesToProcess.forEach((file: File) => {\n const newFile: HvFileData = file;\n\n const isSizeAllowed = file.size <= maxFileSize;\n const isFileAccepted =\n !acceptedFiles.length ||\n acceptedFiles.indexOf(file.type.split(\"/\")[1]) > -1 ||\n acceptedFiles.some((acceptExtension) =>\n accept({ name: file.name, type: file.type }, acceptExtension)\n );\n\n if (!isFileAccepted) {\n newFile.errorMessage = labels?.fileTypeError;\n newFile.status = \"fail\";\n } else if (!isSizeAllowed) {\n newFile.errorMessage = labels?.fileSizeError;\n newFile.status = \"fail\";\n }\n\n newFile.id = uniqueId(\"uploaded-file-data-\");\n newFiles.push(newFile);\n });\n\n onFilesAdded?.(newFiles);\n };\n\n return (\n <>\n {!hideLabels && (\n <div id={id} className={classes.dropZoneLabelsGroup}>\n <HvLabel\n id={setId(id, \"input-file-label\")}\n htmlFor={setId(id, \"input-file\")}\n label={labels?.dropzone}\n className={classes.dropZoneLabel}\n />\n <HvInfoMessage id={setId(id, \"description\")}>\n {Number.isInteger(maxFileSize) &&\n `${labels?.sizeWarning} ${convertUnits(maxFileSize)}`}\n {labels?.acceptedFiles && labels.acceptedFiles}\n {!labels?.acceptedFiles &&\n acceptedFiles.length > 0 &&\n `\\u00A0(${acceptedFiles.join(\", \")})`}\n </HvInfoMessage>\n </div>\n )}\n <div\n id={setId(id, \"input-file-container\")}\n className={cx(classes.dropZoneContainer, {\n [classes.dragAction]: dragState,\n [classes.dropZoneContainerDisabled]: disabled,\n })}\n >\n <input\n id={setId(id, \"input-file\")}\n className={classes.inputArea}\n type=\"file\"\n multiple={multiple}\n disabled={disabled}\n title={!disabled ? `${labels?.drag}\\xa0${labels?.selectFiles}` : \"\"}\n onClick={() => {\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n }}\n onChange={() => {\n if (!disabled && inputRef.current?.files) {\n onChangeHandler(inputRef.current.files);\n }\n }}\n onDragEnter={(event) => {\n if (!disabled) {\n enterDropArea();\n event.stopPropagation();\n event.preventDefault();\n }\n }}\n onDragLeave={leaveDropArea}\n onDropCapture={leaveDropArea}\n onDragOver={(event) => {\n if (!disabled) {\n enterDropArea();\n event.stopPropagation();\n event.preventDefault();\n }\n }}\n onDrop={(event) => {\n if (!disabled) {\n const { files } = event.dataTransfer;\n if (multiple === true || files.length === 1) {\n event.stopPropagation();\n event.preventDefault();\n onChangeHandler(files);\n }\n }\n }}\n ref={inputRef}\n accept={acceptedFiles.join(\",\")}\n {...inputProps}\n />\n <div className={classes?.dropArea}>\n {dragState ? (\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.dropFiles}\n </HvTypography>\n </div>\n ) : (\n <>\n <Doc\n iconSize=\"M\"\n className={classes.dropZoneAreaIcon}\n color={disabled ? \"secondary_60\" : \"secondary\"}\n />\n <div className={classes.dropZoneAreaLabels}>\n <HvTypography className={classes.dragText}>\n {labels?.drag}\n <span\n className={classes.selectFilesText}\n >{`\\xa0${labels?.selectFiles}`}</span>\n </HvTypography>\n </div>\n </>\n )}\n </div>\n </div>\n </>\n );\n};\n"],"names":["HvDropZone","id","idProp","classes","classesProp","labels","acceptedFiles","maxFileSize","inputProps","hideLabels","multiple","disabled","onFilesAdded","useUniqueId","cx","useClasses","dragState","setDrag","useState","inputRef","useRef","leaveDropArea","enterDropArea","onChangeHandler","filesList","filesToProcess","Object","keys","map","e","newFiles","forEach","file","newFile","isSizeAllowed","size","isFileAccepted","length","indexOf","type","split","some","acceptExtension","accept","name","errorMessage","fileTypeError","status","fileSizeError","uniqueId","push","_Fragment","children","className","dropZoneLabelsGroup","_jsx","HvLabel","setId","htmlFor","label","dropzone","dropZoneLabel","_jsxs","HvInfoMessage","Number","isInteger","sizeWarning","convertUnits","join","dropZoneContainer","dragAction","dropZoneContainerDisabled","inputArea","title","drag","selectFiles","onClick","current","value","onChange","files","onDragEnter","event","stopPropagation","preventDefault","onDragLeave","onDropCapture","onDragOver","onDrop","dataTransfer","ref","dropArea","dropZoneAreaLabels","HvTypography","dragText","dropFiles","Doc","iconSize","dropZoneAreaIcon","color","selectFilesText"],"mappings":";;;;;;;;;;;;;;;;;AAoGO,MAAMA,aAAaA,CAAC;AAAA,EACzBC,IAAIC;AAAAA,EACJC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,WAAW;AAAA,EACXC;AACe,MAAM;AACfX,QAAAA,KAAKY,YAAAA,YAAYX,QAAQ,UAAU;AAEnC,QAAA;AAAA,IAAEC;AAAAA,IAASW;AAAAA,EAAAA,IAAOC,gBAAAA,WAAWX,WAAW;AAE9C,QAAM,CAACY,WAAWC,OAAO,IAAIC,eAAkB,KAAK;AAE9CC,QAAAA,WAAWC,aAAgC,IAAI;AAErD,QAAMC,gBAAgBA,MAAM;AAC1BJ,YAAQ,KAAK;AAAA,EAAA;AAGf,QAAMK,gBAAgBA,MAAM;AAC1BL,YAAQ,IAAI;AAAA,EAAA;AAGRM,QAAAA,kBAAkBA,CAACC,cAAwB;AACzCC,UAAAA,iBAAiBC,OAAOC,KAAKH,SAAS,EAAEI,IAAKC,CAAAA,MAAML,UAAUK,CAAC,CAAC;AAErE,UAAMC,WAAyB,CAAA;AAEhBC,mBAAAA,QAAQ,CAACC,SAAe;AACrC,YAAMC,UAAsBD;AAEtBE,YAAAA,gBAAgBF,KAAKG,QAAQ5B;AACnC,YAAM6B,iBACJ,CAAC9B,cAAc+B,UACf/B,cAAcgC,QAAQN,KAAKO,KAAKC,MAAM,GAAG,EAAE,CAAC,CAAC,IAAI,MACjDlC,cAAcmC,KAAMC,qBAClBC,wBAAO;AAAA,QAAEC,MAAMZ,KAAKY;AAAAA,QAAML,MAAMP,KAA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A,OAAA;AAAA,QAAKF,WAAWlD,mCAASwF;AAAAA,QAASvC,UAC/BpC,YACCuC,2BAAAA,IAAA,OAAA;AAAA,UAAKF,WAAWlD,QAAQyF;AAAAA,UAAmBxC,yCACxCyC,yBAAY;AAAA,YAACxC,WAAWlD,QAAQ2F;AAAAA,YAAS1C,UACvC/C,iCAAQ0F;AAAAA,UAAAA,CACG;AAAA,QAAA,CACX,IAELjC,2BAAAA,KAAAX,qBAAA;AAAA,UAAAC,UAAA,CACEG,2BAAAA,IAACyC,qBAAG;AAAA,YACFC,UAAS;AAAA,YACT5C,WAAWlD,QAAQ+F;AAAAA,YACnBC,OAAOxF,WAAW,iBAAiB;AAAA,UAAA,CACpC,GACD4C,2BAAAA,IAAA,OAAA;AAAA,YAAKF,WAAWlD,QAAQyF;AAAAA,YAAmBxC,0CACxCyC,yBAAY;AAAA,cAACxC,WAAWlD,QAAQ2F;AAAAA,cAAS1C,UACvC/C,CAAAA,iCAAQqE,qCACT,QAAA;AAAA,gBACErB,WAAWlD,QAAQiG;AAAAA,gBAAgBhD,UAClC,IAAM/C,iCAAQsE;AAAAA,cAAAA,CAAoB,CAAC;AAAA,YAAA,CAC1B;AAAA,UAAA,CACX,CAAC;AAAA,QAAA,CACN;AAAA,MAAA,CAED,CAAC;AAAA,IAAA,CACH,CAAC;AAAA,EAAA,CACN;AAEN;;;"}
@@ -19,7 +19,7 @@ const {
19
19
  background: `${uikitStyles.theme.colors.atmo1}`,
20
20
  border: `1px ${uikitStyles.theme.fileUploader.dropZone.borderType} ${uikitStyles.theme.colors.secondary}`
21
21
  },
22
- "&:focus": {
22
+ "&:focus-within": {
23
23
  background: `${uikitStyles.theme.colors.atmo1}`,
24
24
  border: `1px ${uikitStyles.theme.fileUploader.dropZone.borderType} ${uikitStyles.theme.colors.secondary}`,
25
25
  ...focusUtils.outlineStyles
@@ -69,7 +69,7 @@ const {
69
69
  },
70
70
  dropZoneAreaLabels: {
71
71
  display: "flex",
72
- width: 115,
72
+ maxWidth: 120,
73
73
  margin: "auto"
74
74
  },
75
75
  dropZoneAreaIcon: {
@@ -1 +1 @@
1
- {"version":3,"file":"DropZone.styles.cjs","sources":["../../../../../src/components/FileUploader/DropZone/DropZone.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CSSProperties } from \"react\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropZone\", {\n dropZoneContainer: {\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColor}`,\n cursor: \"pointer\",\n background: theme.fileUploader.dropZone.backgroundColor,\n borderRadius: theme.fileUploader.dropZone.borderRadius,\n\n \"&:hover\": {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.colors.secondary}`,\n },\n\n \"&:focus\": {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.colors.secondary}`,\n ...outlineStyles,\n },\n },\n dropZoneLabelsGroup: {\n display: \"flex\",\n justifyContent: \"start\",\n\n \"& label:nth-of-type(1)\": {},\n\n \"& p:nth-of-type(2)\": {\n marginLeft: \"auto\",\n },\n },\n dragAction: {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDrag}`,\n },\n dropZoneContainerDisabled: {\n background: `${theme.colors.atmo3}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDisabled}`,\n cursor: \"not-allowed\",\n \"&:hover\": {\n background: `${theme.colors.atmo3}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDisabled}`,\n },\n\n \"& $dragText\": {\n color: theme.colors.secondary_60,\n },\n \"& $selectFilesText\": {\n color: theme.colors.secondary_60,\n },\n },\n inputArea: {\n opacity: 0,\n width: \"100%\",\n position: \"absolute\",\n height: \"100%\",\n cursor: \"pointer\",\n\n \"&:disabled\": {\n cursor: \"not-allowed\",\n },\n },\n dropArea: {\n display: \"flex\",\n margin: `${theme.space.md} auto`,\n minHeight: 48,\n },\n dropZoneAreaLabels: {\n display: \"flex\",\n width: 115,\n margin: \"auto\",\n },\n dropZoneAreaIcon: {\n margin: \"auto\",\n marginRight: theme.space.xs,\n },\n dropZoneLabel: {\n paddingBottom: 6,\n },\n dragText: {\n ...(theme.typography.body as CSSProperties),\n },\n selectFilesText: {\n ...(theme.typography.label as CSSProperties),\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","dropZoneContainer","position","width","display","border","theme","fileUploader","dropZone","borderType","borderColor","cursor","background","backgroundColor","borderRadius","colors","atmo1","secondary","outlineStyles","dropZoneLabelsGroup","justifyContent","marginLeft","dragAction","borderColorDrag","dropZoneContainerDisabled","atmo3","borderColorDisabled","color","secondary_60","inputArea","opacity","height","dropArea","margin","space","md","minHeight","dropZoneAreaLabels","dropZoneAreaIcon","marginRight","xs","dropZoneLabel","paddingBottom","dragText","typography","body","selectFilesText","label"],"mappings":";;;;;AAKa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,cAAc;AAAA,EACvEC,mBAAmB;AAAA,IACjBC,UAAU;AAAA,IACVC,OAAO;AAAA,IACPC,SAAS;AAAA,IACTC,QAAS,OAAMC,YAAMC,MAAAA,aAAaC,SAASC,cAAcH,YAAAA,MAAMC,aAAaC,SAASE;AAAAA,IACrFC,QAAQ;AAAA,IACRC,YAAYN,YAAMC,MAAAA,aAAaC,SAASK;AAAAA,IACxCC,cAAcR,YAAMC,MAAAA,aAAaC,SAASM;AAAAA,IAE1C,WAAW;AAAA,MACTF,YAAa,GAAEN,YAAAA,MAAMS,OAAOC;AAAAA,MAC5BX,QAAS,OAAMC,YAAAA,MAAMC,aAAaC,SAASC,cAAcH,YAAAA,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,EACF;AAAA,EACAqB,UAAU;AAAA,IACR5B,SAAS;AAAA,IACT6B,QAAS,GAAE3B,YAAAA,MAAM4B,MAAMC;AAAAA,IACvBC,WAAW;AAAA,EACb;AAAA,EACAC,oBAAoB;AAAA,IAClBjC,SAAS;AAAA,IACTD,OAAO;AAAA,IACP8B,QAAQ;AAAA,EACV;AAAA,EACAK,kBAAkB;AAAA,IAChBL,QAAQ;AAAA,IACRM,aAAajC,YAAAA,MAAM4B,MAAMM;AAAAA,EAC3B;AAAA,EACAC,eAAe;AAAA,IACbC,eAAe;AAAA,EACjB;AAAA,EACAC,UAAU;AAAA,IACR,GAAIrC,YAAAA,MAAMsC,WAAWC;AAAAA,EACvB;AAAA,EACAC,iBAAiB;AAAA,IACf,GAAIxC,YAAAA,MAAMsC,WAAWG;AAAAA,EACvB;AACF,CAAC;;;"}
1
+ {"version":3,"file":"DropZone.styles.cjs","sources":["../../../../../src/components/FileUploader/DropZone/DropZone.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CSSProperties } from \"react\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropZone\", {\n dropZoneContainer: {\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColor}`,\n cursor: \"pointer\",\n background: theme.fileUploader.dropZone.backgroundColor,\n borderRadius: theme.fileUploader.dropZone.borderRadius,\n\n \"&:hover\": {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.colors.secondary}`,\n },\n\n \"&:focus-within\": {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.colors.secondary}`,\n ...outlineStyles,\n },\n },\n dropZoneLabelsGroup: {\n display: \"flex\",\n justifyContent: \"start\",\n\n \"& label:nth-of-type(1)\": {},\n\n \"& p:nth-of-type(2)\": {\n marginLeft: \"auto\",\n },\n },\n dragAction: {\n background: `${theme.colors.atmo1}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDrag}`,\n },\n dropZoneContainerDisabled: {\n background: `${theme.colors.atmo3}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDisabled}`,\n cursor: \"not-allowed\",\n \"&:hover\": {\n background: `${theme.colors.atmo3}`,\n border: `1px ${theme.fileUploader.dropZone.borderType} ${theme.fileUploader.dropZone.borderColorDisabled}`,\n },\n\n \"& $dragText\": {\n color: theme.colors.secondary_60,\n },\n \"& $selectFilesText\": {\n color: theme.colors.secondary_60,\n },\n },\n inputArea: {\n opacity: 0,\n width: \"100%\",\n position: \"absolute\",\n height: \"100%\",\n cursor: \"pointer\",\n\n \"&:disabled\": {\n cursor: \"not-allowed\",\n },\n },\n dropArea: {\n display: \"flex\",\n margin: `${theme.space.md} auto`,\n minHeight: 48,\n },\n dropZoneAreaLabels: {\n display: \"flex\",\n maxWidth: 120,\n margin: \"auto\",\n },\n dropZoneAreaIcon: {\n margin: \"auto\",\n marginRight: theme.space.xs,\n },\n dropZoneLabel: {\n paddingBottom: 6,\n },\n dragText: {\n ...(theme.typography.body as CSSProperties),\n },\n selectFilesText: {\n ...(theme.typography.label as CSSProperties),\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","dropZoneContainer","position","width","display","border","theme","fileUploader","dropZone","borderType","borderColor","cursor","background","backgroundColor","borderRadius","colors","atmo1","secondary","outlineStyles","dropZoneLabelsGroup","justifyContent","marginLeft","dragAction","borderColorDrag","dropZoneContainerDisabled","atmo3","borderColorDisabled","color","secondary_60","inputArea","opacity","height","dropArea","margin","space","md","minHeight","dropZoneAreaLabels","maxWidth","dropZoneAreaIcon","marginRight","xs","dropZoneLabel","paddingBottom","dragText","typography","body","selectFilesText","label"],"mappings":";;;;;AAKa,MAAA;AAAA,EAA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