@grupor5/raya 0.2.49 → 0.2.50

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
@@ -4133,13 +4133,21 @@ function DatePickerWithRange({
4133
4133
  ] })
4134
4134
  ] });
4135
4135
  }
4136
+ function applyDateMask(raw) {
4137
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
4138
+ if (digits.length <= 2) return digits;
4139
+ if (digits.length <= 4) return digits.slice(0, 2) + "/" + digits.slice(2);
4140
+ return digits.slice(0, 2) + "/" + digits.slice(2, 4) + "/" + digits.slice(4);
4141
+ }
4136
4142
  function DatePickerSingle({
4137
4143
  className,
4138
4144
  date,
4139
4145
  onDateChange,
4140
4146
  label,
4141
4147
  placeholder = "dd/mm/aa",
4142
- error
4148
+ error,
4149
+ minDate,
4150
+ maxDate
4143
4151
  }) {
4144
4152
  const [month, setMonth] = React30__namespace.useState(date || /* @__PURE__ */ new Date());
4145
4153
  const [open, setOpen] = React30__namespace.useState(false);
@@ -4148,7 +4156,20 @@ function DatePickerSingle({
4148
4156
  setInputValue(date ? dateFns.format(date, "dd/MM/yyyy") : "");
4149
4157
  }, [date]);
4150
4158
  const handleInputChange = (e) => {
4151
- setInputValue(e.target.value);
4159
+ setInputValue(applyDateMask(e.target.value));
4160
+ };
4161
+ const isDateInRange = (d) => {
4162
+ if (minDate) {
4163
+ const min = new Date(minDate);
4164
+ min.setHours(0, 0, 0, 0);
4165
+ if (d < min) return false;
4166
+ }
4167
+ if (maxDate) {
4168
+ const max = new Date(maxDate);
4169
+ max.setHours(23, 59, 59, 999);
4170
+ if (d > max) return false;
4171
+ }
4172
+ return true;
4152
4173
  };
4153
4174
  const handleInputBlur = () => {
4154
4175
  if (inputValue === "") {
@@ -4157,7 +4178,7 @@ function DatePickerSingle({
4157
4178
  }
4158
4179
  if (inputValue.length !== 10) return;
4159
4180
  const parsed = dateFns.parse(inputValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
4160
- if (dateFns.isValid(parsed)) {
4181
+ if (dateFns.isValid(parsed) && isDateInRange(parsed)) {
4161
4182
  onDateChange(parsed);
4162
4183
  setMonth(parsed);
4163
4184
  }
@@ -4167,6 +4188,12 @@ function DatePickerSingle({
4167
4188
  if (selected) setMonth(selected);
4168
4189
  setOpen(false);
4169
4190
  };
4191
+ const disabledMatcher = React30__namespace.useMemo(() => {
4192
+ const matchers = [];
4193
+ if (minDate) matchers.push({ before: minDate });
4194
+ if (maxDate) matchers.push({ after: maxDate });
4195
+ return matchers.length > 0 ? matchers : void 0;
4196
+ }, [minDate, maxDate]);
4170
4197
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid gap-1", className), children: [
4171
4198
  label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-body-xs font-normal text-neutral-900", children: label }),
4172
4199
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
@@ -4202,7 +4229,8 @@ function DatePickerSingle({
4202
4229
  selected: date,
4203
4230
  onSelect: handleSelect,
4204
4231
  month,
4205
- onMonthChange: setMonth
4232
+ onMonthChange: setMonth,
4233
+ disabled: disabledMatcher
4206
4234
  }
4207
4235
  ) })
4208
4236
  ] })
@@ -4420,8 +4448,8 @@ var ProgressBar = React30__namespace.default.forwardRef(
4420
4448
  label ? "justify-between" : "justify-end"
4421
4449
  ),
4422
4450
  children: [
4423
- label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
4424
- showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-progress-bar-label font-normal", children: [
4451
+ label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
4452
+ showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
4425
4453
  Math.round(progress),
4426
4454
  "%"
4427
4455
  ] })
package/dist/index.mjs CHANGED
@@ -4102,13 +4102,21 @@ function DatePickerWithRange({
4102
4102
  ] })
4103
4103
  ] });
4104
4104
  }
4105
+ function applyDateMask(raw) {
4106
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
4107
+ if (digits.length <= 2) return digits;
4108
+ if (digits.length <= 4) return digits.slice(0, 2) + "/" + digits.slice(2);
4109
+ return digits.slice(0, 2) + "/" + digits.slice(2, 4) + "/" + digits.slice(4);
4110
+ }
4105
4111
  function DatePickerSingle({
4106
4112
  className,
4107
4113
  date,
4108
4114
  onDateChange,
4109
4115
  label,
4110
4116
  placeholder = "dd/mm/aa",
4111
- error
4117
+ error,
4118
+ minDate,
4119
+ maxDate
4112
4120
  }) {
4113
4121
  const [month, setMonth] = React30.useState(date || /* @__PURE__ */ new Date());
4114
4122
  const [open, setOpen] = React30.useState(false);
@@ -4117,7 +4125,20 @@ function DatePickerSingle({
4117
4125
  setInputValue(date ? format(date, "dd/MM/yyyy") : "");
4118
4126
  }, [date]);
4119
4127
  const handleInputChange = (e) => {
4120
- setInputValue(e.target.value);
4128
+ setInputValue(applyDateMask(e.target.value));
4129
+ };
4130
+ const isDateInRange = (d) => {
4131
+ if (minDate) {
4132
+ const min = new Date(minDate);
4133
+ min.setHours(0, 0, 0, 0);
4134
+ if (d < min) return false;
4135
+ }
4136
+ if (maxDate) {
4137
+ const max = new Date(maxDate);
4138
+ max.setHours(23, 59, 59, 999);
4139
+ if (d > max) return false;
4140
+ }
4141
+ return true;
4121
4142
  };
4122
4143
  const handleInputBlur = () => {
4123
4144
  if (inputValue === "") {
@@ -4126,7 +4147,7 @@ function DatePickerSingle({
4126
4147
  }
4127
4148
  if (inputValue.length !== 10) return;
4128
4149
  const parsed = parse(inputValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
4129
- if (isValid(parsed)) {
4150
+ if (isValid(parsed) && isDateInRange(parsed)) {
4130
4151
  onDateChange(parsed);
4131
4152
  setMonth(parsed);
4132
4153
  }
@@ -4136,6 +4157,12 @@ function DatePickerSingle({
4136
4157
  if (selected) setMonth(selected);
4137
4158
  setOpen(false);
4138
4159
  };
4160
+ const disabledMatcher = React30.useMemo(() => {
4161
+ const matchers = [];
4162
+ if (minDate) matchers.push({ before: minDate });
4163
+ if (maxDate) matchers.push({ after: maxDate });
4164
+ return matchers.length > 0 ? matchers : void 0;
4165
+ }, [minDate, maxDate]);
4139
4166
  return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-1", className), children: [
4140
4167
  label && /* @__PURE__ */ jsx("label", { className: "text-body-xs font-normal text-neutral-900", children: label }),
4141
4168
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
@@ -4171,7 +4198,8 @@ function DatePickerSingle({
4171
4198
  selected: date,
4172
4199
  onSelect: handleSelect,
4173
4200
  month,
4174
- onMonthChange: setMonth
4201
+ onMonthChange: setMonth,
4202
+ disabled: disabledMatcher
4175
4203
  }
4176
4204
  ) })
4177
4205
  ] })
@@ -4389,8 +4417,8 @@ var ProgressBar = React30__default.forwardRef(
4389
4417
  label ? "justify-between" : "justify-end"
4390
4418
  ),
4391
4419
  children: [
4392
- label && /* @__PURE__ */ jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
4393
- showPercentage && /* @__PURE__ */ jsxs("span", { className: "text-progress-bar-label font-normal", children: [
4420
+ label && /* @__PURE__ */ jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
4421
+ showPercentage && /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
4394
4422
  Math.round(progress),
4395
4423
  "%"
4396
4424
  ] })
@@ -16,7 +16,9 @@ interface DatePickerSingleProps {
16
16
  label?: string;
17
17
  placeholder?: string;
18
18
  error?: string | boolean;
19
+ minDate?: Date;
20
+ maxDate?: Date;
19
21
  }
20
- declare function DatePickerSingle({ className, date, onDateChange, label, placeholder, error, }: DatePickerSingleProps): react_jsx_runtime.JSX.Element;
22
+ declare function DatePickerSingle({ className, date, onDateChange, label, placeholder, error, minDate, maxDate, }: DatePickerSingleProps): react_jsx_runtime.JSX.Element;
21
23
 
22
24
  export { DatePickerSingle, type DatePickerSingleProps, DatePickerWithRange, type DatePickerWithRangeProps };
@@ -16,7 +16,9 @@ interface DatePickerSingleProps {
16
16
  label?: string;
17
17
  placeholder?: string;
18
18
  error?: string | boolean;
19
+ minDate?: Date;
20
+ maxDate?: Date;
19
21
  }
20
- declare function DatePickerSingle({ className, date, onDateChange, label, placeholder, error, }: DatePickerSingleProps): react_jsx_runtime.JSX.Element;
22
+ declare function DatePickerSingle({ className, date, onDateChange, label, placeholder, error, minDate, maxDate, }: DatePickerSingleProps): react_jsx_runtime.JSX.Element;
21
23
 
22
24
  export { DatePickerSingle, type DatePickerSingleProps, DatePickerWithRange, type DatePickerWithRangeProps };
@@ -778,13 +778,21 @@ function DatePickerWithRange({
778
778
  ] })
779
779
  ] });
780
780
  }
781
+ function applyDateMask(raw) {
782
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
783
+ if (digits.length <= 2) return digits;
784
+ if (digits.length <= 4) return digits.slice(0, 2) + "/" + digits.slice(2);
785
+ return digits.slice(0, 2) + "/" + digits.slice(2, 4) + "/" + digits.slice(4);
786
+ }
781
787
  function DatePickerSingle({
782
788
  className,
783
789
  date,
784
790
  onDateChange,
785
791
  label,
786
792
  placeholder = "dd/mm/aa",
787
- error
793
+ error,
794
+ minDate,
795
+ maxDate
788
796
  }) {
789
797
  const [month, setMonth] = React2__namespace.useState(date || /* @__PURE__ */ new Date());
790
798
  const [open, setOpen] = React2__namespace.useState(false);
@@ -793,7 +801,20 @@ function DatePickerSingle({
793
801
  setInputValue(date ? dateFns.format(date, "dd/MM/yyyy") : "");
794
802
  }, [date]);
795
803
  const handleInputChange = (e) => {
796
- setInputValue(e.target.value);
804
+ setInputValue(applyDateMask(e.target.value));
805
+ };
806
+ const isDateInRange = (d) => {
807
+ if (minDate) {
808
+ const min = new Date(minDate);
809
+ min.setHours(0, 0, 0, 0);
810
+ if (d < min) return false;
811
+ }
812
+ if (maxDate) {
813
+ const max = new Date(maxDate);
814
+ max.setHours(23, 59, 59, 999);
815
+ if (d > max) return false;
816
+ }
817
+ return true;
797
818
  };
798
819
  const handleInputBlur = () => {
799
820
  if (inputValue === "") {
@@ -802,7 +823,7 @@ function DatePickerSingle({
802
823
  }
803
824
  if (inputValue.length !== 10) return;
804
825
  const parsed = dateFns.parse(inputValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
805
- if (dateFns.isValid(parsed)) {
826
+ if (dateFns.isValid(parsed) && isDateInRange(parsed)) {
806
827
  onDateChange(parsed);
807
828
  setMonth(parsed);
808
829
  }
@@ -812,6 +833,12 @@ function DatePickerSingle({
812
833
  if (selected) setMonth(selected);
813
834
  setOpen(false);
814
835
  };
836
+ const disabledMatcher = React2__namespace.useMemo(() => {
837
+ const matchers = [];
838
+ if (minDate) matchers.push({ before: minDate });
839
+ if (maxDate) matchers.push({ after: maxDate });
840
+ return matchers.length > 0 ? matchers : void 0;
841
+ }, [minDate, maxDate]);
815
842
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid gap-1", className), children: [
816
843
  label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-body-xs font-normal text-neutral-900", children: label }),
817
844
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
@@ -847,7 +874,8 @@ function DatePickerSingle({
847
874
  selected: date,
848
875
  onSelect: handleSelect,
849
876
  month,
850
- onMonthChange: setMonth
877
+ onMonthChange: setMonth,
878
+ disabled: disabledMatcher
851
879
  }
852
880
  ) })
853
881
  ] })
@@ -756,13 +756,21 @@ function DatePickerWithRange({
756
756
  ] })
757
757
  ] });
758
758
  }
759
+ function applyDateMask(raw) {
760
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
761
+ if (digits.length <= 2) return digits;
762
+ if (digits.length <= 4) return digits.slice(0, 2) + "/" + digits.slice(2);
763
+ return digits.slice(0, 2) + "/" + digits.slice(2, 4) + "/" + digits.slice(4);
764
+ }
759
765
  function DatePickerSingle({
760
766
  className,
761
767
  date,
762
768
  onDateChange,
763
769
  label,
764
770
  placeholder = "dd/mm/aa",
765
- error
771
+ error,
772
+ minDate,
773
+ maxDate
766
774
  }) {
767
775
  const [month, setMonth] = React2.useState(date || /* @__PURE__ */ new Date());
768
776
  const [open, setOpen] = React2.useState(false);
@@ -771,7 +779,20 @@ function DatePickerSingle({
771
779
  setInputValue(date ? format(date, "dd/MM/yyyy") : "");
772
780
  }, [date]);
773
781
  const handleInputChange = (e) => {
774
- setInputValue(e.target.value);
782
+ setInputValue(applyDateMask(e.target.value));
783
+ };
784
+ const isDateInRange = (d) => {
785
+ if (minDate) {
786
+ const min = new Date(minDate);
787
+ min.setHours(0, 0, 0, 0);
788
+ if (d < min) return false;
789
+ }
790
+ if (maxDate) {
791
+ const max = new Date(maxDate);
792
+ max.setHours(23, 59, 59, 999);
793
+ if (d > max) return false;
794
+ }
795
+ return true;
775
796
  };
776
797
  const handleInputBlur = () => {
777
798
  if (inputValue === "") {
@@ -780,7 +801,7 @@ function DatePickerSingle({
780
801
  }
781
802
  if (inputValue.length !== 10) return;
782
803
  const parsed = parse(inputValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
783
- if (isValid(parsed)) {
804
+ if (isValid(parsed) && isDateInRange(parsed)) {
784
805
  onDateChange(parsed);
785
806
  setMonth(parsed);
786
807
  }
@@ -790,6 +811,12 @@ function DatePickerSingle({
790
811
  if (selected) setMonth(selected);
791
812
  setOpen(false);
792
813
  };
814
+ const disabledMatcher = React2.useMemo(() => {
815
+ const matchers = [];
816
+ if (minDate) matchers.push({ before: minDate });
817
+ if (maxDate) matchers.push({ after: maxDate });
818
+ return matchers.length > 0 ? matchers : void 0;
819
+ }, [minDate, maxDate]);
793
820
  return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-1", className), children: [
794
821
  label && /* @__PURE__ */ jsx("label", { className: "text-body-xs font-normal text-neutral-900", children: label }),
795
822
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
@@ -825,7 +852,8 @@ function DatePickerSingle({
825
852
  selected: date,
826
853
  onSelect: handleSelect,
827
854
  month,
828
- onMonthChange: setMonth
855
+ onMonthChange: setMonth,
856
+ disabled: disabledMatcher
829
857
  }
830
858
  ) })
831
859
  ] })
@@ -406,8 +406,8 @@ var ProgressBar = React4__namespace.default.forwardRef(
406
406
  label ? "justify-between" : "justify-end"
407
407
  ),
408
408
  children: [
409
- label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
410
- showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-progress-bar-label font-normal", children: [
409
+ label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
410
+ showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
411
411
  Math.round(progress),
412
412
  "%"
413
413
  ] })
@@ -384,8 +384,8 @@ var ProgressBar = React4__default.forwardRef(
384
384
  label ? "justify-between" : "justify-end"
385
385
  ),
386
386
  children: [
387
- label && /* @__PURE__ */ jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
388
- showPercentage && /* @__PURE__ */ jsxs("span", { className: "text-progress-bar-label font-normal", children: [
387
+ label && /* @__PURE__ */ jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
388
+ showPercentage && /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
389
389
  Math.round(progress),
390
390
  "%"
391
391
  ] })
@@ -141,8 +141,8 @@ var ProgressBar = React__namespace.default.forwardRef(
141
141
  label ? "justify-between" : "justify-end"
142
142
  ),
143
143
  children: [
144
- label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
145
- showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-progress-bar-label font-normal", children: [
144
+ label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
145
+ showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
146
146
  Math.round(progress),
147
147
  "%"
148
148
  ] })
@@ -119,8 +119,8 @@ var ProgressBar = React__default.forwardRef(
119
119
  label ? "justify-between" : "justify-end"
120
120
  ),
121
121
  children: [
122
- label && /* @__PURE__ */ jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
123
- showPercentage && /* @__PURE__ */ jsxs("span", { className: "text-progress-bar-label font-normal", children: [
122
+ label && /* @__PURE__ */ jsx(Label, { className: "truncate min-w-0 text-progress-bar-label font-normal", children: label }),
123
+ showPercentage && /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-progress-bar-label font-normal", children: [
124
124
  Math.round(progress),
125
125
  "%"
126
126
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grupor5/raya",
3
- "version": "0.2.49",
3
+ "version": "0.2.50",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",