@ikatec/nebula-react 1.0.24 → 1.0.26

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.js CHANGED
@@ -2242,15 +2242,9 @@ var StyledAsyncCreatable = createStyledSelect(
2242
2242
  "AsyncCreatable"
2243
2243
  );
2244
2244
  var InputText = React8__namespace.forwardRef(
2245
- ({
2246
- className,
2247
- icon,
2248
- isError = false,
2249
- onClean,
2250
- iconPlacement = "start",
2251
- disabled,
2252
- ...props
2253
- }, ref) => {
2245
+ ({ className, isError = false, onClean, disabled, suffix, ...props }, ref) => {
2246
+ const icon = "icon" in props ? props.icon : null;
2247
+ const iconPlacement = "iconPlacement" in props || props.type !== "password" ? props.iconPlacement || "start" : null;
2254
2248
  const initialInputType = props.type || "text";
2255
2249
  const [type, setType] = React8__namespace.useState(initialInputType);
2256
2250
  const iconClass = {
@@ -2261,71 +2255,92 @@ var InputText = React8__namespace.forwardRef(
2261
2255
  return /* @__PURE__ */ jsxRuntime.jsxs(
2262
2256
  "div",
2263
2257
  {
2264
- className: cn("relative w-full", {
2265
- "pointer-events-none": disabled
2266
- }),
2258
+ className: cn(
2259
+ "w-full flex outline-none",
2260
+ "rounded-input",
2261
+ "border border-inputText-border-default focus-within:ring-[3px] focus-within:ring-inputText-border-focus focus-within:border-inputText-border-focus",
2262
+ "focus-within:text-inputText-text-focus placeholder:text-inputText-text-default disabled:text-inputText-text-disabled",
2263
+ isError && "border-inputText-border-danger focus-within:border-inputText-border-danger focus-within:ring-button-danger-border-focus",
2264
+ disabled && "pointer-events-none"
2265
+ ),
2267
2266
  children: [
2268
- /* @__PURE__ */ jsxRuntime.jsx(
2269
- "input",
2267
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds relative w-full", children: [
2268
+ /* @__PURE__ */ jsxRuntime.jsx(
2269
+ "input",
2270
+ {
2271
+ ref,
2272
+ className: cn(
2273
+ "w-full h-10 outline-none text-sm leading-none font-medium",
2274
+ "bg-inputText-background-default disabled:bg-inputText-background-disabled",
2275
+ "text-inputText-text-filled",
2276
+ "disabled:cursor-not-allowed",
2277
+ "rounded-input",
2278
+ "pl-4",
2279
+ !!suffix && "rounded-r-none",
2280
+ {
2281
+ "pl-10 pr-4": !!icon && iconPlacement === "start",
2282
+ "pr-10": initialInputType === "password",
2283
+ "pr-10 pl-4": !!icon && iconPlacement === "end" && initialInputType !== "password"
2284
+ },
2285
+ className
2286
+ ),
2287
+ ...{ ...props, icon: void 0, iconPlacement: void 0 },
2288
+ disabled,
2289
+ type
2290
+ }
2291
+ ),
2292
+ onClean && props.value && /* @__PURE__ */ jsxRuntime.jsx(
2293
+ "button",
2294
+ {
2295
+ type: "button",
2296
+ className: cn("absolute top-1/2 transform -translate-y-1/2", {
2297
+ "right-10": initialInputType === "password" || iconPlacement === "end",
2298
+ "right-4": initialInputType === "text" && iconPlacement === "start"
2299
+ }),
2300
+ onClick: onClean,
2301
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { className: cn("w-4 h-4", iconClass) })
2302
+ }
2303
+ ),
2304
+ initialInputType === "password" && /* @__PURE__ */ jsxRuntime.jsx(
2305
+ "button",
2306
+ {
2307
+ type: "button",
2308
+ className: "nebula-ds absolute right-4 top-1/2 transform -translate-y-1/2",
2309
+ onClick: () => setType((prev) => prev === "text" ? "password" : "text"),
2310
+ children: type === "text" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: cn("w-4 h-4", iconClass) }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: cn("w-4 h-4", iconClass) })
2311
+ }
2312
+ ),
2313
+ icon && initialInputType !== "password" && /* @__PURE__ */ jsxRuntime.jsx(
2314
+ "span",
2315
+ {
2316
+ className: cn("absolute top-1/2 transform -translate-y-1/2", {
2317
+ "left-4": iconPlacement === "start",
2318
+ "right-4": iconPlacement === "end"
2319
+ }),
2320
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2321
+ "span",
2322
+ {
2323
+ className: cn(
2324
+ "w-4 h-4 flex items-center justify-center disabled:text-inputText-icon-disabled",
2325
+ iconClass
2326
+ ),
2327
+ children: icon
2328
+ }
2329
+ )
2330
+ }
2331
+ )
2332
+ ] }),
2333
+ !!suffix && /* @__PURE__ */ jsxRuntime.jsx(
2334
+ "div",
2270
2335
  {
2271
- ref,
2272
2336
  className: cn(
2273
- "w-full h-10 outline-none rounded-input text-sm leading-none font-medium",
2274
- "bg-inputText-background-default disabled:bg-inputText-background-disabled",
2275
- "border border-inputText-border-default focus:ring-[3px] focus:ring-inputText-border-focus focus:border-inputText-border-focus",
2276
- "text-inputText-text-filled focus:text-inputText-text-focus placeholder:text-inputText-text-default disabled:text-inputText-text-disabled",
2277
- "disabled:cursor-not-allowed",
2278
- {
2279
- "pl-10 pr-4": !!icon && iconPlacement === "start",
2280
- "pr-10 pl-4": !!icon && iconPlacement === "end" && initialInputType !== "password",
2281
- "px-4": !icon,
2282
- "border-inputText-border-danger focus:border-inputText-border-danger focus:ring-button-danger-border-focus": isError
2283
- },
2284
- className
2337
+ "w-fit h-10 outline-none rounded-input text-sm leading-none font-medium rounded-l-none flex items-center px-4",
2338
+ "bg-inputText-suffixBackground disabled:bg-inputText-background-disabled",
2339
+ "text-inputText-text-filled",
2340
+ "border-l border-inputText-border-default",
2341
+ "rounded-input rounded-l-none"
2285
2342
  ),
2286
- ...props,
2287
- disabled,
2288
- type
2289
- }
2290
- ),
2291
- onClean && props.value && /* @__PURE__ */ jsxRuntime.jsx(
2292
- "button",
2293
- {
2294
- type: "button",
2295
- className: cn("absolute top-1/2 transform -translate-y-1/2", {
2296
- "right-10": initialInputType === "password" || iconPlacement === "end",
2297
- "right-4": initialInputType === "text" && iconPlacement === "start"
2298
- }),
2299
- onClick: onClean,
2300
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { className: cn("w-4 h-4", iconClass) })
2301
- }
2302
- ),
2303
- initialInputType === "password" && /* @__PURE__ */ jsxRuntime.jsx(
2304
- "button",
2305
- {
2306
- type: "button",
2307
- className: "nebula-ds absolute right-4 top-1/2 transform -translate-y-1/2",
2308
- onClick: () => setType((prev) => prev === "text" ? "password" : "text"),
2309
- children: type === "text" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: cn("w-4 h-4", iconClass) }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: cn("w-4 h-4", iconClass) })
2310
- }
2311
- ),
2312
- icon && /* @__PURE__ */ jsxRuntime.jsx(
2313
- "span",
2314
- {
2315
- className: cn("absolute top-1/2 transform -translate-y-1/2", {
2316
- "left-4": iconPlacement === "start",
2317
- "right-4": iconPlacement === "end" && initialInputType !== "password"
2318
- }),
2319
- children: /* @__PURE__ */ jsxRuntime.jsx(
2320
- "span",
2321
- {
2322
- className: cn(
2323
- "w-4 h-4 flex items-center justify-center disabled:text-inputText-icon-disabled",
2324
- iconClass
2325
- ),
2326
- children: icon
2327
- }
2328
- )
2343
+ children: suffix
2329
2344
  }
2330
2345
  )
2331
2346
  ]
@@ -3906,13 +3921,44 @@ var Calendar = ({
3906
3921
  }
3907
3922
  );
3908
3923
  };
3909
-
3910
- // src/utils/valid-date-format.ts
3911
- function dateFormatIsValid(dateStr, locale) {
3912
- const regexBR = /^(?:(?:31\/(0[13578]|1[02]))\/(?:\d{4})|(?:29|30)\/(0[13-9]|1[0-2])\/(?:\d{4})|29\/02\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:0[1-9]|1\d|2[0-8])\/(0[1-9]|1[0-2])\/(?:\d{4}))$/;
3913
- const regexUS = /^(?:(?:(0[13578]|1[02])\/31)\/(?:\d{4})|(?:(0[13-9]|1[0-2])\/(29|30))\/(?:\d{4})|(?:02\/29)\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:(0[1-9]|1[0-2])\/(0[1-9]|1\d|2[0-8]))\/(?:\d{4}))$/;
3914
- const regex = locale === "en-US" ? regexUS : regexBR;
3915
- return regex.test(dateStr);
3924
+ function useClickOutside(refs, onClickOutside) {
3925
+ React8.useEffect(() => {
3926
+ const refArray = Array.isArray(refs) ? refs : [refs];
3927
+ function handleClick(event) {
3928
+ const isInside = refArray.some(
3929
+ (ref) => ref?.current && ref?.current.contains(event.target)
3930
+ );
3931
+ if (!isInside) {
3932
+ onClickOutside();
3933
+ }
3934
+ }
3935
+ function handlePressEsc(event) {
3936
+ if (event.key === "Esc") {
3937
+ onClickOutside();
3938
+ }
3939
+ }
3940
+ document.addEventListener("mousedown", handleClick);
3941
+ document.addEventListener("touchstart", handleClick);
3942
+ document.addEventListener("keypress", handlePressEsc);
3943
+ return () => {
3944
+ document.removeEventListener("mousedown", handleClick);
3945
+ document.removeEventListener("touchstart", handleClick);
3946
+ document.removeEventListener("keypress", handlePressEsc);
3947
+ };
3948
+ }, [refs, onClickOutside]);
3949
+ }
3950
+ function useKeyPress(key, callback) {
3951
+ React8.useEffect(() => {
3952
+ function handleKeyDown(event) {
3953
+ if (event.key === key) {
3954
+ callback();
3955
+ }
3956
+ }
3957
+ window.addEventListener("keydown", handleKeyDown);
3958
+ return () => {
3959
+ window.removeEventListener("keydown", handleKeyDown);
3960
+ };
3961
+ }, [key, callback]);
3916
3962
  }
3917
3963
  var formatDateToSubmit = (dateStr, timeFallback = "23:59") => {
3918
3964
  try {
@@ -3933,6 +3979,14 @@ var formatDateToSubmit = (dateStr, timeFallback = "23:59") => {
3933
3979
  return void 0;
3934
3980
  }
3935
3981
  };
3982
+
3983
+ // src/utils/valid-date-format.ts
3984
+ function dateFormatIsValid(dateStr, locale) {
3985
+ const regexBR = /^(?:(?:31\/(0[13578]|1[02]))\/(?:\d{4})|(?:29|30)\/(0[13-9]|1[0-2])\/(?:\d{4})|29\/02\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:0[1-9]|1\d|2[0-8])\/(0[1-9]|1[0-2])\/(?:\d{4}))$/;
3986
+ const regexUS = /^(?:(?:(0[13578]|1[02])\/31)\/(?:\d{4})|(?:(0[13-9]|1[0-2])\/(29|30))\/(?:\d{4})|(?:02\/29)\/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)|(?:(0[1-9]|1[0-2])\/(0[1-9]|1\d|2[0-8]))\/(?:\d{4}))$/;
3987
+ const regex = locale === "en-US" ? regexUS : regexBR;
3988
+ return regex.test(dateStr);
3989
+ }
3936
3990
  var dateIsAvailable = (inputDate, disabledDates) => {
3937
3991
  if (!disabledDates || !inputDate) return true;
3938
3992
  const dateIsDisabled = (d, matcher) => {
@@ -4057,61 +4111,57 @@ var InputDatePickerSingle = ({
4057
4111
  replacement: { _: /\d/ }
4058
4112
  };
4059
4113
  const inputRef = mask.useMask(maskOptions);
4060
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4061
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4062
- "div",
4114
+ const conteinerRef = React8.useRef(null);
4115
+ const calendarRef = React8.useRef(null);
4116
+ useClickOutside([conteinerRef, calendarRef], () => {
4117
+ setPopoverIsOpen(false);
4118
+ });
4119
+ useKeyPress("Escape", () => {
4120
+ setPopoverIsOpen(false);
4121
+ });
4122
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds w-full", ref: conteinerRef, children: [
4123
+ /* @__PURE__ */ jsxRuntime.jsx(
4124
+ InputText,
4063
4125
  {
4064
- onClick: (e) => e.preventDefault(),
4065
- onFocus: (e) => e.preventDefault(),
4066
- children: /* @__PURE__ */ jsxRuntime.jsx(
4067
- InputText,
4126
+ ref: inputRef,
4127
+ placeholder,
4128
+ value,
4129
+ className,
4130
+ onChange: (e) => handleInnerInputChange(e.target.value),
4131
+ onKeyDown: handleKeyDown,
4132
+ icon: /* @__PURE__ */ jsxRuntime.jsx(
4133
+ lucideReact.CalendarIcon,
4068
4134
  {
4069
- ref: inputRef,
4070
- placeholder,
4071
- value,
4072
- className,
4073
- onChange: (e) => handleInnerInputChange(e.target.value),
4074
- onKeyDown: handleKeyDown,
4075
- icon: /* @__PURE__ */ jsxRuntime.jsx(
4076
- lucideReact.CalendarIcon,
4077
- {
4078
- tabIndex: 0,
4079
- role: "button",
4080
- onClick: () => setPopoverIsOpen((s) => !s),
4081
- onKeyUp: (e) => {
4082
- if (e.key === "Enter") {
4083
- setPopoverIsOpen((s) => !s);
4084
- }
4085
- },
4086
- className: "nebula-ds cursor-pointer"
4087
- }
4088
- ),
4089
- iconPlacement: "end",
4135
+ tabIndex: 0,
4136
+ role: "button",
4137
+ onClick: () => setPopoverIsOpen((s) => !s),
4090
4138
  onKeyUp: (e) => {
4091
- if (e.key === "ArrowDown") {
4092
- setPopoverIsOpen(true);
4139
+ if (e.key === "Enter") {
4140
+ setPopoverIsOpen((s) => !s);
4093
4141
  }
4094
4142
  },
4095
- maxLength: 10,
4096
- onClean: onClean ? () => {
4097
- onClean();
4098
- handleClearValue();
4099
- } : void 0,
4100
- ...rest
4143
+ className: "nebula-ds cursor-pointer"
4101
4144
  }
4102
- )
4145
+ ),
4146
+ iconPlacement: "end",
4147
+ onKeyUp: (e) => {
4148
+ if (e.key === "ArrowDown") {
4149
+ setPopoverIsOpen(true);
4150
+ }
4151
+ },
4152
+ maxLength: 10,
4153
+ onClean: onClean ? () => {
4154
+ onClean();
4155
+ handleClearValue();
4156
+ } : void 0,
4157
+ ...rest
4103
4158
  }
4104
- ) }),
4105
- /* @__PURE__ */ jsxRuntime.jsx(
4106
- PopoverContent,
4159
+ ),
4160
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds relative", children: popoverIsOpen && /* @__PURE__ */ jsxRuntime.jsx(
4161
+ "div",
4107
4162
  {
4108
- side: "bottom",
4109
- className: "nebula-ds p-0 border-none bg-transparent shadow-none absolute",
4110
- align: "start",
4111
- collisionPadding: 8,
4112
- avoidCollisions: true,
4113
- asChild: false,
4114
- style: { position: "absolute" },
4163
+ className: "nebula-ds absolute top-full left-0-0 z-40 pb-2 pt-1",
4164
+ ref: calendarRef,
4115
4165
  children: /* @__PURE__ */ jsxRuntime.jsx(
4116
4166
  Calendar,
4117
4167
  {
@@ -4127,8 +4177,8 @@ var InputDatePickerSingle = ({
4127
4177
  }
4128
4178
  )
4129
4179
  }
4130
- )
4131
- ] }) });
4180
+ ) })
4181
+ ] });
4132
4182
  };
4133
4183
  var InputTime = React8.forwardRef(
4134
4184
  ({ value = "", onChange, placeholder = "--:--", ...rest }, ref) => {
@@ -4208,7 +4258,10 @@ var InputDateTimePickerSingle = ({
4208
4258
  ...rest
4209
4259
  }) => {
4210
4260
  const [innerTimeValue, setInnerTimeValue] = React8.useState(
4211
- value?.split?.(DATA_TIME_SEPARATOR)?.at?.(-1) ?? ""
4261
+ () => {
4262
+ const [, time] = (value || "")?.split?.(DATA_TIME_SEPARATOR);
4263
+ return time ?? "";
4264
+ }
4212
4265
  );
4213
4266
  const formattedDateByLanguage = formatDateToSubmit(
4214
4267
  value?.split(DATA_TIME_SEPARATOR)?.at(0) ?? ""
@@ -4275,8 +4328,9 @@ var InputDateTimePickerSingle = ({
4275
4328
  if (date && !dateFormatIsValid(date, locale)) {
4276
4329
  handleClearValue();
4277
4330
  }
4331
+ const hasInputtedDate = date.length === "__/__/____".length;
4278
4332
  onChange?.(
4279
- date + (newTime ? DATA_TIME_SEPARATOR + newTime : ""),
4333
+ date + (newTime && hasInputtedDate ? DATA_TIME_SEPARATOR + newTime : ""),
4280
4334
  innerDate,
4281
4335
  newTime
4282
4336
  );
@@ -4324,60 +4378,56 @@ var InputDateTimePickerSingle = ({
4324
4378
  replacement: { _: /\d/ }
4325
4379
  };
4326
4380
  const inputRef = mask.useMask(maskOptions);
4327
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4328
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4329
- "div",
4381
+ const conteinerRef = React8.useRef(null);
4382
+ const calendarRef = React8.useRef(null);
4383
+ useClickOutside([conteinerRef, calendarRef], () => {
4384
+ setPopoverIsOpen(false);
4385
+ });
4386
+ useKeyPress("Escape", () => {
4387
+ setPopoverIsOpen(false);
4388
+ });
4389
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds w-full", ref: conteinerRef, children: [
4390
+ /* @__PURE__ */ jsxRuntime.jsx(
4391
+ InputText,
4330
4392
  {
4331
- onClick: (e) => e.preventDefault(),
4332
- onFocus: (e) => e.preventDefault(),
4333
- children: /* @__PURE__ */ jsxRuntime.jsx(
4334
- InputText,
4393
+ ref: inputRef,
4394
+ placeholder,
4395
+ value,
4396
+ className,
4397
+ onChange: (e) => handleInnerInputChange(e.target.value),
4398
+ onKeyDown: handleKeyDown,
4399
+ icon: /* @__PURE__ */ jsxRuntime.jsx(
4400
+ lucideReact.CalendarIcon,
4335
4401
  {
4336
- ref: inputRef,
4337
- placeholder,
4338
- value,
4339
- className,
4340
- onChange: (e) => handleInnerInputChange(e.target.value),
4341
- onKeyDown: handleKeyDown,
4342
- icon: /* @__PURE__ */ jsxRuntime.jsx(
4343
- lucideReact.CalendarIcon,
4344
- {
4345
- tabIndex: 0,
4346
- role: "button",
4347
- onClick: () => setPopoverIsOpen((s) => !s),
4348
- onKeyUp: (e) => {
4349
- if (e.key === "Enter") {
4350
- setPopoverIsOpen((s) => !s);
4351
- }
4352
- },
4353
- className: "nebula-ds cursor-pointer"
4354
- }
4355
- ),
4356
- iconPlacement: "end",
4402
+ tabIndex: 0,
4403
+ role: "button",
4404
+ onClick: () => setPopoverIsOpen((s) => !s),
4357
4405
  onKeyUp: (e) => {
4358
- if (e.key === "ArrowDown") {
4359
- setPopoverIsOpen(true);
4406
+ if (e.key === "Enter") {
4407
+ setPopoverIsOpen((s) => !s);
4360
4408
  }
4361
4409
  },
4362
- onClean: onClean ? () => {
4363
- onClean();
4364
- handleClearValue();
4365
- } : void 0,
4366
- ...rest
4410
+ className: "nebula-ds cursor-pointer"
4367
4411
  }
4368
- )
4412
+ ),
4413
+ iconPlacement: "end",
4414
+ onKeyUp: (e) => {
4415
+ if (e.key === "ArrowDown") {
4416
+ setPopoverIsOpen(true);
4417
+ }
4418
+ },
4419
+ onClean: onClean ? () => {
4420
+ onClean();
4421
+ handleClearValue();
4422
+ } : void 0,
4423
+ ...rest
4369
4424
  }
4370
- ) }),
4371
- /* @__PURE__ */ jsxRuntime.jsx(
4372
- PopoverContent,
4425
+ ),
4426
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds relative", children: popoverIsOpen && /* @__PURE__ */ jsxRuntime.jsx(
4427
+ "div",
4373
4428
  {
4374
- side: "bottom",
4375
- className: "nebula-ds p-0 border-none bg-transparent shadow-none",
4376
- align: "start",
4377
- collisionPadding: 8,
4378
- avoidCollisions: true,
4379
- asChild: false,
4380
- style: { position: "absolute" },
4429
+ className: "nebula-ds absolute top-full left-0-0 z-40 pb-2 pt-1",
4430
+ ref: calendarRef,
4381
4431
  children: /* @__PURE__ */ jsxRuntime.jsx(
4382
4432
  Calendar,
4383
4433
  {
@@ -4409,14 +4459,14 @@ var InputDateTimePickerSingle = ({
4409
4459
  }
4410
4460
  )
4411
4461
  }
4412
- )
4413
- ] }) });
4462
+ ) })
4463
+ ] });
4414
4464
  };
4415
- var FileUploadError = /* @__PURE__ */ ((FileUploadError2) => {
4416
- FileUploadError2["MAX_FILES_EXCEEDED"] = "MAX_FILES_EXCEEDED";
4417
- FileUploadError2["MAXIMUM_FILE_SIZE_EXCEEDED"] = "MAXIMUM_FILE_SIZE_EXCEEDED";
4418
- FileUploadError2["INVALID_FORMAT"] = "INVALID_FORMAT";
4419
- return FileUploadError2;
4465
+ var FileUploadError = /* @__PURE__ */ ((FileUploadError4) => {
4466
+ FileUploadError4["MAX_FILES_EXCEEDED"] = "MAX_FILES_EXCEEDED";
4467
+ FileUploadError4["MAXIMUM_FILE_SIZE_EXCEEDED"] = "MAXIMUM_FILE_SIZE_EXCEEDED";
4468
+ FileUploadError4["INVALID_FORMAT"] = "INVALID_FORMAT";
4469
+ return FileUploadError4;
4420
4470
  })(FileUploadError || {});
4421
4471
  var useFileUpload = (options = {}) => {
4422
4472
  const {
@@ -4517,9 +4567,6 @@ var useFileUpload = (options = {}) => {
4517
4567
  const newFilesArray = Array.from(newFiles);
4518
4568
  const errors = [];
4519
4569
  setState((prev) => ({ ...prev, errors: [] }));
4520
- if (!multiple) {
4521
- clearFiles();
4522
- }
4523
4570
  if (multiple && maxFiles !== Infinity && state.files.length + newFilesArray.length > maxFiles) {
4524
4571
  errors.push({ error: "MAX_FILES_EXCEEDED" /* MAX_FILES_EXCEEDED */ });
4525
4572
  setState((prev) => ({ ...prev, errors }));
@@ -4554,6 +4601,9 @@ var useFileUpload = (options = {}) => {
4554
4601
  }
4555
4602
  });
4556
4603
  if (validFiles.length > 0) {
4604
+ if (!multiple) {
4605
+ clearFiles();
4606
+ }
4557
4607
  onFilesAdded?.(validFiles);
4558
4608
  setState((prev) => {
4559
4609
  const newFiles2 = !multiple ? validFiles : [...prev.files, ...validFiles];
@@ -4850,6 +4900,7 @@ function FileUpload({
4850
4900
  ) })
4851
4901
  ] });
4852
4902
  }
4903
+ FileUpload.displayName = "FileUpload";
4853
4904
  var TextArea = React8__namespace.forwardRef(
4854
4905
  ({
4855
4906
  className,
@@ -4927,6 +4978,102 @@ var TextArea = React8__namespace.forwardRef(
4927
4978
  }
4928
4979
  );
4929
4980
  TextArea.displayName = "TextArea";
4981
+ var ProfileImage = ({
4982
+ maxSizeMB = 2,
4983
+ subtitle,
4984
+ onError,
4985
+ maxFiles = Infinity,
4986
+ onRemove,
4987
+ ...rest
4988
+ }) => {
4989
+ const maxSize = maxSizeMB * 1024 * 1024;
4990
+ const [
4991
+ { files, isDragging, errors },
4992
+ {
4993
+ handleDragEnter,
4994
+ handleDragLeave,
4995
+ handleDragOver,
4996
+ handleDrop,
4997
+ openFileDialog,
4998
+ removeFile,
4999
+ getInputProps
5000
+ }
5001
+ ] = useFileUpload({
5002
+ multiple: false,
5003
+ maxSize: maxSize > 0 ? maxSize : void 0,
5004
+ accept: "image/*",
5005
+ ...rest,
5006
+ maxFiles
5007
+ });
5008
+ React8.useEffect(() => {
5009
+ onError?.(errors);
5010
+ }, [errors, onError]);
5011
+ const [file] = files;
5012
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nebula-ds flex flex-col gap-3", children: [
5013
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nebula-ds flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs(
5014
+ "div",
5015
+ {
5016
+ role: "button",
5017
+ onClick: openFileDialog,
5018
+ onDragEnter: handleDragEnter,
5019
+ onDragLeave: handleDragLeave,
5020
+ onDragOver: handleDragOver,
5021
+ onDrop: handleDrop,
5022
+ "data-dragging": isDragging || void 0,
5023
+ className: cn(
5024
+ "relative border border-transparent rounded-full size-fit",
5025
+ "bg-fileUpload-background hover:bg-fileUpload-backgroundHover transition-colors",
5026
+ !file && "border-dashed border-fileUpload-border"
5027
+ ),
5028
+ "data-testid": "select-image-profile",
5029
+ children: [
5030
+ /* @__PURE__ */ jsxRuntime.jsx(
5031
+ "input",
5032
+ {
5033
+ ...getInputProps(),
5034
+ className: "nebula-ds sr-only",
5035
+ "aria-label": "Upload file"
5036
+ }
5037
+ ),
5038
+ /* @__PURE__ */ jsxRuntime.jsxs(
5039
+ "div",
5040
+ {
5041
+ className: "nebula-ds flex size-12 shrink-0 items-center justify-center rounded-full",
5042
+ "aria-hidden": "true",
5043
+ children: [
5044
+ file && file.preview && /* @__PURE__ */ jsxRuntime.jsx(
5045
+ "img",
5046
+ {
5047
+ src: file.preview,
5048
+ alt: file.file.name,
5049
+ className: "nebula-ds rounded-[inherit] object-cover h-full w-full"
5050
+ }
5051
+ ),
5052
+ !file && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserIcon, { className: "nebula-ds size-4 opacity-60 text-fileUpload-icon" })
5053
+ ]
5054
+ }
5055
+ ),
5056
+ file && /* @__PURE__ */ jsxRuntime.jsx(
5057
+ "button",
5058
+ {
5059
+ className: "nebula-ds box-border absolute flex items-center justify-center -top-1 -right-1 rounded-full size-5 text-profileImage-removeImageButton-icon border-2 border-profileImage-removeImageButton-border bg-profileImage-removeImageButton-background hover:bg-profileImage-removeImageButton-hover",
5060
+ "data-testid": "remove-profile-image",
5061
+ onClick: (e) => {
5062
+ e.stopPropagation();
5063
+ removeFile(file.id);
5064
+ onRemove?.();
5065
+ },
5066
+ type: "button",
5067
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "nebula-ds size-2" })
5068
+ }
5069
+ )
5070
+ ]
5071
+ }
5072
+ ) }),
5073
+ !!subtitle && /* @__PURE__ */ jsxRuntime.jsx(Paragraph, { className: "nebula-ds text-center", size: "sm", children: subtitle })
5074
+ ] });
5075
+ };
5076
+ ProfileImage.displayName = "ProfileImage";
4930
5077
 
4931
5078
  // src/tailwind.ts
4932
5079
  function content({ base = "./" } = {}) {
@@ -5030,6 +5177,7 @@ exports.Paragraph = Paragraph;
5030
5177
  exports.Popover = Popover;
5031
5178
  exports.PopoverContent = PopoverContent;
5032
5179
  exports.PopoverTrigger = PopoverTrigger;
5180
+ exports.ProfileImage = ProfileImage;
5033
5181
  exports.Select = StyledSelect;
5034
5182
  exports.Separator = Separator2;
5035
5183
  exports.Skeleton = Skeleton;
@@ -5069,4 +5217,7 @@ exports.setNebulaLanguage = setNebulaLanguage;
5069
5217
  exports.tagVariantsEnum = tagVariantsEnum;
5070
5218
  exports.tailwind = tailwind;
5071
5219
  exports.toast = toast;
5220
+ exports.useClickOutside = useClickOutside;
5221
+ exports.useFileUpload = useFileUpload;
5222
+ exports.useKeyPress = useKeyPress;
5072
5223
  exports.useNebulaI18n = useNebulaI18n;