@synerise/ds-card-tabs 2.0.11 → 2.1.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,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
+ # [2.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@2.0.12...@synerise/ds-card-tabs@2.1.0) (2026-10-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.0.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@2.0.11...@synerise/ds-card-tabs@2.0.12) (2026-10-28)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-card-tabs
20
+
21
+
22
+
23
+
24
+
6
25
  ## [2.0.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-card-tabs@2.0.10...@synerise/ds-card-tabs@2.0.11) (2026-10-26)
7
26
 
8
27
 
package/CLAUDE.md CHANGED
@@ -16,7 +16,7 @@ src/
16
16
  CardTabActions/ — inline CRUD icon buttons (edit/duplicate/remove/preview)
17
17
  CardTabDropdown/ — 3-dot dropdown menu for the same actions
18
18
  CardTabPrefix/ — left-side prefix (tag, dot, icon, or drag handle)
19
- utils.ts — getColor, getLighterColor helpers
19
+ utils.ts — getColor, customColorOr, orderedBaseOr/orderedHoverOr helpers
20
20
  index.ts — public exports
21
21
  ```
22
22
 
@@ -51,13 +51,14 @@ Individual tab card. Generic: `CardTab<IdType extends string | number>`. Not usu
51
51
 
52
52
  | Prop | Type | Default | Description |
53
53
  |------|------|---------|-------------|
54
- | `color` | `Color \| DefaultColor \| string` | `'yellow'` | Background colour of the active state. Auto-assigned by `CardTabs` from `defaultColorsOrder` if not set. |
54
+ | `color` | `DefaultColor \| string` | `'yellow'` | Explicit categorical colour of the active state — a `$hue-$shade` key (`'blue-600'`) or a bare hue (`'grey'`, defaults to shade 600). Resolved to the reversible `--ds-color-custom-<hue>-<shade>` token. When omitted, `CardTabs` assigns an `orderIndex` instead and the colour comes from the `ordered` token slot. |
55
+ | `orderIndex` | `number` | `undefined` | Slot in the `ordered` categorical-colour queue, injected by `CardTabs` for tabs without an explicit `color`. When set, the tab's colour comes from `orderedBase`/`orderedHover` (`@synerise/ds-tokens/names`) rather than the `color`-derived custom token. |
55
56
  | `active` | `boolean` | `undefined` | Shows the card in its active/selected state (coloured background). |
56
57
  | `draggable` | `boolean` | `undefined` | Shows a drag handle. Also auto-set by `CardTabs` when >1 children and `onChangeOrder` is provided. |
57
58
  | `disabled` | `boolean` | `undefined` | Sets `pointer-events: none` and reduces opacity. Does NOT disable child actions individually. |
58
- | `invalid` | `boolean` | `undefined` | Red border. Combined with `active`, turns the card red-600. |
59
+ | `invalid` | `boolean` | `undefined` | Red border (`--ds-card-tabs-variant-grey-border-validate`). Combined with `active`, the background becomes `--ds-card-tabs-variant-grey-bg-validateactive`. |
59
60
  | `invalidName` | `boolean` | `undefined` | Same visual effect as `invalid` (both flags are OR'd). |
60
- | `greyBackground` | `boolean` | `undefined` | White card with drop shadow instead of the default grey-050 bordered card. |
61
+ | `greyBackground` | `boolean` | `undefined` | White card with drop shadow (`--ds-card-tabs-variant-white-*` tokens) instead of the default bordered `--ds-card-tabs-variant-grey-*` card. |
61
62
  | `suffixIcon` | `ReactNode` | `undefined` | Renders a static icon on the right. **Suppresses** `CardTabActions`/`CardTabDropdown` entirely. |
62
63
  | `renderSuffix` | `(props: CardTabSuffixProps) => ReactNode` | `undefined` | Custom suffix renderer. Takes precedence over action icons. |
63
64
  | `actionsAsDropdown` | `boolean` | `undefined` | Renders action callbacks in a 3-dot `CardTabDropdown` instead of inline `CardTabActions` icons. |
@@ -148,8 +149,9 @@ import CardTabs, { CardTab, prefixType } from '@synerise/ds-card-tabs';
148
149
  ## Styling
149
150
 
150
151
  - `CardTabs.styles.ts` — container is full-width flex row with `gap: 16px 12px`, wraps at 588px breakpoint; at ≤588px, the Creator add button collapses to icon-only (label hidden via CSS).
151
- - `CardTab.styles.ts` — `CardTabContainer` is a styled div 168×48px, 3px border-radius. Background, border, and text colours all derive from the `color` prop and the `active`/`invalid`/`greyBackground` flags via inline theme palette lookups.
152
- - Uses `@synerise/ds-core` theme palette tokens throughout; `getLighterColor` utility steps colour levels down by 100 on hover.
152
+ - `CardTab.styles.ts` — `CardTabContainer` is a styled div 168×48px, 3px border-radius. Its fixed chrome (bg/border/text/icon/tag/dot-ring/handler/shadow/disabled-opacity) reads the `--ds-card-tabs-variant-*` **module tokens**; only **background** threads the variant (`greyBackground` → `white-*`, else `grey-*`, since their bg/shadow/border differ), while text/icon/tag/etc. use the `grey-*` tokens (identical across variants). `grey-100` pressed (inactive) has no module token → semantic `--ds-color-background-base-muted`.
153
+ - The per-tab **categorical** colour is separate: auto-assigned tabs (`orderIndex` set) take the `ordered` token slot via `orderedBaseOr`/`orderedHoverOr` (`utils.ts` → `orderedBase`/`orderedHover` from `@synerise/ds-tokens/names`); tabs with an explicit `color` prop resolve through `customColorOr` to the reversible `--ds-color-custom-<hue>-<shade>` token (shade −100 for hover). The `ordered` hover is an explicit token (base − 100 baked in), so hover/`:active` read `orderedHover[slot]` rather than computing a shade by name. A string that is not a custom colour yields `undefined` from `customColorOr` and the declaration is dropped (no `theme.palette` fallback any more).
154
+ - The InlineEdit fake-caret gradients are tokenised: the accent caret → `--ds-color-text-brand-default`; the active/inactive caret tracks the input's own text token (`--ds-card-tabs-variant-grey-text-active`/`-hover`) so it flips with the theme. The per-tab explicit-`color` fallback (used when no `orderIndex`) resolves through `customColorOr` (`utils.ts`) to the reversible `--ds-color-custom-<hue>-<shade>` token, so explicit-colour tabs flip with the theme too — a bare hue (`'grey'`) defaults to shade 600, `$hue-$shade` (`'blue-600'`) is used as-is, hover picks shade −100; an out-of-set string yields `undefined` and the declaration is dropped (no `theme.palette` fallback any more). The invalid hover/pressed background adopts `bg-validateactivehover` — a ⚑ shift (darker than the former `red-500`). `svg { fill }` rules point at the icon token directly (a `currentColor` cleanup is a deferred follow-up).
153
155
 
154
156
  ## Key dependencies
155
157
 
@@ -158,15 +160,15 @@ import CardTabs, { CardTab, prefixType } from '@synerise/ds-card-tabs';
158
160
  - `@synerise/ds-cruds` — inline CRUD icon buttons in `CardTabActions`
159
161
  - `@synerise/ds-dropdown` `DropdownMenu` — 3-dot contextual menu in `CardTabDropdown`
160
162
  - `react-intl` `useIntl` — default tooltip/label strings (requires `IntlProvider` in the tree)
161
- - `@synerise/ds-core` `defaultColorsOrder` — auto-assigns colours to tabs by index
163
+ - `@synerise/ds-tokens` `orderedBase`/`orderedHover` (`/names` manifest) — the `ordered` categorical-colour queue auto-assigned to tabs by index
162
164
 
163
165
  ## Implementation notes
164
166
 
165
167
  - **`useIntl()` is called unconditionally** in `CardTab.tsx`. An `IntlProvider` must be present in the React tree or the component will throw. The `texts` prop can override individual strings but does not remove this requirement.
166
- - **Colour auto-assignment** — `CardTabs` uses `cloneElement` to inject `color` from `defaultColorsOrder[i % length]` for any tab that doesn't have an explicit `color` prop.
168
+ - **Colour auto-assignment** — `CardTabs` injects `orderIndex = i % orderedBase.length` (via `cloneElement`, or in the `Sortable` item data) for any tab without an explicit `color` prop; the tab then resolves its colour from that `ordered` token slot. Tabs with an explicit `color` resolve it (via `customColorOr`) to the reversible `--ds-color-custom-*` token.
167
169
  - **Sortable mode is activated automatically** — when `onChangeOrder` is provided AND `childrenCount > 1`, `CardTabs` switches from `renderChildren` (cloneElement loop) to a `<Sortable>` component that manages drag state. Individual tab's `draggable` prop is also OR'd with parent's `onChangeOrder` presence.
168
170
  - **Suffix rendering priority** — `actionsAsDropdown` > `renderSuffix` > `suffixIcon` (suppresses actions) > `CardTabActions` (if any action callback present).
169
171
  - **Double-click to rename** — `CardTabLabel` has an `onDoubleClick` handler that triggers `handleEditName` (same as clicking the rename action). While `edited=true`, the prefix is hidden and the suffix is replaced by `InlineEdit`.
170
172
  - **`disabled` is visual only** — applies `pointer-events: none` on the container div, but does not disable action icons individually; individual buttons inside the card are not disabled.
171
- - **`invalid` + `active` combination** — when both are true, the background becomes `red-600` and hover/active states use `getLighterColor('red-600')` (i.e., `red-500`).
173
+ - **`invalid` + `active` combination** — when both are true, the background uses the `--ds-card-tabs-variant-*-bg-validateactive` token and hover/pressed use `--ds-card-tabs-variant-grey-bg-validateactivehover` (a darker red than the former `red-500`; see the ⚑ note above).
172
174
  - **`index` prop does not exist** — the README incorrectly documents an `index` prop; no such prop is in `CardTabProps`.
@@ -27,6 +27,7 @@ const CardTab = (props) => {
27
27
  onPreviewTab,
28
28
  texts,
29
29
  color = "yellow",
30
+ orderIndex,
30
31
  itemData,
31
32
  dragHandleProps,
32
33
  actionsAsDropdown,
@@ -141,7 +142,7 @@ const CardTab = (props) => {
141
142
  }
142
143
  return /* @__PURE__ */ jsx(Fragment, {});
143
144
  })();
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
+ return /* @__PURE__ */ jsxs(CardTabContainer, { edited, active: Boolean(active), invalid: Boolean(invalid || invalidName), disabled: !active && Boolean(disabled), isDraggable: draggable, color, orderIndex, onClick: handleSelect, greyBackground: !!greyBackground, "data-id": id, "data-testid": "card-tab-container", itemData, children: [
145
146
  !edited && /* @__PURE__ */ jsx(CardTabPrefix, { dragHandleProps, draggable, ...prefixProps }),
146
147
  /* @__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: {
147
148
  value: editedName,
@@ -15,6 +15,7 @@ export declare const CardTabContainer: import('styled-components').StyledCompone
15
15
  invalid: boolean;
16
16
  greyBackground: boolean;
17
17
  color: string;
18
+ orderIndex?: number;
18
19
  disabled: boolean;
19
20
  edited: boolean;
20
21
  isDraggable?: boolean;
@@ -1,7 +1,7 @@
1
1
  import styled from "styled-components";
2
2
  import { InPlaceEditableInputContainer } from "@synerise/ds-inline-edit/dist/InlineEdit.styles";
3
3
  import { macro } from "@synerise/ds-typography";
4
- import { getColor, getLighterColor } from "../utils.js";
4
+ import { orderedBaseOr, customColorOr, getColor, orderedHoverOr } from "../utils.js";
5
5
  const CardTabSuffix = /* @__PURE__ */ styled.div.withConfig({
6
6
  displayName: "CardTabstyles__CardTabSuffix",
7
7
  componentId: "sc-1n86s98-0"
@@ -17,19 +17,15 @@ const CardSuffixWrapper = /* @__PURE__ */ styled.span.withConfig({
17
17
  const CardTabLabel = /* @__PURE__ */ styled.span.withConfig({
18
18
  displayName: "CardTabstyles__CardTabLabel",
19
19
  componentId: "sc-1n86s98-3"
20
- })(["", ";color:", ";line-height:20px;position:relative;font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex:1;display:flex;align-items:center;justify-content:flex-start;", "{input{font-weight:500;font-size:14px;line-height:20px;color:", ";background-image:linear-gradient( to right,", " 0%,", " 33%,rgba(255,255,255,0) 34%,rgba(255,255,255,0) 100% );}}"], macro.h300, (props) => props.theme.palette["grey-600"], InPlaceEditableInputContainer, (props) => props.theme.palette["grey-800"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"]);
20
+ })(["", ";color:var(--ds-card-tabs-variant-grey-text-default);line-height:20px;position:relative;font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex:1;display:flex;align-items:center;justify-content:flex-start;", "{input{font-weight:500;font-size:14px;line-height:20px;color:var(--ds-card-tabs-variant-grey-text-hover);background-image:linear-gradient( to right,var(--ds-color-text-brand-default) 0%,var(--ds-color-text-brand-default) 33%,transparent 34%,transparent 100% );}}"], macro.h300, InPlaceEditableInputContainer);
21
21
  const CardTabTag = /* @__PURE__ */ styled.div.withConfig({
22
22
  displayName: "CardTabstyles__CardTabTag",
23
23
  componentId: "sc-1n86s98-4"
24
- })(["", " color:", ";display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:3px;"], macro.h200, ({
25
- theme
26
- }) => theme.palette.white);
24
+ })(["", " color:var(--ds-card-tabs-variant-grey-tag-text-default);display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:3px;"], macro.h200);
27
25
  const CardDotPrefix = /* @__PURE__ */ styled.div.withConfig({
28
26
  displayName: "CardTabstyles__CardDotPrefix",
29
27
  componentId: "sc-1n86s98-5"
30
- })(["", " color:", ";display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;"], macro.h200, ({
31
- theme
32
- }) => theme.palette.white);
28
+ })(["", " color:var(--ds-card-tabs-variant-grey-text-active);display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;"], macro.h200);
33
29
  const CardDot = /* @__PURE__ */ styled.div.withConfig({
34
30
  displayName: "CardTabstyles__CardDot",
35
31
  componentId: "sc-1n86s98-6"
@@ -49,57 +45,62 @@ const CardIconPrefix = /* @__PURE__ */ styled.div.withConfig({
49
45
  const CardTabContainer = /* @__PURE__ */ styled.div.withConfig({
50
46
  displayName: "CardTabstyles__CardTabContainer",
51
47
  componentId: "sc-1n86s98-10"
52
- })(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:12px;width:168px;@media (max-width:588px){max-width:145px;}height:48px;user-select:none;background-color:", ";box-shadow:", ";border-radius:3px;border-width:", ";border-color:", ";border-style:solid;pointer-events:", ";", "{background-color:", ";color:", ";}", "{background-color:", ";}", "{height:", ";width:", ";border-width:", ";border-color:", ";border-style:solid;}", "{svg{color:", ";fill:", " !important;}}", "{svg{color:", " !important;fill:", " !important;}.remove{svg{color:", " !important;fill:", " !important;}}}&:hover{cursor:pointer;box-shadow:", ";background-color:", ";", "{display:", ";}", "{display:", ";}", "{color:", ";}", "{background-color:", ";color:", ";display:", ";}", "{svg{color:", ";fill:", ";}}", "{display:", ";svg{color:", ";fill:", " !important;}}", "{display:", ";}", "{display:", ";svg{color:", ";fill:", ";}}.ds-card-tabs__suffix-icon{svg{color:", ";fill:", " !important;}}}&:active{background-color:", ";}", "{input{color:", ";padding:0 !important;background-image:linear-gradient( to right,", " 0%,", " 33%,rgba(255,255,255,0) 34%,rgba(255,255,255,0) 100% ) !important;}}", "{color:", ";opacity:", ";}.ds-card-tabs__suffix-icon{svg{color:", ";fill:", ";}opacity:", ";}", "{opacity:", ";.ds-card-tabs__handle-icon{svg{color:", ";fill:", ";}}svg{color:", ";fill:", ";}", "{opacity:", ";}}"], ({
48
+ })(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:12px;width:168px;@media (max-width:588px){max-width:145px;}height:48px;user-select:none;background-color:", ";box-shadow:", ";border-radius:3px;border-width:", ";border-color:", ";border-style:solid;pointer-events:", ";", "{background-color:", ";color:", ";}", "{background-color:", ";}", "{height:", ";width:", ";border-width:", ";border-color:", ";border-style:solid;}", "{color:", ";}", "{.ds-icon{color:", ";}.remove .ds-icon{color:", ";}}&:hover{cursor:pointer;box-shadow:", ";background-color:", ";", "{display:", ";}", "{display:", ";}", "{color:", ";}", "{background-color:", ";color:", ";display:", ";}", "{color:", ";}", "{display:", ";.ds-icon{color:", ";}}", "{display:", ";}", "{display:", ";color:", ";}.ds-card-tabs__suffix-icon{color:", ";}}&:active{background-color:", ";}", "{input{color:", ";padding:0 !important;background-image:linear-gradient( to right,", " 0%,", " 33%,transparent 34%,transparent 100% ) !important;}}", "{color:", ";opacity:", ";}.ds-card-tabs__suffix-icon{color:", ";opacity:", ";}", "{opacity:", ";color:", ";.ds-card-tabs__handle-icon{color:", ";}", "{opacity:", ";}}"], ({
53
49
  theme,
54
50
  active,
55
51
  invalid,
56
52
  color,
53
+ orderIndex,
57
54
  greyBackground
58
55
  }) => {
59
56
  if (invalid && active) {
60
- return theme.palette["red-600"];
57
+ return "var(--ds-card-tabs-variant-grey-bg-validateactive)";
61
58
  }
62
59
  if (active) {
63
- return theme.palette[`${color}`];
60
+ return orderedBaseOr(customColorOr(color), orderIndex);
64
61
  }
65
62
  if (greyBackground) {
66
- return theme.palette.white;
63
+ return "var(--ds-card-tabs-variant-white-bg-default)";
67
64
  }
68
- return theme.palette["grey-050"];
65
+ return "var(--ds-card-tabs-variant-grey-bg-default)";
69
66
  }, ({
70
67
  greyBackground
71
- }) => greyBackground ? "0 4px 12px 0 rgba(35, 41, 54, 0.04)" : "0", ({
68
+ }) => greyBackground ? "var(--ds-card-tabs-variant-white-shadow)" : "0", ({
72
69
  greyBackground
73
70
  }) => greyBackground ? "0" : "1px", ({
74
71
  theme,
75
72
  active,
76
73
  invalid,
77
- color
74
+ color,
75
+ orderIndex
78
76
  }) => {
79
77
  if (invalid) {
80
- return theme.palette["red-600"];
78
+ return "var(--ds-card-tabs-variant-grey-border-validate)";
81
79
  }
82
- return getColor(active, theme.palette[`${color}`], theme.palette["grey-300"]);
80
+ return getColor(active, orderedBaseOr(customColorOr(color), orderIndex), "var(--ds-card-tabs-variant-grey-border-default)");
83
81
  }, ({
84
82
  disabled
85
83
  }) => disabled ? "none" : "all", CardTabTag, ({
86
84
  theme,
87
85
  active,
88
- color
89
- }) => getColor(active, theme.palette.white, theme.palette[`${color}`]), ({
86
+ color,
87
+ orderIndex
88
+ }) => getColor(active, "var(--ds-card-tabs-variant-grey-tag-bg-active)", orderedBaseOr(customColorOr(color), orderIndex)), ({
90
89
  theme,
91
90
  active,
92
- color
93
- }) => getColor(active, theme.palette[`${color}`], theme.palette.white), CardDot, ({
91
+ color,
92
+ orderIndex
93
+ }) => getColor(active, orderedBaseOr(customColorOr(color), orderIndex), "var(--ds-card-tabs-variant-grey-tag-text-default)"), CardDot, ({
94
94
  theme,
95
95
  active,
96
96
  color,
97
- invalid
97
+ invalid,
98
+ orderIndex
98
99
  }) => {
99
100
  if (active && invalid) {
100
- return theme.palette[`${color}`];
101
+ return orderedBaseOr(customColorOr(color), orderIndex);
101
102
  }
102
- return getColor(active, "transparent", theme.palette[`${color}`]);
103
+ return getColor(active, "transparent", orderedBaseOr(customColorOr(color), orderIndex));
103
104
  }, CardDotPrefix, ({
104
105
  active,
105
106
  edited
@@ -110,218 +111,111 @@ const CardTabContainer = /* @__PURE__ */ styled.div.withConfig({
110
111
  active,
111
112
  edited
112
113
  }) => active && !edited ? "2px" : "0px", ({
113
- theme,
114
114
  active,
115
115
  edited
116
- }) => active && !edited ? theme.palette.white : "none", CardSuffixWrapper, ({
117
- theme,
116
+ }) => active && !edited ? "var(--ds-card-tabs-variant-grey-dot-ring)" : "none", CardSuffixWrapper, ({
118
117
  active
119
- }) => {
120
- if (active) {
121
- return theme.palette.white;
122
- }
123
- return theme.palette["grey-600"];
124
- }, ({
125
- theme,
118
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", CardTabSuffix, ({
126
119
  active
127
- }) => {
128
- if (active) {
129
- return theme.palette.white;
130
- }
131
- return theme.palette["grey-600"];
132
- }, CardTabSuffix, ({
133
- theme,
134
- active
135
- }) => active ? theme.palette.white : theme.palette["grey-600"], ({
136
- theme,
120
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", ({
137
121
  active
138
- }) => active ? theme.palette.white : theme.palette["grey-600"], ({
139
- theme,
140
- active
141
- }) => active ? theme.palette.white : theme.palette["red-600"], ({
142
- theme,
143
- active
144
- }) => active ? theme.palette.white : theme.palette["red-600"], ({
122
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-remove-icon)", ({
145
123
  greyBackground
146
- }) => greyBackground ? "0 4px 12px 0 rgba(35, 41, 54, 0.04)" : "", ({
124
+ }) => greyBackground ? "var(--ds-card-tabs-variant-white-shadow)" : "", ({
147
125
  theme,
148
126
  active,
149
127
  invalid,
150
128
  color,
129
+ orderIndex,
151
130
  greyBackground
152
131
  }) => {
153
132
  if (invalid && active) {
154
- return theme.palette[`${getLighterColor("red-600")}`];
133
+ return "var(--ds-card-tabs-variant-grey-bg-validateactivehover)";
155
134
  }
156
135
  if (active) {
157
- return theme.palette[`${getLighterColor(color)}`];
136
+ return orderedHoverOr(customColorOr(color, -100), orderIndex);
158
137
  }
159
138
  if (greyBackground && !active) {
160
- return theme.palette.white;
139
+ return "var(--ds-card-tabs-variant-white-bg-hover)";
161
140
  }
162
- return theme.palette["grey-050"];
141
+ return "var(--ds-card-tabs-variant-grey-bg-hover)";
163
142
  }, CardTabSuffix, ({
164
143
  edited
165
144
  }) => edited ? "none" : "flex", CardSuffixWrapper, ({
166
145
  edited
167
146
  }) => edited ? "none" : "flex", CardTabLabel, ({
168
- theme,
169
147
  active
170
- }) => {
171
- if (active) {
172
- return theme.palette.white;
173
- }
174
- return theme.palette["grey-800"];
175
- }, CardTabTag, ({
148
+ }) => active ? "var(--ds-card-tabs-variant-grey-text-active)" : "var(--ds-card-tabs-variant-grey-text-hover)", CardTabTag, ({
176
149
  theme,
177
150
  color,
178
- active
151
+ active,
152
+ orderIndex
179
153
  }) => {
180
154
  if (active) {
181
- return theme.palette.white;
155
+ return "var(--ds-card-tabs-variant-grey-tag-bg-active)";
182
156
  }
183
- return theme.palette[`${color}`];
157
+ return orderedBaseOr(customColorOr(color), orderIndex);
184
158
  }, ({
185
159
  theme,
186
160
  active,
187
- color
161
+ color,
162
+ orderIndex
188
163
  }) => {
189
164
  if (active) {
190
- return theme.palette[`${color}`];
165
+ return orderedBaseOr(customColorOr(color), orderIndex);
191
166
  }
192
- return theme.palette.white;
167
+ return "var(--ds-card-tabs-variant-grey-tag-text-default)";
193
168
  }, (props) => props.isDraggable ? "none" : "flex", CardTabPrefix, ({
194
- theme,
195
169
  active
196
- }) => {
197
- if (active) {
198
- return theme.palette.white;
199
- }
200
- return theme.palette["grey-600"];
201
- }, ({
202
- theme,
203
- active
204
- }) => {
205
- if (active) {
206
- return theme.palette.white;
207
- }
208
- return theme.palette["grey-600"];
209
- }, CardDragPrefix, ({
170
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", CardDragPrefix, ({
210
171
  edited
211
172
  }) => edited ? "none" : "flex", ({
212
- theme,
213
173
  active
214
- }) => {
215
- if (active) {
216
- return theme.palette.white;
217
- }
218
- return theme.palette["grey-600"];
219
- }, ({
220
- theme,
174
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", CardDotPrefix, (props) => props.isDraggable ? "none" : "flex", CardIconPrefix, (props) => props.isDraggable ? "none" : "flex", ({
221
175
  active
222
- }) => {
223
- if (active) {
224
- return theme.palette.white;
225
- }
226
- return theme.palette["grey-600"];
227
- }, CardDotPrefix, (props) => props.isDraggable ? "none" : "flex", CardIconPrefix, (props) => props.isDraggable ? "none" : "flex", ({
228
- theme,
229
- active
230
- }) => active ? theme.palette.white : theme.palette["grey-600"], ({
231
- theme,
232
- active
233
- }) => active ? theme.palette.white : theme.palette["grey-600"], ({
234
- theme,
176
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", ({
235
177
  active
236
- }) => {
237
- if (active) {
238
- return theme.palette.white;
239
- }
240
- return theme.palette["grey-600"];
241
- }, ({
242
- theme,
243
- active
244
- }) => {
245
- if (active) {
246
- return theme.palette.white;
247
- }
248
- return theme.palette["grey-600"];
249
- }, ({
178
+ }) => active ? "var(--ds-card-tabs-variant-grey-icon-active)" : "var(--ds-card-tabs-variant-grey-icon-default)", ({
250
179
  theme,
251
180
  active,
252
181
  invalid,
253
182
  color,
183
+ orderIndex,
254
184
  greyBackground
255
185
  }) => {
256
186
  if (invalid && active) {
257
- return theme.palette[`${getLighterColor("red-600")}`];
187
+ return "var(--ds-card-tabs-variant-grey-bg-validateactivehover)";
258
188
  }
259
189
  if (active) {
260
- return theme.palette[`${getLighterColor(color)}`];
190
+ return orderedHoverOr(customColorOr(color, -100), orderIndex);
261
191
  }
262
192
  if (greyBackground && !active) {
263
- return theme.palette.white;
193
+ return "var(--ds-card-tabs-variant-white-bg-default)";
264
194
  }
265
- return theme.palette["grey-100"];
195
+ return "var(--ds-color-background-base-muted)";
266
196
  }, InPlaceEditableInputContainer, ({
267
- theme,
268
197
  active
269
- }) => {
270
- if (active) {
271
- return theme.palette.white;
272
- }
273
- return theme.palette["grey-800"];
274
- }, ({
275
- theme,
198
+ }) => active ? "var(--ds-card-tabs-variant-grey-text-active)" : "var(--ds-card-tabs-variant-grey-text-hover)", ({
276
199
  active
277
- }) => {
278
- if (active) {
279
- return theme.palette.white;
280
- }
281
- return theme.palette["grey-800"];
282
- }, ({
283
- theme,
200
+ }) => active ? "var(--ds-card-tabs-variant-grey-text-active)" : "var(--ds-card-tabs-variant-grey-text-hover)", ({
284
201
  active
285
- }) => {
286
- if (active) {
287
- return theme.palette.white;
288
- }
289
- return theme.palette["grey-800"];
290
- }, CardTabLabel, ({
291
- theme,
202
+ }) => active ? "var(--ds-card-tabs-variant-grey-text-active)" : "var(--ds-card-tabs-variant-grey-text-hover)", CardTabLabel, ({
292
203
  active
293
- }) => {
294
- if (active) {
295
- return theme.palette.white;
296
- }
297
- return theme.palette["grey-600"];
298
- }, ({
204
+ }) => active ? "var(--ds-card-tabs-variant-grey-text-active)" : "var(--ds-card-tabs-variant-grey-text-default)", ({
299
205
  disabled
300
- }) => disabled ? 0.4 : 1, ({
301
- theme,
206
+ }) => disabled ? "var(--ds-card-tabs-variant-grey-disabled-opacity)" : "1", ({
302
207
  active
303
- }) => getColor(active, theme.palette.white, theme.palette["grey-600"]), ({
304
- theme,
305
- active
306
- }) => getColor(active, theme.palette.white, theme.palette["grey-600"]), ({
208
+ }) => getColor(active, "var(--ds-card-tabs-variant-grey-icon-active)", "var(--ds-card-tabs-variant-grey-icon-default)"), ({
307
209
  disabled
308
- }) => disabled ? 0.4 : 1, CardTabPrefix, ({
210
+ }) => disabled ? "var(--ds-card-tabs-variant-grey-disabled-opacity)" : "1", CardTabPrefix, ({
309
211
  disabled
310
- }) => disabled ? 0.4 : 1, ({
311
- theme,
212
+ }) => disabled ? "var(--ds-card-tabs-variant-grey-disabled-opacity)" : "1", ({
312
213
  active
313
- }) => getColor(active, theme.palette.white, theme.palette["grey-400"]), ({
314
- theme,
315
- active
316
- }) => getColor(active, theme.palette.white, theme.palette["grey-400"]), ({
317
- theme,
318
- active
319
- }) => getColor(active, theme.palette.white, theme.palette["grey-600"]), ({
320
- theme,
214
+ }) => getColor(active, "var(--ds-card-tabs-variant-grey-icon-active)", "var(--ds-card-tabs-variant-grey-icon-default)"), ({
321
215
  active
322
- }) => getColor(active, theme.palette.white, theme.palette["grey-600"]), CardTabSuffix, ({
216
+ }) => getColor(active, "var(--ds-card-tabs-variant-grey-icon-active)", "var(--ds-card-tabs-variant-grey-handler-default)"), CardTabSuffix, ({
323
217
  disabled
324
- }) => disabled ? 0.4 : 1);
218
+ }) => disabled ? "var(--ds-card-tabs-variant-grey-disabled-opacity)" : "1");
325
219
  export {
326
220
  CardDot,
327
221
  CardDotPrefix,
@@ -1,14 +1,13 @@
1
1
  import { KeyboardEvent, MouseEvent, ReactNode } from 'react';
2
2
  import { IntlShape } from 'react-intl';
3
- import { DefaultColor } from '@synerise/ds-core';
4
3
  import { DragHandlePropType } from '@synerise/ds-sortable';
4
+ import { CustomColorToken, LiteralStringUnion } from '@synerise/ds-utils';
5
5
  export declare enum prefixType {
6
6
  TAG = 0,
7
7
  ICON = 1,
8
8
  DOT = 2,
9
9
  HANDLE = 3
10
10
  }
11
- export type Color = 'red' | 'green' | 'grey' | 'yellow' | 'blue' | 'pink' | 'mars' | 'orange' | 'fern' | 'cyan' | 'purple' | 'violet';
12
11
  export type ListItemEventType = MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>;
13
12
  export type CardTabTexts = {
14
13
  changeNameTooltip?: ReactNode;
@@ -38,7 +37,12 @@ export type PrefixProps = DotPrefixProps | HandlePrefixProps | IconPrefixProps |
38
37
  type CardTabCommonProps = {
39
38
  name: string;
40
39
  dragHandleProps?: DragHandlePropType;
41
- color?: Color | DefaultColor | string;
40
+ color?: LiteralStringUnion<CustomColorToken>;
41
+ /**
42
+ * Slot in the `ordered` categorical-colour queue, injected by `CardTabs` for tabs without
43
+ * an explicit `color`. When set, the tab's colour comes from that ordered token slot.
44
+ */
45
+ orderIndex?: number;
42
46
  active?: boolean;
43
47
  draggable?: boolean;
44
48
  suffixIcon?: ReactNode;
package/dist/CardTabs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { Children, isValidElement, cloneElement } from "react";
3
3
  import Button from "@synerise/ds-button";
4
- import { defaultColorsOrder } from "@synerise/ds-core";
5
4
  import Sortable from "@synerise/ds-sortable";
5
+ import { orderedBase } from "@synerise/ds-tokens/names";
6
6
  import CardTab from "./CardTab/CardTab.js";
7
7
  import { CardTabsAddButton, CardTabsContainer } from "./CardTabs.styles.js";
8
8
  const CardTabs = ({
@@ -21,7 +21,7 @@ const CardTabs = ({
21
21
  const childrenCount = Children.count(children);
22
22
  const childrenData = Children.map(children, (child, i) => ({
23
23
  ...child.props,
24
- color: defaultColorsOrder[i % defaultColorsOrder.length],
24
+ orderIndex: i % orderedBase.length,
25
25
  draggable: childrenCount > 1 && (Boolean(onChangeOrder) || child.props.draggable),
26
26
  ...child.props.keyId ? {
27
27
  key: child.props.keyId
@@ -33,7 +33,7 @@ const CardTabs = ({
33
33
  } = child;
34
34
  return isValidElement(child) && cloneElement(child, {
35
35
  ...props.color ? {} : {
36
- color: defaultColorsOrder[i % defaultColorsOrder.length]
36
+ orderIndex: i % orderedBase.length
37
37
  },
38
38
  draggable: childrenCount > 1 && (Boolean(onChangeOrder) || props.draggable)
39
39
  });
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export declare const getColor: (isActive: boolean, activeColor: string, defaultColor: string) => string;
2
- export declare const getLighterColor: (color: string) => string;
1
+ export declare const getColor: (isActive: boolean, activeColor: string | undefined, defaultColor: string | undefined) => string | undefined;
2
+ export declare const orderedBaseOr: (fallback: string | undefined, orderIndex?: number) => string | undefined;
3
+ export declare const orderedHoverOr: (fallback: string | undefined, orderIndex?: number) => string | undefined;
4
+ export declare const customColorOr: (color: string | undefined, shadeShift?: number) => string | undefined;
package/dist/utils.js CHANGED
@@ -1,21 +1,19 @@
1
+ import { orderedBase, orderedHover } from "@synerise/ds-tokens/names";
2
+ import { resolveCustomColor } from "@synerise/ds-utils";
1
3
  const getColor = (isActive, activeColor, defaultColor) => {
2
4
  if (isActive) {
3
5
  return activeColor;
4
6
  }
5
7
  return defaultColor;
6
8
  };
7
- const getLighterColor = (color) => {
8
- if (color) {
9
- const levelRegex = /(\d){3}$/g;
10
- const matches = color.match(levelRegex);
11
- if (matches?.length) {
12
- const level = parseInt(matches[0], 10);
13
- return color.replace(levelRegex, (level - 100).toString());
14
- }
15
- }
16
- return color;
17
- };
9
+ const orderedBaseOr = (fallback, orderIndex) => orderIndex !== void 0 ? orderedBase[orderIndex] : fallback;
10
+ const orderedHoverOr = (fallback, orderIndex) => orderIndex !== void 0 ? orderedHover[orderIndex] : fallback;
11
+ const customColorOr = (color, shadeShift = 0) => resolveCustomColor(color, void 0, {
12
+ shadeShift
13
+ });
18
14
  export {
15
+ customColorOr,
19
16
  getColor,
20
- getLighterColor
17
+ orderedBaseOr,
18
+ orderedHoverOr
21
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-card-tabs",
3
- "version": "2.0.11",
3
+ "version": "2.1.0",
4
4
  "description": "CardTabs UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -42,15 +42,16 @@
42
42
  ],
43
43
  "types": "dist/index.d.ts",
44
44
  "dependencies": {
45
- "@synerise/ds-button": "^2.1.5",
46
- "@synerise/ds-cruds": "^2.0.10",
47
- "@synerise/ds-dropdown": "^2.1.7",
48
- "@synerise/ds-icon": "^2.2.3",
49
- "@synerise/ds-inline-edit": "^2.0.11",
50
- "@synerise/ds-sortable": "^2.0.5",
51
- "@synerise/ds-tooltip": "^2.0.10",
52
- "@synerise/ds-typography": "^2.0.10",
53
- "@synerise/ds-utils": "^2.2.2"
45
+ "@synerise/ds-button": "^2.2.0",
46
+ "@synerise/ds-cruds": "^2.1.0",
47
+ "@synerise/ds-dropdown": "^2.2.0",
48
+ "@synerise/ds-icon": "^2.3.0",
49
+ "@synerise/ds-inline-edit": "^2.1.0",
50
+ "@synerise/ds-sortable": "^2.1.0",
51
+ "@synerise/ds-tokens": "^2.1.0",
52
+ "@synerise/ds-tooltip": "^2.1.0",
53
+ "@synerise/ds-typography": "^2.1.0",
54
+ "@synerise/ds-utils": "^2.3.0"
54
55
  },
55
56
  "devDependencies": {
56
57
  "vitest": "4"
@@ -61,5 +62,5 @@
61
62
  "react-intl": ">=3.12.0 <= 6.8",
62
63
  "styled-components": "^5.3.3"
63
64
  },
64
- "gitHead": "5ac0f7dcb7c3995b402c86c087d8f32770f80a1d"
65
+ "gitHead": "5c3d61e30289486d14c7d6becb682e2d4a08ce41"
65
66
  }