@payfit/unity-components 2.44.1 → 2.46.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.
@@ -1,39 +1,96 @@
1
1
  import { VariantProps } from '@payfit/unity-themes';
2
- import { AriaRole, PropsWithChildren } from 'react';
2
+ import { AriaRole, PropsWithChildren, ReactNode } from 'react';
3
3
  declare const badge: import('tailwind-variants').TVReturnType<{
4
4
  variant: {
5
- success: string;
6
- warning: string;
7
- danger: string;
8
- neutral: string;
9
- promo: string[];
10
- attention: string;
11
- numeric: string;
12
- contextual: string;
5
+ success: {
6
+ root: string;
7
+ };
8
+ warning: {
9
+ root: string;
10
+ };
11
+ danger: {
12
+ root: string;
13
+ };
14
+ neutral: {
15
+ root: string;
16
+ };
17
+ promo: {
18
+ root: string[];
19
+ };
20
+ attention: {
21
+ root: string;
22
+ };
23
+ numeric: {
24
+ root: string;
25
+ };
26
+ contextual: {
27
+ root: string;
28
+ };
13
29
  };
14
- }, undefined, "uy:inline-block uy:rounded-75 uy:px-75 uy:py-25 uy:font-sans uy:typography-body uy:whitespace-nowrap uy:text-center", {
30
+ }, {
31
+ root: string[];
32
+ prefix: string;
33
+ }, undefined, {
15
34
  variant: {
16
- success: string;
17
- warning: string;
18
- danger: string;
19
- neutral: string;
20
- promo: string[];
21
- attention: string;
22
- numeric: string;
23
- contextual: string;
35
+ success: {
36
+ root: string;
37
+ };
38
+ warning: {
39
+ root: string;
40
+ };
41
+ danger: {
42
+ root: string;
43
+ };
44
+ neutral: {
45
+ root: string;
46
+ };
47
+ promo: {
48
+ root: string[];
49
+ };
50
+ attention: {
51
+ root: string;
52
+ };
53
+ numeric: {
54
+ root: string;
55
+ };
56
+ contextual: {
57
+ root: string;
58
+ };
24
59
  };
25
- }, undefined, import('tailwind-variants').TVReturnType<{
60
+ }, {
61
+ root: string[];
62
+ prefix: string;
63
+ }, import('tailwind-variants').TVReturnType<{
26
64
  variant: {
27
- success: string;
28
- warning: string;
29
- danger: string;
30
- neutral: string;
31
- promo: string[];
32
- attention: string;
33
- numeric: string;
34
- contextual: string;
65
+ success: {
66
+ root: string;
67
+ };
68
+ warning: {
69
+ root: string;
70
+ };
71
+ danger: {
72
+ root: string;
73
+ };
74
+ neutral: {
75
+ root: string;
76
+ };
77
+ promo: {
78
+ root: string[];
79
+ };
80
+ attention: {
81
+ root: string;
82
+ };
83
+ numeric: {
84
+ root: string;
85
+ };
86
+ contextual: {
87
+ root: string;
88
+ };
35
89
  };
36
- }, undefined, "uy:inline-block uy:rounded-75 uy:px-75 uy:py-25 uy:font-sans uy:typography-body uy:whitespace-nowrap uy:text-center", unknown, unknown, undefined>>;
90
+ }, {
91
+ root: string[];
92
+ prefix: string;
93
+ }, undefined, unknown, unknown, undefined>>;
37
94
  export type BadgeProps = PropsWithChildren<{
38
95
  /**
39
96
  * To add classes to the badge
@@ -53,6 +110,10 @@ export type BadgeProps = PropsWithChildren<{
53
110
  * @default false
54
111
  */
55
112
  asChild?: boolean;
113
+ /**
114
+ * Optional leading visual rendered before the badge content.
115
+ */
116
+ prefix?: ReactNode;
56
117
  /**
57
118
  * Accessible label for the badge
58
119
  */
@@ -80,11 +141,15 @@ declare const Badge: import('react').ForwardRefExoticComponent<{
80
141
  * @default false
81
142
  */
82
143
  asChild?: boolean;
144
+ /**
145
+ * Optional leading visual rendered before the badge content.
146
+ */
147
+ prefix?: ReactNode;
83
148
  /**
84
149
  * Accessible label for the badge
85
150
  */
86
151
  'aria-label'?: string;
87
152
  } & {
88
- children?: import('react').ReactNode | undefined;
153
+ children?: ReactNode | undefined;
89
154
  } & import('react').RefAttributes<HTMLSpanElement>>;
90
155
  export { Badge };
@@ -1,28 +1,52 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as l } from "react";
3
- import { uyTv as y } from "@payfit/unity-themes";
4
- import { Slot as i } from "@radix-ui/react-slot";
5
- const g = y({
6
- base: "uy:inline-block uy:rounded-75 uy:px-75 uy:py-25 uy:font-sans uy:typography-body uy:whitespace-nowrap uy:text-center",
1
+ import { jsxs as g, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as p, cloneElement as f, isValidElement as m } from "react";
3
+ import { uyTv as h } from "@payfit/unity-themes";
4
+ import { Slot as x, Slottable as b } from "@radix-ui/react-slot";
5
+ import { Icon as w } from "../icon/Icon.js";
6
+ const v = h({
7
+ slots: {
8
+ root: [
9
+ 'uy:inline-flex uy:items-center uy:gap-50 uy:has-data-[unity-component="BadgeDot"]:gap-0',
10
+ 'uy:rounded-75 uy:px-75 uy:py-25 uy:has-data-[unity-component="BadgeDot"]:pl-25',
11
+ "uy:font-sans uy:typography-body uy:whitespace-nowrap uy:text-center"
12
+ ],
13
+ prefix: "uy:inline-flex uy:size-250 uy:shrink-0 uy:items-center uy:justify-center uy:text-inherit"
14
+ },
7
15
  variants: {
8
16
  variant: {
9
- success: "uy:bg-surface-success-low uy:text-content-success-high",
10
- warning: "uy:bg-surface-warning-low uy:text-content-warning-high",
11
- danger: "uy:bg-surface-danger-low uy:text-content-danger-high",
12
- neutral: "uy:bg-surface-neutral-lowest uy:text-content-neutral",
13
- promo: [
14
- "uy:theme-legacy:bg-surface-promo-low uy:theme-legacy:text-content-promo-high",
15
- "uy:theme-rebrand:bg-surface-decorative-purple-low uy:theme-rebrand:text-content-decorative-purple-high"
16
- ],
17
- attention: "uy:bg-surface-danger uy:text-content-inverted",
18
- numeric: "uy:bg-surface-info-low uy:text-content-info-high",
19
- contextual: "uy:bg-surface-neutral uy:border uy:border-solid uy:border-border-neutral uy:text-content-neutral"
17
+ success: {
18
+ root: "uy:bg-surface-success-low uy:text-content-success-high"
19
+ },
20
+ warning: {
21
+ root: "uy:bg-surface-warning-low uy:text-content-warning-high"
22
+ },
23
+ danger: {
24
+ root: "uy:bg-surface-danger-low uy:text-content-danger-high"
25
+ },
26
+ neutral: {
27
+ root: "uy:bg-surface-neutral-lowest uy:text-content-neutral"
28
+ },
29
+ promo: {
30
+ root: [
31
+ "uy:theme-legacy:bg-surface-promo-low uy:theme-legacy:text-content-promo-high",
32
+ "uy:theme-rebrand:bg-surface-decorative-purple-low uy:theme-rebrand:text-content-decorative-purple-high"
33
+ ]
34
+ },
35
+ attention: {
36
+ root: "uy:bg-surface-danger uy:text-content-inverted"
37
+ },
38
+ numeric: {
39
+ root: "uy:bg-surface-info-low uy:text-content-info-high"
40
+ },
41
+ contextual: {
42
+ root: "uy:bg-surface-neutral uy:border uy:border-solid uy:border-border-neutral uy:text-content-neutral"
43
+ }
20
44
  }
21
45
  },
22
46
  defaultVariants: {
23
47
  variant: "neutral"
24
48
  }
25
- }), d = {
49
+ }), B = {
26
50
  success: "status",
27
51
  warning: "alert",
28
52
  danger: "alert",
@@ -31,30 +55,41 @@ const g = y({
31
55
  attention: "alert",
32
56
  contextual: "status",
33
57
  numeric: "status"
34
- }, p = l(
58
+ };
59
+ function j(t) {
60
+ return m(t) && t.type === w;
61
+ }
62
+ function D(t, e) {
63
+ return !j(t) || e === "contextual" ? t : f(t, { color: "inherit" });
64
+ }
65
+ const E = p(
35
66
  ({
36
67
  className: t,
37
68
  variant: e = "neutral",
38
- role: r,
39
- asChild: a = !1,
40
- children: n,
41
- ...u
42
- }, o) => {
43
- const s = r ?? d[e] ?? "status";
44
- return /* @__PURE__ */ c(
45
- a ? i : "span",
69
+ role: a,
70
+ asChild: u = !1,
71
+ prefix: s,
72
+ children: c,
73
+ ...i
74
+ }, l) => {
75
+ const y = a ?? B[e] ?? "status", d = u ? x : "span", r = D(s, e), n = v({ variant: e });
76
+ return /* @__PURE__ */ g(
77
+ d,
46
78
  {
47
79
  "data-dd-privacy": "allow",
48
- ref: o,
49
- className: g({ variant: e, className: t }),
50
- role: s,
51
- ...u,
52
- children: n
80
+ ref: l,
81
+ className: n.root({ className: t }),
82
+ role: y,
83
+ ...i,
84
+ children: [
85
+ r ? /* @__PURE__ */ o("span", { className: n.prefix(), "data-unity-slot": "badge-prefix", children: r }) : null,
86
+ /* @__PURE__ */ o(b, { children: c })
87
+ ]
53
88
  }
54
89
  );
55
90
  }
56
91
  );
57
- p.displayName = "Badge";
92
+ E.displayName = "Badge";
58
93
  export {
59
- p as Badge
94
+ E as Badge
60
95
  };
@@ -0,0 +1,202 @@
1
+ import { VariantProps } from '@payfit/unity-themes';
2
+ import { HTMLAttributes } from 'react';
3
+ declare const badgeDot: import('tailwind-variants').TVReturnType<{
4
+ color: {
5
+ primary: {
6
+ dot: string;
7
+ };
8
+ 'primary.low': {
9
+ dot: string;
10
+ };
11
+ 'neutral.lowest': {
12
+ dot: string;
13
+ };
14
+ 'neutral.highest': {
15
+ dot: string;
16
+ };
17
+ danger: {
18
+ dot: string;
19
+ };
20
+ 'danger.low': {
21
+ dot: string;
22
+ };
23
+ warning: {
24
+ dot: string;
25
+ };
26
+ 'warning.low': {
27
+ dot: string;
28
+ };
29
+ success: {
30
+ dot: string;
31
+ };
32
+ 'success.low': {
33
+ dot: string;
34
+ };
35
+ info: {
36
+ dot: string;
37
+ };
38
+ 'info.low': {
39
+ dot: string;
40
+ };
41
+ 'decorative-teal': {
42
+ dot: string;
43
+ };
44
+ 'decorative-purple': {
45
+ dot: string;
46
+ };
47
+ 'decorative-plum': {
48
+ dot: string;
49
+ };
50
+ 'decorative-orange': {
51
+ dot: string;
52
+ };
53
+ };
54
+ }, {
55
+ root: string;
56
+ dot: string;
57
+ }, undefined, {
58
+ color: {
59
+ primary: {
60
+ dot: string;
61
+ };
62
+ 'primary.low': {
63
+ dot: string;
64
+ };
65
+ 'neutral.lowest': {
66
+ dot: string;
67
+ };
68
+ 'neutral.highest': {
69
+ dot: string;
70
+ };
71
+ danger: {
72
+ dot: string;
73
+ };
74
+ 'danger.low': {
75
+ dot: string;
76
+ };
77
+ warning: {
78
+ dot: string;
79
+ };
80
+ 'warning.low': {
81
+ dot: string;
82
+ };
83
+ success: {
84
+ dot: string;
85
+ };
86
+ 'success.low': {
87
+ dot: string;
88
+ };
89
+ info: {
90
+ dot: string;
91
+ };
92
+ 'info.low': {
93
+ dot: string;
94
+ };
95
+ 'decorative-teal': {
96
+ dot: string;
97
+ };
98
+ 'decorative-purple': {
99
+ dot: string;
100
+ };
101
+ 'decorative-plum': {
102
+ dot: string;
103
+ };
104
+ 'decorative-orange': {
105
+ dot: string;
106
+ };
107
+ };
108
+ }, {
109
+ root: string;
110
+ dot: string;
111
+ }, import('tailwind-variants').TVReturnType<{
112
+ color: {
113
+ primary: {
114
+ dot: string;
115
+ };
116
+ 'primary.low': {
117
+ dot: string;
118
+ };
119
+ 'neutral.lowest': {
120
+ dot: string;
121
+ };
122
+ 'neutral.highest': {
123
+ dot: string;
124
+ };
125
+ danger: {
126
+ dot: string;
127
+ };
128
+ 'danger.low': {
129
+ dot: string;
130
+ };
131
+ warning: {
132
+ dot: string;
133
+ };
134
+ 'warning.low': {
135
+ dot: string;
136
+ };
137
+ success: {
138
+ dot: string;
139
+ };
140
+ 'success.low': {
141
+ dot: string;
142
+ };
143
+ info: {
144
+ dot: string;
145
+ };
146
+ 'info.low': {
147
+ dot: string;
148
+ };
149
+ 'decorative-teal': {
150
+ dot: string;
151
+ };
152
+ 'decorative-purple': {
153
+ dot: string;
154
+ };
155
+ 'decorative-plum': {
156
+ dot: string;
157
+ };
158
+ 'decorative-orange': {
159
+ dot: string;
160
+ };
161
+ };
162
+ }, {
163
+ root: string;
164
+ dot: string;
165
+ }, undefined, unknown, unknown, undefined>>;
166
+ export interface BadgeDotProps extends HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeDot> {
167
+ /**
168
+ * Token-backed surface color used for the visible dot marker.
169
+ *
170
+ * Use decorative colors for the Badge Cluster pattern. Semantic surface colors are available when the dot needs to align with a product-specific status or category.
171
+ * @default 'decorative-teal'
172
+ */
173
+ color?: VariantProps<typeof badgeDot>['color'];
174
+ }
175
+ /**
176
+ * The BadgeDot component renders a small decorative marker for the Badge prefix slot.
177
+ *
178
+ * BadgeDot is primarily used to build the Badge Cluster pattern, where a contextual Badge displays a leading colored dot before its label. It reserves the prefix-slot footprint and renders a centered circular marker, so consumers do not need to recreate Badge-specific spacing or geometry.
179
+ * @param {BadgeDotProps} props - The props for the BadgeDot component, including the token-backed `color` and optional root `className`.
180
+ * @example
181
+ * ```tsx
182
+ * import { Badge, BadgeDot } from '@payfit/unity-components'
183
+ *
184
+ * function Example() {
185
+ * return (
186
+ * <Badge variant="contextual" prefix={<BadgeDot color="decorative-teal" />}>
187
+ * Cluster
188
+ * </Badge>
189
+ * )
190
+ * }
191
+ * ```
192
+ * @remarks
193
+ * - Use BadgeDot inside `Badge`'s `prefix` prop for the supported Cluster composition.
194
+ * - BadgeDot is decorative and is hidden from assistive technologies with `aria-hidden="true"`.
195
+ * - Prefer decorative colors for Cluster markers unless a semantic status color is explicitly needed.
196
+ * @see {@link BadgeDotProps} for all available props
197
+ * @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/components/badge/parts/BadgeDot.tsx GitHub}
198
+ * @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=20376-46274&m=dev Figma}
199
+ * @see Design docs in {@link https://www.payfit.design/24f360409/p/20d6f1-badge Payfit.design}
200
+ */
201
+ declare const BadgeDot: import('react').ForwardRefExoticComponent<BadgeDotProps & import('react').RefAttributes<HTMLSpanElement>>;
202
+ export { BadgeDot };
@@ -0,0 +1,84 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as d } from "react";
3
+ import { uyTv as c } from "@payfit/unity-themes";
4
+ const n = c({
5
+ slots: {
6
+ root: "uy:inline-flex uy:shrink-0 uy:items-center uy:justify-center",
7
+ dot: "uy:size-125 uy:rounded-full"
8
+ },
9
+ variants: {
10
+ color: {
11
+ primary: {
12
+ dot: "uy:bg-surface-primary"
13
+ },
14
+ "primary.low": {
15
+ dot: "uy:bg-surface-primary-low"
16
+ },
17
+ "neutral.lowest": {
18
+ dot: "uy:bg-surface-neutral-low"
19
+ },
20
+ "neutral.highest": {
21
+ dot: "uy:bg-surface-neutral-highest"
22
+ },
23
+ danger: {
24
+ dot: "uy:bg-surface-danger"
25
+ },
26
+ "danger.low": {
27
+ dot: "uy:bg-surface-danger-low"
28
+ },
29
+ warning: {
30
+ dot: "uy:bg-surface-warning"
31
+ },
32
+ "warning.low": {
33
+ dot: "uy:bg-surface-warning-low"
34
+ },
35
+ success: {
36
+ dot: "uy:bg-surface-success"
37
+ },
38
+ "success.low": {
39
+ dot: "uy:bg-surface-success-low"
40
+ },
41
+ info: {
42
+ dot: "uy:bg-surface-info"
43
+ },
44
+ "info.low": {
45
+ dot: "uy:bg-surface-info-low"
46
+ },
47
+ "decorative-teal": {
48
+ dot: "uy:bg-surface-decorative-teal"
49
+ },
50
+ "decorative-purple": {
51
+ dot: "uy:bg-surface-decorative-purple"
52
+ },
53
+ "decorative-plum": {
54
+ dot: "uy:bg-surface-decorative-plum"
55
+ },
56
+ "decorative-orange": {
57
+ dot: "uy:bg-surface-decorative-orange"
58
+ }
59
+ }
60
+ },
61
+ defaultVariants: {
62
+ color: "decorative-teal"
63
+ }
64
+ }), i = d(
65
+ ({ color: r, className: o, ...a }, t) => {
66
+ const { root: u, dot: s } = n({ color: r });
67
+ return /* @__PURE__ */ e(
68
+ "span",
69
+ {
70
+ ...a,
71
+ "aria-hidden": "true",
72
+ className: u({ className: o }),
73
+ "data-dd-privacy": "allow",
74
+ "data-unity-component": "BadgeDot",
75
+ ref: t,
76
+ children: /* @__PURE__ */ e("span", { className: s() })
77
+ }
78
+ );
79
+ }
80
+ );
81
+ i.displayName = "BadgeDot";
82
+ export {
83
+ i as BadgeDot
84
+ };
@@ -24,6 +24,7 @@ export * from './components/avatar/parts/AvatarImage.js';
24
24
  export * from './components/avatar/parts/AvatarPair.js';
25
25
  export * from './components/avatar/utils.js';
26
26
  export * from './components/badge/Badge.js';
27
+ export * from './components/badge/parts/BadgeDot.js';
27
28
  export * from './components/bottom-sheet/BottomSheet.js';
28
29
  export * from './components/bottom-sheet/parts/BottomSheetContent.js';
29
30
  export * from './components/bottom-sheet/parts/BottomSheetFooter.js';