@payfit/unity-components 2.34.0 → 2.35.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.
@@ -1,177 +1,145 @@
1
- import { jsxs as o, jsx as e, Fragment as p } from "react/jsx-runtime";
2
- import { forwardRef as O, useEffect as F } from "react";
3
- import { uyTv as G } from "@payfit/unity-themes";
4
- import { Button as P } from "react-aria-components/Button";
5
- import { Link as z } from "react-aria-components/Link";
6
- import { useIntl as A, FormattedMessage as g } from "react-intl";
7
- import { useRouter as B } from "../../../providers/router/RouterProvider.js";
8
- import { Icon as y } from "../../icon/Icon.js";
9
- import { Text as f } from "../../text/Text.js";
10
- import { useTaskMenuContext as V } from "../TaskMenu.context.js";
11
- import { commonTask as D } from "./task.variants.js";
12
- const H = G({
13
- extend: D,
1
+ import { jsxs as n, jsx as e, Fragment as p } from "react/jsx-runtime";
2
+ import { forwardRef as G, useEffect as O } from "react";
3
+ import { uyTv as P } from "@payfit/unity-themes";
4
+ import { Button as z } from "react-aria-components/Button";
5
+ import { Link as A } from "react-aria-components/Link";
6
+ import { useIntl as B, FormattedMessage as k } from "react-intl";
7
+ import { useRouter as S } from "../../../providers/router/RouterProvider.js";
8
+ import { Icon as g } from "../../icon/Icon.js";
9
+ import { Text as y } from "../../text/Text.js";
10
+ import { useTaskMenuContext as D } from "../TaskMenu.context.js";
11
+ import { commonTask as H } from "./task.variants.js";
12
+ const I = P({
13
+ extend: H,
14
14
  slots: {
15
15
  base: [],
16
- element: ["uy:p-200", "uy:md:p-0", "uy:cursor-pointer"],
16
+ element: [
17
+ "uy:p-200",
18
+ "uy:md:p-0",
19
+ "uy:cursor-pointer",
20
+ "uy:group-data-[task-status=uncompleted]/base:group-data-[current=true]/base:bg-surface-neutral-selected",
21
+ "uy:md:group-data-[task-status=uncompleted]/base:group-data-[current=true]/base:bg-[transparent]"
22
+ ],
17
23
  text: "uy:leading-[1]",
18
24
  lock: "uy:self-center",
19
25
  number: ""
20
- },
21
- variants: {
22
- isSelected: {
23
- false: "",
24
- true: ""
25
- }
26
- },
27
- compoundVariants: [
28
- {
29
- isSelected: !0,
30
- taskStatus: "uncompleted",
31
- className: {
32
- element: ["uy:bg-surface-neutral-selected", "uy:md:bg-[transparent]"],
33
- text: ["uy:md:bg-surface-neutral-selected uy:md:bg-[transparent]"]
34
- }
35
- },
36
- {
37
- isSelected: !1,
38
- taskStatus: "uncompleted",
39
- className: {
40
- number: [
41
- "uy:group-data-[pressed=true]/element:bg-surface-neutral-lowest-pressed",
42
- 'uy:group-data-[hovered="true"]/element:bg-surface-neutral-lowest-hover uy:group-data-[hovered="true"]/element:text-content-neutral-hover'
43
- ],
44
- text: [
45
- 'uy:group-data-[hovered="true"]/element:text-content-neutral-hover'
46
- ]
47
- }
48
- },
49
- {
50
- isSelected: !1,
51
- taskStatus: "locked",
52
- className: {
53
- number: [
54
- 'uy:group-data-[hovered="true"]/element:text-content-neutral-hover',
55
- "uy:group-data-[pressed]/element:bg-surface-neutral-lowest-pressed"
56
- ],
57
- text: [
58
- 'uy:group-data-[hovered="true"]/element:text-content-neutral-hover'
59
- ]
60
- }
61
- }
62
- ]
63
- }), I = O(
26
+ }
27
+ }), J = G(
64
28
  ({
65
- href: a,
66
- isExact: u = !1,
29
+ href: t,
30
+ isExact: c = !1,
67
31
  label: s,
68
- onPress: k,
32
+ onPress: f,
69
33
  taskNumber: b,
70
- taskStatus: n = "uncompleted",
71
- children: h,
34
+ taskStatus: o = "uncompleted",
35
+ children: T,
72
36
  uniqueId: r,
73
- ...m
74
- }, v) => {
75
- const c = B(), d = A(), {
76
- currentTask: x,
77
- setCurrentTask: l,
78
- state: N,
37
+ ...l
38
+ }, N) => {
39
+ const d = S(), u = B(), {
40
+ currentTask: h,
41
+ setCurrentTask: m,
42
+ state: x,
79
43
  expandedTaskGroup: i,
80
- toggleTaskGroup: T
81
- } = V(), S = a ? z : P;
82
- F(() => {
83
- a && c?.isActive(a.toString(), u) && l?.({ uniqueId: r, label: s });
84
- }, [a, u, c, s, r, l]);
85
- const t = x?.uniqueId === r, M = Object.assign(
86
- {},
87
- t !== void 0 && {
88
- "data-current": t,
89
- "aria-current": t ? "page" : void 0
44
+ toggleTaskGroup: M
45
+ } = D(), v = t ? A : z;
46
+ O(() => {
47
+ t && d?.isActive(t.toString(), c) && m?.({ uniqueId: r, label: s });
48
+ }, [t, c, d, s, r, m]);
49
+ const a = h?.uniqueId === r, C = {
50
+ "data-current": a,
51
+ "aria-current": a ? "page" : void 0
52
+ }, { base: w, number: L, element: R, text: E, lock: j } = I({ taskStatus: o });
53
+ return /* @__PURE__ */ n(
54
+ "li",
55
+ {
56
+ ref: N,
57
+ "data-task-status": o,
58
+ className: w(),
59
+ ...a ? { "data-current": !0 } : {},
60
+ ...l,
61
+ children: [
62
+ /* @__PURE__ */ n(
63
+ v,
64
+ {
65
+ className: R(),
66
+ href: t,
67
+ onPress: (F) => {
68
+ m?.({ uniqueId: r, label: s }), x?.toggle(), i && M?.(i), f?.(F);
69
+ },
70
+ ...C,
71
+ ...l,
72
+ children: [
73
+ /* @__PURE__ */ e("div", { className: L(), children: o === "completed" ? /* @__PURE__ */ n(p, { children: [
74
+ /* @__PURE__ */ e(
75
+ g,
76
+ {
77
+ size: 24,
78
+ "aria-hidden": "true",
79
+ src: "CheckOutlined",
80
+ alt: u.formatMessage({
81
+ id: "unity:component:task-menu:task:completed:label",
82
+ defaultMessage: "Completed"
83
+ })
84
+ }
85
+ ),
86
+ /* @__PURE__ */ e("span", { className: "uy:sr-only", children: /* @__PURE__ */ e(
87
+ k,
88
+ {
89
+ id: "unity:component:task-menu:task:completed:label",
90
+ defaultMessage: "Completed"
91
+ }
92
+ ) })
93
+ ] }) : /* @__PURE__ */ e(
94
+ y,
95
+ {
96
+ asElement: "span",
97
+ variant: a ? "bodyStrong" : "body",
98
+ className: "uy:leading-[1]",
99
+ children: b
100
+ }
101
+ ) }),
102
+ /* @__PURE__ */ e(
103
+ y,
104
+ {
105
+ asElement: "span",
106
+ className: E(),
107
+ variant: a ? "bodyStrong" : "body",
108
+ children: s
109
+ }
110
+ ),
111
+ o === "locked" && /* @__PURE__ */ n(p, { children: [
112
+ /* @__PURE__ */ e(
113
+ g,
114
+ {
115
+ "aria-hidden": "true",
116
+ className: j(),
117
+ src: "LockOutlined",
118
+ alt: u.formatMessage({
119
+ id: "unity:component:task-menu:task:lock:label",
120
+ defaultMessage: "Locked"
121
+ })
122
+ }
123
+ ),
124
+ /* @__PURE__ */ e("span", { className: "uy:sr-only", children: /* @__PURE__ */ e(
125
+ k,
126
+ {
127
+ id: "unity:component:task-menu:task:lock:label",
128
+ defaultMessage: "Locked"
129
+ }
130
+ ) })
131
+ ] })
132
+ ]
133
+ }
134
+ ),
135
+ T
136
+ ]
90
137
  }
91
- ), { base: w, number: C, element: L, text: R, lock: j } = H({
92
- isSelected: t,
93
- taskStatus: n
94
- });
95
- return /* @__PURE__ */ o("li", { ref: v, className: w(), ...m, children: [
96
- /* @__PURE__ */ o(
97
- S,
98
- {
99
- className: L(),
100
- href: a,
101
- onPress: (E) => {
102
- l?.({ uniqueId: r, label: s }), N?.toggle(), i && T?.(i), k?.(E);
103
- },
104
- ...M,
105
- ...m,
106
- children: [
107
- /* @__PURE__ */ e("div", { className: C(), children: n === "completed" ? /* @__PURE__ */ o(p, { children: [
108
- /* @__PURE__ */ e(
109
- y,
110
- {
111
- size: 24,
112
- "aria-hidden": "true",
113
- src: "CheckOutlined",
114
- alt: d.formatMessage({
115
- id: "unity:component:task-menu:task:completed:label",
116
- defaultMessage: "Completed"
117
- })
118
- }
119
- ),
120
- /* @__PURE__ */ e("span", { className: "uy:sr-only", children: /* @__PURE__ */ e(
121
- g,
122
- {
123
- id: "unity:component:task-menu:task:completed:label",
124
- defaultMessage: "Completed"
125
- }
126
- ) })
127
- ] }) : /* @__PURE__ */ e(
128
- f,
129
- {
130
- asElement: "span",
131
- variant: t ? "bodyStrong" : "body",
132
- className: "uy:leading-[1]",
133
- children: b
134
- }
135
- ) }),
136
- /* @__PURE__ */ e(
137
- f,
138
- {
139
- asElement: "span",
140
- className: R(),
141
- variant: t ? "bodyStrong" : "body",
142
- children: s
143
- }
144
- ),
145
- n === "locked" && /* @__PURE__ */ o(p, { children: [
146
- /* @__PURE__ */ e(
147
- y,
148
- {
149
- "aria-hidden": "true",
150
- className: j(),
151
- src: "LockOutlined",
152
- alt: d.formatMessage({
153
- id: "unity:component:task-menu:task:lock:label",
154
- defaultMessage: "Locked"
155
- })
156
- }
157
- ),
158
- /* @__PURE__ */ e("span", { className: "uy:sr-only", children: /* @__PURE__ */ e(
159
- g,
160
- {
161
- id: "unity:component:task-menu:task:lock:label",
162
- defaultMessage: "Locked"
163
- }
164
- ) })
165
- ] })
166
- ]
167
- }
168
- ),
169
- h
170
- ] });
138
+ );
171
139
  }
172
140
  );
173
- I.displayName = "RawTask";
141
+ J.displayName = "RawTask";
174
142
  export {
175
- I as RawTask,
176
- H as rawTask
143
+ J as RawTask,
144
+ I as rawTask
177
145
  };
@@ -1,15 +1,15 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as j, Children as i, isValidElement as o, cloneElement as A } from "react";
3
- import { uyTv as V } from "@payfit/unity-themes";
4
- import { Button as $ } from "react-aria-components/Button";
5
- import { useId as B } from "react-aria/useId";
6
- import { useIntl as D } from "react-intl";
7
- import { Icon as F } from "../../icon/Icon.js";
8
- import { Text as f } from "../../text/Text.js";
9
- import { useTaskMenuContext as H } from "../TaskMenu.context.js";
10
- import { commonTask as O } from "./task.variants.js";
11
- const P = V({
12
- extend: O,
1
+ import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as A, Children as l, isValidElement as u, cloneElement as $ } from "react";
3
+ import { uyTv as B } from "@payfit/unity-themes";
4
+ import { Button as D } from "react-aria-components/Button";
5
+ import { useId as F } from "react-aria/useId";
6
+ import { useIntl as H } from "react-intl";
7
+ import { Icon as O } from "../../icon/Icon.js";
8
+ import { Text as g } from "../../text/Text.js";
9
+ import { useTaskMenuContext as P } from "../TaskMenu.context.js";
10
+ import { commonTask as R } from "./task.variants.js";
11
+ const U = B({
12
+ extend: R,
13
13
  slots: {
14
14
  base: ["uy:relative uy:flex-col uy:px-200", "uy:md:px-0"],
15
15
  element: ["uy:z-[1] uy:py-200", "uy:md:py-0", "uy:cursor-pointer"],
@@ -18,155 +18,116 @@ const P = V({
18
18
  "uy:md:my-75"
19
19
  ],
20
20
  containerSubTasks: [
21
- "uy:list-none uy:ml-100 uy:flex uy:flex-col uy:gap-100 uy:z-[1] uy:relative uy:transition-opacity uy:duration-150 uy:delay-25 uy:ease-linear uy:mt-100"
21
+ "uy:list-none uy:ml-100 uy:flex uy:flex-col uy:gap-100 uy:z-[1] uy:relative uy:transition-opacity uy:duration-150 uy:delay-25 uy:ease-linear uy:mt-100",
22
+ "uy:group-data-[expanded=true]/base:opacity-100 uy:group-data-[expanded=true]/base:visible",
23
+ "uy:group-data-[expanded=false]/base:opacity-0 uy:group-data-[expanded=false]/base:invisible uy:group-data-[expanded=false]/base:pointer-events-none"
22
24
  ],
23
25
  containerSubTasksWrapper: [
24
26
  "uy:transition-[max-height] uy:duration-200 uy:ease-linear motion-reduce:transition-none"
25
27
  ],
26
- number: "uy:bg-surface-neutral-lowest"
27
- },
28
- variants: {
29
- expanded: {
30
- true: {
31
- containerSubTasksWrapper: "uy:max-h-[1000px] uy:overflow-visible",
32
- containerSubTasks: "uy:opacity-100 uy:visible"
33
- },
34
- false: {
35
- containerSubTasksWrapper: "uy:max-h-0 uy:overflow-hidden",
36
- containerSubTasks: "uy:opacity-0 uy:invisible uy:pointer-events-none"
37
- }
38
- },
39
- hasSelectedSubTask: {
40
- true: "",
41
- false: ""
42
- }
43
- },
44
- compoundVariants: [
45
- {
46
- hasSelectedSubTask: !0,
47
- taskStatus: "uncompleted",
48
- className: {
49
- number: ["uy:bg-surface-primary-active uy:text-content-inverted"],
50
- text: ["uy:text-content-primary-active"]
51
- }
52
- },
53
- {
54
- hasSelectedSubTask: !1,
55
- taskStatus: "uncompleted",
56
- className: {
57
- number: [
58
- 'uy:group-data-[hovered="true"]/element:bg-surface-neutral-lowest-hover uy:group-data-[hovered="true"]/element:text-content-neutral-hover uy:group-data-[pressed=true]/element:bg-surface-neutral-lowest-pressed'
59
- ],
60
- text: [
61
- 'uy:group-data-[hovered="true"]/element:text-content-neutral-hover'
62
- ]
63
- }
64
- },
65
- {
66
- hasSelectedSubTask: !1,
67
- taskStatus: "locked",
68
- className: {
69
- number: [
70
- 'uy:group-data-[hovered="true"]/element:bg-surface-neutral-hover uy:group-data-[hovered="true"]/element:text-content-neutral-hover uy:group-data-[pressed=true]/element:bg-surface-neutral-pressed'
71
- ],
72
- text: [
73
- 'uy:group-data-[hovered="true"]/element:text-content-neutral-hover'
74
- ]
75
- }
76
- }
77
- ]
78
- }), R = (e, t) => e ? i.toArray(t).some(
79
- (s) => o(s) && s.props.uniqueId === e
80
- ) : !1, U = (e) => e ? i.toArray(e).find(
81
- (t) => o(t) && t.props.taskStatus !== "completed" && t.props.taskStatus !== "locked"
82
- ) : null, J = j(
28
+ number: [
29
+ "uy:bg-surface-neutral-lowest",
30
+ "uy:group-[&[data-task-status=uncompleted][data-active-group=true]]/base:text-content-inverted",
31
+ "uy:theme-legacy:group-[&[data-task-status=uncompleted][data-active-group=true]]/base:bg-surface-primary-active",
32
+ "uy:theme-rebrand:group-[&[data-task-status=uncompleted][data-active-group=true]]/base:bg-surface-neutral-highest-active"
33
+ ],
34
+ text: [
35
+ "uy:theme-legacy:group-[&[data-task-status=uncompleted][data-active-group=true]]/base:text-content-primary-active",
36
+ "uy:theme-rebrand:group-[&[data-task-status=uncompleted][data-active-group=true]]/base:text-content-neutral-active"
37
+ ]
38
+ }
39
+ }), V = (e, t) => e ? l.toArray(t).some(
40
+ (r) => u(r) && r.props.uniqueId === e
41
+ ) : !1, W = (e) => e ? l.toArray(e).find(
42
+ (t) => u(t) && t.props.taskStatus !== "completed" && t.props.taskStatus !== "locked"
43
+ ) : null, J = A(
83
44
  ({
84
45
  children: e,
85
46
  label: t,
86
- taskNumber: s,
87
- taskStatus: d = "uncompleted",
88
- uniqueId: m,
89
- ...g
90
- }, k) => {
91
- const { currentTask: v, setCurrentTask: x, toggleTaskGroup: S, expandedTaskGroup: h } = H(), c = B(), T = D(), a = h === m, N = (u) => {
92
- if (S?.(m), !u) {
93
- const b = U(e);
94
- if (o(b)) {
95
- const { uniqueId: M, label: W } = b.props;
96
- x?.({ uniqueId: M, label: W });
47
+ taskNumber: r,
48
+ taskStatus: n = "uncompleted",
49
+ uniqueId: p,
50
+ ...f
51
+ }, x) => {
52
+ const { currentTask: k, setCurrentTask: v, toggleTaskGroup: T, expandedTaskGroup: h } = P(), c = F(), S = H(), a = h === p, I = (s) => {
53
+ if (T?.(p), !s) {
54
+ const b = W(e);
55
+ if (u(b)) {
56
+ const { uniqueId: M, label: j } = b.props;
57
+ v?.({ uniqueId: M, label: j });
97
58
  }
98
59
  }
99
- }, w = i.map(e, (u) => o(u) ? A(u, { isDisabled: !a }) : u), p = `${c}-toggle`, y = `${c}-content`, n = R(
100
- v?.uniqueId,
60
+ }, N = l.map(e, (s) => u(s) ? $(s, { isDisabled: !a }) : s), m = `${c}-toggle`, y = `${c}-content`, d = V(
61
+ k?.uniqueId,
101
62
  e
102
- ), { base: I, number: C, text: E, bar: G, element: z, containerSubTasks: q } = P({
103
- taskStatus: d,
104
- hasSelectedSubTask: n,
105
- expanded: a
63
+ ), { base: C, number: E, text: G, bar: w, element: z, containerSubTasks: q } = U({
64
+ taskStatus: n
106
65
  });
107
- return /* @__PURE__ */ l(
66
+ return /* @__PURE__ */ i(
108
67
  "li",
109
68
  {
110
- ref: k,
69
+ ref: x,
111
70
  "data-group": "true",
112
- "data-active-group": n,
113
- className: I(),
71
+ "data-task-status": n,
72
+ "data-expanded": a,
73
+ "data-active-group": d,
74
+ className: C(),
114
75
  children: [
115
- /* @__PURE__ */ l(
116
- $,
76
+ /* @__PURE__ */ i(
77
+ D,
117
78
  {
118
- id: p,
79
+ id: m,
119
80
  className: z(),
120
81
  onPress: () => {
121
- N(a);
82
+ I(a);
122
83
  },
123
84
  "aria-expanded": a,
124
85
  "aria-controls": y,
125
- ...g,
86
+ ...f,
126
87
  children: [
127
- /* @__PURE__ */ r("div", { className: C(), children: d === "completed" ? /* @__PURE__ */ r(
128
- F,
88
+ /* @__PURE__ */ o("div", { className: E(), children: n === "completed" ? /* @__PURE__ */ o(
89
+ O,
129
90
  {
130
91
  size: 24,
131
92
  src: "CheckOutlined",
132
- alt: T.formatMessage({
93
+ alt: S.formatMessage({
133
94
  id: "unity:component:task-menu:task:completed:label",
134
95
  defaultMessage: "Completed"
135
96
  })
136
97
  }
137
- ) : /* @__PURE__ */ r(
138
- f,
98
+ ) : /* @__PURE__ */ o(
99
+ g,
139
100
  {
140
101
  asElement: "span",
141
- variant: n ? "bodyStrong" : "body",
102
+ variant: d ? "bodyStrong" : "body",
142
103
  className: "uy:leading-[1]",
143
- children: s
104
+ children: r
144
105
  }
145
106
  ) }),
146
- /* @__PURE__ */ r(
147
- f,
107
+ /* @__PURE__ */ o(
108
+ g,
148
109
  {
149
110
  asElement: "span",
150
- className: E(),
151
- variant: n ? "bodyStrong" : "body",
111
+ className: G(),
112
+ variant: d ? "bodyStrong" : "body",
152
113
  children: t
153
114
  }
154
115
  )
155
116
  ]
156
117
  }
157
118
  ),
158
- /* @__PURE__ */ l("div", { style: { maxHeight: a ? 1e3 : 0 }, children: [
159
- /* @__PURE__ */ r(
119
+ /* @__PURE__ */ i("div", { style: { maxHeight: a ? 1e3 : 0 }, children: [
120
+ /* @__PURE__ */ o(
160
121
  "ol",
161
122
  {
162
123
  id: y,
163
- "aria-labelledby": p,
124
+ "aria-labelledby": m,
164
125
  "aria-hidden": !a,
165
126
  className: q(),
166
- children: w
127
+ children: N
167
128
  }
168
129
  ),
169
- a && /* @__PURE__ */ r("div", { role: "presentation", className: G() })
130
+ a && /* @__PURE__ */ o("div", { role: "presentation", className: w() })
170
131
  ] })
171
132
  ]
172
133
  }
@@ -1,76 +1,37 @@
1
1
  export declare const commonTask: import('tailwind-variants').TVReturnType<{
2
2
  taskStatus: {
3
- uncompleted: {
4
- base: string[];
5
- element: string[];
6
- number: string[];
7
- text: string[];
8
- };
9
- completed: {
10
- base: string[];
11
- number: string[];
12
- text: string[];
13
- };
14
- locked: {
15
- text: string[];
16
- number: string[];
17
- lock: string[];
18
- };
3
+ uncompleted: string;
4
+ completed: string;
5
+ locked: string;
19
6
  };
20
7
  }, {
21
8
  base: string[];
22
9
  number: string[];
23
10
  element: string[];
24
11
  text: string[];
25
- lock: string;
12
+ lock: string[];
26
13
  }, undefined, {
27
14
  taskStatus: {
28
- uncompleted: {
29
- base: string[];
30
- element: string[];
31
- number: string[];
32
- text: string[];
33
- };
34
- completed: {
35
- base: string[];
36
- number: string[];
37
- text: string[];
38
- };
39
- locked: {
40
- text: string[];
41
- number: string[];
42
- lock: string[];
43
- };
15
+ uncompleted: string;
16
+ completed: string;
17
+ locked: string;
44
18
  };
45
19
  }, {
46
20
  base: string[];
47
21
  number: string[];
48
22
  element: string[];
49
23
  text: string[];
50
- lock: string;
24
+ lock: string[];
51
25
  }, import('tailwind-variants').TVReturnType<{
52
26
  taskStatus: {
53
- uncompleted: {
54
- base: string[];
55
- element: string[];
56
- number: string[];
57
- text: string[];
58
- };
59
- completed: {
60
- base: string[];
61
- number: string[];
62
- text: string[];
63
- };
64
- locked: {
65
- text: string[];
66
- number: string[];
67
- lock: string[];
68
- };
27
+ uncompleted: string;
28
+ completed: string;
29
+ locked: string;
69
30
  };
70
31
  }, {
71
32
  base: string[];
72
33
  number: string[];
73
34
  element: string[];
74
35
  text: string[];
75
- lock: string;
36
+ lock: string[];
76
37
  }, undefined, unknown, unknown, undefined>>;