@synerise/ds-operators 1.1.22 → 1.1.24

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,14 @@
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
+ ## [1.1.24](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@1.1.23...@synerise/ds-operators@1.1.24) (2026-03-24)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-operators
9
+
10
+ ## [1.1.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@1.1.22...@synerise/ds-operators@1.1.23) (2026-03-20)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-operators
13
+
6
14
  ## [1.1.22](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@1.1.21...@synerise/ds-operators@1.1.22) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-operators
package/README.md CHANGED
@@ -80,16 +80,18 @@ import Operators from '@synerise/ds-operators'
80
80
 
81
81
  | Property | Description | Type | Default |
82
82
  | ------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | --------- |
83
- | error | error validation | boolean | - |
84
- | getPopupContainerOverride | Popup container function for child tooltips and dropdowns | (trigger: HTMLElement \ null) => HTMLElement; | - |
85
- | groups | Groups of operators | OperatorsGroup[] | [] |
86
- | items | Array of operators | OperatorsItem[] | [] |
87
- | onActivate | Callback called when user opens dropdown | (fieldType: string) => void | - |
88
- | onChange | Callback called when user selects operator | (item: OperatorsItem \ OperatorsGroup \ undefined) => void | - |
89
- | onDeactivate | Callback called when user closes dropdown | () => void | - |
90
- | opened | Whether if dropdown should opens from outside of component | boolean | false |
91
- | texts | Translations object | OperatorTexts | - |
92
- | value | Selected operator | OperatorsItem \ undefined | undefined |
83
+ | errorText | Puts the trigger button in error state | ReactNode | - |
84
+ | getPopupContainerOverride | Popup container function for child tooltips and dropdowns | (trigger: HTMLElement \| null) => HTMLElement | - |
85
+ | groups | Groups of operators | OperatorsGroup[] | - |
86
+ | items | Array of operators | OperatorsItem[] | - |
87
+ | onActivate | Callback called when user opens dropdown | () => void | - |
88
+ | onChange | Callback called when user selects operator | (item: OperatorsItem \| undefined) => void | - |
89
+ | onDeactivate | Callback called when user closes dropdown | () => void | - |
90
+ | opened | Whether if dropdown should opens from outside of component | boolean | false |
91
+ | readOnly | Disables the dropdown; shows selected value without arrow | boolean | false |
92
+ | texts | Translations object | Partial\<OperatorTexts\> | - |
93
+ | value | Selected operator | OperatorsItem \| undefined | undefined |
94
+ | dropdownDimensionsConfig | Override responsive height thresholds | `{ defaultHeight?, lowerHeight?, threshold? }`| - |
93
95
 
94
96
  ### OperatorsGroup
95
97
 
@@ -1,4 +1,4 @@
1
- import { type ReactNode, type ReactText } from 'react';
1
+ import { ReactNode, ReactText } from 'react';
2
2
  export type OperatorTexts = {
3
3
  buttonLabel: string;
4
4
  searchPlaceholder: string;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type OperatorsProps } from './Operator.types';
1
+ import { default as React } from 'react';
2
+ import { OperatorsProps } from './Operator.types';
3
3
  declare const Operators: ({ value, onChange, groups, items, texts, opened, getPopupContainerOverride, onActivate, onDeactivate, readOnly, errorText, dropdownDimensionsConfig, }: OperatorsProps) => React.JSX.Element;
4
4
  export default Operators;
package/dist/Operators.js CHANGED
@@ -1,125 +1,95 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
- import { useIntl } from 'react-intl';
4
- import Button from '@synerise/ds-button';
5
- import Dropdown from '@synerise/ds-dropdown';
6
- import Icon, { AngleDownS } from '@synerise/ds-icon';
7
- import Tooltip from '@synerise/ds-tooltip';
8
- import { getPopupContainer } from '@synerise/ds-utils';
9
- import * as S from './Operators.style';
10
- import OperatorsDropdown from './OperatorsDropdown/OperatorsDropdown';
11
- import { DROPDOWN_HEIGHT, DROPDOWN_HEIGHT_BELOW_THRESHOLD, DROPDOWN_HEIGHT_THRESHOLD } from './constants';
12
- var isOperatorItem = function isOperatorItem(item) {
13
- return 'groupId' in item;
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useMemo, useCallback, useEffect } from "react";
3
+ import { useIntl } from "react-intl";
4
+ import Button from "@synerise/ds-button";
5
+ import Dropdown from "@synerise/ds-dropdown";
6
+ import Icon, { AngleDownS } from "@synerise/ds-icon";
7
+ import Tooltip from "@synerise/ds-tooltip";
8
+ import { getPopupContainer } from "@synerise/ds-utils";
9
+ import { Value } from "./Operators.style.js";
10
+ import OperatorsDropdown from "./OperatorsDropdown/OperatorsDropdown.js";
11
+ import { DROPDOWN_HEIGHT, DROPDOWN_HEIGHT_BELOW_THRESHOLD, DROPDOWN_HEIGHT_THRESHOLD } from "./constants.js";
12
+ const isOperatorItem = (item) => {
13
+ return "groupId" in item;
14
14
  };
15
- var Operators = function Operators(_ref) {
16
- var value = _ref.value,
17
- onChange = _ref.onChange,
18
- groups = _ref.groups,
19
- items = _ref.items,
20
- texts = _ref.texts,
21
- opened = _ref.opened,
22
- getPopupContainerOverride = _ref.getPopupContainerOverride,
23
- onActivate = _ref.onActivate,
24
- onDeactivate = _ref.onDeactivate,
25
- _ref$readOnly = _ref.readOnly,
26
- readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
27
- errorText = _ref.errorText,
28
- dropdownDimensionsConfig = _ref.dropdownDimensionsConfig;
29
- var dimensionsConfig = _extends({
15
+ const Operators = ({
16
+ value,
17
+ onChange,
18
+ groups,
19
+ items,
20
+ texts,
21
+ opened,
22
+ getPopupContainerOverride,
23
+ onActivate,
24
+ onDeactivate,
25
+ readOnly = false,
26
+ errorText,
27
+ dropdownDimensionsConfig
28
+ }) => {
29
+ const dimensionsConfig = {
30
30
  defaultHeight: DROPDOWN_HEIGHT,
31
31
  lowerHeight: DROPDOWN_HEIGHT_BELOW_THRESHOLD,
32
- threshold: DROPDOWN_HEIGHT_THRESHOLD
33
- }, dropdownDimensionsConfig);
34
- var _useIntl = useIntl(),
35
- formatMessage = _useIntl.formatMessage;
36
- var _useState = useState(false),
37
- dropdownVisible = _useState[0],
38
- setDropdownVisible = _useState[1];
39
- var _useState2 = useState(dimensionsConfig.defaultHeight),
40
- outerHeight = _useState2[0],
41
- setOuterHeight = _useState2[1];
42
- var text = useMemo(function () {
43
- return _extends({
44
- buttonLabel: formatMessage({
45
- id: 'DS.OPERATORS.BUTTON_LABEL',
46
- defaultMessage: 'Choose'
47
- }),
48
- searchPlaceholder: formatMessage({
49
- id: 'DS.OPERATORS.SEARCH_PLACEHOLDER',
50
- defaultMessage: 'Search'
51
- }),
52
- noResults: formatMessage({
53
- id: 'DS.OPERATORS.NO_RESULTS',
54
- defaultMessage: 'No results'
55
- })
56
- }, texts);
57
- }, [texts, formatMessage]);
58
- var handleChange = useCallback(function (val) {
32
+ threshold: DROPDOWN_HEIGHT_THRESHOLD,
33
+ ...dropdownDimensionsConfig
34
+ };
35
+ const {
36
+ formatMessage
37
+ } = useIntl();
38
+ const [dropdownVisible, setDropdownVisible] = useState(false);
39
+ const [outerHeight, setOuterHeight] = useState(dimensionsConfig.defaultHeight);
40
+ const text = useMemo(() => ({
41
+ buttonLabel: formatMessage({
42
+ id: "DS.OPERATORS.BUTTON_LABEL",
43
+ defaultMessage: "Choose"
44
+ }),
45
+ searchPlaceholder: formatMessage({
46
+ id: "DS.OPERATORS.SEARCH_PLACEHOLDER",
47
+ defaultMessage: "Search"
48
+ }),
49
+ noResults: formatMessage({
50
+ id: "DS.OPERATORS.NO_RESULTS",
51
+ defaultMessage: "No results"
52
+ }),
53
+ ...texts
54
+ }), [texts, formatMessage]);
55
+ const handleChange = useCallback((val) => {
59
56
  (!val || isOperatorItem(val)) && onChange(val);
60
57
  }, [onChange]);
61
- useEffect(function () {
58
+ useEffect(() => {
62
59
  setDropdownVisible(Boolean(opened));
63
60
  }, [opened]);
64
- var handleClick = useCallback(function () {
65
- onActivate == null || onActivate();
61
+ const handleClick = useCallback(() => {
62
+ onActivate?.();
66
63
  }, [onActivate]);
67
- var onDropdownVisibilityChange = useCallback(function (newValue) {
64
+ const onDropdownVisibilityChange = useCallback((newValue) => {
68
65
  setDropdownVisible(newValue);
69
- newValue && (onActivate == null ? void 0 : onActivate());
66
+ newValue && onActivate?.();
70
67
  }, [onActivate]);
71
- var triggerMode = useMemo(function () {
68
+ const triggerMode = useMemo(() => {
72
69
  if (value) {
73
- return readOnly ? 'icon-label' : 'two-icons';
70
+ return readOnly ? "icon-label" : "two-icons";
74
71
  }
75
- return readOnly ? 'simple' : 'label-icon';
72
+ return readOnly ? "simple" : "label-icon";
76
73
  }, [value, readOnly]);
77
- var dropdownTrigger = /*#__PURE__*/React.createElement(Tooltip, {
78
- getPopupContainer: getPopupContainerOverride || getPopupContainer,
79
- title: (value == null ? void 0 : value.name) || '',
80
- trigger: ['hover']
81
- }, /*#__PURE__*/React.createElement(Button, {
82
- error: Boolean(errorText),
83
- type: "secondary",
84
- mode: triggerMode,
85
- onClick: !readOnly ? handleClick : undefined,
86
- readOnly: readOnly
87
- }, value && /*#__PURE__*/React.createElement(Icon, {
88
- component: value.icon
89
- }), /*#__PURE__*/React.createElement(S.Value, null, value ? value.name : text.buttonLabel), !readOnly && /*#__PURE__*/React.createElement(Icon, {
90
- component: /*#__PURE__*/React.createElement(AngleDownS, null)
91
- })));
92
- useEffect(function () {
93
- var checkViewportHeight = function checkViewportHeight() {
94
- return setOuterHeight(window.innerHeight < dimensionsConfig.threshold ? dimensionsConfig.lowerHeight : dimensionsConfig.defaultHeight);
95
- };
74
+ const dropdownTrigger = /* @__PURE__ */ jsx(Tooltip, { getPopupContainer: getPopupContainerOverride || getPopupContainer, title: value?.name || "", trigger: ["hover"], children: /* @__PURE__ */ jsxs(Button, { error: Boolean(errorText), type: "secondary", mode: triggerMode, onClick: !readOnly ? handleClick : void 0, readOnly, children: [
75
+ value && /* @__PURE__ */ jsx(Icon, { component: value.icon }),
76
+ /* @__PURE__ */ jsx(Value, { children: value ? value.name : text.buttonLabel }),
77
+ !readOnly && /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AngleDownS, {}) })
78
+ ] }) });
79
+ useEffect(() => {
80
+ const checkViewportHeight = () => setOuterHeight(window.innerHeight < dimensionsConfig.threshold ? dimensionsConfig.lowerHeight : dimensionsConfig.defaultHeight);
96
81
  checkViewportHeight();
97
- window.addEventListener('resize', checkViewportHeight);
98
- return function () {
99
- window.removeEventListener('resize', checkViewportHeight);
82
+ window.addEventListener("resize", checkViewportHeight);
83
+ return () => {
84
+ window.removeEventListener("resize", checkViewportHeight);
100
85
  };
101
86
  }, [dimensionsConfig.defaultHeight, dimensionsConfig.lowerHeight, dimensionsConfig.threshold]);
102
- var content = readOnly ? dropdownTrigger : /*#__PURE__*/React.createElement(Dropdown, {
103
- open: dropdownVisible,
104
- onOpenChange: onDropdownVisibilityChange,
105
- getPopupContainer: getPopupContainerOverride || getPopupContainer,
106
- asChild: false,
107
- size: "medium",
108
- onDismiss: onDeactivate,
109
- popoverProps: {
110
- testId: 'operators',
111
- returnFocus: false
112
- },
113
- overlay: /*#__PURE__*/React.createElement(OperatorsDropdown, {
114
- value: value,
115
- setDropdownVisible: setDropdownVisible,
116
- setSelected: handleChange,
117
- groups: groups,
118
- items: items,
119
- texts: text,
120
- outerHeight: outerHeight
121
- })
122
- }, dropdownTrigger);
87
+ const content = readOnly ? dropdownTrigger : /* @__PURE__ */ jsx(Dropdown, { open: dropdownVisible, onOpenChange: onDropdownVisibilityChange, getPopupContainer: getPopupContainerOverride || getPopupContainer, asChild: false, size: "medium", onDismiss: onDeactivate, popoverProps: {
88
+ testId: "operators",
89
+ returnFocus: false
90
+ }, overlay: /* @__PURE__ */ jsx(OperatorsDropdown, { value, setDropdownVisible, setSelected: handleChange, groups, items, texts: text, outerHeight }), children: dropdownTrigger });
123
91
  return content;
124
92
  };
125
- export default Operators;
93
+ export {
94
+ Operators as default
95
+ };
@@ -1,9 +1,9 @@
1
- export declare const TabsWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const ContentPlaceholder: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const ItemsList: import("styled-components").StyledComponent<"div", any, {
1
+ export declare const TabsWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
2
+ export declare const ContentPlaceholder: import('styled-components').StyledComponent<"div", any, {}, never>;
3
+ export declare const ItemsList: import('styled-components').StyledComponent<"div", any, {
4
4
  contentHeight?: number;
5
5
  }, never>;
6
- export declare const SearchResult: import("styled-components").StyledComponent<"span", any, {}, never>;
7
- export declare const SearchResultHighlight: import("styled-components").StyledComponent<"span", any, {}, never>;
8
- export declare const Title: import("styled-components").StyledComponent<"div", any, {}, never>;
9
- export declare const Value: import("styled-components").StyledComponent<"span", any, {}, never>;
6
+ export declare const SearchResult: import('styled-components').StyledComponent<"span", any, {}, never>;
7
+ export declare const SearchResultHighlight: import('styled-components').StyledComponent<"span", any, {}, never>;
8
+ export declare const Title: import('styled-components').StyledComponent<"div", any, {}, never>;
9
+ export declare const Value: import('styled-components').StyledComponent<"span", any, {}, never>;
@@ -1,39 +1,38 @@
1
- import styled from 'styled-components';
2
- export var TabsWrapper = styled.div.withConfig({
1
+ import styled from "styled-components";
2
+ const TabsWrapper = /* @__PURE__ */ styled.div.withConfig({
3
3
  displayName: "Operatorsstyle__TabsWrapper",
4
4
  componentId: "sc-vzf1ol-0"
5
5
  })(["width:100%;padding:0 0 8px 0;"]);
6
- export var ContentPlaceholder = styled.div.withConfig({
6
+ const ContentPlaceholder = /* @__PURE__ */ styled.div.withConfig({
7
7
  displayName: "Operatorsstyle__ContentPlaceholder",
8
8
  componentId: "sc-vzf1ol-1"
9
9
  })(["height:100px;"]);
10
- export var ItemsList = styled.div.withConfig({
10
+ const ItemsList = /* @__PURE__ */ styled.div.withConfig({
11
11
  displayName: "Operatorsstyle__ItemsList",
12
12
  componentId: "sc-vzf1ol-2"
13
- })(["width:100%;backgorund:", ";", ""], function (props) {
14
- return props.theme.palette.white;
15
- }, function (props) {
16
- return props.contentHeight !== undefined && "height: " + props.contentHeight + "px;";
17
- });
18
- export var SearchResult = styled.span.withConfig({
13
+ })(["width:100%;backgorund:", ";", ""], (props) => props.theme.palette.white, (props) => props.contentHeight !== void 0 && `height: ${props.contentHeight}px;`);
14
+ const SearchResult = /* @__PURE__ */ styled.span.withConfig({
19
15
  displayName: "Operatorsstyle__SearchResult",
20
16
  componentId: "sc-vzf1ol-3"
21
- })(["font-weight:400;color:", ";"], function (props) {
22
- return props.theme.palette['grey-500'];
23
- });
24
- export var SearchResultHighlight = styled.span.withConfig({
17
+ })(["font-weight:400;color:", ";"], (props) => props.theme.palette["grey-500"]);
18
+ const SearchResultHighlight = /* @__PURE__ */ styled.span.withConfig({
25
19
  displayName: "Operatorsstyle__SearchResultHighlight",
26
20
  componentId: "sc-vzf1ol-4"
27
- })(["font-weight:500;color:", ";"], function (props) {
28
- return props.theme.palette['grey-700'];
29
- });
30
- export var Title = styled.div.withConfig({
21
+ })(["font-weight:500;color:", ";"], (props) => props.theme.palette["grey-700"]);
22
+ const Title = /* @__PURE__ */ styled.div.withConfig({
31
23
  displayName: "Operatorsstyle__Title",
32
24
  componentId: "sc-vzf1ol-5"
33
- })(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:", ";padding:8px 12px;"], function (props) {
34
- return props.theme.palette['grey-500'];
35
- });
36
- export var Value = styled.span.withConfig({
25
+ })(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:", ";padding:8px 12px;"], (props) => props.theme.palette["grey-500"]);
26
+ const Value = /* @__PURE__ */ styled.span.withConfig({
37
27
  displayName: "Operatorsstyle__Value",
38
28
  componentId: "sc-vzf1ol-6"
39
- })(["max-width:100px;text-overflow:ellipsis;overflow:hidden;"]);
29
+ })(["max-width:100px;text-overflow:ellipsis;overflow:hidden;"]);
30
+ export {
31
+ ContentPlaceholder,
32
+ ItemsList,
33
+ SearchResult,
34
+ SearchResultHighlight,
35
+ TabsWrapper,
36
+ Title,
37
+ Value
38
+ };
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type OperatorsDropdownProps } from '../Operator.types';
1
+ import { default as React } from 'react';
2
+ import { OperatorsDropdownProps } from '../Operator.types';
3
3
  declare const OperatorsDropdown: ({ texts, setSelected, groups, items, setDropdownVisible, value, outerHeight, }: OperatorsDropdownProps) => React.JSX.Element;
4
4
  export default OperatorsDropdown;
@@ -1,186 +1,104 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { v4 as uuid } from 'uuid';
3
- import { theme } from '@synerise/ds-core';
4
- import Dropdown from '@synerise/ds-dropdown';
5
- import Icon, { SearchM } from '@synerise/ds-icon';
6
- import Result from '@synerise/ds-result';
7
- import Scrollbar from '@synerise/ds-scrollbar';
8
- import Tabs from '@synerise/ds-tabs';
9
- import { focusWithArrowKeys } from '@synerise/ds-utils';
10
- import * as S from '../Operators.style';
11
- import { DEFAULT_TAB_INDEX, DROPDOWN_HEIGHT, NO_GROUP_NAME, PADDING, SEARCH_HEIGHT, TABS_HEIGHT } from '../constants';
12
- import { groupByGroupName } from '../utils';
13
- import OperatorsDropdownGroupName from './OperatorsDropdownGroupName';
14
- import OperatorsDropdownItem from './OperatorsDropdownItem';
15
- var OperatorsDropdown = function OperatorsDropdown(_ref) {
16
- var texts = _ref.texts,
17
- setSelected = _ref.setSelected,
18
- groups = _ref.groups,
19
- items = _ref.items,
20
- setDropdownVisible = _ref.setDropdownVisible,
21
- value = _ref.value,
22
- _ref$outerHeight = _ref.outerHeight,
23
- outerHeight = _ref$outerHeight === void 0 ? DROPDOWN_HEIGHT : _ref$outerHeight;
24
- var overlayRef = useRef(null);
25
- var _useState = useState(''),
26
- searchQuery = _useState[0],
27
- setSearchQuery = _useState[1];
28
- var _useState2 = useState(DEFAULT_TAB_INDEX),
29
- activeTab = _useState2[0],
30
- setActiveTab = _useState2[1];
31
- var _useState3 = useState(undefined),
32
- activeGroup = _useState3[0],
33
- setActiveGroup = _useState3[1];
34
- var _useState4 = useState(true),
35
- searchInputCanBeFocused = _useState4[0],
36
- setSearchInputFocus = _useState4[1];
37
- useEffect(function () {
38
- var defaultIndex = groups == null ? void 0 : groups.findIndex(function (group) {
39
- return group.defaultGroup || value && group.id === value.groupId;
40
- });
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect, useMemo, useCallback } from "react";
3
+ import { v4 } from "uuid";
4
+ import { theme } from "@synerise/ds-core";
5
+ import Dropdown from "@synerise/ds-dropdown";
6
+ import Icon, { SearchM } from "@synerise/ds-icon";
7
+ import Result from "@synerise/ds-result";
8
+ import Scrollbar from "@synerise/ds-scrollbar";
9
+ import Tabs from "@synerise/ds-tabs";
10
+ import { focusWithArrowKeys } from "@synerise/ds-utils";
11
+ import { TabsWrapper, ItemsList } from "../Operators.style.js";
12
+ import { DEFAULT_TAB_INDEX, NO_GROUP_NAME, DROPDOWN_HEIGHT, TABS_HEIGHT, SEARCH_HEIGHT, PADDING } from "../constants.js";
13
+ import { groupByGroupName } from "../utils/groupByGroupName.js";
14
+ import OperatorsDropdownGroupName from "./OperatorsDropdownGroupName.js";
15
+ import OperatorsDropdownItem from "./OperatorsDropdownItem.js";
16
+ const OperatorsDropdown = ({
17
+ texts,
18
+ setSelected,
19
+ groups,
20
+ items,
21
+ setDropdownVisible,
22
+ value,
23
+ outerHeight = DROPDOWN_HEIGHT
24
+ }) => {
25
+ const overlayRef = useRef(null);
26
+ const [searchQuery, setSearchQuery] = useState("");
27
+ const [activeTab, setActiveTab] = useState(DEFAULT_TAB_INDEX);
28
+ const [activeGroup, setActiveGroup] = useState(void 0);
29
+ const [searchInputCanBeFocused, setSearchInputFocus] = useState(true);
30
+ useEffect(() => {
31
+ const defaultIndex = groups?.findIndex((group) => group.defaultGroup || value && group.id === value.groupId);
41
32
  setActiveTab(defaultIndex === -1 ? DEFAULT_TAB_INDEX : defaultIndex);
42
33
  }, [groups, value]);
43
- var classNames = useMemo(function () {
44
- return "ds-operator-item ds-operator-item-" + uuid();
34
+ const classNames = useMemo(() => {
35
+ return `ds-operator-item ds-operator-item-${v4()}`;
45
36
  }, []);
46
- var renderGroupedItems = useCallback(function (activeItems) {
47
- var groupedItems = groupByGroupName(activeItems);
48
- var renderedItems = [];
49
- Object.keys(groupedItems).forEach(function (key) {
37
+ const renderGroupedItems = useCallback((activeItems) => {
38
+ const groupedItems = groupByGroupName(activeItems);
39
+ const renderedItems = [];
40
+ Object.keys(groupedItems).forEach((key) => {
50
41
  if (key !== NO_GROUP_NAME) {
51
- renderedItems.push(/*#__PURE__*/React.createElement(OperatorsDropdownGroupName, {
52
- "data-testid": "operator-group-title",
53
- name: key
54
- }));
42
+ renderedItems.push(/* @__PURE__ */ jsx(OperatorsDropdownGroupName, { "data-testid": "operator-group-title", name: key }));
55
43
  }
56
- groupedItems[key].forEach(function (item) {
57
- return renderedItems.push(/*#__PURE__*/React.createElement(OperatorsDropdownItem, {
58
- className: classNames,
59
- key: uuid(),
60
- item: item,
61
- searchQuery: searchQuery,
62
- hideDropdown: function hideDropdown() {
63
- return setDropdownVisible(false);
64
- },
65
- select: setSelected,
66
- selected: Boolean(value) && item.id === (value == null ? void 0 : value.id)
67
- }));
68
- });
44
+ groupedItems[key].forEach((item) => renderedItems.push(/* @__PURE__ */ jsx(OperatorsDropdownItem, { className: classNames, item, searchQuery, hideDropdown: () => setDropdownVisible(false), select: setSelected, selected: Boolean(value) && item.id === value?.id }, v4())));
69
45
  });
70
46
  return renderedItems;
71
47
  }, [searchQuery, setDropdownVisible, setSelected, value, classNames]);
72
- var currentTabItems = useMemo(function () {
73
- return groups == null ? void 0 : groups.find(function (group, index) {
48
+ const currentTabItems = useMemo(() => {
49
+ return groups?.find((group, index) => {
74
50
  return activeTab === index;
75
51
  });
76
52
  }, [groups, activeTab]);
77
- var filteredItems = useMemo(function () {
78
- return items.filter(function (item) {
79
- return item.name.toLowerCase().includes(searchQuery.toLowerCase());
80
- }).map(function (item) {
81
- return /*#__PURE__*/React.createElement(OperatorsDropdownItem, {
82
- className: classNames,
83
- key: item.name + item.groupId,
84
- item: item,
85
- searchQuery: searchQuery,
86
- clearSearch: function clearSearch() {
87
- return setSearchQuery('');
88
- },
89
- hideDropdown: function hideDropdown() {
90
- return setDropdownVisible(false);
91
- },
92
- select: setSelected,
93
- selected: Boolean(value) && item.id === (value == null ? void 0 : value.id)
94
- });
95
- });
96
- }, [items, searchQuery, setDropdownVisible, setSelected, value, classNames]);
97
- var currentItems = useMemo(function () {
53
+ const filteredItems = useMemo(() => items.filter((item) => item.name.toLowerCase().includes(searchQuery.toLowerCase())).map((item) => {
54
+ return /* @__PURE__ */ jsx(OperatorsDropdownItem, { className: classNames, item, searchQuery, clearSearch: () => setSearchQuery(""), hideDropdown: () => setDropdownVisible(false), select: setSelected, selected: Boolean(value) && item.id === value?.id }, item.name + item.groupId);
55
+ }), [items, searchQuery, setDropdownVisible, setSelected, value, classNames]);
56
+ const currentItems = useMemo(() => {
98
57
  if (searchQuery) {
99
58
  return filteredItems;
100
59
  }
101
- var hasSubgroups = Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
60
+ const hasSubgroups = Boolean(currentTabItems?.subGroups);
102
61
  if (hasSubgroups && !activeGroup) {
103
- var _currentTabItems$subG;
104
- return currentTabItems == null || (_currentTabItems$subG = currentTabItems.subGroups) == null ? void 0 : _currentTabItems$subG.map(function (subGroup) {
105
- return /*#__PURE__*/React.createElement(OperatorsDropdownItem, {
106
- className: classNames,
107
- key: subGroup.name + subGroup.id,
108
- item: subGroup,
109
- searchQuery: searchQuery,
110
- select: setActiveGroup
111
- });
62
+ return currentTabItems?.subGroups?.map((subGroup) => {
63
+ return /* @__PURE__ */ jsx(OperatorsDropdownItem, { className: classNames, item: subGroup, searchQuery, select: setActiveGroup }, subGroup.name + subGroup.id);
112
64
  });
113
65
  }
114
- if (activeGroup != null && activeGroup.id) {
115
- return renderGroupedItems(items == null ? void 0 : items.filter(function (item) {
116
- return item.groupId === activeGroup.id;
117
- }));
66
+ if (activeGroup?.id) {
67
+ return renderGroupedItems(items?.filter((item) => item.groupId === activeGroup.id));
118
68
  }
119
- return renderGroupedItems(items == null ? void 0 : items.filter(function (item) {
120
- var _groups$activeTab;
121
- return item.groupId === ((_groups$activeTab = groups[activeTab]) == null ? void 0 : _groups$activeTab.id);
122
- }));
69
+ return renderGroupedItems(items?.filter((item) => item.groupId === groups[activeTab]?.id));
123
70
  }, [currentTabItems, items, groups, searchQuery, activeTab, filteredItems, activeGroup, renderGroupedItems, classNames]);
124
- var handleSearch = useCallback(function (val) {
71
+ const handleSearch = useCallback((val) => {
125
72
  setSearchQuery(val);
126
73
  }, [setSearchQuery]);
127
- var getTabs = useMemo(function () {
128
- return (groups == null ? void 0 : groups.map(function (group) {
129
- return {
130
- icon: group.icon,
131
- tooltip: group.tooltip
132
- };
74
+ const getTabs = useMemo(() => {
75
+ return groups?.map((group) => ({
76
+ icon: group.icon,
77
+ tooltip: group.tooltip
133
78
  })) || [];
134
79
  }, [groups]);
135
- var hasTabs = getTabs.length > 1;
136
- var dropdownContentHeight = useMemo(function () {
80
+ const hasTabs = getTabs.length > 1;
81
+ const dropdownContentHeight = useMemo(() => {
137
82
  return outerHeight - (!searchQuery && hasTabs ? TABS_HEIGHT : 0) - SEARCH_HEIGHT;
138
83
  }, [hasTabs, searchQuery, outerHeight]);
139
- return /*#__PURE__*/React.createElement(Dropdown.Wrapper, {
140
- "data-testid": "ds-operators-dropdown-wrapper",
141
- style: {
142
- zIndex: 1005
143
- },
144
- ref: overlayRef,
145
- onKeyDown: function onKeyDown(e) {
146
- setSearchInputFocus(false);
147
- searchQuery && focusWithArrowKeys(e, classNames.split(' ')[1], function () {
148
- setSearchInputFocus(true);
149
- });
150
- }
151
- }, /*#__PURE__*/React.createElement(Dropdown.SearchInput, {
152
- onSearchChange: handleSearch,
153
- onClearInput: function onClearInput() {
154
- return handleSearch('');
155
- },
156
- placeholder: texts.searchPlaceholder,
157
- value: searchQuery,
158
- autofocus: !searchQuery || searchInputCanBeFocused,
159
- autofocusDelay: 50,
160
- iconLeft: /*#__PURE__*/React.createElement(Icon, {
161
- component: /*#__PURE__*/React.createElement(SearchM, null),
162
- color: theme.palette['grey-600']
163
- })
164
- }), searchQuery === '' && hasTabs && /*#__PURE__*/React.createElement(S.TabsWrapper, null, /*#__PURE__*/React.createElement(Tabs, {
165
- block: true,
166
- tabs: getTabs,
167
- activeTab: activeTab,
168
- handleTabClick: function handleTabClick(index) {
84
+ return /* @__PURE__ */ jsxs(Dropdown.Wrapper, { "data-testid": "ds-operators-dropdown-wrapper", style: {
85
+ zIndex: 1005
86
+ }, ref: overlayRef, onKeyDown: (e) => {
87
+ setSearchInputFocus(false);
88
+ searchQuery && focusWithArrowKeys(e, classNames.split(" ")[1], () => {
89
+ setSearchInputFocus(true);
90
+ });
91
+ }, children: [
92
+ /* @__PURE__ */ jsx(Dropdown.SearchInput, { onSearchChange: handleSearch, onClearInput: () => handleSearch(""), placeholder: texts.searchPlaceholder, value: searchQuery, autofocus: !searchQuery || searchInputCanBeFocused, autofocusDelay: 50, iconLeft: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchM, {}), color: theme.palette["grey-600"] }) }),
93
+ searchQuery === "" && hasTabs && /* @__PURE__ */ jsx(TabsWrapper, { children: /* @__PURE__ */ jsx(Tabs, { block: true, tabs: getTabs, activeTab, handleTabClick: (index) => {
169
94
  setActiveTab(index);
170
- setActiveGroup(undefined);
171
- }
172
- })), /*#__PURE__*/React.createElement(S.ItemsList, {
173
- contentHeight: dropdownContentHeight
174
- }, /*#__PURE__*/React.createElement(Scrollbar, {
175
- absolute: true,
176
- maxHeight: dropdownContentHeight,
177
- style: {
95
+ setActiveGroup(void 0);
96
+ } }) }),
97
+ /* @__PURE__ */ jsx(ItemsList, { contentHeight: dropdownContentHeight, children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, maxHeight: dropdownContentHeight, style: {
178
98
  padding: PADDING
179
- }
180
- }, currentItems != null && currentItems.length ? currentItems : /*#__PURE__*/React.createElement(Result, {
181
- noSearchResults: true,
182
- type: "no-results",
183
- description: texts.noResults
184
- }))));
99
+ }, children: currentItems?.length ? currentItems : /* @__PURE__ */ jsx(Result, { noSearchResults: true, type: "no-results", description: texts.noResults }) }) })
100
+ ] });
101
+ };
102
+ export {
103
+ OperatorsDropdown as default
185
104
  };
186
- export default OperatorsDropdown;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  declare const OperatorsDropdownGroupName: ({ name }: {
3
3
  name: string;
4
4
  }) => React.JSX.Element;
@@ -1,9 +1,10 @@
1
- import React from 'react';
2
- import * as S from '../Operators.style';
3
- var OperatorsDropdownGroupName = function OperatorsDropdownGroupName(_ref) {
4
- var name = _ref.name;
5
- return /*#__PURE__*/React.createElement(S.Title, {
6
- "data-testid": "operator-group-title"
7
- }, name);
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Title } from "../Operators.style.js";
3
+ const OperatorsDropdownGroupName = ({
4
+ name
5
+ }) => {
6
+ return /* @__PURE__ */ jsx(Title, { "data-testid": "operator-group-title", children: name });
7
+ };
8
+ export {
9
+ OperatorsDropdownGroupName as default
8
10
  };
9
- export default OperatorsDropdownGroupName;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { type OperatorsGroup, type OperatorsItem } from '../Operator.types';
1
+ import { default as React } from 'react';
2
+ import { OperatorsGroup, OperatorsItem } from '../Operator.types';
3
3
  type OperatorsDropdownItemProps = {
4
4
  item: OperatorsItem | OperatorsGroup;
5
5
  searchQuery: string;
@@ -1,31 +1,22 @@
1
- import React from 'react';
2
- import { theme } from '@synerise/ds-core';
3
- import Icon, { CheckS } from '@synerise/ds-icon';
4
- import ListItem from '@synerise/ds-list-item';
5
- var OperatorsDropdownItem = function OperatorsDropdownItem(_ref) {
6
- var item = _ref.item,
7
- clearSearch = _ref.clearSearch,
8
- searchQuery = _ref.searchQuery,
9
- hideDropdown = _ref.hideDropdown,
10
- select = _ref.select,
11
- selected = _ref.selected,
12
- className = _ref.className;
13
- return /*#__PURE__*/React.createElement(ListItem, {
14
- className: className,
15
- key: item.name + item.id,
16
- prefixel: searchQuery && /*#__PURE__*/React.createElement(Icon, {
17
- component: item.icon
18
- }),
19
- highlight: searchQuery,
20
- suffixel: selected && /*#__PURE__*/React.createElement(Icon, {
21
- component: /*#__PURE__*/React.createElement(CheckS, null),
22
- color: theme.palette['green-600']
23
- }),
24
- onClick: function onClick() {
25
- clearSearch && clearSearch();
26
- hideDropdown && hideDropdown();
27
- select && select(item);
28
- }
29
- }, item.name);
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { theme } from "@synerise/ds-core";
3
+ import Icon, { CheckS } from "@synerise/ds-icon";
4
+ import ListItem from "@synerise/ds-list-item";
5
+ const OperatorsDropdownItem = ({
6
+ item,
7
+ clearSearch,
8
+ searchQuery,
9
+ hideDropdown,
10
+ select,
11
+ selected,
12
+ className
13
+ }) => {
14
+ return /* @__PURE__ */ jsx(ListItem, { className, prefixel: searchQuery && /* @__PURE__ */ jsx(Icon, { component: item.icon }), highlight: searchQuery, suffixel: selected && /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CheckS, {}), color: theme.palette["green-600"] }), onClick: () => {
15
+ clearSearch && clearSearch();
16
+ hideDropdown && hideDropdown();
17
+ select && select(item);
18
+ }, children: item.name }, item.name + item.id);
19
+ };
20
+ export {
21
+ OperatorsDropdownItem as default
30
22
  };
31
- export default OperatorsDropdownItem;
package/dist/constants.js CHANGED
@@ -1,8 +1,18 @@
1
- export var NO_GROUP_NAME = 'NO_GROUP_NAME';
2
- export var DROPDOWN_HEIGHT = 420;
3
- export var DROPDOWN_HEIGHT_BELOW_THRESHOLD = 350;
4
- export var DROPDOWN_HEIGHT_THRESHOLD = 900;
5
- export var SEARCH_HEIGHT = 53;
6
- export var TABS_HEIGHT = 50;
7
- export var PADDING = 8;
8
- export var DEFAULT_TAB_INDEX = 0;
1
+ const NO_GROUP_NAME = "NO_GROUP_NAME";
2
+ const DROPDOWN_HEIGHT = 420;
3
+ const DROPDOWN_HEIGHT_BELOW_THRESHOLD = 350;
4
+ const DROPDOWN_HEIGHT_THRESHOLD = 900;
5
+ const SEARCH_HEIGHT = 53;
6
+ const TABS_HEIGHT = 50;
7
+ const PADDING = 8;
8
+ const DEFAULT_TAB_INDEX = 0;
9
+ export {
10
+ DEFAULT_TAB_INDEX,
11
+ DROPDOWN_HEIGHT,
12
+ DROPDOWN_HEIGHT_BELOW_THRESHOLD,
13
+ DROPDOWN_HEIGHT_THRESHOLD,
14
+ NO_GROUP_NAME,
15
+ PADDING,
16
+ SEARCH_HEIGHT,
17
+ TABS_HEIGHT
18
+ };
package/dist/index.js CHANGED
@@ -1 +1,4 @@
1
- export { default } from './Operators';
1
+ import { default as default2 } from "./Operators.js";
2
+ export {
3
+ default2 as default
4
+ };
package/dist/modules.d.js CHANGED
@@ -1 +1 @@
1
- import '@testing-library/jest-dom';
1
+ import "@testing-library/jest-dom";
File without changes
@@ -1,4 +1,4 @@
1
- import { type OperatorsItem } from '../Operator.types';
1
+ import { OperatorsItem } from '../Operator.types';
2
2
  type GroupedOperators = Record<string, OperatorsItem[]>;
3
3
  export declare const groupByGroupName: (activeItems: OperatorsItem[]) => GroupedOperators;
4
4
  export {};
@@ -1,8 +1,11 @@
1
- import { NO_GROUP_NAME } from '../constants';
2
- export var groupByGroupName = function groupByGroupName(activeItems) {
3
- return activeItems.reduce(function (acc, item) {
4
- var groupName = item.groupName || NO_GROUP_NAME;
5
- acc[groupName] = [].concat(acc[groupName] || [], [item]);
1
+ import { NO_GROUP_NAME } from "../constants.js";
2
+ const groupByGroupName = (activeItems) => {
3
+ return activeItems.reduce((acc, item) => {
4
+ const groupName = item.groupName || NO_GROUP_NAME;
5
+ acc[groupName] = [...acc[groupName] || [], item];
6
6
  return acc;
7
7
  }, {});
8
- };
8
+ };
9
+ export {
10
+ groupByGroupName
11
+ };
@@ -1 +1,4 @@
1
- export * from './groupByGroupName';
1
+ import { groupByGroupName } from "./groupByGroupName.js";
2
+ export {
3
+ groupByGroupName
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-operators",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "Operators UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -16,10 +16,10 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "build": "pnpm run build:js && pnpm run build:css && pnpm run defs",
19
+ "build": "vite build",
20
20
  "build:css": "node ../../../scripts/style/less.js",
21
21
  "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
- "build:watch": "pnpm run build:js -- --watch",
22
+ "build:watch": "vite build --watch",
23
23
  "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
24
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
25
25
  "prepublish": "pnpm run build",
@@ -35,15 +35,15 @@
35
35
  ],
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
- "@synerise/ds-button": "^1.5.16",
39
- "@synerise/ds-dropdown": "^1.3.0",
40
- "@synerise/ds-icon": "^1.14.1",
41
- "@synerise/ds-list-item": "^1.4.8",
42
- "@synerise/ds-result": "^1.0.47",
43
- "@synerise/ds-scrollbar": "^1.2.15",
44
- "@synerise/ds-tabs": "^1.1.22",
45
- "@synerise/ds-tooltip": "^1.4.8",
46
- "@synerise/ds-utils": "^1.6.0",
38
+ "@synerise/ds-button": "^1.5.18",
39
+ "@synerise/ds-dropdown": "^1.3.2",
40
+ "@synerise/ds-icon": "^1.15.1",
41
+ "@synerise/ds-list-item": "^1.4.10",
42
+ "@synerise/ds-result": "^1.0.49",
43
+ "@synerise/ds-scrollbar": "^1.2.17",
44
+ "@synerise/ds-tabs": "^1.1.24",
45
+ "@synerise/ds-tooltip": "^1.4.10",
46
+ "@synerise/ds-utils": "^1.7.1",
47
47
  "uuid": "^8.3.2"
48
48
  },
49
49
  "peerDependencies": {
@@ -52,5 +52,5 @@
52
52
  "react-intl": ">=3.12.0 <= 6.8",
53
53
  "styled-components": "^5.3.3"
54
54
  },
55
- "gitHead": "8dfafc5d7278f09d430f1e7499782d05c76b47c0"
55
+ "gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
56
56
  }
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- export declare const OPERATORS_TEXTS: {
3
- buttonLabel: string;
4
- searchPlaceholder: string;
5
- noResults: string;
6
- };
7
- export declare const OPERATORS_GROUPS: ({
8
- id: string;
9
- name: string;
10
- temsType: null;
11
- tooltip: string;
12
- icon: React.JSX.Element;
13
- defaultGroup: boolean;
14
- itemsType?: undefined;
15
- } | {
16
- id: string;
17
- name: string;
18
- itemsType: null;
19
- tooltip: string;
20
- icon: React.JSX.Element;
21
- defaultGroup: boolean;
22
- temsType?: undefined;
23
- })[];
24
- export declare const OPERATORS_ITEMS: ({
25
- id: string;
26
- value: string;
27
- logic: string;
28
- name: string;
29
- groupId: string;
30
- group: string;
31
- icon: React.JSX.Element;
32
- groupName?: undefined;
33
- } | {
34
- id: string;
35
- value: string;
36
- logic: string;
37
- name: string;
38
- groupId: string;
39
- group: string;
40
- icon: React.JSX.Element;
41
- groupName: string;
42
- })[];
@@ -1 +0,0 @@
1
- export {};