@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.
package/dist/index.js CHANGED
@@ -6914,7 +6914,6 @@ var getOptionDisabled = (option) => {
6914
6914
  var findOptionByValue = (options, value) => {
6915
6915
  return options.find((opt) => getOptionValue(opt) === value);
6916
6916
  };
6917
- var REQUIRED_ERROR_MESSAGE = "This field is required";
6918
6917
  var Combobox = ({
6919
6918
  id,
6920
6919
  options,
@@ -6944,6 +6943,7 @@ var Combobox = ({
6944
6943
  helperText,
6945
6944
  useOverlayScrollbar = false
6946
6945
  }) => {
6946
+ const tv = useSmartTranslations("ValidationInput");
6947
6947
  const [open, setOpen] = React24.useState(false);
6948
6948
  const [query, setQuery] = React24.useState("");
6949
6949
  const [activeIndex, setActiveIndex] = React24.useState(null);
@@ -7293,13 +7293,14 @@ var Combobox = ({
7293
7293
  {
7294
7294
  tabIndex: -1,
7295
7295
  "aria-hidden": "true",
7296
- readOnly: true,
7297
7296
  value: hasValue ? "selected" : "",
7297
+ onChange: () => {
7298
+ },
7298
7299
  required,
7299
7300
  disabled,
7300
7301
  onInvalid: (e) => {
7301
7302
  e.preventDefault();
7302
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE);
7303
+ setLocalRequiredError(tv("required"));
7303
7304
  },
7304
7305
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
7305
7306
  }
@@ -8011,7 +8012,6 @@ import { Calendar, ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight3, S
8011
8012
  import * as React28 from "react";
8012
8013
  import { useId as useId6 } from "react";
8013
8014
  import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
8014
- var REQUIRED_ERROR_MESSAGE2 = "This field is required";
8015
8015
  var DatePicker = ({
8016
8016
  id,
8017
8017
  value,
@@ -8031,6 +8031,7 @@ var DatePicker = ({
8031
8031
  maxDate
8032
8032
  }) => {
8033
8033
  const t = useSmartTranslations("DatePicker");
8034
+ const tv = useSmartTranslations("ValidationInput");
8034
8035
  const locale = useSmartLocale();
8035
8036
  const [isOpen, setIsOpen] = React28.useState(false);
8036
8037
  const [viewDate, setViewDate] = React28.useState(value || /* @__PURE__ */ new Date());
@@ -8448,13 +8449,14 @@ var DatePicker = ({
8448
8449
  {
8449
8450
  tabIndex: -1,
8450
8451
  "aria-hidden": "true",
8451
- readOnly: true,
8452
8452
  value: value ? "selected" : "",
8453
+ onChange: () => {
8454
+ },
8453
8455
  required,
8454
8456
  disabled,
8455
8457
  onInvalid: (e) => {
8456
8458
  e.preventDefault();
8457
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE2);
8459
+ setLocalRequiredError(tv("required"));
8458
8460
  },
8459
8461
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
8460
8462
  }
@@ -8907,7 +8909,6 @@ import * as React30 from "react";
8907
8909
  import * as React29 from "react";
8908
8910
  import { Calendar as Calendar2, X as X10, Check as Check4, ChevronDown as ChevronDown2 } from "lucide-react";
8909
8911
  import { jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
8910
- var REQUIRED_ERROR_MESSAGE3 = "This field is required";
8911
8912
  var DEFAULT_MONTH_NAMES = [
8912
8913
  "January",
8913
8914
  "February",
@@ -9385,6 +9386,7 @@ function MonthYearPicker({
9385
9386
  className,
9386
9387
  ...rest
9387
9388
  }) {
9389
+ const tv = useSmartTranslations("ValidationInput");
9388
9390
  const now = /* @__PURE__ */ new Date();
9389
9391
  const currentYear = now.getFullYear();
9390
9392
  const resolvedMinYear = minYear ?? minDate?.getFullYear() ?? currentYear - 50;
@@ -9402,6 +9404,7 @@ function MonthYearPicker({
9402
9404
  const [parts, setParts] = React29.useState(initial);
9403
9405
  const [focusedColumn, setFocusedColumn] = React29.useState(null);
9404
9406
  const [localRequiredError, setLocalRequiredError] = React29.useState();
9407
+ const [hasCommittedValue, setHasCommittedValue] = React29.useState(Boolean(parseValue(isControlled ? value : defaultValue)));
9405
9408
  const monthScrollRef = React29.useRef(null);
9406
9409
  const yearScrollRef = React29.useRef(null);
9407
9410
  React29.useEffect(() => {
@@ -9410,7 +9413,12 @@ function MonthYearPicker({
9410
9413
  if (parsed) setParts(parsed);
9411
9414
  }
9412
9415
  }, [value, isControlled]);
9413
- const hasValue = isControlled ? !!value : !!defaultValue || parts !== initial;
9416
+ React29.useEffect(() => {
9417
+ if (isControlled) {
9418
+ setHasCommittedValue(Boolean(parseValue(value)));
9419
+ }
9420
+ }, [isControlled, value]);
9421
+ const hasValue = hasCommittedValue;
9414
9422
  const effectiveError = error ?? localRequiredError;
9415
9423
  React29.useEffect(() => {
9416
9424
  if (disabled || !required || hasValue) {
@@ -9441,15 +9449,17 @@ function MonthYearPicker({
9441
9449
  (next) => {
9442
9450
  if (!next) {
9443
9451
  setLocalRequiredError(void 0);
9452
+ if (!isControlled) setHasCommittedValue(false);
9444
9453
  onChange?.(void 0);
9445
9454
  return;
9446
9455
  }
9447
9456
  if (!isDateInRange(next.month, next.year)) return;
9448
9457
  const date = new Date(next.year, next.month, 1);
9449
9458
  setLocalRequiredError(void 0);
9459
+ if (!isControlled) setHasCommittedValue(true);
9450
9460
  onChange?.({ ...next, date });
9451
9461
  },
9452
- [isDateInRange, onChange]
9462
+ [isControlled, isDateInRange, onChange]
9453
9463
  );
9454
9464
  const tryUpdate = React29.useCallback(
9455
9465
  (next) => {
@@ -9697,13 +9707,14 @@ function MonthYearPicker({
9697
9707
  {
9698
9708
  tabIndex: -1,
9699
9709
  "aria-hidden": "true",
9700
- readOnly: true,
9701
9710
  value: hasValue ? "selected" : "",
9711
+ onChange: () => {
9712
+ },
9702
9713
  required,
9703
9714
  disabled,
9704
9715
  onInvalid: (e) => {
9705
9716
  e.preventDefault();
9706
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE3);
9717
+ setLocalRequiredError(tv("required"));
9707
9718
  },
9708
9719
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
9709
9720
  }
@@ -9732,13 +9743,14 @@ function MonthYearPicker({
9732
9743
  {
9733
9744
  tabIndex: -1,
9734
9745
  "aria-hidden": "true",
9735
- readOnly: true,
9736
9746
  value: hasValue ? "selected" : "",
9747
+ onChange: () => {
9748
+ },
9737
9749
  required,
9738
9750
  disabled,
9739
9751
  onInvalid: (e) => {
9740
9752
  e.preventDefault();
9741
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE3);
9753
+ setLocalRequiredError(tv("required"));
9742
9754
  },
9743
9755
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
9744
9756
  }
@@ -10414,7 +10426,6 @@ function Calendar3({
10414
10426
  import * as React31 from "react";
10415
10427
  import { Clock as Clock2, X as X11, Check as Check5, Sun, Moon, Sunset, Coffee } from "lucide-react";
10416
10428
  import { Fragment as Fragment9, jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
10417
- var REQUIRED_ERROR_MESSAGE4 = "This field is required";
10418
10429
  var pad = (n) => n.toString().padStart(2, "0");
10419
10430
  var clamp4 = (n, min, max) => Math.min(max, Math.max(min, n));
10420
10431
  var WHEEL_ITEM_HEIGHT2 = {
@@ -10898,6 +10909,7 @@ function TimePicker({
10898
10909
  className,
10899
10910
  ...rest
10900
10911
  }) {
10912
+ const tv = useSmartTranslations("ValidationInput");
10901
10913
  const isControlled = value !== void 0;
10902
10914
  const now = /* @__PURE__ */ new Date();
10903
10915
  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() });
@@ -11478,13 +11490,14 @@ function TimePicker({
11478
11490
  {
11479
11491
  tabIndex: -1,
11480
11492
  "aria-hidden": "true",
11481
- readOnly: true,
11482
11493
  value: hasCommittedValue ? "selected" : "",
11494
+ onChange: () => {
11495
+ },
11483
11496
  required,
11484
11497
  disabled,
11485
11498
  onInvalid: (e) => {
11486
11499
  e.preventDefault();
11487
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE4);
11500
+ setLocalRequiredError(tv("required"));
11488
11501
  },
11489
11502
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11490
11503
  }
@@ -11527,13 +11540,14 @@ function TimePicker({
11527
11540
  {
11528
11541
  tabIndex: -1,
11529
11542
  "aria-hidden": "true",
11530
- readOnly: true,
11531
11543
  value: hasCommittedValue ? "selected" : "",
11544
+ onChange: () => {
11545
+ },
11532
11546
  required,
11533
11547
  disabled,
11534
11548
  onInvalid: (e) => {
11535
11549
  e.preventDefault();
11536
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE4);
11550
+ setLocalRequiredError(tv("required"));
11537
11551
  },
11538
11552
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11539
11553
  }
@@ -11575,7 +11589,6 @@ function TimePicker({
11575
11589
 
11576
11590
  // src/components/DateTimePicker.tsx
11577
11591
  import { jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
11578
- var REQUIRED_ERROR_MESSAGE5 = "This field is required";
11579
11592
  var DateTimePicker = ({
11580
11593
  value,
11581
11594
  onChange,
@@ -11594,6 +11607,7 @@ var DateTimePicker = ({
11594
11607
  size = "md"
11595
11608
  }) => {
11596
11609
  const t = useSmartTranslations("DateTimePicker");
11610
+ const tv = useSmartTranslations("ValidationInput");
11597
11611
  const locale = useSmartLocale();
11598
11612
  const [open, setOpen] = React32.useState(false);
11599
11613
  const [localRequiredError, setLocalRequiredError] = React32.useState();
@@ -11745,13 +11759,14 @@ var DateTimePicker = ({
11745
11759
  {
11746
11760
  tabIndex: -1,
11747
11761
  "aria-hidden": "true",
11748
- readOnly: true,
11749
11762
  value: value ? "selected" : "",
11763
+ onChange: () => {
11764
+ },
11750
11765
  required,
11751
11766
  disabled,
11752
11767
  onInvalid: (e) => {
11753
11768
  e.preventDefault();
11754
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE5);
11769
+ setLocalRequiredError(tv("required"));
11755
11770
  },
11756
11771
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
11757
11772
  }
@@ -14772,7 +14787,6 @@ import * as React39 from "react";
14772
14787
  import { useId as useId7 } from "react";
14773
14788
  import { ChevronDown as ChevronDown4, Search as Search5, Check as Check6, SearchX as SearchX2, Loader2 as Loader24, X as X13, Sparkles as Sparkles3 } from "lucide-react";
14774
14789
  import { Fragment as Fragment13, jsx as jsx45, jsxs as jsxs35 } from "react/jsx-runtime";
14775
- var REQUIRED_ERROR_MESSAGE6 = "This field is required";
14776
14790
  var MultiCombobox = ({
14777
14791
  id,
14778
14792
  options,
@@ -14806,6 +14820,7 @@ var MultiCombobox = ({
14806
14820
  maxTagsVisible = 3,
14807
14821
  useOverlayScrollbar = false
14808
14822
  }) => {
14823
+ const tv = useSmartTranslations("ValidationInput");
14809
14824
  const [query, setQuery] = React39.useState("");
14810
14825
  const [open, setOpen] = React39.useState(false);
14811
14826
  const [activeIndex, setActiveIndex] = React39.useState(null);
@@ -15219,13 +15234,14 @@ var MultiCombobox = ({
15219
15234
  {
15220
15235
  tabIndex: -1,
15221
15236
  "aria-hidden": "true",
15222
- readOnly: true,
15223
15237
  value: value.length > 0 ? "selected" : "",
15238
+ onChange: () => {
15239
+ },
15224
15240
  required,
15225
15241
  disabled,
15226
15242
  onInvalid: (e) => {
15227
15243
  e.preventDefault();
15228
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE6);
15244
+ setLocalRequiredError(tv("required"));
15229
15245
  },
15230
15246
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
15231
15247
  }
@@ -16400,7 +16416,6 @@ var defaultLabels = {
16400
16416
  searchPlaceholder: "Search...",
16401
16417
  noResultsText: "No results found"
16402
16418
  };
16403
- var REQUIRED_ERROR_MESSAGE7 = "This field is required";
16404
16419
  function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline) {
16405
16420
  if (!(viewOnly || inline) || !defaultExpanded) return /* @__PURE__ */ new Set();
16406
16421
  const parentIds = /* @__PURE__ */ new Set();
@@ -16412,6 +16427,7 @@ function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline)
16412
16427
  return parentIds;
16413
16428
  }
16414
16429
  function CategoryTreeSelect(props) {
16430
+ const tv = useSmartTranslations("ValidationInput");
16415
16431
  const {
16416
16432
  id,
16417
16433
  label,
@@ -16732,13 +16748,14 @@ function CategoryTreeSelect(props) {
16732
16748
  {
16733
16749
  tabIndex: -1,
16734
16750
  "aria-hidden": "true",
16735
- readOnly: true,
16736
16751
  value: valueArray.length > 0 ? "selected" : "",
16752
+ onChange: () => {
16753
+ },
16737
16754
  required,
16738
16755
  disabled,
16739
16756
  onInvalid: (e) => {
16740
16757
  e.preventDefault();
16741
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
16758
+ setLocalRequiredError(tv("required"));
16742
16759
  },
16743
16760
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
16744
16761
  }
@@ -16767,13 +16784,14 @@ function CategoryTreeSelect(props) {
16767
16784
  {
16768
16785
  tabIndex: -1,
16769
16786
  "aria-hidden": "true",
16770
- readOnly: true,
16771
16787
  value: valueArray.length > 0 ? "selected" : "",
16788
+ onChange: () => {
16789
+ },
16772
16790
  required,
16773
16791
  disabled,
16774
16792
  onInvalid: (e) => {
16775
16793
  e.preventDefault();
16776
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
16794
+ setLocalRequiredError(tv("required"));
16777
16795
  },
16778
16796
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
16779
16797
  }
@@ -16882,13 +16900,14 @@ function CategoryTreeSelect(props) {
16882
16900
  {
16883
16901
  tabIndex: -1,
16884
16902
  "aria-hidden": "true",
16885
- readOnly: true,
16886
16903
  value: valueArray.length > 0 ? "selected" : "",
16904
+ onChange: () => {
16905
+ },
16887
16906
  required,
16888
16907
  disabled,
16889
16908
  onInvalid: (e) => {
16890
16909
  e.preventDefault();
16891
- setLocalRequiredError(REQUIRED_ERROR_MESSAGE7);
16910
+ setLocalRequiredError(tv("required"));
16892
16911
  },
16893
16912
  className: "pointer-events-none absolute h-0 w-0 opacity-0"
16894
16913
  }