@synerise/ds-tag 2.1.0 → 2.1.2
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 +19 -0
- package/CLAUDE.md +8 -9
- package/README.md +3 -3
- package/dist/Tag.d.ts +2 -20
- package/dist/Tag.js +26 -13
- package/dist/Tag.styles.d.ts +3 -1
- package/dist/Tag.styles.js +24 -24
- package/dist/Tag.types.d.ts +12 -3
- package/package.json +5 -5
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.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@2.1.1...@synerise/ds-tag@2.1.2) (2026-11-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-tag
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [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)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **tag:** match Figma horizontal spacing ([1434e22](https://github.com/Synerise/synerise-design/commit/1434e2218d0e12ac0954788518f44167acde9f6b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [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)
|
|
7
26
|
|
|
8
27
|
|
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,
|
|
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
|
|
|
@@ -33,13 +33,13 @@ export { useDefaultTexts } from './hooks/useDefaultTexts';
|
|
|
33
33
|
| `color` | `string` | — | Background color for non-status shapes. Unset → grey variant tokens for background and text |
|
|
34
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` | — |
|
|
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;
|
|
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
44
|
| `asPill` | `boolean` | — | Disables the hover effect (cursor stays default) |
|
|
45
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`. |
|
|
@@ -119,7 +119,7 @@ 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={
|
|
122
|
+
prefixel={<Icon component={<Add3M />} size={24} />}
|
|
123
123
|
/>
|
|
124
124
|
```
|
|
125
125
|
|
|
@@ -129,10 +129,10 @@ import Tag, { TagShape } from '@synerise/ds-tag';
|
|
|
129
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
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
131
|
- When `asPill` is `true`, the hover effect is suppressed and cursor stays `default`.
|
|
132
|
-
-
|
|
133
|
-
-
|
|
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
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`, …) don't reach the DOM element.
|
|
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.
|
|
136
136
|
|
|
137
137
|
## Key dependencies
|
|
138
138
|
|
|
@@ -148,5 +148,4 @@ import Tag, { TagShape } from '@synerise/ds-tag';
|
|
|
148
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.
|
|
149
149
|
- Remove is restricted to `DEFAULT_ROUND` and `DEFAULT_SQUARE` shapes regardless of the `removable` prop.
|
|
150
150
|
- `disabled` only applies visual styling (opacity + cursor) and prevents `isActionable`; it does **not** stop `onClick` from firing.
|
|
151
|
-
- Tests use `jest` (not vitest) — see `jest.config.js`.
|
|
152
151
|
- `data-testid` is `"tag-{id}"` when `id` is provided, otherwise `"tag"`.
|
package/README.md
CHANGED
|
@@ -42,9 +42,9 @@ 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
|
|
46
|
-
| prefixel | leading slot content
|
|
47
|
-
| suffixel | trailing slot content (
|
|
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<TagTexts> | - |
|
|
49
49
|
| asPill | disable hover brightness effect | boolean | - |
|
|
50
50
|
| dashed | **@deprecated** no-op on Tag; dashed border is applied by ds-status | boolean | - |
|
package/dist/Tag.d.ts
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
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, 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
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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,
|
|
60
|
-
|
|
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:
|
|
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
|
});
|
package/dist/Tag.styles.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ThemeProps } from '@synerise/ds-core';
|
|
2
2
|
import { TagShape } from './Tag.types';
|
|
3
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;
|
package/dist/Tag.styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { resolveCustomColor } from "@synerise/ds-utils";
|
|
3
3
|
import { TagShape } from "./Tag.types.js";
|
|
4
|
-
const dsProps = /* @__PURE__ */ new Set(["isStatusShape", "shape", "color", "textColor", "removable", "disabled", "isActionable", "suffixel", "preffixel", "
|
|
4
|
+
const dsProps = /* @__PURE__ */ new Set(["isStatusShape", "shape", "color", "textColor", "removable", "disabled", "isActionable", "suffixel", "preffixel", "iconHover", "asPill", "dashed", "isHovered"]);
|
|
5
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;"]);
|
|
6
6
|
const LIGHT_GREY = resolveCustomColor("grey-200");
|
|
7
7
|
const isLightGrey = (color, theme) => !!color && (color === LIGHT_GREY || color === theme?.tokens["--ds-color-grey-200"]);
|
|
@@ -14,18 +14,12 @@ const getColorText = (color, textColor, theme) => {
|
|
|
14
14
|
}
|
|
15
15
|
return isLightGrey(color, theme) ? "var(--ds-color-text-base-muted)" : "var(--ds-tag-variant-color-text)";
|
|
16
16
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (props.suffixel) {
|
|
25
|
-
return "calc(100% - 4px)";
|
|
26
|
-
}
|
|
27
|
-
return "calc(100% - 10px)";
|
|
28
|
-
};
|
|
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;
|
|
29
23
|
const getFilterColor = (props) => {
|
|
30
24
|
if (props.iconHover) {
|
|
31
25
|
return "brightness(100%)";
|
|
@@ -50,11 +44,15 @@ const addonStyles = () => `
|
|
|
50
44
|
const TagName = /* @__PURE__ */ styled.span.withConfig({
|
|
51
45
|
displayName: "Tagstyles__TagName",
|
|
52
46
|
componentId: "sc-1xw3den-0"
|
|
53
|
-
})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
|
|
47
|
+
})(["min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
|
|
54
48
|
const RemoveButton = /* @__PURE__ */ styled.div.withConfig({
|
|
55
49
|
displayName: "Tagstyles__RemoveButton",
|
|
56
50
|
componentId: "sc-1xw3den-1"
|
|
57
|
-
})(["color:inherit;
|
|
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
|
+
};
|
|
58
56
|
const insertShapeStyles = (props) => {
|
|
59
57
|
switch (props.shape) {
|
|
60
58
|
case TagShape.SMALL_SQUARE:
|
|
@@ -64,9 +62,9 @@ const insertShapeStyles = (props) => {
|
|
|
64
62
|
case TagShape.MEDIUM_ROUND:
|
|
65
63
|
return css(["color:", ";", ""], getColorText(props.color, props.textColor, props.theme), defaultStatusStyles);
|
|
66
64
|
case TagShape.DEFAULT_ROUND:
|
|
67
|
-
return
|
|
65
|
+
return defaultShapeStyles(props, "12px");
|
|
68
66
|
case TagShape.DEFAULT_SQUARE:
|
|
69
|
-
return
|
|
67
|
+
return defaultShapeStyles(props, "3px");
|
|
70
68
|
case TagShape.SINGLE_CHARACTER_ROUND:
|
|
71
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));
|
|
72
70
|
case TagShape.SINGLE_CHARACTER_SQUARE:
|
|
@@ -88,7 +86,7 @@ const Content = /* @__PURE__ */ styled.div.withConfig({
|
|
|
88
86
|
}).withConfig({
|
|
89
87
|
displayName: "Tagstyles__Content",
|
|
90
88
|
componentId: "sc-1xw3den-2"
|
|
91
|
-
})(["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 && `
|
|
92
90
|
&&& {
|
|
93
91
|
color: var(--ds-color-text-danger-default);
|
|
94
92
|
}
|
|
@@ -98,7 +96,7 @@ const PrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
98
96
|
}).withConfig({
|
|
99
97
|
displayName: "Tagstyles__PrefixWrapper",
|
|
100
98
|
componentId: "sc-1xw3den-3"
|
|
101
|
-
})(["", ";", ""], addonStyles(), (props) => !!props.iconHover && `.ds-badge-scroll-number{
|
|
99
|
+
})(["", ";margin-right:", "px;", ""], addonStyles(), BADGE_GAP, (props) => !!props.iconHover && `.ds-badge-scroll-number{
|
|
102
100
|
color: var(--ds-color-text-danger-default)!important;
|
|
103
101
|
box-shadow: 0 0 0 1px var(--ds-color-border-danger-default)!important;
|
|
104
102
|
}
|
|
@@ -108,17 +106,17 @@ const PrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
108
106
|
const SuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
109
107
|
displayName: "Tagstyles__SuffixWrapper",
|
|
110
108
|
componentId: "sc-1xw3den-4"
|
|
111
|
-
})(["", ";"], addonStyles());
|
|
109
|
+
})(["", ";margin-left:", "px;"], addonStyles(), BADGE_GAP);
|
|
112
110
|
const DefaultSuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
113
111
|
displayName: "Tagstyles__DefaultSuffixWrapper",
|
|
114
112
|
componentId: "sc-1xw3den-5"
|
|
115
|
-
})([""]);
|
|
113
|
+
})(["display:flex;align-items:center;> .ds-badge{margin-left:", "px;}"], BADGE_GAP);
|
|
116
114
|
const DefaultPrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
117
115
|
shouldForwardProp: (prop) => !dsProps.has(prop)
|
|
118
116
|
}).withConfig({
|
|
119
117
|
displayName: "Tagstyles__DefaultPrefixWrapper",
|
|
120
118
|
componentId: "sc-1xw3den-6"
|
|
121
|
-
})(["", ""], (props) => !!props.iconHover && `.ds-badge-scroll-number{
|
|
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{
|
|
122
120
|
color: var(--ds-color-text-danger-default)!important;
|
|
123
121
|
box-shadow: 0 0 0 1px var(--ds-color-border-danger-default)!important;
|
|
124
122
|
}
|
|
@@ -130,11 +128,11 @@ const Tag = /* @__PURE__ */ styled.div.withConfig({
|
|
|
130
128
|
}).withConfig({
|
|
131
129
|
displayName: "Tagstyles__Tag",
|
|
132
130
|
componentId: "sc-1xw3den-7"
|
|
133
|
-
})(["position:relative;margin:4px;display:inline-flex;font-weight:500;overflow:hidden;cursor:default;", " ", ";", " ", " ", "
|
|
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 && `
|
|
134
132
|
&&&:before{
|
|
135
133
|
background-color: var(--ds-color-background-danger-subtle);
|
|
136
134
|
}
|
|
137
|
-
`, (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))
|
|
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)));
|
|
138
136
|
const DeleteButton = /* @__PURE__ */ styled.div.withConfig({
|
|
139
137
|
displayName: "Tagstyles__DeleteButton",
|
|
140
138
|
componentId: "sc-1xw3den-8"
|
|
@@ -144,7 +142,9 @@ export {
|
|
|
144
142
|
DefaultPrefixWrapper,
|
|
145
143
|
DefaultSuffixWrapper,
|
|
146
144
|
DeleteButton,
|
|
145
|
+
HUG_PADDING,
|
|
147
146
|
PrefixWrapper,
|
|
147
|
+
REMOVE_BUTTON_SIZE,
|
|
148
148
|
RemoveButton,
|
|
149
149
|
SuffixWrapper,
|
|
150
150
|
Tag,
|
package/dist/Tag.types.d.ts
CHANGED
|
@@ -11,19 +11,27 @@ export type TagTexts = {
|
|
|
11
11
|
deleteTooltip?: ReactNode;
|
|
12
12
|
noResultsLabel?: ReactNode;
|
|
13
13
|
};
|
|
14
|
-
|
|
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;
|
|
@@ -48,3 +56,4 @@ export declare enum TagShape {
|
|
|
48
56
|
STATUS_ERROR = "status_inactive",
|
|
49
57
|
STATUS_WARNING = "status_paused"
|
|
50
58
|
}
|
|
59
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-tag",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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.3.
|
|
46
|
-
"@synerise/ds-tooltip": "^2.1.
|
|
47
|
-
"@synerise/ds-utils": "^2.3.
|
|
45
|
+
"@synerise/ds-icon": "^2.3.2",
|
|
46
|
+
"@synerise/ds-tooltip": "^2.1.2",
|
|
47
|
+
"@synerise/ds-utils": "^2.3.2",
|
|
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": "
|
|
58
|
+
"gitHead": "084f3c021487cdf978892b475e5c657faf5e9a2f"
|
|
59
59
|
}
|