@local-civics/hub-ui 0.1.113 → 0.1.115

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.d.ts CHANGED
@@ -499,6 +499,8 @@ type LearningFormProps = {
499
499
  rating?: number;
500
500
  items?: FormItemProps[];
501
501
  preview?: boolean;
502
+ timeSpent?: number;
503
+ elapsedTime?: number;
502
504
  stopWatch?: React__default.ReactNode;
503
505
  onHome?: () => void;
504
506
  onGoBack?: () => void;
package/dist/index.js CHANGED
@@ -3850,14 +3850,18 @@ const RadioQuestion = (props) => {
3850
3850
  }));
3851
3851
  };
3852
3852
  const CheckboxQuestion = (props) => {
3853
- var _a;
3854
3853
  const options = props.options || [];
3855
3854
  const responses = props.responses || [];
3856
3855
  const values = {};
3857
- const ref = React.useRef(null);
3858
- const rawResponse = responses.length > 0 ? responses[0] : ((_a = ref.current) == null ? void 0 : _a.value) || "";
3859
- const response = rawResponse.replace("Other: ", "");
3860
- const isOtherResponse = rawResponse.startsWith("Other: ");
3856
+ let rawResponse = "";
3857
+ for (const val of responses) {
3858
+ if (val.startsWith("Other: ")) {
3859
+ rawResponse = val;
3860
+ break;
3861
+ }
3862
+ }
3863
+ const response = rawResponse && rawResponse.replace("Other: ", "");
3864
+ const isOtherResponse = rawResponse && rawResponse.startsWith("Other: ");
3861
3865
  responses.forEach((key) => values[key] = true);
3862
3866
  const onOtherChange = (e) => setResponseValue(e.target.value ? `Other: ${e.target.value}` : "");
3863
3867
  const onChange = (e) => setResponseValue(e.target.value);
@@ -3887,7 +3891,7 @@ const CheckboxQuestion = (props) => {
3887
3891
  id: "checkbox",
3888
3892
  disabled: props.disabled,
3889
3893
  className: "cursor-pointer shrink-0",
3890
- required: props.required && !isOneChecked,
3894
+ required: option ? props.required && !isOneChecked && !!isOtherResponse : props.required && !isOneChecked,
3891
3895
  checked: values[option] || !option && values[`Other: ${response}`],
3892
3896
  onChange: option ? onChange : onOtherChange,
3893
3897
  type: "checkbox",
@@ -3899,11 +3903,10 @@ const CheckboxQuestion = (props) => {
3899
3903
  {
3900
3904
  className: "w-full px-3 py-2 bg-white text-slate-500 focus:text-slate-600 text-sm placeholder-slate-400 border border-slate-300 rounded-sm shadow-sm\r\n focus:outline-none focus:ring-1 focus:ring-sky-500",
3901
3905
  value: isOtherResponse ? response : "",
3902
- required: props.required,
3906
+ required: props.required && !isOneChecked,
3903
3907
  disabled: props.disabled,
3904
3908
  onChange: onOtherChange,
3905
- placeholder: "Input another option",
3906
- ref
3909
+ placeholder: "Input another option"
3907
3910
  }
3908
3911
  ))));
3909
3912
  }));
@@ -4262,6 +4265,12 @@ const LearningForm = (props) => {
4262
4265
  setIsDraft(true);
4263
4266
  }
4264
4267
  }, [currentAnswersKey]);
4268
+ React.useEffect(() => {
4269
+ if (props.timeSpent !== props.elapsedTime && !isDraft) {
4270
+ setIsDraft(true);
4271
+ }
4272
+ return;
4273
+ }, [props.timeSpent, props.elapsedTime]);
4265
4274
  const onReflectionChange = (responses) => {
4266
4275
  if (!responses || responses.length === 0) {
4267
4276
  setReflection("");