@local-civics/hub-ui 0.1.97 → 0.1.99
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 +50 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3836,23 +3836,30 @@ const CheckboxQuestion = (props) => {
|
|
|
3836
3836
|
props.onResponseChange(newResponses);
|
|
3837
3837
|
}
|
|
3838
3838
|
};
|
|
3839
|
+
let isOneChecked = false;
|
|
3840
|
+
React.useEffect(() => {
|
|
3841
|
+
}, []);
|
|
3839
3842
|
return /* @__PURE__ */ React.createElement("fieldset", { className: "grid grid-cols-1 gap-y-8" }, options.map((option) => {
|
|
3843
|
+
isOneChecked = Object.keys(values).length ? true : false;
|
|
3840
3844
|
return /* @__PURE__ */ React.createElement("div", { key: option }, /* @__PURE__ */ React.createElement("label", { className: "flex gap-x-4 items-center" }, /* @__PURE__ */ React.createElement(
|
|
3841
3845
|
"input",
|
|
3842
3846
|
{
|
|
3847
|
+
id: "checkbox",
|
|
3843
3848
|
disabled: props.disabled,
|
|
3844
3849
|
className: "cursor-pointer shrink-0",
|
|
3850
|
+
required: props.required && !isOneChecked,
|
|
3845
3851
|
checked: values[option] || !option && values[`Other: ${response}`],
|
|
3846
3852
|
onChange: option ? onChange : onOtherChange,
|
|
3847
3853
|
type: "checkbox",
|
|
3848
3854
|
value: option || response,
|
|
3849
3855
|
name: displayNameString(props.displayName)
|
|
3850
3856
|
}
|
|
3851
|
-
), option && /* @__PURE__ */ React.createElement("div", null, option), !option && /* @__PURE__ */ React.createElement(React.Fragment, null, "Other: ", /* @__PURE__ */ React.createElement(
|
|
3857
|
+
), option && /* @__PURE__ */ React.createElement("div", null, option), !option && /* @__PURE__ */ React.createElement(React.Fragment, null, "Other:", " ", /* @__PURE__ */ React.createElement(
|
|
3852
3858
|
"input",
|
|
3853
3859
|
{
|
|
3854
|
-
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\n focus:outline-none focus:ring-1 focus:ring-sky-500",
|
|
3860
|
+
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",
|
|
3855
3861
|
value: isOtherResponse ? response : "",
|
|
3862
|
+
required: props.required,
|
|
3856
3863
|
disabled: props.disabled,
|
|
3857
3864
|
onChange: onOtherChange,
|
|
3858
3865
|
placeholder: "Input another option",
|
|
@@ -3923,7 +3930,7 @@ const FileUploadQuestion = (props) => {
|
|
|
3923
3930
|
onChange: onImageUpload,
|
|
3924
3931
|
name: "image",
|
|
3925
3932
|
type: "file",
|
|
3926
|
-
className: "block w-full text-sm text-slate-500 disabled:text-gray-600\n file:mr-4 file:py-2 file:px-4\n file:rounded-full file:border-0\n file:text-sm file:font-semibold\n file:bg-violet-50 file:text-violet-700\n hover:file:bg-violet-100"
|
|
3933
|
+
className: "block w-full text-sm text-slate-500 disabled:text-gray-600\r\n file:mr-4 file:py-2 file:px-4\r\n file:rounded-full file:border-0\r\n file:text-sm file:font-semibold\r\n file:bg-violet-50 file:text-violet-700\r\n hover:file:bg-violet-100"
|
|
3927
3934
|
}
|
|
3928
3935
|
))), /* @__PURE__ */ React.createElement("div", { className: "-ml-2" }, /* @__PURE__ */ React.createElement(
|
|
3929
3936
|
"input",
|
|
@@ -3935,7 +3942,7 @@ const FileUploadQuestion = (props) => {
|
|
|
3935
3942
|
onChange,
|
|
3936
3943
|
value: imageURL,
|
|
3937
3944
|
placeholder: "Paste a url or select a file above",
|
|
3938
|
-
className: "w-full mt-1 block px-3 py-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none"
|
|
3945
|
+
className: "w-full mt-1 block px-3 py-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\r\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\r\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none"
|
|
3939
3946
|
}
|
|
3940
3947
|
)));
|
|
3941
3948
|
};
|
|
@@ -3951,7 +3958,7 @@ const TextQuestion = (props) => {
|
|
|
3951
3958
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, !props.paragraph && /* @__PURE__ */ React.createElement(
|
|
3952
3959
|
"input",
|
|
3953
3960
|
{
|
|
3954
|
-
className: "mt-1 block 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\n focus:outline-none focus:ring-1 focus:ring-sky-500 focus:border-sky-500\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3961
|
+
className: "mt-1 block 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 focus:border-sky-500\r\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3955
3962
|
required: props.required,
|
|
3956
3963
|
minLength: minimum,
|
|
3957
3964
|
onChange,
|
|
@@ -3965,7 +3972,7 @@ const TextQuestion = (props) => {
|
|
|
3965
3972
|
), props.paragraph && /* @__PURE__ */ React.createElement(
|
|
3966
3973
|
"textarea",
|
|
3967
3974
|
{
|
|
3968
|
-
className: "resize-none text-slate-500 focus:text-slate-600 h-24 mt-1 block w-full px-3 py-2 bg-white border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3975
|
+
className: "resize-none text-slate-500 focus:text-slate-600 h-24 mt-1 block w-full px-3 py-2 bg-white border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\r\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\r\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3969
3976
|
required: props.required,
|
|
3970
3977
|
minLength: minimum,
|
|
3971
3978
|
onChange,
|
|
@@ -3988,7 +3995,7 @@ const DateQuestion = (props) => {
|
|
|
3988
3995
|
return /* @__PURE__ */ React.createElement(
|
|
3989
3996
|
"input",
|
|
3990
3997
|
{
|
|
3991
|
-
className: "mt-1 block w-full px-3 pt-3 pb-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3998
|
+
className: "mt-1 block w-full px-3 pt-3 pb-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\r\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\r\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
3992
3999
|
required: props.required,
|
|
3993
4000
|
onChange,
|
|
3994
4001
|
name: displayNameString(props.displayName),
|
|
@@ -4009,7 +4016,7 @@ const TimeQuestion = (props) => {
|
|
|
4009
4016
|
return /* @__PURE__ */ React.createElement(
|
|
4010
4017
|
"input",
|
|
4011
4018
|
{
|
|
4012
|
-
className: "mt-1 block w-full px-3 pt-3 pb-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
4019
|
+
className: "mt-1 block w-full px-3 pt-3 pb-2 bg-white text-slate-500 focus:text-slate-600 border border-slate-300 rounded-sm text-sm shadow-sm placeholder-slate-400\r\n focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500\r\n disabled:bg-slate-50 disabled:text-gray-600 disabled:border-slate-200 disabled:shadow-none",
|
|
4013
4020
|
required: props.required,
|
|
4014
4021
|
onChange,
|
|
4015
4022
|
name: displayNameString(props.displayName),
|
|
@@ -4065,7 +4072,15 @@ const Image = (props) => {
|
|
|
4065
4072
|
return;
|
|
4066
4073
|
}
|
|
4067
4074
|
};
|
|
4068
|
-
return /* @__PURE__ */ React.createElement("div", { className: "relative max-w-[25rem] md:max-w-[40rem] md:w-[40rem] overflow-hidden" }, /* @__PURE__ */ React.createElement(
|
|
4075
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative max-w-[25rem] md:max-w-[40rem] md:w-[40rem] overflow-hidden" }, /* @__PURE__ */ React.createElement(
|
|
4076
|
+
"img",
|
|
4077
|
+
{
|
|
4078
|
+
referrerPolicy: "no-referrer",
|
|
4079
|
+
className: `h-full max-h-[25rem] w-full object-cover ${scale}`,
|
|
4080
|
+
alt: displayNameString(props.displayName),
|
|
4081
|
+
src: props.url
|
|
4082
|
+
}
|
|
4083
|
+
), /* @__PURE__ */ React.createElement("div", { className: "absolute rounded-sm shadow-md bottom-5 right-5 z-5 bg-gray-100 font-bold" }, /* @__PURE__ */ React.createElement("span", { className: "p-5 cursor-pointer text-md text-gray-400 hover:text-gray-600", onClick: scaleUp }, "+"), /* @__PURE__ */ React.createElement("span", { className: "p-5 cursor-pointer text-xl text-gray-400 hover:text-gray-600", onClick: scaleDown }, "-")));
|
|
4069
4084
|
};
|
|
4070
4085
|
const Embed = (props) => {
|
|
4071
4086
|
return /* @__PURE__ */ React.createElement("div", { className: "max-w-[25rem] md:max-w-[40rem] md:w-[40rem]" }, /* @__PURE__ */ React.createElement(
|
|
@@ -4140,11 +4155,14 @@ const autoSave = (run, func, callback) => {
|
|
|
4140
4155
|
let timeout;
|
|
4141
4156
|
return (items, reflection, rating) => {
|
|
4142
4157
|
clearTimeout(timeout);
|
|
4143
|
-
timeout = setTimeout(
|
|
4144
|
-
|
|
4145
|
-
callback
|
|
4146
|
-
|
|
4147
|
-
|
|
4158
|
+
timeout = setTimeout(
|
|
4159
|
+
async () => run && func && await func(items, reflection, rating).then((e) => {
|
|
4160
|
+
if (!e && callback) {
|
|
4161
|
+
callback();
|
|
4162
|
+
}
|
|
4163
|
+
}),
|
|
4164
|
+
AUTOSAVE_TIMEOUT
|
|
4165
|
+
);
|
|
4148
4166
|
return timeout;
|
|
4149
4167
|
};
|
|
4150
4168
|
};
|
|
@@ -4156,7 +4174,10 @@ const LearningForm = (props) => {
|
|
|
4156
4174
|
const [showExitDialogue, setShowExitDialogue] = React.useState(false);
|
|
4157
4175
|
const [showSubmitDialogue, setShowSubmitDialogue] = React.useState(false);
|
|
4158
4176
|
const [isDraft, setIsDraft] = React.useState(false);
|
|
4159
|
-
const autoSaveHandler = React.useCallback(
|
|
4177
|
+
const autoSaveHandler = React.useCallback(
|
|
4178
|
+
autoSave(isDraft, props.onSaveDraft, () => setIsDraft(false)),
|
|
4179
|
+
[isDraft]
|
|
4180
|
+
);
|
|
4160
4181
|
const saveVisibility = isDraft ? "opacity-100 visible" : "opacity-0 invisible";
|
|
4161
4182
|
const answers = [];
|
|
4162
4183
|
const saveDraft = async () => {
|
|
@@ -4175,7 +4196,7 @@ const LearningForm = (props) => {
|
|
|
4175
4196
|
}
|
|
4176
4197
|
});
|
|
4177
4198
|
const canReflect = !!reflection || answeredAllRequired;
|
|
4178
|
-
|
|
4199
|
+
answeredAllRequired && reflection.length >= MIN_REFLECTION_LENGTH;
|
|
4179
4200
|
const items = props.items || [];
|
|
4180
4201
|
const currentAnswersKey = answers && answers.length > 0 ? JSON.stringify(answers) : null;
|
|
4181
4202
|
React.useEffect(() => {
|
|
@@ -4236,15 +4257,7 @@ const LearningForm = (props) => {
|
|
|
4236
4257
|
/* @__PURE__ */ React.createElement("div", { className: "w-3 h-3 min-w-3" }, /* @__PURE__ */ React.createElement(Icon$1, { name: "leftArrow" })),
|
|
4237
4258
|
/* @__PURE__ */ React.createElement("span", { className: "text-md" }, "Back")
|
|
4238
4259
|
), !!props.displayName && /* @__PURE__ */ React.createElement("h2", { className: "h-max font-semibold text-2xl" }, props.displayName), !!props.description && /* @__PURE__ */ React.createElement("p", { className: "h-max max-h-[14rem] overflow-y-auto whitespace-pre-line" }, props.description), !!props.eta && /* @__PURE__ */ React.createElement("p", { className: "text-sm h-max font-semibold" }, "Estimated Completion Time: ", props.eta)), /* @__PURE__ */ React.createElement("img", { className: "grow h-full max-h-[30rem] w-full object-cover", alt: props.displayName, src: props.imageURL })), /* @__PURE__ */ React.createElement("form", { className: "w-full max-w-[62.5rem] m-auto grid grid-cols-1 gap-y-12", onSubmit }, items.map((item) => {
|
|
4239
|
-
return /* @__PURE__ */ React.createElement(
|
|
4240
|
-
FormItem,
|
|
4241
|
-
__spreadProps$6(__spreadValues$8({
|
|
4242
|
-
key: item.itemId
|
|
4243
|
-
}, item), {
|
|
4244
|
-
minText: 0,
|
|
4245
|
-
disabled: !!props.preview
|
|
4246
|
-
})
|
|
4247
|
-
);
|
|
4260
|
+
return /* @__PURE__ */ React.createElement(FormItem, __spreadProps$6(__spreadValues$8({ key: item.itemId }, item), { minText: 0, disabled: !!props.preview }));
|
|
4248
4261
|
}), /* @__PURE__ */ React.createElement(
|
|
4249
4262
|
FormItem,
|
|
4250
4263
|
{
|
|
@@ -4259,7 +4272,18 @@ const LearningForm = (props) => {
|
|
|
4259
4272
|
minText: MIN_REFLECTION_LENGTH,
|
|
4260
4273
|
responses: reflection ? [reflection] : void 0
|
|
4261
4274
|
}
|
|
4262
|
-
), /* @__PURE__ */ React.createElement(FormItem, null, /* @__PURE__ */ React.createElement(Rating, { disabled: !canReflect || !!props.preview, rating, setRating })), !props.preview && /* @__PURE__ */ React.createElement("div", { className: "w-max m-auto" }, /* @__PURE__ */ React.createElement(
|
|
4275
|
+
), /* @__PURE__ */ React.createElement(FormItem, null, /* @__PURE__ */ React.createElement(Rating, { disabled: !canReflect || !!props.preview, rating, setRating })), !props.preview && /* @__PURE__ */ React.createElement("div", { className: "w-max m-auto" }, /* @__PURE__ */ React.createElement(
|
|
4276
|
+
Button,
|
|
4277
|
+
{
|
|
4278
|
+
type: "submit",
|
|
4279
|
+
color: "blue",
|
|
4280
|
+
size: "md",
|
|
4281
|
+
spacing: "md",
|
|
4282
|
+
border: "rounded",
|
|
4283
|
+
theme: "dark",
|
|
4284
|
+
text: "Submit"
|
|
4285
|
+
}
|
|
4286
|
+
))), !props.preview && /* @__PURE__ */ React.createElement("div", { className: `fixed bottom-10 right-14 transition ease-in-out ${saveVisibility}` }, /* @__PURE__ */ React.createElement(
|
|
4263
4287
|
Button,
|
|
4264
4288
|
{
|
|
4265
4289
|
type: "button",
|