@tesouro/embedded-components-react 0.9.54 → 0.9.56

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.
@@ -41,23 +41,23 @@ function S({ option: e, isSelected: n, isDisabled: r, reason: i, onToggle: s })
41
41
  })] }) : l;
42
42
  }
43
43
  var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions: E, disabled: D, error: O, labels: k, testId: A }) => {
44
- let [j, M] = m(!1), [N, P] = m(""), F = d(), I = p(null), L = p(null), R = f(() => new Set(t.map((e) => e.id)), [t]), z = f(() => {
44
+ let [j, M] = m(!1), [N, P] = m(""), F = d(), I = d(), L = p(null), R = p(null), z = f(() => new Set(t.map((e) => e.id)), [t]), B = f(() => {
45
45
  let e = N.trim().toLowerCase();
46
46
  return e ? C.filter((t) => t.label.toLowerCase().includes(e) || t.sublabel?.toLowerCase().includes(e)) : C;
47
- }, [C, N]), B = z.filter((e) => e.section === "roles"), V = z.filter((e) => e.section === "teamMembers"), H = (e) => {
47
+ }, [C, N]), V = B.filter((e) => e.section === "roles"), H = B.filter((e) => e.section === "teamMembers"), U = (e) => {
48
48
  let t = T?.[e.section], n = E?.[e.id];
49
49
  return /* @__PURE__ */ g(S, {
50
50
  option: e,
51
- isSelected: R.has(e.id),
51
+ isSelected: z.has(e.id),
52
52
  isDisabled: !!e.disabled || !!t || !!n,
53
53
  reason: e.disabledReason ?? n ?? t,
54
- onToggle: () => U(e)
54
+ onToggle: () => W(e)
55
55
  }, e.id);
56
- }, U = (e) => {
57
- R.has(e.id) ? w(t.filter((t) => t.id !== e.id)) : w([...t, x(e)]), P(""), I.current?.focus();
58
56
  }, W = (e) => {
57
+ z.has(e.id) ? w(t.filter((t) => t.id !== e.id)) : w([...t, x(e)]), P(""), L.current?.focus();
58
+ }, G = (e) => {
59
59
  w(t.filter((t) => t.id !== e));
60
- }, G = B.length > 0 && V.length > 0;
60
+ }, K = V.length > 0 && H.length > 0;
61
61
  return /* @__PURE__ */ g(s, { children: /* @__PURE__ */ _(n, {
62
62
  open: j,
63
63
  onOpenChange: (e) => {
@@ -66,13 +66,7 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
66
66
  children: [/* @__PURE__ */ g(r, {
67
67
  asChild: !0,
68
68
  children: /* @__PURE__ */ _("div", {
69
- ref: L,
70
- onPointerDown: () => {
71
- D || M(!0);
72
- },
73
- onClick: () => {
74
- D || I.current?.focus();
75
- },
69
+ ref: R,
76
70
  className: `ttw:flex ttw:min-h-9 ttw:w-full ttw:cursor-text ttw:flex-wrap ttw:items-center ttw:gap-1.5 ttw:rounded-md ttw:border ttw:bg-transparent ttw:px-2.5 ttw:py-1.5 ttw:has-[:disabled]:cursor-not-allowed ttw:has-[:disabled]:opacity-60 ${O ? "ttw:border-destructive" : "ttw:border-input"}`,
77
71
  children: [
78
72
  t.map((t, n) => /* @__PURE__ */ _(u, { children: [n > 0 ? /* @__PURE__ */ g("span", {
@@ -85,28 +79,34 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
85
79
  type: "button",
86
80
  "aria-label": k.RemoveApproverAriaLabel.replace("{name}", t.label),
87
81
  onClick: (e) => {
88
- e.stopPropagation(), W(t.id);
82
+ e.stopPropagation(), G(t.id);
89
83
  },
90
84
  disabled: D,
91
85
  className: "ttw:inline-flex ttw:size-3.5 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-sm ttw:opacity-70 ttw:disabled:cursor-not-allowed hover:ttw:opacity-100",
92
86
  children: /* @__PURE__ */ g(b, { className: "ttw:size-3" })
93
87
  })]
94
88
  })] }, t.id)),
95
- /* @__PURE__ */ g("input", {
96
- ref: I,
97
- type: "text",
98
- value: N,
99
- onChange: (e) => {
100
- P(e.target.value), M(!0);
101
- },
102
- onFocus: () => M(!0),
103
- disabled: D,
104
- placeholder: t.length === 0 ? k.ChoosePlaceholder : "",
105
- "aria-label": k.ChoosePlaceholder,
106
- "aria-invalid": !!O,
107
- "aria-describedby": O ? F : void 0,
108
- "data-testid": A,
109
- className: "ttw:min-w-16 ttw:flex-1 ttw:bg-transparent ttw:text-sm ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed"
89
+ /* @__PURE__ */ g("label", {
90
+ htmlFor: I,
91
+ className: "ttw:flex ttw:min-w-16 ttw:flex-1 ttw:cursor-text ttw:self-stretch ttw:items-center",
92
+ children: /* @__PURE__ */ g("input", {
93
+ id: I,
94
+ ref: L,
95
+ type: "text",
96
+ value: N,
97
+ onChange: (e) => {
98
+ P(e.target.value), M(!0);
99
+ },
100
+ onFocus: () => M(!0),
101
+ onClick: () => M(!0),
102
+ disabled: D,
103
+ placeholder: t.length === 0 ? k.ChoosePlaceholder : "",
104
+ "aria-label": k.ChoosePlaceholder,
105
+ "aria-invalid": !!O,
106
+ "aria-describedby": O ? F : void 0,
107
+ "data-testid": A,
108
+ className: "ttw:w-full ttw:bg-transparent ttw:text-sm ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed"
109
+ })
110
110
  }),
111
111
  O ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(c, {
112
112
  asChild: !0,
@@ -137,18 +137,18 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
137
137
  sideOffset: 4,
138
138
  onOpenAutoFocus: (e) => e.preventDefault(),
139
139
  onInteractOutside: (e) => {
140
- e.target instanceof Node && L.current?.contains(e.target) && e.preventDefault();
140
+ e.target instanceof Node && R.current?.contains(e.target) && e.preventDefault();
141
141
  },
142
142
  className: "ttw:w-[var(--radix-popover-trigger-width)] ttw:min-w-80 ttw:p-2",
143
143
  children: /* @__PURE__ */ g("div", {
144
144
  className: "ttw:max-h-64 ttw:overflow-y-auto",
145
- children: z.length === 0 ? /* @__PURE__ */ g(l, {
145
+ children: B.length === 0 ? /* @__PURE__ */ g(l, {
146
146
  variant: "body2",
147
147
  color: "muted",
148
148
  className: "ttw:px-2 ttw:py-1.5",
149
149
  children: C.length === 0 ? k.NoOptionsMessage : k.NoResultsMessage
150
150
  }) : /* @__PURE__ */ _(h, { children: [
151
- B.length > 0 ? /* @__PURE__ */ _("div", {
151
+ V.length > 0 ? /* @__PURE__ */ _("div", {
152
152
  role: "group",
153
153
  "aria-label": k.RolesSectionHeading,
154
154
  children: [/* @__PURE__ */ g(l, {
@@ -156,9 +156,9 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
156
156
  color: "muted",
157
157
  className: "ttw:block ttw:px-2 ttw:py-1",
158
158
  children: k.RolesSectionHeading
159
- }), B.map(H)]
159
+ }), V.map(U)]
160
160
  }) : null,
161
- G ? /* @__PURE__ */ _("div", {
161
+ K ? /* @__PURE__ */ _("div", {
162
162
  className: "ttw:my-1 ttw:flex ttw:items-center ttw:gap-2 ttw:px-2",
163
163
  children: [
164
164
  /* @__PURE__ */ g("div", { className: "ttw:h-px ttw:flex-1 ttw:bg-border" }),
@@ -170,7 +170,7 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
170
170
  /* @__PURE__ */ g("div", { className: "ttw:h-px ttw:flex-1 ttw:bg-border" })
171
171
  ]
172
172
  }) : null,
173
- V.length > 0 ? /* @__PURE__ */ _("div", {
173
+ H.length > 0 ? /* @__PURE__ */ _("div", {
174
174
  role: "group",
175
175
  "aria-label": k.TeamMembersSectionHeading,
176
176
  children: [/* @__PURE__ */ g(l, {
@@ -178,7 +178,7 @@ var C = ({ value: t, options: C, onChange: w, lockedSections: T, lockedOptions:
178
178
  color: "muted",
179
179
  className: "ttw:block ttw:px-2 ttw:py-1",
180
180
  children: k.TeamMembersSectionHeading
181
- }), V.map(H)]
181
+ }), H.map(U)]
182
182
  }) : null
183
183
  ] })
184
184
  })