@hitachivantara/uikit-react-core 5.66.2 → 5.66.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Slider/Slider.cjs +14 -8
- package/dist/cjs/Slider/utils.cjs +22 -1
- package/dist/cjs/Stack/Stack.cjs +4 -1
- package/dist/cjs/Stack/Stack.styles.cjs +3 -0
- package/dist/esm/Slider/Slider.js +15 -9
- package/dist/esm/Slider/Slider.js.map +1 -1
- package/dist/esm/Slider/utils.js +22 -1
- package/dist/esm/Slider/utils.js.map +1 -1
- package/dist/esm/Stack/Stack.js +4 -1
- package/dist/esm/Stack/Stack.js.map +1 -1
- package/dist/esm/Stack/Stack.styles.js +3 -0
- package/dist/esm/Stack/Stack.styles.js.map +1 -1
- package/dist/types/index.d.ts +43 -41
- package/package.json +5 -5
|
@@ -71,6 +71,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
71
71
|
markStep,
|
|
72
72
|
divisionQuantity,
|
|
73
73
|
minPointValue,
|
|
74
|
+
maxPointValue,
|
|
74
75
|
stepValue,
|
|
75
76
|
markDigits,
|
|
76
77
|
!!disabled,
|
|
@@ -84,6 +85,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
84
85
|
markProperties,
|
|
85
86
|
markStep,
|
|
86
87
|
minPointValue,
|
|
88
|
+
maxPointValue,
|
|
87
89
|
stepValue
|
|
88
90
|
]
|
|
89
91
|
);
|
|
@@ -137,7 +139,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
137
139
|
const generateKnobsPositionAndValues = React.useCallback(
|
|
138
140
|
(knobsCurrentPosition) => {
|
|
139
141
|
const newKnobsPosition = knobsCurrentPosition.slice();
|
|
140
|
-
const
|
|
142
|
+
const knobsValues2 = [];
|
|
141
143
|
let duplicatedValue = null;
|
|
142
144
|
const findDuplicated = newKnobsPosition.filter(
|
|
143
145
|
(item, index) => newKnobsPosition.indexOf(item) !== index
|
|
@@ -155,7 +157,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
155
157
|
newArray[index] = newPosition;
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
|
|
160
|
+
knobsValues2[index] = utils.knobsPositionToScaledValue(
|
|
159
161
|
newPosition,
|
|
160
162
|
minPointValue,
|
|
161
163
|
stepValue
|
|
@@ -163,7 +165,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
163
165
|
}, void 0);
|
|
164
166
|
return {
|
|
165
167
|
knobsPosition: newKnobsPosition,
|
|
166
|
-
knobsValues
|
|
168
|
+
knobsValues: knobsValues2
|
|
167
169
|
};
|
|
168
170
|
},
|
|
169
171
|
[knobsPositions, minPointValue, noOverlap, stepValue]
|
|
@@ -335,6 +337,14 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
335
337
|
index
|
|
336
338
|
);
|
|
337
339
|
};
|
|
340
|
+
const knobsValuesArray = utils.knobsPositionsToKnobsValues(
|
|
341
|
+
knobsPositions,
|
|
342
|
+
stepValue,
|
|
343
|
+
minPointValue
|
|
344
|
+
);
|
|
345
|
+
const knobsValues = knobsValuesArray.map(
|
|
346
|
+
(v) => Number(v.toFixed(markDigits))
|
|
347
|
+
);
|
|
338
348
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
339
349
|
FormElement.HvFormElement,
|
|
340
350
|
{
|
|
@@ -380,11 +390,7 @@ const HvSlider = React.forwardRef((props, ref) => {
|
|
|
380
390
|
{
|
|
381
391
|
id: sliderInputId,
|
|
382
392
|
label,
|
|
383
|
-
values:
|
|
384
|
-
knobsPositions,
|
|
385
|
-
stepValue,
|
|
386
|
-
minPointValue
|
|
387
|
-
),
|
|
393
|
+
values: knobsValues,
|
|
388
394
|
onChange: onInputChangeHandler,
|
|
389
395
|
status: validationStatus,
|
|
390
396
|
disabled,
|
|
@@ -28,8 +28,9 @@ const knobsPositionsToKnobsValues = (knobPositions, stepValue, minPointValue) =>
|
|
|
28
28
|
return knobsValues;
|
|
29
29
|
};
|
|
30
30
|
const calculateStepValue = (maxPointValue, minPointValue, divisionQuantity) => Math.abs(maxPointValue - minPointValue) / divisionQuantity;
|
|
31
|
-
const createMark = (markProperties, markstep, divisionQuantity, minPointValue, stepValue, markDigits, disabled, formatMark = (mark) => mark) => {
|
|
31
|
+
const createMark = (markProperties, markstep, divisionQuantity, minPointValue, maxPointValue, stepValue, markDigits, disabled, formatMark = (mark) => mark) => {
|
|
32
32
|
const marks = {};
|
|
33
|
+
const values = [];
|
|
33
34
|
if (markProperties.length > 0) {
|
|
34
35
|
markProperties.forEach((markProperty) => {
|
|
35
36
|
if (typeof markProperty.position === "number") {
|
|
@@ -54,6 +55,7 @@ const createMark = (markProperties, markstep, divisionQuantity, minPointValue, s
|
|
|
54
55
|
minPointValue,
|
|
55
56
|
stepValue
|
|
56
57
|
).toFixed(markDigits);
|
|
58
|
+
values.push(labelValue);
|
|
57
59
|
labelValue = formatMark?.(labelValue) || labelValue;
|
|
58
60
|
marks[index] = disabled ? {
|
|
59
61
|
label: `${labelValue}`,
|
|
@@ -67,6 +69,25 @@ const createMark = (markProperties, markstep, divisionQuantity, minPointValue, s
|
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
71
|
}
|
|
72
|
+
if (!values.includes(maxPointValue.toString())) {
|
|
73
|
+
const lastMarkPosition = knobsValuesToKnobsPositions(
|
|
74
|
+
[maxPointValue],
|
|
75
|
+
1 / stepValue,
|
|
76
|
+
minPointValue
|
|
77
|
+
);
|
|
78
|
+
const lastMarkLabel = formatMark?.(maxPointValue.toFixed(markDigits));
|
|
79
|
+
marks[lastMarkPosition[0]] = disabled ? {
|
|
80
|
+
label: `${lastMarkLabel}`,
|
|
81
|
+
style: {
|
|
82
|
+
...Slider_styles.sliderStyles.disabledMark
|
|
83
|
+
}
|
|
84
|
+
} : {
|
|
85
|
+
label: `${lastMarkLabel}`,
|
|
86
|
+
style: {
|
|
87
|
+
...Slider_styles.sliderStyles.mark
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
70
91
|
}
|
|
71
92
|
return marks;
|
|
72
93
|
};
|
package/dist/cjs/Stack/Stack.cjs
CHANGED
|
@@ -48,12 +48,15 @@ const HvStack = (props) => {
|
|
|
48
48
|
orientation: processedDirection === "column" ? "horizontal" : "vertical",
|
|
49
49
|
flexItem: processedDirection === "row",
|
|
50
50
|
role: "separator",
|
|
51
|
+
classes: {
|
|
52
|
+
root: classes.divider
|
|
53
|
+
},
|
|
51
54
|
...dividerProps
|
|
52
55
|
}
|
|
53
56
|
);
|
|
54
57
|
}
|
|
55
58
|
return divider;
|
|
56
|
-
}, [divider, dividerProps, processedDirection]);
|
|
59
|
+
}, [classes.divider, divider, dividerProps, processedDirection]);
|
|
57
60
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
61
|
"div",
|
|
59
62
|
{
|
|
@@ -10,7 +10,7 @@ import { setId } from "../utils/setId.js";
|
|
|
10
10
|
import { useClasses, sliderStyles } from "./Slider.styles.js";
|
|
11
11
|
import { staticClasses } from "./Slider.styles.js";
|
|
12
12
|
import { HvSliderInput } from "./SliderInput/SliderInput.js";
|
|
13
|
-
import { calculateStepValue, createMark, isSingleSlider, knobsValuesToKnobsPositions, convertStatusToArray, generateDefaultKnobProperties, createTrackStyles, createKnobStyles, knobsPositionToScaledValue,
|
|
13
|
+
import { calculateStepValue, createMark, isSingleSlider, knobsValuesToKnobsPositions, convertStatusToArray, generateDefaultKnobProperties, createTrackStyles, createKnobStyles, knobsPositionToScaledValue, knobsPositionsToKnobsValues, statusArrayToFormStatus, scaledValueToKnobsPositionValue, ensureValuesConsistency } from "./utils.js";
|
|
14
14
|
import { HvFormElement } from "../Forms/FormElement/FormElement.js";
|
|
15
15
|
import { HvLabel } from "../Forms/Label/Label.js";
|
|
16
16
|
import { HvWarningText } from "../Forms/WarningText/WarningText.js";
|
|
@@ -67,6 +67,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
67
67
|
markStep,
|
|
68
68
|
divisionQuantity,
|
|
69
69
|
minPointValue,
|
|
70
|
+
maxPointValue,
|
|
70
71
|
stepValue,
|
|
71
72
|
markDigits,
|
|
72
73
|
!!disabled,
|
|
@@ -80,6 +81,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
80
81
|
markProperties,
|
|
81
82
|
markStep,
|
|
82
83
|
minPointValue,
|
|
84
|
+
maxPointValue,
|
|
83
85
|
stepValue
|
|
84
86
|
]
|
|
85
87
|
);
|
|
@@ -133,7 +135,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
133
135
|
const generateKnobsPositionAndValues = useCallback(
|
|
134
136
|
(knobsCurrentPosition) => {
|
|
135
137
|
const newKnobsPosition = knobsCurrentPosition.slice();
|
|
136
|
-
const
|
|
138
|
+
const knobsValues2 = [];
|
|
137
139
|
let duplicatedValue = null;
|
|
138
140
|
const findDuplicated = newKnobsPosition.filter(
|
|
139
141
|
(item, index) => newKnobsPosition.indexOf(item) !== index
|
|
@@ -151,7 +153,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
151
153
|
newArray[index] = newPosition;
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
|
|
156
|
+
knobsValues2[index] = knobsPositionToScaledValue(
|
|
155
157
|
newPosition,
|
|
156
158
|
minPointValue,
|
|
157
159
|
stepValue
|
|
@@ -159,7 +161,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
159
161
|
}, void 0);
|
|
160
162
|
return {
|
|
161
163
|
knobsPosition: newKnobsPosition,
|
|
162
|
-
knobsValues
|
|
164
|
+
knobsValues: knobsValues2
|
|
163
165
|
};
|
|
164
166
|
},
|
|
165
167
|
[knobsPositions, minPointValue, noOverlap, stepValue]
|
|
@@ -331,6 +333,14 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
331
333
|
index
|
|
332
334
|
);
|
|
333
335
|
};
|
|
336
|
+
const knobsValuesArray = knobsPositionsToKnobsValues(
|
|
337
|
+
knobsPositions,
|
|
338
|
+
stepValue,
|
|
339
|
+
minPointValue
|
|
340
|
+
);
|
|
341
|
+
const knobsValues = knobsValuesArray.map(
|
|
342
|
+
(v) => Number(v.toFixed(markDigits))
|
|
343
|
+
);
|
|
334
344
|
return /* @__PURE__ */ jsxs(
|
|
335
345
|
HvFormElement,
|
|
336
346
|
{
|
|
@@ -376,11 +386,7 @@ const HvSlider = forwardRef((props, ref) => {
|
|
|
376
386
|
{
|
|
377
387
|
id: sliderInputId,
|
|
378
388
|
label,
|
|
379
|
-
values:
|
|
380
|
-
knobsPositions,
|
|
381
|
-
stepValue,
|
|
382
|
-
minPointValue
|
|
383
|
-
),
|
|
389
|
+
values: knobsValues,
|
|
384
390
|
onChange: onInputChangeHandler,
|
|
385
391
|
status: validationStatus,
|
|
386
392
|
disabled,
|
|
@@ -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 stepValue,\n markDigits,\n !!disabled,\n formatMark,\n ),\n [\n disabled,\n divisionQuantity,\n formatMark,\n markDigits,\n markProperties,\n markStep,\n minPointValue,\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 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={knobsPositionsToKnobsValues(\n knobsPositions,\n stepValue,\n minPointValue,\n )}\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":["validationStates"],"mappings":";;;;;;;;;;;;;;;;AA2IO,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,eAA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AE3D,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
|
+
{"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,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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AA,cAChC,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,YAAA,CACvB;AAAA,YACD,KAAK;AAAA,YACL,KAAK;AAAA,YACL,MAAM;AAAA,YACN;AAAA,YACA,UAAU,WAAW,aAAa,cAAc,aAAa;AAAA,YAC7D,UAAU,CAAC,gBACT,gBAAgB,QAAgB,OAAO,WAAW,CAAC;AAAA,YAErD,gBAAgB,CAAC,gBACf,sBAAsB,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;"}
|
package/dist/esm/Slider/utils.js
CHANGED
|
@@ -26,8 +26,9 @@ const knobsPositionsToKnobsValues = (knobPositions, stepValue, minPointValue) =>
|
|
|
26
26
|
return knobsValues;
|
|
27
27
|
};
|
|
28
28
|
const calculateStepValue = (maxPointValue, minPointValue, divisionQuantity) => Math.abs(maxPointValue - minPointValue) / divisionQuantity;
|
|
29
|
-
const createMark = (markProperties, markstep, divisionQuantity, minPointValue, stepValue, markDigits, disabled, formatMark = (mark) => mark) => {
|
|
29
|
+
const createMark = (markProperties, markstep, divisionQuantity, minPointValue, maxPointValue, stepValue, markDigits, disabled, formatMark = (mark) => mark) => {
|
|
30
30
|
const marks = {};
|
|
31
|
+
const values = [];
|
|
31
32
|
if (markProperties.length > 0) {
|
|
32
33
|
markProperties.forEach((markProperty) => {
|
|
33
34
|
if (typeof markProperty.position === "number") {
|
|
@@ -52,6 +53,7 @@ const createMark = (markProperties, markstep, divisionQuantity, minPointValue, s
|
|
|
52
53
|
minPointValue,
|
|
53
54
|
stepValue
|
|
54
55
|
).toFixed(markDigits);
|
|
56
|
+
values.push(labelValue);
|
|
55
57
|
labelValue = formatMark?.(labelValue) || labelValue;
|
|
56
58
|
marks[index] = disabled ? {
|
|
57
59
|
label: `${labelValue}`,
|
|
@@ -65,6 +67,25 @@ const createMark = (markProperties, markstep, divisionQuantity, minPointValue, s
|
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
}
|
|
70
|
+
if (!values.includes(maxPointValue.toString())) {
|
|
71
|
+
const lastMarkPosition = knobsValuesToKnobsPositions(
|
|
72
|
+
[maxPointValue],
|
|
73
|
+
1 / stepValue,
|
|
74
|
+
minPointValue
|
|
75
|
+
);
|
|
76
|
+
const lastMarkLabel = formatMark?.(maxPointValue.toFixed(markDigits));
|
|
77
|
+
marks[lastMarkPosition[0]] = disabled ? {
|
|
78
|
+
label: `${lastMarkLabel}`,
|
|
79
|
+
style: {
|
|
80
|
+
...sliderStyles.disabledMark
|
|
81
|
+
}
|
|
82
|
+
} : {
|
|
83
|
+
label: `${lastMarkLabel}`,
|
|
84
|
+
style: {
|
|
85
|
+
...sliderStyles.mark
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
68
89
|
}
|
|
69
90
|
return marks;
|
|
70
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/Slider/utils.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFormStatus } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { sliderStyles as styles } from \"./Slider.styles\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} sliderValue - he value of the slider to be scaled\n * @param {*} minPointVlue - The value of the first point in the slider from left to right.\n * @param {*} stepVlue - The calculated separation between the values of the slider.\n */\nexport const knobsPositionToScaledValue = (\n sliderValue: number,\n minPointValue: number,\n stepValue: number,\n): number => minPointValue + stepValue * sliderValue;\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} scaledValue - The value of the slider to be scaled\n * @param {*} minPointValue - The value of the first point in\n * the slider from left to right.\n * @param {*} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n */\nexport const scaledValueToKnobsPositionValue = (\n scaledValue: number | undefined,\n minPointValue: number,\n inverseStepValue: number,\n): number =>\n typeof scaledValue === \"number\"\n ? Math.floor((scaledValue - minPointValue) * inverseStepValue)\n : NaN;\n\n/**\n * Transform the received knobs values into knob positions\n *\n * @param {Object} values - The values of the slider.\n * @param {Number} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsValuesToKnobsPositions = (\n values: (number | undefined)[],\n inverseStepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsPositions: number[] = [];\n\n values.forEach((value, index) => {\n knobsPositions[index] = scaledValueToKnobsPositionValue(\n value,\n minPointValue,\n inverseStepValue,\n );\n });\n\n return knobsPositions;\n};\n\n/**\n * Transform the received knobs positions into knob values\n *\n * @param {Object} knobPositions - The values of the slider.\n * @param {Number} stepValue - The calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsPositionsToKnobsValues = (\n knobPositions: number[],\n stepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsValues: number[] = [];\n\n knobPositions.forEach((value, index) => {\n knobsValues[index] = knobsPositionToScaledValue(\n value,\n minPointValue,\n stepValue,\n );\n });\n\n return knobsValues;\n};\n\n/**\n * Calculates the separation between each value in the slider.\n *\n * @param {*} maxPointValue - The value of the last point in the slider from left to right.\n * @param {*} minPointValue - The value of the first point in the slider from left to right.\n * @param {*} divisionQuantity - How many subdivisions there are in the slider.\n */\nexport const calculateStepValue = (\n maxPointValue: number,\n minPointValue: number,\n divisionQuantity: number,\n): number => Math.abs(maxPointValue - minPointValue) / divisionQuantity;\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} markProperties - The object provided by the user with\n * the desired configuration for the marks.\n * @param {Integer} markstep - The separation between marks.\n * @param {Integer} divisionQuantity - How many subdivisions there are in the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @param {Integer} stepValue - The calculated separation between the values of the slider.\n * @param {Integer} markDigits - How many decimals the mark will show.\n * @param {Function} formatMark - A function provided by the user that is going to\n * be executed to format the mark text.\n * @param {Object} styles - the default styles for the marks.\n * @returns {Object} - An object with the for the marks.\n * @memberof HvSlider\n */\nexport const createMark = (\n markProperties: HvMarkProperty[],\n markstep: number,\n divisionQuantity: number,\n minPointValue: number,\n stepValue: number,\n markDigits: number,\n disabled: boolean,\n formatMark: (label: React.ReactNode) => React.ReactNode = (mark) => mark,\n): Record<number, { label: string; style: React.CSSProperties }> => {\n const marks: Record<number, { label: string; style: React.CSSProperties }> =\n {};\n\n if (markProperties.length > 0) {\n markProperties.forEach((markProperty) => {\n if (typeof markProperty.position === \"number\") {\n marks[markProperty.position] = disabled\n ? {\n label: `${markProperty.label}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${markProperty.label}`,\n style: {\n ...styles.mark,\n },\n };\n }\n });\n } else {\n const roundedMarkStep = Math.floor(markstep);\n\n for (let index = 0; index <= divisionQuantity; index += roundedMarkStep) {\n let labelValue: React.ReactNode = knobsPositionToScaledValue(\n index,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n\n labelValue = formatMark?.(labelValue) || labelValue;\n\n marks[index] = disabled\n ? {\n label: `${labelValue}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${labelValue}`,\n style: {\n ...styles.mark,\n },\n };\n }\n }\n\n return marks;\n};\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the tracks.\n * @returns {Object} - An object with the style for each track.\n * @memberof HvSlider\n */\nexport const createTrackStyles = (\n knobProperties: HvKnobProperty[],\n): React.CSSProperties[] => {\n const trackStyles: React.CSSProperties[] = [];\n\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n trackStyles[index] = { ...styles.track };\n if (knobProperty.color) {\n trackStyles[index].backgroundColor = knobProperty.trackColor;\n }\n });\n }\n\n return trackStyles;\n};\n\n/**\n * Generates the inline styles used for each knob, applying colors if specified.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the knobs.\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const createKnobStyles = (\n knobProperties: HvKnobProperty[],\n): {\n knobInner: React.CSSProperties[];\n knobOuterStyle: React.CSSProperties[];\n} => {\n const knobInner: React.CSSProperties[] = [];\n const knobOuterStyle: React.CSSProperties[] = [];\n\n const lastItem = knobProperties.length - 1;\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n knobInner[index] = { ...styles.knobInner };\n knobOuterStyle[index] = { ...styles.knobOuter };\n\n if (knobProperty.color) {\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index].backgroundColor = \"transparent\";\n }\n\n if (knobProperty.hidden) {\n knobInner[index] = styles.knobHidden;\n if (index === lastItem) {\n knobInner[index] = { ...styles.knobHiddenLast };\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index] = { ...styles.knobHidden };\n knobOuterStyle[index].backgroundColor = knobProperty.color;\n }\n }\n });\n }\n\n return {\n knobInner,\n knobOuterStyle,\n };\n};\n\n/**\n * Analyzes both the values and the default values to determine whether the slider is working in single mode.\n *\n * @param {Array} values - the values where the knobs are positioned when controlled.\n * @param {Array} defaultValues - the values where the knobs start when uncontrolled.\n * @returns {Boolean} - if true the slider should work as single slider\n */\nexport const isSingleSlider = (\n values: number[],\n defaultValues: (number | undefined)[],\n): boolean => {\n if (!(values?.length > 1)) {\n return defaultValues.length === 1;\n }\n return values.length === 1;\n};\n\n/**\n * Generates the default knob styles for each knob\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Integer} numberOfKnobs - the default styles for the knobs.\n * @param {Object} theme - The theme to extract the colors.\n *\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const generateDefaultKnobProperties = (\n numberOfKnobs: number = 1,\n disabled: boolean = false,\n knobPropertiesProp?: HvKnobProperty[],\n): HvKnobProperty[] => {\n let knobProperties = knobPropertiesProp || [];\n\n const defaultKnobStyles = {\n color: theme.colors.secondary,\n hoverColor: theme.colors.secondary,\n trackColor: theme.colors.secondary,\n dragColor: theme.colors.secondary,\n knobRingColor: theme.colors.atmo1,\n };\n\n const disabledKnobStyles = {\n color: theme.colors.secondary_60,\n hoverColor: theme.colors.secondary_60,\n trackColor: theme.colors.secondary_60,\n dragColor: theme.colors.secondary_60,\n knobRingColor: theme.colors.secondary_60,\n };\n\n if (knobProperties.length > 0) {\n knobProperties = knobProperties.slice(0, numberOfKnobs);\n knobProperties = knobProperties.map((knobProperty) => {\n if (!disabled) {\n return {\n ...disabledKnobStyles,\n ...knobProperty,\n };\n }\n return {\n ...defaultKnobStyles,\n ...knobProperty,\n };\n });\n } else {\n for (let i = 0; i < numberOfKnobs; i += 1) {\n if (!disabled) knobProperties.push(defaultKnobStyles);\n if (disabled) knobProperties.push(disabledKnobStyles);\n }\n }\n\n return knobProperties;\n};\n\nconst pushSlider = (\n index: number,\n inputIndex: number,\n inputValue: number,\n): number => {\n const difference = index - inputIndex;\n\n return inputValue + difference;\n};\n\nexport const ensureValuesConsistency = (\n knobPositions: number[],\n inputIndex: number,\n): number[] => {\n const newKnobsPosition: number[] = [...knobPositions];\n\n newKnobsPosition.forEach((value, index) => {\n if (Number.isNaN(value) || value == null) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index < inputIndex && value > newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index > inputIndex && value < newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n }\n });\n\n return newKnobsPosition;\n};\n\nexport const convertStatusToArray = (\n length: number,\n status?: HvFormStatus | HvFormStatus[],\n): {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n} => {\n const result: {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n } = {\n arrayDefaultStatus: Array.from({ length }, () => validationStates.standBy),\n };\n\n if (status == null) {\n return result;\n }\n if (!Array.isArray(status)) {\n result.arrayStatus = Array.from({ length }, () => status);\n return result;\n }\n result.arrayStatus = status;\n\n return result;\n};\n\nexport const statusArrayToFormStatus = (\n arrayStatus: HvFormStatus[],\n): keyof typeof validationStates => {\n const invalid = arrayStatus.some(\n (status) => status === validationStates.invalid,\n );\n\n if (invalid) return validationStates.invalid;\n\n const valid = arrayStatus.some((status) => status === validationStates.valid);\n\n if (valid) return validationStates.valid;\n\n return validationStates.standBy;\n};\n\nexport const knobsValuesToString = (\n knobsValues: number[],\n markDigits: number,\n): string[] =>\n knobsValues.map((knobValue) =>\n Number.isNaN(knobValue) ? \"\" : knobValue.toFixed(markDigits),\n );\n\nexport const stringValuesToKnobs = (inputsValues: string[]): number[] =>\n inputsValues.map((inputValue) => parseFloat(inputValue));\n"],"names":["styles","validationStates"],"mappings":";;;AAcO,MAAM,6BAA6B,CACxC,aACA,eACA,cACW,gBAAgB,YAAY;AAWlC,MAAM,kCAAkC,CAC7C,aACA,eACA,qBAEA,OAAO,gBAAgB,WACnB,KAAK,OAAO,cAAc,iBAAiB,gBAAgB,IAC3D;AAYC,MAAM,8BAA8B,CACzC,QACA,kBACA,kBACa;AACb,QAAM,iBAA2B,CAAA;AAE1B,SAAA,QAAQ,CAAC,OAAO,UAAU;AAC/B,mBAAe,KAAK,IAAI;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AAYO,MAAM,8BAA8B,CACzC,eACA,WACA,kBACa;AACb,QAAM,cAAwB,CAAA;AAEhB,gBAAA,QAAQ,CAAC,OAAO,UAAU;AACtC,gBAAY,KAAK,IAAI;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AASa,MAAA,qBAAqB,CAChC,eACA,eACA,qBACW,KAAK,IAAI,gBAAgB,aAAa,IAAI;AAmBhD,MAAM,aAAa,CACxB,gBACA,UACA,kBACA,eACA,WACA,YACA,UACA,aAA0D,CAAC,SAAS,SACF;AAClE,QAAM,QACJ,CAAA;AAEE,MAAA,eAAe,SAAS,GAAG;AACd,mBAAA,QAAQ,CAAC,iBAAiB;AACnC,UAAA,OAAO,aAAa,aAAa,UAAU;AACvC,cAAA,aAAa,QAAQ,IAAI,WAC3B;AAAA,UACE,OAAO,GAAG,aAAa,KAAK;AAAA,UAC5B,OAAO;AAAA,YACL,GAAGA,aAAO;AAAA,UACZ;AAAA,QAAA,IAEF;AAAA,UACE,OAAO,GAAG,aAAa,KAAK;AAAA,UAC5B,OAAO;AAAA,YACL,GAAGA,aAAO;AAAA,UACZ;AAAA,QAAA;AAAA,MAER;AAAA,IAAA,CACD;AAAA,EAAA,OACI;AACC,U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BAAiB;AAAA,EAAA;AAGtC,MAAA;AAAS,WAAOA,gBAAiB;AAErC,QAAM,QAAQ,YAAY,KAAK,CAAC,WAAW,WAAWA,gBAAiB,KAAK;AAExE,MAAA;AAAO,WAAOA,gBAAiB;AAEnC,SAAOA,gBAAiB;AAC1B;AAEO,MAAM,sBAAsB,CACjC,aACA,eAEA,YAAY;AAAA,EAAI,CAAC,cACf,OAAO,MAAM,SAAS,IAAI,KAAK,UAAU,QAAQ,UAAU;AAC7D;AAEW,MAAA,sBAAsB,CAAC,iBAClC,aAAa,IAAI,CAAC,eAAe,WAAW,UAAU,CAAC;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/Slider/utils.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFormStatus } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { sliderStyles as styles } from \"./Slider.styles\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} sliderValue - he value of the slider to be scaled\n * @param {*} minPointVlue - The value of the first point in the slider from left to right.\n * @param {*} stepVlue - The calculated separation between the values of the slider.\n */\nexport const knobsPositionToScaledValue = (\n sliderValue: number,\n minPointValue: number,\n stepValue: number,\n): number => minPointValue + stepValue * sliderValue;\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} scaledValue - The value of the slider to be scaled\n * @param {*} minPointValue - The value of the first point in\n * the slider from left to right.\n * @param {*} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n */\nexport const scaledValueToKnobsPositionValue = (\n scaledValue: number | undefined,\n minPointValue: number,\n inverseStepValue: number,\n): number =>\n typeof scaledValue === \"number\"\n ? Math.floor((scaledValue - minPointValue) * inverseStepValue)\n : NaN;\n\n/**\n * Transform the received knobs values into knob positions\n *\n * @param {Object} values - The values of the slider.\n * @param {Number} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsValuesToKnobsPositions = (\n values: (number | undefined)[],\n inverseStepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsPositions: number[] = [];\n\n values.forEach((value, index) => {\n knobsPositions[index] = scaledValueToKnobsPositionValue(\n value,\n minPointValue,\n inverseStepValue,\n );\n });\n\n return knobsPositions;\n};\n\n/**\n * Transform the received knobs positions into knob values\n *\n * @param {Object} knobPositions - The values of the slider.\n * @param {Number} stepValue - The calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsPositionsToKnobsValues = (\n knobPositions: number[],\n stepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsValues: number[] = [];\n\n knobPositions.forEach((value, index) => {\n knobsValues[index] = knobsPositionToScaledValue(\n value,\n minPointValue,\n stepValue,\n );\n });\n\n return knobsValues;\n};\n\n/**\n * Calculates the separation between each value in the slider.\n *\n * @param {*} maxPointValue - The value of the last point in the slider from left to right.\n * @param {*} minPointValue - The value of the first point in the slider from left to right.\n * @param {*} divisionQuantity - How many subdivisions there are in the slider.\n */\nexport const calculateStepValue = (\n maxPointValue: number,\n minPointValue: number,\n divisionQuantity: number,\n): number => Math.abs(maxPointValue - minPointValue) / divisionQuantity;\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} markProperties - The object provided by the user with\n * the desired configuration for the marks.\n * @param {Integer} markstep - The separation between marks.\n * @param {Integer} divisionQuantity - How many subdivisions there are in the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @param {Integer} stepValue - The calculated separation between the values of the slider.\n * @param {Integer} markDigits - How many decimals the mark will show.\n * @param {Function} formatMark - A function provided by the user that is going to\n * be executed to format the mark text.\n * @param {Object} styles - the default styles for the marks.\n * @returns {Object} - An object with the for the marks.\n * @memberof HvSlider\n */\nexport const createMark = (\n markProperties: HvMarkProperty[],\n markstep: number,\n divisionQuantity: number,\n minPointValue: number,\n maxPointValue: number,\n stepValue: number,\n markDigits: number,\n disabled: boolean,\n formatMark: (label: React.ReactNode) => React.ReactNode = (mark) => mark,\n): Record<number, { label: string; style: React.CSSProperties }> => {\n const marks: Record<number, { label: string; style: React.CSSProperties }> =\n {};\n\n const values: string[] = [];\n\n if (markProperties.length > 0) {\n markProperties.forEach((markProperty) => {\n if (typeof markProperty.position === \"number\") {\n marks[markProperty.position] = disabled\n ? {\n label: `${markProperty.label}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${markProperty.label}`,\n style: {\n ...styles.mark,\n },\n };\n }\n });\n } else {\n const roundedMarkStep = Math.floor(markstep);\n\n for (let index = 0; index <= divisionQuantity; index += roundedMarkStep) {\n let labelValue: React.ReactNode = knobsPositionToScaledValue(\n index,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n\n values.push(labelValue as string);\n labelValue = formatMark?.(labelValue) || labelValue;\n\n marks[index] = disabled\n ? {\n label: `${labelValue}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${labelValue}`,\n style: {\n ...styles.mark,\n },\n };\n }\n\n if (!values.includes(maxPointValue.toString())) {\n const lastMarkPosition = knobsValuesToKnobsPositions(\n [maxPointValue],\n 1 / stepValue,\n minPointValue,\n );\n\n const lastMarkLabel = formatMark?.(maxPointValue.toFixed(markDigits));\n marks[lastMarkPosition[0]] = disabled\n ? {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.mark,\n },\n };\n }\n }\n\n return marks;\n};\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the tracks.\n * @returns {Object} - An object with the style for each track.\n * @memberof HvSlider\n */\nexport const createTrackStyles = (\n knobProperties: HvKnobProperty[],\n): React.CSSProperties[] => {\n const trackStyles: React.CSSProperties[] = [];\n\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n trackStyles[index] = { ...styles.track };\n if (knobProperty.color) {\n trackStyles[index].backgroundColor = knobProperty.trackColor;\n }\n });\n }\n\n return trackStyles;\n};\n\n/**\n * Generates the inline styles used for each knob, applying colors if specified.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the knobs.\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const createKnobStyles = (\n knobProperties: HvKnobProperty[],\n): {\n knobInner: React.CSSProperties[];\n knobOuterStyle: React.CSSProperties[];\n} => {\n const knobInner: React.CSSProperties[] = [];\n const knobOuterStyle: React.CSSProperties[] = [];\n\n const lastItem = knobProperties.length - 1;\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n knobInner[index] = { ...styles.knobInner };\n knobOuterStyle[index] = { ...styles.knobOuter };\n\n if (knobProperty.color) {\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index].backgroundColor = \"transparent\";\n }\n\n if (knobProperty.hidden) {\n knobInner[index] = styles.knobHidden;\n if (index === lastItem) {\n knobInner[index] = { ...styles.knobHiddenLast };\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index] = { ...styles.knobHidden };\n knobOuterStyle[index].backgroundColor = knobProperty.color;\n }\n }\n });\n }\n\n return {\n knobInner,\n knobOuterStyle,\n };\n};\n\n/**\n * Analyzes both the values and the default values to determine whether the slider is working in single mode.\n *\n * @param {Array} values - the values where the knobs are positioned when controlled.\n * @param {Array} defaultValues - the values where the knobs start when uncontrolled.\n * @returns {Boolean} - if true the slider should work as single slider\n */\nexport const isSingleSlider = (\n values: number[],\n defaultValues: (number | undefined)[],\n): boolean => {\n if (!(values?.length > 1)) {\n return defaultValues.length === 1;\n }\n return values.length === 1;\n};\n\n/**\n * Generates the default knob styles for each knob\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Integer} numberOfKnobs - the default styles for the knobs.\n * @param {Object} theme - The theme to extract the colors.\n *\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const generateDefaultKnobProperties = (\n numberOfKnobs: number = 1,\n disabled: boolean = false,\n knobPropertiesProp?: HvKnobProperty[],\n): HvKnobProperty[] => {\n let knobProperties = knobPropertiesProp || [];\n\n const defaultKnobStyles = {\n color: theme.colors.secondary,\n hoverColor: theme.colors.secondary,\n trackColor: theme.colors.secondary,\n dragColor: theme.colors.secondary,\n knobRingColor: theme.colors.atmo1,\n };\n\n const disabledKnobStyles = {\n color: theme.colors.secondary_60,\n hoverColor: theme.colors.secondary_60,\n trackColor: theme.colors.secondary_60,\n dragColor: theme.colors.secondary_60,\n knobRingColor: theme.colors.secondary_60,\n };\n\n if (knobProperties.length > 0) {\n knobProperties = knobProperties.slice(0, numberOfKnobs);\n knobProperties = knobProperties.map((knobProperty) => {\n if (!disabled) {\n return {\n ...disabledKnobStyles,\n ...knobProperty,\n };\n }\n return {\n ...defaultKnobStyles,\n ...knobProperty,\n };\n });\n } else {\n for (let i = 0; i < numberOfKnobs; i += 1) {\n if (!disabled) knobProperties.push(defaultKnobStyles);\n if (disabled) knobProperties.push(disabledKnobStyles);\n }\n }\n\n return knobProperties;\n};\n\nconst pushSlider = (\n index: number,\n inputIndex: number,\n inputValue: number,\n): number => {\n const difference = index - inputIndex;\n\n return inputValue + difference;\n};\n\nexport const ensureValuesConsistency = (\n knobPositions: number[],\n inputIndex: number,\n): number[] => {\n const newKnobsPosition: number[] = [...knobPositions];\n\n newKnobsPosition.forEach((value, index) => {\n if (Number.isNaN(value) || value == null) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index < inputIndex && value > newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index > inputIndex && value < newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n }\n });\n\n return newKnobsPosition;\n};\n\nexport const convertStatusToArray = (\n length: number,\n status?: HvFormStatus | HvFormStatus[],\n): {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n} => {\n const result: {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n } = {\n arrayDefaultStatus: Array.from({ length }, () => validationStates.standBy),\n };\n\n if (status == null) {\n return result;\n }\n if (!Array.isArray(status)) {\n result.arrayStatus = Array.from({ length }, () => status);\n return result;\n }\n result.arrayStatus = status;\n\n return result;\n};\n\nexport const statusArrayToFormStatus = (\n arrayStatus: HvFormStatus[],\n): keyof typeof validationStates => {\n const invalid = arrayStatus.some(\n (status) => status === validationStates.invalid,\n );\n\n if (invalid) return validationStates.invalid;\n\n const valid = arrayStatus.some((status) => status === validationStates.valid);\n\n if (valid) return validationStates.valid;\n\n return validationStates.standBy;\n};\n\nexport const knobsValuesToString = (\n knobsValues: number[],\n markDigits: number,\n): string[] =>\n knobsValues.map((knobValue) =>\n Number.isNaN(knobValue) ? \"\" : knobValue.toFixed(markDigits),\n );\n\nexport const stringValuesToKnobs = (inputsValues: string[]): number[] =>\n inputsValues.map((inputValue) => parseFloat(inputValue));\n"],"names":["styles","validationStates"],"mappings":";;;AAcO,MAAM,6BAA6B,CACxC,aACA,eACA,cACW,gBAAgB,YAAY;AAWlC,MAAM,kCAAkC,CAC7C,aACA,eACA,qBAEA,OAAO,gBAAgB,WACnB,KAAK,OAAO,cAAc,iBAAiB,gBAAgB,IAC3D;AAYC,MAAM,8BAA8B,CACzC,QACA,kBACA,kBACa;AACb,QAAM,iBAA2B,CAAA;AAE1B,SAAA,QAAQ,CAAC,OAAO,UAAU;AAC/B,m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AM,MAAM;AACjD,WAAA;AAAA,EACT;AACA,SAAO,cAAc;AAEd,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,gBACkC;AAClC,QAAM,UAAU,YAAY;AAAA,IAC1B,CAAC,WAAW,WAAWA,gBAAiB;AAAA,EAAA;AAGtC,MAAA;AAAS,WAAOA,gBAAiB;AAErC,QAAM,QAAQ,YAAY,KAAK,CAAC,WAAW,WAAWA,gBAAiB,KAAK;AAExE,MAAA;AAAO,WAAOA,gBAAiB;AAEnC,SAAOA,gBAAiB;AAC1B;AAEO,MAAM,sBAAsB,CACjC,aACA,eAEA,YAAY;AAAA,EAAI,CAAC,cACf,OAAO,MAAM,SAAS,IAAI,KAAK,UAAU,QAAQ,UAAU;AAC7D;AAEW,MAAA,sBAAsB,CAAC,iBAClC,aAAa,IAAI,CAAC,eAAe,WAAW,UAAU,CAAC;"}
|
package/dist/esm/Stack/Stack.js
CHANGED
|
@@ -45,12 +45,15 @@ const HvStack = (props) => {
|
|
|
45
45
|
orientation: processedDirection === "column" ? "horizontal" : "vertical",
|
|
46
46
|
flexItem: processedDirection === "row",
|
|
47
47
|
role: "separator",
|
|
48
|
+
classes: {
|
|
49
|
+
root: classes.divider
|
|
50
|
+
},
|
|
48
51
|
...dividerProps
|
|
49
52
|
}
|
|
50
53
|
);
|
|
51
54
|
}
|
|
52
55
|
return divider;
|
|
53
|
-
}, [divider, dividerProps, processedDirection]);
|
|
56
|
+
}, [classes.divider, divider, dividerProps, processedDirection]);
|
|
54
57
|
return /* @__PURE__ */ jsx(
|
|
55
58
|
"div",
|
|
56
59
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import { Children, useCallback, useMemo, useRef } from \"react\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\nimport { useTheme } from \"@mui/material/styles\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFocus } from \"../Focus\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useWidth } from \"../hooks/useWidth\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { staticClasses, useClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction: any, width: any, breakpoints: any) => {\n if (typeof direction === \"string\") return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const processedDirection = useMemo(\n () => getDirection(direction, width, breakpoints.keys),\n [direction, width, breakpoints],\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (typeof divider === \"boolean\" && divider) {\n return (\n <MuiDivider\n orientation={\n processedDirection === \"column\" ? \"horizontal\" : \"vertical\"\n }\n flexItem={processedDirection === \"row\"}\n role=\"separator\"\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [divider, dividerProps, processedDirection]);\n\n return (\n <div\n ref={containerRef}\n className={cx(\n classes.root,\n classes[processedDirection],\n classes[spacing],\n className,\n )}\n {...others}\n >\n {Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent()}\n {withNavigation ? (\n <HvFocus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={\n processedDirection === \"column\"\n ? 1\n : Children.count(children) || 0\n }\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </HvFocus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8CA,MAAM,eAAe,CAAC,WAAgB,OAAY,gBAAqB;AACrE,MAAI,OAAO,cAAc;AAAiB,WAAA;AAEjC,WAAA,IAAI,YAAY,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;AACvD,QAAI,UAAU,YAAY,CAAC,CAAC,MAAM,QAAW;AACpC,aAAA,UAAU,YAAY,CAAC,CAAC;AAAA,IACjC;AAAA,EACF;AACO,SAAA;AACT;AAOa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,eAAe,CAAC;AAAA,IAChB,GAAG;AAAA,EAAA,IACD,gBAAgB,WAAW,KAAK;AACpC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,QAAQ;AACR,QAAA,eAAe,OAAO,IAAI;AAC1B,QAAA,EAAE,gBAAgB;AAExB,QAAM,qBAAqB;AAAA,IACzB,MAAM,aAAa,WAAW,OAAO,YAAY,IAAI;AAAA,IACrD,CAAC,WAAW,OAAO,WAAW;AAAA,EAAA;AAQ1B,QAAA,sBAAsB,YAAY,MAAM;AACxC,QAAA,OAAO,YAAY,aAAa,SAAS;AAEzC,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aACE,uBAAuB,WAAW,eAAe;AAAA,UAEnD,UAAU,uBAAuB;AAAA,UACjC,MAAK;AAAA,
|
|
1
|
+
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import { Children, useCallback, useMemo, useRef } from \"react\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\nimport { useTheme } from \"@mui/material/styles\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFocus } from \"../Focus\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useWidth } from \"../hooks/useWidth\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { staticClasses, useClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction: any, width: any, breakpoints: any) => {\n if (typeof direction === \"string\") return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const processedDirection = useMemo(\n () => getDirection(direction, width, breakpoints.keys),\n [direction, width, breakpoints],\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (typeof divider === \"boolean\" && divider) {\n return (\n <MuiDivider\n orientation={\n processedDirection === \"column\" ? \"horizontal\" : \"vertical\"\n }\n flexItem={processedDirection === \"row\"}\n role=\"separator\"\n classes={{\n root: classes.divider,\n }}\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [classes.divider, divider, dividerProps, processedDirection]);\n\n return (\n <div\n ref={containerRef}\n className={cx(\n classes.root,\n classes[processedDirection],\n classes[spacing],\n className,\n )}\n {...others}\n >\n {Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent()}\n {withNavigation ? (\n <HvFocus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={\n processedDirection === \"column\"\n ? 1\n : Children.count(children) || 0\n }\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </HvFocus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8CA,MAAM,eAAe,CAAC,WAAgB,OAAY,gBAAqB;AACrE,MAAI,OAAO,cAAc;AAAiB,WAAA;AAEjC,WAAA,IAAI,YAAY,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;AACvD,QAAI,UAAU,YAAY,CAAC,CAAC,MAAM,QAAW;AACpC,aAAA,UAAU,YAAY,CAAC,CAAC;AAAA,IACjC;AAAA,EACF;AACO,SAAA;AACT;AAOa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,eAAe,CAAC;AAAA,IAChB,GAAG;AAAA,EAAA,IACD,gBAAgB,WAAW,KAAK;AACpC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,QAAQ;AACR,QAAA,eAAe,OAAO,IAAI;AAC1B,QAAA,EAAE,gBAAgB;AAExB,QAAM,qBAAqB;AAAA,IACzB,MAAM,aAAa,WAAW,OAAO,YAAY,IAAI;AAAA,IACrD,CAAC,WAAW,OAAO,WAAW;AAAA,EAAA;AAQ1B,QAAA,sBAAsB,YAAY,MAAM;AACxC,QAAA,OAAO,YAAY,aAAa,SAAS;AAEzC,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aACE,uBAAuB,WAAW,eAAe;AAAA,UAEnD,UAAU,uBAAuB;AAAA,UACjC,MAAK;AAAA,UACL,SAAS;AAAA,YACP,MAAM,QAAQ;AAAA,UAChB;AAAA,UACC,GAAG;AAAA,QAAA;AAAA,MAAA;AAAA,IAGV;AACO,WAAA;AAAA,EAAA,GACN,CAAC,QAAQ,SAAS,SAAS,cAAc,kBAAkB,CAAC;AAG7D,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,kBAAkB;AAAA,QAC1B,QAAQ,OAAO;AAAA,QACf;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH,UAAS,SAAA,IAAI,UAAU,CAAC,OAAO,MAAM;AACpC,eAEK,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAW,WAAA,MAAM,KAAK,oBAAoB;AAAA,UAC1C,iBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,eAAe;AAAA,cACf,UAAS;AAAA,cACT,gBACE,uBAAuB,WACnB,IACA,SAAS,MAAM,QAAQ,KAAK;AAAA,cAElC,aAAY;AAAA,cAEZ,UAAC,oBAAA,OAAA,EAAI,WAAU,SAAS,UAAM,OAAA;AAAA,YAAA;AAAA,UAAA,IAGhC;AAAA,QAEJ,EAAA,CAAA;AAAA,MAAA,CAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.styles.js","sources":["../../../src/Stack/Stack.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvStack\", {\n root: {\n display: \"flex\",\n },\n column: {\n flexDirection: \"column\",\n },\n row: {\n flexDirection: \"row\",\n },\n xs: {\n gap: theme.space.xs,\n },\n sm: {\n gap: theme.space.sm,\n },\n md: {\n gap: theme.spacing(4),\n },\n lg: {\n gap: theme.spacing(6),\n },\n xl: {\n gap: theme.spacing(11),\n },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM;AAAA,IACJ,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,IACN,eAAe;AAAA,EACjB;AAAA,EACA,KAAK;AAAA,IACH,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,CAAC;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,CAAC;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,EAAE;AAAA,EACvB;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Stack.styles.js","sources":["../../../src/Stack/Stack.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvStack\", {\n root: {\n display: \"flex\",\n },\n column: {\n flexDirection: \"column\",\n },\n row: {\n flexDirection: \"row\",\n },\n divider: {\n borderColor: theme.colors.atmo4,\n },\n xs: {\n gap: theme.space.xs,\n },\n sm: {\n gap: theme.space.sm,\n },\n md: {\n gap: theme.spacing(4),\n },\n lg: {\n gap: theme.spacing(6),\n },\n xl: {\n gap: theme.spacing(11),\n },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM;AAAA,IACJ,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,IACN,eAAe;AAAA,EACjB;AAAA,EACA,KAAK;AAAA,IACH,eAAe;AAAA,EACjB;AAAA,EACA,SAAS;AAAA,IACP,aAAa,MAAM,OAAO;AAAA,EAC5B;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,CAAC;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,CAAC;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,KAAK,MAAM,QAAQ,EAAE;AAAA,EACvB;AACF,CAAC;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -569,8 +569,8 @@ export declare const checkValidHexColorValue: (value?: string) => boolean;
|
|
|
569
569
|
|
|
570
570
|
export declare const colorPickerClasses: {
|
|
571
571
|
colorPicker: "HvColorPicker-colorPicker";
|
|
572
|
-
label: "HvColorPicker-label";
|
|
573
572
|
description: "HvColorPicker-description";
|
|
573
|
+
label: "HvColorPicker-label";
|
|
574
574
|
root: "HvColorPicker-root";
|
|
575
575
|
panel: "HvColorPicker-panel";
|
|
576
576
|
headerColorValue: "HvColorPicker-headerColorValue";
|
|
@@ -623,8 +623,8 @@ name: Name, stylesObject: Record<ClassName, CSSInterpolation>): {
|
|
|
623
623
|
export declare const createTheme: (props: HvCreateThemeProps) => HvTheme | HvThemeStructure;
|
|
624
624
|
|
|
625
625
|
export declare const datePickerClasses: {
|
|
626
|
-
label: "HvDatePicker-label";
|
|
627
626
|
description: "HvDatePicker-description";
|
|
627
|
+
label: "HvDatePicker-label";
|
|
628
628
|
root: "HvDatePicker-root";
|
|
629
629
|
panel: "HvDatePicker-panel";
|
|
630
630
|
icon: "HvDatePicker-icon";
|
|
@@ -789,8 +789,8 @@ declare interface Descriptor {
|
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
export declare const dialogActionClasses: {
|
|
792
|
-
spacing: "HvDialog-Action-spacing";
|
|
793
792
|
root: "HvDialog-Action-root";
|
|
793
|
+
spacing: "HvDialog-Action-spacing";
|
|
794
794
|
fullscreen: "HvDialog-Action-fullscreen";
|
|
795
795
|
};
|
|
796
796
|
|
|
@@ -843,8 +843,8 @@ export declare const drawerClasses: {
|
|
|
843
843
|
};
|
|
844
844
|
|
|
845
845
|
export declare const dropdownClasses: {
|
|
846
|
-
label: "HvDropdown-label";
|
|
847
846
|
description: "HvDropdown-description";
|
|
847
|
+
label: "HvDropdown-label";
|
|
848
848
|
root: "HvDropdown-root";
|
|
849
849
|
placeholder: "HvDropdown-placeholder";
|
|
850
850
|
disabled: "HvDropdown-disabled";
|
|
@@ -913,8 +913,8 @@ export declare const fileUploaderPreviewClasses: {
|
|
|
913
913
|
};
|
|
914
914
|
|
|
915
915
|
export declare const filterGroupClasses: {
|
|
916
|
-
label: "HvFilterGroup-label";
|
|
917
916
|
description: "HvFilterGroup-description";
|
|
917
|
+
label: "HvFilterGroup-label";
|
|
918
918
|
root: "HvFilterGroup-root";
|
|
919
919
|
error: "HvFilterGroup-error";
|
|
920
920
|
labelContainer: "HvFilterGroup-labelContainer";
|
|
@@ -7070,6 +7070,7 @@ export declare const HvTypography: <C extends ElementType<any, keyof JSX_2.Intri
|
|
|
7070
7070
|
display: string;
|
|
7071
7071
|
"5xlTitle": string;
|
|
7072
7072
|
"4xlTitle": string;
|
|
7073
|
+
link: string;
|
|
7073
7074
|
title1: string;
|
|
7074
7075
|
title2: string;
|
|
7075
7076
|
title3: string;
|
|
@@ -7085,7 +7086,6 @@ export declare const HvTypography: <C extends ElementType<any, keyof JSX_2.Intri
|
|
|
7085
7086
|
xxsTitle: string;
|
|
7086
7087
|
sectionTitle: string;
|
|
7087
7088
|
placeholderText: string;
|
|
7088
|
-
link: string;
|
|
7089
7089
|
disabledText: string;
|
|
7090
7090
|
selectedNavText: string;
|
|
7091
7091
|
vizTextDisabled: string;
|
|
@@ -7656,8 +7656,8 @@ export declare const inlineEditorClasses: {
|
|
|
7656
7656
|
};
|
|
7657
7657
|
|
|
7658
7658
|
export declare const inputClasses: {
|
|
7659
|
-
label: "HvInput-label";
|
|
7660
7659
|
description: "HvInput-description";
|
|
7660
|
+
label: "HvInput-label";
|
|
7661
7661
|
root: "HvInput-root";
|
|
7662
7662
|
inputBorderContainer: "HvInput-inputBorderContainer";
|
|
7663
7663
|
inputRoot: "HvInput-inputRoot";
|
|
@@ -8050,8 +8050,8 @@ export declare const sectionClasses: {
|
|
|
8050
8050
|
};
|
|
8051
8051
|
|
|
8052
8052
|
export declare const selectClasses: {
|
|
8053
|
-
label: "HvSelect-label";
|
|
8054
8053
|
description: "HvSelect-description";
|
|
8054
|
+
label: "HvSelect-label";
|
|
8055
8055
|
root: "HvSelect-root";
|
|
8056
8056
|
panel: "HvSelect-panel";
|
|
8057
8057
|
disabled: "HvSelect-disabled";
|
|
@@ -8068,8 +8068,8 @@ export declare const selectClasses: {
|
|
|
8068
8068
|
export declare const selectionListClasses: {
|
|
8069
8069
|
vertical: "HvSelectionList-vertical";
|
|
8070
8070
|
horizontal: "HvSelectionList-horizontal";
|
|
8071
|
-
label: "HvSelectionList-label";
|
|
8072
8071
|
description: "HvSelectionList-description";
|
|
8072
|
+
label: "HvSelectionList-label";
|
|
8073
8073
|
root: "HvSelectionList-root";
|
|
8074
8074
|
listbox: "HvSelectionList-listbox";
|
|
8075
8075
|
error: "HvSelectionList-error";
|
|
@@ -8157,6 +8157,7 @@ export declare const stackClasses: {
|
|
|
8157
8157
|
lg: "HvStack-lg";
|
|
8158
8158
|
xl: "HvStack-xl";
|
|
8159
8159
|
root: "HvStack-root";
|
|
8160
|
+
divider: "HvStack-divider";
|
|
8160
8161
|
row: "HvStack-row";
|
|
8161
8162
|
column: "HvStack-column";
|
|
8162
8163
|
};
|
|
@@ -8316,8 +8317,8 @@ export declare const tagClasses: {
|
|
|
8316
8317
|
};
|
|
8317
8318
|
|
|
8318
8319
|
export declare const tagsInputClasses: {
|
|
8319
|
-
label: "HvTagsInput-label";
|
|
8320
8320
|
description: "HvTagsInput-description";
|
|
8321
|
+
label: "HvTagsInput-label";
|
|
8321
8322
|
root: "HvTagsInput-root";
|
|
8322
8323
|
disabled: "HvTagsInput-disabled";
|
|
8323
8324
|
readOnly: "HvTagsInput-readOnly";
|
|
@@ -8344,8 +8345,8 @@ export declare const tagsInputClasses: {
|
|
|
8344
8345
|
};
|
|
8345
8346
|
|
|
8346
8347
|
export declare const textAreaClasses: {
|
|
8347
|
-
label: "HvTextArea-label";
|
|
8348
8348
|
description: "HvTextArea-description";
|
|
8349
|
+
label: "HvTextArea-label";
|
|
8349
8350
|
root: "HvTextArea-root";
|
|
8350
8351
|
disabled: "HvTextArea-disabled";
|
|
8351
8352
|
input: "HvTextArea-input";
|
|
@@ -8369,8 +8370,8 @@ export declare const timeAgoClasses: {
|
|
|
8369
8370
|
export declare type TimeFormat = "12" | "24";
|
|
8370
8371
|
|
|
8371
8372
|
export declare const timePickerClasses: {
|
|
8372
|
-
label: "HvTimePicker-label";
|
|
8373
8373
|
description: "HvTimePicker-description";
|
|
8374
|
+
label: "HvTimePicker-label";
|
|
8374
8375
|
root: "HvTimePicker-root";
|
|
8375
8376
|
placeholder: "HvTimePicker-placeholder";
|
|
8376
8377
|
icon: "HvTimePicker-icon";
|
|
@@ -8420,8 +8421,8 @@ export declare const treeViewClasses: {
|
|
|
8420
8421
|
|
|
8421
8422
|
export declare const treeViewItemClasses: {
|
|
8422
8423
|
content: "HvVerticalNavigationTreeViewItem-content";
|
|
8423
|
-
label: "HvVerticalNavigationTreeViewItem-label";
|
|
8424
8424
|
link: "HvVerticalNavigationTreeViewItem-link";
|
|
8425
|
+
label: "HvVerticalNavigationTreeViewItem-label";
|
|
8425
8426
|
disabled: "HvVerticalNavigationTreeViewItem-disabled";
|
|
8426
8427
|
selectable: "HvVerticalNavigationTreeViewItem-selectable";
|
|
8427
8428
|
selected: "HvVerticalNavigationTreeViewItem-selected";
|
|
@@ -8461,6 +8462,7 @@ export declare const typographyClasses: {
|
|
|
8461
8462
|
display: "HvTypography-display";
|
|
8462
8463
|
"5xlTitle": "HvTypography-5xlTitle";
|
|
8463
8464
|
"4xlTitle": "HvTypography-4xlTitle";
|
|
8465
|
+
link: "HvTypography-link";
|
|
8464
8466
|
title1: "HvTypography-title1";
|
|
8465
8467
|
title2: "HvTypography-title2";
|
|
8466
8468
|
title3: "HvTypography-title3";
|
|
@@ -8476,7 +8478,6 @@ export declare const typographyClasses: {
|
|
|
8476
8478
|
xxsTitle: "HvTypography-xxsTitle";
|
|
8477
8479
|
sectionTitle: "HvTypography-sectionTitle";
|
|
8478
8480
|
placeholderText: "HvTypography-placeholderText";
|
|
8479
|
-
link: "HvTypography-link";
|
|
8480
8481
|
disabledText: "HvTypography-disabledText";
|
|
8481
8482
|
selectedNavText: "HvTypography-selectedNavText";
|
|
8482
8483
|
vizTextDisabled: "HvTypography-vizTextDisabled";
|
|
@@ -8500,11 +8501,12 @@ export declare type UseBulkActionsProps = (<D extends object = Record<string, un
|
|
|
8500
8501
|
pluginName: string;
|
|
8501
8502
|
};
|
|
8502
8503
|
|
|
8503
|
-
declare const useClasses: (classesProp?: Partial<Record<"display" | "5xlTitle" | "4xlTitle" | "title1" | "title2" | "title3" | "title4" | "label" | "body" | "captionLabel" | "caption1" | "caption2" | "xxlTitle" | "lTitle" | "sTitle" | "xxsTitle" | "sectionTitle" | "placeholderText" | "
|
|
8504
|
+
declare const useClasses: (classesProp?: Partial<Record<"display" | "5xlTitle" | "4xlTitle" | "link" | "title1" | "title2" | "title3" | "title4" | "label" | "body" | "captionLabel" | "caption1" | "caption2" | "xxlTitle" | "lTitle" | "sTitle" | "xxsTitle" | "sectionTitle" | "placeholderText" | "disabledText" | "selectedNavText" | "vizTextDisabled" | "xsInlineLink" | "root" | "disabled" | "isLink" | "noWrap" | "3xlTitle" | "xlTitle" | "mTitle" | "xsTitle" | "highlightText" | "normalText" | "vizText", string>>, addStatic?: boolean) => {
|
|
8504
8505
|
classes: {
|
|
8505
8506
|
display: string;
|
|
8506
8507
|
"5xlTitle": string;
|
|
8507
8508
|
"4xlTitle": string;
|
|
8509
|
+
link: string;
|
|
8508
8510
|
title1: string;
|
|
8509
8511
|
title2: string;
|
|
8510
8512
|
title3: string;
|
|
@@ -8520,7 +8522,6 @@ declare const useClasses: (classesProp?: Partial<Record<"display" | "5xlTitle" |
|
|
|
8520
8522
|
xxsTitle: string;
|
|
8521
8523
|
sectionTitle: string;
|
|
8522
8524
|
placeholderText: string;
|
|
8523
|
-
link: string;
|
|
8524
8525
|
disabledText: string;
|
|
8525
8526
|
selectedNavText: string;
|
|
8526
8527
|
vizTextDisabled: string;
|
|
@@ -8648,7 +8649,7 @@ declare const useClasses_104: (classesProp?: Partial<Record<"snackItemRoot", str
|
|
|
8648
8649
|
cx: (...args: any) => string;
|
|
8649
8650
|
};
|
|
8650
8651
|
|
|
8651
|
-
declare const useClasses_105: (classesProp?: Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "root" | "row" | "column", string>>, addStatic?: boolean) => {
|
|
8652
|
+
declare const useClasses_105: (classesProp?: Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "root" | "divider" | "row" | "column", string>>, addStatic?: boolean) => {
|
|
8652
8653
|
classes: {
|
|
8653
8654
|
xs: string;
|
|
8654
8655
|
sm: string;
|
|
@@ -8656,6 +8657,7 @@ declare const useClasses_105: (classesProp?: Partial<Record<"xs" | "sm" | "md" |
|
|
|
8656
8657
|
lg: string;
|
|
8657
8658
|
xl: string;
|
|
8658
8659
|
root: string;
|
|
8660
|
+
divider: string;
|
|
8659
8661
|
row: string;
|
|
8660
8662
|
column: string;
|
|
8661
8663
|
};
|
|
@@ -8717,10 +8719,10 @@ declare const useClasses_109: (classesProp?: Partial<Record<"root", string>>, ad
|
|
|
8717
8719
|
cx: (...args: any) => string;
|
|
8718
8720
|
};
|
|
8719
8721
|
|
|
8720
|
-
declare const useClasses_11: (classesProp?: Partial<Record<"
|
|
8722
|
+
declare const useClasses_11: (classesProp?: Partial<Record<"description" | "label" | "root" | "panel" | "disabled" | "readOnly" | "select" | "popper" | "error" | "invalid" | "labelContainer" | "panelOpenedUp" | "panelOpenedDown", string>>, addStatic?: boolean) => {
|
|
8721
8723
|
classes: {
|
|
8722
|
-
label: string;
|
|
8723
8724
|
description: string;
|
|
8725
|
+
label: string;
|
|
8724
8726
|
root: string;
|
|
8725
8727
|
panel: string;
|
|
8726
8728
|
disabled: string;
|
|
@@ -8789,10 +8791,10 @@ declare const useClasses_112: (classesProp?: Partial<Record<"root" | "indicator"
|
|
|
8789
8791
|
cx: (...args: any) => string;
|
|
8790
8792
|
};
|
|
8791
8793
|
|
|
8792
|
-
declare const useClasses_113: (classesProp?: Partial<Record<"
|
|
8794
|
+
declare const useClasses_113: (classesProp?: Partial<Record<"description" | "label" | "root" | "disabled" | "readOnly" | "input" | "tagsList" | "error" | "invalid" | "labelContainer" | "resizable" | "suggestionsContainer" | "suggestionList" | "inputExtension" | "chipRoot" | "listItemGutters" | "listItemRoot" | "characterCounter" | "tagInputContainerRoot" | "tagInputRoot" | "tagSelected" | "tagInputBorderContainer" | "tagInputRootFocused" | "tagInputRootEmpty" | "singleLine", string>>, addStatic?: boolean) => {
|
|
8793
8795
|
classes: {
|
|
8794
|
-
label: string;
|
|
8795
8796
|
description: string;
|
|
8797
|
+
label: string;
|
|
8796
8798
|
root: string;
|
|
8797
8799
|
disabled: string;
|
|
8798
8800
|
readOnly: string;
|
|
@@ -8824,10 +8826,10 @@ declare const useClasses_113: (classesProp?: Partial<Record<"label" | "descripti
|
|
|
8824
8826
|
cx: (...args: any) => string;
|
|
8825
8827
|
};
|
|
8826
8828
|
|
|
8827
|
-
declare const useClasses_114: (classesProp?: Partial<Record<"
|
|
8829
|
+
declare const useClasses_114: (classesProp?: Partial<Record<"description" | "label" | "root" | "disabled" | "input" | "error" | "invalid" | "labelContainer" | "resizable" | "inputResizable" | "characterCounter" | "baseInput", string>>, addStatic?: boolean) => {
|
|
8828
8830
|
classes: {
|
|
8829
|
-
label: string;
|
|
8830
8831
|
description: string;
|
|
8832
|
+
label: string;
|
|
8831
8833
|
root: string;
|
|
8832
8834
|
disabled: string;
|
|
8833
8835
|
input: string;
|
|
@@ -8857,10 +8859,10 @@ declare const useClasses_115: (classesProp?: Partial<Record<"root", string>>, ad
|
|
|
8857
8859
|
cx: (...args: any) => string;
|
|
8858
8860
|
};
|
|
8859
8861
|
|
|
8860
|
-
declare const useClasses_116: (classesProp?: Partial<Record<"
|
|
8862
|
+
declare const useClasses_116: (classesProp?: Partial<Record<"description" | "label" | "root" | "placeholder" | "icon" | "error" | "labelContainer" | "dropdownHeader" | "dropdownHeaderInvalid" | "dropdownHeaderOpen" | "placeholderDisabled" | "dropdownPanel" | "timePopperContainer", string>>, addStatic?: boolean) => {
|
|
8861
8863
|
classes: {
|
|
8862
|
-
label: string;
|
|
8863
8864
|
description: string;
|
|
8865
|
+
label: string;
|
|
8864
8866
|
root: string;
|
|
8865
8867
|
placeholder: string;
|
|
8866
8868
|
icon: string;
|
|
@@ -9044,11 +9046,11 @@ declare const useClasses_126: (classesProp?: Partial<Record<"root", string>>, ad
|
|
|
9044
9046
|
cx: (...args: any) => string;
|
|
9045
9047
|
};
|
|
9046
9048
|
|
|
9047
|
-
declare const useClasses_127: (classesProp?: Partial<Record<"content" | "
|
|
9049
|
+
declare const useClasses_127: (classesProp?: Partial<Record<"content" | "link" | "label" | "disabled" | "selectable" | "selected" | "hide" | "expanded" | "unselectable" | "group" | "node" | "focused" | "expandable" | "labelIcon" | "collapsed" | "minimized" | "unselected" | "labelExpandable", string>>, addStatic?: boolean) => {
|
|
9048
9050
|
classes: {
|
|
9049
9051
|
content: string;
|
|
9050
|
-
label: string;
|
|
9051
9052
|
link: string;
|
|
9053
|
+
label: string;
|
|
9052
9054
|
disabled: string;
|
|
9053
9055
|
selectable: string;
|
|
9054
9056
|
selected: string;
|
|
@@ -9129,12 +9131,12 @@ declare const useClasses_14: (classesProp?: Partial<Record<"root", string>>, add
|
|
|
9129
9131
|
cx: (...args: any) => string;
|
|
9130
9132
|
};
|
|
9131
9133
|
|
|
9132
|
-
declare const useClasses_15: (classesProp?: Partial<Record<"vertical" | "horizontal" | "
|
|
9134
|
+
declare const useClasses_15: (classesProp?: Partial<Record<"vertical" | "horizontal" | "description" | "label" | "root" | "listbox" | "error" | "invalid", string>>, addStatic?: boolean) => {
|
|
9133
9135
|
classes: {
|
|
9134
9136
|
vertical: string;
|
|
9135
9137
|
horizontal: string;
|
|
9136
|
-
label: string;
|
|
9137
9138
|
description: string;
|
|
9139
|
+
label: string;
|
|
9138
9140
|
root: string;
|
|
9139
9141
|
listbox: string;
|
|
9140
9142
|
error: string;
|
|
@@ -9719,10 +9721,10 @@ declare const useClasses_44: (classesProp?: Partial<Record<"image" | "slide", st
|
|
|
9719
9721
|
cx: (...args: any) => string;
|
|
9720
9722
|
};
|
|
9721
9723
|
|
|
9722
|
-
declare const useClasses_45: (classesProp?: Partial<Record<"
|
|
9724
|
+
declare const useClasses_45: (classesProp?: Partial<Record<"description" | "label" | "root" | "inputBorderContainer" | "inputRoot" | "inputRootFocused" | "inputRootMultiline" | "input" | "icon" | "error" | "adornmentButton" | "labelContainer" | "inputRootDisabled" | "adornmentsBox" | "iconClear" | "hasSuggestions" | "suggestionsContainer" | "suggestionList" | "inputExtension", string>>, addStatic?: boolean) => {
|
|
9723
9725
|
classes: {
|
|
9724
|
-
label: string;
|
|
9725
9726
|
description: string;
|
|
9727
|
+
label: string;
|
|
9726
9728
|
root: string;
|
|
9727
9729
|
inputBorderContainer: string;
|
|
9728
9730
|
inputRoot: string;
|
|
@@ -9791,11 +9793,11 @@ declare const useClasses_47: (classesProp?: Partial<Record<"vertical" | "horizon
|
|
|
9791
9793
|
cx: (...args: any) => string;
|
|
9792
9794
|
};
|
|
9793
9795
|
|
|
9794
|
-
declare const useClasses_48: (classesProp?: Partial<Record<"colorPicker" | "
|
|
9796
|
+
declare const useClasses_48: (classesProp?: Partial<Record<"colorPicker" | "description" | "label" | "root" | "panel" | "headerColorValue" | "recommendedColorsRoot" | "labelContainer" | "headerColorIcon" | "colorPickerIcon" | "dropdownRootIconOnly" | "headerColorIconOnly" | "pickerFields", string>>, addStatic?: boolean) => {
|
|
9795
9797
|
classes: {
|
|
9796
9798
|
colorPicker: string;
|
|
9797
|
-
label: string;
|
|
9798
9799
|
description: string;
|
|
9800
|
+
label: string;
|
|
9799
9801
|
root: string;
|
|
9800
9802
|
panel: string;
|
|
9801
9803
|
headerColorValue: string;
|
|
@@ -9994,10 +9996,10 @@ declare const useClasses_56: (classesProp?: Partial<Record<"root" | "sortDropdow
|
|
|
9994
9996
|
cx: (...args: any) => string;
|
|
9995
9997
|
};
|
|
9996
9998
|
|
|
9997
|
-
declare const useClasses_57: (classesProp?: Partial<Record<"
|
|
9999
|
+
declare const useClasses_57: (classesProp?: Partial<Record<"description" | "label" | "root" | "placeholder" | "disabled" | "readOnly" | "placeholderClosed" | "error" | "arrow" | "dropdown" | "labelContainer" | "selectionDisabled" | "dropdownHeader" | "dropdownHeaderInvalid" | "dropdownHeaderOpen" | "dropdownListContainer" | "rootList", string>>, addStatic?: boolean) => {
|
|
9998
10000
|
classes: {
|
|
9999
|
-
label: string;
|
|
10000
10001
|
description: string;
|
|
10002
|
+
label: string;
|
|
10001
10003
|
root: string;
|
|
10002
10004
|
placeholder: string;
|
|
10003
10005
|
disabled: string;
|
|
@@ -10039,10 +10041,10 @@ declare const useClasses_58: (classesProp?: Partial<Record<"selection" | "select
|
|
|
10039
10041
|
cx: (...args: any) => string;
|
|
10040
10042
|
};
|
|
10041
10043
|
|
|
10042
|
-
declare const useClasses_59: (classesProp?: Partial<Record<"
|
|
10044
|
+
declare const useClasses_59: (classesProp?: Partial<Record<"description" | "label" | "root" | "panel" | "icon" | "inputText" | "action" | "error" | "dropdown" | "labelContainer" | "actionContainer" | "dropdownHeaderInvalid" | "dropdownHeaderOpen" | "leftContainer" | "rightContainer" | "dateText", string>>, addStatic?: boolean) => {
|
|
10043
10045
|
classes: {
|
|
10044
|
-
label: string;
|
|
10045
10046
|
description: string;
|
|
10047
|
+
label: string;
|
|
10046
10048
|
root: string;
|
|
10047
10049
|
panel: string;
|
|
10048
10050
|
icon: string;
|
|
@@ -10108,10 +10110,10 @@ declare const useClasses_61: (classesProp?: Partial<Record<"root" | "textContent
|
|
|
10108
10110
|
cx: (...args: any) => string;
|
|
10109
10111
|
};
|
|
10110
10112
|
|
|
10111
|
-
declare const useClasses_62: (classesProp?: Partial<Record<"
|
|
10113
|
+
declare const useClasses_62: (classesProp?: Partial<Record<"root" | "spacing" | "fullscreen", string>>, addStatic?: boolean) => {
|
|
10112
10114
|
classes: {
|
|
10113
|
-
spacing: string;
|
|
10114
10115
|
root: string;
|
|
10116
|
+
spacing: string;
|
|
10115
10117
|
fullscreen: string;
|
|
10116
10118
|
};
|
|
10117
10119
|
css: {
|
|
@@ -10247,10 +10249,10 @@ declare const useClasses_7: (classesProp?: Partial<Record<"root", string>>, addS
|
|
|
10247
10249
|
cx: (...args: any) => string;
|
|
10248
10250
|
};
|
|
10249
10251
|
|
|
10250
|
-
declare const useClasses_70: (classesProp?: Partial<Record<"
|
|
10252
|
+
declare const useClasses_70: (classesProp?: Partial<Record<"description" | "label" | "root" | "error" | "labelContainer", string>>, addStatic?: boolean) => {
|
|
10251
10253
|
classes: {
|
|
10252
|
-
label: string;
|
|
10253
10254
|
description: string;
|
|
10255
|
+
label: string;
|
|
10254
10256
|
root: string;
|
|
10255
10257
|
error: string;
|
|
10256
10258
|
labelContainer: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.66.
|
|
3
|
+
"version": "5.66.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@emotion/css": "^11.11.2",
|
|
34
34
|
"@emotion/serialize": "^1.1.2",
|
|
35
35
|
"@emotion/utils": "^1.2.1",
|
|
36
|
-
"@hitachivantara/uikit-react-icons": "^5.9.
|
|
37
|
-
"@hitachivantara/uikit-react-shared": "^5.1.
|
|
38
|
-
"@hitachivantara/uikit-styles": "^5.
|
|
36
|
+
"@hitachivantara/uikit-react-icons": "^5.9.11",
|
|
37
|
+
"@hitachivantara/uikit-react-shared": "^5.1.41",
|
|
38
|
+
"@hitachivantara/uikit-styles": "^5.30.0",
|
|
39
39
|
"@internationalized/date": "^3.2.0",
|
|
40
40
|
"@mui/base": "^5.0.0-beta.34",
|
|
41
41
|
"@popperjs/core": "^2.11.8",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"access": "public",
|
|
63
63
|
"directory": "package"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "394f8f505809bbc92342cdeb8ec08f157b079183",
|
|
66
66
|
"exports": {
|
|
67
67
|
".": {
|
|
68
68
|
"require": "./dist/cjs/index.cjs",
|