/* Copyright 2024 New Vector Ltd. Copyright 2021 The Matrix.org Foundation C.I.C. SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ import React, { type ReactElement } from "react"; import { JoinRule } from "matrix-js-sdk/src/matrix"; import Dropdown from "./Dropdown"; import { type NonEmptyArray } from "../../../@types/common"; import { Icon as AskToJoinIcon } from "../../../../res/img/element-icons/ask-to-join.svg"; interface IProps { value: JoinRule; label: string; width?: number; labelInvite: string; labelKnock?: string; labelPublic: string; labelRestricted?: string; // if omitted then this option will be hidden, e.g if unsupported onChange(value: JoinRule): void; } const JoinRuleDropdown: React.FC = ({ label, labelInvite, labelKnock, labelPublic, labelRestricted, value, width = 448, onChange, }) => { const options = [
{labelInvite}
,
{labelPublic}
, ] as NonEmptyArray; if (labelKnock) { options.unshift( (
{labelKnock}
) as ReactElement & { key: string }, ); } if (labelRestricted) { options.unshift( (
{labelRestricted}
) as ReactElement & { key: string }, ); } return ( {options} ); }; export default JoinRuleDropdown;