@underverse-ui/underverse 1.0.81 → 1.0.82

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,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 225,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -7099,7 +7099,6 @@ var getOptionDisabled = (option) => {
7099
7099
  var findOptionByValue = (options, value) => {
7100
7100
  return options.find((opt) => getOptionValue(opt) === value);
7101
7101
  };
7102
- var REQUIRED_ERROR_MESSAGE = "This field is required";
7103
7102
  var Combobox = ({
7104
7103
  id,
7105
7104
  options,
@@ -7129,6 +7128,7 @@ var Combobox = ({
7129
7128
  helperText,
7130
7129
  useOverlayScrollbar = false
7131
7130
  }) => {
7131
+ const tv = useSmartTranslations("ValidationInput");
7132
7132
  const [open, setOpen] = React24.useState(false);
7133
7133
  const [query, setQuery] = React24.useState("");
7134
7134
  const [activeIndex, setActiveIndex] = React24.useState(null);
@@ -7478,13 +7478,14 @@ var Combobox = ({
7478
7478
  {
7479
7479
  tabIndex: -1,
7480
7480
  "aria-hidden": "true",
7481
- readOnly: true,
7482
7481
  value: hasValue ? "selected" : "",
7482
+ onChange: () => {
7483
+ },
7483
7484
  required,
7484
7485
  disabled,
7485
7486
  onInvalid: (e) => {
7486
7487
  e.preventDefault();
7487
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE);
7488
+ setLocalRequiredError(tv("required"));
7488
7489
  },
7489
7490
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
7490
7491
  }
@@ -8196,7 +8197,6 @@ var import_lucide_react15 = require("lucide-react");
8196
8197
  var React28 = __toESM(require("react"), 1);
8197
8198
  var import_react19 = require("react");
8198
8199
  var import_jsx_runtime34 = require("react/jsx-runtime");
8199
- var REQUIRED_ERROR_MESSAGE2 = "This field is required";
8200
8200
  var DatePicker = ({
8201
8201
  id,
8202
8202
  value,
@@ -8216,6 +8216,7 @@ var DatePicker = ({
8216
8216
  maxDate
8217
8217
  }) => {
8218
8218
  const t = useSmartTranslations("DatePicker");
8219
+ const tv = useSmartTranslations("ValidationInput");
8219
8220
  const locale = useSmartLocale();
8220
8221
  const [isOpen, setIsOpen] = React28.useState(false);
8221
8222
  const [viewDate, setViewDate] = React28.useState(value || /* @__PURE__ */ new Date());
@@ -8633,13 +8634,14 @@ var DatePicker = ({
8633
8634
  {
8634
8635
  tabIndex: -1,
8635
8636
  "aria-hidden": "true",
8636
- readOnly: true,
8637
8637
  value: value ? "selected" : "",
8638
+ onChange: () => {
8639
+ },
8638
8640
  required,
8639
8641
  disabled,
8640
8642
  onInvalid: (e) => {
8641
8643
  e.preventDefault();
8642
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE2);
8644
+ setLocalRequiredError(tv("required"));
8643
8645
  },
8644
8646
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
8645
8647
  }
@@ -9092,7 +9094,6 @@ var React30 = __toESM(require("react"), 1);
9092
9094
  var React29 = __toESM(require("react"), 1);
9093
9095
  var import_lucide_react16 = require("lucide-react");
9094
9096
  var import_jsx_runtime35 = require("react/jsx-runtime");
9095
- var REQUIRED_ERROR_MESSAGE3 = "This field is required";
9096
9097
  var DEFAULT_MONTH_NAMES = [
9097
9098
  "January",
9098
9099
  "February",
@@ -9570,6 +9571,7 @@ function MonthYearPicker({
9570
9571
  className,
9571
9572
  ...rest
9572
9573
  }) {
9574
+ const tv = useSmartTranslations("ValidationInput");
9573
9575
  const now = /* @__PURE__ */ new Date();
9574
9576
  const currentYear = now.getFullYear();
9575
9577
  const resolvedMinYear = minYear ?? minDate?.getFullYear() ?? currentYear - 50;
@@ -9587,6 +9589,7 @@ function MonthYearPicker({
9587
9589
  const [parts, setParts] = React29.useState(initial);
9588
9590
  const [focusedColumn, setFocusedColumn] = React29.useState(null);
9589
9591
  const [localRequiredError, setLocalRequiredError] = React29.useState();
9592
+ const [hasCommittedValue, setHasCommittedValue] = React29.useState(Boolean(parseValue(isControlled ? value : defaultValue)));
9590
9593
  const monthScrollRef = React29.useRef(null);
9591
9594
  const yearScrollRef = React29.useRef(null);
9592
9595
  React29.useEffect(() => {
@@ -9595,7 +9598,12 @@ function MonthYearPicker({
9595
9598
  if (parsed) setParts(parsed);
9596
9599
  }
9597
9600
  }, [value, isControlled]);
9598
- const hasValue = isControlled ? !!value : !!defaultValue || parts !== initial;
9601
+ React29.useEffect(() => {
9602
+ if (isControlled) {
9603
+ setHasCommittedValue(Boolean(parseValue(value)));
9604
+ }
9605
+ }, [isControlled, value]);
9606
+ const hasValue = hasCommittedValue;
9599
9607
  const effectiveError = error ?? localRequiredError;
9600
9608
  React29.useEffect(() => {
9601
9609
  if (disabled || !required || hasValue) {
@@ -9626,15 +9634,17 @@ function MonthYearPicker({
9626
9634
  (next) => {
9627
9635
  if (!next) {
9628
9636
  setLocalRequiredError(void 0);
9637
+ if (!isControlled) setHasCommittedValue(false);
9629
9638
  onChange?.(void 0);
9630
9639
  return;
9631
9640
  }
9632
9641
  if (!isDateInRange(next.month, next.year)) return;
9633
9642
  const date = new Date(next.year, next.month, 1);
9634
9643
  setLocalRequiredError(void 0);
9644
+ if (!isControlled) setHasCommittedValue(true);
9635
9645
  onChange?.({ ...next, date });
9636
9646
  },
9637
- [isDateInRange, onChange]
9647
+ [isControlled, isDateInRange, onChange]
9638
9648
  );
9639
9649
  const tryUpdate = React29.useCallback(
9640
9650
  (next) => {
@@ -9882,13 +9892,14 @@ function MonthYearPicker({
9882
9892
  {
9883
9893
  tabIndex: -1,
9884
9894
  "aria-hidden": "true",
9885
- readOnly: true,
9886
9895
  value: hasValue ? "selected" : "",
9896
+ onChange: () => {
9897
+ },
9887
9898
  required,
9888
9899
  disabled,
9889
9900
  onInvalid: (e) => {
9890
9901
  e.preventDefault();
9891
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE3);
9902
+ setLocalRequiredError(tv("required"));
9892
9903
  },
9893
9904
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
9894
9905
  }
@@ -9917,13 +9928,14 @@ function MonthYearPicker({
9917
9928
  {
9918
9929
  tabIndex: -1,
9919
9930
  "aria-hidden": "true",
9920
- readOnly: true,
9921
9931
  value: hasValue ? "selected" : "",
9932
+ onChange: () => {
9933
+ },
9922
9934
  required,
9923
9935
  disabled,
9924
9936
  onInvalid: (e) => {
9925
9937
  e.preventDefault();
9926
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE3);
9938
+ setLocalRequiredError(tv("required"));
9927
9939
  },
9928
9940
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
9929
9941
  }
@@ -10599,7 +10611,6 @@ function Calendar3({
10599
10611
  var React31 = __toESM(require("react"), 1);
10600
10612
  var import_lucide_react18 = require("lucide-react");
10601
10613
  var import_jsx_runtime37 = require("react/jsx-runtime");
10602
- var REQUIRED_ERROR_MESSAGE4 = "This field is required";
10603
10614
  var pad = (n) => n.toString().padStart(2, "0");
10604
10615
  var clamp4 = (n, min, max) => Math.min(max, Math.max(min, n));
10605
10616
  var WHEEL_ITEM_HEIGHT2 = {
@@ -11083,6 +11094,7 @@ function TimePicker({
11083
11094
  className,
11084
11095
  ...rest
11085
11096
  }) {
11097
+ const tv = useSmartTranslations("ValidationInput");
11086
11098
  const isControlled = value !== void 0;
11087
11099
  const now = /* @__PURE__ */ new Date();
11088
11100
  const initial = parseTime(isControlled ? value : defaultValue, format, includeSeconds) || (format === "12" ? { h: now.getHours() % 12 || 12, m: now.getMinutes(), s: now.getSeconds(), p: now.getHours() >= 12 ? "PM" : "AM" } : { h: now.getHours(), m: now.getMinutes(), s: now.getSeconds() });
@@ -11663,13 +11675,14 @@ function TimePicker({
11663
11675
  {
11664
11676
  tabIndex: -1,
11665
11677
  "aria-hidden": "true",
11666
- readOnly: true,
11667
11678
  value: hasCommittedValue ? "selected" : "",
11679
+ onChange: () => {
11680
+ },
11668
11681
  required,
11669
11682
  disabled,
11670
11683
  onInvalid: (e) => {
11671
11684
  e.preventDefault();
11672
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE4);
11685
+ setLocalRequiredError(tv("required"));
11673
11686
  },
11674
11687
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11675
11688
  }
@@ -11712,13 +11725,14 @@ function TimePicker({
11712
11725
  {
11713
11726
  tabIndex: -1,
11714
11727
  "aria-hidden": "true",
11715
- readOnly: true,
11716
11728
  value: hasCommittedValue ? "selected" : "",
11729
+ onChange: () => {
11730
+ },
11717
11731
  required,
11718
11732
  disabled,
11719
11733
  onInvalid: (e) => {
11720
11734
  e.preventDefault();
11721
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE4);
11735
+ setLocalRequiredError(tv("required"));
11722
11736
  },
11723
11737
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11724
11738
  }
@@ -11760,7 +11774,6 @@ function TimePicker({
11760
11774
 
11761
11775
  // src/components/DateTimePicker.tsx
11762
11776
  var import_jsx_runtime38 = require("react/jsx-runtime");
11763
- var REQUIRED_ERROR_MESSAGE5 = "This field is required";
11764
11777
  var DateTimePicker = ({
11765
11778
  value,
11766
11779
  onChange,
@@ -11779,6 +11792,7 @@ var DateTimePicker = ({
11779
11792
  size = "md"
11780
11793
  }) => {
11781
11794
  const t = useSmartTranslations("DateTimePicker");
11795
+ const tv = useSmartTranslations("ValidationInput");
11782
11796
  const locale = useSmartLocale();
11783
11797
  const [open, setOpen] = React32.useState(false);
11784
11798
  const [localRequiredError, setLocalRequiredError] = React32.useState();
@@ -11930,13 +11944,14 @@ var DateTimePicker = ({
11930
11944
  {
11931
11945
  tabIndex: -1,
11932
11946
  "aria-hidden": "true",
11933
- readOnly: true,
11934
11947
  value: value ? "selected" : "",
11948
+ onChange: () => {
11949
+ },
11935
11950
  required,
11936
11951
  disabled,
11937
11952
  onInvalid: (e) => {
11938
11953
  e.preventDefault();
11939
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE5);
11954
+ setLocalRequiredError(tv("required"));
11940
11955
  },
11941
11956
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11942
11957
  }
@@ -14957,7 +14972,6 @@ var React39 = __toESM(require("react"), 1);
14957
14972
  var import_react20 = require("react");
14958
14973
  var import_lucide_react24 = require("lucide-react");
14959
14974
  var import_jsx_runtime45 = require("react/jsx-runtime");
14960
- var REQUIRED_ERROR_MESSAGE6 = "This field is required";
14961
14975
  var MultiCombobox = ({
14962
14976
  id,
14963
14977
  options,
@@ -14991,6 +15005,7 @@ var MultiCombobox = ({
14991
15005
  maxTagsVisible = 3,
14992
15006
  useOverlayScrollbar = false
14993
15007
  }) => {
15008
+ const tv = useSmartTranslations("ValidationInput");
14994
15009
  const [query, setQuery] = React39.useState("");
14995
15010
  const [open, setOpen] = React39.useState(false);
14996
15011
  const [activeIndex, setActiveIndex] = React39.useState(null);
@@ -15404,13 +15419,14 @@ var MultiCombobox = ({
15404
15419
  {
15405
15420
  tabIndex: -1,
15406
15421
  "aria-hidden": "true",
15407
- readOnly: true,
15408
15422
  value: value.length > 0 ? "selected" : "",
15423
+ onChange: () => {
15424
+ },
15409
15425
  required,
15410
15426
  disabled,
15411
15427
  onInvalid: (e) => {
15412
15428
  e.preventDefault();
15413
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE6);
15429
+ setLocalRequiredError(tv("required"));
15414
15430
  },
15415
15431
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
15416
15432
  }
@@ -16585,7 +16601,6 @@ var defaultLabels = {
16585
16601
  searchPlaceholder: "Search...",
16586
16602
  noResultsText: "No results found"
16587
16603
  };
16588
- var REQUIRED_ERROR_MESSAGE7 = "This field is required";
16589
16604
  function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline) {
16590
16605
  if (!(viewOnly || inline) || !defaultExpanded) return /* @__PURE__ */ new Set();
16591
16606
  const parentIds = /* @__PURE__ */ new Set();
@@ -16597,6 +16612,7 @@ function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline)
16597
16612
  return parentIds;
16598
16613
  }
16599
16614
  function CategoryTreeSelect(props) {
16615
+ const tv = useSmartTranslations("ValidationInput");
16600
16616
  const {
16601
16617
  id,
16602
16618
  label,
@@ -16917,13 +16933,14 @@ function CategoryTreeSelect(props) {
16917
16933
  {
16918
16934
  tabIndex: -1,
16919
16935
  "aria-hidden": "true",
16920
- readOnly: true,
16921
16936
  value: valueArray.length > 0 ? "selected" : "",
16937
+ onChange: () => {
16938
+ },
16922
16939
  required,
16923
16940
  disabled,
16924
16941
  onInvalid: (e) => {
16925
16942
  e.preventDefault();
16926
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
16943
+ setLocalRequiredError(tv("required"));
16927
16944
  },
16928
16945
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
16929
16946
  }
@@ -16952,13 +16969,14 @@ function CategoryTreeSelect(props) {
16952
16969
  {
16953
16970
  tabIndex: -1,
16954
16971
  "aria-hidden": "true",
16955
- readOnly: true,
16956
16972
  value: valueArray.length > 0 ? "selected" : "",
16973
+ onChange: () => {
16974
+ },
16957
16975
  required,
16958
16976
  disabled,
16959
16977
  onInvalid: (e) => {
16960
16978
  e.preventDefault();
16961
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
16979
+ setLocalRequiredError(tv("required"));
16962
16980
  },
16963
16981
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
16964
16982
  }
@@ -17067,13 +17085,14 @@ function CategoryTreeSelect(props) {
17067
17085
  {
17068
17086
  tabIndex: -1,
17069
17087
  "aria-hidden": "true",
17070
- readOnly: true,
17071
17088
  value: valueArray.length > 0 ? "selected" : "",
17089
+ onChange: () => {
17090
+ },
17072
17091
  required,
17073
17092
  disabled,
17074
17093
  onInvalid: (e) => {
17075
17094
  e.preventDefault();
17076
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
17095
+ setLocalRequiredError(tv("required"));
17077
17096
  },
17078
17097
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
17079
17098
  }