@pareto-engineering/design-system 4.0.0-alpha.58 → 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
  /**
@@ -23,7 +23,7 @@ const ToggleSwitch = _ref => {
23
23
  id,
24
24
  className: userClassName,
25
25
  style,
26
- handleOnChange,
26
+ handleOnClick,
27
27
  checked,
28
28
  size
29
29
  // ...otherProps
@@ -38,13 +38,13 @@ const ToggleSwitch = _ref => {
38
38
  '--size': size,
39
39
  ...style
40
40
  },
41
+ onClick: handleOnClick,
41
42
  type: "button"
42
43
  // {...otherProps}
43
44
  }, /*#__PURE__*/React.createElement("input", {
44
45
  type: "checkbox",
45
46
  id: "switch",
46
- checked: checked,
47
- onChange: handleOnChange
47
+ checked: checked
48
48
  }), /*#__PURE__*/React.createElement("label", {
49
49
  htmlFor: "switch"
50
50
  }));
@@ -65,7 +65,7 @@ ToggleSwitch.propTypes = {
65
65
  /**
66
66
  * The onClick handler for this element
67
67
  */
68
- handleOnChange: _propTypes.default.func,
68
+ handleOnClick: _propTypes.default.func,
69
69
  /**
70
70
  * The checked state of this element
71
71
  */
@@ -45,7 +45,7 @@ const ThemeSelector = _ref => {
45
45
  className: "c-x x-paragraph"
46
46
  }, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(_a.ToggleSwitch, {
47
47
  checked: userTheme === 'dark',
48
- handleOnChange: loopThemes
48
+ handleOnClick: loopThemes
49
49
  }));
50
50
  };
51
51
  ThemeSelector.propTypes = {
@@ -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
  /**
@@ -16,7 +16,7 @@ const ToggleSwitch = ({
16
16
  id,
17
17
  className: userClassName,
18
18
  style,
19
- handleOnChange,
19
+ handleOnClick,
20
20
  checked,
21
21
  size
22
22
  // ...otherProps
@@ -31,13 +31,13 @@ const ToggleSwitch = ({
31
31
  '--size': size,
32
32
  ...style
33
33
  },
34
+ onClick: handleOnClick,
34
35
  type: "button"
35
36
  // {...otherProps}
36
37
  }, /*#__PURE__*/React.createElement("input", {
37
38
  type: "checkbox",
38
39
  id: "switch",
39
- checked: checked,
40
- onChange: handleOnChange
40
+ checked: checked
41
41
  }), /*#__PURE__*/React.createElement("label", {
42
42
  htmlFor: "switch"
43
43
  }));
@@ -58,7 +58,7 @@ ToggleSwitch.propTypes = {
58
58
  /**
59
59
  * The onClick handler for this element
60
60
  */
61
- handleOnChange: PropTypes.func,
61
+ handleOnClick: PropTypes.func,
62
62
  /**
63
63
  * The checked state of this element
64
64
  */
@@ -38,7 +38,7 @@ const ThemeSelector = ({
38
38
  className: "c-x x-paragraph"
39
39
  }, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(ToggleSwitch, {
40
40
  checked: userTheme === 'dark',
41
- handleOnChange: loopThemes
41
+ handleOnClick: loopThemes
42
42
  }));
43
43
  };
44
44
  ThemeSelector.propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.58",
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": "dcccc8b3170d8f1f27d4fbbe653aebdf4b5f829b"
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}
@@ -20,7 +20,7 @@ const ToggleSwitch = ({
20
20
  id,
21
21
  className:userClassName,
22
22
  style,
23
- handleOnChange,
23
+ handleOnClick,
24
24
  checked,
25
25
  size,
26
26
  // ...otherProps
@@ -45,15 +45,11 @@ const ToggleSwitch = ({
45
45
  '--size':size,
46
46
  ...style,
47
47
  }}
48
+ onClick={handleOnClick}
48
49
  type="button"
49
50
  // {...otherProps}
50
51
  >
51
- <input
52
- type="checkbox"
53
- id="switch"
54
- checked={checked}
55
- onChange={handleOnChange}
56
- />
52
+ <input type="checkbox" id="switch" checked={checked} />
57
53
  {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
58
54
  <label htmlFor="switch" />
59
55
  </button>
@@ -79,7 +75,7 @@ ToggleSwitch.propTypes = {
79
75
  /**
80
76
  * The onClick handler for this element
81
77
  */
82
- handleOnChange:PropTypes.func,
78
+ handleOnClick:PropTypes.func,
83
79
 
84
80
  /**
85
81
  * The checked state of this element
@@ -53,7 +53,7 @@ const ThemeSelector = ({
53
53
  {' '}
54
54
  Theme
55
55
  </span>
56
- <ToggleSwitch checked={userTheme === 'dark'} handleOnChange={loopThemes} />
56
+ <ToggleSwitch checked={userTheme === 'dark'} handleOnClick={loopThemes} />
57
57
  </div>
58
58
  )
59
59
  }
@@ -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"