stream-chat-react 13.0.1 → 13.0.2

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.
@@ -8,3 +8,4 @@ export * from './components';
8
8
  export * from './UnsupportedAttachment';
9
9
  export * from './FileAttachment';
10
10
  export * from './utils';
11
+ export { useAudioController } from './hooks/useAudioController';
@@ -8,3 +8,4 @@ export * from './components';
8
8
  export * from './UnsupportedAttachment';
9
9
  export * from './FileAttachment';
10
10
  export * from './utils';
11
+ export { useAudioController } from './hooks/useAudioController';
@@ -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 = "13.0.1";
27
+ const version = "13.0.2";
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;
@@ -17583,6 +17583,7 @@ __export(src_exports, {
17583
17583
  useActionHandler: () => useActionHandler,
17584
17584
  useActiveThread: () => useActiveThread,
17585
17585
  useAttachmentManagerState: () => useAttachmentManagerState,
17586
+ useAudioController: () => useAudioController,
17586
17587
  useCanCreatePoll: () => useCanCreatePoll,
17587
17588
  useChannelActionContext: () => useChannelActionContext,
17588
17589
  useChannelDeletedListener: () => useChannelDeletedListener,
@@ -38680,12 +38681,13 @@ var PollHeader = () => {
38680
38681
  const { enforce_unique_vote, is_closed, max_votes_allowed, name: name2, options } = useStateStore(poll.state, pollStateSelector);
38681
38682
  const selectionInstructions = (0, import_react123.useMemo)(() => {
38682
38683
  if (is_closed) return t("Vote ended");
38683
- if (enforce_unique_vote) return t("Select one");
38684
+ if (enforce_unique_vote || options.length === 1) return t("Select one");
38684
38685
  if (max_votes_allowed)
38685
38686
  return t("Select up to {{count}}", {
38686
38687
  count: max_votes_allowed > options.length ? options.length : max_votes_allowed
38687
38688
  });
38688
- return t("Select one or more");
38689
+ if (options.length > 1) return t("Select one or more");
38690
+ return "";
38689
38691
  }, [is_closed, enforce_unique_vote, max_votes_allowed, options.length, t]);
38690
38692
  if (!name2) return;
38691
38693
  return /* @__PURE__ */ import_react123.default.createElement("div", { className: "str-chat__poll-header" }, /* @__PURE__ */ import_react123.default.createElement("div", { className: "str-chat__poll-title" }, name2), /* @__PURE__ */ import_react123.default.createElement("div", { className: "str-chat__poll-subtitle" }, selectionInstructions));
@@ -38765,36 +38767,46 @@ var FormDialog = ({
38765
38767
  await onSubmit(value);
38766
38768
  close();
38767
38769
  };
38768
- return /* @__PURE__ */ import_react125.default.createElement("div", { className: (0, import_clsx27.default)("str-chat__dialog str-chat__dialog--form", className) }, /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__body" }, title && /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__title" }, title), /* @__PURE__ */ import_react125.default.createElement("form", { autoComplete: "off" }, Object.entries(fields).map(([id, fieldConfig]) => /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__field", key: `dialog-field-${id}` }, fieldConfig.label && /* @__PURE__ */ import_react125.default.createElement(
38769
- "label",
38770
- {
38771
- className: (0, import_clsx27.default)(
38772
- `str-chat__dialog__title str-chat__dialog__title--${id}`
38773
- ),
38774
- htmlFor: id
38775
- },
38776
- fieldConfig.label
38777
- ), import_react125.default.createElement(fieldConfig.element, {
38778
- id,
38779
- ...fieldConfig.props,
38780
- onChange: handleChange,
38781
- value: value[id]
38782
- }), /* @__PURE__ */ import_react125.default.createElement(FieldError, { text: fieldErrors[id]?.message }))))), /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__controls" }, /* @__PURE__ */ import_react125.default.createElement(
38783
- "button",
38784
- {
38785
- className: "str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel",
38786
- onClick: close
38787
- },
38788
- t("Cancel")
38789
- ), /* @__PURE__ */ import_react125.default.createElement(
38790
- "button",
38770
+ return /* @__PURE__ */ import_react125.default.createElement("div", { className: (0, import_clsx27.default)("str-chat__dialog str-chat__dialog--form", className) }, /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__body" }, title && /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__title" }, title), /* @__PURE__ */ import_react125.default.createElement(
38771
+ "form",
38791
38772
  {
38792
- className: "str-chat__dialog__controls-button str-chat__dialog__controls-button--submit",
38793
- disabled: Object.keys(fieldErrors).length > 0 || shouldDisableSubmitButton?.(value),
38794
- onClick: handleSubmit,
38795
- type: "submit"
38773
+ autoComplete: "off",
38774
+ onSubmit: (e) => {
38775
+ e.preventDefault();
38776
+ handleSubmit();
38777
+ }
38796
38778
  },
38797
- t("Send")
38779
+ Object.entries(fields).map(([id, fieldConfig]) => /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__field", key: `dialog-field-${id}` }, fieldConfig.label && /* @__PURE__ */ import_react125.default.createElement(
38780
+ "label",
38781
+ {
38782
+ className: (0, import_clsx27.default)(
38783
+ `str-chat__dialog__title str-chat__dialog__title--${id}`
38784
+ ),
38785
+ htmlFor: id
38786
+ },
38787
+ fieldConfig.label
38788
+ ), import_react125.default.createElement(fieldConfig.element, {
38789
+ id,
38790
+ ...fieldConfig.props,
38791
+ onChange: handleChange,
38792
+ value: value[id]
38793
+ }), /* @__PURE__ */ import_react125.default.createElement(FieldError, { text: fieldErrors[id]?.message }))),
38794
+ /* @__PURE__ */ import_react125.default.createElement("div", { className: "str-chat__dialog__controls" }, /* @__PURE__ */ import_react125.default.createElement(
38795
+ "button",
38796
+ {
38797
+ className: "str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel",
38798
+ onClick: close
38799
+ },
38800
+ t("Cancel")
38801
+ ), /* @__PURE__ */ import_react125.default.createElement(
38802
+ "button",
38803
+ {
38804
+ className: "str-chat__dialog__controls-button str-chat__dialog__controls-button--submit",
38805
+ disabled: Object.keys(fieldErrors).length > 0 || shouldDisableSubmitButton?.(value),
38806
+ type: "submit"
38807
+ },
38808
+ t("Send")
38809
+ ))
38798
38810
  )));
38799
38811
  };
38800
38812
 
@@ -51184,7 +51196,7 @@ var useChat = ({
51184
51196
  };
51185
51197
  (0, import_react264.useEffect)(() => {
51186
51198
  if (!client) return;
51187
- const version = "13.0.1";
51199
+ const version = "13.0.2";
51188
51200
  const userAgent = client.getUserAgent();
51189
51201
  if (!userAgent.includes("stream-chat-react")) {
51190
51202
  client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);