mblabs-roccato-frontend-commons 0.2.10 → 0.2.12

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.
package/dist/index.d.ts CHANGED
@@ -480,6 +480,7 @@ export declare interface ColorPickerProps extends Omit<ComponentProps<'input'>,
480
480
  value?: string;
481
481
  onChange?: (value: string) => void;
482
482
  error?: string;
483
+ buttonText?: string;
483
484
  }
484
485
 
485
486
  export declare function ColorScale({ colors, principalLabel, copiedLabel }: ColorScaleProps): JSX.Element;
@@ -40150,22 +40150,22 @@ function MNe({
40150
40150
  );
40151
40151
  }
40152
40152
  const Rve = tn(
40153
- ({ label: n, helperText: e, value: t = "", onChange: r, error: i, disabled: o = !1, ...s }, a) => {
40154
- const l = Oe(null), c = () => {
40155
- var d;
40156
- o || (d = l.current) == null || d.click();
40157
- }, u = (d) => {
40158
- r == null || r(d.target.value);
40153
+ ({ label: n, helperText: e, value: t = "", onChange: r, error: i, disabled: o = !1, buttonText: s = "Selecionar", ...a }, l) => {
40154
+ const c = Oe(null), u = () => {
40155
+ var f;
40156
+ o || (f = c.current) == null || f.click();
40157
+ }, d = (f) => {
40158
+ r == null || r(f.target.value);
40159
40159
  };
40160
40160
  return /* @__PURE__ */ p.jsxs(Yt, { children: [
40161
40161
  n && /* @__PURE__ */ p.jsx(G1, { className: "mb-1.5 block", children: n }),
40162
- /* @__PURE__ */ p.jsxs(bt, { className: "items-center", children: [
40162
+ /* @__PURE__ */ p.jsxs(bt, { className: "items-center relative", children: [
40163
40163
  /* @__PURE__ */ p.jsx(
40164
40164
  "input",
40165
40165
  {
40166
40166
  type: "text",
40167
40167
  value: t,
40168
- onChange: (d) => r == null ? void 0 : r(d.target.value),
40168
+ onChange: (f) => r == null ? void 0 : r(f.target.value),
40169
40169
  placeholder: "#D92D20",
40170
40170
  disabled: o,
40171
40171
  className: G(
@@ -40174,39 +40174,42 @@ const Rve = tn(
40174
40174
  i && "border-error-500",
40175
40175
  o && "bg-gray-100 text-gray-400 cursor-not-allowed"
40176
40176
  ),
40177
- ...s
40177
+ ...a
40178
40178
  }
40179
40179
  ),
40180
40180
  /* @__PURE__ */ p.jsxs(
40181
40181
  "button",
40182
40182
  {
40183
40183
  type: "button",
40184
- onClick: c,
40184
+ onClick: u,
40185
40185
  disabled: o,
40186
40186
  className: G(
40187
- "h-10 px-3 border border-l-transparent rounded-r-2xl flex items-center gap-2 text-sm",
40187
+ "h-10 px-3 border border-l-transparent rounded-r-2xl flex items-center gap-2 relative",
40188
40188
  "transition-colors",
40189
+ "font-semibold text-sm text-gray-700 whitespace-nowrap",
40190
+ "cursor-pointer",
40189
40191
  !o && "hover:bg-gray-50",
40190
40192
  o && "text-gray-400 cursor-not-allowed"
40191
40193
  ),
40192
40194
  children: [
40193
40195
  /* @__PURE__ */ p.jsx(kne, { className: "size-4 text-gray-500" }),
40194
- "Selecionar"
40196
+ s,
40197
+ /* @__PURE__ */ p.jsx(
40198
+ "input",
40199
+ {
40200
+ ref: (f) => {
40201
+ typeof l == "function" ? l(f) : l && (l.current = f), c.current = f;
40202
+ },
40203
+ type: "color",
40204
+ value: t,
40205
+ onChange: d,
40206
+ disabled: o,
40207
+ className: "absolute inset-0 opacity-0 cursor-pointer",
40208
+ style: { width: "100%", height: "100%" }
40209
+ }
40210
+ )
40195
40211
  ]
40196
40212
  }
40197
- ),
40198
- /* @__PURE__ */ p.jsx(
40199
- "input",
40200
- {
40201
- ref: (d) => {
40202
- typeof a == "function" ? a(d) : a && (a.current = d), l.current = d;
40203
- },
40204
- type: "color",
40205
- value: t,
40206
- onChange: u,
40207
- disabled: o,
40208
- className: "hidden"
40209
- }
40210
40213
  )
40211
40214
  ] }),
40212
40215
  (e || i) && /* @__PURE__ */ p.jsx(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-frontend-commons",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20.11.1"
@@ -12,10 +12,11 @@ export interface ColorPickerProps extends Omit<ComponentProps<'input'>, 'value'
12
12
  value?: string;
13
13
  onChange?: (value: string) => void;
14
14
  error?: string;
15
+ buttonText?: string;
15
16
  }
16
17
 
17
18
  export const ColorPicker = forwardRef<HTMLInputElement, ColorPickerProps>(
18
- ({ label, helperText, value = '', onChange, error, disabled = false, ...props }, ref) => {
19
+ ({ label, helperText, value = '', onChange, error, disabled = false, buttonText = 'Selecionar', ...props }, ref) => {
19
20
  const inputRef = useRef<HTMLInputElement | null>(null);
20
21
 
21
22
  const handleClick = () => {
@@ -36,7 +37,7 @@ export const ColorPicker = forwardRef<HTMLInputElement, ColorPickerProps>(
36
37
  </Label>
37
38
  )}
38
39
 
39
- <Flex className="items-center">
40
+ <Flex className="items-center relative">
40
41
  <input
41
42
  type="text"
42
43
  value={value}
@@ -57,32 +58,34 @@ export const ColorPicker = forwardRef<HTMLInputElement, ColorPickerProps>(
57
58
  onClick={handleClick}
58
59
  disabled={disabled}
59
60
  className={cn(
60
- 'h-10 px-3 border border-l-transparent rounded-r-2xl flex items-center gap-2 text-sm',
61
+ 'h-10 px-3 border border-l-transparent rounded-r-2xl flex items-center gap-2 relative',
61
62
  'transition-colors',
63
+ 'font-semibold text-sm text-gray-700 whitespace-nowrap',
64
+ 'cursor-pointer',
62
65
  !disabled && 'hover:bg-gray-50',
63
66
  disabled && 'text-gray-400 cursor-not-allowed'
64
67
  )}
65
68
  >
66
69
  <Dropper className="size-4 text-gray-500" />
67
- Selecionar
68
- </button>
69
-
70
- <input
71
- ref={(node) => {
72
- if (typeof ref === 'function') {
73
- ref(node);
74
- } else if (ref) {
75
- ref.current = node;
76
- }
70
+ {buttonText}
71
+ <input
72
+ ref={(node) => {
73
+ if (typeof ref === 'function') {
74
+ ref(node);
75
+ } else if (ref) {
76
+ ref.current = node;
77
+ }
77
78
 
78
- inputRef.current = node;
79
- }}
80
- type="color"
81
- value={value}
82
- onChange={handleChange}
83
- disabled={disabled}
84
- className="hidden"
85
- />
79
+ inputRef.current = node;
80
+ }}
81
+ type="color"
82
+ value={value}
83
+ onChange={handleChange}
84
+ disabled={disabled}
85
+ className="absolute inset-0 opacity-0 cursor-pointer"
86
+ style={{ width: '100%', height: '100%' }}
87
+ />
88
+ </button>
86
89
  </Flex>
87
90
 
88
91
  {(helperText || error) && (