@hitachivantara/uikit-react-core 5.66.8 → 5.66.10

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.
@@ -10,6 +10,7 @@ const useDefaultProps = require("../hooks/useDefaultProps.cjs");
10
10
  const useTheme = require("../hooks/useTheme.cjs");
11
11
  const useUniqueId = require("../hooks/useUniqueId.cjs");
12
12
  const generic = require("../types/generic.cjs");
13
+ const document = require("../utils/document.cjs");
13
14
  const setId = require("../utils/setId.cjs");
14
15
  const Select_styles = require("./Select.styles.cjs");
15
16
  const DropdownButton = require("../DropdownButton/DropdownButton.cjs");
@@ -178,7 +179,7 @@ const HvSelect = generic.fixedForwardRef(function HvSelect2(props, ref) {
178
179
  open: isOpen,
179
180
  keepMounted: true,
180
181
  disablePortal: !enablePortal,
181
- container: enablePortal ? document.getElementById(rootId || "") || document.body : void 0,
182
+ container: enablePortal ? document.getContainerElement(rootId) : void 0,
182
183
  anchorEl: buttonRef.current,
183
184
  className: classes.popper,
184
185
  placement,
@@ -8,6 +8,7 @@ const validationStates = require("../Forms/FormElement/validationStates.cjs");
8
8
  const useControlled = require("../hooks/useControlled.cjs");
9
9
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
10
10
  const useUniqueId = require("../hooks/useUniqueId.cjs");
11
+ const document = require("../utils/document.cjs");
11
12
  const setId = require("../utils/setId.cjs");
12
13
  const Slider_styles = require("./Slider.styles.cjs");
13
14
  const SliderInput = require("./SliderInput/SliderInput.cjs");
@@ -312,7 +313,7 @@ const HvSlider = React.forwardRef((props, ref) => {
312
313
  visible: dragging,
313
314
  placement: "top",
314
315
  overlayClassName: classes.sliderTooltip,
315
- getTooltipContainer: () => document.getElementById(indexedHandleId || ""),
316
+ getTooltipContainer: () => document.getElementById(indexedHandleId),
316
317
  children: /* @__PURE__ */ jsxRuntime.jsx(
317
318
  "div",
318
319
  {
@@ -28,11 +28,17 @@ const HvTooltip = React.forwardRef((props, ref) => {
28
28
  } = useDefaultProps.useDefaultProps("HvTooltip", props);
29
29
  const { rootId } = useTheme.useTheme();
30
30
  const { classes } = Tooltip_styles.useClasses(classesProp);
31
+ const [container, setContainer] = React.useState(
32
+ () => document.getElementById(containerId ?? rootId)
33
+ );
34
+ React.useEffect(() => {
35
+ setContainer(document.getElementById(containerId ?? rootId));
36
+ }, [containerId, rootId]);
31
37
  return /* @__PURE__ */ jsxRuntime.jsx(
32
38
  Tooltip__default.default,
33
39
  {
34
40
  ref,
35
- open: open ?? void 0,
41
+ open,
36
42
  enterDelay,
37
43
  placement,
38
44
  TransitionComponent,
@@ -43,9 +49,7 @@ const HvTooltip = React.forwardRef((props, ref) => {
43
49
  popper: classes.popper
44
50
  },
45
51
  title,
46
- PopperProps: {
47
- container: document.getElementById(containerId || rootId)
48
- },
52
+ PopperProps: { container },
49
53
  ...others,
50
54
  children
51
55
  }
@@ -9,41 +9,34 @@ const theme = require("../utils/theme.cjs");
9
9
  const HvThemeProvider = ({
10
10
  children,
11
11
  themes: themesList,
12
- theme: theme$1,
12
+ theme: themeProp,
13
13
  emotionCache,
14
- colorMode,
14
+ colorMode: colorModeProp,
15
15
  themeRootId: rootId
16
16
  }) => {
17
- const initTheme = uikitStyles.parseTheme(themesList, theme$1, colorMode);
18
- const [parsedTheme, setParsedTheme] = React.useState(initTheme);
19
- const [activeTheme, setActiveTheme] = React.useState(parsedTheme.theme);
20
- const [selectedTheme, setSelectedTheme] = React.useState(parsedTheme.selectedTheme);
21
- const [selectedMode, setThemeMode] = React.useState(parsedTheme.selectedMode);
22
- const [colorModes, setColorModes] = React.useState(parsedTheme.colorModes);
23
- const [themes, setThemes] = React.useState(themesList.map((t) => t.name));
17
+ const [theme$1, setTheme] = React.useState(themeProp);
18
+ const [colorMode, setColorMode] = React.useState(colorModeProp);
19
+ const {
20
+ theme: activeTheme,
21
+ selectedTheme,
22
+ selectedMode,
23
+ colorModes,
24
+ colorScheme
25
+ } = uikitStyles.parseTheme(themesList, theme$1, colorMode);
26
+ const themes = themesList.map((t) => t.name);
24
27
  React.useEffect(() => {
25
- const pTheme = uikitStyles.parseTheme(themesList, theme$1, colorMode);
26
- setThemes(themesList.map((t) => t.name));
27
- setParsedTheme(pTheme);
28
- }, [themesList, theme$1, colorMode]);
28
+ setTheme(themeProp);
29
+ setColorMode(colorModeProp);
30
+ }, [colorModeProp, themeProp]);
29
31
  React.useEffect(() => {
30
- setActiveTheme(parsedTheme.theme);
31
- setSelectedTheme(parsedTheme.selectedTheme);
32
- setThemeMode(parsedTheme.selectedMode);
33
- setColorModes(parsedTheme.colorModes);
34
- theme.setElementAttrs(
35
- parsedTheme.selectedTheme,
36
- parsedTheme.selectedMode,
37
- parsedTheme.colorScheme,
38
- rootId
39
- );
40
- }, [parsedTheme, rootId]);
32
+ theme.setElementAttrs(selectedTheme, selectedMode, colorScheme, rootId);
33
+ }, [colorScheme, rootId, selectedMode, selectedTheme]);
41
34
  const changeTheme = React.useCallback(
42
35
  (newTheme = selectedTheme, newMode = selectedMode) => {
43
- const pTheme = uikitStyles.parseTheme(themesList, newTheme, newMode);
44
- setParsedTheme(pTheme);
36
+ setTheme(newTheme);
37
+ setColorMode(newMode);
45
38
  },
46
- [selectedMode, selectedTheme, themesList]
39
+ [selectedMode, selectedTheme]
47
40
  );
48
41
  const value = React.useMemo(
49
42
  () => ({
@@ -65,25 +58,25 @@ const HvThemeProvider = ({
65
58
  rootId
66
59
  ]
67
60
  );
68
- const MuiTheme = styles.createTheme({
69
- components: {
70
- MuiButtonBase: {
71
- defaultProps: {
72
- disableRipple: true
61
+ const muiTheme = React.useMemo(() => {
62
+ return styles.createTheme({
63
+ components: {
64
+ MuiButtonBase: {
65
+ defaultProps: {
66
+ disableRipple: true
67
+ }
73
68
  }
69
+ },
70
+ breakpoints: {
71
+ ...activeTheme.breakpoints
74
72
  }
75
- },
76
- breakpoints: {
77
- values: {
78
- ...activeTheme.breakpoints.values
79
- }
80
- }
81
- });
73
+ });
74
+ }, [activeTheme.breakpoints]);
82
75
  const emotionCacheValue = React.useMemo(
83
76
  () => ({ cache: emotionCache }),
84
77
  [emotionCache]
85
78
  );
86
- return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, { theme: MuiTheme, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactShared.HvThemeContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactShared.EmotionContext.Provider, { value: emotionCacheValue, children }) }) });
79
+ return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, { theme: muiTheme, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactShared.HvThemeContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactShared.EmotionContext.Provider, { value: emotionCacheValue, children }) }) });
87
80
  };
88
81
  Object.defineProperty(exports, "EmotionContext", {
89
82
  enumerable: true,
@@ -6,5 +6,9 @@ function getDocument() {
6
6
  function getElementById(elementId) {
7
7
  return elementId && getDocument()?.getElementById(elementId) || void 0;
8
8
  }
9
+ function getContainerElement(elementId) {
10
+ return getElementById(elementId) || getDocument()?.body;
11
+ }
12
+ exports.getContainerElement = getContainerElement;
9
13
  exports.getDocument = getDocument;
10
14
  exports.getElementById = getElementById;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const uikitStyles = require("@hitachivantara/uikit-styles");
4
- const document$1 = require("./document.cjs");
4
+ const document = require("./document.cjs");
5
5
  const setElementAttrs = (themeName, modeName, colorScheme, themeRootId) => {
6
- const element = themeRootId ? document.getElementById(themeRootId) : document.body;
6
+ const element = document.getContainerElement(themeRootId);
7
7
  if (element) {
8
8
  element.setAttribute(`data-theme`, themeName);
9
9
  element.setAttribute(`data-color-mode`, modeName);
@@ -78,7 +78,7 @@ const processThemes = (themesList) => {
78
78
  return [uikitStyles.themes.ds5];
79
79
  };
80
80
  const getVarValue = (cssVar, rootElementId) => {
81
- const root = document$1.getElementById(rootElementId || "hv-root");
81
+ const root = document.getElementById(rootElementId || "hv-root");
82
82
  if (!root)
83
83
  return void 0;
84
84
  return getComputedStyle(root).getPropertyValue(cssVar.replace("var(", "").replace(")", "")).trim();
@@ -8,6 +8,7 @@ import { useDefaultProps } from "../hooks/useDefaultProps.js";
8
8
  import { useTheme } from "../hooks/useTheme.js";
9
9
  import { useUniqueId } from "../hooks/useUniqueId.js";
10
10
  import { fixedForwardRef } from "../types/generic.js";
11
+ import { getContainerElement } from "../utils/document.js";
11
12
  import { setId } from "../utils/setId.js";
12
13
  import { useClasses } from "./Select.styles.js";
13
14
  import { staticClasses } from "./Select.styles.js";
@@ -175,7 +176,7 @@ const HvSelect = fixedForwardRef(function HvSelect2(props, ref) {
175
176
  open: isOpen,
176
177
  keepMounted: true,
177
178
  disablePortal: !enablePortal,
178
- container: enablePortal ? document.getElementById(rootId || "") || document.body : void 0,
179
+ container: enablePortal ? getContainerElement(rootId) : void 0,
179
180
  anchorEl: buttonRef.current,
180
181
  className: classes.popper,
181
182
  placement,
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport clsx from \"clsx\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { HvPanel } from \"../Panel\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: clsx.ClassValue[]) => clsx(ids) || undefined;\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean = false,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : getOptionMetadata(value as OptionValue) ?? null;\n\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(ariaLabelledBy, { [labelId]: label })}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(ariaDescribedBy, {\n [descriptionId]: description,\n })}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={\n enablePortal\n ? document.getElementById(rootId || \"\") || document.body\n : undefined\n }\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvPanel\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n >\n <SelectProvider value={contextValue}>\n <HvListContainer condensed selectable {...getListboxProps()}>\n {children}\n </HvListContainer>\n </SelectProvider>\n </HvPanel>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC1B,QAAI,QAAQ,WAAW;AAAU,aAAA;AAC1B,WAAA,oBAAA,UAAA,EAAG,UAAQ,QAAA,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,CAAA;AAAA,EACnD;AAEA,SAAO,SAAS,SAAS;AAC3B;AAEA,MAAM,WAAW,IAAI,QAA2B,KAAK,GAAG,KAAK;AAmDtD,MAAM,WAAW,gBAAgB,SAASA,UAI/C,OACA,KACA;AACM,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IAC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A,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
1
+ {"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport clsx from \"clsx\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { HvPanel } from \"../Panel\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { getContainerElement } from \"../utils/document\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: clsx.ClassValue[]) => clsx(ids) || undefined;\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean = false,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : getOptionMetadata(value as OptionValue) ?? null;\n\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(ariaLabelledBy, { [labelId]: label })}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(ariaDescribedBy, {\n [descriptionId]: description,\n })}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvPanel\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n >\n <SelectProvider value={contextValue}>\n <HvListContainer condensed selectable {...getListboxProps()}>\n {children}\n </HvListContainer>\n </SelectProvider>\n </HvPanel>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,Q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C,OAAO;AAAA,kBACL,OAAO,gBACH,UACC,UAAU,SAAS,eAAe,KAAK;AAAA,gBAC9C;AAAA,gBACA,WAAW,GAAG,QAAQ,OAAO,WAAW;AAAA,kBACtC,CAAC,QAAQ,aAAa,GAAG,UAAU,SAAS,KAAK;AAAA,kBACjD,CAAC,QAAQ,eAAe,GAAG,UAAU,SAAS,QAAQ;AAAA,gBAAA,CACvD;AAAA,gBAED,UAAC,oBAAA,gBAAA,EAAe,OAAO,cACrB,8BAAC,iBAAgB,EAAA,WAAS,MAAC,YAAU,MAAE,GAAG,mBACvC,SACH,CAAA,GACF;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QACF;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAG,oBAAoB;AAAA,YACxB;AAAA,YACC,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
@@ -6,6 +6,7 @@ import validationState from "../Forms/FormElement/validationStates.js";
6
6
  import { useControlled } from "../hooks/useControlled.js";
7
7
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
8
8
  import { useUniqueId } from "../hooks/useUniqueId.js";
9
+ import { getElementById } from "../utils/document.js";
9
10
  import { setId } from "../utils/setId.js";
10
11
  import { useClasses, sliderStyles } from "./Slider.styles.js";
11
12
  import { staticClasses } from "./Slider.styles.js";
@@ -308,7 +309,7 @@ const HvSlider = forwardRef((props, ref) => {
308
309
  visible: dragging,
309
310
  placement: "top",
310
311
  overlayClassName: classes.sliderTooltip,
311
- getTooltipContainer: () => document.getElementById(indexedHandleId || ""),
312
+ getTooltipContainer: () => getElementById(indexedHandleId),
312
313
  children: /* @__PURE__ */ jsx(
313
314
  "div",
314
315
  {
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":["../../../src/Slider/Slider.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport Slider, { SliderProps, SliderRef } from \"rc-slider\";\nimport Tooltip from \"rc-tooltip\";\n\nimport { HvFormElement, HvFormStatus, HvLabel, HvWarningText } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvInputProps } from \"../Input\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { sliderStyles, staticClasses, useClasses } from \"./Slider.styles\";\nimport { HvSliderInput } from \"./SliderInput/SliderInput\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\nimport {\n calculateStepValue,\n convertStatusToArray,\n createKnobStyles,\n createMark,\n createTrackStyles,\n ensureValuesConsistency,\n generateDefaultKnobProperties,\n isSingleSlider,\n knobsPositionsToKnobsValues,\n knobsPositionToScaledValue,\n knobsValuesToKnobsPositions,\n scaledValueToKnobsPositionValue,\n statusArrayToFormStatus,\n} from \"./utils\";\n\nexport { staticClasses as sliderClasses };\n\nexport type HvSliderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSliderProps\n extends HvBaseProps<HTMLDivElement, \"onChange\" | \"onBlur\"> {\n /** The slider name. */\n name?: string;\n /** The label of the slider. If not provided, an aria-label or aria-labelledby must be inputted via sliderProps. */\n label?: React.ReactNode;\n /** Indicates that the slider is disabled. */\n disabled?: boolean;\n /** Indicates that the slider is not editable. */\n readOnly?: boolean;\n /** Indicates that user slider is required on the form element. */\n required?: boolean;\n /** Error message to render when the value is required. */\n requiredMessage?: string;\n /** If `true` the input that controls the slider is hidden. */\n hideInput?: boolean;\n /** Attributes applied to the slider element. */\n sliderProps?: SliderProps;\n /**\n * The status of the slider element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus | HvFormStatus[];\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: React.ReactNode;\n /** The values array to apply to the component */\n values?: number[];\n /** The default values array to apply to the component */\n defaultValues?: (number | undefined)[];\n /**\n * The object used to set the knob properties,\n * for every item in the array a new knob will be created.\n */\n knobProperties?: HvKnobProperty[];\n /** The object used to set the mark properties individually. */\n markProperties?: HvMarkProperty[];\n /**\n * The function executed before a change will occur in the slider.\n * @deprecated It's always better to use onChange instead\n */\n onBeforeChange?: (value: number[]) => void;\n /** The function executed while a change is occurring in the slider. */\n onChange?: (value: number[]) => void;\n /**\n * The function executed after a change ocurred in the slider.\n * @deprecated It's always better to use onChange instead\n */\n onAfterChange?: (value: number[]) => void;\n /** The function executed after a blur ocurred in the slider. */\n onBlur?: (\n event: React.FocusEvent,\n knobsValues: number[],\n status?: HvFormStatus | HvFormStatus[],\n ) => void;\n /**\n * The separation in points between marks.\n * example: if 10 divisions and a markstep of 2 there will be 5 marks.\n */\n markStep?: number;\n /** How many subdivisions there are in the slider. */\n divisionQuantity?: number;\n /** The value of the first point in the slider from left to right. */\n minPointValue?: number;\n /** The value of the last point in the slider from left to right. */\n maxPointValue?: number;\n /** Error message to render when the value is higher than maxPointValue or lower than minPointValue. */\n outOfRangeMessage?: string;\n /** The max number of decimals if no format function is applied */\n markDigits?: number;\n /**\n * A formatting function used to add format to the marks in the track,\n * the function receives the mark text\n */\n formatMark?: (label: React.ReactNode) => React.ReactNode;\n /**\n * A formatting function used to add format to the tooltip in the track,\n * the function receives the mark text\n */\n formatTooltip?: (label: React.ReactNode) => React.ReactNode;\n /** If `true` the knobs can't have the same value, if `false` knobs can have the same value. */\n noOverlap?: boolean;\n /** Attributes applied to the input element. */\n inputProps?: HvInputProps[];\n /** Attributes applied to the knob element. */\n knobProps?: React.HTMLAttributes<HTMLDivElement>[];\n /** The classes object to be applied into the root object. */\n classes?: HvSliderClasses;\n}\n\n/**\n * Sliders reflect a range of values along a bar, from which users may select a single value. They are ideal for adjusting settings such as volume, brightness, or applying image filters.\n */\nexport const HvSlider = forwardRef<SliderRef, HvSliderProps>((props, ref) => {\n const {\n id,\n className,\n name,\n label,\n status,\n statusMessage,\n disabled,\n classes: classesProp,\n sliderProps,\n knobProps,\n inputProps,\n requiredMessage = \"The value is required\",\n outOfRangeMessage = \"The value is out of range\",\n noOverlap = true,\n hideInput = false,\n required = false,\n readOnly = false,\n markProperties = [],\n defaultValues = [undefined],\n values: valuesProp = [],\n knobProperties: knobPropertiesProp,\n \"aria-errormessage\": ariaErrorMessage,\n maxPointValue = 100,\n minPointValue = 0,\n divisionQuantity = 100,\n markStep = 20,\n markDigits = 0,\n formatMark,\n onChange,\n onBlur,\n onBeforeChange,\n onAfterChange,\n formatTooltip,\n ...others\n } = useDefaultProps(\"HvSlider\", props);\n const { classes, cx } = useClasses(classesProp);\n\n // Miscellaneous state\n const hasLabel = label != null;\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n const elementId = useUniqueId(id);\n\n const sliderInputId = setId(elementId, \"input\");\n\n const stepValue = useMemo(\n () => calculateStepValue(maxPointValue, minPointValue, divisionQuantity),\n [divisionQuantity, maxPointValue, minPointValue],\n );\n\n const inverseStepValue = 1 / stepValue;\n\n const marks = useMemo(\n () =>\n createMark(\n markProperties,\n markStep,\n divisionQuantity,\n minPointValue,\n maxPointValue,\n stepValue,\n markDigits,\n !!disabled,\n formatMark,\n ),\n [\n disabled,\n divisionQuantity,\n formatMark,\n markDigits,\n markProperties,\n markStep,\n minPointValue,\n maxPointValue,\n stepValue,\n ],\n );\n\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n // We always show an error when the value(s) are not between maxPointValue and minPointValue; and when required is true (set by user).\n status === undefined);\n\n const isSingle: boolean = useMemo(\n () => isSingleSlider(valuesProp, defaultValues),\n [defaultValues, valuesProp],\n );\n\n const value: number[] | undefined = useMemo(\n () =>\n valuesProp?.length > 0\n ? knobsValuesToKnobsPositions(\n valuesProp,\n inverseStepValue,\n minPointValue,\n )\n : undefined,\n [inverseStepValue, minPointValue, valuesProp],\n );\n\n const defaultKnobsPositions: number[] = useMemo(\n () =>\n knobsValuesToKnobsPositions(\n defaultValues,\n inverseStepValue,\n minPointValue,\n ),\n [defaultValues, inverseStepValue, minPointValue],\n );\n\n const [knobsPositions, setKnobsPositions] = useControlled(\n value,\n defaultKnobsPositions,\n );\n\n // Validation related state\n const { arrayStatus, arrayDefaultStatus } = useMemo(\n () => convertStatusToArray(knobsPositions.length, status),\n [knobsPositions.length, status],\n );\n\n const [validationStatus, setValidationState] = useControlled(\n arrayStatus,\n arrayDefaultStatus,\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n const [isDraggingTrack, setIsDraggingTrack] = useState(false);\n\n const knobProperties = generateDefaultKnobProperties(\n knobsPositions.length,\n disabled,\n knobPropertiesProp,\n );\n\n const rangesCount = knobProperties.length - 1;\n\n const trackStyles = createTrackStyles(knobProperties);\n\n const knobStyles = createKnobStyles(knobProperties);\n\n /**\n * Generates an object which posses the current value and position of the knobs.\n *\n * @param {Array} knobsCurrentPosition - An array containing the current positions of the knobs.\n * @returns {Object} - An object with the positions and values of the knobs.\n * @memberof HvSlider\n */\n const generateKnobsPositionAndValues = useCallback(\n (\n knobsCurrentPosition: number[],\n ): { knobsPosition: number[]; knobsValues: number[] } => {\n const newKnobsPosition: number[] = knobsCurrentPosition.slice();\n const knobsValues: number[] = [];\n\n let duplicatedValue: number | null = null;\n\n const findDuplicated: number[] = newKnobsPosition.filter(\n (item, index) => newKnobsPosition.indexOf(item) !== index,\n );\n\n if (noOverlap && findDuplicated.length > 0) {\n [duplicatedValue] = findDuplicated;\n }\n\n newKnobsPosition.forEach((position, index, array) => {\n const newArray: number[] = array;\n let newPosition: number = position;\n\n if (noOverlap && newPosition === duplicatedValue) {\n const previousValue = knobsPositions[index];\n if (previousValue !== newPosition) {\n newPosition += newPosition > previousValue ? -1 : 1;\n newArray[index] = newPosition;\n }\n }\n\n knobsValues[index] = knobsPositionToScaledValue(\n newPosition,\n minPointValue,\n stepValue,\n );\n }, this);\n\n return {\n knobsPosition: newKnobsPosition,\n knobsValues,\n };\n },\n [knobsPositions, minPointValue, noOverlap, stepValue],\n );\n\n const performValidation = useCallback(() => {\n let invalid = false;\n let requiredMsg = false;\n\n const mappedValues =\n generateKnobsPositionAndValues(knobsPositions).knobsValues;\n\n const newValidationState = mappedValues.map((knobValue) => {\n if (required && (knobValue == null || Number.isNaN(knobValue))) {\n invalid = true;\n requiredMsg = true;\n return validationStates.invalid;\n }\n\n if (knobValue < minPointValue || knobValue > maxPointValue) {\n invalid = true;\n return validationStates.invalid;\n }\n\n return validationStates.valid;\n });\n\n setValidationState([...newValidationState]);\n\n if (invalid) {\n setValidationMessage(requiredMsg ? requiredMessage : outOfRangeMessage);\n return;\n }\n\n setValidationMessage(\"\");\n }, [\n generateKnobsPositionAndValues,\n knobsPositions,\n maxPointValue,\n minPointValue,\n outOfRangeMessage,\n required,\n requiredMessage,\n setValidationMessage,\n setValidationState,\n ]);\n\n useEffect(() => {\n const stepVl = calculateStepValue(\n maxPointValue,\n minPointValue,\n divisionQuantity,\n );\n\n const inverseStepVl = 1 / stepVl;\n\n if (valuesProp?.length > 0) {\n setKnobsPositions(\n knobsValuesToKnobsPositions(\n valuesProp.length > 0 ? valuesProp : defaultValues,\n inverseStepVl,\n minPointValue,\n ),\n );\n }\n }, [\n defaultValues,\n divisionQuantity,\n maxPointValue,\n minPointValue,\n setKnobsPositions,\n valuesProp,\n ]);\n\n useEffect(() => {\n if (!isDirty.current) {\n // Skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [knobsPositions, requiredMessage, performValidation]);\n\n const onMouseDownHandler = (event: React.MouseEvent<HTMLDivElement>) => {\n if ((event.target as HTMLDivElement).className.includes(\"track\")) {\n setIsDraggingTrack(true);\n }\n };\n\n const onMouseUpHandler = () => {\n setIsDraggingTrack(false);\n };\n\n const onBlurHandler = (event: React.FocusEvent) => {\n const knobs = generateKnobsPositionAndValues(knobsPositions);\n\n performValidation();\n\n onBlur?.(event, knobs.knobsValues, status);\n };\n\n /**\n * Function executed while the knobs changes.\n *\n * executes the callback provided by the user with the values and position of the knobs,\n * also lock the value of the knob in case one is fixed.\n */\n const onChangeHandler = (knobsPosition: number[]) => {\n isDirty.current = true;\n\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n knobProperties.forEach((knobProperty, index) => {\n if (knobProperty.fixed) {\n knobs.knobsPosition[index] = scaledValueToKnobsPositionValue(\n defaultValues[index],\n minPointValue,\n inverseStepValue,\n );\n }\n });\n\n if (disabled || readOnly) return;\n onChange?.(knobs.knobsValues);\n\n setKnobsPositions(knobs.knobsPosition);\n };\n\n const onInputChangeHandler = (inputValues: number[], index: number) => {\n let newKnobPositions = knobsValuesToKnobsPositions(\n inputValues,\n inverseStepValue,\n minPointValue,\n );\n\n newKnobPositions = ensureValuesConsistency(newKnobPositions, index);\n\n onChangeHandler(newKnobPositions);\n };\n\n /**\n * Function executed before a change.\n *\n * executes the callback provided by the user with the values and position of the knobs\n */\n const onBeforeChangeHandler = (knobsPosition: number[]) => {\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n onBeforeChange?.(knobs.knobsValues);\n };\n\n /**\n * Function executed after a change.\n *\n * executes the callback provided by the user with the values and position of the knobs\n */\n const onAfterChangeHandler = (knobsPosition: number[]) => {\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n onAfterChange?.(knobs.knobsValues);\n };\n\n /**\n * Function used to create a custom knob for the slider.\n *\n * TODO: This should be isolated because is creating a sub component,\n * but there were some problems regarding the underlying component losing\n * references of the handlers disabling the focus.\n */\n const createKnob: SliderProps[\"handleRender\"] = (knobNode, params) => {\n const { value: knobValue, dragging, index } = params;\n const { style = {}, ...restProps } = knobNode.props;\n const scaledKnobValue = knobsPositionToScaledValue(\n knobValue,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n if (dragging) {\n style.backgroundColor = knobProperties[index]?.dragColor;\n } else {\n style.backgroundColor = knobProperties[index]?.color;\n }\n\n const isEmpty =\n Number.isNaN(knobsPositions[index]) || knobsPositions[index] == null;\n const handleId = setId(elementId, \"knob\");\n const indexedHandleId = setId(handleId, index);\n\n return (\n <div\n key={index}\n className={cx({\n [classes.handleContainer]: !!(!disabled && !isEmpty),\n [classes.handleContainerDisabled]: !!(disabled && !isEmpty),\n [classes.handleHiddenContainer]: isEmpty || readOnly,\n })}\n >\n <Tooltip\n prefixCls=\"rc-slider-tooltip\"\n overlay={formatTooltip?.(scaledKnobValue) || scaledKnobValue}\n visible={dragging}\n placement=\"top\"\n overlayClassName={classes.sliderTooltip}\n getTooltipContainer={() =>\n document.getElementById(indexedHandleId || \"\") as HTMLElement\n }\n >\n <div\n id={indexedHandleId}\n style={style}\n className={classes.handle}\n {...restProps}\n aria-label={`${label}-knob-${index}`}\n aria-valuenow={knobsPositionToScaledValue(\n knobValue,\n minPointValue,\n stepValue,\n )}\n aria-valuemin={minPointValue}\n aria-valuemax={maxPointValue}\n {...knobProps?.[index]}\n />\n </Tooltip>\n </div>\n );\n };\n\n const knobsValuesArray = knobsPositionsToKnobsValues(\n knobsPositions,\n stepValue,\n minPointValue,\n );\n\n const knobsValues = knobsValuesArray.map((v) =>\n Number(v.toFixed(markDigits)),\n );\n\n return (\n <HvFormElement\n className={cx(\n classes.root,\n {\n [classes.trackStandBy]:\n !readOnly && !disabled && !isSingle && !isDraggingTrack,\n [classes.trackDragging]:\n !readOnly && !disabled && !isSingle && isDraggingTrack,\n [classes.rootDisabled]: !!disabled,\n },\n className,\n )}\n id={id}\n name={name}\n status={statusArrayToFormStatus(validationStatus)}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onMouseDown={onMouseDownHandler}\n onMouseUp={onMouseUpHandler}\n onBlur={onBlurHandler}\n {...others}\n >\n {(hasLabel || !hideInput) && (\n <div\n className={cx(classes.labelContainer, {\n [classes.labelIncluded]: hasLabel,\n [classes.onlyInput]: !hasLabel,\n })}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={sliderInputId}\n label={label}\n />\n )}\n\n {!hideInput && (\n <HvSliderInput\n id={sliderInputId}\n label={label}\n values={knobsValues}\n onChange={onInputChangeHandler}\n status={validationStatus}\n disabled={disabled}\n readOnly={readOnly}\n markDigits={markDigits}\n inputProps={inputProps}\n />\n )}\n </div>\n )}\n\n <div className={cx(classes.sliderBase, classes.sliderContainer)}>\n <Slider\n ref={ref}\n range={!isSingle}\n handleRender={createKnob}\n className={cx(classes.sliderRoot, {\n [classes.rootRange]: !isSingle,\n })}\n min={0}\n max={divisionQuantity}\n step={1}\n marks={marks}\n dotStyle={disabled ? sliderStyles.dotDisabled : sliderStyles.dot}\n onChange={(singleValue) =>\n onChangeHandler(Array<number>().concat(singleValue))\n }\n onBeforeChange={(singleValue) =>\n onBeforeChangeHandler(Array<number>().concat(singleValue))\n }\n onAfterChange={(singleValue) =>\n onAfterChangeHandler(Array<number>().concat(singleValue))\n }\n value={\n knobsPositions.length === 0\n ? undefined\n : isSingle\n ? knobsPositions[0]\n : [...knobsPositions]\n }\n allowCross={false}\n disabled={disabled}\n count={rangesCount}\n railStyle={sliderStyles.rail}\n handleStyle={knobStyles.knobInner}\n trackStyle={trackStyles}\n draggableTrack={!readOnly && !isSingle}\n {...sliderProps}\n />\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["knobsValues","validationStates"],"mappings":";;;;;;;;;;;;;;;;AA2IO,MAAM,WAAW,WAAqC,CA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AAY;AAAA,YACZ,gBAAgB,CAAC,YAAY,CAAC;AAAA,YAC7B,GAAG;AAAA,UAAA;AAAA,QAAA,GAER;AAAA,QAEC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,MAAM,WAAW,OAAO;AAAA,YAC5B,WAAW,QAAQ;AAAA,YACnB,eAAa;AAAA,YAEZ,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
1
+ {"version":3,"file":"Slider.js","sources":["../../../src/Slider/Slider.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport Slider, { SliderProps, SliderRef } from \"rc-slider\";\nimport Tooltip from \"rc-tooltip\";\n\nimport { HvFormElement, HvFormStatus, HvLabel, HvWarningText } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvInputProps } from \"../Input\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { getElementById } from \"../utils/document\";\nimport { setId } from \"../utils/setId\";\nimport { sliderStyles, staticClasses, useClasses } from \"./Slider.styles\";\nimport { HvSliderInput } from \"./SliderInput/SliderInput\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\nimport {\n calculateStepValue,\n convertStatusToArray,\n createKnobStyles,\n createMark,\n createTrackStyles,\n ensureValuesConsistency,\n generateDefaultKnobProperties,\n isSingleSlider,\n knobsPositionsToKnobsValues,\n knobsPositionToScaledValue,\n knobsValuesToKnobsPositions,\n scaledValueToKnobsPositionValue,\n statusArrayToFormStatus,\n} from \"./utils\";\n\nexport { staticClasses as sliderClasses };\n\nexport type HvSliderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSliderProps\n extends HvBaseProps<HTMLDivElement, \"onChange\" | \"onBlur\"> {\n /** The slider name. */\n name?: string;\n /** The label of the slider. If not provided, an aria-label or aria-labelledby must be inputted via sliderProps. */\n label?: React.ReactNode;\n /** Indicates that the slider is disabled. */\n disabled?: boolean;\n /** Indicates that the slider is not editable. */\n readOnly?: boolean;\n /** Indicates that user slider is required on the form element. */\n required?: boolean;\n /** Error message to render when the value is required. */\n requiredMessage?: string;\n /** If `true` the input that controls the slider is hidden. */\n hideInput?: boolean;\n /** Attributes applied to the slider element. */\n sliderProps?: SliderProps;\n /**\n * The status of the slider element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus | HvFormStatus[];\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: React.ReactNode;\n /** The values array to apply to the component */\n values?: number[];\n /** The default values array to apply to the component */\n defaultValues?: (number | undefined)[];\n /**\n * The object used to set the knob properties,\n * for every item in the array a new knob will be created.\n */\n knobProperties?: HvKnobProperty[];\n /** The object used to set the mark properties individually. */\n markProperties?: HvMarkProperty[];\n /**\n * The function executed before a change will occur in the slider.\n * @deprecated It's always better to use onChange instead\n */\n onBeforeChange?: (value: number[]) => void;\n /** The function executed while a change is occurring in the slider. */\n onChange?: (value: number[]) => void;\n /**\n * The function executed after a change ocurred in the slider.\n * @deprecated It's always better to use onChange instead\n */\n onAfterChange?: (value: number[]) => void;\n /** The function executed after a blur ocurred in the slider. */\n onBlur?: (\n event: React.FocusEvent,\n knobsValues: number[],\n status?: HvFormStatus | HvFormStatus[],\n ) => void;\n /**\n * The separation in points between marks.\n * example: if 10 divisions and a markstep of 2 there will be 5 marks.\n */\n markStep?: number;\n /** How many subdivisions there are in the slider. */\n divisionQuantity?: number;\n /** The value of the first point in the slider from left to right. */\n minPointValue?: number;\n /** The value of the last point in the slider from left to right. */\n maxPointValue?: number;\n /** Error message to render when the value is higher than maxPointValue or lower than minPointValue. */\n outOfRangeMessage?: string;\n /** The max number of decimals if no format function is applied */\n markDigits?: number;\n /**\n * A formatting function used to add format to the marks in the track,\n * the function receives the mark text\n */\n formatMark?: (label: React.ReactNode) => React.ReactNode;\n /**\n * A formatting function used to add format to the tooltip in the track,\n * the function receives the mark text\n */\n formatTooltip?: (label: React.ReactNode) => React.ReactNode;\n /** If `true` the knobs can't have the same value, if `false` knobs can have the same value. */\n noOverlap?: boolean;\n /** Attributes applied to the input element. */\n inputProps?: HvInputProps[];\n /** Attributes applied to the knob element. */\n knobProps?: React.HTMLAttributes<HTMLDivElement>[];\n /** The classes object to be applied into the root object. */\n classes?: HvSliderClasses;\n}\n\n/**\n * Sliders reflect a range of values along a bar, from which users may select a single value. They are ideal for adjusting settings such as volume, brightness, or applying image filters.\n */\nexport const HvSlider = forwardRef<SliderRef, HvSliderProps>((props, ref) => {\n const {\n id,\n className,\n name,\n label,\n status,\n statusMessage,\n disabled,\n classes: classesProp,\n sliderProps,\n knobProps,\n inputProps,\n requiredMessage = \"The value is required\",\n outOfRangeMessage = \"The value is out of range\",\n noOverlap = true,\n hideInput = false,\n required = false,\n readOnly = false,\n markProperties = [],\n defaultValues = [undefined],\n values: valuesProp = [],\n knobProperties: knobPropertiesProp,\n \"aria-errormessage\": ariaErrorMessage,\n maxPointValue = 100,\n minPointValue = 0,\n divisionQuantity = 100,\n markStep = 20,\n markDigits = 0,\n formatMark,\n onChange,\n onBlur,\n onBeforeChange,\n onAfterChange,\n formatTooltip,\n ...others\n } = useDefaultProps(\"HvSlider\", props);\n const { classes, cx } = useClasses(classesProp);\n\n // Miscellaneous state\n const hasLabel = label != null;\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n const elementId = useUniqueId(id);\n\n const sliderInputId = setId(elementId, \"input\");\n\n const stepValue = useMemo(\n () => calculateStepValue(maxPointValue, minPointValue, divisionQuantity),\n [divisionQuantity, maxPointValue, minPointValue],\n );\n\n const inverseStepValue = 1 / stepValue;\n\n const marks = useMemo(\n () =>\n createMark(\n markProperties,\n markStep,\n divisionQuantity,\n minPointValue,\n maxPointValue,\n stepValue,\n markDigits,\n !!disabled,\n formatMark,\n ),\n [\n disabled,\n divisionQuantity,\n formatMark,\n markDigits,\n markProperties,\n markStep,\n minPointValue,\n maxPointValue,\n stepValue,\n ],\n );\n\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n // We always show an error when the value(s) are not between maxPointValue and minPointValue; and when required is true (set by user).\n status === undefined);\n\n const isSingle: boolean = useMemo(\n () => isSingleSlider(valuesProp, defaultValues),\n [defaultValues, valuesProp],\n );\n\n const value: number[] | undefined = useMemo(\n () =>\n valuesProp?.length > 0\n ? knobsValuesToKnobsPositions(\n valuesProp,\n inverseStepValue,\n minPointValue,\n )\n : undefined,\n [inverseStepValue, minPointValue, valuesProp],\n );\n\n const defaultKnobsPositions: number[] = useMemo(\n () =>\n knobsValuesToKnobsPositions(\n defaultValues,\n inverseStepValue,\n minPointValue,\n ),\n [defaultValues, inverseStepValue, minPointValue],\n );\n\n const [knobsPositions, setKnobsPositions] = useControlled(\n value,\n defaultKnobsPositions,\n );\n\n // Validation related state\n const { arrayStatus, arrayDefaultStatus } = useMemo(\n () => convertStatusToArray(knobsPositions.length, status),\n [knobsPositions.length, status],\n );\n\n const [validationStatus, setValidationState] = useControlled(\n arrayStatus,\n arrayDefaultStatus,\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n const [isDraggingTrack, setIsDraggingTrack] = useState(false);\n\n const knobProperties = generateDefaultKnobProperties(\n knobsPositions.length,\n disabled,\n knobPropertiesProp,\n );\n\n const rangesCount = knobProperties.length - 1;\n\n const trackStyles = createTrackStyles(knobProperties);\n\n const knobStyles = createKnobStyles(knobProperties);\n\n /**\n * Generates an object which posses the current value and position of the knobs.\n *\n * @param {Array} knobsCurrentPosition - An array containing the current positions of the knobs.\n * @returns {Object} - An object with the positions and values of the knobs.\n * @memberof HvSlider\n */\n const generateKnobsPositionAndValues = useCallback(\n (\n knobsCurrentPosition: number[],\n ): { knobsPosition: number[]; knobsValues: number[] } => {\n const newKnobsPosition: number[] = knobsCurrentPosition.slice();\n const knobsValues: number[] = [];\n\n let duplicatedValue: number | null = null;\n\n const findDuplicated: number[] = newKnobsPosition.filter(\n (item, index) => newKnobsPosition.indexOf(item) !== index,\n );\n\n if (noOverlap && findDuplicated.length > 0) {\n [duplicatedValue] = findDuplicated;\n }\n\n newKnobsPosition.forEach((position, index, array) => {\n const newArray: number[] = array;\n let newPosition: number = position;\n\n if (noOverlap && newPosition === duplicatedValue) {\n const previousValue = knobsPositions[index];\n if (previousValue !== newPosition) {\n newPosition += newPosition > previousValue ? -1 : 1;\n newArray[index] = newPosition;\n }\n }\n\n knobsValues[index] = knobsPositionToScaledValue(\n newPosition,\n minPointValue,\n stepValue,\n );\n }, this);\n\n return {\n knobsPosition: newKnobsPosition,\n knobsValues,\n };\n },\n [knobsPositions, minPointValue, noOverlap, stepValue],\n );\n\n const performValidation = useCallback(() => {\n let invalid = false;\n let requiredMsg = false;\n\n const mappedValues =\n generateKnobsPositionAndValues(knobsPositions).knobsValues;\n\n const newValidationState = mappedValues.map((knobValue) => {\n if (required && (knobValue == null || Number.isNaN(knobValue))) {\n invalid = true;\n requiredMsg = true;\n return validationStates.invalid;\n }\n\n if (knobValue < minPointValue || knobValue > maxPointValue) {\n invalid = true;\n return validationStates.invalid;\n }\n\n return validationStates.valid;\n });\n\n setValidationState([...newValidationState]);\n\n if (invalid) {\n setValidationMessage(requiredMsg ? requiredMessage : outOfRangeMessage);\n return;\n }\n\n setValidationMessage(\"\");\n }, [\n generateKnobsPositionAndValues,\n knobsPositions,\n maxPointValue,\n minPointValue,\n outOfRangeMessage,\n required,\n requiredMessage,\n setValidationMessage,\n setValidationState,\n ]);\n\n useEffect(() => {\n const stepVl = calculateStepValue(\n maxPointValue,\n minPointValue,\n divisionQuantity,\n );\n\n const inverseStepVl = 1 / stepVl;\n\n if (valuesProp?.length > 0) {\n setKnobsPositions(\n knobsValuesToKnobsPositions(\n valuesProp.length > 0 ? valuesProp : defaultValues,\n inverseStepVl,\n minPointValue,\n ),\n );\n }\n }, [\n defaultValues,\n divisionQuantity,\n maxPointValue,\n minPointValue,\n setKnobsPositions,\n valuesProp,\n ]);\n\n useEffect(() => {\n if (!isDirty.current) {\n // Skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [knobsPositions, requiredMessage, performValidation]);\n\n const onMouseDownHandler = (event: React.MouseEvent<HTMLDivElement>) => {\n if ((event.target as HTMLDivElement).className.includes(\"track\")) {\n setIsDraggingTrack(true);\n }\n };\n\n const onMouseUpHandler = () => {\n setIsDraggingTrack(false);\n };\n\n const onBlurHandler = (event: React.FocusEvent) => {\n const knobs = generateKnobsPositionAndValues(knobsPositions);\n\n performValidation();\n\n onBlur?.(event, knobs.knobsValues, status);\n };\n\n /**\n * Function executed while the knobs changes.\n *\n * executes the callback provided by the user with the values and position of the knobs,\n * also lock the value of the knob in case one is fixed.\n */\n const onChangeHandler = (knobsPosition: number[]) => {\n isDirty.current = true;\n\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n knobProperties.forEach((knobProperty, index) => {\n if (knobProperty.fixed) {\n knobs.knobsPosition[index] = scaledValueToKnobsPositionValue(\n defaultValues[index],\n minPointValue,\n inverseStepValue,\n );\n }\n });\n\n if (disabled || readOnly) return;\n onChange?.(knobs.knobsValues);\n\n setKnobsPositions(knobs.knobsPosition);\n };\n\n const onInputChangeHandler = (inputValues: number[], index: number) => {\n let newKnobPositions = knobsValuesToKnobsPositions(\n inputValues,\n inverseStepValue,\n minPointValue,\n );\n\n newKnobPositions = ensureValuesConsistency(newKnobPositions, index);\n\n onChangeHandler(newKnobPositions);\n };\n\n /**\n * Function executed before a change.\n *\n * executes the callback provided by the user with the values and position of the knobs\n */\n const onBeforeChangeHandler = (knobsPosition: number[]) => {\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n onBeforeChange?.(knobs.knobsValues);\n };\n\n /**\n * Function executed after a change.\n *\n * executes the callback provided by the user with the values and position of the knobs\n */\n const onAfterChangeHandler = (knobsPosition: number[]) => {\n const knobs = generateKnobsPositionAndValues(knobsPosition);\n\n onAfterChange?.(knobs.knobsValues);\n };\n\n /**\n * Function used to create a custom knob for the slider.\n *\n * TODO: This should be isolated because is creating a sub component,\n * but there were some problems regarding the underlying component losing\n * references of the handlers disabling the focus.\n */\n const createKnob: SliderProps[\"handleRender\"] = (knobNode, params) => {\n const { value: knobValue, dragging, index } = params;\n const { style = {}, ...restProps } = knobNode.props;\n const scaledKnobValue = knobsPositionToScaledValue(\n knobValue,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n if (dragging) {\n style.backgroundColor = knobProperties[index]?.dragColor;\n } else {\n style.backgroundColor = knobProperties[index]?.color;\n }\n\n const isEmpty =\n Number.isNaN(knobsPositions[index]) || knobsPositions[index] == null;\n const handleId = setId(elementId, \"knob\");\n const indexedHandleId = setId(handleId, index);\n\n return (\n <div\n key={index}\n className={cx({\n [classes.handleContainer]: !!(!disabled && !isEmpty),\n [classes.handleContainerDisabled]: !!(disabled && !isEmpty),\n [classes.handleHiddenContainer]: isEmpty || readOnly,\n })}\n >\n <Tooltip\n prefixCls=\"rc-slider-tooltip\"\n overlay={formatTooltip?.(scaledKnobValue) || scaledKnobValue}\n visible={dragging}\n placement=\"top\"\n overlayClassName={classes.sliderTooltip}\n getTooltipContainer={() => getElementById(indexedHandleId)!}\n >\n <div\n id={indexedHandleId}\n style={style}\n className={classes.handle}\n {...restProps}\n aria-label={`${label}-knob-${index}`}\n aria-valuenow={knobsPositionToScaledValue(\n knobValue,\n minPointValue,\n stepValue,\n )}\n aria-valuemin={minPointValue}\n aria-valuemax={maxPointValue}\n {...knobProps?.[index]}\n />\n </Tooltip>\n </div>\n );\n };\n\n const knobsValuesArray = knobsPositionsToKnobsValues(\n knobsPositions,\n stepValue,\n minPointValue,\n );\n\n const knobsValues = knobsValuesArray.map((v) =>\n Number(v.toFixed(markDigits)),\n );\n\n return (\n <HvFormElement\n className={cx(\n classes.root,\n {\n [classes.trackStandBy]:\n !readOnly && !disabled && !isSingle && !isDraggingTrack,\n [classes.trackDragging]:\n !readOnly && !disabled && !isSingle && isDraggingTrack,\n [classes.rootDisabled]: !!disabled,\n },\n className,\n )}\n id={id}\n name={name}\n status={statusArrayToFormStatus(validationStatus)}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onMouseDown={onMouseDownHandler}\n onMouseUp={onMouseUpHandler}\n onBlur={onBlurHandler}\n {...others}\n >\n {(hasLabel || !hideInput) && (\n <div\n className={cx(classes.labelContainer, {\n [classes.labelIncluded]: hasLabel,\n [classes.onlyInput]: !hasLabel,\n })}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={sliderInputId}\n label={label}\n />\n )}\n\n {!hideInput && (\n <HvSliderInput\n id={sliderInputId}\n label={label}\n values={knobsValues}\n onChange={onInputChangeHandler}\n status={validationStatus}\n disabled={disabled}\n readOnly={readOnly}\n markDigits={markDigits}\n inputProps={inputProps}\n />\n )}\n </div>\n )}\n\n <div className={cx(classes.sliderBase, classes.sliderContainer)}>\n <Slider\n ref={ref}\n range={!isSingle}\n handleRender={createKnob}\n className={cx(classes.sliderRoot, {\n [classes.rootRange]: !isSingle,\n })}\n min={0}\n max={divisionQuantity}\n step={1}\n marks={marks}\n dotStyle={disabled ? sliderStyles.dotDisabled : sliderStyles.dot}\n onChange={(singleValue) =>\n onChangeHandler(Array<number>().concat(singleValue))\n }\n onBeforeChange={(singleValue) =>\n onBeforeChangeHandler(Array<number>().concat(singleValue))\n }\n onAfterChange={(singleValue) =>\n onAfterChangeHandler(Array<number>().concat(singleValue))\n }\n value={\n knobsPositions.length === 0\n ? undefined\n : isSingle\n ? knobsPositions[0]\n : [...knobsPositions]\n }\n allowCross={false}\n disabled={disabled}\n count={rangesCount}\n railStyle={sliderStyles.rail}\n handleStyle={knobStyles.knobInner}\n trackStyle={trackStyles}\n draggableTrack={!readOnly && !isSingle}\n {...sliderProps}\n />\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["knobsValues","validationStates"],"mappings":";;;;;;;;;;;;;;;;;AA4IO,MAAM,WAAW,WAAqC,CAAC,OAAO,QAAQ;AACrE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,iBAAiB,CAAC;AAAA,IAClB,gBAAgB,CAAC,MAAS;AAAA,IAC1B,QAAQ,aAAa,CAAC;AAAA,IACtB,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,WAAW;AAAA,IACX,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,YAAY,KAAK;AACrC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAG9C,QAAM,WAAW,SAAS;AAGpB,QAAA,UAAU,OAAO,KAAK;AAEtB,QAAA,YAAY,YAAY,EAAE;AAE1B,QAAA,gBAAgB,MAAM,WAAW,OAAO;AAE9C,QAAM,YAAY;AAAA,IAChB,MAAM,mBAAmB,eAAe,eAAe,gBAAgB;AAAA,IACvE,CAAC,kBAAkB,eAAe,aAAa;AAAA,EAAA;AAGjD,QAAM,mBAAmB,IAAI;AA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B,QAAgB,OAAO,WAAW,CAAC;AAAA,YAE3D,eAAe,CAAC,gBACd,qBAAqB,QAAgB,OAAO,WAAW,CAAC;AAAA,YAE1D,OACE,eAAe,WAAW,IACtB,SACA,WACE,eAAe,CAAC,IAChB,CAAC,GAAG,cAAc;AAAA,YAE1B,YAAY;AAAA,YACZ;AAAA,YACA,OAAO;AAAA,YACP,WAAW,aAAa;AAAA,YACxB,aAAa,WAAW;AAAA,YACxB,YAAY;AAAA,YACZ,gBAAgB,CAAC,YAAY,CAAC;AAAA,YAC7B,GAAG;AAAA,UAAA;AAAA,QAAA,GAER;AAAA,QAEC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,MAAM,WAAW,OAAO;AAAA,YAC5B,WAAW,QAAQ;AAAA,YACnB,eAAa;AAAA,YAEZ,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { forwardRef } from "react";
2
+ import { forwardRef, useState, useEffect } from "react";
3
3
  import Fade from "@mui/material/Fade";
4
4
  import Tooltip from "@mui/material/Tooltip";
5
5
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
@@ -24,11 +24,17 @@ const HvTooltip = forwardRef((props, ref) => {
24
24
  } = useDefaultProps("HvTooltip", props);
25
25
  const { rootId } = useTheme();
26
26
  const { classes } = useClasses(classesProp);
27
+ const [container, setContainer] = useState(
28
+ () => getElementById(containerId ?? rootId)
29
+ );
30
+ useEffect(() => {
31
+ setContainer(getElementById(containerId ?? rootId));
32
+ }, [containerId, rootId]);
27
33
  return /* @__PURE__ */ jsx(
28
34
  Tooltip,
29
35
  {
30
36
  ref,
31
- open: open ?? void 0,
37
+ open,
32
38
  enterDelay,
33
39
  placement,
34
40
  TransitionComponent,
@@ -39,9 +45,7 @@ const HvTooltip = forwardRef((props, ref) => {
39
45
  popper: classes.popper
40
46
  },
41
47
  title,
42
- PopperProps: {
43
- container: getElementById(containerId || rootId)
44
- },
48
+ PopperProps: { container },
45
49
  ...others,
46
50
  children
47
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../src/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport Fade from \"@mui/material/Fade\";\nimport Tooltip, {\n TooltipProps as MuiTooltipProps,\n} from \"@mui/material/Tooltip\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { getElementById } from \"../utils/document\";\nimport { staticClasses, useClasses } from \"./Tooltip.styles\";\n\nexport { staticClasses as tooltipClasses };\n\nexport type HvTooltipClasses = ExtractNames<typeof useClasses>;\nexport type HvTooltipPlacementType = MuiTooltipProps[\"placement\"];\n\nexport interface HvTooltipProps extends Omit<MuiTooltipProps, \"classes\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvTooltipClasses;\n /**\n * If true, the tooltip is shown.\n */\n open?: boolean;\n /**\n * Tooltip placement.\n */\n placement?: HvTooltipPlacementType;\n /**\n * The number of milliseconds to wait before showing the tooltip.\n * This property won't impact the enter touch delay (enterTouchDelay).\n */\n enterDelay?: number;\n /** @inheritdoc */\n title: MuiTooltipProps[\"title\"];\n /** @inheritdoc */\n TransitionComponent?: MuiTooltipProps[\"TransitionComponent\"];\n /** @inheritdoc */\n TransitionProps?: MuiTooltipProps[\"TransitionProps\"];\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle?: boolean;\n /**\n * Node to apply the tooltip.\n */\n children: React.ReactElement;\n /**\n * Id attribute value of an HTML Element to have the tooltip appended to it.\n */\n containerId?: string;\n}\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n * Accessibility-wise, the tooltip automatically labels the `children` content.\n *\n * If you are looking to wrap an icon only button with a tooltip, take a look at the `HvIconButton` component\n * which offers you thus behavior out of the box.\n */\nexport const HvTooltip = forwardRef((props: HvTooltipProps, ref) => {\n const {\n className,\n classes: classesProp,\n open,\n enterDelay = 300,\n placement = \"top\",\n useSingle = true,\n children,\n title,\n TransitionComponent = Fade,\n TransitionProps = { timeout: 400, placement: \"top\" },\n containerId,\n ...others\n } = useDefaultProps(\"HvTooltip\", props);\n\n const { rootId } = useTheme();\n const { classes } = useClasses(classesProp);\n\n return (\n <Tooltip\n ref={ref}\n open={open ?? undefined}\n enterDelay={enterDelay}\n placement={placement}\n TransitionComponent={TransitionComponent}\n TransitionProps={TransitionProps}\n className={className}\n classes={{\n tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,\n popper: classes.popper,\n }}\n title={title}\n PopperProps={{\n container: getElementById(containerId || rootId),\n }}\n {...others}\n >\n {children}\n </Tooltip>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;AAkEO,MAAM,YAAY,WAAW,CAAC,OAAuB,QAAQ;AAC5D,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB,kBAAkB,EAAE,SAAS,KAAK,WAAW,MAAM;AAAA,IACnD;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,aAAa,KAAK;AAEhC,QAAA,EAAE,WAAW;AACnB,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAGxC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,MAAM,QAAQ;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,QACP,SAAS,YAAY,QAAQ,UAAU,QAAQ;AAAA,QAC/C,QAAQ,QAAQ;AAAA,MAClB;AAAA,MACA;AAAA,MACA,aAAa;AAAA,QACX,WAAW,eAAe,eAAe,MAAM;AAAA,MACjD;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../src/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, useEffect, useState } from \"react\";\nimport Fade from \"@mui/material/Fade\";\nimport Tooltip, {\n TooltipProps as MuiTooltipProps,\n} from \"@mui/material/Tooltip\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { getElementById } from \"../utils/document\";\nimport { staticClasses, useClasses } from \"./Tooltip.styles\";\n\nexport { staticClasses as tooltipClasses };\n\nexport type HvTooltipClasses = ExtractNames<typeof useClasses>;\nexport type HvTooltipPlacementType = MuiTooltipProps[\"placement\"];\n\nexport interface HvTooltipProps extends Omit<MuiTooltipProps, \"classes\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvTooltipClasses;\n /**\n * If true, the tooltip is shown.\n */\n open?: boolean;\n /**\n * Tooltip placement.\n */\n placement?: HvTooltipPlacementType;\n /**\n * The number of milliseconds to wait before showing the tooltip.\n * This property won't impact the enter touch delay (enterTouchDelay).\n */\n enterDelay?: number;\n /** @inheritdoc */\n title: MuiTooltipProps[\"title\"];\n /** @inheritdoc */\n TransitionComponent?: MuiTooltipProps[\"TransitionComponent\"];\n /** @inheritdoc */\n TransitionProps?: MuiTooltipProps[\"TransitionProps\"];\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle?: boolean;\n /**\n * Node to apply the tooltip.\n */\n children: React.ReactElement;\n /**\n * Id attribute value of an HTML Element to have the tooltip appended to it.\n */\n containerId?: string;\n}\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n * Accessibility-wise, the tooltip automatically labels the `children` content.\n *\n * If you are looking to wrap an icon only button with a tooltip, take a look at the `HvIconButton` component\n * which offers you thus behavior out of the box.\n */\nexport const HvTooltip = forwardRef((props: HvTooltipProps, ref) => {\n const {\n className,\n classes: classesProp,\n open,\n enterDelay = 300,\n placement = \"top\",\n useSingle = true,\n children,\n title,\n TransitionComponent = Fade,\n TransitionProps = { timeout: 400, placement: \"top\" },\n containerId,\n ...others\n } = useDefaultProps(\"HvTooltip\", props);\n\n const { rootId } = useTheme();\n const { classes } = useClasses(classesProp);\n const [container, setContainer] = useState(() =>\n getElementById(containerId ?? rootId),\n );\n\n // force extra render to get the correct container DOM element\n useEffect(() => {\n setContainer(getElementById(containerId ?? rootId));\n }, [containerId, rootId]);\n\n return (\n <Tooltip\n ref={ref}\n open={open}\n enterDelay={enterDelay}\n placement={placement}\n TransitionComponent={TransitionComponent}\n TransitionProps={TransitionProps}\n className={className}\n classes={{\n tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,\n popper: classes.popper,\n }}\n title={title}\n PopperProps={{ container }}\n {...others}\n >\n {children}\n </Tooltip>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;AAkEO,MAAM,YAAY,WAAW,CAAC,OAAuB,QAAQ;AAC5D,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB,kBAAkB,EAAE,SAAS,KAAK,WAAW,MAAM;AAAA,IACnD;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,aAAa,KAAK;AAEhC,QAAA,EAAE,WAAW;AACnB,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AACpC,QAAA,CAAC,WAAW,YAAY,IAAI;AAAA,IAAS,MACzC,eAAe,eAAe,MAAM;AAAA,EAAA;AAItC,YAAU,MAAM;AACD,iBAAA,eAAe,eAAe,MAAM,CAAC;AAAA,EAAA,GACjD,CAAC,aAAa,MAAM,CAAC;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,QACP,SAAS,YAAY,QAAQ,UAAU,QAAQ;AAAA,QAC/C,QAAQ,QAAQ;AAAA,MAClB;AAAA,MACA;AAAA,MACA,aAAa,EAAE,UAAU;AAAA,MACxB,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport {\n CacheProvider,\n ClassNames,\n css as cssReact,\n Global,\n} from \"@emotion/react\";\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTheme } from \"../types/theme\";\nimport { getElementById } from \"../utils/document\";\nimport { processThemes } from \"../utils/theme\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n HvThemeProvider,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If `emotionCache` is passed, this is value is ignored.\n *\n * @default \"hv\"\n */\n classNameKey?: string;\n /**\n * The emotion cache instance to use. If no value is provided, the default cache is used.\n */\n emotionCache?: EmotionCache;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n emotionCache: emotionCacheProp,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const generatedId = useUniqueId();\n const scopedRootId = `${scopedRootPrefix}-${generatedId}`;\n\n // Themes\n const themesList: (HvTheme | HvThemeStructure)[] = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(() => {\n if (emotionCacheProp) return emotionCacheProp;\n // reuse the default shared cache if `classNameKey` is the same\n if (classNameKey === defaultCacheKey) return defaultEmotionCache;\n\n return createCache({ key: classNameKey, prepend: true });\n }, [classNameKey, emotionCacheProp]);\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${\n cssBaseline === \"global\" && {\n [`@layer hv-uikit-baseline`]: {\n ...CssBaseline,\n },\n }\n }\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n }),\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n : undefined\n }\n >\n {children}\n </div>\n ) : (\n children\n );\n }}\n </ClassNames>\n </HvThemeProvider>\n </CacheProvider>\n );\n};\n"],"names":["cssReact","css"],"mappings":";;;;;;;;;;AAqFA,MAAM,mBAAmB;AAKlB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AACjB,MAAuB;AACrB,QAAM,cAAc;AACpB,QAAM,eAAe,GAAG,gBAAgB,IAAI,WAAW;AAGjD,QAAA,aAA6C,cAAc,MAAM;AAKjE,QAAA,eAAe,QAAQ,MAAM;AAC7B,QAAA;AAAyB,aAAA;AAE7B,QAAI,iBAAiB;AAAwB,aAAA;AAE7C,WAAO,YAAY,EAAE,KAAK,cAAc,SAAS,MAAM;AAAA,EAAA,GACtD,CAAC,cAAc,gBAAgB,CAAC;AAGjC,SAAA,qBAAC,eAAc,EAAA,OAAO,cACpB,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQA;AAAAA,YAEJ,gBAAgB,YAAY;AAAA,UAC1B,CAAC,0BAA0B,GAAG;AAAA,YAC5B,GAAG;AAAA,UACL;AAAA,QAAA,CAEJ;AAAA,YACE,cAAc,UAAU,CAAC;AAAA;AAAA,MAAA;AAAA,IAE/B;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,OAAO,SAAS,WAAW,CAAC,EAAE;AAAA,QAC9B;AAAA,QACA,WAAW,aAAa,OAAO,KAAK,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,CAAC;AAAA,QACjE,aACE,aAAa,WAAW,iBAAiB,eAAe;AAAA,QAG1D,UAAC,oBAAA,YAAA,EACE,UAAC,CAAA,EAAE,KAAAC,WAAU;AACZ,cAAI,gBAAgB,UAAU;AACtB,kBAAA,cAAc,eAAe,aAAa;AAEhD,gBAAI,aAAa;AACf,0BAAY,UAAU;AAAA,gBACpBA,KAAI;AAAA,kBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,oBACpC,GAAG;AAAA,kBACL;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,YAEL;AAAA,UACF;AAEA,kBAAQ,aAAa,YAAY,gBAAgB,aAC/C,CAAC,gBACD;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI;AAAA,cACJ,WACE,gBAAgB,WACZA,KAAI;AAAA,gBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,kBACpC,GAAG;AAAA,gBACL;AAAA,cACD,CAAA,IACD;AAAA,cAGL;AAAA,YAAA;AAAA,UAGH,IAAA;AAAA,QAAA,GAGN;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport {\n CacheProvider,\n ClassNames,\n css as cssReact,\n Global,\n} from \"@emotion/react\";\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTheme } from \"../types/theme\";\nimport { getElementById } from \"../utils/document\";\nimport { processThemes } from \"../utils/theme\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n HvThemeProvider,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If `emotionCache` is passed, this is value is ignored.\n *\n * @default \"hv\"\n */\n classNameKey?: string;\n /**\n * The emotion cache instance to use. If no value is provided, the default cache is used.\n */\n emotionCache?: EmotionCache;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n emotionCache: emotionCacheProp,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const generatedId = useUniqueId();\n const scopedRootId = `${scopedRootPrefix}-${generatedId}`;\n\n // Themes\n const themesList = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(() => {\n if (emotionCacheProp) return emotionCacheProp;\n // reuse the default shared cache if `classNameKey` is the same\n if (classNameKey === defaultCacheKey) return defaultEmotionCache;\n\n return createCache({ key: classNameKey, prepend: true });\n }, [classNameKey, emotionCacheProp]);\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${\n cssBaseline === \"global\" && {\n [`@layer hv-uikit-baseline`]: {\n ...CssBaseline,\n },\n }\n }\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n }),\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n : undefined\n }\n >\n {children}\n </div>\n ) : (\n children\n );\n }}\n </ClassNames>\n </HvThemeProvider>\n </CacheProvider>\n );\n};\n"],"names":["cssReact","css"],"mappings":";;;;;;;;;;AAqFA,MAAM,mBAAmB;AAKlB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AACjB,MAAuB;AACrB,QAAM,cAAc;AACpB,QAAM,eAAe,GAAG,gBAAgB,IAAI,WAAW;AAGjD,QAAA,aAAa,cAAc,MAAM;AAKjC,QAAA,eAAe,QAAQ,MAAM;AAC7B,QAAA;AAAyB,aAAA;AAE7B,QAAI,iBAAiB;AAAwB,aAAA;AAE7C,WAAO,YAAY,EAAE,KAAK,cAAc,SAAS,MAAM;AAAA,EAAA,GACtD,CAAC,cAAc,gBAAgB,CAAC;AAGjC,SAAA,qBAAC,eAAc,EAAA,OAAO,cACpB,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQA;AAAAA,YAEJ,gBAAgB,YAAY;AAAA,UAC1B,CAAC,0BAA0B,GAAG;AAAA,YAC5B,GAAG;AAAA,UACL;AAAA,QAAA,CAEJ;AAAA,YACE,cAAc,UAAU,CAAC;AAAA;AAAA,MAAA;AAAA,IAE/B;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,OAAO,SAAS,WAAW,CAAC,EAAE;AAAA,QAC9B;AAAA,QACA,WAAW,aAAa,OAAO,KAAK,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,CAAC;AAAA,QACjE,aACE,aAAa,WAAW,iBAAiB,eAAe;AAAA,QAG1D,UAAC,oBAAA,YAAA,EACE,UAAC,CAAA,EAAE,KAAAC,WAAU;AACZ,cAAI,gBAAgB,UAAU;AACtB,kBAAA,cAAc,eAAe,aAAa;AAEhD,gBAAI,aAAa;AACf,0BAAY,UAAU;AAAA,gBACpBA,KAAI;AAAA,kBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,oBACpC,GAAG;AAAA,kBACL;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,YAEL;AAAA,UACF;AAEA,kBAAQ,aAAa,YAAY,gBAAgB,aAC/C,CAAC,gBACD;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI;AAAA,cACJ,WACE,gBAAgB,WACZA,KAAI;AAAA,gBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,kBACpC,GAAG;AAAA,gBACL;AAAA,cACD,CAAA,IACD;AAAA,cAGL;AAAA,YAAA;AAAA,UAGH,IAAA;AAAA,QAAA,GAGN;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -8,41 +8,34 @@ import { setElementAttrs } from "../utils/theme.js";
8
8
  const HvThemeProvider = ({
9
9
  children,
10
10
  themes: themesList,
11
- theme,
11
+ theme: themeProp,
12
12
  emotionCache,
13
- colorMode,
13
+ colorMode: colorModeProp,
14
14
  themeRootId: rootId
15
15
  }) => {
16
- const initTheme = parseTheme(themesList, theme, colorMode);
17
- const [parsedTheme, setParsedTheme] = useState(initTheme);
18
- const [activeTheme, setActiveTheme] = useState(parsedTheme.theme);
19
- const [selectedTheme, setSelectedTheme] = useState(parsedTheme.selectedTheme);
20
- const [selectedMode, setThemeMode] = useState(parsedTheme.selectedMode);
21
- const [colorModes, setColorModes] = useState(parsedTheme.colorModes);
22
- const [themes, setThemes] = useState(themesList.map((t) => t.name));
16
+ const [theme, setTheme] = useState(themeProp);
17
+ const [colorMode, setColorMode] = useState(colorModeProp);
18
+ const {
19
+ theme: activeTheme,
20
+ selectedTheme,
21
+ selectedMode,
22
+ colorModes,
23
+ colorScheme
24
+ } = parseTheme(themesList, theme, colorMode);
25
+ const themes = themesList.map((t) => t.name);
23
26
  useEffect(() => {
24
- const pTheme = parseTheme(themesList, theme, colorMode);
25
- setThemes(themesList.map((t) => t.name));
26
- setParsedTheme(pTheme);
27
- }, [themesList, theme, colorMode]);
27
+ setTheme(themeProp);
28
+ setColorMode(colorModeProp);
29
+ }, [colorModeProp, themeProp]);
28
30
  useEffect(() => {
29
- setActiveTheme(parsedTheme.theme);
30
- setSelectedTheme(parsedTheme.selectedTheme);
31
- setThemeMode(parsedTheme.selectedMode);
32
- setColorModes(parsedTheme.colorModes);
33
- setElementAttrs(
34
- parsedTheme.selectedTheme,
35
- parsedTheme.selectedMode,
36
- parsedTheme.colorScheme,
37
- rootId
38
- );
39
- }, [parsedTheme, rootId]);
31
+ setElementAttrs(selectedTheme, selectedMode, colorScheme, rootId);
32
+ }, [colorScheme, rootId, selectedMode, selectedTheme]);
40
33
  const changeTheme = useCallback(
41
34
  (newTheme = selectedTheme, newMode = selectedMode) => {
42
- const pTheme = parseTheme(themesList, newTheme, newMode);
43
- setParsedTheme(pTheme);
35
+ setTheme(newTheme);
36
+ setColorMode(newMode);
44
37
  },
45
- [selectedMode, selectedTheme, themesList]
38
+ [selectedMode, selectedTheme]
46
39
  );
47
40
  const value = useMemo(
48
41
  () => ({
@@ -64,25 +57,25 @@ const HvThemeProvider = ({
64
57
  rootId
65
58
  ]
66
59
  );
67
- const MuiTheme = createTheme({
68
- components: {
69
- MuiButtonBase: {
70
- defaultProps: {
71
- disableRipple: true
60
+ const muiTheme = useMemo(() => {
61
+ return createTheme({
62
+ components: {
63
+ MuiButtonBase: {
64
+ defaultProps: {
65
+ disableRipple: true
66
+ }
72
67
  }
68
+ },
69
+ breakpoints: {
70
+ ...activeTheme.breakpoints
73
71
  }
74
- },
75
- breakpoints: {
76
- values: {
77
- ...activeTheme.breakpoints.values
78
- }
79
- }
80
- });
72
+ });
73
+ }, [activeTheme.breakpoints]);
81
74
  const emotionCacheValue = useMemo(
82
75
  () => ({ cache: emotionCache }),
83
76
  [emotionCache]
84
77
  );
85
- return /* @__PURE__ */ jsx(ThemeProvider, { theme: MuiTheme, children: /* @__PURE__ */ jsx(HvThemeContext.Provider, { value, children: /* @__PURE__ */ jsx(EmotionContext.Provider, { value: emotionCacheValue, children }) }) });
78
+ return /* @__PURE__ */ jsx(ThemeProvider, { theme: muiTheme, children: /* @__PURE__ */ jsx(HvThemeContext.Provider, { value, children: /* @__PURE__ */ jsx(EmotionContext.Provider, { value: emotionCacheValue, children }) }) });
86
79
  };
87
80
  export {
88
81
  EmotionContext2 as EmotionContext,
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","sources":["../../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { EmotionCache } from \"@emotion/cache\";\nimport {\n createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n EmotionContext,\n HvThemeContext,\n type HvThemeContextValue,\n} from \"@hitachivantara/uikit-react-shared\";\nimport { HvThemeStructure, parseTheme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTheme } from \"../types/theme\";\nimport { setElementAttrs } from \"../utils/theme\";\n\nexport { HvThemeContext };\nexport type { HvThemeContextValue };\n\nexport { defaultCacheKey, defaultEmotionCache, EmotionContext };\n\ninterface HvThemeProviderProps {\n children: React.ReactNode;\n themes: (HvTheme | HvThemeStructure)[];\n theme: string;\n emotionCache: EmotionCache;\n colorMode: string;\n themeRootId?: string;\n}\n\nexport const HvThemeProvider = ({\n children,\n themes: themesList,\n theme,\n emotionCache,\n colorMode,\n themeRootId: rootId,\n}: HvThemeProviderProps) => {\n const initTheme = parseTheme(themesList, theme, colorMode);\n\n const [parsedTheme, setParsedTheme] = useState(initTheme);\n const [activeTheme, setActiveTheme] = useState(parsedTheme.theme);\n const [selectedTheme, setSelectedTheme] = useState(parsedTheme.selectedTheme);\n const [selectedMode, setThemeMode] = useState(parsedTheme.selectedMode);\n const [colorModes, setColorModes] = useState(parsedTheme.colorModes);\n const [themes, setThemes] = useState(themesList.map((t) => t.name));\n\n useEffect(() => {\n const pTheme = parseTheme(themesList, theme, colorMode);\n setThemes(themesList.map((t) => t.name));\n setParsedTheme(pTheme);\n }, [themesList, theme, colorMode]);\n\n useEffect(() => {\n setActiveTheme(parsedTheme.theme);\n setSelectedTheme(parsedTheme.selectedTheme);\n setThemeMode(parsedTheme.selectedMode);\n setColorModes(parsedTheme.colorModes);\n\n setElementAttrs(\n parsedTheme.selectedTheme,\n parsedTheme.selectedMode,\n parsedTheme.colorScheme,\n rootId,\n );\n }, [parsedTheme, rootId]);\n\n const changeTheme = useCallback(\n (newTheme = selectedTheme, newMode = selectedMode) => {\n const pTheme = parseTheme(themesList, newTheme, newMode);\n setParsedTheme(pTheme);\n },\n [selectedMode, selectedTheme, themesList],\n );\n\n const value = useMemo<HvThemeContextValue>(\n () => ({\n themes,\n colorModes,\n activeTheme: activeTheme as HvTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n }),\n [\n themes,\n colorModes,\n activeTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n ],\n );\n\n const MuiTheme = createTheme({\n components: {\n MuiButtonBase: {\n defaultProps: {\n disableRipple: true,\n },\n },\n },\n breakpoints: {\n values: {\n ...activeTheme.breakpoints.values,\n },\n },\n });\n\n const emotionCacheValue = useMemo(\n () => ({ cache: emotionCache }),\n [emotionCache],\n );\n\n return (\n <MuiThemeProvider theme={MuiTheme}>\n <HvThemeContext.Provider value={value}>\n <EmotionContext.Provider value={emotionCacheValue}>\n {children}\n </EmotionContext.Provider>\n </HvThemeContext.Provider>\n </MuiThemeProvider>\n );\n};\n"],"names":["MuiThemeProvider"],"mappings":";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A,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,WAAW,YAAY;AAAA,IAC3B,YAAY;AAAA,MACV,eAAe;AAAA,QACb,cAAc;AAAA,UACZ,eAAe;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACX,QAAQ;AAAA,QACN,GAAG,YAAY,YAAY;AAAA,MAC7B;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,oBAAoB;AAAA,IACxB,OAAO,EAAE,OAAO;IAChB,CAAC,YAAY;AAAA,EAAA;AAGf,6BACGA,eAAiB,EAAA,OAAO,UACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OAAO,mBAC7B,SACH,CAAA,GACF,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"ThemeProvider.js","sources":["../../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { EmotionCache } from \"@emotion/cache\";\nimport {\n createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n EmotionContext,\n HvThemeContext,\n type HvThemeContextValue,\n} from \"@hitachivantara/uikit-react-shared\";\nimport { HvThemeStructure, parseTheme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTheme } from \"../types/theme\";\nimport { setElementAttrs } from \"../utils/theme\";\n\nexport { HvThemeContext };\nexport type { HvThemeContextValue };\n\nexport { defaultCacheKey, defaultEmotionCache, EmotionContext };\n\ninterface HvThemeProviderProps {\n children: React.ReactNode;\n themes: (HvTheme | HvThemeStructure)[];\n theme: string;\n emotionCache: EmotionCache;\n colorMode: string;\n themeRootId?: string;\n}\n\nexport const HvThemeProvider = ({\n children,\n themes: themesList,\n theme: themeProp,\n emotionCache,\n colorMode: colorModeProp,\n themeRootId: rootId,\n}: HvThemeProviderProps) => {\n const [theme, setTheme] = useState(themeProp);\n const [colorMode, setColorMode] = useState(colorModeProp);\n\n const {\n theme: activeTheme,\n selectedTheme,\n selectedMode,\n colorModes,\n colorScheme,\n } = parseTheme(themesList, theme, colorMode);\n\n const themes = themesList.map((t) => t.name);\n\n // review in v6 so that theme/colorMode isn't both controlled & uncontrolled\n useEffect(() => {\n setTheme(themeProp);\n setColorMode(colorModeProp);\n }, [colorModeProp, themeProp]);\n\n useEffect(() => {\n setElementAttrs(selectedTheme, selectedMode, colorScheme, rootId);\n }, [colorScheme, rootId, selectedMode, selectedTheme]);\n\n const changeTheme = useCallback(\n (newTheme = selectedTheme, newMode = selectedMode) => {\n setTheme(newTheme);\n setColorMode(newMode);\n },\n [selectedMode, selectedTheme],\n );\n\n const value = useMemo<HvThemeContextValue>(\n () => ({\n themes,\n colorModes,\n activeTheme: activeTheme as HvTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n }),\n [\n themes,\n colorModes,\n activeTheme,\n selectedTheme,\n selectedMode,\n changeTheme,\n rootId,\n ],\n );\n\n const muiTheme = useMemo(() => {\n return createTheme({\n components: {\n MuiButtonBase: {\n defaultProps: {\n disableRipple: true,\n },\n },\n },\n breakpoints: {\n ...activeTheme.breakpoints,\n },\n });\n }, [activeTheme.breakpoints]);\n\n const emotionCacheValue = useMemo(\n () => ({ cache: emotionCache }),\n [emotionCache],\n );\n\n return (\n <MuiThemeProvider theme={muiTheme}>\n <HvThemeContext.Provider value={value}>\n <EmotionContext.Provider value={emotionCacheValue}>\n {children}\n </EmotionContext.Provider>\n </HvThemeContext.Provider>\n </MuiThemeProvider>\n );\n};\n"],"names":["MuiThemeProvider"],"mappings":";;;;;;;AAgCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AAAA,EACP;AAAA,EACA,WAAW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,EAAA;AAGf,6BACGA,eAAiB,EAAA,OAAO,UACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OACvB,UAAA,oBAAC,eAAe,UAAf,EAAwB,OAAO,mBAC7B,SACH,CAAA,GACF,EACF,CAAA;AAEJ;"}
@@ -4,7 +4,11 @@ function getDocument() {
4
4
  function getElementById(elementId) {
5
5
  return elementId && getDocument()?.getElementById(elementId) || void 0;
6
6
  }
7
+ function getContainerElement(elementId) {
8
+ return getElementById(elementId) || getDocument()?.body;
9
+ }
7
10
  export {
11
+ getContainerElement,
8
12
  getDocument,
9
13
  getElementById
10
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sources":["../../../src/utils/document.ts"],"sourcesContent":["export function getDocument() {\n return typeof window !== \"undefined\" ? document : undefined;\n}\n\n/** Wrapper around `document.getElementById` */\nexport function getElementById(elementId?: string) {\n return (elementId && getDocument()?.getElementById(elementId)) || undefined;\n}\n\n/** Get a container element by id, falling back to document-body */\nexport function getContainerElement(elementId?: string) {\n return getElementById(elementId) || getDocument()?.body;\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc;AACrB,SAAA,OAAO,WAAW,cAAc,WAAW;AACpD;AAGO,SAAS,eAAe,WAAoB;AACjD,SAAQ,aAAa,YAAe,GAAA,eAAe,SAAS,KAAM;AACpE;"}
1
+ {"version":3,"file":"document.js","sources":["../../../src/utils/document.ts"],"sourcesContent":["export function getDocument() {\n return typeof window !== \"undefined\" ? document : undefined;\n}\n\n/** Wrapper around `document.getElementById` */\nexport function getElementById(elementId?: string) {\n return (elementId && getDocument()?.getElementById(elementId)) || undefined;\n}\n\n/** Get a container element by id, falling back to document-body */\nexport function getContainerElement(elementId?: string) {\n return getElementById(elementId) || getDocument()?.body;\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc;AACrB,SAAA,OAAO,WAAW,cAAc,WAAW;AACpD;AAGO,SAAS,eAAe,WAAoB;AACjD,SAAQ,aAAa,YAAe,GAAA,eAAe,SAAS,KAAM;AACpE;AAGO,SAAS,oBAAoB,WAAoB;AACtD,SAAO,eAAe,SAAS,KAAK,YAAA,GAAe;AACrD;"}
@@ -1,7 +1,7 @@
1
1
  import { themes } from "@hitachivantara/uikit-styles";
2
- import { getElementById } from "./document.js";
2
+ import { getContainerElement, getElementById } from "./document.js";
3
3
  const setElementAttrs = (themeName, modeName, colorScheme, themeRootId) => {
4
- const element = themeRootId ? document.getElementById(themeRootId) : document.body;
4
+ const element = getContainerElement(themeRootId);
5
5
  if (element) {
6
6
  element.setAttribute(`data-theme`, themeName);
7
7
  element.setAttribute(`data-color-mode`, modeName);
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sources":["../../../src/utils/theme.ts"],"sourcesContent":["import {\n HvThemeColorModeStructure,\n HvThemeStructure,\n themes,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { HvCreateThemeProps, HvTheme } from \"../types/theme\";\nimport { getElementById } from \"./document\";\n\n/**\n * Sets the element attributes and style for a theme and color mode.\n */\nexport const setElementAttrs = (\n themeName: string,\n modeName: string,\n colorScheme: string,\n themeRootId?: string,\n) => {\n const element = themeRootId\n ? document.getElementById(themeRootId)\n : document.body;\n\n if (element) {\n element.setAttribute(`data-theme`, themeName);\n element.setAttribute(`data-color-mode`, modeName);\n\n // set default styles for child components to inherit\n element.classList.add(`uikit-root-element`);\n element.style.colorScheme = colorScheme;\n }\n};\n\n/**\n * Applies customizations to a theme.\n */\nconst applyThemeCustomizations = (obj: any, customizations: any) => {\n const isObject = (val: any) =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\n // Customized theme\n const customizedTheme = { ...obj };\n\n // Add new values to the theme or replace values\n Object.keys(customizations).forEach((key) => {\n if (customizedTheme[key]) {\n if (isObject(customizedTheme[key]) && isObject(customizations[key])) {\n customizedTheme[key] = applyThemeCustomizations(\n customizedTheme[key],\n customizations[key],\n );\n } else if (typeof customizedTheme[key] === typeof customizations[key]) {\n customizedTheme[key] = customizations[key];\n }\n } else {\n customizedTheme[key] = customizations[key];\n }\n });\n\n return customizedTheme;\n};\n\n/**\n * Creates a customized theme based on the base theme and customizations given.\n * For the color modes, the colors that are not defined will be replaced by the values from the dawn mode of the base theme.\n */\nexport const createTheme = (\n props: HvCreateThemeProps,\n): HvTheme | HvThemeStructure => {\n const {\n name,\n base = \"ds5\",\n inheritColorModes = true,\n ...customizations\n } = props;\n\n // Apply customizations to the base theme\n const customizedTheme: HvTheme | HvThemeStructure = customizations\n ? (applyThemeCustomizations(themes[base], customizations) as HvTheme)\n : { ...themes[base] };\n\n // Set theme name\n customizedTheme.name = name.trim();\n // Set theme base\n customizedTheme.base = base;\n\n // Fill new color modes with missing colors\n if (customizations) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!themes[base].colors.modes[mode]) {\n customizedTheme.colors.modes[mode] = {\n ...themes[base].colors.modes.dawn,\n ...(customizedTheme.colors.modes[mode] as Partial<\n HvThemeColorModeStructure & { [key: string]: string }\n >),\n };\n }\n });\n }\n\n // If the flag `inheritColorModes` is false and customizations were given for the color modes,\n // we're removing any color modes that might have been inherited\n if (!inheritColorModes && customizations.colors?.modes) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!Object.keys(customizations.colors?.modes || {}).includes(mode)) {\n delete customizedTheme.colors.modes[mode];\n }\n });\n }\n\n // Created theme\n return customizedTheme;\n};\n\n/**\n * Process the themes provided to the HvProvider:\n * - Cleans themes with the same name\n * - Returns the default if the list is empty (ds5)\n */\nexport const processThemes = (\n themesList?: (HvTheme | HvThemeStructure)[],\n): (HvTheme | HvThemeStructure)[] => {\n if (themesList && Array.isArray(themesList) && themesList.length > 0) {\n const list: (HvTheme | HvThemeStructure)[] = [];\n\n themesList.forEach((thm) => {\n const i: number = list.findIndex(\n (t) => t.name.trim() === thm.name.trim(),\n );\n\n if (i !== -1) {\n list.splice(i, 1);\n list.push(thm);\n } else {\n list.push(thm);\n }\n });\n\n // Cleaned themes\n return list;\n }\n // DS5\n return [themes.ds5];\n};\n\nexport const getVarValue = (cssVar: string, rootElementId?: string) => {\n const root = getElementById(rootElementId || \"hv-root\");\n if (!root) return undefined;\n\n return getComputedStyle(root)\n .getPropertyValue(cssVar.replace(\"var(\", \"\").replace(\")\", \"\"))\n .trim();\n};\n"],"names":[],"mappings":";;AAYO,MAAM,kBAAkB,CAC7B,WACA,UACA,aACA,gBACG;AACH,QAAM,UAAU,cACZ,SAAS,eAAe,WAAW,IACnC,SAAS;AAEb,MAAI,SAAS;AACH,YAAA,aAAa,cAAc,SAAS;AACpC,YAAA,aAAa,mBAAmB,QAAQ;AAGxC,YAAA,UAAU,IAAI,oBAAoB;AAC1C,YAAQ,MAAM,cAAc;AAAA,EAC9B;AACF;AAKA,MAAM,2BAA2B,CAAC,KAAU,mBAAwB;AAC5D,QAAA,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAGhD,QAAA,kBAAkB,EAAE,GAAG;AAG7B,SAAO,KAAK,cAAc,EAAE,QAAQ,CAAC,QAAQ;AACvC,QAAA,gBAAgB,GAAG,GAAG;AACpB,UAAA,SAAS,gBAAgB,GAAG,CAAC,KAAK,SAAS,eAAe,GAAG,CAAC,GAAG;AACnE,wBAAgB,GAAG,IAAI;AAAA,UACrB,gBAAgB,GAAG;AAAA,UACnB,eAAe,GAAG;AAAA,QAAA;AAAA,MACpB,WACS,OAAO,gBAAgB,GAAG,MAAM,OAAO,eAAe,GAAG,GAAG;AACrD,wBAAA,GAAG,IAAI,eAAe,GAAG;AAAA,MAC3C;AAAA,IAAA,OACK;AACW,sBAAA,GAAG,IAAI,eAAe,GAAG;AAAA,IAC3C;AAAA,EAAA,CACD;AAEM,SAAA;AACT;AAMa,MAAA,cAAc,CACzB,UAC+B;AACzB,QAAA;AAAA,IACJ;AAAA,IACA,OAAO;AAAA,IACP,oBAAoB;AAAA,IACpB,GAAG;AAAA,EACD,IAAA;AAGJ,QAAM,kBAA8C,iBAC/C,yBAAyB,OAAO,IA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Ae,iBAAiB,SAAS;AACtD,MAAI,CAAC;AAAa,WAAA;AAElB,SAAO,iBAAiB,IAAI,EACzB,iBAAiB,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,KAAK,EAAE,CAAC,EAC5D,KAAK;AACV;"}
1
+ {"version":3,"file":"theme.js","sources":["../../../src/utils/theme.ts"],"sourcesContent":["import {\n HvThemeColorModeStructure,\n HvThemeStructure,\n themes,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { HvCreateThemeProps, HvTheme } from \"../types/theme\";\nimport { getContainerElement, getElementById } from \"./document\";\n\n/**\n * Sets the element attributes and style for a theme and color mode.\n */\nexport const setElementAttrs = (\n themeName: string,\n modeName: string,\n colorScheme: string,\n themeRootId?: string,\n) => {\n const element = getContainerElement(themeRootId);\n\n if (element) {\n element.setAttribute(`data-theme`, themeName);\n element.setAttribute(`data-color-mode`, modeName);\n\n // set default styles for child components to inherit\n element.classList.add(`uikit-root-element`);\n element.style.colorScheme = colorScheme;\n }\n};\n\n/**\n * Applies customizations to a theme.\n */\nconst applyThemeCustomizations = (obj: any, customizations: any) => {\n const isObject = (val: any) =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\n // Customized theme\n const customizedTheme = { ...obj };\n\n // Add new values to the theme or replace values\n Object.keys(customizations).forEach((key) => {\n if (customizedTheme[key]) {\n if (isObject(customizedTheme[key]) && isObject(customizations[key])) {\n customizedTheme[key] = applyThemeCustomizations(\n customizedTheme[key],\n customizations[key],\n );\n } else if (typeof customizedTheme[key] === typeof customizations[key]) {\n customizedTheme[key] = customizations[key];\n }\n } else {\n customizedTheme[key] = customizations[key];\n }\n });\n\n return customizedTheme;\n};\n\n/**\n * Creates a customized theme based on the base theme and customizations given.\n * For the color modes, the colors that are not defined will be replaced by the values from the dawn mode of the base theme.\n */\nexport const createTheme = (\n props: HvCreateThemeProps,\n): HvTheme | HvThemeStructure => {\n const {\n name,\n base = \"ds5\",\n inheritColorModes = true,\n ...customizations\n } = props;\n\n // Apply customizations to the base theme\n const customizedTheme: HvTheme | HvThemeStructure = customizations\n ? (applyThemeCustomizations(themes[base], customizations) as HvTheme)\n : { ...themes[base] };\n\n // Set theme name\n customizedTheme.name = name.trim();\n // Set theme base\n customizedTheme.base = base;\n\n // Fill new color modes with missing colors\n if (customizations) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!themes[base].colors.modes[mode]) {\n customizedTheme.colors.modes[mode] = {\n ...themes[base].colors.modes.dawn,\n ...(customizedTheme.colors.modes[mode] as Partial<\n HvThemeColorModeStructure & { [key: string]: string }\n >),\n };\n }\n });\n }\n\n // If the flag `inheritColorModes` is false and customizations were given for the color modes,\n // we're removing any color modes that might have been inherited\n if (!inheritColorModes && customizations.colors?.modes) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!Object.keys(customizations.colors?.modes || {}).includes(mode)) {\n delete customizedTheme.colors.modes[mode];\n }\n });\n }\n\n // Created theme\n return customizedTheme;\n};\n\n/**\n * Process the themes provided to the HvProvider:\n * - Cleans themes with the same name\n * - Returns the default if the list is empty (ds5)\n */\nexport const processThemes = (\n themesList?: (HvTheme | HvThemeStructure)[],\n): (HvTheme | HvThemeStructure)[] => {\n if (themesList && Array.isArray(themesList) && themesList.length > 0) {\n const list: (HvTheme | HvThemeStructure)[] = [];\n\n themesList.forEach((thm) => {\n const i: number = list.findIndex(\n (t) => t.name.trim() === thm.name.trim(),\n );\n\n if (i !== -1) {\n list.splice(i, 1);\n list.push(thm);\n } else {\n list.push(thm);\n }\n });\n\n // Cleaned themes\n return list;\n }\n // DS5\n return [themes.ds5];\n};\n\nexport const getVarValue = (cssVar: string, rootElementId?: string) => {\n const root = getElementById(rootElementId || \"hv-root\");\n if (!root) return undefined;\n\n return getComputedStyle(root)\n .getPropertyValue(cssVar.replace(\"var(\", \"\").replace(\")\", \"\"))\n .trim();\n};\n"],"names":[],"mappings":";;AAYO,MAAM,kBAAkB,CAC7B,WACA,UACA,aACA,gBACG;AACG,QAAA,U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const HvThemeProvider: ({ children, themes: themesList, theme, emotionCache, colorMode, themeRootId: rootId, }: HvThemeProviderProps) => JSX_3.Element;
6745
+ export declare const HvThemeProvider: ({ children, themes: themesList, theme: themeProp, emotionCache, colorMode: colorModeProp, themeRootId: rootId, }: HvThemeProviderProps) => JSX_3.Element;
6746
6746
 
6747
6747
  declare interface HvThemeProviderProps {
6748
6748
  children: React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.66.8",
3
+ "version": "5.66.10",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "Core React components for the NEXT Design System.",
@@ -15,7 +15,8 @@
15
15
  ],
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/lumada-design/hv-uikit-react.git"
18
+ "url": "https://github.com/lumada-design/hv-uikit-react.git",
19
+ "directory": "packages/core"
19
20
  },
20
21
  "license": "Apache-2.0",
21
22
  "bugs": {
@@ -33,9 +34,9 @@
33
34
  "@emotion/css": "^11.11.2",
34
35
  "@emotion/serialize": "^1.1.2",
35
36
  "@emotion/utils": "^1.2.1",
36
- "@hitachivantara/uikit-react-icons": "^5.10.1",
37
- "@hitachivantara/uikit-react-shared": "^5.1.43",
38
- "@hitachivantara/uikit-styles": "^5.30.2",
37
+ "@hitachivantara/uikit-react-icons": "^5.10.2",
38
+ "@hitachivantara/uikit-react-shared": "^5.1.44",
39
+ "@hitachivantara/uikit-styles": "^5.30.3",
39
40
  "@internationalized/date": "^3.2.0",
40
41
  "@mui/base": "^5.0.0-beta.40",
41
42
  "@popperjs/core": "^2.11.8",
@@ -62,7 +63,7 @@
62
63
  "access": "public",
63
64
  "directory": "package"
64
65
  },
65
- "gitHead": "6cfa285815d1ff1d4621790762555845129a3fd3",
66
+ "gitHead": "fd75cf61e59e75d65a015d0e148ec71ecd88da4b",
66
67
  "exports": {
67
68
  ".": {
68
69
  "require": "./dist/cjs/index.cjs",