@oondemand/oon-core-front 0.3.26 → 0.3.27

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
@@ -1905,12 +1905,20 @@ function toValue2(value, kind) {
1905
1905
  function isMultiline2(field) {
1906
1906
  return /observa|descricao|mensagem|detalhe|necessidade/i.test(field.field);
1907
1907
  }
1908
+ function FieldLabel({ field, htmlFor }) {
1909
+ const label = fieldLabel({ name: field.field, label: field.label });
1910
+ return /* @__PURE__ */ jsx14("label", { htmlFor, children: /* @__PURE__ */ jsxs10(Text9, { as: "span", display: "block", mb: "5px", color: "#475467", fontSize: "11px", fontWeight: "600", children: [
1911
+ label,
1912
+ field.required ? /* @__PURE__ */ jsx14(Text9, { as: "span", color: "#DC2626", children: " *" }) : null
1913
+ ] }) });
1914
+ }
1908
1915
  function FieldControl({
1909
1916
  field,
1910
1917
  value,
1911
1918
  onChange
1912
1919
  }) {
1913
1920
  const label = fieldLabel({ name: field.field, label: field.label });
1921
+ const inputId = `oon-detail-field-${field.field.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
1914
1922
  if (field.widget === "checkbox") {
1915
1923
  const checkedValue = String(field.checkedValue ?? true);
1916
1924
  const uncheckedValue = String(field.uncheckedValue ?? false);
@@ -1945,22 +1953,41 @@ function FieldControl({
1945
1953
  }
1946
1954
  );
1947
1955
  }
1956
+ if (field.kind === "ref" && field.ref) {
1957
+ return /* @__PURE__ */ jsxs10(Box7, { children: [
1958
+ /* @__PURE__ */ jsx14(FieldLabel, { field, htmlFor: inputId }),
1959
+ /* @__PURE__ */ jsx14(
1960
+ ReferenceSelect,
1961
+ {
1962
+ field: field.field,
1963
+ inputId,
1964
+ label,
1965
+ refModel: field.ref,
1966
+ value,
1967
+ initialValue: value,
1968
+ required: field.required,
1969
+ onChange
1970
+ }
1971
+ )
1972
+ ] });
1973
+ }
1948
1974
  const control = field.kind === "enum" && field.options?.length ? /* @__PURE__ */ jsxs10(NativeSelect4.Root, { size: "sm", children: [
1949
- /* @__PURE__ */ jsxs10(NativeSelect4.Field, { value, onChange: (event) => onChange(event.currentTarget.value), children: [
1975
+ /* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value, onChange: (event) => onChange(event.currentTarget.value), children: [
1950
1976
  /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014 Selecione \u2014" }),
1951
1977
  field.options.map((option) => /* @__PURE__ */ jsx14("option", { value: option, children: option }, option))
1952
1978
  ] }),
1953
1979
  /* @__PURE__ */ jsx14(NativeSelect4.Indicator, {})
1954
1980
  ] }) : field.kind === "boolean" ? /* @__PURE__ */ jsxs10(NativeSelect4.Root, { size: "sm", children: [
1955
- /* @__PURE__ */ jsxs10(NativeSelect4.Field, { value, onChange: (event) => onChange(event.currentTarget.value), children: [
1981
+ /* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value, onChange: (event) => onChange(event.currentTarget.value), children: [
1956
1982
  /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014 Selecione \u2014" }),
1957
1983
  /* @__PURE__ */ jsx14("option", { value: "true", children: "Sim" }),
1958
1984
  /* @__PURE__ */ jsx14("option", { value: "false", children: "N\xE3o" })
1959
1985
  ] }),
1960
1986
  /* @__PURE__ */ jsx14(NativeSelect4.Indicator, {})
1961
- ] }) : isMultiline2(field) ? /* @__PURE__ */ jsx14(Textarea3, { rows: 4, resize: "vertical", value, onChange: (event) => onChange(event.currentTarget.value) }) : /* @__PURE__ */ jsx14(
1987
+ ] }) : isMultiline2(field) ? /* @__PURE__ */ jsx14(Textarea3, { id: inputId, rows: 4, resize: "vertical", value, onChange: (event) => onChange(event.currentTarget.value) }) : /* @__PURE__ */ jsx14(
1962
1988
  Input5,
1963
1989
  {
1990
+ id: inputId,
1964
1991
  size: "sm",
1965
1992
  type: field.kind === "date" ? "date" : ["number", "currency", "currencyConverted"].includes(field.kind ?? "") ? "number" : "text",
1966
1993
  value,
@@ -1968,10 +1995,7 @@ function FieldControl({
1968
1995
  }
1969
1996
  );
1970
1997
  return /* @__PURE__ */ jsxs10(Box7, { children: [
1971
- /* @__PURE__ */ jsxs10(Text9, { as: "label", display: "block", mb: "5px", color: "#475467", fontSize: "11px", fontWeight: "600", children: [
1972
- label,
1973
- field.required ? /* @__PURE__ */ jsx14(Text9, { as: "span", color: "#DC2626", children: " *" }) : null
1974
- ] }),
1998
+ /* @__PURE__ */ jsx14(FieldLabel, { field, htmlFor: inputId }),
1975
1999
  control
1976
2000
  ] });
1977
2001
  }