@pareto-engineering/design-system 4.0.0-alpha.57 → 4.0.0-alpha.59

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.
@@ -30,12 +30,38 @@ const SnapScroller = _ref => {
30
30
  (0, React.useInsertionEffect)(() => {
31
31
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
32
32
  }, []);
33
- return /*#__PURE__*/React.createElement("div", {
34
- id: id,
35
- className: [baseClassName, componentClassName, userClassName, noScrollOnDesktop && 'desktop-no-scroll'].filter(e => e).join(' '),
36
- style: style
37
- // {...otherProps}
38
- }, children);
33
+ const [isDragging, setIsDragging] = (0, React.useState)(false);
34
+ const [startX, setStartX] = (0, React.useState)(0);
35
+ const [startScrollX, setStartScrollX] = (0, React.useState)(0);
36
+ const ref = (0, React.useRef)(null);
37
+ const onMouseDown = e => {
38
+ setIsDragging(true);
39
+ setStartX(e.clientX);
40
+ setStartScrollX(ref.current.scrollLeft);
41
+ };
42
+ const onMouseUp = () => {
43
+ setIsDragging(false);
44
+ };
45
+ const onMouseMove = e => {
46
+ if (isDragging) {
47
+ const deltaX = e.clientX - startX;
48
+ ref.current.scrollLeft = startScrollX - deltaX;
49
+ }
50
+ };
51
+ return (
52
+ /*#__PURE__*/
53
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
54
+ React.createElement("div", {
55
+ id: id,
56
+ className: [baseClassName, componentClassName, userClassName, noScrollOnDesktop && 'desktop-no-scroll'].filter(e => e).join(' '),
57
+ style: style,
58
+ ref: ref,
59
+ onMouseDown: noScrollOnDesktop ? null : onMouseDown,
60
+ onMouseUp: noScrollOnDesktop ? null : onMouseUp,
61
+ onMouseMove: noScrollOnDesktop ? null : onMouseMove
62
+ // {...otherProps}
63
+ }, children)
64
+ );
39
65
  };
40
66
  SnapScroller.propTypes = {
41
67
  /**
@@ -1,6 +1,6 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  import * as React from 'react';
3
- import { useInsertionEffect } from 'react';
3
+ import { useInsertionEffect, useState, useRef } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import styleNames from '@pareto-engineering/bem/exports';
6
6
 
@@ -23,12 +23,38 @@ const SnapScroller = ({
23
23
  useInsertionEffect(() => {
24
24
  import("./styles.scss");
25
25
  }, []);
26
- return /*#__PURE__*/React.createElement("div", {
27
- id: id,
28
- className: [baseClassName, componentClassName, userClassName, noScrollOnDesktop && 'desktop-no-scroll'].filter(e => e).join(' '),
29
- style: style
30
- // {...otherProps}
31
- }, children);
26
+ const [isDragging, setIsDragging] = useState(false);
27
+ const [startX, setStartX] = useState(0);
28
+ const [startScrollX, setStartScrollX] = useState(0);
29
+ const ref = useRef(null);
30
+ const onMouseDown = e => {
31
+ setIsDragging(true);
32
+ setStartX(e.clientX);
33
+ setStartScrollX(ref.current.scrollLeft);
34
+ };
35
+ const onMouseUp = () => {
36
+ setIsDragging(false);
37
+ };
38
+ const onMouseMove = e => {
39
+ if (isDragging) {
40
+ const deltaX = e.clientX - startX;
41
+ ref.current.scrollLeft = startScrollX - deltaX;
42
+ }
43
+ };
44
+ return (
45
+ /*#__PURE__*/
46
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
47
+ React.createElement("div", {
48
+ id: id,
49
+ className: [baseClassName, componentClassName, userClassName, noScrollOnDesktop && 'desktop-no-scroll'].filter(e => e).join(' '),
50
+ style: style,
51
+ ref: ref,
52
+ onMouseDown: noScrollOnDesktop ? null : onMouseDown,
53
+ onMouseUp: noScrollOnDesktop ? null : onMouseUp,
54
+ onMouseMove: noScrollOnDesktop ? null : onMouseMove
55
+ // {...otherProps}
56
+ }, children)
57
+ );
32
58
  };
33
59
  SnapScroller.propTypes = {
34
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.57",
3
+ "version": "4.0.0-alpha.59",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@lexical/react": "^0.11.3",
54
- "@pareto-engineering/assets": "^4.0.0-alpha.54",
54
+ "@pareto-engineering/assets": "^4.0.0-alpha.59",
55
55
  "@pareto-engineering/bem": "^4.0.0-alpha.20",
56
56
  "@pareto-engineering/styles": "^4.0.0-alpha.57",
57
57
  "@pareto-engineering/utils": "^4.0.0-alpha.46",
@@ -70,5 +70,5 @@
70
70
  "relay-test-utils": "^15.0.0"
71
71
  },
72
72
  "browserslist": "> 2%",
73
- "gitHead": "4f0a6d4cc2b8be23d78e82714adb717b21d91c2c"
73
+ "gitHead": "2d7315603950316a4dc7b8c4a0ccfbc0584e405f"
74
74
  }
@@ -1,7 +1,7 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  import * as React from 'react'
3
3
 
4
- import { useInsertionEffect } from 'react'
4
+ import { useInsertionEffect, useState, useRef } from 'react'
5
5
 
6
6
  import PropTypes from 'prop-types'
7
7
 
@@ -27,14 +27,34 @@ const SnapScroller = ({
27
27
  useInsertionEffect(() => {
28
28
  import('./styles.scss')
29
29
  }, [])
30
+ const [isDragging, setIsDragging] = useState(false)
31
+ const [startX, setStartX] = useState(0)
32
+ const [startScrollX, setStartScrollX] = useState(0)
33
+ const ref = useRef(null)
34
+
35
+ const onMouseDown = (e) => {
36
+ setIsDragging(true)
37
+ setStartX(e.clientX)
38
+ setStartScrollX(ref.current.scrollLeft)
39
+ }
40
+
41
+ const onMouseUp = () => {
42
+ setIsDragging(false)
43
+ }
44
+
45
+ const onMouseMove = (e) => {
46
+ if (isDragging) {
47
+ const deltaX = e.clientX - startX
48
+ ref.current.scrollLeft = startScrollX - deltaX
49
+ }
50
+ }
30
51
 
31
52
  return (
53
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
32
54
  <div
33
55
  id={id}
34
56
  className={[
35
-
36
57
  baseClassName,
37
-
38
58
  componentClassName,
39
59
  userClassName,
40
60
  noScrollOnDesktop && 'desktop-no-scroll',
@@ -42,6 +62,10 @@ const SnapScroller = ({
42
62
  .filter((e) => e)
43
63
  .join(' ')}
44
64
  style={style}
65
+ ref={ref}
66
+ onMouseDown={noScrollOnDesktop ? null : onMouseDown}
67
+ onMouseUp={noScrollOnDesktop ? null : onMouseUp}
68
+ onMouseMove={noScrollOnDesktop ? null : onMouseMove}
45
69
  // {...otherProps}
46
70
  >
47
71
  {children}
@@ -2959,6 +2959,9 @@ exports[`Storyshots a/SVG Stroke 1`] = `
2959
2959
  exports[`Storyshots a/SnapScroller Base 1`] = `
2960
2960
  <div
2961
2961
  className="base snap-scroller u1 pv-u"
2962
+ onMouseDown={[Function]}
2963
+ onMouseMove={[Function]}
2964
+ onMouseUp={[Function]}
2962
2965
  style={
2963
2966
  {
2964
2967
  "background": "var(--background4)",
@@ -3036,6 +3039,9 @@ exports[`Storyshots a/SnapScroller Base 1`] = `
3036
3039
  exports[`Storyshots a/SnapScroller No Scroll On Desktop 1`] = `
3037
3040
  <div
3038
3041
  className="base snap-scroller u1 pv-u desktop-no-scroll"
3042
+ onMouseDown={null}
3043
+ onMouseMove={null}
3044
+ onMouseUp={null}
3039
3045
  style={
3040
3046
  {
3041
3047
  "background": "var(--background4)",
@@ -11731,6 +11737,9 @@ exports[`Storyshots b/Card Card With Progress 1`] = `
11731
11737
  exports[`Storyshots b/Card/Group Base 1`] = `
11732
11738
  <div
11733
11739
  className="base snap-scroller base group span-8 snap-scroller desktop-vertical-flexbox desktop-no-scroll"
11740
+ onMouseDown={null}
11741
+ onMouseMove={null}
11742
+ onMouseUp={null}
11734
11743
  >
11735
11744
  <div
11736
11745
  className="base card span-2"
@@ -11771,6 +11780,9 @@ exports[`Storyshots b/Card/Group Base 1`] = `
11771
11780
  exports[`Storyshots b/Card/Group Card Group Grid On Desktop 1`] = `
11772
11781
  <div
11773
11782
  className="base snap-scroller base group span-8 snap-scroller desktop-grid desktop-no-scroll"
11783
+ onMouseDown={null}
11784
+ onMouseMove={null}
11785
+ onMouseUp={null}
11774
11786
  >
11775
11787
  <div
11776
11788
  className="base card span-2"