stream-chat-react 12.15.4 → 12.15.5

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.
@@ -24,7 +24,7 @@ export const useChat = ({ client, defaultLanguage = 'en', i18nInstance, initialN
24
24
  useEffect(() => {
25
25
  if (!client)
26
26
  return;
27
- const version = "12.15.4";
27
+ const version = "12.15.5";
28
28
  const userAgent = client.getUserAgent();
29
29
  if (!userAgent.includes('stream-chat-react')) {
30
30
  // result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
@@ -57,16 +57,20 @@ export const FormDialog = ({ className, close, fields, onSubmit, shouldDisableSu
57
57
  return (React.createElement("div", { className: clsx('str-chat__dialog str-chat__dialog--form', className) },
58
58
  React.createElement("div", { className: 'str-chat__dialog__body' },
59
59
  title && React.createElement("div", { className: 'str-chat__dialog__title' }, title),
60
- React.createElement("form", { autoComplete: 'off' }, Object.entries(fields).map(([id, fieldConfig]) => (React.createElement("div", { className: 'str-chat__dialog__field', key: `dialog-field-${id}` },
61
- fieldConfig.label && (React.createElement("label", { className: clsx(`str-chat__dialog__title str-chat__dialog__title--${id}`), htmlFor: id }, fieldConfig.label)),
62
- React.createElement(fieldConfig.element, {
63
- id,
64
- ...fieldConfig.props,
65
- onChange: handleChange,
66
- value: value[id],
67
- }),
68
- React.createElement(FieldError, { text: fieldErrors[id]?.message })))))),
69
- React.createElement("div", { className: 'str-chat__dialog__controls' },
70
- React.createElement("button", { className: 'str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel', onClick: close }, t('Cancel')),
71
- React.createElement("button", { className: 'str-chat__dialog__controls-button str-chat__dialog__controls-button--submit', disabled: Object.keys(fieldErrors).length > 0 || shouldDisableSubmitButton?.(value), onClick: handleSubmit, type: 'submit' }, t('Send')))));
60
+ React.createElement("form", { autoComplete: 'off', onSubmit: (e) => {
61
+ e.preventDefault();
62
+ handleSubmit();
63
+ } },
64
+ Object.entries(fields).map(([id, fieldConfig]) => (React.createElement("div", { className: 'str-chat__dialog__field', key: `dialog-field-${id}` },
65
+ fieldConfig.label && (React.createElement("label", { className: clsx(`str-chat__dialog__title str-chat__dialog__title--${id}`), htmlFor: id }, fieldConfig.label)),
66
+ React.createElement(fieldConfig.element, {
67
+ id,
68
+ ...fieldConfig.props,
69
+ onChange: handleChange,
70
+ value: value[id],
71
+ }),
72
+ React.createElement(FieldError, { text: fieldErrors[id]?.message })))),
73
+ React.createElement("div", { className: 'str-chat__dialog__controls' },
74
+ React.createElement("button", { className: 'str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel', onClick: close }, t('Cancel')),
75
+ React.createElement("button", { className: 'str-chat__dialog__controls-button str-chat__dialog__controls-button--submit', disabled: Object.keys(fieldErrors).length > 0 || shouldDisableSubmitButton?.(value), type: 'submit' }, t('Send')))))));
72
76
  };
@@ -15,13 +15,15 @@ export const PollHeader = () => {
15
15
  const selectionInstructions = useMemo(() => {
16
16
  if (is_closed)
17
17
  return t('Vote ended');
18
- if (enforce_unique_vote)
18
+ if (enforce_unique_vote || options.length === 1)
19
19
  return t('Select one');
20
20
  if (max_votes_allowed)
21
21
  return t('Select up to {{count}}', {
22
22
  count: max_votes_allowed > options.length ? options.length : max_votes_allowed,
23
23
  });
24
- return t('Select one or more');
24
+ if (options.length > 1)
25
+ return t('Select one or more');
26
+ return '';
25
27
  }, [is_closed, enforce_unique_vote, max_votes_allowed, options.length, t]);
26
28
  if (!name)
27
29
  return;