@elliemae/ds-slider 3.22.0-next.3 → 3.22.0-next.31
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/DSSlider.js.map +3 -3
- package/dist/cjs/components/SliderImp.js +55 -81
- package/dist/cjs/components/SliderImp.js.map +4 -4
- package/dist/cjs/components/Thumb.js.map +1 -1
- package/dist/cjs/components/TickMarks.js.map +1 -1
- package/dist/cjs/components/TickMarksValues.js.map +1 -1
- package/dist/cjs/components/TooltipWithLabelAndValue.js +84 -0
- package/dist/cjs/components/TooltipWithLabelAndValue.js.map +7 -0
- package/dist/cjs/components/Track.js.map +1 -1
- package/dist/cjs/components/context.js.map +1 -1
- package/dist/cjs/components/styled.js.map +1 -1
- package/dist/cjs/components/useOptionalCustomTickMarksValues.js +74 -0
- package/dist/cjs/components/useOptionalCustomTickMarksValues.js.map +7 -0
- package/dist/cjs/components/useSelectedValuesArray.js +64 -0
- package/dist/cjs/components/useSelectedValuesArray.js.map +7 -0
- package/dist/cjs/components/utils.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/prop-types.js +13 -14
- package/dist/cjs/prop-types.js.map +3 -3
- package/dist/esm/DSSlider.js.map +3 -3
- package/dist/esm/components/SliderImp.js +58 -84
- package/dist/esm/components/SliderImp.js.map +4 -4
- package/dist/esm/components/Thumb.js.map +1 -1
- package/dist/esm/components/TickMarks.js.map +1 -1
- package/dist/esm/components/TickMarksValues.js.map +1 -1
- package/dist/esm/components/TooltipWithLabelAndValue.js +54 -0
- package/dist/esm/components/TooltipWithLabelAndValue.js.map +7 -0
- package/dist/esm/components/Track.js.map +1 -1
- package/dist/esm/components/context.js.map +1 -1
- package/dist/esm/components/styled.js.map +1 -1
- package/dist/esm/components/useOptionalCustomTickMarksValues.js +44 -0
- package/dist/esm/components/useOptionalCustomTickMarksValues.js.map +7 -0
- package/dist/esm/components/useSelectedValuesArray.js +34 -0
- package/dist/esm/components/useSelectedValuesArray.js.map +7 -0
- package/dist/esm/components/utils.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/prop-types.js +13 -14
- package/dist/esm/prop-types.js.map +3 -3
- package/dist/types/DSSlider.d.ts +3 -2
- package/dist/types/components/SliderImp.d.ts +3 -1
- package/dist/types/components/TooltipWithLabelAndValue.d.ts +12 -0
- package/dist/types/components/useOptionalCustomTickMarksValues.d.ts +7 -0
- package/dist/types/components/useSelectedValuesArray.d.ts +7 -0
- package/dist/types/prop-types.d.ts +28 -0
- package/package.json +15 -15
package/dist/cjs/DSSlider.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/DSSlider.tsx", "
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport SliderImp from './components/SliderImp.js';\nimport { defaultProps, sliderPropTypes } from './prop-types.js';\n\nconst DSSlider = (props) => <SliderImp {...props} />;\n\nDSSlider.defaultProps = defaultProps;\nDSSlider.propTypes = sliderPropTypes;\nDSSlider.displayName = 'DSSlider';\nconst DSSliderWithSchema = describe(DSSlider);\nDSSliderWithSchema.propTypes = sliderPropTypes;\n\nexport { DSSlider, DSSliderWithSchema };\nexport default DSSlider;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
3
|
+
"sources": ["../../src/DSSlider.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport SliderImp from './components/SliderImp.js';\nimport { defaultProps, sliderPropTypes, type DSSliderT } from './prop-types.js';\n\nconst DSSlider = (props: DSSliderT.Props) => <SliderImp {...props} />;\n\nDSSlider.defaultProps = defaultProps;\nDSSlider.propTypes = sliderPropTypes;\nDSSlider.displayName = 'DSSlider';\nconst DSSliderWithSchema = describe(DSSlider);\nDSSliderWithSchema.propTypes = sliderPropTypes;\n\nexport { DSSlider, DSSliderWithSchema };\nexport default DSSlider;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKsB;AAJ7C,8BAAyB;AACzB,uBAAsB;AACtB,wBAA8D;AAE9D,MAAM,WAAW,CAAC,UAA2B,4CAAC,iBAAAA,SAAA,EAAW,GAAG,OAAO;AAEnE,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,MAAM,yBAAqB,kCAAS,QAAQ;AAC5C,mBAAmB,YAAY;AAG/B,IAAO,mBAAQ;",
|
|
6
6
|
"names": ["SliderImp"]
|
|
7
7
|
}
|
|
@@ -33,29 +33,34 @@ __export(SliderImp_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(SliderImp_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_react = require("react");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_uuid = require("uuid");
|
|
38
38
|
var import_react_range = require("react-range");
|
|
39
39
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
40
|
-
var import_ds_truncated_tooltip_text =
|
|
40
|
+
var import_ds_truncated_tooltip_text = require("@elliemae/ds-truncated-tooltip-text");
|
|
41
41
|
var import_ds_grid = require("@elliemae/ds-grid");
|
|
42
42
|
var import_ds_system = require("@elliemae/ds-system");
|
|
43
43
|
var import_Track = __toESM(require("./Track.js"));
|
|
44
44
|
var import_Thumb = __toESM(require("./Thumb.js"));
|
|
45
45
|
var import_styled = require("./styled.js");
|
|
46
|
-
var import_utils = require("./utils.js");
|
|
47
46
|
var import_context = require("./context.js");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
var import_useOptionalCustomTickMarksValues = require("./useOptionalCustomTickMarksValues.js");
|
|
48
|
+
var import_useSelectedValuesArray = require("./useSelectedValuesArray.js");
|
|
49
|
+
var import_TooltipWithLabelAndValue = require("./TooltipWithLabelAndValue.js");
|
|
50
|
+
const useResetInternalValueOnWithTwoHandlesChange = ({
|
|
51
|
+
withTwoHandles,
|
|
52
|
+
setRangeValues,
|
|
53
|
+
parsedMinValue,
|
|
54
|
+
parsedMaxValue
|
|
55
|
+
}) => {
|
|
56
|
+
const prevWithTwoHandles = (0, import_ds_utilities.usePrevious)(withTwoHandles);
|
|
57
|
+
import_react.default.useEffect(() => {
|
|
58
|
+
if (!prevWithTwoHandles && withTwoHandles) {
|
|
59
|
+
setRangeValues([parsedMinValue, parsedMaxValue]);
|
|
60
|
+
} else if (prevWithTwoHandles && !withTwoHandles) {
|
|
61
|
+
setRangeValues([parsedMinValue]);
|
|
62
|
+
}
|
|
63
|
+
}, [withTwoHandles]);
|
|
59
64
|
};
|
|
60
65
|
const SliderImp = (props) => {
|
|
61
66
|
const {
|
|
@@ -63,79 +68,36 @@ const SliderImp = (props) => {
|
|
|
63
68
|
disabled,
|
|
64
69
|
label,
|
|
65
70
|
labelWithValue,
|
|
66
|
-
minValue,
|
|
67
|
-
maxValue,
|
|
68
|
-
step,
|
|
69
71
|
onChange,
|
|
70
72
|
withTickMarks,
|
|
71
73
|
withTickMarksValues,
|
|
72
74
|
withTwoHandles,
|
|
73
75
|
customTickMarksValues,
|
|
74
|
-
zIndex
|
|
76
|
+
zIndex,
|
|
77
|
+
controlledValue
|
|
75
78
|
} = props;
|
|
76
|
-
const ref =
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const parsedStep = (0, import_react.useMemo)(() => {
|
|
90
|
-
if (customTickMarksValues?.length)
|
|
91
|
-
return 1;
|
|
92
|
-
return step;
|
|
93
|
-
}, [customTickMarksValues?.length, step]);
|
|
94
|
-
const parsedValuesArray = (0, import_react.useMemo)(() => {
|
|
95
|
-
if (customTickMarksValues?.length)
|
|
96
|
-
return customTickMarksValues;
|
|
97
|
-
const newLength = Math.ceil(maxValue / step);
|
|
98
|
-
const valuesArray = [];
|
|
99
|
-
for (let i = 0; i <= newLength; i += 1) {
|
|
100
|
-
valuesArray.push(step * i);
|
|
101
|
-
}
|
|
102
|
-
return valuesArray;
|
|
103
|
-
}, [customTickMarksValues?.length, minValue, maxValue, step]);
|
|
104
|
-
const [rangeValues, setRangeValues] = (0, import_react.useState)(withTwoHandles ? [parsedMinValue, parsedMaxValue] : [parsedMinValue]);
|
|
105
|
-
const [fullSelectedValues, setFullSelectedValues] = (0, import_react.useState)([]);
|
|
106
|
-
(0, import_react.useEffect)(() => {
|
|
107
|
-
const selectedRangeValues = getSubArrayFromRange(parsedValuesArray, rangeValues, !!customTickMarksValues?.length);
|
|
108
|
-
setFullSelectedValues(selectedRangeValues);
|
|
109
|
-
}, [parsedValuesArray, rangeValues, customTickMarksValues?.length]);
|
|
110
|
-
const prevWithTwoHandles = (0, import_ds_utilities.usePrevious)(withTwoHandles);
|
|
111
|
-
const resizeHandler = () => {
|
|
112
|
-
setWidth(0);
|
|
113
|
-
setWidth(ref.current?.clientWidth);
|
|
114
|
-
};
|
|
115
|
-
(0, import_react.useEffect)(() => {
|
|
116
|
-
window.addEventListener("resize", resizeHandler);
|
|
117
|
-
return () => window.removeEventListener("resize", resizeHandler);
|
|
79
|
+
const ref = import_react.default.useRef();
|
|
80
|
+
const sliderUUID = import_react.default.useMemo(() => (0, import_uuid.v4)(), []);
|
|
81
|
+
const { parsedMinValue, parsedMaxValue, parsedStep, parsedValuesArray } = (0, import_useOptionalCustomTickMarksValues.useOptionalCustomTickMarksValues)(props);
|
|
82
|
+
const [rangeValues, setRangeValues] = (0, import_ds_utilities.useControlledUncontrolledState)({
|
|
83
|
+
defaultState: withTwoHandles ? [parsedMinValue, parsedMaxValue] : [parsedMinValue],
|
|
84
|
+
...controlledValue !== void 0 && { controlledState: controlledValue }
|
|
85
|
+
// due to a strange interaction with useResetInternalValueOnWithTwoHandlesChange and particularly with usePrevious
|
|
86
|
+
// if we use the "onChange" to notify the parent component of the change, every time the setRangeValues is invoked
|
|
87
|
+
// this will break "first render default value" due to useResetInternalValueOnWithTwoHandlesChange,
|
|
88
|
+
// since usePrevious only work if no extra-render happen,
|
|
89
|
+
// during the first render will triggering an `onChange` with "resetted rangeValues", effectively breaking the "first render default value"
|
|
90
|
+
// all of this is extremely brittle, this component needs to be re-coded from scratch, but short term, we can't use onChange here
|
|
91
|
+
// onChange,
|
|
118
92
|
});
|
|
119
|
-
(0,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
setWidth(ref.current?.clientWidth);
|
|
128
|
-
}, [ref.current?.clientWidth]);
|
|
129
|
-
const [finalLabelText, finalValueText] = (0, import_react.useMemo)(
|
|
130
|
-
() => (0, import_utils.conformedLabel)(rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep),
|
|
131
|
-
[rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep]
|
|
132
|
-
);
|
|
133
|
-
const SliderLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
134
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.LabelText, { children: finalLabelText }),
|
|
135
|
-
finalLabelText && " ",
|
|
136
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.ValueText, { disabled, children: finalValueText })
|
|
137
|
-
] });
|
|
138
|
-
const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
|
|
93
|
+
const [fullSelectedValues] = (0, import_useSelectedValuesArray.useSelectedValuesArray)({ parsedValuesArray, rangeValues, customTickMarksValues });
|
|
94
|
+
useResetInternalValueOnWithTwoHandlesChange({
|
|
95
|
+
withTwoHandles,
|
|
96
|
+
setRangeValues,
|
|
97
|
+
parsedMinValue,
|
|
98
|
+
parsedMaxValue
|
|
99
|
+
});
|
|
100
|
+
const theme = import_react.default.useContext(import_ds_system.ThemeContext);
|
|
139
101
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_truncated_tooltip_text.TooltipTextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
102
|
import_ds_grid.Grid,
|
|
141
103
|
{
|
|
@@ -166,7 +128,19 @@ const SliderImp = (props) => {
|
|
|
166
128
|
zIndex: zIndex ?? theme.zIndex.tooltip
|
|
167
129
|
},
|
|
168
130
|
children: [
|
|
169
|
-
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
import_TooltipWithLabelAndValue.TooltipWithLabelAndValue,
|
|
133
|
+
{
|
|
134
|
+
containerRef: ref,
|
|
135
|
+
rangeValues,
|
|
136
|
+
label,
|
|
137
|
+
labelWithValue,
|
|
138
|
+
withTwoHandles,
|
|
139
|
+
customTickMarksValues,
|
|
140
|
+
parsedStep,
|
|
141
|
+
disabled
|
|
142
|
+
}
|
|
143
|
+
),
|
|
170
144
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledRangeWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
145
|
import_react_range.Range,
|
|
172
146
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/SliderImp.tsx", "
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/components/SliderImp.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { Range } from 'react-range';\nimport { usePrevious, useControlledUncontrolledState } from '@elliemae/ds-utilities';\nimport { TooltipTextProvider } from '@elliemae/ds-truncated-tooltip-text';\nimport { Grid } from '@elliemae/ds-grid';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport Track from './Track.js';\nimport Thumb from './Thumb.js';\nimport { StyledRangeWrapper } from './styled.js';\nimport { SliderContext } from './context.js';\nimport type { DSSliderT } from '../prop-types.js';\nimport { useOptionalCustomTickMarksValues } from './useOptionalCustomTickMarksValues.js';\nimport { useSelectedValuesArray } from './useSelectedValuesArray.js';\nimport { TooltipWithLabelAndValue } from './TooltipWithLabelAndValue.js';\n\n// the intention is to only invoke this when the \"withTwoHandles\" change from true to false or viceversa\n// the current implementation is not working as intended, but changing this is a bigger change outside the scope of this PR.\n// this is specifically triggering an extra time after the first render,\n// forcing the value to start from the min value or [min, max] value\nconst useResetInternalValueOnWithTwoHandlesChange = ({\n withTwoHandles,\n setRangeValues,\n parsedMinValue,\n parsedMaxValue,\n}: {\n withTwoHandles: boolean;\n setRangeValues: (newVal: DSSliderT.RangeTuple) => void;\n parsedMinValue: number;\n parsedMaxValue: number;\n}) => {\n const prevWithTwoHandles = usePrevious(withTwoHandles);\n React.useEffect(() => {\n if (!prevWithTwoHandles && withTwoHandles) {\n setRangeValues([parsedMinValue, parsedMaxValue]);\n } else if (prevWithTwoHandles && !withTwoHandles) {\n setRangeValues([parsedMinValue]);\n }\n // this is legacy code, we can't change this to avoid breaking changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [withTwoHandles]);\n};\n\nconst SliderImp = (props: DSSliderT.InternalProps): JSX.Element => {\n const {\n containerProps,\n disabled,\n label,\n labelWithValue,\n onChange,\n withTickMarks,\n withTickMarksValues,\n withTwoHandles,\n customTickMarksValues,\n zIndex,\n controlledValue,\n } = props;\n const ref = React.useRef() as React.MutableRefObject<HTMLDivElement>;\n const sliderUUID = React.useMemo(() => uuidv4(), []);\n\n const { parsedMinValue, parsedMaxValue, parsedStep, parsedValuesArray } = useOptionalCustomTickMarksValues(props);\n\n const [rangeValues, setRangeValues] = useControlledUncontrolledState<DSSliderT.RangeTuple>({\n defaultState: withTwoHandles ? [parsedMinValue, parsedMaxValue] : [parsedMinValue],\n ...(controlledValue !== undefined && { controlledState: controlledValue }),\n // due to a strange interaction with useResetInternalValueOnWithTwoHandlesChange and particularly with usePrevious\n // if we use the \"onChange\" to notify the parent component of the change, every time the setRangeValues is invoked\n // this will break \"first render default value\" due to useResetInternalValueOnWithTwoHandlesChange,\n // since usePrevious only work if no extra-render happen,\n // during the first render will triggering an `onChange` with \"resetted rangeValues\", effectively breaking the \"first render default value\"\n // all of this is extremely brittle, this component needs to be re-coded from scratch, but short term, we can't use onChange here\n // onChange,\n });\n\n // this is used to change the text color of the tickmarks values\n const [fullSelectedValues] = useSelectedValuesArray({ parsedValuesArray, rangeValues, customTickMarksValues });\n\n // (hystorically) for some reason we have chosen to\n // not notify the parent component of the change when we reset the value due to the \"withTwoHandles\" change\n // if useControlledUncontrolledState receives onChange, it will notify the parent component of the change...\n useResetInternalValueOnWithTwoHandlesChange({\n withTwoHandles,\n setRangeValues,\n parsedMinValue,\n parsedMaxValue,\n });\n\n const theme = React.useContext(ThemeContext);\n\n return (\n <TooltipTextProvider>\n <div ref={ref}>\n <Grid\n width=\"100%\"\n style={{ maxWidth: '100%' }}\n containerProps={containerProps}\n data-testid=\"slider\"\n alignItems=\"center\"\n rows={['auto', 'auto']}\n >\n <SliderContext.Provider\n value={{\n disabled,\n sliderUUID,\n label,\n labelWithValue,\n minValue: parsedMinValue,\n maxValue: parsedMaxValue,\n step: parsedStep,\n parsedValuesArray,\n withTickMarks,\n withTickMarksValues,\n withTwoHandles,\n customTickMarksValues,\n rangeValues,\n fullSelectedValues,\n zIndex: zIndex ?? theme.zIndex.tooltip,\n }}\n >\n <TooltipWithLabelAndValue\n containerRef={ref}\n rangeValues={rangeValues}\n label={label}\n labelWithValue={labelWithValue}\n withTwoHandles={withTwoHandles}\n customTickMarksValues={customTickMarksValues}\n parsedStep={parsedStep}\n disabled={disabled}\n />\n <StyledRangeWrapper>\n <Range\n step={parsedStep}\n min={parsedMinValue}\n max={parsedMaxValue}\n values={rangeValues}\n disabled={disabled}\n onChange={(values) => {\n if (withTwoHandles && values[0] === values[1]) return;\n setRangeValues(values as DSSliderT.RangeTuple);\n onChange(values as DSSliderT.RangeTuple);\n }}\n renderTrack={({ props: trackProps, children }) => <Track props={trackProps}>{children}</Track>}\n renderThumb={(renderArgs) => {\n const { index, props: thumbProps, isDragged } = renderArgs;\n return (\n <Thumb\n key={`${sliderUUID}-${thumbProps.key}`}\n props={thumbProps}\n isDragged={isDragged}\n index={index}\n />\n );\n }}\n allowOverlap={false}\n />\n </StyledRangeWrapper>\n </SliderContext.Provider>\n </Grid>\n </div>\n </TooltipTextProvider>\n );\n};\n\nexport default SliderImp;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuGb;AApGV,mBAAkB;AAClB,kBAA6B;AAC7B,yBAAsB;AACtB,0BAA4D;AAC5D,uCAAoC;AACpC,qBAAqB;AACrB,uBAA6B;AAC7B,mBAAkB;AAClB,mBAAkB;AAClB,oBAAmC;AACnC,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B,GACF;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF,GACF;AAEJ;AAEA,IAAO,oBAAQ;",
|
|
6
|
+
"names": ["React", "uuidv4", "Track", "Thumb"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Thumb.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/Thumb.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { useContext, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { SliderContext } from './context.js';\nimport { conformedThumbLabel } from './utils.js';\nimport { ThumbStyled, TooltipContainerStyled, TooltipArrow } from './styled.js';\n\nconst Thumb = ({ index, props, isDragged }) => {\n const [isHovered, setIsHovered] = useState(false);\n const { disabled, rangeValues, zIndex, customTickMarksValues, step, minValue } = useContext(SliderContext);\n\n const cleanedProps = { ...props };\n // delete cleanedProps.key;\n // delete cleanedProps.draggable;\n return (\n // ...props is needed because it's received from the library\n // ...props.style has it own style from the library but has a bug with the zIndex for two thumbs, so that's why it has to be overwrite\n <ThumbStyled\n {...cleanedProps}\n data-testid=\"slider-thumb\"\n disabled={disabled}\n // eslint-disable-next-line react/prop-types\n style={{ ...cleanedProps.style, zIndex }}\n index={index}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <DSTooltipV3\n key={conformedThumbLabel(rangeValues, customTickMarksValues, index, step, minValue)}\n text={conformedThumbLabel(rangeValues, customTickMarksValues, index, step, minValue)}\n showPopover={isDragged || isHovered}\n customOffset={[0, 20]}\n withoutAnimation\n ></DSTooltipV3>\n </ThumbStyled>\n );\n};\n\n/* {createPortal(\n <TooltipContainerStyled isDragged={isDragged} isHovered={isHovered}>\n <TooltipText>{</TooltipText>\n <TooltipArrow />\n </TooltipContainerStyled>,\n document.body,\n )} */\n\nThumb.propTypes = {\n index: PropTypes.number,\n props: PropTypes.shape({\n style: PropTypes.shape({}).isRequired,\n }).isRequired,\n isDragged: PropTypes.bool,\n};\n\nexport default Thumb;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD4BjB;AA5BN,mBAA4C;AAE5C,wBAAsB;AACtB,wBAA4B;AAC5B,qBAA8B;AAC9B,mBAAoC;AACpC,oBAAkE;AAElE,MAAM,QAAQ,CAAC,EAAE,OAAO,OAAO,UAAU,MAAM;AAC7C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,EAAE,UAAU,aAAa,QAAQ,uBAAuB,MAAM,SAAS,QAAI,yBAAW,4BAAa;AAEzG,QAAM,eAAe,EAAE,GAAG,MAAM;AAGhC;AAAA;AAAA;AAAA,IAGE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,eAAY;AAAA,QACZ;AAAA,QAEA,OAAO,EAAE,GAAG,aAAa,OAAO,OAAO;AAAA,QACvC;AAAA,QACA,cAAc,MAAM,aAAa,IAAI;AAAA,QACrC,cAAc,MAAM,aAAa,KAAK;AAAA,QAEtC;AAAA,UAAC;AAAA;AAAA,YAEC,UAAM,kCAAoB,aAAa,uBAAuB,OAAO,MAAM,QAAQ;AAAA,YACnF,aAAa,aAAa;AAAA,YAC1B,cAAc,CAAC,GAAG,EAAE;AAAA,YACpB,kBAAgB;AAAA;AAAA,cAJX,kCAAoB,aAAa,uBAAuB,OAAO,MAAM,QAAQ;AAAA,QAKnF;AAAA;AAAA,IACH;AAAA;AAEJ;AAUA,MAAM,YAAY;AAAA,EAChB,OAAO,kBAAAA,QAAU;AAAA,EACjB,OAAO,kBAAAA,QAAU,MAAM;AAAA,IACrB,OAAO,kBAAAA,QAAU,MAAM,CAAC,CAAC,EAAE;AAAA,EAC7B,CAAC,EAAE;AAAA,EACH,WAAW,kBAAAA,QAAU;AACvB;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["PropTypes"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/TickMarks.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/TickMarks.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable indent */\nimport React, { useContext } from 'react';\nimport { styled, __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';\nimport { SliderContext } from './context.js';\n\nconst TickMarks = () => {\n const { minValue, maxValue, rangeValues, step, withTwoHandles, zIndex } = useContext(SliderContext);\n const dots = [];\n\n for (let index = minValue || 0; index <= maxValue; index += step) {\n const isActive = withTwoHandles ? rangeValues[0] <= index && index < rangeValues[1] : rangeValues[0] > index;\n dots.push(<Dot data-testid=\"slider-dot\" isActive={isActive} key={index} />);\n }\n\n return (\n <DotsContainer data-testid=\"slider-tick-marks\" zIndex={zIndex}>\n {dots}\n </DotsContainer>\n );\n};\n\nconst Dot = styled.div`\n &:after {\n content: '';\n background: ${(props) => (props.isActive ? props.theme.colors.brand[300] : props.theme.colors.neutral[400])};\n border-radius: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};\n display: block;\n position: relative;\n width: 2px;\n height: 2px;\n }\n`;\n\nconst DotsContainer = styled.div`\n padding: 0 calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 0.5);\n align-items: center;\n display: flex;\n justify-content: space-between;\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: ${(props) => props.zIndex - 1};\n`;\n\nexport default TickMarks;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWT;AAVd,mBAAkC;AAClC,uBAAiD;AACjD,qBAA8B;AAE9B,MAAM,YAAY,MAAM;AACtB,QAAM,EAAE,UAAU,UAAU,aAAa,MAAM,gBAAgB,OAAO,QAAI,yBAAW,4BAAa;AAClG,QAAM,OAAO,CAAC;AAEd,WAAS,QAAQ,YAAY,GAAG,SAAS,UAAU,SAAS,MAAM;AAChE,UAAM,WAAW,iBAAiB,YAAY,CAAC,KAAK,SAAS,QAAQ,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI;AACvG,SAAK,KAAK,4CAAC,OAAI,eAAY,cAAa,YAAyB,KAAO,CAAE;AAAA,EAC5E;AAEA,SACE,4CAAC,iBAAc,eAAY,qBAAoB,QAC5C,gBACH;AAEJ;AAEA,MAAM,MAAM,wBAAO;AAAA;AAAA;AAAA,kBAGD,CAAC,UAAW,MAAM,WAAW,MAAM,MAAM,OAAO,MAAM,GAAG,IAAI,MAAM,MAAM,OAAO,QAAQ,GAAG;AAAA,qBACxF,CAAC,cAAU,2CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ9E,MAAM,gBAAgB,wBAAO;AAAA,oBACT,CAAC,cAAU,2CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAUhE,CAAC,UAAU,MAAM,SAAS;AAAA;AAGvC,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/TickMarksValues.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/TickMarksValues.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable no-plusplus */\nimport React, { useContext, useMemo } from 'react';\nimport { styled, __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';\nimport { SliderContext } from './context.js';\n\nconst TickMarks = () => {\n const { parsedValuesArray, fullSelectedValues, sliderUUID } = useContext(SliderContext);\n\n const TickMarksLabels = useMemo(\n () =>\n parsedValuesArray.map((value) => {\n const isSelected = fullSelectedValues.findIndex((selectedVal) => selectedVal === value) >= 0;\n return (\n <TickMarkValue key={`${sliderUUID}-${value}`} isSelected={isSelected}>\n {value}\n </TickMarkValue>\n );\n }),\n\n [parsedValuesArray, sliderUUID, fullSelectedValues],\n );\n\n const PureTickMArksValues = useMemo(\n () => <TickMarksContainer data-testid=\"slider-tick-marks-values\">{TickMarksLabels}</TickMarksContainer>,\n [TickMarksLabels],\n );\n\n return PureTickMArksValues;\n};\n\nconst TickMarkValue = styled.div`\n min-height: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.s)};\n overflow: visible;\n transform: translateX(-100%);\n width: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};\n color: ${(props) => (props.isSelected ? props.theme.colors.neutral[800] : props.theme.colors.neutral[500])};\n`;\n\nconst TickMarksContainer = styled.div`\n display: flex;\n justify-content: space-between;\n // this next property-value rever the sanitize.css value\n overflow-wrap: normal;\n`;\n\nexport default TickMarks;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADab;AAZV,mBAA2C;AAC3C,uBAAiD;AACjD,qBAA8B;AAE9B,MAAM,YAAY,MAAM;AACtB,QAAM,EAAE,mBAAmB,oBAAoB,WAAW,QAAI,yBAAW,4BAAa;AAEtF,QAAM,sBAAkB;AAAA,IACtB,MACE,kBAAkB,IAAI,CAAC,UAAU;AAC/B,YAAM,aAAa,mBAAmB,UAAU,CAAC,gBAAgB,gBAAgB,KAAK,KAAK;AAC3F,aACE,4CAAC,iBAA6C,YAC3C,mBADiB,GAAG,cAAc,OAErC;AAAA,IAEJ,CAAC;AAAA,IAEH,CAAC,mBAAmB,YAAY,kBAAkB;AAAA,EACpD;AAEA,QAAM,0BAAsB;AAAA,IAC1B,MAAM,4CAAC,sBAAmB,eAAY,4BAA4B,2BAAgB;AAAA,IAClF,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AACT;AAEA,MAAM,gBAAgB,wBAAO;AAAA,gBACb,CAAC,cAAU,2CAAyB,MAAM,MAAM,MAAM,CAAC;AAAA;AAAA;AAAA,WAG5D,CAAC,cAAU,2CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA,WACzD,CAAC,UAAW,MAAM,aAAa,MAAM,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,MAAM,OAAO,QAAQ,GAAG;AAAA;AAG1G,MAAM,qBAAqB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOlC,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var TooltipWithLabelAndValue_exports = {};
|
|
30
|
+
__export(TooltipWithLabelAndValue_exports, {
|
|
31
|
+
TooltipWithLabelAndValue: () => TooltipWithLabelAndValue
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(TooltipWithLabelAndValue_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_ds_truncated_tooltip_text = __toESM(require("@elliemae/ds-truncated-tooltip-text"));
|
|
38
|
+
var import_styled = require("./styled.js");
|
|
39
|
+
var import_utils = require("./utils.js");
|
|
40
|
+
const useWidthForLabel = ({ ref }) => {
|
|
41
|
+
const [width, setWidth] = import_react.default.useState(0);
|
|
42
|
+
const resizeHandler = () => {
|
|
43
|
+
setWidth(0);
|
|
44
|
+
setWidth(ref.current?.clientWidth);
|
|
45
|
+
};
|
|
46
|
+
import_react.default.useEffect(() => {
|
|
47
|
+
window.addEventListener("resize", resizeHandler);
|
|
48
|
+
return () => window.removeEventListener("resize", resizeHandler);
|
|
49
|
+
});
|
|
50
|
+
import_react.default.useEffect(() => {
|
|
51
|
+
setWidth(ref.current?.clientWidth);
|
|
52
|
+
}, [ref.current?.clientWidth]);
|
|
53
|
+
return { ref, width };
|
|
54
|
+
};
|
|
55
|
+
const TooltipWithLabelAndValue = (props) => {
|
|
56
|
+
const {
|
|
57
|
+
containerRef,
|
|
58
|
+
rangeValues,
|
|
59
|
+
label,
|
|
60
|
+
labelWithValue,
|
|
61
|
+
withTwoHandles,
|
|
62
|
+
customTickMarksValues,
|
|
63
|
+
parsedStep,
|
|
64
|
+
disabled
|
|
65
|
+
} = props;
|
|
66
|
+
const { width } = useWidthForLabel({ ref: containerRef });
|
|
67
|
+
const [finalLabelText, finalValueText] = import_react.default.useMemo(
|
|
68
|
+
() => (0, import_utils.conformedLabel)(rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep),
|
|
69
|
+
[rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep]
|
|
70
|
+
);
|
|
71
|
+
if (!finalLabelText)
|
|
72
|
+
return null;
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.LabelWrapper, { width, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_ds_truncated_tooltip_text.default,
|
|
75
|
+
{
|
|
76
|
+
value: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.LabelText, { children: finalLabelText }),
|
|
78
|
+
finalLabelText && " ",
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.ValueText, { disabled, children: finalValueText })
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
) });
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=TooltipWithLabelAndValue.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/TooltipWithLabelAndValue.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport DSTruncatedTooltipText from '@elliemae/ds-truncated-tooltip-text';\nimport { LabelWrapper, LabelText, ValueText } from './styled.js';\nimport { conformedLabel } from './utils.js';\nimport type { DSSliderT } from '../prop-types.js';\n\nconst useWidthForLabel = ({ ref }: { ref: React.MutableRefObject<HTMLDivElement> }) => {\n const [width, setWidth] = React.useState(0);\n const resizeHandler = () => {\n setWidth(0);\n setWidth(ref.current?.clientWidth);\n };\n React.useEffect(() => {\n window.addEventListener('resize', resizeHandler);\n return () => window.removeEventListener('resize', resizeHandler);\n });\n React.useEffect(() => {\n setWidth(ref.current?.clientWidth);\n // this is legacy code, we can't change this to avoid breaking changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref.current?.clientWidth]);\n return { ref, width };\n};\n\nexport const TooltipWithLabelAndValue = (props: {\n containerRef: React.MutableRefObject<HTMLDivElement>;\n rangeValues: DSSliderT.RangeTuple;\n label: string;\n labelWithValue: boolean;\n withTwoHandles: boolean;\n customTickMarksValues: DSSliderT.CustomTickMarkValue[];\n parsedStep: number;\n disabled: boolean;\n}) => {\n const {\n containerRef,\n rangeValues,\n label,\n labelWithValue,\n withTwoHandles,\n customTickMarksValues,\n parsedStep,\n disabled,\n } = props;\n const { width } = useWidthForLabel({ ref: containerRef });\n\n const [finalLabelText, finalValueText] = React.useMemo(\n () => conformedLabel(rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep),\n [rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep],\n );\n\n if (!finalLabelText) return null;\n return (\n <LabelWrapper width={width}>\n <DSTruncatedTooltipText\n value={\n <>\n <LabelText>{finalLabelText}</LabelText>\n {finalLabelText && ' '}\n <ValueText disabled={disabled}>{finalValueText}</ValueText>\n </>\n }\n />\n </LabelWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD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"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Track.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/Track.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable indent */\n/* eslint-disable react/prop-types */\nimport React, { useContext } from 'react';\nimport { getTrackBackground } from 'react-range';\nimport { styled, __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';\nimport TickMarks from './TickMarks.js';\nimport TickMarksValues from './TickMarksValues.js';\nimport { SliderContext } from './context.js';\n\nconst Track = ({ children, props }) => {\n const { disabled, minValue, maxValue, rangeValues, withTickMarks, withTickMarksValues, withTwoHandles } =\n useContext(SliderContext);\n\n return (\n <>\n <TrackStyled\n {...props} // This is needed because it's received from the library\n disabled={disabled}\n minValue={minValue}\n maxValue={maxValue}\n rangeValues={rangeValues}\n withTwoHandles={withTwoHandles}\n >\n {children}\n {withTickMarks && !disabled && <TickMarks />}\n </TrackStyled>\n {withTickMarksValues && <TickMarksValues />}\n </>\n );\n};\n\nconst TrackStyled = styled.div`\n position: relative;\n height: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};\n width: 100%;\n min-width: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxl)};\n border-radius: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};\n background: ${(props) =>\n props.disabled\n ? props.theme.colors.neutral[100]\n : getTrackBackground({\n values: props.rangeValues,\n colors: props.withTwoHandles\n ? [props.theme.colors.neutral[100], props.theme.colors.brand[600], props.theme.colors.neutral[100]]\n : [props.theme.colors.brand[600], props.theme.colors.neutral[100]],\n min: props.minValue,\n max: props.maxValue,\n })};\n`;\n\nexport default Track;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;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ues"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/context.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/context.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React from 'react';\n\nexport const SliderContext = React.createContext();\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAEX,MAAM,gBAAgB,aAAAA,QAAM,cAAc;",
|
|
6
6
|
"names": ["React"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/styled.tsx", "
|
|
3
|
+
"sources": ["../../../src/components/styled.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable indent */\nimport { styled } from '@elliemae/ds-system';\nimport { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';\nimport { TooltipContainer } from '@elliemae/ds-tooltip';\n\nexport const ThumbStyled = styled.div`\n height: 20px;\n width: 20px;\n top: 0;\n background-color: ${(props) =>\n props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral['000']};\n border-radius: 10px;\n border: 1px solid ${(props) => (props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral[400])};\n\n :focus {\n border: 1px solid ${(props) => props.theme.colors.brand[600]};\n outline: unset;\n }\n\n :hover {\n background-color: ${({ disabled, theme }) => (disabled ? theme.colors.neutral[100] : theme.colors.brand[200])};\n }\n`;\n\nexport const TooltipContainerStyled = styled(TooltipContainer)`\n position: relative;\n display: flex;\n align-items: center;\n flex-direction: column;\n top: -35px;\n width: max-content;\n left: 50%;\n transform: translateX(-50%);\n visibility: ${({ isDragged, isHovered }) => (isDragged || isHovered ? 'visible' : 'hidden')};\n`;\n// TODO: didn't work with DSTooltip, see how to improve\nexport const TooltipArrow = styled.div`\n position: absolute;\n width: 0;\n height: 0;\n top: 20px;\n color: white;\n border-left: calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 2.5) solid transparent;\n border-right: calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 2.5) solid transparent;\n\n border-top: calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 2.5) solid\n ${(props) => props.theme.colors.neutral['000']};\n`;\n\nexport const LabelWrapper = styled.div`\n padding: 0 8px;\n max-width: 100%;\n line-height: 1;\n height: 12px;\n width: ${(props) => `${props.width || 0}px`};\n`;\n\nexport const LabelText = styled.span`\n color: ${(props) => props.theme.colors.neutral[600]};\n`;\n\nexport const ValueText = styled.span`\n color: ${({ disabled, theme }) => theme.colors.neutral[disabled ? 500 : 800]};\n`;\n\nexport const StyledRangeWrapper = styled.div`\n min-height: 28px;\n margin: 0 16px;\n display: grid;\n grid-template-rows: 28px auto;\n align-items: center;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAAuB;AACvB,IAAAA,oBAAyC;AACzC,wBAAiC;AAE1B,MAAM,cAAc,wBAAO;AAAA;AAAA;AAAA;AAAA,sBAIZ,CAAC,UACnB,MAAM,WAAW,MAAM,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,MAAM,OAAO,QAAQ,KAAK;AAAA;AAAA,sBAEjE,CAAC,UAAW,MAAM,WAAW,MAAM,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,MAAM,OAAO,QAAQ,GAAG;AAAA;AAAA;AAAA,wBAG3F,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKvC,CAAC,EAAE,UAAU,MAAM,MAAO,WAAW,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,OAAO,MAAM,GAAG;AAAA;AAAA;AAIxG,MAAM,6BAAyB,yBAAO,kCAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAS7C,CAAC,EAAE,WAAW,UAAU,MAAO,aAAa,YAAY,YAAY;AAAA;AAG7E,MAAM,eAAe,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMb,CAAC,cAAU,4CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA,uBACxD,CAAC,cAAU,4CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA;AAAA,qBAE3D,CAAC,cAAU,4CAAyB,MAAM,MAAM,MAAM,GAAG;AAAA,MACxE,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ,KAAK;AAAA;AAG1C,MAAM,eAAe,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA,WAKxB,CAAC,UAAU,GAAG,MAAM,SAAS;AAAA;AAGjC,MAAM,YAAY,wBAAO;AAAA,WACrB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ,GAAG;AAAA;AAG7C,MAAM,YAAY,wBAAO;AAAA,WACrB,CAAC,EAAE,UAAU,MAAM,MAAM,MAAM,OAAO,QAAQ,WAAW,MAAM,GAAG;AAAA;AAGtE,MAAM,qBAAqB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": ["import_ds_system"]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useOptionalCustomTickMarksValues_exports = {};
|
|
30
|
+
__export(useOptionalCustomTickMarksValues_exports, {
|
|
31
|
+
useOptionalCustomTickMarksValues: () => useOptionalCustomTickMarksValues
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useOptionalCustomTickMarksValues_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const getDefaultTickMarksValues = ({
|
|
37
|
+
minValue,
|
|
38
|
+
maxValue,
|
|
39
|
+
step
|
|
40
|
+
}) => {
|
|
41
|
+
let parsedValuesArray = [];
|
|
42
|
+
if (maxValue && step) {
|
|
43
|
+
const newLength = Math.ceil(maxValue / step);
|
|
44
|
+
const valuesArray = [];
|
|
45
|
+
for (let i = 0; i <= newLength; i += 1) {
|
|
46
|
+
valuesArray.push(step * i);
|
|
47
|
+
}
|
|
48
|
+
parsedValuesArray = valuesArray;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
parsedMinValue: minValue,
|
|
52
|
+
parsedMaxValue: maxValue,
|
|
53
|
+
parsedStep: step,
|
|
54
|
+
parsedValuesArray
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const getCustomTickMarksValues = ({
|
|
58
|
+
customTickMarksValues
|
|
59
|
+
}) => ({
|
|
60
|
+
parsedMinValue: 0,
|
|
61
|
+
parsedMaxValue: customTickMarksValues.length - 1,
|
|
62
|
+
parsedStep: 1,
|
|
63
|
+
parsedValuesArray: customTickMarksValues
|
|
64
|
+
});
|
|
65
|
+
const useOptionalCustomTickMarksValues = (props) => {
|
|
66
|
+
const { customTickMarksValues, minValue, maxValue, step } = props;
|
|
67
|
+
return import_react.default.useMemo(() => {
|
|
68
|
+
const canUseCustomTickMarksValues = customTickMarksValues?.length;
|
|
69
|
+
if (canUseCustomTickMarksValues)
|
|
70
|
+
return getCustomTickMarksValues({ customTickMarksValues });
|
|
71
|
+
return getDefaultTickMarksValues({ minValue, maxValue, step });
|
|
72
|
+
}, [customTickMarksValues, maxValue, minValue, step]);
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=useOptionalCustomTickMarksValues.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/useOptionalCustomTickMarksValues.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { DSSliderT } from '../prop-types.js';\n\n// when the user doesn't pass customTickMarksValues\n// the internal opinion the component makes is that\n// - the minValue will be provided by the user (default to defaultProps.minValue)\n// - the maxValue will be provided by the user (default to defaultProps.maxValue)\n// - the step will be provided by the user (default to defaultProps.step)\n// - the values array will be generated from the above values (min, max, step)\nconst getDefaultTickMarksValues = ({\n minValue,\n maxValue,\n step,\n}: {\n minValue: DSSliderT.InternalProps['minValue'];\n maxValue: DSSliderT.InternalProps['maxValue'];\n step: DSSliderT.InternalProps['step'];\n}) => {\n // this is truly number[], but for custom logic and props we support string[] as well,\n // this typecast just makes it easier to work with right now...\n let parsedValuesArray: DSSliderT.CustomTickMarkValue[] = [];\n if (maxValue && step) {\n const newLength = Math.ceil(maxValue / step);\n const valuesArray = [];\n // storycally \"i\" starts from 0... I don't understand why it's not starting from minValue...\n // if it ain't broke, don't fix it.\n for (let i = 0; i <= newLength; i += 1) {\n valuesArray.push(step * i);\n }\n\n parsedValuesArray = valuesArray;\n }\n\n return {\n parsedMinValue: minValue,\n parsedMaxValue: maxValue,\n parsedStep: step,\n parsedValuesArray,\n };\n};\n// when user passes customTickMarksValues\n// the internal opinion the component makes is that\n// - the minValue will be 0\n// - the maxValue will be the last index of the array\n// - the step will be 1\n// - the values array will be the customTickMarksValues array\n// the idea is that since customTickMarksValues may potentially be string[]\n// we can't really do math on it, so we just use the index of the array as the value\n// this is why we force step to be 1, minValue to be 0, and maxValue to be the last index of the array.\nconst getCustomTickMarksValues = ({\n customTickMarksValues,\n}: {\n customTickMarksValues: Required<DSSliderT.Props>['customTickMarksValues'];\n}) => ({\n parsedMinValue: 0,\n parsedMaxValue: customTickMarksValues.length - 1,\n parsedStep: 1,\n parsedValuesArray: customTickMarksValues,\n});\n\nexport const useOptionalCustomTickMarksValues = (props: DSSliderT.InternalProps) => {\n const { customTickMarksValues, minValue, maxValue, step } = props;\n return React.useMemo(() => {\n const canUseCustomTickMarksValues = customTickMarksValues?.length;\n if (canUseCustomTickMarksValues) return getCustomTickMarksValues({ customTickMarksValues });\n return getDefaultTickMarksValues({ minValue, maxValue, step });\n }, [customTickMarksValues, maxValue, minValue, step]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AASlB,MAAM,4BAA4B,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF,MAIM;AAGJ,MAAI,oBAAqD,CAAC;AAC1D,MAAI,YAAY,MAAM;AACpB,UAAM,YAAY,KAAK,KAAK,WAAW,IAAI;AAC3C,UAAM,cAAc,CAAC;AAGrB,aAAS,IAAI,GAAG,KAAK,WAAW,KAAK,GAAG;AACtC,kBAAY,KAAK,OAAO,CAAC;AAAA,IAC3B;AAEA,wBAAoB;AAAA,EACtB;AAEA,SAAO;AAAA,IACL,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ;AAAA,EACF;AACF;AAUA,MAAM,2BAA2B,CAAC;AAAA,EAChC;AACF,OAEO;AAAA,EACL,gBAAgB;AAAA,EAChB,gBAAgB,sBAAsB,SAAS;AAAA,EAC/C,YAAY;AAAA,EACZ,mBAAmB;AACrB;AAEO,MAAM,mCAAmC,CAAC,UAAmC;AAClF,QAAM,EAAE,uBAAuB,UAAU,UAAU,KAAK,IAAI;AAC5D,SAAO,aAAAA,QAAM,QAAQ,MAAM;AACzB,UAAM,8BAA8B,uBAAuB;AAC3D,QAAI;AAA6B,aAAO,yBAAyB,EAAE,sBAAsB,CAAC;AAC1F,WAAO,0BAA0B,EAAE,UAAU,UAAU,KAAK,CAAC;AAAA,EAC/D,GAAG,CAAC,uBAAuB,UAAU,UAAU,IAAI,CAAC;AACtD;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useSelectedValuesArray_exports = {};
|
|
30
|
+
__export(useSelectedValuesArray_exports, {
|
|
31
|
+
useSelectedValuesArray: () => useSelectedValuesArray
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useSelectedValuesArray_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const getArrayOfSelectedValues = (arr, range, isCustomTickMarksValues = false) => {
|
|
37
|
+
const [minVal, maxVal] = range;
|
|
38
|
+
const trueMinVal = isCustomTickMarksValues ? arr[minVal] : minVal;
|
|
39
|
+
if (maxVal === void 0)
|
|
40
|
+
return [trueMinVal];
|
|
41
|
+
const minIndex = arr.findIndex((el) => el === trueMinVal);
|
|
42
|
+
const trueMaxVal = isCustomTickMarksValues ? arr[maxVal] : maxVal;
|
|
43
|
+
const maxIndex = arr.findIndex((el) => el === trueMaxVal);
|
|
44
|
+
if (minIndex >= 0 && maxIndex > minIndex)
|
|
45
|
+
return arr.slice(minIndex, maxIndex + 1);
|
|
46
|
+
return [];
|
|
47
|
+
};
|
|
48
|
+
const useSelectedValuesArray = ({
|
|
49
|
+
parsedValuesArray,
|
|
50
|
+
rangeValues,
|
|
51
|
+
customTickMarksValues
|
|
52
|
+
}) => {
|
|
53
|
+
const [fullSelectedValues, setFullSelectedValues] = (0, import_react.useState)([]);
|
|
54
|
+
(0, import_react.useEffect)(() => {
|
|
55
|
+
const selectedRangeValues = getArrayOfSelectedValues(
|
|
56
|
+
parsedValuesArray,
|
|
57
|
+
rangeValues,
|
|
58
|
+
!!customTickMarksValues?.length
|
|
59
|
+
);
|
|
60
|
+
setFullSelectedValues(selectedRangeValues);
|
|
61
|
+
}, [parsedValuesArray, rangeValues, customTickMarksValues?.length]);
|
|
62
|
+
return import_react.default.useMemo(() => [fullSelectedValues, setFullSelectedValues], [fullSelectedValues]);
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=useSelectedValuesArray.js.map
|