mcr-design-systems 1.0.26 → 1.0.28

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,11 +1,11 @@
1
- import { jsxs as I, jsx as u } from "react/jsx-runtime";
2
- import r, { forwardRef as D, useState as H, useMemo as B, useEffect as R, memo as _ } from "react";
1
+ import { jsxs as I, jsx as o } from "react/jsx-runtime";
2
+ import c, { forwardRef as $, useState as H, useMemo as B, useEffect as R, memo as _ } from "react";
3
3
  import { inputBaseVariants as F, textAreaVariants as K } from "./variants.js";
4
4
  import W from "../Icon/Icon.js";
5
5
  import { cn as f } from "../../shared/utils/cn.js";
6
6
  import { dataTestId as q } from "../../shared/utils/dataTestId.js";
7
- const A = (n) => {
8
- switch (n) {
7
+ const A = (t) => {
8
+ switch (t) {
9
9
  case "sm":
10
10
  return 16;
11
11
  case "md":
@@ -15,174 +15,177 @@ const A = (n) => {
15
15
  default:
16
16
  return 20;
17
17
  }
18
- }, N = D(
18
+ }, N = $(
19
19
  ({
20
- disabled: n,
21
- readOnly: a,
22
- endAdornment: l,
23
- className: V,
24
- color: w,
20
+ disabled: t,
21
+ readOnly: s,
22
+ endAdornment: u,
23
+ className: w,
24
+ color: T,
25
25
  sizeVariant: v = "md",
26
26
  startAdornment: b,
27
27
  InputComponent: y,
28
- containerProps: z,
29
- containerRef: T,
28
+ containerProps: V,
29
+ containerRef: z,
30
30
  width: C,
31
31
  iconsSize: S,
32
32
  error: j,
33
- clearText: M,
33
+ clearText: D,
34
34
  optionalProps: h,
35
35
  // inputSize,
36
36
  ...e
37
- }, k) => {
38
- const [L, g] = H(!1), o = S || A(v), m = B(
37
+ }, M) => {
38
+ const [k, g] = H(!1), m = S || A(v), p = B(
39
39
  () => `inputbase-input-${Math.random().toString(36).substring(2, 9)}`,
40
40
  []
41
- ), p = B(
41
+ ), d = B(
42
42
  () => `inputbase-textarea-${Math.random().toString(36).substring(2, 9)}`,
43
43
  []
44
44
  );
45
45
  R(() => {
46
- const t = e.value;
47
- if (t !== void 0) {
48
- g(String(t).length > 0);
46
+ const n = e.value;
47
+ if (n !== void 0) {
48
+ g(String(n).length > 0);
49
49
  return;
50
50
  }
51
- const i = () => {
52
- const c = e.type === "textarea" ? document.getElementById(p) : document.getElementById(m);
53
- if (c) {
51
+ const a = () => {
52
+ const r = e.type === "textarea" ? document.getElementById(d) : document.getElementById(p);
53
+ if (r) {
54
54
  const x = () => {
55
- g(c.value.length > 0);
55
+ g(r.value.length > 0);
56
56
  };
57
- return x(), c.addEventListener("input", x), () => {
58
- c.removeEventListener("input", x);
57
+ return x(), r.addEventListener("input", x), () => {
58
+ r.removeEventListener("input", x);
59
59
  };
60
60
  }
61
- }, d = i();
62
- if (!d) {
63
- const c = setTimeout(() => {
64
- i();
61
+ }, l = a();
62
+ if (!l) {
63
+ const r = setTimeout(() => {
64
+ a();
65
65
  }, 100);
66
- return () => clearTimeout(c);
66
+ return () => clearTimeout(r);
67
67
  }
68
- return d;
69
- }, [e.type, e.value, m, p]);
70
- const E = M && L ? /* @__PURE__ */ u(
68
+ return l;
69
+ }, [e.type, e.value, p, d]);
70
+ const E = D && k ? /* @__PURE__ */ o(
71
71
  W,
72
72
  {
73
73
  name: "x-circle",
74
74
  variant: "solid",
75
- size: o,
75
+ size: m,
76
76
  className: "cursor-pointer text-fg-neutral-subtle",
77
- onClick: () => {
78
- g(!1);
79
- const t = e.type === "textarea" ? document.getElementById(p) : document.getElementById(m);
80
- if (t) {
81
- if (t.value = "", e.onChange) {
82
- const i = {
83
- target: t,
84
- currentTarget: t,
77
+ onClick: (n) => {
78
+ n.preventDefault(), n.stopPropagation(), g(!1);
79
+ const a = e.type === "textarea" ? document.getElementById(d) : document.getElementById(p);
80
+ if (a) {
81
+ if (a.value = "", e.onChange) {
82
+ const l = {
83
+ target: a,
84
+ currentTarget: a,
85
85
  type: "change",
86
86
  bubbles: !0
87
87
  };
88
- e.onChange(i);
88
+ e.onChange(l);
89
89
  } else {
90
- const i = new Event("input", { bubbles: !0 }), d = new Event("change", { bubbles: !0 });
91
- t.dispatchEvent(i), t.dispatchEvent(d);
90
+ const l = new Event("input", { bubbles: !0 }), r = new Event("change", { bubbles: !0 });
91
+ a.dispatchEvent(l), a.dispatchEvent(r);
92
92
  }
93
- t?.focus();
93
+ setTimeout(() => {
94
+ a?.focus();
95
+ }, 0);
94
96
  }
95
97
  },
96
98
  "aria-label": "Clear text"
97
99
  }
98
- ) : null, s = E && l ? /* @__PURE__ */ I("div", { className: "flex items-center gap-2", children: [
100
+ ) : null, i = E && u ? /* @__PURE__ */ I("div", { className: "flex items-center gap-2", children: [
99
101
  E,
100
- r.isValidElement(l) ? r.cloneElement(
101
- l,
102
+ c.isValidElement(u) ? c.cloneElement(
103
+ u,
102
104
  {
103
- size: o
105
+ size: m
104
106
  }
105
- ) : l
106
- ] }) : E || l, $ = {
107
+ ) : u
108
+ ] }) : E || u, L = {
107
109
  sm: "h-4",
108
110
  md: "h-5",
109
111
  lg: "h-6"
110
112
  };
111
- return /* @__PURE__ */ u("div", { className: "relative justify-center items-center", children: /* @__PURE__ */ I(
113
+ return /* @__PURE__ */ o("div", { className: "relative justify-center items-center", children: /* @__PURE__ */ I(
112
114
  "div",
113
115
  {
114
116
  ...q("InputBase"),
115
- ref: T,
116
- ...z,
117
+ ref: z,
118
+ ...V,
117
119
  className: F({
118
- disabled: !!n,
119
- className: V,
120
- color: w,
120
+ disabled: !!t,
121
+ className: w,
122
+ color: T,
121
123
  size: e?.type === "textarea" ? void 0 : v,
122
- readOnly: !!a,
124
+ readOnly: !!s,
123
125
  error: !!j
124
126
  }),
125
127
  style: { minWidth: C ?? "100%" },
126
128
  children: [
127
- b && /* @__PURE__ */ u(
129
+ b && /* @__PURE__ */ o(
128
130
  "div",
129
131
  {
130
132
  className: f("flex cursor-pointer items-center justify-center", {
131
- "color-icon-disabled": n || a,
132
- "cursor-pointer": !n || a
133
+ "color-icon-disabled": t || s,
134
+ "cursor-pointer": !t || s
133
135
  }),
134
- children: r.cloneElement(b, {
136
+ children: c.cloneElement(b, {
135
137
  // color: disabled || readOnly ? 'disabled' : 'currentColor',
136
- size: o
138
+ size: m
137
139
  })
138
140
  }
139
141
  ),
140
- y ? r.cloneElement(
142
+ y ? c.cloneElement(
141
143
  y,
142
144
  {
143
- id: e?.type === "textarea" ? p : void 0,
145
+ id: e?.type === "textarea" ? d : void 0,
144
146
  className: f(
145
147
  e?.type === "textarea" ? K({
146
148
  size: h?.sizeTextArea,
147
- disabled: !!n,
148
- readOnly: !!a
149
+ disabled: !!t,
150
+ readOnly: !!s
149
151
  }) : void 0,
150
152
  "w-full appearance-none bg-transparent outline-none",
151
153
  h?.textAreaClassName
152
154
  ),
153
- disabled: n || a,
155
+ disabled: t || s,
154
156
  ...e
155
157
  },
156
158
  null
157
- ) : /* @__PURE__ */ u(
159
+ ) : /* @__PURE__ */ o(
158
160
  "input",
159
161
  {
160
- id: e.type === "textarea" ? void 0 : m,
162
+ id: e.type === "textarea" ? void 0 : p,
161
163
  className: f(
162
- "w-full appearance-none bg-transparent font-sans outline-none",
163
- $[v || "md"]
164
+ "w-full appearance-none bg-transparent font-sans outline-none text-fg-neutral-main",
165
+ L[v || "md"]
164
166
  ),
165
- ref: k,
166
- disabled: n || a,
167
+ ref: M,
168
+ disabled: t || s,
167
169
  ...e,
168
- onKeyDown: (t) => {
169
- e?.type === "number" && ["e", "E", "+", "-", "."].includes(t.key) && t.preventDefault();
170
+ onKeyDown: (n) => {
171
+ e?.type === "number" && ["e", "E", "+", "-", "."].includes(n.key) && n.preventDefault();
170
172
  }
171
173
  }
172
174
  ),
173
- s && /* @__PURE__ */ u(
175
+ i && /* @__PURE__ */ o(
174
176
  "div",
175
177
  {
176
178
  className: f("max-h flex items-center justify-center", {
177
- "color-icon-disabled": n || a,
178
- "cursor-pointer": !n || a
179
+ "color-icon-disabled": t || s,
180
+ "cursor-pointer": !t || s
179
181
  }),
180
- children: r.isValidElement(s) && s.type === "div" ? s : r.isValidElement(s) ? r.cloneElement(
181
- s,
182
+ onMouseDown: (n) => n.preventDefault(),
183
+ children: c.isValidElement(i) && i.type === "div" ? i : c.isValidElement(i) ? c.cloneElement(
184
+ i,
182
185
  {
183
- size: o
186
+ size: m
184
187
  }
185
- ) : s
188
+ ) : i
186
189
  }
187
190
  )
188
191
  ]
@@ -191,7 +194,7 @@ const A = (n) => {
191
194
  }
192
195
  );
193
196
  N.displayName = "InputBase";
194
- const P = _(N);
197
+ const Z = _(N);
195
198
  export {
196
- P as default
199
+ Z as default
197
200
  };
@@ -34,6 +34,10 @@ export interface InputPasswordProps extends Omit<InputBaseProps, 'type' | 'start
34
34
  * Callback when visibility changes
35
35
  */
36
36
  onVisibilityChange?: (visible: boolean) => void;
37
+ /**
38
+ * Custom helper content - allows completely custom layout
39
+ */
40
+ customHelperContent?: React.ReactNode;
37
41
  }
38
42
  declare const InputPassword: React.ForwardRefExoticComponent<InputPasswordProps & React.RefAttributes<HTMLInputElement>>;
39
43
  export default InputPassword;
@@ -1,61 +1,69 @@
1
- import { jsxs as x, jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as y, useState as g } from "react";
3
- import h from "../InputBase/index.js";
4
- import I from "../TextField/HelperText.js";
5
- import v from "../Icon/Icon.js";
6
- const N = y(
1
+ import { jsxs as v, jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as I, useState as h } from "react";
3
+ import N from "../InputBase/index.js";
4
+ import c from "../TextField/HelperText.js";
5
+ import V from "../Icon/Icon.js";
6
+ const P = I(
7
7
  ({
8
- helperText: a,
9
- error: i = !1,
10
- showHelperIcon: r = !0,
11
- helperIconCustom: l,
12
- helperTextClassName: d,
13
- defaultVisible: m = !1,
8
+ helperText: i,
9
+ error: n = !1,
10
+ showHelperIcon: m = !0,
11
+ helperIconCustom: u,
12
+ helperTextClassName: r,
13
+ defaultVisible: f = !1,
14
14
  visible: t,
15
- onVisibilityChange: c,
16
- className: u,
17
- ...s
18
- }, f) => {
19
- const [p, b] = g(m), o = t !== void 0 ? t : p, w = () => {
20
- if (s.disabled)
15
+ onVisibilityChange: p,
16
+ customHelperContent: s,
17
+ className: b,
18
+ ...a
19
+ }, w) => {
20
+ const [g, x] = h(f), o = t !== void 0 ? t : g, y = (l) => {
21
+ if (l.preventDefault(), l.stopPropagation(), a.disabled)
21
22
  return;
22
- const n = !o;
23
- t === void 0 && b(n), c?.(n);
23
+ const d = !o;
24
+ t === void 0 && x(d), p?.(d);
24
25
  };
25
- return /* @__PURE__ */ x("div", { className: "w-full [&_input[type='password']::-ms-reveal]:hidden [&_input[type='password']::-ms-clear]:hidden", children: [
26
+ return /* @__PURE__ */ v("div", { className: "w-full [&_input[type='password']::-ms-reveal]:hidden [&_input[type='password']::-ms-clear]:hidden", children: [
26
27
  /* @__PURE__ */ e(
27
- h,
28
+ N,
28
29
  {
29
- ...s,
30
- ref: f,
30
+ ...a,
31
+ ref: w,
31
32
  type: o ? "text" : "password",
32
- error: i,
33
- className: u,
33
+ error: n,
34
+ className: b,
34
35
  clearText: !0,
35
36
  endAdornment: /* @__PURE__ */ e(
36
- v,
37
+ V,
37
38
  {
38
39
  name: o ? "eye" : "eye-off",
39
- className: `transition-colors ${s.disabled ? "bg-bg-input-disabled cursor-not-allowed" : "cursor-pointer hover:text-fg-neutral-rest text-fg-neutral-subtle"}`,
40
- onClick: w
40
+ className: `transition-colors ${a.disabled ? "bg-bg-input-disabled cursor-not-allowed" : "cursor-pointer hover:text-fg-neutral-rest text-fg-neutral-subtle"}`,
41
+ onClick: y
41
42
  }
42
43
  )
43
44
  }
44
45
  ),
45
- a && /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(
46
- I,
46
+ s && /* @__PURE__ */ e(
47
+ c,
47
48
  {
48
- text: a,
49
- error: i,
50
- haveIcon: r,
51
- iconsCustom: l,
52
- className: d
49
+ customContent: s,
50
+ className: r
51
+ }
52
+ ),
53
+ !s && i && /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(
54
+ c,
55
+ {
56
+ text: i,
57
+ error: n,
58
+ haveIcon: m,
59
+ iconsCustom: u,
60
+ className: r
53
61
  }
54
62
  ) })
55
63
  ] });
56
64
  }
57
65
  );
58
- N.displayName = "InputPassword";
66
+ P.displayName = "InputPassword";
59
67
  export {
60
- N as default
68
+ P as default
61
69
  };
@@ -1,4 +1,9 @@
1
1
  import { default as React } from 'react';
2
+ export interface RequirementItem {
3
+ id: string;
4
+ text: string;
5
+ isValid: boolean;
6
+ }
2
7
  export interface HelpTextProps {
3
8
  text?: string;
4
9
  error?: boolean;
@@ -6,6 +11,18 @@ export interface HelpTextProps {
6
11
  iconsCustom?: React.ReactNode;
7
12
  className?: string;
8
13
  iconsSize?: number;
14
+ /**
15
+ * Custom content mode - allows rendering custom layout
16
+ */
17
+ customContent?: React.ReactNode;
18
+ /**
19
+ * Requirements list mode - can be used for any type of validation requirements
20
+ */
21
+ requirementsList?: {
22
+ items: RequirementItem[];
23
+ title?: string;
24
+ showTitle?: boolean;
25
+ };
9
26
  }
10
27
  declare const HelpText: React.FC<HelpTextProps>;
11
28
  export default HelpText;
@@ -1,50 +1,100 @@
1
- import { jsx as e, jsxs as f } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { Typography as c } from "../Typography/index.js";
4
- import s from "../Icon/Icon.js";
5
- const x = ({
6
- text: l,
7
- error: a = !1,
8
- haveIcon: i = !0,
9
- iconsCustom: r,
10
- className: n,
11
- iconsSize: t = 16
12
- }) => l ? /* @__PURE__ */ e(
13
- "div",
14
- {
15
- className: `self-stretch inline-flex flex-col justify-start items-start ${n || ""}`,
16
- children: /* @__PURE__ */ f("div", { className: "self-stretch inline-flex justify-start items-start gap-1", children: [
17
- a && (r || /* @__PURE__ */ e(
18
- s,
4
+ import n from "../Icon/Icon.js";
5
+ import u from "clsx";
6
+ const j = ({
7
+ text: f,
8
+ error: l = !1,
9
+ haveIcon: d = !0,
10
+ iconsCustom: m,
11
+ className: r,
12
+ iconsSize: t = 16,
13
+ customContent: o,
14
+ requirementsList: a
15
+ }) => {
16
+ if (o)
17
+ return /* @__PURE__ */ e(
18
+ "div",
19
+ {
20
+ className: `self-stretch inline-flex flex-col justify-start items-start ${r || ""}`,
21
+ children: o
22
+ }
23
+ );
24
+ if (a) {
25
+ const { items: x } = a, h = a.showTitle !== !1, p = a.title || "Requirements:";
26
+ return /* @__PURE__ */ i("div", { className: `mt-1 space-y-1 ${r || ""}`, children: [
27
+ h && /* @__PURE__ */ i("div", { className: "self-stretch inline-flex justify-start items-start gap-1", children: [
28
+ /* @__PURE__ */ e(
29
+ n,
30
+ {
31
+ name: "alert-octagon",
32
+ className: "text-fg-accent-error",
33
+ variant: "solid",
34
+ size: typeof t == "number" ? t : 16
35
+ }
36
+ ),
37
+ /* @__PURE__ */ e(
38
+ c,
39
+ {
40
+ variants: "body",
41
+ size: "sm",
42
+ color: "fg-accent-error",
43
+ className: "font-medium",
44
+ children: p
45
+ }
46
+ )
47
+ ] }),
48
+ /* @__PURE__ */ e("ul", { className: "list-disc ml-9", children: x.map((s) => /* @__PURE__ */ e(
49
+ "li",
19
50
  {
20
- name: "alert-octagon",
21
- className: "text-fg-accent-error",
22
- variant: "solid",
23
- size: typeof t == "number" ? t : 16
24
- }
25
- )),
26
- i && !a && /* @__PURE__ */ e(
27
- s,
28
- {
29
- name: "help-circle",
30
- variant: "line",
31
- className: "text-fg-neutral-subtle",
32
- size: typeof t == "number" ? t : 16
33
- }
34
- ),
35
- /* @__PURE__ */ e("div", { className: "flex-1 justify-start text-left flex flex-wrap items-center gap-0", children: /* @__PURE__ */ e(
36
- c,
37
- {
38
- variants: "body",
39
- size: "sm",
40
- color: a ? "fg-accent-error" : "fg-neutral-subtle",
41
- className: "inline",
42
- children: l
43
- }
44
- ) })
45
- ] })
51
+ className: u("", {
52
+ "marker:text-fg-accent-success text-fg-accent-success": s.isValid,
53
+ "marker:text-fg-accent-error text-fg-accent-error": !s.isValid
54
+ }),
55
+ children: /* @__PURE__ */ e(c, { variants: "body", size: "sm", className: "text-inherit", children: s.text })
56
+ },
57
+ s.id
58
+ )) })
59
+ ] });
46
60
  }
47
- ) : null;
61
+ return f ? /* @__PURE__ */ e(
62
+ "div",
63
+ {
64
+ className: `self-stretch inline-flex flex-col justify-start items-start ${r || ""}`,
65
+ children: /* @__PURE__ */ i("div", { className: "self-stretch inline-flex justify-start items-start gap-1", children: [
66
+ l && (m || /* @__PURE__ */ e(
67
+ n,
68
+ {
69
+ name: "alert-octagon",
70
+ className: "text-fg-accent-error",
71
+ variant: "solid",
72
+ size: typeof t == "number" ? t : 16
73
+ }
74
+ )),
75
+ d && !l && /* @__PURE__ */ e(
76
+ n,
77
+ {
78
+ name: "help-circle",
79
+ variant: "line",
80
+ className: "text-fg-neutral-subtle",
81
+ size: typeof t == "number" ? t : 16
82
+ }
83
+ ),
84
+ /* @__PURE__ */ e("div", { className: "flex-1 justify-start text-left flex flex-wrap items-center gap-0", children: /* @__PURE__ */ e(
85
+ c,
86
+ {
87
+ variants: "body",
88
+ size: "sm",
89
+ color: l ? "fg-accent-error" : "fg-neutral-subtle",
90
+ className: "inline",
91
+ children: f
92
+ }
93
+ ) })
94
+ ] })
95
+ }
96
+ ) : null;
97
+ };
48
98
  export {
49
- x as default
99
+ j as default
50
100
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcr-design-systems",
3
3
  "private": false,
4
- "version": "1.0.26",
4
+ "version": "1.0.28",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",