@synerise/ds-card-tabs 1.5.23 → 1.5.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 +4 -0
- package/dist/CardTab/CardTab.d.ts +2 -2
- package/dist/CardTab/CardTab.js +102 -144
- package/dist/CardTab/CardTab.styles.d.ts +11 -11
- package/dist/CardTab/CardTab.styles.js +239 -253
- package/dist/CardTab/CardTab.types.d.ts +4 -4
- package/dist/CardTab/CardTab.types.js +10 -7
- package/dist/CardTab/CardTabActions/CardTabActions.d.ts +2 -2
- package/dist/CardTab/CardTabActions/CardTabActions.js +15 -24
- package/dist/CardTab/CardTabActions/CardTabActions.types.d.ts +2 -2
- package/dist/CardTab/CardTabActions/CardTabActions.types.js +1 -1
- package/dist/CardTab/CardTabDropdown/CardTabDropdown.d.ts +2 -2
- package/dist/CardTab/CardTabDropdown/CardTabDropdown.js +27 -43
- package/dist/CardTab/CardTabDropdown/CardTabDropdown.types.d.ts +1 -1
- package/dist/CardTab/CardTabDropdown/CardTabDropdown.types.js +1 -1
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.d.ts +2 -2
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.js +38 -41
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.types.d.ts +1 -1
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.types.js +1 -1
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.utils.d.ts +1 -1
- package/dist/CardTab/CardTabPrefix/CardTabPrefix.utils.js +12 -6
- package/dist/CardTabs.d.ts +2 -2
- package/dist/CardTabs.js +46 -54
- package/dist/CardTabs.styles.d.ts +2 -2
- package/dist/CardTabs.styles.js +9 -5
- package/dist/CardTabs.types.d.ts +3 -3
- package/dist/CardTabs.types.js +1 -1
- package/dist/index.js +17 -10
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils.js +11 -7
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.5.24](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@1.5.23...@synerise/ds-card-tabs@1.5.24) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-card-tabs
|
|
9
|
+
|
|
6
10
|
## [1.5.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@1.5.22...@synerise/ds-card-tabs@1.5.23) (2026-03-20)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @synerise/ds-card-tabs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CardTabProps } from './CardTab.types';
|
|
3
3
|
declare const CardTab: <IdType extends string | number>(props: CardTabProps<IdType>) => React.JSX.Element;
|
|
4
4
|
export default CardTab;
|
package/dist/CardTab/CardTab.js
CHANGED
|
@@ -1,199 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var _useState2 = useState(name),
|
|
42
|
-
editedName = _useState2[0],
|
|
43
|
-
setEditedName = _useState2[1];
|
|
44
|
-
var getTexts = useMemo(function () {
|
|
45
|
-
return _extends({
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useCallback } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import Icon from "@synerise/ds-icon";
|
|
5
|
+
import InlineEdit from "@synerise/ds-inline-edit";
|
|
6
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
7
|
+
import { CardSuffixWrapper, CardTabContainer, CardTabLabel, CardTabName } from "./CardTab.styles.js";
|
|
8
|
+
import CardTabActions from "./CardTabActions/CardTabActions.js";
|
|
9
|
+
import CardTabDropdown from "./CardTabDropdown/CardTabDropdown.js";
|
|
10
|
+
import CardTabPrefix from "./CardTabPrefix/CardTabPrefix.js";
|
|
11
|
+
const CardTab = (props) => {
|
|
12
|
+
const {
|
|
13
|
+
id,
|
|
14
|
+
name,
|
|
15
|
+
suffixIcon,
|
|
16
|
+
renderSuffix,
|
|
17
|
+
active,
|
|
18
|
+
draggable,
|
|
19
|
+
disabled,
|
|
20
|
+
invalid,
|
|
21
|
+
invalidName,
|
|
22
|
+
greyBackground,
|
|
23
|
+
onChangeName,
|
|
24
|
+
onSelectTab,
|
|
25
|
+
onDuplicateTab,
|
|
26
|
+
onRemoveTab,
|
|
27
|
+
onPreviewTab,
|
|
28
|
+
texts,
|
|
29
|
+
color = "yellow",
|
|
30
|
+
itemData,
|
|
31
|
+
dragHandleProps,
|
|
32
|
+
actionsAsDropdown,
|
|
33
|
+
intl: _intl,
|
|
34
|
+
...prefixProps
|
|
35
|
+
} = props;
|
|
36
|
+
const intl = useIntl();
|
|
37
|
+
const [edited, setEdited] = useState(false);
|
|
38
|
+
const [editedName, setEditedName] = useState(name);
|
|
39
|
+
const getTexts = useMemo(() => {
|
|
40
|
+
return {
|
|
46
41
|
changeNameTooltip: intl.formatMessage({
|
|
47
|
-
id:
|
|
48
|
-
defaultMessage:
|
|
42
|
+
id: "DS.CARD-TAB.RENAME",
|
|
43
|
+
defaultMessage: "Rename"
|
|
49
44
|
}),
|
|
50
45
|
removeTooltip: intl.formatMessage({
|
|
51
|
-
id:
|
|
52
|
-
defaultMessage:
|
|
46
|
+
id: "DS.CARD-TAB.REMOVE",
|
|
47
|
+
defaultMessage: "Delete"
|
|
53
48
|
}),
|
|
54
49
|
duplicateTooltip: intl.formatMessage({
|
|
55
|
-
id:
|
|
56
|
-
defaultMessage:
|
|
50
|
+
id: "DS.CARD-TAB.DUPLICATE",
|
|
51
|
+
defaultMessage: "Duplicate"
|
|
57
52
|
}),
|
|
58
53
|
changeNameMenuItem: intl.formatMessage({
|
|
59
|
-
id:
|
|
60
|
-
defaultMessage:
|
|
54
|
+
id: "DS.CARD-TAB.RENAME",
|
|
55
|
+
defaultMessage: "Rename"
|
|
61
56
|
}),
|
|
62
57
|
removeMenuItem: intl.formatMessage({
|
|
63
|
-
id:
|
|
64
|
-
defaultMessage:
|
|
58
|
+
id: "DS.CARD-TAB.REMOVE",
|
|
59
|
+
defaultMessage: "Delete"
|
|
65
60
|
}),
|
|
66
61
|
duplicateMenuItem: intl.formatMessage({
|
|
67
|
-
id:
|
|
68
|
-
defaultMessage:
|
|
69
|
-
})
|
|
70
|
-
|
|
62
|
+
id: "DS.CARD-TAB.DUPLICATE",
|
|
63
|
+
defaultMessage: "Duplicate"
|
|
64
|
+
}),
|
|
65
|
+
...texts
|
|
66
|
+
};
|
|
71
67
|
}, [texts, intl]);
|
|
72
|
-
|
|
73
|
-
if (onChangeName ===
|
|
74
|
-
return
|
|
68
|
+
const handleEditName = useMemo(() => {
|
|
69
|
+
if (onChangeName === void 0) {
|
|
70
|
+
return void 0;
|
|
75
71
|
}
|
|
76
|
-
return
|
|
72
|
+
return (event) => {
|
|
77
73
|
!!event && event.stopPropagation();
|
|
78
74
|
setEdited(true);
|
|
79
75
|
};
|
|
80
76
|
}, [onChangeName, setEdited]);
|
|
81
|
-
|
|
82
|
-
if (onChangeName ===
|
|
83
|
-
return
|
|
77
|
+
const handleChangeName = useMemo(() => {
|
|
78
|
+
if (onChangeName === void 0) {
|
|
79
|
+
return void 0;
|
|
84
80
|
}
|
|
85
|
-
return
|
|
81
|
+
return (event) => {
|
|
86
82
|
if (event) {
|
|
87
|
-
|
|
83
|
+
const {
|
|
84
|
+
value: nameValue
|
|
85
|
+
} = event.target;
|
|
88
86
|
setEditedName(nameValue);
|
|
89
87
|
onChangeName && onChangeName(id, nameValue);
|
|
90
88
|
}
|
|
91
89
|
};
|
|
92
90
|
}, [setEditedName, onChangeName, id]);
|
|
93
|
-
|
|
91
|
+
const handleEditNameBlur = useCallback(() => {
|
|
94
92
|
setEdited(false);
|
|
95
93
|
onChangeName && onChangeName(id, editedName);
|
|
96
94
|
}, [onChangeName, id, editedName]);
|
|
97
|
-
|
|
98
|
-
if (onDuplicateTab ===
|
|
99
|
-
return
|
|
95
|
+
const handleDuplicate = useMemo(() => {
|
|
96
|
+
if (onDuplicateTab === void 0) {
|
|
97
|
+
return void 0;
|
|
100
98
|
}
|
|
101
|
-
return
|
|
99
|
+
return (event) => {
|
|
102
100
|
event && event.stopPropagation();
|
|
103
101
|
onDuplicateTab && onDuplicateTab(id);
|
|
104
102
|
};
|
|
105
103
|
}, [id, onDuplicateTab]);
|
|
106
|
-
|
|
107
|
-
if (onRemoveTab ===
|
|
108
|
-
return
|
|
104
|
+
const handleRemove = useMemo(() => {
|
|
105
|
+
if (onRemoveTab === void 0) {
|
|
106
|
+
return void 0;
|
|
109
107
|
}
|
|
110
|
-
return
|
|
108
|
+
return (event) => {
|
|
111
109
|
event && event.stopPropagation();
|
|
112
110
|
onRemoveTab && onRemoveTab(id);
|
|
113
111
|
};
|
|
114
112
|
}, [id, onRemoveTab]);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
var handleSelect = useCallback(function (event) {
|
|
113
|
+
const handlePreview = onPreviewTab && (() => onPreviewTab(id));
|
|
114
|
+
const handleSelect = useCallback((event) => {
|
|
119
115
|
!!event && event.stopPropagation();
|
|
120
116
|
!edited && onSelectTab && onSelectTab(id);
|
|
121
117
|
}, [edited, id, onSelectTab]);
|
|
122
|
-
|
|
118
|
+
const showCardActions = useCallback(() => {
|
|
123
119
|
return (!!onChangeName || !!onDuplicateTab || !!onRemoveTab || !!onPreviewTab) && !suffixIcon && !renderSuffix;
|
|
124
120
|
}, [onChangeName, onDuplicateTab, onRemoveTab, onPreviewTab, suffixIcon, renderSuffix]);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
121
|
+
const suffixProps = {
|
|
122
|
+
...props,
|
|
123
|
+
handleRemove,
|
|
124
|
+
handleDuplicate,
|
|
125
|
+
handleEditName,
|
|
129
126
|
texts: getTexts
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
};
|
|
128
|
+
const cardSuffix = (() => {
|
|
129
|
+
const showActionsDropdownMenu = actionsAsDropdown && (onChangeName || handleDuplicate || handleRemove);
|
|
133
130
|
if (showActionsDropdownMenu) {
|
|
134
|
-
return
|
|
135
|
-
editNameHandler: onChangeName ? handleEditName : undefined,
|
|
136
|
-
duplicateHandler: handleDuplicate,
|
|
137
|
-
removeHandler: handleRemove,
|
|
138
|
-
texts: getTexts
|
|
139
|
-
});
|
|
131
|
+
return /* @__PURE__ */ jsx(CardTabDropdown, { editNameHandler: onChangeName ? handleEditName : void 0, duplicateHandler: handleDuplicate, removeHandler: handleRemove, texts: getTexts });
|
|
140
132
|
}
|
|
141
133
|
if (renderSuffix) {
|
|
142
134
|
return renderSuffix(suffixProps);
|
|
143
135
|
}
|
|
144
136
|
if (suffixIcon) {
|
|
145
|
-
return
|
|
146
|
-
className: "ds-card-tabs__suffix-icon",
|
|
147
|
-
component: suffixIcon
|
|
148
|
-
}));
|
|
137
|
+
return /* @__PURE__ */ jsx(CardSuffixWrapper, { children: /* @__PURE__ */ jsx(Icon, { className: "ds-card-tabs__suffix-icon", component: suffixIcon }) });
|
|
149
138
|
}
|
|
150
139
|
if (showCardActions()) {
|
|
151
|
-
return
|
|
152
|
-
onChangeName: onChangeName ? handleEditName : undefined,
|
|
153
|
-
onDuplicateTab: handleDuplicate,
|
|
154
|
-
onRemoveTab: handleRemove,
|
|
155
|
-
onPreviewTab: handlePreview,
|
|
156
|
-
texts: getTexts
|
|
157
|
-
});
|
|
140
|
+
return /* @__PURE__ */ jsx(CardTabActions, { onChangeName: onChangeName ? handleEditName : void 0, onDuplicateTab: handleDuplicate, onRemoveTab: handleRemove, onPreviewTab: handlePreview, texts: getTexts });
|
|
158
141
|
}
|
|
159
|
-
return
|
|
160
|
-
}();
|
|
161
|
-
return
|
|
162
|
-
edited
|
|
163
|
-
|
|
164
|
-
invalid: Boolean(invalid || invalidName),
|
|
165
|
-
disabled: !active && Boolean(disabled),
|
|
166
|
-
isDraggable: draggable,
|
|
167
|
-
color: color,
|
|
168
|
-
onClick: handleSelect,
|
|
169
|
-
greyBackground: !!greyBackground,
|
|
170
|
-
"data-id": id,
|
|
171
|
-
"data-testid": "card-tab-container",
|
|
172
|
-
itemData: itemData
|
|
173
|
-
}, !edited && /*#__PURE__*/React.createElement(CardTabPrefix, _extends({
|
|
174
|
-
dragHandleProps: dragHandleProps,
|
|
175
|
-
draggable: draggable
|
|
176
|
-
}, prefixProps)), /*#__PURE__*/React.createElement(S.CardTabLabel, {
|
|
177
|
-
onDoubleClick: handleEditName,
|
|
178
|
-
"data-testid": "card-tab-label"
|
|
179
|
-
}, edited ? /*#__PURE__*/React.createElement(InlineEdit, {
|
|
180
|
-
className: "ds-card-tabs__edit-name",
|
|
181
|
-
size: "small",
|
|
182
|
-
hideIcon: true,
|
|
183
|
-
autoFocus: true,
|
|
184
|
-
input: {
|
|
142
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
143
|
+
})();
|
|
144
|
+
return /* @__PURE__ */ jsxs(CardTabContainer, { edited, active: Boolean(active), invalid: Boolean(invalid || invalidName), disabled: !active && Boolean(disabled), isDraggable: draggable, color, onClick: handleSelect, greyBackground: !!greyBackground, "data-id": id, "data-testid": "card-tab-container", itemData, children: [
|
|
145
|
+
!edited && /* @__PURE__ */ jsx(CardTabPrefix, { dragHandleProps, draggable, ...prefixProps }),
|
|
146
|
+
/* @__PURE__ */ jsx(CardTabLabel, { onDoubleClick: handleEditName, "data-testid": "card-tab-label", children: edited ? /* @__PURE__ */ jsx(InlineEdit, { className: "ds-card-tabs__edit-name", size: "small", hideIcon: true, autoFocus: true, input: {
|
|
185
147
|
value: editedName,
|
|
186
|
-
name:
|
|
148
|
+
name: `ds-card-tab-input-${id}`,
|
|
187
149
|
onBlur: handleEditNameBlur,
|
|
188
|
-
onChange: handleChangeName ||
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}, /*#__PURE__*/React.createElement(S.CardTabName, {
|
|
196
|
-
"data-testid": "card-tab-name"
|
|
197
|
-
}, name))), cardSuffix);
|
|
150
|
+
onChange: handleChangeName || (() => void 0)
|
|
151
|
+
}, "data-testid": "card-tab-edit-input" }) : /* @__PURE__ */ jsx(Tooltip, { title: name, children: /* @__PURE__ */ jsx(CardTabName, { "data-testid": "card-tab-name", children: name }) }) }),
|
|
152
|
+
cardSuffix
|
|
153
|
+
] });
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
CardTab as default
|
|
198
157
|
};
|
|
199
|
-
export default CardTab;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare const CardTabSuffix: import(
|
|
2
|
-
export declare const CardTabName: import(
|
|
3
|
-
export declare const CardSuffixWrapper: import(
|
|
4
|
-
export declare const CardTabLabel: import(
|
|
5
|
-
export declare const CardTabTag: import(
|
|
6
|
-
export declare const CardDotPrefix: import(
|
|
7
|
-
export declare const CardDot: import(
|
|
8
|
-
export declare const CardTabPrefix: import(
|
|
9
|
-
export declare const CardDragPrefix: import(
|
|
1
|
+
export declare const CardTabSuffix: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const CardTabName: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
3
|
+
export declare const CardSuffixWrapper: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
4
|
+
export declare const CardTabLabel: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
5
|
+
export declare const CardTabTag: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const CardDotPrefix: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const CardDot: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const CardTabPrefix: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const CardDragPrefix: import('styled-components').StyledComponent<"div", any, {
|
|
10
10
|
persistent: boolean;
|
|
11
11
|
}, never>;
|
|
12
|
-
export declare const CardIconPrefix: import(
|
|
13
|
-
export declare const CardTabContainer: import(
|
|
12
|
+
export declare const CardIconPrefix: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const CardTabContainer: import('styled-components').StyledComponent<"div", any, {
|
|
14
14
|
active: boolean;
|
|
15
15
|
invalid: boolean;
|
|
16
16
|
greyBackground: boolean;
|