@synerise/ds-tag 2.0.11 → 2.1.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,28 @@
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.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@2.1.0...@synerise/ds-tag@2.1.1) (2026-11-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **tag:** match Figma horizontal spacing ([1434e22](https://github.com/Synerise/synerise-design/commit/1434e2218d0e12ac0954788518f44167acde9f6b))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@2.0.11...@synerise/ds-tag@2.1.0) (2026-10-29)
18
+
19
+
20
+ ### Features
21
+
22
+ * integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [2.0.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@2.0.10...@synerise/ds-tag@2.0.11) (2026-10-28)
7
29
 
8
30
  **Note:** Version bump only for package @synerise/ds-tag
package/CLAUDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tag (`@synerise/ds-tag`)
2
2
 
3
- > A styled label component that supports multiple shapes, optional removal, prefix/suffix slots, image, tooltip, and status variants.
3
+ > A styled label component that supports multiple shapes, optional removal, prefix/suffix slots, tooltip, and status variants.
4
4
 
5
5
  ## Package structure
6
6
 
@@ -30,19 +30,19 @@ export { useDefaultTexts } from './hooks/useDefaultTexts';
30
30
  |------|------|---------|-------------|
31
31
  | `id` | `string \| number` | — | Used as the argument passed to `onRemove`; also sets `data-testid="tag-{id}"` (falls back to `"tag"` when absent) |
32
32
  | `name` | `string` | — | Display text of the tag, rendered inside a `<span>` with text-overflow ellipsis |
33
- | `color` | `string` | — | Background color for non-status shapes; sets close-icon color via `getColorText` |
34
- | `textColor` | `string` | — | Overrides computed text color for any shape |
33
+ | `color` | `string` | — | Background color for non-status shapes. Unset → grey variant tokens for background and text |
34
+ | `textColor` | `string` | — | Text color; on default/single-character/medium shapes it applies only when `color` is set (else the grey variant text token wins) |
35
35
  | `shape` | `TagShape` | `TagShape.DEFAULT_SQUARE` (see note) | Controls size, border-radius, and status styling |
36
- | `image` | `string` | — | `src` for an `<img>` rendered before content; only shown for `DEFAULT_ROUND`/`DEFAULT_SQUARE` shapes |
36
+ | `image` | `string` | — | **@deprecated** — renders `<img src={image} alt="" />` as the `prefixel`, exactly as if passed there. Typed as exclusive with `prefixel` |
37
37
  | `removable` | `boolean` | — | Shows remove button on hover; only functional for `DEFAULT_ROUND` and `DEFAULT_SQUARE` |
38
38
  | `disabled` | `boolean` | — | Reduces opacity to 0.4, prevents remove action; `onClick` still fires |
39
39
  | `onClick` | `() => void` | — | Click handler on the tag container |
40
40
  | `onRemove` | `(tag: string \| number) => void` | — | Called with `id` when remove button is clicked; requires `id` to be set |
41
- | `prefixel` | `ReactNode` | — | Leading slot; strings/numbers get badge-style addonStyles wrapper, nodes get plain wrapper |
42
- | `suffixel` | `ReactNode` | — | Trailing slot; hidden on remove-button hover; strings/numbers get addonStyles wrapper |
41
+ | `prefixel` | `ReactNode` | — | Leading slot; strings/numbers get badge-style addonStyles wrapper, nodes get plain wrapper. An `<img>` (direct child) is sized 16×16, `object-fit: cover`, centred in a 24px slot. Reduces the left padding to 4px |
42
+ | `suffixel` | `ReactNode` | — | Trailing slot; replaced by the remove button on hover; strings/numbers get addonStyles wrapper. Reduces the right padding to 4px |
43
43
  | `texts` | `Partial<TagTexts>` | — | Override any i18n string (see `TagTexts`) |
44
- | `asPill` | `boolean` | — | Disables hover brightness filter (cursor stays default) |
45
- | `dashed` | `boolean` | — | Passed to styled component; intended for dashed-border variant (no built-in CSS rule in current styles) |
44
+ | `asPill` | `boolean` | — | Disables the hover effect (cursor stays default) |
45
+ | `dashed` | `boolean` | — | **@deprecated** — no-op on `Tag` (no CSS rule; filtered from the DOM). The dashed-border status variant is applied by `ds-status`'s `styled(Tag)` wrapper, not `Tag`. |
46
46
  | `tooltipProps` | `TooltipProps` | — | Wraps the entire rendered tag in `<Tooltip>` when provided |
47
47
  | `className` | `string` | — | Appended to the `ds-tag` className on the root element |
48
48
  | `ref` | `React.Ref<HTMLDivElement>` | — | Forwarded to the root `<div>` |
@@ -119,26 +119,27 @@ import Tag, { TagShape } from '@synerise/ds-tag';
119
119
  name="With icon"
120
120
  shape={TagShape.DEFAULT_ROUND}
121
121
  color="#5A32FB"
122
- prefixel={<Icon component={<Add3M />} size={20} />}
122
+ prefixel={<Icon component={<Add3M />} size={24} />}
123
123
  />
124
124
  ```
125
125
 
126
126
  ## Styling
127
127
 
128
128
  - Uses `styled-components` throughout; all styles are in `Tag.styles.ts`.
129
- - Background is rendered via a `::before` pseudo-element (non-status shapes), with `filter: brightness()` applied on hover.
130
- - `getColorText(theme, color)` is exported from `Tag.styles` and used by stories and the remove-icon to pick white vs `grey-600` depending on whether `color` equals `theme.palette['grey-200']`.
131
- - When `asPill` is `true`, the hover brightness filter is suppressed and cursor stays `default`.
132
- - Remove button is hidden via `display: none` by default and set to `display: inline-block` on `:hover` via the isActionable CSS block.
133
- - Suffix is hidden (`display: none`) while the remove button is visible on hover.
134
- - `dashed` prop is forwarded to the styled component but no CSS rule currently uses it in `Tag.styles.ts` — it is available for downstream extension.
129
+ - Background is rendered via a `::before` pseudo-element (non-status shapes). On hover, a tag without `color` (grey variant, not a small pill shape) switches to `--ds-tag-variant-gray-bg-hover`; a tag with a custom `color` and the small pill shapes get `filter: brightness()` instead.
130
+ - `getColorText(color, textColor, theme?)` is exported from `Tag.styles` (stories deep-import it). No `color` → `--ds-tag-variant-gray-text`; `color` set → `textColor`, else `--ds-tag-variant-color-text`, except on a light-grey `color` (the grey-200 custom colour, or its hex via `theme`) → `--ds-color-text-base-muted`. The background pairs with it: `color`, else `--ds-tag-variant-gray-bg-default`.
131
+ - When `asPill` is `true`, the hover effect is suppressed and cursor stays `default`.
132
+ - **Horizontal spacing** (`DEFAULT_ROUND` / `DEFAULT_SQUARE`, per Figma node 366-7645): 12px padding on each side, reduced to 4px on the side that has a prefixel / suffixel. A badge (a string/number prefixel/suffixel, or a `.ds-badge` passed as the wrapper's direct child) gets 4px more between it and the label. The child selector is deliberate — jsdom's `:has()` throws in `getComputedStyle` on elements with a React `useId` id, which would break consumer specs.
133
+ - **Remove on hover** — on `mouseenter` of an actionable tag `Tag.tsx` locks the root's inline `width` to its rest width (`isHovered`), hides the suffixel and shows the 24px ✕ in its place with 4px right padding; the label truncates with an ellipsis instead of the tag growing. The lock never goes below the width the ✕ needs (`labelLeft + REMOVE_BUTTON_SIZE + HUG_PADDING`), so a one-character label can grow slightly. `mouseleave` clears it; consumer `style`/`onMouseEnter`/`onMouseLeave` are merged in.
134
+ - **`dashed` is deprecated and a no-op on `Tag`** — it has no CSS rule in `Tag.styles.ts` and is filtered from the DOM via `shouldForwardProp`. The dashed-border status variant is applied by `ds-status`'s `styled(Tag)` wrapper (`Status.styles.ts`), which reads its own `dashed` prop.
135
+ - **DOM prop leak guard** — `Tag`/`Content`/`PrefixWrapper`/`DefaultPrefixWrapper` use `.withConfig({ shouldForwardProp })` (denylist `dsProps`) so styling props (`shape`, `color`, `iconHover`, `isHovered`, …) don't reach the DOM element.
135
136
 
136
137
  ## Key dependencies
137
138
 
138
139
  - `@synerise/ds-icon` — close icon (`CloseS`) and custom prefix icons
139
140
  - `@synerise/ds-tooltip` — delete tooltip on remove button and optional whole-tag tooltip
140
- - `@synerise/ds-core` — `useTheme()` for palette access, `ThemeProps` typing
141
- - `@synerise/ds-utils` — `WithHTMLAttributes` wrapper type
141
+ - `@synerise/ds-core` — `useTheme()` for the `zindex-tooltip` value (`theme.variables`), `ThemeProps` typing
142
+ - `@synerise/ds-utils` — `WithHTMLAttributes` wrapper type, `resolveCustomColor` for the light-grey text check
142
143
  - `react-intl` — i18n for default texts (requires `IntlProvider` in the tree)
143
144
 
144
145
  ## Implementation notes
@@ -147,5 +148,4 @@ import Tag, { TagShape } from '@synerise/ds-tag';
147
148
  - `onRemove` is only called when both `onRemove` and `id` are defined; passing `removable` without `id` will show the button but silently no-op on click.
148
149
  - Remove is restricted to `DEFAULT_ROUND` and `DEFAULT_SQUARE` shapes regardless of the `removable` prop.
149
150
  - `disabled` only applies visual styling (opacity + cursor) and prevents `isActionable`; it does **not** stop `onClick` from firing.
150
- - Tests use `jest` (not vitest) — see `jest.config.js`.
151
151
  - `data-testid` is `"tag-{id}"` when `id` is provided, otherwise `"tag"`.
package/README.md CHANGED
@@ -42,12 +42,12 @@ import Tag from '@synerise/ds-tag'
42
42
  | removable | show remove button | boolean | - |
43
43
  | shape | shape of the tag | TagShape | TagShape.DEFAULT_SQUARE |
44
44
  | textColor | color of tag name label | string | - |
45
- | image | src of image shown before content (DEFAULT_ROUND/SQUARE only) | string | - |
46
- | prefixel | leading slot content | ReactNode | - |
47
- | suffixel | trailing slot content (hidden on remove hover) | ReactNode | - |
45
+ | image | **@deprecated** pass `<img src alt="" />` as `prefixel`; renders exactly that. Not allowed together with `prefixel` | string | - |
46
+ | prefixel | leading slot content; an `<img>` is sized 16px in the 24px slot | ReactNode | - |
47
+ | suffixel | trailing slot content (replaced by ✕ on hover) | ReactNode | - |
48
48
  | texts | i18n overrides for internal labels | Partial&lt;TagTexts&gt; | - |
49
49
  | asPill | disable hover brightness effect | boolean | - |
50
- | dashed | make border dashed | boolean | - |
50
+ | dashed | **@deprecated** no-op on Tag; dashed border is applied by ds-status | boolean | - |
51
51
  | tooltipProps | tooltip to show over entire tag. see ds-tooltip | TooltipProps | - |
52
52
 
53
53
  ## TagShape Enum
package/dist/Tag.d.ts CHANGED
@@ -1,22 +1,4 @@
1
1
  import { default as React } from 'react';
2
- import { TagShape } from './Tag.types';
3
- declare const Tag: React.ForwardRefExoticComponent<{
4
- id?: string | number;
5
- name?: string;
6
- textColor?: string;
7
- color?: string;
8
- image?: string;
9
- shape?: TagShape;
10
- removable?: boolean;
11
- className?: string;
12
- disabled?: boolean;
13
- onClick?: () => void;
14
- onRemove?: (tag: string | number) => void;
15
- prefixel?: React.ReactNode;
16
- suffixel?: React.ReactNode;
17
- texts?: import('./Tag.types').TagTexts;
18
- asPill?: boolean;
19
- dashed?: boolean;
20
- tooltipProps?: import('@synerise/ds-tooltip').TooltipProps;
21
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "className" | "id" | "color" | "onClick" | "name" | "textColor" | "image" | "shape" | "removable" | "disabled" | "onRemove" | "prefixel" | "suffixel" | "texts" | "asPill" | "dashed" | "tooltipProps"> & import('@synerise/ds-utils').DataAttributes & React.RefAttributes<HTMLDivElement>>;
2
+ import { TagProps } from './Tag.types';
3
+ declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLDivElement>>;
22
4
  export default Tag;
package/dist/Tag.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useState } from "react";
2
+ import { forwardRef, useState, useRef } from "react";
3
3
  import { useTheme } from "@synerise/ds-core";
4
4
  import Icon, { CloseS } from "@synerise/ds-icon";
5
5
  import Tooltip from "@synerise/ds-tooltip";
6
6
  import { useDefaultTexts } from "./hooks/useDefaultTexts.js";
7
- import { Tag as Tag$1, Content, TagName, RemoveButton, getColorText, PrefixWrapper, DefaultPrefixWrapper, SuffixWrapper, DefaultSuffixWrapper } from "./Tag.styles.js";
7
+ import { Tag as Tag$1, Content, TagName, RemoveButton, REMOVE_BUTTON_SIZE, HUG_PADDING, PrefixWrapper, DefaultPrefixWrapper, SuffixWrapper, DefaultSuffixWrapper } from "./Tag.styles.js";
8
8
  import { TagShape } from "./Tag.types.js";
9
9
  const Tag = forwardRef(({
10
10
  id,
@@ -18,23 +18,29 @@ const Tag = forwardRef(({
18
18
  textColor,
19
19
  onRemove,
20
20
  onClick,
21
- prefixel,
21
+ prefixel: prefixelProp,
22
22
  suffixel,
23
23
  texts,
24
24
  asPill,
25
25
  dashed,
26
26
  tooltipProps,
27
+ style,
28
+ onMouseEnter,
29
+ onMouseLeave,
27
30
  ...htmlAttributes
28
31
  }, ref) => {
29
32
  const theme = useTheme();
33
+ const prefixel = prefixelProp ?? (image ? /* @__PURE__ */ jsx("img", { src: image, alt: "" }) : void 0);
30
34
  const allTexts = useDefaultTexts(texts);
31
- const isDefaultType = shape && [TagShape.DEFAULT_ROUND, TagShape.DEFAULT_SQUARE].includes(shape);
32
35
  const isDefaultRound = shape === TagShape.DEFAULT_ROUND;
33
36
  const isDefaultSquare = shape === TagShape.DEFAULT_SQUARE;
34
37
  const isStatusShape = shape && [TagShape.STATUS_ERROR, TagShape.STATUS_NEUTRAL, TagShape.STATUS_SUCCESS, TagShape.STATUS_WARNING].includes(shape);
35
38
  const isRemovable = removable && (isDefaultRound || isDefaultSquare);
36
39
  const isActionable = !disabled && isRemovable;
37
40
  const [isIconHovered, setIsIconHovered] = useState(false);
41
+ const [hoverWidth, setHoverWidth] = useState();
42
+ const labelRef = useRef(null);
43
+ const isHovered = hoverWidth !== void 0;
38
44
  const onRemoveCall = () => !!onRemove && !!id && onRemove(id);
39
45
  const renderPrefixel = () => {
40
46
  if (typeof prefixel === "string" || typeof prefixel === "number") {
@@ -48,20 +54,27 @@ const Tag = forwardRef(({
48
54
  }
49
55
  return /* @__PURE__ */ jsx(DefaultSuffixWrapper, { children: suffixel });
50
56
  };
51
- const handleMouseOver = (event) => {
52
- setIsIconHovered(true);
53
- htmlAttributes.onMouseOver?.(event);
57
+ const handleMouseEnter = (event) => {
58
+ if (isActionable) {
59
+ const tagRect = event.currentTarget.getBoundingClientRect();
60
+ const labelLeft = labelRef.current?.getBoundingClientRect().left ?? tagRect.left;
61
+ const widthForRemoveButton = labelLeft - tagRect.left + REMOVE_BUTTON_SIZE + HUG_PADDING;
62
+ setHoverWidth(Math.max(tagRect.width, widthForRemoveButton));
63
+ }
64
+ onMouseEnter?.(event);
54
65
  };
55
66
  const handleMouseLeave = (event) => {
56
- setIsIconHovered(false);
57
- htmlAttributes.onMouseLeave?.(event);
67
+ setHoverWidth(void 0);
68
+ onMouseLeave?.(event);
58
69
  };
59
- const renderedTag = /* @__PURE__ */ jsx(Tag$1, { ref, className: `ds-tag ${className ?? ""}`, isStatusShape, shape, color, textColor, removable, disabled, isActionable, onClick, "data-testid": typeof id !== "undefined" ? `tag-${id}` : "tag", preffixel: !!prefixel, suffixel: !!suffixel, hasImage: !!image, iconHover: isIconHovered, asPill, dashed, ...htmlAttributes, children: /* @__PURE__ */ jsxs(Content, { iconHover: isIconHovered, children: [
60
- image && isDefaultType && /* @__PURE__ */ jsx("img", { src: image, alt: "" }),
70
+ const renderedTag = /* @__PURE__ */ jsx(Tag$1, { ref, className: `ds-tag ${className ?? ""}`, isStatusShape, shape, color, textColor, removable, disabled, isActionable, onClick, "data-testid": typeof id !== "undefined" ? `tag-${id}` : "tag", preffixel: !!prefixel, suffixel: !!suffixel, iconHover: isIconHovered, isHovered, asPill, dashed, ...htmlAttributes, style: isHovered ? {
71
+ ...style,
72
+ width: hoverWidth
73
+ } : style, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: /* @__PURE__ */ jsxs(Content, { iconHover: isIconHovered, children: [
61
74
  !!prefixel && renderPrefixel(),
62
- /* @__PURE__ */ jsx(TagName, { children: name }),
75
+ /* @__PURE__ */ jsx(TagName, { ref: labelRef, children: name }),
63
76
  !!suffixel && renderSuffixel(),
64
- isRemovable && /* @__PURE__ */ jsx(Tooltip, { title: allTexts.deleteTooltip, open: isIconHovered, zIndex: parseInt(theme.variables["@zindex-tooltip"], 10) + 1, children: /* @__PURE__ */ jsx(RemoveButton, { onClick: onRemoveCall, onMouseOver: handleMouseOver, onMouseLeave: handleMouseLeave, "data-testid": "remove-btn", children: /* @__PURE__ */ jsx(Icon, { className: "icon", component: /* @__PURE__ */ jsx(CloseS, {}), size: 24, color: getColorText(theme, color) }) }) })
77
+ isRemovable && /* @__PURE__ */ jsx(Tooltip, { title: allTexts.deleteTooltip, open: isIconHovered, zIndex: parseInt(theme.variables["zindex-tooltip"], 10) + 1, children: /* @__PURE__ */ jsx(RemoveButton, { onClick: onRemoveCall, onMouseOver: () => setIsIconHovered(true), onMouseLeave: () => setIsIconHovered(false), "data-testid": "remove-btn", children: /* @__PURE__ */ jsx(Icon, { className: "icon", component: /* @__PURE__ */ jsx(CloseS, {}), size: 24 }) }) })
65
78
  ] }) });
66
79
  return tooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...tooltipProps, children: renderedTag }) : renderedTag;
67
80
  });
@@ -1,6 +1,8 @@
1
- import { ThemeProps, ThemePropsVars } from '@synerise/ds-core';
1
+ import { ThemeProps } from '@synerise/ds-core';
2
2
  import { TagShape } from './Tag.types';
3
- export declare const getColorText: (theme: ThemePropsVars, color?: string) => string;
3
+ export declare const getColorText: (color?: string, textColor?: string, theme?: ThemeProps["theme"]) => string;
4
+ export declare const HUG_PADDING = 4;
5
+ export declare const REMOVE_BUTTON_SIZE = 24;
4
6
  export declare const TagName: import('styled-components').StyledComponent<"span", any, {}, never>;
5
7
  export declare const RemoveButton: import('styled-components').StyledComponent<"div", any, {}, never>;
6
8
  type TagProps = {
@@ -13,8 +15,8 @@ type TagProps = {
13
15
  isActionable?: boolean;
14
16
  suffixel?: boolean;
15
17
  preffixel?: boolean;
16
- hasImage?: boolean;
17
18
  iconHover?: boolean;
19
+ isHovered?: boolean;
18
20
  asPill?: boolean;
19
21
  dashed?: boolean;
20
22
  } & ThemeProps;
@@ -1,39 +1,42 @@
1
1
  import styled, { css } from "styled-components";
2
+ import { resolveCustomColor } from "@synerise/ds-utils";
2
3
  import { TagShape } from "./Tag.types.js";
4
+ const dsProps = /* @__PURE__ */ new Set(["isStatusShape", "shape", "color", "textColor", "removable", "disabled", "isActionable", "suffixel", "preffixel", "iconHover", "asPill", "dashed", "isHovered"]);
3
5
  const defaultStatusStyles = /* @__PURE__ */ css(["border-radius:9px;font-size:10px;height:18px;font-weight:500;line-height:18px;text-transform:uppercase;letter-spacing:0.1px;padding:0 8px;line-height:18px;"]);
4
- const getColorText = (theme, color) => {
5
- return color === theme.palette["grey-200"] ? theme.palette["grey-600"] : theme.palette.white;
6
- };
7
- const getWidthOnHover = (props) => {
8
- if (props.suffixel && props.preffixel || props.hasImage) {
9
- return "calc(100% - 23px)";
10
- }
11
- if (props.preffixel) {
12
- return "calc(100% - 35px)";
6
+ const LIGHT_GREY = resolveCustomColor("grey-200");
7
+ const isLightGrey = (color, theme) => !!color && (color === LIGHT_GREY || color === theme?.tokens["--ds-color-grey-200"]);
8
+ const getColorText = (color, textColor, theme) => {
9
+ if (!color) {
10
+ return "var(--ds-tag-variant-gray-text)";
13
11
  }
14
- if (props.suffixel) {
15
- return "calc(100% - 4px)";
12
+ if (textColor) {
13
+ return textColor;
16
14
  }
17
- return "calc(100% - 10px)";
15
+ return isLightGrey(color, theme) ? "var(--ds-color-text-base-muted)" : "var(--ds-tag-variant-color-text)";
18
16
  };
17
+ const LABEL_PADDING = 12;
18
+ const HUG_PADDING = 4;
19
+ const BADGE_GAP = 4;
20
+ const REMOVE_BUTTON_SIZE = 24;
21
+ const PREFIXEL_SLOT_SIZE = 24;
22
+ const PREFIXEL_IMAGE_SIZE = 16;
19
23
  const getFilterColor = (props) => {
20
- if (props.iconHover && props.color === props.theme.palette["grey-200"]) {
24
+ if (props.iconHover) {
21
25
  return "brightness(100%)";
22
26
  }
23
- if (props.color === props.theme.palette["grey-200"]) {
27
+ if (isLightGrey(props.color, props.theme)) {
24
28
  return "brightness(90%)";
25
29
  }
26
- if (props.iconHover) {
27
- return "brightness(100%)";
28
- }
29
30
  return "brightness(110%)";
30
31
  };
31
- const addonStyles = (props) => `
32
+ const usesGrayVariant = (props) => !props.color && props.shape !== TagShape.SMALL_SQUARE && props.shape !== TagShape.SMALL_ROUND;
33
+ const getHoverStyles = (props) => usesGrayVariant(props) ? "background-color: var(--ds-tag-variant-gray-bg-hover);" : `filter: ${getFilterColor(props)};`;
34
+ const addonStyles = () => `
32
35
  border: 1px solid;
33
36
  border-radius: 10px;
34
37
  height: 50%;
35
38
  padding: 0 3px;
36
- border-color: ${props.theme.palette.white};
39
+ border-color: var(--ds-color-background-base-default);
37
40
  font-size: 9px;
38
41
  line-height: 10px;
39
42
  text-align: center;
@@ -41,86 +44,95 @@ const addonStyles = (props) => `
41
44
  const TagName = /* @__PURE__ */ styled.span.withConfig({
42
45
  displayName: "Tagstyles__TagName",
43
46
  componentId: "sc-1xw3den-0"
44
- })(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
47
+ })(["min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
45
48
  const RemoveButton = /* @__PURE__ */ styled.div.withConfig({
46
49
  displayName: "Tagstyles__RemoveButton",
47
50
  componentId: "sc-1xw3den-1"
48
- })(["color:", ";height:18px;width:18px;border-radius:10px;padding:0;border:none;outline:none;margin:3px 3px 3px 5px;text-align:center;cursor:pointer;position:relative;overflow:hidden;display:none;opacity:0.8;&:before{color:", ";filter:brightness(70%);opacity:0.3;content:'';position:absolute;top:0;left:0;width:100%;height:100%;}&&&:hover{.ds-icon svg{fill:", " !important;}}.icon{&&{transform:translate(1px,-3px);}}"], ({
49
- color,
50
- theme
51
- }) => getColorText(theme, color), (props) => props.color || props.theme.palette["red-600"], (props) => props.theme.palette["red-600"]);
51
+ })(["color:inherit;display:none;flex:0 0 ", "px;height:", "px;align-items:center;justify-content:center;cursor:pointer;opacity:var(--ds-tag-remove-opacity);&&&:hover{.ds-icon{color:var(--ds-tag-remove-icon);}}"], REMOVE_BUTTON_SIZE, REMOVE_BUTTON_SIZE);
52
+ const defaultShapeStyles = (props, borderRadius) => {
53
+ const showRemove = props.isActionable && props.isHovered;
54
+ return css(["color:", ";border-radius:", ";font-size:13px;height:24px;line-height:24px;padding-left:", "px;padding-right:", "px;", ""], getColorText(props.color, props.textColor, props.theme), borderRadius, props.preffixel ? HUG_PADDING : LABEL_PADDING, props.suffixel || showRemove ? HUG_PADDING : LABEL_PADDING, showRemove && css(["", ",", "{display:none;}", "{display:flex;}"], SuffixWrapper, DefaultSuffixWrapper, RemoveButton));
55
+ };
52
56
  const insertShapeStyles = (props) => {
53
57
  switch (props.shape) {
54
58
  case TagShape.SMALL_SQUARE:
55
- return css(["color:", ";border-radius:3px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;font-weight:500;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "#fff");
59
+ return css(["color:", ";border-radius:3px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;font-weight:500;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "var(--ds-tag-pill-text)");
56
60
  case TagShape.SMALL_ROUND:
57
- return css(["color:", ";border-radius:8px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "#fff");
61
+ return css(["color:", ";border-radius:8px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "var(--ds-tag-pill-text)");
58
62
  case TagShape.MEDIUM_ROUND:
59
- return css(["color:", ";", ""], props.textColor || getColorText(props.theme, props.color), defaultStatusStyles);
63
+ return css(["color:", ";", ""], getColorText(props.color, props.textColor, props.theme), defaultStatusStyles);
60
64
  case TagShape.DEFAULT_ROUND:
61
- return css(["color:", ";border-radius:12px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ? "0" : "0 12px", TagName, props.removable ? "0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "4px", props.isActionable && css(["&:hover{padding:", ";", "{display:inline-block;padding:", ";padding-left:", ";padding-right:", ";width:", ";}padding-right:", ";", "{margin-left:0px;margin-right:", ";.icon{position:absolute;left:-3px;top:-3px;}}}"], props.removable && props.suffixel && "0 15px 0 0px", TagName, props.removable ? "0 7px 0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "10px", getWidthOnHover(props), !props.suffixel && "5px", RemoveButton, props.suffixel ? "2px" : "-2px"));
65
+ return defaultShapeStyles(props, "12px");
62
66
  case TagShape.DEFAULT_SQUARE:
63
- return css(["color:", ";border-radius:3px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ? "0" : "0 12px", TagName, props.removable ? "0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "4px", props.isActionable && css(["&:hover{padding-right:", ";", "{display:inline-block;padding:", ";padding-left:", ";padding-right:", ";width:", ";}padding-right:", ";", "{margin-left:0px;margin-right:", ";.icon{position:absolute;left:-3px;top:-3px;}}}"], props.removable && props.suffixel && "15px", TagName, props.removable ? "0 7px 0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "10px", getWidthOnHover(props), !props.suffixel && "5px", RemoveButton, props.suffixel ? "2px" : "-2px"));
67
+ return defaultShapeStyles(props, "3px");
64
68
  case TagShape.SINGLE_CHARACTER_ROUND:
65
- return css(["color:", ";border-radius:12px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], props.textColor || getColorText(props.theme, props.color));
69
+ return css(["color:", ";border-radius:12px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], getColorText(props.color, props.textColor, props.theme));
66
70
  case TagShape.SINGLE_CHARACTER_SQUARE:
67
- return css(["color:", ";border-radius:3px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], props.textColor || getColorText(props.theme, props.color));
71
+ return css(["color:", ";border-radius:3px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], getColorText(props.color, props.textColor, props.theme));
68
72
  case TagShape.STATUS_NEUTRAL:
69
- return css(["border:1px solid ", ";color:", ";", ""], props.color || props.theme.palette["grey-500"], props.textColor || props.color || props.theme.palette["grey-500"], defaultStatusStyles);
73
+ return css(["border:1px solid ", ";color:", ";", ""], props.color || "var(--ds-status-pill-variant-neutral-border-solid)", props.textColor || props.color || "var(--ds-status-pill-variant-neutral-text)", defaultStatusStyles);
70
74
  case TagShape.STATUS_SUCCESS:
71
- return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["green-600"], props.theme.palette["green-600"], defaultStatusStyles);
75
+ return css(["border:1px solid var(--ds-status-pill-variant-success-border-solid);color:var(--ds-status-pill-variant-success-text);", ""], defaultStatusStyles);
72
76
  case TagShape.STATUS_ERROR:
73
- return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["red-600"], props.theme.palette["red-600"], defaultStatusStyles);
77
+ return css(["border:1px solid var(--ds-status-pill-variant-error-border-solid);color:var(--ds-status-pill-variant-error-text);", ""], defaultStatusStyles);
74
78
  case TagShape.STATUS_WARNING:
75
- return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["yellow-600"], props.theme.palette["yellow-600"], defaultStatusStyles);
79
+ return css(["border:1px solid var(--ds-status-pill-variant-warning-border-solid);color:var(--ds-status-pill-variant-warning-text);", ""], defaultStatusStyles);
76
80
  default:
77
81
  return css([""]);
78
82
  }
79
83
  };
80
84
  const Content = /* @__PURE__ */ styled.div.withConfig({
85
+ shouldForwardProp: (prop) => !dsProps.has(prop)
86
+ }).withConfig({
81
87
  displayName: "Tagstyles__Content",
82
88
  componentId: "sc-1xw3den-2"
83
- })(["position:relative;display:flex;align-items:center;flex-grow:0;flex-shrink:1;max-width:100%;", ""], (props) => !!props.iconHover && `
89
+ })(["position:relative;display:flex;align-items:center;flex-grow:0;flex-shrink:1;min-width:0;max-width:100%;", ""], (props) => !!props.iconHover && `
84
90
  &&& {
85
- color:${props.theme.palette["red-600"]};
91
+ color: var(--ds-color-text-danger-default);
86
92
  }
87
93
  `);
88
94
  const PrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
95
+ shouldForwardProp: (prop) => !dsProps.has(prop)
96
+ }).withConfig({
89
97
  displayName: "Tagstyles__PrefixWrapper",
90
98
  componentId: "sc-1xw3den-3"
91
- })(["", ";", ""], (props) => addonStyles(props), (props) => !!props.iconHover && `.ds-badge-scroll-number{
92
- color: ${props.theme.palette["red-600"]}!important;
93
- box-shadow: 0 0 0 1px ${props.theme.palette["red-600"]}!important;
99
+ })(["", ";margin-right:", "px;", ""], addonStyles(), BADGE_GAP, (props) => !!props.iconHover && `.ds-badge-scroll-number{
100
+ color: var(--ds-color-text-danger-default)!important;
101
+ box-shadow: 0 0 0 1px var(--ds-color-border-danger-default)!important;
94
102
  }
95
- .ds-icon svg {
96
- fill: ${props.theme.palette["red-600"]};
103
+ .ds-icon {
104
+ color: var(--ds-color-icon-danger-default);
97
105
  }`);
98
106
  const SuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
99
107
  displayName: "Tagstyles__SuffixWrapper",
100
108
  componentId: "sc-1xw3den-4"
101
- })(["", ";"], (props) => addonStyles(props));
109
+ })(["", ";margin-left:", "px;"], addonStyles(), BADGE_GAP);
102
110
  const DefaultSuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
103
111
  displayName: "Tagstyles__DefaultSuffixWrapper",
104
112
  componentId: "sc-1xw3den-5"
105
- })([""]);
113
+ })(["display:flex;align-items:center;> .ds-badge{margin-left:", "px;}"], BADGE_GAP);
106
114
  const DefaultPrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
115
+ shouldForwardProp: (prop) => !dsProps.has(prop)
116
+ }).withConfig({
107
117
  displayName: "Tagstyles__DefaultPrefixWrapper",
108
118
  componentId: "sc-1xw3den-6"
109
- })(["", ""], (props) => !!props.iconHover && `.ds-badge-scroll-number{
110
- color: ${props.theme.palette["red-600"]}!important;
111
- box-shadow: 0 0 0 1px ${props.theme.palette["red-600"]}!important;
119
+ })(["display:flex;align-items:center;> .ds-badge{margin-right:", "px;}> img{display:block;width:", "px;height:", "px;margin:0 ", "px;object-fit:cover;}", ""], BADGE_GAP, PREFIXEL_IMAGE_SIZE, PREFIXEL_IMAGE_SIZE, (PREFIXEL_SLOT_SIZE - PREFIXEL_IMAGE_SIZE) / 2, (props) => !!props.iconHover && `.ds-badge-scroll-number{
120
+ color: var(--ds-color-text-danger-default)!important;
121
+ box-shadow: 0 0 0 1px var(--ds-color-border-danger-default)!important;
112
122
  }
113
- .ds-icon svg {
114
- fill: ${props.theme.palette["red-600"]};
123
+ .ds-icon {
124
+ color: var(--ds-color-icon-danger-default);
115
125
  }`);
116
126
  const Tag = /* @__PURE__ */ styled.div.withConfig({
127
+ shouldForwardProp: (prop) => !dsProps.has(prop)
128
+ }).withConfig({
117
129
  displayName: "Tagstyles__Tag",
118
130
  componentId: "sc-1xw3den-7"
119
- })(["position:relative;margin:4px;display:inline-flex;font-weight:500;overflow:hidden;cursor:default;", " ", ";", " ", " ", " .icon1{margin:0 -2px 0 1px;}", ";", ",", "{margin:", ";}", ",", "{margin:", ";}"], (props) => !props.asPill && css(["cursor:pointer;&:hover:before{filter:", ";}"], getFilterColor), (props) => insertShapeStyles(props), (props) => !!props.iconHover && `
131
+ })(["position:relative;box-sizing:border-box;margin:4px;display:inline-flex;font-weight:500;overflow:hidden;cursor:default;", " ", ";", " ", " ", ""], (props) => !props.asPill && css(["cursor:pointer;&:hover:before{", "}"], getHoverStyles), (props) => insertShapeStyles(props), (props) => !!props.iconHover && `
120
132
  &&&:before{
121
- background-color:${props.theme.palette["red-050"]};
133
+ background-color: var(--ds-color-background-danger-subtle);
122
134
  }
123
- `, (props) => !!props.disabled && css(["opacity:0.4;cursor:not-allowed;"]), (props) => !props.isStatusShape && css(["&:before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:", ";}", ";"], props.color || props.theme.palette["grey-500"], props.isActionable && css(["&:hover:before{filter:", ";}"], getFilterColor)), (props) => !!props.isActionable && css(["&:hover{", ",", "{display:none;}", "{position:absolute;top:0;right:", ";display:inline-block;}}"], SuffixWrapper, DefaultSuffixWrapper, RemoveButton, props.removable && props.suffixel ? "-15px" : "0"), SuffixWrapper, DefaultSuffixWrapper, (props) => !props.removable && props.suffixel ? "0px -8px 3px 5px" : "0 4px 3px 1px", PrefixWrapper, DefaultPrefixWrapper, (props) => !props.removable && props.preffixel ? "0px 5px 3px -8px" : "0 1px 3px 4px");
135
+ `, (props) => !!props.disabled && css(["opacity:var(--ds-tag-disabled-opacity);cursor:not-allowed;"]), (props) => !props.isStatusShape && css(["&:before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:", ";}", ";"], props.color || (props.shape === TagShape.SMALL_SQUARE || props.shape === TagShape.SMALL_ROUND ? "var(--ds-tag-pill-bg-gray)" : "var(--ds-tag-variant-gray-bg-default)"), props.isActionable && css(["&:hover:before{", "}"], getHoverStyles)));
124
136
  const DeleteButton = /* @__PURE__ */ styled.div.withConfig({
125
137
  displayName: "Tagstyles__DeleteButton",
126
138
  componentId: "sc-1xw3den-8"
@@ -130,7 +142,9 @@ export {
130
142
  DefaultPrefixWrapper,
131
143
  DefaultSuffixWrapper,
132
144
  DeleteButton,
145
+ HUG_PADDING,
133
146
  PrefixWrapper,
147
+ REMOVE_BUTTON_SIZE,
134
148
  RemoveButton,
135
149
  SuffixWrapper,
136
150
  Tag,
@@ -11,22 +11,35 @@ export type TagTexts = {
11
11
  deleteTooltip?: ReactNode;
12
12
  noResultsLabel?: ReactNode;
13
13
  };
14
- export type TagProps = WithHTMLAttributes<HTMLDivElement, {
14
+ type TagPrefixelProps = {
15
+ prefixel?: ReactNode;
16
+ image?: never;
17
+ } | {
18
+ prefixel?: never;
19
+ /**
20
+ * @deprecated Pass `<img src={src} alt="" />` as `prefixel` instead; this renders exactly that.
21
+ */
22
+ image?: string;
23
+ };
24
+ export type TagProps = WithHTMLAttributes<HTMLDivElement, TagPrefixelProps & {
15
25
  id?: string | number;
16
26
  name?: string;
17
27
  textColor?: string;
18
28
  color?: string;
19
- image?: string;
20
29
  shape?: TagShape;
21
30
  removable?: boolean;
22
31
  className?: string;
23
32
  disabled?: boolean;
24
33
  onClick?: () => void;
25
34
  onRemove?: (tag: string | number) => void;
26
- prefixel?: ReactNode;
27
35
  suffixel?: ReactNode;
28
36
  texts?: TagTexts;
29
37
  asPill?: boolean;
38
+ /**
39
+ * @deprecated No-op on `Tag` — it has no CSS rule and is filtered from the DOM.
40
+ * The dashed-border status variant is applied by `ds-status`'s `styled(Tag)` wrapper,
41
+ * not by `Tag` itself. Kept only for backward compatibility.
42
+ */
30
43
  dashed?: boolean;
31
44
  tooltipProps?: TooltipProps;
32
45
  }>;
@@ -43,3 +56,4 @@ export declare enum TagShape {
43
56
  STATUS_ERROR = "status_inactive",
44
57
  STATUS_WARNING = "status_paused"
45
58
  }
59
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-tag",
3
- "version": "2.0.11",
3
+ "version": "2.1.1",
4
4
  "description": "Tag UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -42,9 +42,9 @@
42
42
  ],
43
43
  "types": "dist/index.d.ts",
44
44
  "dependencies": {
45
- "@synerise/ds-icon": "^2.2.3",
46
- "@synerise/ds-tooltip": "^2.0.11",
47
- "@synerise/ds-utils": "^2.2.2",
45
+ "@synerise/ds-icon": "^2.3.1",
46
+ "@synerise/ds-tooltip": "^2.1.1",
47
+ "@synerise/ds-utils": "^2.3.1",
48
48
  "react-intl": "^6.8.7"
49
49
  },
50
50
  "devDependencies": {
@@ -55,5 +55,5 @@
55
55
  "react": ">=16.9.0 <= 18.3.1",
56
56
  "styled-components": "^5.3.3"
57
57
  },
58
- "gitHead": "c356039703d8826bbbdb6dadcb18bb008fea8bc5"
58
+ "gitHead": "2d2a540b35fddf8855da45f0dec2f4612c6d87b6"
59
59
  }