@synerise/ds-logic 0.6.2 → 0.7.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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.7.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-logic@0.6.4...@synerise/ds-logic@0.7.0) (2022-04-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **logic:** removes dropdown, now value is changing by clicking on it like Logic.Matching ([711abcf](https://github.com/Synerise/synerise-design/commit/711abcf35191b8376418242b23ad6f7680ab52e1))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.6.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-logic@0.6.3...@synerise/ds-logic@0.6.4) (2022-03-30)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-logic
20
+
21
+
22
+
23
+
24
+
25
+ ## [0.6.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-logic@0.6.2...@synerise/ds-logic@0.6.3) (2022-03-24)
26
+
27
+ **Note:** Version bump only for package @synerise/ds-logic
28
+
29
+
30
+
31
+
32
+
6
33
  ## [0.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-logic@0.6.1...@synerise/ds-logic@0.6.2) (2022-03-24)
7
34
 
8
35
  **Note:** Version bump only for package @synerise/ds-logic
package/dist/Logic.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
- import Dropdown from '@synerise/ds-dropdown';
3
- import { useOnClickOutside } from '@synerise/ds-utils';
4
2
  import { useIntl } from 'react-intl';
3
+ import { Title } from '@synerise/ds-typography';
5
4
  import * as S from './Logic.style';
6
5
  import Matching from './Matching/Matching';
7
6
  var DEFAULT_OPTIONS = ['AND', 'OR'];
@@ -11,15 +10,6 @@ var Logic = function Logic(_ref) {
11
10
  options = _ref.options,
12
11
  onChange = _ref.onChange;
13
12
  var intl = useIntl();
14
-
15
- var _React$useState = React.useState(false),
16
- optionsVisible = _React$useState[0],
17
- setOptionsVisible = _React$useState[1];
18
-
19
- var ref = React.useRef(null);
20
- useOnClickOutside(ref, function () {
21
- setOptionsVisible(false);
22
- });
23
13
  var operators = React.useMemo(function () {
24
14
  if (options !== undefined && options.length) {
25
15
  return options;
@@ -34,28 +24,12 @@ var Logic = function Logic(_ref) {
34
24
  };
35
25
  });
36
26
  }, [options, intl]);
37
- var getOptions = React.useMemo(function () {
38
- return (
39
- /*#__PURE__*/
40
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
41
- // @ts-ignore
42
- React.createElement(S.Wrapper, {
43
- ref: ref
44
- }, /*#__PURE__*/React.createElement(S.LogicMenu, {
45
- asDropdownMenu: true
46
- }, operators.map(function (operator) {
47
- return /*#__PURE__*/React.createElement(S.MenuItem, {
48
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
49
- // @ts-ignore
50
- key: operator,
51
- checked: operator.value === value,
52
- onClick: function onClick() {
53
- setOptionsVisible(false);
54
- onChange(operator.value);
55
- }
56
- }, operator.label);
57
- })))
58
- );
27
+ var handleNextLogic = React.useCallback(function () {
28
+ var currentOperatorIndex = operators.findIndex(function (operator) {
29
+ return operator.value === value;
30
+ });
31
+ var nextOperatorIndex = currentOperatorIndex + 1 >= operators.length ? 0 : currentOperatorIndex + 1;
32
+ onChange(operators[nextOperatorIndex].value);
59
33
  }, [onChange, operators, value]);
60
34
  var renderValue = React.useMemo(function () {
61
35
  var _operators$find;
@@ -64,18 +38,13 @@ var Logic = function Logic(_ref) {
64
38
  return option.value === value;
65
39
  })) == null ? void 0 : _operators$find.label;
66
40
  }, [operators, value]);
67
- return /*#__PURE__*/React.createElement(Dropdown, {
68
- overlay: getOptions,
69
- visible: optionsVisible
70
- }, /*#__PURE__*/React.createElement(S.Logic, {
71
- className: "ds-logic"
72
- }, /*#__PURE__*/React.createElement(Dropdown.TextTrigger, {
73
- value: renderValue,
74
- size: 4,
75
- onClick: function onClick() {
76
- return setOptionsVisible(!optionsVisible);
77
- }
78
- })));
41
+ return /*#__PURE__*/React.createElement(S.Logic, {
42
+ className: "ds-logic",
43
+ onClick: handleNextLogic
44
+ }, /*#__PURE__*/React.createElement(Title, {
45
+ withoutMargin: true,
46
+ level: 4
47
+ }, renderValue));
79
48
  };
80
49
 
81
50
  Logic.Matching = Matching;
@@ -1,6 +1 @@
1
- /// <reference types="react" />
2
- import Menu from '@synerise/ds-menu';
3
- export declare const MenuItem: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-menu/dist/Elements/SubMenu/SubMenu.types").SubMenuProps & import("@synerise/ds-menu").MenuItemProps>, any, {}, never>;
4
- export declare const LogicMenu: import("styled-components").StyledComponent<typeof Menu, any, {}, never>;
5
1
  export declare const Logic: import("styled-components").StyledComponent<"div", any, {}, never>;
6
- export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,19 +1,16 @@
1
- import Menu from '@synerise/ds-menu';
2
- import styled from 'styled-components';
3
- import Dropdown from '@synerise/ds-dropdown';
4
- export var MenuItem = styled(Menu.Item).withConfig({
5
- displayName: "Logicstyle__MenuItem",
6
- componentId: "yp0pif-0"
7
- })(["min-width:80px;"]);
8
- export var LogicMenu = styled(Menu).withConfig({
9
- displayName: "Logicstyle__LogicMenu",
10
- componentId: "yp0pif-1"
11
- })(["&&&{width:auto;}"]);
1
+ import styled from 'styled-components'; // eslint-disable-next-line import/prefer-default-export
2
+
12
3
  export var Logic = styled.div.withConfig({
13
4
  displayName: "Logicstyle__Logic",
14
- componentId: "yp0pif-2"
15
- })(["&&&{.ds-title{text-transform:uppercase;}}"]);
16
- export var Wrapper = styled(Dropdown.Wrapper).withConfig({
17
- displayName: "Logicstyle__Wrapper",
18
- componentId: "yp0pif-3"
19
- })(["width:auto;"]);
5
+ componentId: "yp0pif-0"
6
+ })(["user-select:none;position:relative;.ds-title{cursor:pointer;&:after{position:absolute;bottom:-2px;width:100%;content:'';height:1px;left:1px;background-image:linear-gradient( to right,", " 25%,", " 0% );background-position:top;background-size:4px 1px;background-repeat:repeat-x;}}&:hover{.ds-title{color:", ";&:after{background-image:linear-gradient( to right,", " 25%,", " 0% );}}}"], function (props) {
7
+ return props.theme.palette['grey-600'];
8
+ }, function (props) {
9
+ return props.theme.palette.white;
10
+ }, function (props) {
11
+ return props.theme.palette['blue-700'];
12
+ }, function (props) {
13
+ return props.theme.palette['blue-700'];
14
+ }, function (props) {
15
+ return props.theme.palette.white;
16
+ });
@@ -34,7 +34,8 @@ var Matching = function Matching(_ref) {
34
34
  var getToggle = React.useMemo(function () {
35
35
  return /*#__PURE__*/React.createElement(S.Toggle, {
36
36
  onClick: handleClick,
37
- matching: matching
37
+ matching: matching,
38
+ className: "ds-matching-toggle"
38
39
  }, matching ? text.matching : text.notMatching);
39
40
  }, [handleClick, matching, text]);
40
41
  var getLabelWithToggle = React.useMemo(function () {
@@ -8,8 +8,16 @@ export var MatchingWrapper = styled.div.withConfig({
8
8
  export var Toggle = styled.span.withConfig({
9
9
  displayName: "Matchingstyles__Toggle",
10
10
  componentId: "sc-7z57qz-1"
11
- })(["cursor:pointer;font-size:16px;font-weight:500;line-height:1.25;color:", ";transition:color 0.1s ease-in-out;&:hover{color:", ";}"], function (props) {
11
+ })(["cursor:pointer;font-size:16px;font-weight:500;line-height:1.25;color:", ";transition:color 0.1s ease-in-out;position:relative;&:after{position:absolute;bottom:-2px;width:100%;content:'';height:1px;left:1px;background-image:linear-gradient( to right,", " 25%,", " 0% );background-position:top;background-size:4px 1px;background-repeat:repeat-x;}&:hover{color:", ";&:after{background-image:linear-gradient( to right,", " 25%,", " 0% );}}"], function (props) {
12
12
  return props.theme.palette["blue-600"];
13
+ }, function (props) {
14
+ return props.theme.palette['blue-600'];
15
+ }, function (props) {
16
+ return props.theme.palette.white;
13
17
  }, function (props) {
14
18
  return props.theme.palette["blue-700"];
19
+ }, function (props) {
20
+ return props.theme.palette['blue-700'];
21
+ }, function (props) {
22
+ return props.theme.palette.white;
15
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-logic",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Logic UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,14 +32,13 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-dropdown": "^0.17.13",
36
- "@synerise/ds-icon": "^0.48.0",
37
- "@synerise/ds-menu": "^0.13.0",
35
+ "@synerise/ds-icon": "^0.49.0",
36
+ "@synerise/ds-typography": "^0.12.2",
38
37
  "@synerise/ds-utils": "^0.19.0"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "@synerise/ds-core": "*",
42
41
  "react": ">=16.9.0 < 17.0.0"
43
42
  },
44
- "gitHead": "7f696cdfd31f36bbeeb750df44b0f6d2010d0c9d"
43
+ "gitHead": "5793ce09feb88b36cc8ca1923ddfcb272b889cb0"
45
44
  }