@sustaina/shared-ui 1.59.2 → 1.60.0

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.mjs CHANGED
@@ -4903,7 +4903,7 @@ var ConditionTextInput = ({ row, control, onClear }) => /* @__PURE__ */ jsx(
4903
4903
  }
4904
4904
  }
4905
4905
  );
4906
- var ConditionNumberInput = ({ row, control, onClear }) => /* @__PURE__ */ jsx(
4906
+ var ConditionNumberInput = ({ row, control, onClear, fieldSchema }) => /* @__PURE__ */ jsx(
4907
4907
  FormField,
4908
4908
  {
4909
4909
  control,
@@ -4923,6 +4923,17 @@ var ConditionNumberInput = ({ row, control, onClear }) => /* @__PURE__ */ jsx(
4923
4923
  value: field.value ?? "",
4924
4924
  autoComplete: "off",
4925
4925
  inputMode: "numeric",
4926
+ min: fieldSchema?.min,
4927
+ max: fieldSchema?.max,
4928
+ onKeyDown: (e) => {
4929
+ const blocked = ["e", "E"];
4930
+ if (fieldSchema?.min !== void 0 && fieldSchema.min >= 0) {
4931
+ blocked.push("-");
4932
+ }
4933
+ if (blocked.includes(e.key)) {
4934
+ e.preventDefault();
4935
+ }
4936
+ },
4926
4937
  className: "w-full h-9 rounded-md bg-white pr-8 text-sm text-gray-700 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 "
4927
4938
  }
4928
4939
  ) }),
@@ -5472,6 +5483,7 @@ var ConditionDateInput = ({
5472
5483
  onClear,
5473
5484
  shortDateFormat = fallbackShortDateFormat
5474
5485
  }) => {
5486
+ const dateFormat = /D/i.test(shortDateFormat) ? shortDateFormat : fallbackShortDateFormat;
5475
5487
  const isBetween = row.operator === "between";
5476
5488
  const buildAriaLabel = (isEnd) => {
5477
5489
  if (isEnd) return "Select end date";
@@ -5503,11 +5515,11 @@ var ConditionDateInput = ({
5503
5515
  ...field,
5504
5516
  value: field.value || void 0,
5505
5517
  onValueChange: handleValueChange,
5506
- placeholder: shortDateFormat,
5518
+ placeholder: dateFormat,
5507
5519
  ariaLabel: buildAriaLabel(options?.isEnd),
5508
5520
  clearAriaLabel: buildClearLabel(options?.isEnd),
5509
5521
  invalid: Boolean(fieldState.error),
5510
- displayFormatter: (d) => formatISODate(d, shortDateFormat),
5522
+ displayFormatter: (d) => formatISODate(d, dateFormat),
5511
5523
  wrapperClassName: "min-w-0",
5512
5524
  "data-testid": "advsearch-date-value"
5513
5525
  }
@@ -7863,7 +7875,15 @@ var ConditionValue = ({
7863
7875
  }
7864
7876
  switch (fieldType) {
7865
7877
  case "number":
7866
- return /* @__PURE__ */ jsx(ConditionNumberInput, { row, control, onClear: onClearValue });
7878
+ return /* @__PURE__ */ jsx(
7879
+ ConditionNumberInput,
7880
+ {
7881
+ row,
7882
+ control,
7883
+ onClear: onClearValue,
7884
+ fieldSchema
7885
+ }
7886
+ );
7867
7887
  case "date":
7868
7888
  case "datetime":
7869
7889
  return /* @__PURE__ */ jsx(
@@ -8515,7 +8535,7 @@ var validateByFieldType = (value, fieldType) => {
8515
8535
  return { valid: true };
8516
8536
  }
8517
8537
  if (numericTypes.includes(fieldType)) {
8518
- if (!/^\d+(\.\d+)?$/.test(value)) {
8538
+ if (!/^-?\d+(\.\d+)?$/.test(value)) {
8519
8539
  return { valid: false, message: "Please enter a valid number." };
8520
8540
  }
8521
8541
  }