@sustaina/shared-ui 1.59.1 → 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
  }
@@ -10014,13 +10034,13 @@ function DialogContent3({
10014
10034
  ...props
10015
10035
  }) {
10016
10036
  return /* @__PURE__ */ jsxs(DialogPortal3, { "data-slot": "dialog-portal", children: [
10017
- /* @__PURE__ */ jsx(DialogOverlay3, { className: "z-49" }),
10037
+ /* @__PURE__ */ jsx(DialogOverlay3, { className: "z-99" }),
10018
10038
  /* @__PURE__ */ jsxs(
10019
10039
  SheetPrimitive.Content,
10020
10040
  {
10021
10041
  "data-slot": "dialog-content",
10022
10042
  className: cn2(
10023
- "w-full sm:max-w-[360px] max-w-[calc(100%-2rem)] bg-white data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-4 shadow-lg duration-200",
10043
+ "z-100 w-full sm:max-w-[360px] max-w-[calc(100%-2rem)] bg-white data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] grid translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-4 shadow-lg duration-200",
10024
10044
  className
10025
10045
  ),
10026
10046
  ...props,