@anker-in/ui 0.1.17 → 0.1.18

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
@@ -1980,7 +1980,7 @@ var QuestionnaireForm = ({
1980
1980
  onChange: (e) => handleOtherInputChange(questionId, e.target.value),
1981
1981
  placeholder: question.placeholder || "Please specify...",
1982
1982
  className: cn(
1983
- "w-full ml-8 px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-gray-900",
1983
+ "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-gray-900",
1984
1984
  "focus:outline-none focus:ring-2 focus:ring-[#3ADB67] focus:border-transparent",
1985
1985
  hasError ? "border-red-500" : "border-[#E4E5E6]"
1986
1986
  )
@@ -2022,11 +2022,17 @@ var QuestionnaireForm = ({
2022
2022
  optionValue
2023
2023
  );
2024
2024
  }) });
2025
- case "select":
2025
+ case "select": {
2026
+ const currentValue = responses[questionId];
2027
+ const hasOnlyOneOption = question.options?.length === 1;
2028
+ const defaultValue = hasOnlyOneOption && !currentValue && question.options?.[0] ? question.options[0].value || question.options[0].label : currentValue || "";
2029
+ if (hasOnlyOneOption && !currentValue && question.options?.[0]) {
2030
+ handleChange(questionId, defaultValue);
2031
+ }
2026
2032
  return /* @__PURE__ */ jsxRuntime.jsx(
2027
2033
  "select",
2028
2034
  {
2029
- value: responses[questionId] || "",
2035
+ value: defaultValue,
2030
2036
  onChange: (e) => handleChange(questionId, e.target.value),
2031
2037
  className: cn(
2032
2038
  "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-gray-900",
@@ -2044,6 +2050,7 @@ var QuestionnaireForm = ({
2044
2050
  ))
2045
2051
  }
2046
2052
  );
2053
+ }
2047
2054
  default:
2048
2055
  return null;
2049
2056
  }