@mackin.com/styleguide 6.1.0 → 6.2.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.
Files changed (2) hide show
  1. package/index.js +34 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1591,7 +1591,7 @@ const Divider = (props) => {
1591
1591
 
1592
1592
  /** @jsx jsx */
1593
1593
  const ErrorModal = (props) => {
1594
- const { message } = props; __rest(props, ["message"]);
1594
+ const { message } = props;
1595
1595
  const theme = useThemeSafely();
1596
1596
  const modalStyles = react.css `
1597
1597
  .modalHeader {
@@ -3112,7 +3112,6 @@ const FileUploader = (p) => {
3112
3112
  message === 'failure' && (react.jsx(UploadInfoPanel, { variant: "error", message: fullFailureMessage, onClear: onClear }))));
3113
3113
  };
3114
3114
  const UploadInfoPanel = (p) => {
3115
- useThemeSafely();
3116
3115
  return (react.jsx(InfoPanel, { variant: p.variant },
3117
3116
  p.message,
3118
3117
  react.jsx(Button, { block: true, className: css.css({
@@ -3174,8 +3173,9 @@ const BoundStaticPager = (p) => {
3174
3173
  const Slider = (p) => {
3175
3174
  const theme = useThemeSafely();
3176
3175
  const currentValue = React.useRef(p.value);
3176
+ const sliderContainer = React.useRef(null);
3177
3177
  const height = p.showValue ? `calc(${theme.controls.height} + 1.5rem)` : theme.controls.height;
3178
- return (react.jsx("div", { css: {
3178
+ return (react.jsx("div", { ref: sliderContainer, css: {
3179
3179
  width: '100%',
3180
3180
  height,
3181
3181
  } },
@@ -3218,23 +3218,46 @@ const Slider = (p) => {
3218
3218
  '&:hover': {
3219
3219
  filter: theme.controls.hoverBrightness
3220
3220
  }
3221
- } }, props), p.showValue && react.jsx(HandleText, { value: currentValue.current, index: state.index, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth })));
3221
+ } }, props), p.showValue && (react.jsx(HandleText, { index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
3222
3222
  } })));
3223
3223
  };
3224
+ const rectsCollideX = (r1, r2) => {
3225
+ if (r1.left >= r2.left && r1.left <= r2.right) {
3226
+ return true;
3227
+ }
3228
+ if (r1.right >= r2.left && r1.right <= r2.right) {
3229
+ return true;
3230
+ }
3231
+ return false;
3232
+ };
3224
3233
  const HandleText = (p) => {
3225
- var _a, _b, _c, _d;
3234
+ var _a, _b, _c;
3226
3235
  const theme = useThemeSafely();
3227
- const value = Array.isArray(p.value) ? p.value[(_a = p.index) !== null && _a !== void 0 ? _a : 0] : p.value;
3228
- const displayValue = (_c = (_b = p.renderValue) === null || _b === void 0 ? void 0 : _b.call(p, value)) !== null && _c !== void 0 ? _c : value;
3229
- const renderValueWidth = (_d = p.renderValueWidth) !== null && _d !== void 0 ? _d : theme.controls.height;
3230
- const renderValueLeft = `calc(${renderValueWidth} * 0.5 * -1 + (${theme.controls.height} * 0.5))`;
3236
+ const displayValue = (_b = (_a = p.renderValue) === null || _a === void 0 ? void 0 : _a.call(p, p.value)) !== null && _b !== void 0 ? _b : p.value;
3237
+ const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : theme.controls.height;
3238
+ const renderValueLeft = React.useMemo(() => {
3239
+ return `calc(${renderValueWidth} * 0.5 * -1 + (${theme.controls.height} * 0.5))`;
3240
+ }, [p.renderValueWidth]);
3241
+ const [flipText, setFlipText] = React.useState(false);
3242
+ React.useEffect(() => {
3243
+ // this needs to fire on every render due to the other handle also moving.
3244
+ var _a, _b;
3245
+ if (p.index === 1) {
3246
+ // only do this for the max/right-most handle
3247
+ const [r1, r2] = Array.from((_b = (_a = p.parentElement) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.slider-handle').values()) !== null && _b !== void 0 ? _b : []).map(e => e.getBoundingClientRect());
3248
+ if (r1 && r2) {
3249
+ setFlipText(rectsCollideX(r1, r2));
3250
+ }
3251
+ }
3252
+ });
3231
3253
  return (react.jsx(Text, { ellipsis: true, css: {
3232
3254
  width: renderValueWidth,
3233
3255
  left: renderValueLeft,
3234
- bottom: '-1.5rem',
3256
+ top: flipText ? undefined : theme.controls.height,
3257
+ bottom: flipText ? theme.controls.height : undefined,
3235
3258
  position: 'absolute',
3236
3259
  overflow: 'hidden',
3237
- }, tag: "div", align: "center" }, displayValue));
3260
+ }, className: "slider-handle", tag: "div", align: "center" }, displayValue));
3238
3261
  };
3239
3262
 
3240
3263
  /** @jsx jsx */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",