@synerise/ds-card-tabs 1.2.5 → 1.3.1

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,25 @@
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.3.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@1.3.0...@synerise/ds-card-tabs@1.3.1) (2025-05-19)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-card-tabs
9
+
10
+
11
+
12
+
13
+
14
+ # [1.3.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@1.2.5...@synerise/ds-card-tabs@1.3.0) (2025-05-07)
15
+
16
+
17
+ ### Features
18
+
19
+ * **card-tabs:** fix types for id and prefix ([c0efb33](https://github.com/Synerise/synerise-design/commit/c0efb3371f31919923f42d111ad946b346b6ad29))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [1.2.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@1.2.4...@synerise/ds-card-tabs@1.2.5) (2025-04-24)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-card-tabs
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CardTabProps } from './CardTab.types';
3
- declare const CardTab: (props: CardTabProps) => React.JSX.Element;
3
+ declare const CardTab: <IdType extends string | number>(props: CardTabProps<IdType>) => React.JSX.Element;
4
4
  export default CardTab;
@@ -1,7 +1,9 @@
1
+ var _excluded = ["id", "name", "suffixIcon", "renderSuffix", "active", "draggable", "disabled", "invalid", "invalidName", "greyBackground", "onChangeName", "onSelectTab", "onDuplicateTab", "onRemoveTab", "onPreviewTab", "texts", "color", "itemData", "dragHandleProps", "actionsAsDropdown", "intl"];
1
2
  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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
2
4
  import React, { useState, useMemo, useCallback } from 'react';
3
5
  import Icon from '@synerise/ds-icon';
4
- import InlineEdit from '@synerise/ds-inline-edit/dist/InlineEdit';
6
+ import InlineEdit from '@synerise/ds-inline-edit';
5
7
  import { useIntl } from 'react-intl';
6
8
  import Tooltip from '@synerise/ds-tooltip';
7
9
  import * as S from './CardTab.styles';
@@ -11,9 +13,6 @@ import CardTabDropdown from './CardTabDropdown/CardTabDropdown';
11
13
  var CardTab = function CardTab(props) {
12
14
  var id = props.id,
13
15
  name = props.name,
14
- tag = props.tag,
15
- prefix = props.prefix,
16
- prefixIcon = props.prefixIcon,
17
16
  suffixIcon = props.suffixIcon,
18
17
  renderSuffix = props.renderSuffix,
19
18
  active = props.active,
@@ -30,10 +29,11 @@ var CardTab = function CardTab(props) {
30
29
  texts = props.texts,
31
30
  _props$color = props.color,
32
31
  color = _props$color === void 0 ? 'yellow' : _props$color,
33
- colorDot = props.colorDot,
34
32
  itemData = props.itemData,
35
33
  dragHandleProps = props.dragHandleProps,
36
- actionsAsDropdown = props.actionsAsDropdown;
34
+ actionsAsDropdown = props.actionsAsDropdown,
35
+ _intl = props.intl,
36
+ prefixProps = _objectWithoutPropertiesLoose(props, _excluded);
37
37
  var intl = useIntl();
38
38
  var _useState = useState(false),
39
39
  edited = _useState[0],
@@ -170,14 +170,10 @@ var CardTab = function CardTab(props) {
170
170
  "data-id": id,
171
171
  "data-testid": "card-tab-container",
172
172
  itemData: itemData
173
- }, !edited && /*#__PURE__*/React.createElement(CardTabPrefix, {
173
+ }, !edited && /*#__PURE__*/React.createElement(CardTabPrefix, _extends({
174
174
  dragHandleProps: dragHandleProps,
175
- colorDot: colorDot,
176
- draggable: draggable,
177
- prefixIcon: prefixIcon,
178
- prefix: prefix,
179
- tag: tag
180
- }), /*#__PURE__*/React.createElement(S.CardTabLabel, {
175
+ draggable: draggable
176
+ }, prefixProps)), /*#__PURE__*/React.createElement(S.CardTabLabel, {
181
177
  onDoubleClick: handleEditName,
182
178
  "data-testid": "card-tab-label"
183
179
  }, edited ? /*#__PURE__*/React.createElement(InlineEdit, {
@@ -6,7 +6,9 @@ export declare const CardTabTag: import("styled-components").StyledComponent<"di
6
6
  export declare const CardDotPrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
7
7
  export declare const CardDot: import("styled-components").StyledComponent<"div", any, {}, never>;
8
8
  export declare const CardTabPrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
9
- export declare const CardDragPrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
9
+ export declare const CardDragPrefix: import("styled-components").StyledComponent<"div", any, {
10
+ persistent: boolean;
11
+ }, never>;
10
12
  export declare const CardIconPrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
11
13
  export declare const CardTabContainer: import("styled-components").StyledComponent<"div", any, {
12
14
  active: boolean;
@@ -51,7 +51,9 @@ export var CardTabPrefix = styled.div.withConfig({
51
51
  export var CardDragPrefix = styled.div.withConfig({
52
52
  displayName: "CardTabstyles__CardDragPrefix",
53
53
  componentId: "sc-1n86s98-8"
54
- })(["display:none;&.persistent{display:block;}"]);
54
+ })(["display:", ";"], function (props) {
55
+ return props.persistent ? 'block' : 'none';
56
+ });
55
57
  export var CardIconPrefix = styled.div.withConfig({
56
58
  displayName: "CardTabstyles__CardIconPrefix",
57
59
  componentId: "sc-1n86s98-9"
@@ -19,42 +19,57 @@ export type CardTabTexts = {
19
19
  removeMenuItem?: ReactNode;
20
20
  duplicateMenuItem?: ReactNode;
21
21
  };
22
- export type CardTabProps<IdType extends string | number = number> = {
23
- /**
24
- * @deprecated
25
- */
26
- intl?: IntlShape;
27
- id: IdType;
28
- name: string;
22
+ export type TagPrefixProps = {
23
+ prefix: prefixType.TAG;
29
24
  tag: string;
30
- prefix: prefixType;
31
- dragHandleProps?: DragHandlePropType;
25
+ };
26
+ export type DotPrefixProps = {
27
+ prefix: prefixType.DOT;
32
28
  colorDot?: ReactNode;
29
+ };
30
+ export type IconPrefixProps = {
31
+ prefix: prefixType.ICON;
32
+ prefixIcon: ReactNode;
33
+ };
34
+ export type HandlePrefixProps = {
35
+ prefix: prefixType.HANDLE;
36
+ };
37
+ export type PrefixProps = DotPrefixProps | HandlePrefixProps | IconPrefixProps | TagPrefixProps;
38
+ type CardTabCommonProps = {
39
+ name: string;
40
+ dragHandleProps?: DragHandlePropType;
33
41
  color?: Color | DefaultColor | string;
34
42
  active?: boolean;
35
43
  draggable?: boolean;
36
- prefixIcon?: ReactNode;
37
44
  suffixIcon?: ReactNode;
38
45
  disabled?: boolean;
39
46
  invalid?: boolean;
40
47
  invalidName?: boolean;
41
48
  greyBackground?: boolean;
42
- onSelectTab?: (id: IdType) => void;
43
- onChangeName?: (id: IdType, name: string) => void;
44
- onDuplicateTab?: (id: IdType) => void;
45
- onRemoveTab?: (id: IdType) => void;
46
- onPreviewTab?: (id: IdType) => void;
47
49
  texts?: CardTabTexts;
48
50
  itemData?: unknown;
49
51
  actionsAsDropdown?: boolean;
50
- renderSuffix?: (props: CardTabSuffixProps) => ReactNode;
52
+ /**
53
+ * @deprecated
54
+ */
55
+ keyId?: string;
56
+ } & PrefixProps;
57
+ export type CardTabProps<IdType extends string | number = number> = {
51
58
  /**
52
59
  * @deprecated
53
60
  */
54
- keyId?: string;
55
- };
56
- export type CardTabSuffixProps = Omit<CardTabProps & {
61
+ intl?: IntlShape;
62
+ id: IdType;
63
+ onSelectTab?: (id: IdType) => void;
64
+ onChangeName?: (id: IdType, name: string) => void;
65
+ onDuplicateTab?: (id: IdType) => void;
66
+ onRemoveTab?: (id: IdType) => void;
67
+ onPreviewTab?: (id: IdType) => void;
68
+ renderSuffix?: (props: CardTabSuffixProps) => ReactNode;
69
+ } & CardTabCommonProps;
70
+ export type CardTabSuffixProps = CardTabCommonProps & {
57
71
  handleRemove?: (event?: MouseEvent<HTMLElement>) => void;
58
72
  handleDuplicate?: (event?: MouseEvent<HTMLElement>) => void;
59
73
  handleEditName?: (event?: MouseEvent<HTMLElement>) => void;
60
- }, 'onChangeName' | 'onDuplicateTab' | 'onRemoveTab' | 'onSelectTab'>;
74
+ };
75
+ export {};
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { Props } from './CardTabPrefix.types';
3
- declare const CardTabPrefix: ({ prefix, draggable, tag, prefixIcon, colorDot, dragHandleProps }: Props) => React.JSX.Element;
2
+ import { CardTabPrefixProps } from './CardTabPrefix.types';
3
+ declare const CardTabPrefix: ({ draggable, dragHandleProps, ...rest }: CardTabPrefixProps) => React.JSX.Element;
4
4
  export default CardTabPrefix;
@@ -1,30 +1,52 @@
1
+ var _excluded = ["draggable", "dragHandleProps"];
1
2
  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 from 'react';
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import React, { useMemo } from 'react';
3
5
  import Icon, { DragHandleM } from '@synerise/ds-icon';
4
6
  import * as S from '../CardTab.styles';
5
7
  import { prefixType } from '../CardTab.types';
8
+ import { isTagPrefix, isDotPrefix, isIconPrefix, isHandlePrefix } from './CardTabPrefix.utils';
6
9
  var CardTabPrefix = function CardTabPrefix(_ref) {
7
- var prefix = _ref.prefix,
8
- draggable = _ref.draggable,
9
- tag = _ref.tag,
10
- prefixIcon = _ref.prefixIcon,
11
- colorDot = _ref.colorDot,
12
- dragHandleProps = _ref.dragHandleProps;
13
- var className = prefix === prefixType.HANDLE ? 'persistent' : '';
10
+ var draggable = _ref.draggable,
11
+ dragHandleProps = _ref.dragHandleProps,
12
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
13
+ var prefixElement = useMemo(function () {
14
+ if (isTagPrefix(rest)) {
15
+ var tag = rest.tag;
16
+ return /*#__PURE__*/React.createElement(S.CardTabTag, {
17
+ "data-testid": "card-tab-tag"
18
+ }, tag);
19
+ }
20
+ if (isDotPrefix(rest)) {
21
+ var colorDot = rest.colorDot;
22
+ return /*#__PURE__*/React.createElement(S.CardDotPrefix, {
23
+ "data-testid": "card-tab-dot"
24
+ }, colorDot || /*#__PURE__*/React.createElement(S.CardDot, null));
25
+ }
26
+ if (isIconPrefix(rest)) {
27
+ var prefixIcon = rest.prefixIcon;
28
+ return /*#__PURE__*/React.createElement(S.CardIconPrefix, {
29
+ "data-testid": "card-tab-icon"
30
+ }, /*#__PURE__*/React.createElement(Icon, {
31
+ component: prefixIcon
32
+ }));
33
+ }
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
35
+ }, [rest]);
36
+ var handleElement = useMemo(function () {
37
+ if (isHandlePrefix(rest) || draggable) {
38
+ return /*#__PURE__*/React.createElement(S.CardDragPrefix, _extends({
39
+ "data-testid": "card-tab-handle",
40
+ persistent: rest.prefix === prefixType.HANDLE
41
+ }, dragHandleProps), /*#__PURE__*/React.createElement(Icon, {
42
+ className: "ds-card-tabs__handle-icon sortable-drag",
43
+ component: /*#__PURE__*/React.createElement(DragHandleM, null)
44
+ }), ' ');
45
+ }
46
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
47
+ }, [dragHandleProps, draggable, rest]);
14
48
  return /*#__PURE__*/React.createElement(S.CardTabPrefix, {
15
49
  "data-testid": "card-tab-prefix"
16
- }, prefix === prefixType.TAG && tag && /*#__PURE__*/React.createElement(S.CardTabTag, {
17
- draggable: draggable,
18
- "data-testid": "card-tab-tag"
19
- }, tag), prefix === prefixType.ICON && prefixIcon && /*#__PURE__*/React.createElement(S.CardIconPrefix, null, /*#__PURE__*/React.createElement(Icon, {
20
- component: prefixIcon
21
- })), prefix === prefixType.DOT && colorDot && /*#__PURE__*/React.createElement(S.CardDotPrefix, {
22
- "data-testid": "card-dot-tag"
23
- }, colorDot), (prefix === prefixType.HANDLE || draggable) && /*#__PURE__*/React.createElement(S.CardDragPrefix, _extends({
24
- className: className
25
- }, dragHandleProps), /*#__PURE__*/React.createElement(Icon, {
26
- className: "ds-card-tabs__handle-icon sortable-drag",
27
- component: /*#__PURE__*/React.createElement(DragHandleM, null)
28
- }), ' '));
50
+ }, prefixElement, handleElement);
29
51
  };
30
52
  export default CardTabPrefix;
@@ -1,10 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { prefixType, CardTabProps } from '../CardTab.types';
3
- export interface Props {
4
- prefix: prefixType;
1
+ import { CardTabProps, PrefixProps } from '../CardTab.types';
2
+ export type CardTabPrefixProps = PrefixProps & {
5
3
  draggable?: boolean;
6
- tag?: string;
7
- prefixIcon?: ReactNode;
8
- colorDot?: ReactNode;
9
4
  dragHandleProps?: CardTabProps['dragHandleProps'];
10
- }
5
+ };
@@ -0,0 +1,5 @@
1
+ import type { PrefixProps, TagPrefixProps, DotPrefixProps, IconPrefixProps, HandlePrefixProps } from '../CardTab.types';
2
+ export declare const isTagPrefix: (props: PrefixProps) => props is TagPrefixProps;
3
+ export declare const isDotPrefix: (props: PrefixProps) => props is DotPrefixProps;
4
+ export declare const isIconPrefix: (props: PrefixProps) => props is IconPrefixProps;
5
+ export declare const isHandlePrefix: (props: PrefixProps) => props is HandlePrefixProps;
@@ -0,0 +1,13 @@
1
+ import { prefixType } from '../CardTab.types';
2
+ export var isTagPrefix = function isTagPrefix(props) {
3
+ return props.prefix === prefixType.TAG;
4
+ };
5
+ export var isDotPrefix = function isDotPrefix(props) {
6
+ return props.prefix === prefixType.DOT;
7
+ };
8
+ export var isIconPrefix = function isIconPrefix(props) {
9
+ return props.prefix === prefixType.ICON;
10
+ };
11
+ export var isHandlePrefix = function isHandlePrefix(props) {
12
+ return props.prefix === prefixType.HANDLE;
13
+ };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CardTabsProps } from './CardTabs.types';
3
- declare const CardTabs: ({ className, onChangeOrder, onAddTab, maxTabsCount, children, addTabLabel, ...htmlAttributes }: CardTabsProps) => React.JSX.Element;
3
+ declare const CardTabs: <IdType extends string | number>({ className, onChangeOrder, onAddTab, maxTabsCount, children, addTabLabel, ...htmlAttributes }: CardTabsProps<IdType>) => React.JSX.Element;
4
4
  export default CardTabs;
@@ -1,11 +1,12 @@
1
1
  import { WithHTMLAttributes } from '@synerise/ds-utils';
2
2
  import { ReactElement } from 'react';
3
3
  import type { CardTabProps } from './CardTab/CardTab.types';
4
- export type CardTabsProps = WithHTMLAttributes<HTMLDivElement, {
5
- onChangeOrder?: (newOrder: CardTabsItem[]) => void;
4
+ export type CardTabsPropsBase<IdType extends string | number> = {
5
+ onChangeOrder?: (newOrder: CardTabProps<IdType>[]) => void;
6
6
  onAddTab?: () => void;
7
7
  addTabLabel?: string;
8
8
  maxTabsCount?: number;
9
- children?: Array<ReactElement<CardTabProps>>;
10
- }>;
9
+ children?: Array<ReactElement<CardTabProps<IdType>>>;
10
+ };
11
+ export type CardTabsProps<IdType extends string | number> = WithHTMLAttributes<HTMLDivElement, CardTabsPropsBase<IdType>>;
11
12
  export type CardTabsItem = Partial<CardTabProps>;
package/dist/index.d.ts CHANGED
@@ -3,9 +3,10 @@ import * as MainCardTabsStyles from './CardTabs.styles';
3
3
  export { default } from './CardTabs';
4
4
  export { default as CardTab } from './CardTab/CardTab';
5
5
  export { prefixType } from './CardTab/CardTab.types';
6
+ export { CardDot } from './CardTab/CardTab.styles';
6
7
  export declare const CardTabsStyles: {
7
8
  CardTabs: typeof MainCardTabsStyles;
8
9
  CardTab: typeof CardTabStyles;
9
10
  };
10
- export type { CardTabsItem, CardTabsProps } from './CardTabs.types';
11
+ export type { CardTabsItem, CardTabsProps, CardTabsPropsBase } from './CardTabs.types';
11
12
  export type { CardTabProps } from './CardTab/CardTab.types';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import * as MainCardTabsStyles from './CardTabs.styles';
3
3
  export { default } from './CardTabs';
4
4
  export { default as CardTab } from './CardTab/CardTab';
5
5
  export { prefixType } from './CardTab/CardTab.types';
6
+ export { CardDot } from './CardTab/CardTab.styles';
6
7
  export var CardTabsStyles = {
7
8
  CardTabs: MainCardTabsStyles,
8
9
  CardTab: CardTabStyles
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-card-tabs",
3
- "version": "1.2.5",
3
+ "version": "1.3.1",
4
4
  "description": "CardTabs UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,16 +34,16 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^1.1.5",
38
- "@synerise/ds-cruds": "^1.0.6",
39
- "@synerise/ds-dropdown": "^1.0.6",
40
- "@synerise/ds-icon": "^1.4.1",
41
- "@synerise/ds-inline-edit": "^1.0.7",
42
- "@synerise/ds-menu": "^1.0.6",
43
- "@synerise/ds-sortable": "^1.1.1",
44
- "@synerise/ds-tooltip": "^1.1.5",
45
- "@synerise/ds-typography": "^1.0.6",
46
- "@synerise/ds-utils": "^1.0.1"
37
+ "@synerise/ds-button": "^1.3.0",
38
+ "@synerise/ds-cruds": "^1.0.8",
39
+ "@synerise/ds-dropdown": "^1.0.8",
40
+ "@synerise/ds-icon": "^1.5.0",
41
+ "@synerise/ds-inline-edit": "^1.0.9",
42
+ "@synerise/ds-menu": "^1.0.8",
43
+ "@synerise/ds-sortable": "^1.1.2",
44
+ "@synerise/ds-tooltip": "^1.1.7",
45
+ "@synerise/ds-typography": "^1.0.8",
46
+ "@synerise/ds-utils": "^1.1.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@synerise/ds-core": "*",
@@ -52,5 +52,5 @@
52
52
  "react-intl": ">=3.12.0 <= 6.8",
53
53
  "styled-components": "^5.3.3"
54
54
  },
55
- "gitHead": "fc601270d3c84a5a52b62473a01f1b3c1c7014a7"
55
+ "gitHead": "8aa16b27c86c97e3ac774d92561ab0a03176c439"
56
56
  }