@evergis/react 4.0.139 → 4.0.141

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/react.esm.js CHANGED
@@ -6248,7 +6248,6 @@ const useMapImages = ({ images }) => {
6248
6248
  const { map, loaded: mapLoaded } = useMapContext();
6249
6249
  const [loaded, setLoaded] = useState(false);
6250
6250
  const [errors, setErrors] = useState({});
6251
- const loadedImagesRef = useRef(new Set());
6252
6251
  const previouslyLoadedImages = useRef([]);
6253
6252
  const hasImage = useCallback((name) => {
6254
6253
  if (!map?.current) {
@@ -6262,7 +6261,6 @@ const useMapImages = ({ images }) => {
6262
6261
  }
6263
6262
  if (map.current.hasImage(name)) {
6264
6263
  map.current.removeImage(name);
6265
- loadedImagesRef.current.delete(name);
6266
6264
  }
6267
6265
  }, [map]);
6268
6266
  const addImage = useCallback(async (config) => {
@@ -6283,7 +6281,6 @@ const useMapImages = ({ images }) => {
6283
6281
  sdf,
6284
6282
  pixelRatio,
6285
6283
  });
6286
- loadedImagesRef.current.add(config.name);
6287
6284
  }
6288
6285
  catch (error) {
6289
6286
  const message = error instanceof Error ? error.message : "Unknown error";
@@ -6299,7 +6296,6 @@ const useMapImages = ({ images }) => {
6299
6296
  sdf,
6300
6297
  pixelRatio,
6301
6298
  });
6302
- loadedImagesRef.current.add(config.name);
6303
6299
  }
6304
6300
  catch (error) {
6305
6301
  const message = error instanceof Error ? error.message : "Unknown error";
@@ -6316,7 +6312,6 @@ const useMapImages = ({ images }) => {
6316
6312
  sdf,
6317
6313
  pixelRatio,
6318
6314
  });
6319
- loadedImagesRef.current.add(config.name);
6320
6315
  resolve();
6321
6316
  }
6322
6317
  }).catch(error => {
@@ -6357,16 +6352,19 @@ const useMapImages = ({ images }) => {
6357
6352
  if (!mapLoaded) {
6358
6353
  return;
6359
6354
  }
6360
- map.current.on("styleimagemissing", async (e) => {
6361
- const missingImage = images.find(item => item.name === e.id);
6362
- if (missingImage && !map.current.hasImage(e.id)) {
6355
+ map.current.on("style.load", async () => {
6356
+ if (previouslyLoadedImages.current.length === 0) {
6357
+ return;
6358
+ }
6359
+ const loadPromises = previouslyLoadedImages.current.map(async (config) => {
6363
6360
  try {
6364
- await addImage(missingImage);
6361
+ await addImage(config);
6365
6362
  }
6366
6363
  catch {
6367
6364
  // Ошибка уже записана в errors
6368
6365
  }
6369
- }
6366
+ });
6367
+ await Promise.all(loadPromises);
6370
6368
  });
6371
6369
  }, [mapLoaded]);
6372
6370
  return { loaded, errors, addImage, removeImage, hasImage };
@@ -11906,7 +11904,8 @@ const VoteAcceptedBadge = styled(Flex).withConfig({ displayName: "VoteAcceptedBa
11906
11904
  color: #ffffff;
11907
11905
  font-size: 0.875rem;
11908
11906
  `;
11909
- const VoteAuthHint = styled.div.withConfig({ displayName: "VoteAuthHint", componentId: "sc-8uftsh" }) `
11907
+ /** Мелкая серая подпись под контролами: почему нельзя голосовать или почему кнопка неактивна. */
11908
+ const VoteHint = styled.div.withConfig({ displayName: "VoteHint", componentId: "sc-li8usz" }) `
11910
11909
  font-size: 0.8125rem;
11911
11910
  color: ${({ theme: { palette } }) => palette.textSecondary};
11912
11911
  `;
@@ -12008,8 +12007,18 @@ const useVoteForm = (initialValues) => {
12008
12007
  const removeVariant = useCallback((index) => {
12009
12008
  setVariants(prev => prev.filter((_, itemIndex) => itemIndex !== index));
12010
12009
  }, []);
12011
- const isValid = useMemo(() => Boolean(categoryId && text.trim() && variants.length >= MIN_VARIANTS), [categoryId, text, variants.length]);
12012
- const values = useMemo(() => ({ categoryId, text: text.trim(), multiSelect, variants }), [categoryId, text, multiSelect, variants]);
12010
+ /**
12011
+ * Варианты вместе с недобавленным черновиком.
12012
+ *
12013
+ * Последний вариант часто набирают и жмут «Создать», не нажав Enter: чипсом он ещё не стал, но
12014
+ * пользователь его уже ввёл. Считать такой текст вариантом честнее, чем гасить кнопку и молчать.
12015
+ */
12016
+ const allVariants = useMemo(() => {
12017
+ const pending = draft.trim();
12018
+ return pending ? [...variants, { text: pending }] : variants;
12019
+ }, [variants, draft]);
12020
+ const isValid = useMemo(() => Boolean(categoryId && text.trim() && allVariants.length >= MIN_VARIANTS), [categoryId, text, allVariants.length]);
12021
+ const values = useMemo(() => ({ categoryId, text: text.trim(), multiSelect, variants: allVariants }), [categoryId, text, multiSelect, allVariants]);
12013
12022
  return {
12014
12023
  categoryId,
12015
12024
  setCategoryId,
@@ -12039,7 +12048,10 @@ const VoteCreateForm = ({ categories, initialValues, isEditing, canDelete, submi
12039
12048
  }
12040
12049
  } }), jsxs(Flex, { alignItems: "center", justifyContent: "space-between", children: [jsx(VoteSectionLabel, { children: t("vote.multiSelect", { ns: VOTE_NS, defaultValue: "Множественный выбор" }) }), jsx(Switch, { checked: multiSelect, onChange: () => setMultiSelect(prev => !prev) })] }), jsx(RaisedButton, { primary: true, disabled: !isValid || submitting, onClick: () => onSubmit(values), children: isEditing
12041
12050
  ? t("vote.save", { ns: VOTE_NS, defaultValue: "Сохранить" })
12042
- : t("vote.create", { ns: VOTE_NS, defaultValue: "Создать голосование" }) }), isEditing && (jsxs(Flex, { alignItems: "center", justifyContent: "space-between", children: [onCancel && (jsx(VoteEditLink, { onClick: onCancel, children: t("vote.cancel", { ns: VOTE_NS, defaultValue: "Отмена" }) })), canDelete && onDelete && (jsx(RaisedButton, { error: true, disabled: submitting, onClick: onDelete, children: t("vote.delete", { ns: VOTE_NS, defaultValue: "Удалить голосование" }) }))] }))] }));
12051
+ : t("vote.create", { ns: VOTE_NS, defaultValue: "Создать голосование" }) }), !isValid && (jsx(VoteHint, { children: t("vote.formHint", {
12052
+ ns: VOTE_NS,
12053
+ defaultValue: "Нужны категория, вопрос и минимум два варианта ответа",
12054
+ }) })), isEditing && (jsxs(Flex, { alignItems: "center", justifyContent: "space-between", children: [onCancel && (jsx(VoteEditLink, { onClick: onCancel, children: t("vote.cancel", { ns: VOTE_NS, defaultValue: "Отмена" }) })), canDelete && onDelete && (jsx(RaisedButton, { error: true, disabled: submitting, onClick: onDelete, children: t("vote.delete", { ns: VOTE_NS, defaultValue: "Удалить голосование" }) }))] }))] }));
12043
12055
  };
12044
12056
 
12045
12057
  /** Блок «Поделиться в соцсетях» — пока только вёрстка, без рабочих ссылок. */
@@ -12063,7 +12075,7 @@ const VoteResults = ({ question, category, results, screen, isOwner, hasAnswers,
12063
12075
  }, [question.multiSelect]);
12064
12076
  const canSubmit = useMemo(() => selected.length > 0 && !submitting, [selected.length, submitting]);
12065
12077
  return (jsxs(VoteWrapper, { children: [category && jsx(VoteCategoryLabel, { children: category.name }), jsx(VoteQuestionText, { children: question.text }), jsx(VoteVariantList, { column: true, value: selected[0] ?? "", children: results.map(({ id, text, count, percent }) => (jsxs(VoteVariantRow, { children: [jsxs(VoteVariantHead, { children: [showControls &&
12066
- (question.multiSelect ? (jsx(Checkbox, { checked: selected.includes(id), onChange: () => toggle(id) })) : (jsx(Radio, { value: id, checked: selected.includes(id), onChange: () => toggle(id) }))), jsx(VoteVariantText, { children: text }), jsx(VoteVariantCount, { children: count })] }), jsx(LinearProgress, { done: percent })] }, id))) }), screen === "unauthenticated" && (jsx(VoteAuthHint, { children: t("vote.authHint", { ns: VOTE_NS, defaultValue: "Чтобы проголосовать, пожалуйста, авторизуйтесь" }) })), screen === "voted" && (jsxs(VoteAcceptedBadge, { children: [jsx(Icon, { kind: "success" }), t("vote.accepted", { ns: VOTE_NS, defaultValue: "Ваш ответ принят" })] })), showControls && (jsx(RaisedButton, { primary: true, disabled: !canSubmit, onClick: () => onSubmit(selected), children: t("vote.submit", { ns: VOTE_NS, defaultValue: "Отправить ответ" }) })), canEdit && onEdit && (jsx(Flex, { children: jsx(VoteEditLink, { onClick: onEdit, children: t("vote.edit", { ns: VOTE_NS, defaultValue: "Редактировать" }) }) })), showShare && jsx(VoteShare, {})] }));
12078
+ (question.multiSelect ? (jsx(Checkbox, { checked: selected.includes(id), onChange: () => toggle(id) })) : (jsx(Radio, { value: id, checked: selected.includes(id), onChange: () => toggle(id) }))), jsx(VoteVariantText, { children: text }), jsx(VoteVariantCount, { children: count })] }), jsx(LinearProgress, { done: percent })] }, id))) }), screen === "unauthenticated" && (jsx(VoteHint, { children: t("vote.authHint", { ns: VOTE_NS, defaultValue: "Чтобы проголосовать, пожалуйста, авторизуйтесь" }) })), screen === "voted" && (jsxs(VoteAcceptedBadge, { children: [jsx(Icon, { kind: "success" }), t("vote.accepted", { ns: VOTE_NS, defaultValue: "Ваш ответ принят" })] })), showControls && (jsx(RaisedButton, { primary: true, disabled: !canSubmit, onClick: () => onSubmit(selected), children: t("vote.submit", { ns: VOTE_NS, defaultValue: "Отправить ответ" }) })), canEdit && onEdit && (jsx(Flex, { children: jsx(VoteEditLink, { onClick: onEdit, children: t("vote.edit", { ns: VOTE_NS, defaultValue: "Редактировать" }) }) })), showShare && jsx(VoteShare, {})] }));
12067
12079
  };
12068
12080
 
12069
12081
  /**