mcr-design-systems 1.0.113 → 1.0.115

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.
@@ -33,7 +33,7 @@ const l = e({
33
33
  "xx-small": ["px-xs-4", "gap-xs-4"],
34
34
  "x-small": ["px-xs-2", "gap-xs-3"],
35
35
  small: ["px-sm-2", "gap-xs-3"],
36
- medium: ["px-sm-2 py-2.5", "gap-xs-3"],
36
+ medium: ["px-sm-2", "gap-xs-3"],
37
37
  large: ["px-sm", "gap-xs-3"]
38
38
  },
39
39
  iconOnly: {
@@ -80,6 +80,10 @@ export interface ButtonFilterProps extends React.ButtonHTMLAttributes<HTMLButton
80
80
  * Whether the dropdown is open
81
81
  */
82
82
  isOpen?: boolean;
83
+ /**
84
+ * Whether to show clear button
85
+ */
86
+ showClearButton?: boolean;
83
87
  }
84
88
  /**
85
89
  * ButtonFilter component - specialized button for filtering with selected state support and dropdown functionality
@@ -107,4 +111,4 @@ export interface ButtonFilterProps extends React.ButtonHTMLAttributes<HTMLButton
107
111
  * </ButtonFilter>
108
112
  * ```
109
113
  */
110
- export default function ButtonFilter({ variant, size, iconOnly, leadingIcon, trailingIcon, icon, loading, isChosen, count, onClose, className, children, disabled, dropdownItems, selectedValues, onSelectionChange, multiSelect, withDropdown, selectionMode, search, shouldShowSeparator, isOpen: externalIsOpen, ...props }: ButtonFilterProps): import("react/jsx-runtime").JSX.Element;
114
+ export default function ButtonFilter({ variant, size, iconOnly, leadingIcon, trailingIcon, icon, loading, isChosen, count, onClose, className, children, disabled, dropdownItems, selectedValues, onSelectionChange, multiSelect, withDropdown, selectionMode, search, shouldShowSeparator, showClearButton, isOpen: externalIsOpen, ...props }: ButtonFilterProps): import("react/jsx-runtime").JSX.Element;
@@ -1,62 +1,40 @@
1
- import { jsxs as f, jsx as n } from "react/jsx-runtime";
2
- import { useState as M, useMemo as K } from "react";
3
- import { buttonFilter as h } from "./helper/index.js";
1
+ import { jsxs as h, jsx as r } from "react/jsx-runtime";
2
+ import { useState as w, useMemo as U } from "react";
3
+ import { buttonFilter as d } from "./helper/index.js";
4
4
  import { cn as a } from "../../shared/utils/cn.js";
5
5
  import { dataTestId as C } from "../../shared/utils/dataTestId.js";
6
- import l from "../Icon/Icon.js";
7
- import Q from "../Badge/index.js";
8
- import { Dropdown as U } from "../Dropdown/index.js";
9
- function ie({
10
- variant: m = "primary",
11
- size: s = "medium",
12
- iconOnly: W = !1,
6
+ import u from "../Icon/Icon.js";
7
+ import W from "../Badge/index.js";
8
+ import { Dropdown as X } from "../Dropdown/index.js";
9
+ function ae({
10
+ variant: l = "primary",
11
+ size: n = "medium",
12
+ iconOnly: Y = !1,
13
13
  leadingIcon: k,
14
- trailingIcon: L,
15
- icon: P,
14
+ trailingIcon: F,
15
+ icon: L,
16
16
  loading: e = !1,
17
- isChosen: F = !1,
18
- count: x,
17
+ isChosen: P = !1,
18
+ count: z,
19
19
  onClose: T,
20
20
  className: y,
21
21
  children: I,
22
- disabled: o,
23
- dropdownItems: g = [],
24
- selectedValues: c = [],
25
- onSelectionChange: d,
26
- multiSelect: z = !0,
27
- withDropdown: p = !1,
22
+ disabled: s,
23
+ dropdownItems: R = [],
24
+ selectedValues: o = [],
25
+ onSelectionChange: p,
26
+ multiSelect: B = !0,
27
+ withDropdown: b = !1,
28
28
  selectionMode: A = "default",
29
- search: R = !0,
30
- shouldShowSeparator: S,
29
+ search: S = !0,
30
+ shouldShowSeparator: q,
31
+ showClearButton: Z = !0,
31
32
  isOpen: j,
32
33
  ...O
33
34
  }) {
34
- const [X, Y] = M(!1), v = j !== void 0 ? j : X, q = j !== void 0 ? () => {
35
- } : Y, t = W && !!P, i = K(() => {
36
- const r = x !== void 0 ? x : c?.length || 0;
37
- return console.log(
38
- "ButtonFilter effectiveCount:",
39
- r,
40
- "selectedValues:",
41
- c,
42
- "count:",
43
- x
44
- ), r;
45
- }, [x, c]), b = K(() => {
46
- if (p) {
47
- const r = i > 0;
48
- return console.log(
49
- "ButtonFilter effectiveIsChosen (dropdown):",
50
- r,
51
- "effectiveCount:",
52
- i,
53
- "selectedValues:",
54
- c
55
- ), r;
56
- }
57
- return console.log("ButtonFilter effectiveIsChosen (no dropdown):", F), F;
58
- }, [F, p, i, c]), u = (() => {
59
- switch (s) {
35
+ const [_, $] = w(!1), m = j !== void 0 ? j : _, E = j !== void 0 ? () => {
36
+ } : $, t = Y && !!L, f = U(() => z !== void 0 ? z : o?.length || 0, [z, o]), x = U(() => b ? f > 0 : P, [P, b, f, o]), i = (() => {
37
+ switch (n) {
60
38
  case "xx-small":
61
39
  return 16;
62
40
  case "x-small":
@@ -69,8 +47,8 @@ function ie({
69
47
  default:
70
48
  return 24;
71
49
  }
72
- })(), w = () => {
73
- switch (s) {
50
+ })(), G = () => {
51
+ switch (n) {
74
52
  case "xx-small":
75
53
  case "x-small":
76
54
  case "small":
@@ -80,77 +58,77 @@ function ie({
80
58
  default:
81
59
  return "md";
82
60
  }
83
- }, E = (r) => {
84
- if (Array.isArray(r))
85
- d?.(r);
61
+ }, H = (c) => {
62
+ if (Array.isArray(c))
63
+ p?.(c);
86
64
  else {
87
- if (r === "") {
88
- d?.([]);
65
+ if (c === "") {
66
+ p?.([]);
89
67
  return;
90
68
  }
91
- if (!z || A === "radio") {
92
- d?.([r]);
69
+ if (!B || A === "radio") {
70
+ p?.([c]);
93
71
  return;
94
72
  }
95
- const _ = c.includes(r) ? c.filter(($) => $ !== r) : [...c, r];
96
- d?.(_);
73
+ const g = o.includes(c) ? o.filter((D) => D !== c) : [...o, c];
74
+ p?.(g);
97
75
  }
98
- }, G = () => {
99
- d?.([]), T?.();
100
- }, B = e ? /* @__PURE__ */ n(
101
- l,
76
+ }, J = () => {
77
+ p?.([]), T?.();
78
+ }, N = e ? /* @__PURE__ */ r(
79
+ u,
102
80
  {
103
81
  name: "activity-heart",
104
- size: u,
82
+ size: i,
105
83
  className: "animate-spin",
106
84
  "aria-hidden": "true"
107
85
  }
108
- ) : null, N = k && !e ? /* @__PURE__ */ n(l, { name: k, size: u, "aria-hidden": "true" }) : null, Z = L && !e && !b && !p ? /* @__PURE__ */ n(l, { name: L, size: u, "aria-hidden": "true" }) : null, H = p && !e ? /* @__PURE__ */ n(l, { name: "chevron-down", size: u, "aria-hidden": "true" }) : null, J = t && !e ? /* @__PURE__ */ n(l, { name: P, size: u, "aria-hidden": "true" }) : null;
109
- return p && !t ? b ? /* @__PURE__ */ f("div", { className: "inline-flex items-center", children: [
110
- /* @__PURE__ */ n(
111
- U,
86
+ ) : null, v = k && !e ? /* @__PURE__ */ r(u, { name: k, size: i, "aria-hidden": "true" }) : null, M = F && !e && !x && !b ? /* @__PURE__ */ r(u, { name: F, size: i, "aria-hidden": "true" }) : null, K = b && !e ? /* @__PURE__ */ r(u, { name: "chevron-down", size: i, "aria-hidden": "true" }) : null, Q = t && !e ? /* @__PURE__ */ r(u, { name: L, size: i, "aria-hidden": "true" }) : null;
87
+ return b && !t ? x ? /* @__PURE__ */ h("div", { className: "inline-flex items-center", children: [
88
+ /* @__PURE__ */ r(
89
+ X,
112
90
  {
113
- items: g,
114
- value: c,
115
- open: v,
116
- onOpenChange: q,
117
- onValueChange: E,
118
- disabled: o,
119
- multiSelect: z,
120
- search: R,
91
+ items: R,
92
+ value: o,
93
+ open: m,
94
+ onOpenChange: E,
95
+ onValueChange: H,
96
+ disabled: s,
97
+ multiSelect: B,
98
+ search: S,
121
99
  searchPlaceholder: "Search",
122
100
  selectionMode: A,
123
- showClearButton: !0,
124
- shouldShowSeparator: S,
125
- trigger: /* @__PURE__ */ f(
101
+ showClearButton: Z,
102
+ shouldShowSeparator: q,
103
+ trigger: /* @__PURE__ */ h(
126
104
  "button",
127
105
  {
128
106
  className: a(
129
- h({
130
- variant: m,
131
- size: s,
107
+ d({
108
+ variant: l,
109
+ size: n,
132
110
  isChosen: !0,
133
- isOpen: v,
134
- spacing: s
111
+ isOpen: m,
112
+ spacing: n
135
113
  }),
136
114
  "rounded-r-none border-r-[1px]"
137
115
  ),
138
- disabled: o || e,
116
+ disabled: s || e,
139
117
  type: "button",
140
118
  ...O,
141
119
  children: [
142
- e && B,
143
- !e && N,
120
+ e && N,
121
+ !e && v,
144
122
  !e && I,
145
- i > 0 && /* @__PURE__ */ n(
146
- Q,
123
+ f > 0 && /* @__PURE__ */ r(
124
+ W,
147
125
  {
148
126
  variant: "boldest",
149
- size: w(),
127
+ size: G(),
150
128
  emphasize: !0,
151
- disabled: o,
129
+ disabled: s,
152
130
  className: "ml-xs-3 text-fg-selected-rest",
153
- children: i
131
+ children: f
154
132
  }
155
133
  )
156
134
  ]
@@ -158,160 +136,158 @@ function ie({
158
136
  )
159
137
  }
160
138
  ),
161
- /* @__PURE__ */ n(
139
+ /* @__PURE__ */ r(
162
140
  "button",
163
141
  {
164
142
  type: "button",
165
143
  className: a(
166
- h({
167
- variant: m,
168
- size: s,
144
+ d({
145
+ variant: l,
146
+ size: n,
169
147
  isChosen: !0,
170
148
  iconOnly: !0
171
149
  }),
172
150
  "rounded-l-none border-l-0"
173
151
  ),
174
- onClick: G,
175
- disabled: o,
152
+ onClick: J,
153
+ disabled: s,
176
154
  "aria-label": "Clear all filters",
177
155
  ...C("button-filter-clear"),
178
- children: /* @__PURE__ */ n(l, { name: "x-close", size: u, "aria-hidden": "true" })
156
+ children: /* @__PURE__ */ r(u, { name: "x-close", size: i, "aria-hidden": "true" })
179
157
  }
180
158
  )
181
- ] }) : /* @__PURE__ */ n(
182
- U,
159
+ ] }) : /* @__PURE__ */ r(
160
+ X,
183
161
  {
184
- items: g,
185
- value: c,
186
- open: v,
187
- onOpenChange: q,
188
- onValueChange: E,
189
- disabled: o,
190
- multiSelect: z,
191
- search: R,
162
+ items: R,
163
+ value: o,
164
+ open: m,
165
+ onOpenChange: E,
166
+ onValueChange: H,
167
+ disabled: s,
168
+ multiSelect: B,
169
+ search: S,
192
170
  searchPlaceholder: "Search",
193
171
  selectionMode: A,
194
172
  showClearButton: !0,
195
- shouldShowSeparator: S,
173
+ shouldShowSeparator: q,
196
174
  className: y,
197
- trigger: /* @__PURE__ */ f(
175
+ trigger: /* @__PURE__ */ h(
198
176
  "button",
199
177
  {
200
178
  className: a(
201
- h({
202
- variant: m,
203
- size: s,
179
+ d({
180
+ variant: l,
181
+ size: n,
204
182
  iconOnly: t,
205
- isChosen: b,
206
- isOpen: v,
207
- spacing: t ? void 0 : s
183
+ isChosen: x,
184
+ isOpen: m,
185
+ spacing: t ? void 0 : n
208
186
  }),
209
187
  y
210
188
  ),
211
- disabled: o || e,
189
+ disabled: s || e,
212
190
  type: "button",
213
191
  ...C("button-filter"),
214
192
  ...O,
215
193
  children: [
216
- e && B,
217
- !e && !t && N,
218
- !e && t && J,
194
+ e && N,
195
+ !e && !t && v,
196
+ !e && t && Q,
219
197
  !t && I,
220
- !e && !t && H
198
+ !e && !t && K
221
199
  ]
222
200
  }
223
201
  )
224
202
  }
225
- ) : b && !t ? /* @__PURE__ */ f(
203
+ ) : x && !t ? /* @__PURE__ */ h(
226
204
  "div",
227
205
  {
228
206
  className: a("inline-flex items-center", y),
229
207
  ...C("button-filter"),
230
208
  children: [
231
- /* @__PURE__ */ f(
209
+ /* @__PURE__ */ h(
232
210
  "button",
233
211
  {
234
212
  className: a(
235
- h({
236
- variant: m,
237
- size: s,
213
+ d({
214
+ variant: l,
215
+ size: n,
238
216
  isChosen: !0,
239
- isOpen: !1,
240
- // Non-dropdown buttons don't have open state
241
- spacing: s
217
+ isOpen: m,
218
+ spacing: n
242
219
  }),
243
220
  "rounded-r-none border-r-[1px]"
244
221
  ),
245
- disabled: o || e,
222
+ disabled: s || e,
246
223
  ...O,
247
224
  children: [
248
- e && B,
249
- !e && N,
225
+ e && N,
226
+ !e && v,
250
227
  !e && I,
251
- i > 0 && /* @__PURE__ */ n(
252
- Q,
228
+ f > 0 && /* @__PURE__ */ r(
229
+ W,
253
230
  {
254
231
  variant: "boldest",
255
- size: w(),
232
+ size: G(),
256
233
  emphasize: !0,
257
- disabled: o,
234
+ disabled: s,
258
235
  className: "ml-xs-3 text-fg-selected-rest",
259
- children: i
236
+ children: f
260
237
  }
261
238
  )
262
239
  ]
263
240
  }
264
241
  ),
265
- /* @__PURE__ */ n(
242
+ /* @__PURE__ */ r(
266
243
  "button",
267
244
  {
268
245
  type: "button",
269
246
  className: a(
270
- h({
271
- variant: m,
272
- size: s,
247
+ d({
248
+ variant: l,
249
+ size: n,
273
250
  isChosen: !0,
274
251
  iconOnly: !0
275
252
  }),
276
253
  "rounded-l-none border-l-0"
277
254
  ),
278
- onClick: T || G,
279
- disabled: o,
255
+ onClick: T || J,
256
+ disabled: s,
280
257
  "aria-label": "Remove filter",
281
258
  ...C("button-filter-close"),
282
- children: /* @__PURE__ */ n(l, { name: "x-close", size: u, "aria-hidden": "true" })
259
+ children: /* @__PURE__ */ r(u, { name: "x-close", size: i, "aria-hidden": "true" })
283
260
  }
284
261
  )
285
262
  ]
286
263
  }
287
- ) : /* @__PURE__ */ f(
264
+ ) : /* @__PURE__ */ h(
288
265
  "button",
289
266
  {
290
267
  className: a(
291
- h({
292
- variant: m,
293
- size: s,
268
+ d({
269
+ variant: l,
270
+ size: n,
294
271
  iconOnly: t,
295
- isChosen: b,
296
- isOpen: !1,
297
- // Regular buttons don't have open state
298
- spacing: t ? void 0 : s
272
+ isChosen: x,
273
+ isOpen: m,
274
+ spacing: t ? void 0 : n
299
275
  }),
300
276
  y
301
277
  ),
302
- disabled: o || e,
278
+ disabled: s || e,
303
279
  ...C("button-filter"),
304
280
  ...O,
305
281
  children: [
306
- e && B,
307
- !e && !t && N,
308
- !e && t && J,
282
+ e && N,
283
+ !e && !t && v,
284
+ !e && t && Q,
309
285
  !t && I,
310
- !e && !t && (Z || H)
286
+ !e && !t && (M || K)
311
287
  ]
312
288
  }
313
289
  );
314
290
  }
315
291
  export {
316
- ie as default
292
+ ae as default
317
293
  };