@mackin.com/styleguide 8.9.5 → 8.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +7 -3
- package/index.js +18 -17
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -882,18 +882,22 @@ interface SliderProps<T extends SliderValue> {
|
|
|
882
882
|
renderValue?: (value: number) => string;
|
|
883
883
|
/** Used with renderValue for the custom element width. Defaults to theme.controls.height * 2. */
|
|
884
884
|
renderValueWidth?: string;
|
|
885
|
+
/** The with and height of the handles. Defaults to theme.controls.height. Do not use css to change the handle sizes. */
|
|
886
|
+
sliderHandleSize?: string;
|
|
885
887
|
/** Styles of the overall slider. */
|
|
886
888
|
className?: string;
|
|
887
|
-
/** Styles for the slider handles. */
|
|
889
|
+
/** Styles for the slider handles. Do not use css to change the handle sizes. Use 'sliderHandleSize'. */
|
|
888
890
|
handleClassName?: string;
|
|
889
|
-
/** Styles for the first handle. */
|
|
891
|
+
/** Styles for the first handle. Do not use css to change the handle sizes. Use 'sliderHandleSize'. */
|
|
890
892
|
handle1ClassName?: string;
|
|
891
|
-
/** Styles for the second handle. Ignored if the value is not an array. */
|
|
893
|
+
/** Styles for the second handle. Ignored if the value is not an array. Do not use css to change the handle sizes. Use 'sliderHandleSize'. */
|
|
892
894
|
handle2ClassName?: string;
|
|
893
895
|
/** Styles of the track. */
|
|
894
896
|
trackClassName?: string;
|
|
895
897
|
/** Styles applied to the track between two handlers. Ignored if the value is not an array. */
|
|
896
898
|
innerTrackClassName?: string;
|
|
899
|
+
/** Styles applied to the floating handle text with using 'showValue'. */
|
|
900
|
+
sliderTextClassName?: string;
|
|
897
901
|
}
|
|
898
902
|
declare const Slider: <T extends SliderValue>(p: SliderProps<T>) => JSX.Element;
|
|
899
903
|
|
package/index.js
CHANGED
|
@@ -3215,8 +3215,6 @@ const OmniLink = (props) => {
|
|
|
3215
3215
|
};
|
|
3216
3216
|
|
|
3217
3217
|
const roundPxPadding = '4px';
|
|
3218
|
-
//TB: needs to be 2rem padding for right caret
|
|
3219
|
-
//TB: the generated border is bad (border: 1pxsolidrgba(0, 0, 0, 0.125);)
|
|
3220
3218
|
const Picker = (props) => {
|
|
3221
3219
|
const selectProps = __rest(props
|
|
3222
3220
|
// if we put numbers in, we expect them out
|
|
@@ -3883,10 +3881,12 @@ const GlobalStyles = (p) => {
|
|
|
3883
3881
|
};
|
|
3884
3882
|
|
|
3885
3883
|
const Slider = (p) => {
|
|
3884
|
+
var _a;
|
|
3886
3885
|
const theme = useThemeSafely();
|
|
3887
3886
|
const currentValue = React.useRef(p.value);
|
|
3888
3887
|
const sliderContainer = React.useRef(null);
|
|
3889
|
-
const
|
|
3888
|
+
const sliderHandleSize = (_a = p.sliderHandleSize) !== null && _a !== void 0 ? _a : theme.controls.height;
|
|
3889
|
+
const height = p.showValue ? `calc(${sliderHandleSize} + 1.5rem)` : sliderHandleSize;
|
|
3890
3890
|
return (React__default['default'].createElement("div", { ref: sliderContainer, className: css.cx(css.css({
|
|
3891
3891
|
label: 'Slider',
|
|
3892
3892
|
width: '100%',
|
|
@@ -3900,17 +3900,17 @@ const Slider = (p) => {
|
|
|
3900
3900
|
(_a = p.onUpdate) === null || _a === void 0 ? void 0 : _a.call(p, value);
|
|
3901
3901
|
} : undefined, renderTrack: (props, state) => {
|
|
3902
3902
|
const { className } = props, rest = __rest(props, ["className"]);
|
|
3903
|
-
return React__default['default'].createElement("div", Object.assign({ className: css.cx(className, css.css({
|
|
3903
|
+
return (React__default['default'].createElement("div", Object.assign({ className: css.cx(className, p.trackClassName, css.css({
|
|
3904
3904
|
display: 'flex',
|
|
3905
3905
|
alignItems: 'center',
|
|
3906
|
-
height:
|
|
3907
|
-
})
|
|
3906
|
+
height: sliderHandleSize
|
|
3907
|
+
})) }, rest),
|
|
3908
3908
|
React__default['default'].createElement("div", { className: css.css({
|
|
3909
3909
|
backgroundColor: theme.colors.secondary,
|
|
3910
|
-
height: `calc(${
|
|
3910
|
+
height: `calc(${sliderHandleSize} / 4)`,
|
|
3911
3911
|
borderRadius: theme.controls.roundRadius,
|
|
3912
3912
|
width: '100%'
|
|
3913
|
-
}, p.innerTrackClassName && rest.key === 'track-1' && Array.isArray(p.value) ? p.innerTrackClassName : undefined) }));
|
|
3913
|
+
}, p.innerTrackClassName && rest.key === 'track-1' && Array.isArray(p.value) ? p.innerTrackClassName : undefined) })));
|
|
3914
3914
|
}, renderThumb: (props, state) => {
|
|
3915
3915
|
const { className } = props, rest = __rest(props, ["className"]);
|
|
3916
3916
|
let specificThumbStyles;
|
|
@@ -3921,8 +3921,6 @@ const Slider = (p) => {
|
|
|
3921
3921
|
specificThumbStyles = p.handle2ClassName;
|
|
3922
3922
|
}
|
|
3923
3923
|
return (React__default['default'].createElement("div", Object.assign({ className: css.cx(className, css.css({
|
|
3924
|
-
width: theme.controls.height,
|
|
3925
|
-
height: theme.controls.height,
|
|
3926
3924
|
borderRadius: theme.controls.roundRadius,
|
|
3927
3925
|
backgroundColor: 'white',
|
|
3928
3926
|
border: theme.controls.border,
|
|
@@ -3940,7 +3938,10 @@ const Slider = (p) => {
|
|
|
3940
3938
|
'&:hover': {
|
|
3941
3939
|
filter: theme.controls.hoverBrightness
|
|
3942
3940
|
}
|
|
3943
|
-
}), specificThumbStyles, p.handleClassName
|
|
3941
|
+
}), specificThumbStyles, p.handleClassName, css.css({
|
|
3942
|
+
width: sliderHandleSize,
|
|
3943
|
+
height: sliderHandleSize,
|
|
3944
|
+
})) }, rest), p.showValue && (React__default['default'].createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
3944
3945
|
} })));
|
|
3945
3946
|
};
|
|
3946
3947
|
const rectsCollideX = (r1, r2) => {
|
|
@@ -3954,13 +3955,13 @@ const rectsCollideX = (r1, r2) => {
|
|
|
3954
3955
|
};
|
|
3955
3956
|
const HandleText = (p) => {
|
|
3956
3957
|
var _a, _b, _c;
|
|
3957
|
-
const theme = useThemeSafely();
|
|
3958
3958
|
const displayValue = (_b = (_a = p.renderValue) === null || _a === void 0 ? void 0 : _a.call(p, p.value)) !== null && _b !== void 0 ? _b : p.value;
|
|
3959
|
-
const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c :
|
|
3959
|
+
const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : p.sliderHandleSize;
|
|
3960
3960
|
const renderValueLeft = React.useMemo(() => {
|
|
3961
|
-
return `calc(${renderValueWidth} * 0.5 * -1 + (${
|
|
3961
|
+
return `calc(${renderValueWidth} * 0.5 * -1 + (${p.sliderHandleSize} * 0.5))`;
|
|
3962
3962
|
}, [p.renderValueWidth]);
|
|
3963
3963
|
const [flipText, setFlipText] = React.useState(false);
|
|
3964
|
+
const offset = '2px';
|
|
3964
3965
|
React.useEffect(() => {
|
|
3965
3966
|
// this needs to fire on every render due to the other handle also moving.
|
|
3966
3967
|
var _a, _b;
|
|
@@ -3975,11 +3976,11 @@ const HandleText = (p) => {
|
|
|
3975
3976
|
return (React__default['default'].createElement(Text, { ellipsis: true, className: css.cx('slider-handle', css.css({
|
|
3976
3977
|
width: renderValueWidth,
|
|
3977
3978
|
left: renderValueLeft,
|
|
3978
|
-
top: flipText ? undefined :
|
|
3979
|
-
bottom: flipText ?
|
|
3979
|
+
top: flipText ? undefined : `calc(${p.sliderHandleSize} + ${offset})`,
|
|
3980
|
+
bottom: flipText ? `calc(${p.sliderHandleSize} + ${offset})` : undefined,
|
|
3980
3981
|
position: 'absolute',
|
|
3981
3982
|
overflow: 'hidden',
|
|
3982
|
-
})), tag: "div", align: "center" }, displayValue));
|
|
3983
|
+
}), p.className), tag: "div", align: "center" }, displayValue));
|
|
3983
3984
|
};
|
|
3984
3985
|
|
|
3985
3986
|
const TabHeader = (p) => {
|