mcr-design-systems 1.0.7 → 1.0.9

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,6 +1,6 @@
1
- import { jsxs as T, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as v, jsx as r } from "react/jsx-runtime";
2
2
  import "react";
3
- import { button as v } from "./helper/index.js";
3
+ import { button as T } from "./helper/index.js";
4
4
  import { cn as O } from "../../shared/utils/cn.js";
5
5
  import { dataTestId as S } from "../../shared/utils/dataTestId.js";
6
6
  import a from "../Icon/Icon.js";
@@ -56,11 +56,11 @@ function A({
56
56
  "aria-hidden": "true"
57
57
  }
58
58
  ) : null, I = m && !e ? /* @__PURE__ */ r(a, { name: m, size: s, "aria-hidden": "true" }) : null, z = c && !e ? /* @__PURE__ */ r(a, { name: c, size: s, "aria-hidden": "true" }) : null, b = t && !e ? /* @__PURE__ */ r(a, { name: i, size: s, "aria-hidden": "true" }) : null;
59
- return /* @__PURE__ */ T(
59
+ return /* @__PURE__ */ v(
60
60
  "button",
61
61
  {
62
62
  className: O(
63
- v({
63
+ T({
64
64
  variant: o,
65
65
  size: n,
66
66
  iconOnly: t,
@@ -75,7 +75,7 @@ function A({
75
75
  e && y,
76
76
  !e && !t && I,
77
77
  !e && t && b,
78
- !t && /* @__PURE__ */ r(j, { variants: "action", size: x(), children: d }),
78
+ !t && /* @__PURE__ */ r(j, { as: "div", variants: "action", size: x(), children: d }),
79
79
  !e && !t && z
80
80
  ]
81
81
  }
@@ -1,23 +1,23 @@
1
- import { jsx as r, jsxs as j } from "react/jsx-runtime";
1
+ import { jsx as l, jsxs as v } from "react/jsx-runtime";
2
2
  import h, { useCallback as f } from "react";
3
- import { cn as v } from "../../shared/utils/cn.js";
3
+ import { cn as S } from "../../shared/utils/cn.js";
4
4
  import { dataTestId as V } from "../../shared/utils/dataTestId.js";
5
5
  import { Typography as _ } from "../Typography/index.js";
6
- import p from "../Icon/Icon.js";
6
+ import c from "../Icon/Icon.js";
7
7
  import { chipIconVariants as x, chipVariants as I } from "./helper/variants.js";
8
- const b = h.memo(({ icon: o, size: t, position: m }) => {
9
- const { name: n, node: c, "aria-label": e } = o;
10
- return /* @__PURE__ */ r(
8
+ const b = h.memo(({ icon: i, size: r, position: e }) => {
9
+ const { name: n, node: p, "aria-label": m } = i;
10
+ return /* @__PURE__ */ l(
11
11
  "span",
12
12
  {
13
- className: x({ size: t, position: m }),
14
- "aria-label": e,
15
- role: e ? "img" : void 0,
16
- children: c || n && /* @__PURE__ */ r(
17
- p,
13
+ className: x({ size: r, position: e }),
14
+ "aria-label": m,
15
+ role: m ? "img" : void 0,
16
+ children: p || n && /* @__PURE__ */ l(
17
+ c,
18
18
  {
19
19
  name: n,
20
- size: t === "x-small" ? 12 : t === "small" || t === "medium" ? 16 : 24
20
+ size: r === "x-small" ? 12 : r === "small" || r === "medium" ? 16 : 24
21
21
  }
22
22
  )
23
23
  }
@@ -26,91 +26,91 @@ const b = h.memo(({ icon: o, size: t, position: m }) => {
26
26
  b.displayName = "ChipIcon";
27
27
  const L = h.forwardRef(
28
28
  ({
29
- children: o,
30
- leadingIcon: t,
31
- trailingIcon: m,
29
+ children: i,
30
+ leadingIcon: r,
31
+ trailingIcon: e,
32
32
  variant: n = "warning",
33
- selected: c = !0,
34
- state: e = "default",
33
+ selected: p = !0,
34
+ state: m = "default",
35
35
  size: a = "large",
36
36
  className: C,
37
37
  disabled: s = !1,
38
38
  onClick: d,
39
- onRemove: l,
39
+ onRemove: t,
40
40
  dataTestIdName: N = "chip",
41
- ...g
42
- }, w) => {
43
- const y = f(
44
- (i) => {
45
- !s && e !== "disabled" && d?.(i);
41
+ ...w
42
+ }, y) => {
43
+ const g = f(
44
+ (o) => {
45
+ !s && m !== "disabled" && d?.(o);
46
46
  },
47
- [s, e, d]
48
- ), T = f(
49
- (i) => {
50
- i.stopPropagation(), !s && e !== "disabled" && l?.();
47
+ [s, m, d]
48
+ ), k = f(
49
+ (o) => {
50
+ o.stopPropagation(), !s && m !== "disabled" && t?.();
51
51
  },
52
- [s, e, l]
53
- ), u = s ? "disabled" : e, { id: k } = V(N), S = v(
52
+ [s, m, t]
53
+ ), u = s ? "disabled" : m, T = S(
54
54
  I({
55
55
  size: a,
56
56
  variant: n,
57
57
  state: u,
58
- selected: c,
58
+ selected: p,
59
59
  className: C
60
60
  })
61
- );
62
- return /* @__PURE__ */ j(
61
+ ), j = (o) => {
62
+ switch (o) {
63
+ case "x-small":
64
+ return "xs";
65
+ case "small":
66
+ return "sm";
67
+ case "medium":
68
+ return "sm";
69
+ case "large":
70
+ return "md";
71
+ default:
72
+ return "md";
73
+ }
74
+ };
75
+ return /* @__PURE__ */ v(
63
76
  "button",
64
77
  {
65
- ref: w,
78
+ ref: y,
66
79
  type: "button",
67
- className: S,
80
+ className: T,
68
81
  disabled: s || u === "disabled",
69
- onClick: y,
70
- "data-testid": k,
71
- "aria-pressed": c,
72
- ...g,
82
+ onClick: g,
83
+ ...V(N),
84
+ "aria-pressed": p,
85
+ ...w,
73
86
  children: [
74
- t && /* @__PURE__ */ r(b, { icon: t, size: a, position: "leading" }),
75
- o && /* @__PURE__ */ r(
87
+ r && /* @__PURE__ */ l(b, { icon: r, size: a, position: "leading" }),
88
+ i && /* @__PURE__ */ l(
76
89
  _,
77
90
  {
78
91
  variants: "action-emphasize",
79
- size: ((i) => {
80
- switch (i) {
81
- case "x-small":
82
- return "xs";
83
- case "small":
84
- return "sm";
85
- case "medium":
86
- return "sm";
87
- case "large":
88
- return "md";
89
- default:
90
- return "md";
91
- }
92
- })(a),
92
+ size: j(a),
93
93
  as: "span",
94
94
  className: "font-medium whitespace-nowrap",
95
- children: o
95
+ children: i
96
96
  }
97
97
  ),
98
- m && /* @__PURE__ */ r(
98
+ e && /* @__PURE__ */ l(
99
99
  "span",
100
100
  {
101
101
  className: x({ size: a, position: "trailing" }),
102
- onClick: l ? T : void 0,
103
- role: l ? "button" : void 0,
104
- tabIndex: l ? 0 : void 0,
105
- "aria-label": m["aria-label"] || "Remove",
106
- children: m.node || m.name && /* @__PURE__ */ r(
107
- p,
102
+ onClick: t ? k : void 0,
103
+ role: t ? "button" : void 0,
104
+ tabIndex: t ? 0 : void 0,
105
+ "aria-label": e["aria-label"] || "Remove",
106
+ children: e.node || e.name && /* @__PURE__ */ l(
107
+ c,
108
108
  {
109
- name: m.name,
109
+ name: e.name,
110
110
  size: a === "x-small" ? 12 : a === "small" || a === "medium" ? 16 : 24
111
111
  }
112
- ) || l && /* @__PURE__ */ r(
113
- p,
112
+ ) || t && /* @__PURE__ */ l(
113
+ c,
114
114
  {
115
115
  name: "x-close",
116
116
  size: a === "x-small" ? 12 : a === "small" || a === "medium" ? 16 : 24
@@ -3,6 +3,7 @@ import { IconProps } from '../Icon';
3
3
  export interface InputBaseProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
4
  disabled?: boolean;
5
5
  readOnly?: boolean;
6
+ sizeVariant?: 'sm' | 'md' | 'lg';
6
7
  endAdornment?: React.ReactElement<IconProps>;
7
8
  color?: 'primary' | 'error';
8
9
  startAdornment?: React.ReactElement<IconProps>;
@@ -12,6 +13,7 @@ export interface InputBaseProps extends React.InputHTMLAttributes<HTMLInputEleme
12
13
  iconsSize?: number;
13
14
  fontSize?: string;
14
15
  error?: boolean;
16
+ clearText?: boolean;
15
17
  optionalProps?: {
16
18
  textAreaClassName?: string;
17
19
  maxIndicatorLength?: number;
@@ -1,97 +1,181 @@
1
- import { jsx as a, jsxs as E } from "react/jsx-runtime";
2
- import i, { forwardRef as I, memo as $ } from "react";
3
- import { inputBaseVariants as w, textAreaVariants as b } from "./variants.js";
4
- import { cn as c } from "../../shared/utils/cn.js";
5
- import { dataTestId as g } from "../../shared/utils/dataTestId.js";
6
- const f = I(
1
+ import { jsx as i, jsxs as I } from "react/jsx-runtime";
2
+ import m, { forwardRef as A, useState as D, useMemo as B, useEffect as H, memo as R } from "react";
3
+ import { inputBaseVariants as _, textAreaVariants as F } from "./variants.js";
4
+ import K from "../Icon/Icon.js";
5
+ import { cn as p } from "../../shared/utils/cn.js";
6
+ import { dataTestId as W } from "../../shared/utils/dataTestId.js";
7
+ const q = (n) => {
8
+ switch (n) {
9
+ case "sm":
10
+ return 16;
11
+ case "md":
12
+ return 20;
13
+ case "lg":
14
+ return 24;
15
+ default:
16
+ return 20;
17
+ }
18
+ }, N = A(
7
19
  ({
8
- disabled: e,
9
- readOnly: t,
10
- endAdornment: r,
11
- className: x,
12
- color: N,
13
- startAdornment: n,
14
- InputComponent: l,
15
- containerProps: d,
16
- containerRef: v,
17
- width: y,
18
- fontSize: o,
19
- iconsSize: p,
20
+ disabled: n,
21
+ readOnly: a,
22
+ endAdornment: d,
23
+ className: w,
24
+ color: T,
25
+ sizeVariant: f = "md",
26
+ startAdornment: y,
27
+ InputComponent: b,
28
+ containerProps: z,
29
+ containerRef: C,
30
+ width: S,
31
+ iconsSize: V,
20
32
  error: j,
21
- optionalProps: m,
22
- ...s
23
- }, B) => {
24
- const { id: h } = g("InputBase");
25
- return /* @__PURE__ */ a("div", { className: "relative justify-center items-center", children: /* @__PURE__ */ E(
33
+ clearText: M,
34
+ optionalProps: h,
35
+ ...e
36
+ }, k) => {
37
+ const [L, v] = D(!1), g = V || q(f), c = B(
38
+ () => `inputbase-input-${Math.random().toString(36).substring(2, 9)}`,
39
+ []
40
+ ), l = B(
41
+ () => `inputbase-textarea-${Math.random().toString(36).substring(2, 9)}`,
42
+ []
43
+ );
44
+ H(() => {
45
+ const t = e.value;
46
+ if (t !== void 0) {
47
+ v(String(t).length > 0);
48
+ return;
49
+ }
50
+ const s = () => {
51
+ const r = e.type === "textarea" ? document.getElementById(l) : document.getElementById(c);
52
+ if (r) {
53
+ const E = () => {
54
+ v(r.value.length > 0);
55
+ };
56
+ return E(), r.addEventListener("input", E), () => {
57
+ r.removeEventListener("input", E);
58
+ };
59
+ }
60
+ }, o = s();
61
+ if (!o) {
62
+ const r = setTimeout(() => {
63
+ s();
64
+ }, 100);
65
+ return () => clearTimeout(r);
66
+ }
67
+ return o;
68
+ }, [e.type, e.value, c, l]);
69
+ const x = M && L ? /* @__PURE__ */ i(
70
+ K,
71
+ {
72
+ name: "x-circle",
73
+ variant: "solid",
74
+ size: g,
75
+ className: "cursor-pointer hover:opacity-70 transition-opacity text-fg-neutral-subtle",
76
+ onClick: () => {
77
+ v(!1);
78
+ const t = e.type === "textarea" ? document.getElementById(l) : document.getElementById(c);
79
+ if (t)
80
+ if (t.value = "", e.onChange) {
81
+ const s = {
82
+ target: t,
83
+ currentTarget: t,
84
+ type: "change",
85
+ bubbles: !0
86
+ };
87
+ e.onChange(s);
88
+ } else {
89
+ const s = new Event("input", { bubbles: !0 }), o = new Event("change", { bubbles: !0 });
90
+ t.dispatchEvent(s), t.dispatchEvent(o);
91
+ }
92
+ },
93
+ "aria-label": "Clear text"
94
+ }
95
+ ) : null, u = x && d ? /* @__PURE__ */ I("div", { className: "flex items-center gap-1", children: [
96
+ x,
97
+ d
98
+ ] }) : x || d, $ = {
99
+ sm: "h-4",
100
+ md: "h-5",
101
+ lg: "h-6"
102
+ };
103
+ return /* @__PURE__ */ i("div", { className: "relative justify-center items-center", children: /* @__PURE__ */ I(
26
104
  "div",
27
105
  {
28
- "data-testid": h,
29
- ref: v,
30
- ...d,
31
- className: w({
32
- disabled: !!e,
33
- className: x,
34
- color: N,
35
- readOnly: !!t,
106
+ ...W("InputBase"),
107
+ ref: C,
108
+ ...z,
109
+ className: _({
110
+ disabled: !!n,
111
+ className: w,
112
+ color: T,
113
+ size: e?.type === "textarea" ? void 0 : f,
114
+ readOnly: !!a,
36
115
  error: !!j
37
116
  }),
38
- style: { minWidth: y ?? "100%" },
117
+ style: { minWidth: S ?? "100%" },
39
118
  children: [
40
- n && /* @__PURE__ */ a(
119
+ y && /* @__PURE__ */ i(
41
120
  "div",
42
121
  {
43
- className: c(
44
- "flex cursor-pointer items-center justify-center pl-2",
45
- {
46
- "color-icon-disabled": e || t,
47
- "cursor-pointer": !e || t
48
- }
49
- ),
50
- children: i.cloneElement(n, {
122
+ className: p("flex cursor-pointer items-center justify-center", {
123
+ "color-icon-disabled": n || a,
124
+ "cursor-pointer": !n || a
125
+ }),
126
+ children: m.cloneElement(y, {
51
127
  // color: disabled || readOnly ? 'disabled' : 'currentColor',
52
- size: p
128
+ size: g
53
129
  })
54
130
  }
55
131
  ),
56
- l ? i.cloneElement(
57
- l,
132
+ b ? m.cloneElement(
133
+ b,
58
134
  {
59
- className: c(
60
- s?.type === "textarea" ? b({
61
- size: m?.sizeTextArea,
62
- disabled: !!e,
63
- readOnly: !!t
64
- }) : "py-3 px-4",
65
- "appearance-none bg-transparent outline-none",
66
- m?.textAreaClassName
135
+ id: e?.type === "textarea" ? l : void 0,
136
+ className: p(
137
+ e?.type === "textarea" ? F({
138
+ size: h?.sizeTextArea,
139
+ disabled: !!n,
140
+ readOnly: !!a
141
+ }) : void 0,
142
+ "w-full appearance-none bg-transparent outline-none",
143
+ h?.textAreaClassName
67
144
  ),
68
- disabled: e || t,
69
- ...s
145
+ disabled: n || a,
146
+ ...e
70
147
  },
71
148
  null
72
- ) : /* @__PURE__ */ a(
149
+ ) : /* @__PURE__ */ i(
73
150
  "input",
74
151
  {
75
- className: `min-h-8 w-full appearance-none bg-transparent px-2 py-1 font-sans outline-none ${o || ""}`,
76
- ref: B,
77
- disabled: e || t,
78
- ...s,
79
- onKeyDown: (u) => {
80
- s?.type === "number" && ["e", "E", "+", "-", "."].includes(u.key) && u.preventDefault();
152
+ id: e.type === "textarea" ? void 0 : c,
153
+ className: p(
154
+ "w-full appearance-none bg-transparent font-sans outline-none",
155
+ $[f || "md"]
156
+ ),
157
+ ref: k,
158
+ disabled: n || a,
159
+ ...e,
160
+ onKeyDown: (t) => {
161
+ e?.type === "number" && ["e", "E", "+", "-", "."].includes(t.key) && t.preventDefault();
81
162
  }
82
163
  }
83
164
  ),
84
- r && /* @__PURE__ */ a(
165
+ u && /* @__PURE__ */ i(
85
166
  "div",
86
167
  {
87
- className: c("max-h flex items-center justify-center p-2", {
88
- "color-icon-disabled": e || t,
89
- "cursor-pointer": !e || t
168
+ className: p("max-h flex items-center justify-center", {
169
+ "color-icon-disabled": n || a,
170
+ "cursor-pointer": !n || a
90
171
  }),
91
- children: i.cloneElement(r, {
92
- // color: disabled ? 'disabled' : 'default',
93
- size: p
94
- })
172
+ children: m.isValidElement(u) ? m.cloneElement(
173
+ u,
174
+ {
175
+ // color: disabled ? 'disabled' : 'default',
176
+ size: g
177
+ }
178
+ ) : u
95
179
  }
96
180
  )
97
181
  ]
@@ -99,8 +183,8 @@ const f = I(
99
183
  ) });
100
184
  }
101
185
  );
102
- f.displayName = "InputBase";
103
- const _ = $(f);
186
+ N.displayName = "InputBase";
187
+ const P = R(N);
104
188
  export {
105
- _ as default
189
+ P as default
106
190
  };
@@ -1,4 +1,9 @@
1
1
  export declare const inputBaseVariants: import('tailwind-variants').TVReturnType<{
2
+ size: {
3
+ sm: string;
4
+ md: string;
5
+ lg: string;
6
+ };
2
7
  disabled: {
3
8
  true: string;
4
9
  };
@@ -12,7 +17,12 @@ export declare const inputBaseVariants: import('tailwind-variants').TVReturnType
12
17
  primary: string;
13
18
  error: string;
14
19
  };
15
- }, undefined, "text-p-medium leading-p-medium flex items-center rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2", {
20
+ }, undefined, "text-fg-neutral-main placeholder:text-fg-neutral-subtlest flex items-center gap-1 rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2", {
21
+ size: {
22
+ sm: string;
23
+ md: string;
24
+ lg: string;
25
+ };
16
26
  disabled: {
17
27
  true: string;
18
28
  };
@@ -27,6 +37,11 @@ export declare const inputBaseVariants: import('tailwind-variants').TVReturnType
27
37
  error: string;
28
38
  };
29
39
  }, undefined, import('tailwind-variants').TVReturnType<{
40
+ size: {
41
+ sm: string;
42
+ md: string;
43
+ lg: string;
44
+ };
30
45
  disabled: {
31
46
  true: string;
32
47
  };
@@ -40,7 +55,7 @@ export declare const inputBaseVariants: import('tailwind-variants').TVReturnType
40
55
  primary: string;
41
56
  error: string;
42
57
  };
43
- }, undefined, "text-p-medium leading-p-medium flex items-center rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2", unknown, unknown, undefined>>;
58
+ }, undefined, "text-fg-neutral-main placeholder:text-fg-neutral-subtlest flex items-center gap-1 rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2", unknown, unknown, undefined>>;
44
59
  export declare const textAreaVariants: import('tailwind-variants').TVReturnType<{
45
60
  size: {
46
61
  sm: string;
@@ -1,12 +1,17 @@
1
1
  import { tv as e } from "../../node_modules/tailwind-variants/dist/index.js";
2
2
  const a = e({
3
- base: "text-p-medium leading-p-medium flex items-center rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2",
3
+ base: "text-fg-neutral-main placeholder:text-fg-neutral-subtlest flex items-center gap-1 rounded-lg tracking-p-medium outline-1 focus-within:border-input-active focus-within:outline-2",
4
4
  variants: {
5
+ size: {
6
+ sm: "py-xs-2 px-xs h-lg text-base-sm",
7
+ md: "py-2.5 py- px-sm-2 h-xl text-base-md",
8
+ lg: "py-sm-2 px-sm h-xl-2 text-base-lg"
9
+ },
5
10
  disabled: {
6
- true: "placeholder:text-fg-neutral-disabled bg-bg-surface-level-2 cursor-not-allowed text-fg-neutral-disabled outline-bg-neutral-bold-rest placeholder:bg-fg-neutral-disabled hover:outline-offset-0"
11
+ true: "placeholder:text-fg-neutral-disabled bg-bg-input-disabled border-input-disabled cursor-not-allowed text-fg-neutral-disabled outline-bg-neutral-bold-rest placeholder:bg-fg-neutral-disabled hover:outline-offset-0"
7
12
  },
8
13
  readOnly: {
9
- true: "placeholder:color-text-disabled bg-bg-surface-level-2 cursor-not-allowed outline-bg-neutral-bold-rest placeholder:bg-fg-neutral-disabled hover:outline-offset-0"
14
+ true: "placeholder:color-text-disabled bg-bg-input-disabled border-input-disabled cursor-not-allowed outline-bg-neutral-bold-rest placeholder:bg-fg-neutral-disabled hover:outline-offset-0"
10
15
  },
11
16
  error: {
12
17
  true: "outline-fg-accent-error focus-within:outline-fg-accent-error"
@@ -17,9 +22,9 @@ const a = e({
17
22
  }
18
23
  },
19
24
  defaultVariants: {
25
+ size: "md",
20
26
  color: "primary",
21
27
  disabled: !1,
22
- // size: 'md',
23
28
  readOnly: !1,
24
29
  error: !1
25
30
  },