@ikatec/nebula-react 1.0.18 → 1.0.20

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.mts CHANGED
@@ -591,8 +591,9 @@ interface InputDatePickerSingleProps extends Omit<InputTextProps, 'onChange' | '
591
591
  numberOfMonths?: CalendarProps['numberOfMonths'];
592
592
  portal?: PopoverContentProps['portal'];
593
593
  placeholder?: string;
594
- className: InputTextProps['className'];
594
+ className?: string;
595
595
  disabledDates?: CalendarProps['disabled'];
596
+ onClean?: VoidFunction;
596
597
  }
597
598
  declare const dateIsAvailable: (inputDate?: Date | null, disabledDates?: InputDatePickerSingleProps["disabledDates"]) => boolean;
598
599
  declare const InputDatePickerSingle: ({ portal, placeholder, className, value, onChange, numberOfMonths, onClean, disabledDates, ...rest }: InputDatePickerSingleProps) => react_jsx_runtime.JSX.Element;
@@ -603,8 +604,9 @@ interface InputDateTimePickerSingleProps extends Omit<InputTextProps, 'onChange'
603
604
  numberOfMonths?: CalendarProps['numberOfMonths'];
604
605
  portal?: PopoverContentProps['portal'];
605
606
  placeholder?: string;
606
- className: InputTextProps['className'];
607
+ className?: string;
607
608
  disabledDates?: CalendarProps['disabled'];
609
+ onClean?: VoidFunction;
608
610
  }
609
611
  declare const InputDateTimePickerSingle: ({ portal, placeholder, className, value, onChange, numberOfMonths, onClean, disabledDates, ...rest }: InputDateTimePickerSingleProps) => react_jsx_runtime.JSX.Element;
610
612
 
package/dist/index.d.ts CHANGED
@@ -591,8 +591,9 @@ interface InputDatePickerSingleProps extends Omit<InputTextProps, 'onChange' | '
591
591
  numberOfMonths?: CalendarProps['numberOfMonths'];
592
592
  portal?: PopoverContentProps['portal'];
593
593
  placeholder?: string;
594
- className: InputTextProps['className'];
594
+ className?: string;
595
595
  disabledDates?: CalendarProps['disabled'];
596
+ onClean?: VoidFunction;
596
597
  }
597
598
  declare const dateIsAvailable: (inputDate?: Date | null, disabledDates?: InputDatePickerSingleProps["disabledDates"]) => boolean;
598
599
  declare const InputDatePickerSingle: ({ portal, placeholder, className, value, onChange, numberOfMonths, onClean, disabledDates, ...rest }: InputDatePickerSingleProps) => react_jsx_runtime.JSX.Element;
@@ -603,8 +604,9 @@ interface InputDateTimePickerSingleProps extends Omit<InputTextProps, 'onChange'
603
604
  numberOfMonths?: CalendarProps['numberOfMonths'];
604
605
  portal?: PopoverContentProps['portal'];
605
606
  placeholder?: string;
606
- className: InputTextProps['className'];
607
+ className?: string;
607
608
  disabledDates?: CalendarProps['disabled'];
609
+ onClean?: VoidFunction;
608
610
  }
609
611
  declare const InputDateTimePickerSingle: ({ portal, placeholder, className, value, onChange, numberOfMonths, onClean, disabledDates, ...rest }: InputDateTimePickerSingleProps) => react_jsx_runtime.JSX.Element;
610
612
 
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ var flags = require('react-phone-number-input/flags');
27
27
  var dateFns = require('date-fns');
28
28
  var reactDayPicker = require('react-day-picker');
29
29
  var locale = require('react-day-picker/locale');
30
+ var mask = require('@react-input/mask');
30
31
 
31
32
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
32
33
 
@@ -3917,6 +3918,25 @@ function timeFormatIsValid(timeStr) {
3917
3918
  const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
3918
3919
  return regex.test(timeStr);
3919
3920
  }
3921
+ var formatDateToSubmit = (dateStr, timeFallback = "23:59") => {
3922
+ try {
3923
+ if (!dateStr) return;
3924
+ const [date = "", time = timeFallback] = dateStr.split(" ");
3925
+ if (!date) return;
3926
+ const [p1, p2, p3] = date.split("/");
3927
+ const parsedDate = new Date(
3928
+ (() => {
3929
+ if (getNebulaLanguage() === "en-US") {
3930
+ return [p3, p1, p2].join("/") + " " + time;
3931
+ }
3932
+ return [p3, p2, p1].join("/") + " " + time;
3933
+ })().trim()
3934
+ ).toString();
3935
+ return dateFns.isValid(new Date(parsedDate)) ? parsedDate : void 0;
3936
+ } catch (error2) {
3937
+ return void 0;
3938
+ }
3939
+ };
3920
3940
  var dateIsAvailable = (inputDate, disabledDates) => {
3921
3941
  if (!disabledDates || !inputDate) return true;
3922
3942
  const dateIsDisabled = (d, matcher) => {
@@ -3974,10 +3994,11 @@ var InputDatePickerSingle = ({
3974
3994
  disabledDates,
3975
3995
  ...rest
3976
3996
  }) => {
3977
- const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
3997
+ const formattedDateByLanguage = formatDateToSubmit(value ?? "");
3978
3998
  const [innerDate, setInnerDate] = React8.useState(
3979
- value ? new Date(value) : void 0
3999
+ formattedDateByLanguage ? new Date(formattedDateByLanguage) : void 0
3980
4000
  );
4001
+ const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
3981
4002
  const { locale } = useNebulaI18n();
3982
4003
  const [month, setMonth] = React8.useState(/* @__PURE__ */ new Date());
3983
4004
  const handleClearValue = () => {
@@ -4036,6 +4057,11 @@ var InputDatePickerSingle = ({
4036
4057
  React8.useEffect(() => {
4037
4058
  if (innerDate) setMonth(innerDate);
4038
4059
  }, [innerDate]);
4060
+ const maskOptions = {
4061
+ mask: "__/__/____",
4062
+ replacement: { _: /\d/ }
4063
+ };
4064
+ const inputRef = mask.useMask(maskOptions);
4039
4065
  return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4040
4066
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4041
4067
  "div",
@@ -4045,6 +4071,7 @@ var InputDatePickerSingle = ({
4045
4071
  children: /* @__PURE__ */ jsxRuntime.jsx(
4046
4072
  InputText,
4047
4073
  {
4074
+ ref: inputRef,
4048
4075
  placeholder,
4049
4076
  value,
4050
4077
  className,
@@ -4171,6 +4198,7 @@ var InputTime = React8.forwardRef(
4171
4198
  }
4172
4199
  );
4173
4200
  InputTime.displayName = "InputTime";
4201
+ var DATA_TIME_SEPARATOR = " - ";
4174
4202
  var InputDateTimePickerSingle = ({
4175
4203
  portal,
4176
4204
  placeholder,
@@ -4182,11 +4210,16 @@ var InputDateTimePickerSingle = ({
4182
4210
  disabledDates,
4183
4211
  ...rest
4184
4212
  }) => {
4185
- const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
4186
- const [innerTimeValue, setInnerTimeValue] = React8.useState();
4213
+ const [innerTimeValue, setInnerTimeValue] = React8.useState(
4214
+ value?.split?.(DATA_TIME_SEPARATOR)?.at?.(-1) ?? ""
4215
+ );
4216
+ const formattedDateByLanguage = formatDateToSubmit(
4217
+ value?.split(DATA_TIME_SEPARATOR)?.at(0) ?? ""
4218
+ );
4187
4219
  const [innerDate, setInnerDate] = React8.useState(
4188
- value ? new Date(value) : void 0
4220
+ formattedDateByLanguage ? new Date(formattedDateByLanguage) : void 0
4189
4221
  );
4222
+ const [popoverIsOpen, setPopoverIsOpen] = React8.useState(false);
4190
4223
  const { locale, messages: messages17 } = useNebulaI18n();
4191
4224
  const [month, setMonth] = React8.useState(/* @__PURE__ */ new Date());
4192
4225
  const inputTimeRef = React8.useRef(null);
@@ -4196,8 +4229,7 @@ var InputDateTimePickerSingle = ({
4196
4229
  setMonth(/* @__PURE__ */ new Date());
4197
4230
  };
4198
4231
  const handleInnerInputChange = (text) => {
4199
- const dateSlice = text.substring(0, 11).trim();
4200
- let hourSlice = text.substring(11).trim();
4232
+ let [dateSlice = "", hourSlice = ""] = text.split(DATA_TIME_SEPARATOR);
4201
4233
  if (!text) {
4202
4234
  onChange?.(text);
4203
4235
  handleClearValue();
@@ -4271,6 +4303,11 @@ var InputDateTimePickerSingle = ({
4271
4303
  React8.useEffect(() => {
4272
4304
  if (innerDate) setMonth(innerDate);
4273
4305
  }, [innerDate]);
4306
+ const maskOptions = {
4307
+ mask: "__/__/____ - __:__",
4308
+ replacement: { _: /\d/ }
4309
+ };
4310
+ const inputRef = mask.useMask(maskOptions);
4274
4311
  return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4275
4312
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4276
4313
  "div",
@@ -4280,6 +4317,7 @@ var InputDateTimePickerSingle = ({
4280
4317
  children: /* @__PURE__ */ jsxRuntime.jsx(
4281
4318
  InputText,
4282
4319
  {
4320
+ ref: inputRef,
4283
4321
  placeholder,
4284
4322
  value,
4285
4323
  className,
@@ -4305,7 +4343,6 @@ var InputDateTimePickerSingle = ({
4305
4343
  setPopoverIsOpen(true);
4306
4344
  }
4307
4345
  },
4308
- maxLength: 16,
4309
4346
  onClean: onClean ? () => {
4310
4347
  onClean();
4311
4348
  handleClearValue();
package/dist/index.mjs CHANGED
@@ -26,6 +26,7 @@ import flags from 'react-phone-number-input/flags';
26
26
  import { formatDate, isValid, addMonths, isSameDay, isBefore, isAfter } from 'date-fns';
27
27
  import { DayPicker } from 'react-day-picker';
28
28
  import { ptBR, enUS, es } from 'react-day-picker/locale';
29
+ import { useMask } from '@react-input/mask';
29
30
 
30
31
  // src/button.tsx
31
32
 
@@ -3877,6 +3878,25 @@ function timeFormatIsValid(timeStr) {
3877
3878
  const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
3878
3879
  return regex.test(timeStr);
3879
3880
  }
3881
+ var formatDateToSubmit = (dateStr, timeFallback = "23:59") => {
3882
+ try {
3883
+ if (!dateStr) return;
3884
+ const [date = "", time = timeFallback] = dateStr.split(" ");
3885
+ if (!date) return;
3886
+ const [p1, p2, p3] = date.split("/");
3887
+ const parsedDate = new Date(
3888
+ (() => {
3889
+ if (getNebulaLanguage() === "en-US") {
3890
+ return [p3, p1, p2].join("/") + " " + time;
3891
+ }
3892
+ return [p3, p2, p1].join("/") + " " + time;
3893
+ })().trim()
3894
+ ).toString();
3895
+ return isValid(new Date(parsedDate)) ? parsedDate : void 0;
3896
+ } catch (error2) {
3897
+ return void 0;
3898
+ }
3899
+ };
3880
3900
  var dateIsAvailable = (inputDate, disabledDates) => {
3881
3901
  if (!disabledDates || !inputDate) return true;
3882
3902
  const dateIsDisabled = (d, matcher) => {
@@ -3934,10 +3954,11 @@ var InputDatePickerSingle = ({
3934
3954
  disabledDates,
3935
3955
  ...rest
3936
3956
  }) => {
3937
- const [popoverIsOpen, setPopoverIsOpen] = useState(false);
3957
+ const formattedDateByLanguage = formatDateToSubmit(value ?? "");
3938
3958
  const [innerDate, setInnerDate] = useState(
3939
- value ? new Date(value) : void 0
3959
+ formattedDateByLanguage ? new Date(formattedDateByLanguage) : void 0
3940
3960
  );
3961
+ const [popoverIsOpen, setPopoverIsOpen] = useState(false);
3941
3962
  const { locale } = useNebulaI18n();
3942
3963
  const [month, setMonth] = useState(/* @__PURE__ */ new Date());
3943
3964
  const handleClearValue = () => {
@@ -3996,6 +4017,11 @@ var InputDatePickerSingle = ({
3996
4017
  useEffect(() => {
3997
4018
  if (innerDate) setMonth(innerDate);
3998
4019
  }, [innerDate]);
4020
+ const maskOptions = {
4021
+ mask: "__/__/____",
4022
+ replacement: { _: /\d/ }
4023
+ };
4024
+ const inputRef = useMask(maskOptions);
3999
4025
  return /* @__PURE__ */ jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4000
4026
  /* @__PURE__ */ jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsx(
4001
4027
  "div",
@@ -4005,6 +4031,7 @@ var InputDatePickerSingle = ({
4005
4031
  children: /* @__PURE__ */ jsx(
4006
4032
  InputText,
4007
4033
  {
4034
+ ref: inputRef,
4008
4035
  placeholder,
4009
4036
  value,
4010
4037
  className,
@@ -4131,6 +4158,7 @@ var InputTime = forwardRef(
4131
4158
  }
4132
4159
  );
4133
4160
  InputTime.displayName = "InputTime";
4161
+ var DATA_TIME_SEPARATOR = " - ";
4134
4162
  var InputDateTimePickerSingle = ({
4135
4163
  portal,
4136
4164
  placeholder,
@@ -4142,11 +4170,16 @@ var InputDateTimePickerSingle = ({
4142
4170
  disabledDates,
4143
4171
  ...rest
4144
4172
  }) => {
4145
- const [popoverIsOpen, setPopoverIsOpen] = useState(false);
4146
- const [innerTimeValue, setInnerTimeValue] = useState();
4173
+ const [innerTimeValue, setInnerTimeValue] = useState(
4174
+ value?.split?.(DATA_TIME_SEPARATOR)?.at?.(-1) ?? ""
4175
+ );
4176
+ const formattedDateByLanguage = formatDateToSubmit(
4177
+ value?.split(DATA_TIME_SEPARATOR)?.at(0) ?? ""
4178
+ );
4147
4179
  const [innerDate, setInnerDate] = useState(
4148
- value ? new Date(value) : void 0
4180
+ formattedDateByLanguage ? new Date(formattedDateByLanguage) : void 0
4149
4181
  );
4182
+ const [popoverIsOpen, setPopoverIsOpen] = useState(false);
4150
4183
  const { locale, messages: messages17 } = useNebulaI18n();
4151
4184
  const [month, setMonth] = useState(/* @__PURE__ */ new Date());
4152
4185
  const inputTimeRef = useRef(null);
@@ -4156,8 +4189,7 @@ var InputDateTimePickerSingle = ({
4156
4189
  setMonth(/* @__PURE__ */ new Date());
4157
4190
  };
4158
4191
  const handleInnerInputChange = (text) => {
4159
- const dateSlice = text.substring(0, 11).trim();
4160
- let hourSlice = text.substring(11).trim();
4192
+ let [dateSlice = "", hourSlice = ""] = text.split(DATA_TIME_SEPARATOR);
4161
4193
  if (!text) {
4162
4194
  onChange?.(text);
4163
4195
  handleClearValue();
@@ -4231,6 +4263,11 @@ var InputDateTimePickerSingle = ({
4231
4263
  useEffect(() => {
4232
4264
  if (innerDate) setMonth(innerDate);
4233
4265
  }, [innerDate]);
4266
+ const maskOptions = {
4267
+ mask: "__/__/____ - __:__",
4268
+ replacement: { _: /\d/ }
4269
+ };
4270
+ const inputRef = useMask(maskOptions);
4234
4271
  return /* @__PURE__ */ jsxs(Popover, { open: popoverIsOpen, onOpenChange: setPopoverIsOpen, children: [
4235
4272
  /* @__PURE__ */ jsx(PopoverTrigger, { className, asChild: true, children: /* @__PURE__ */ jsx(
4236
4273
  "div",
@@ -4240,6 +4277,7 @@ var InputDateTimePickerSingle = ({
4240
4277
  children: /* @__PURE__ */ jsx(
4241
4278
  InputText,
4242
4279
  {
4280
+ ref: inputRef,
4243
4281
  placeholder,
4244
4282
  value,
4245
4283
  className,
@@ -4265,7 +4303,6 @@ var InputDateTimePickerSingle = ({
4265
4303
  setPopoverIsOpen(true);
4266
4304
  }
4267
4305
  },
4268
- maxLength: 16,
4269
4306
  onClean: onClean ? () => {
4270
4307
  onClean();
4271
4308
  handleClearValue();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikatec/nebula-react",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "React components",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -50,18 +50,20 @@
50
50
  "@radix-ui/react-tabs": "^1.1.12",
51
51
  "@radix-ui/react-toggle": "^1.1.8",
52
52
  "@radix-ui/react-tooltip": "^1.2.6",
53
+ "@react-input/mask": "^2.0.4",
53
54
  "class-variance-authority": "^0.7.1",
55
+ "date-fns": "^4.1.0",
54
56
  "react-day-picker": "^9.8.1",
55
57
  "react-phone-number-input": "^3.4.12",
56
58
  "react-select": "^5.10.1",
57
59
  "sonner": "^2.0.5",
58
- "tailwind-merge": "^2.6.0",
59
- "date-fns": "^4.1.0"
60
+ "tailwind-merge": "^2.6.0"
60
61
  },
61
62
  "peerDependencies": {
62
- "react": "^18.3.1",
63
- "react-dom": "18.3.1",
63
+ "@react-input/mask": "^2.0.4",
64
64
  "date-fns": "^4.1.0",
65
- "lucide-react": "^0.454.0"
65
+ "lucide-react": "^0.454.0",
66
+ "react": "^18.3.1",
67
+ "react-dom": "18.3.1"
66
68
  }
67
69
  }