How to use the @react-md/form.useChoice function in @react-md/form

To help you get started, we’ve selected a few @react-md/form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mlaursen / react-md / packages / documentation / components / Demos / Form / TextFieldThemeConfig.tsx View on Github external
const TextFieldThemeConfig: FC = ({
  idPrefix,
  children,
  renderField,
  disableDense,
  disableRightIcon,
}) => {
  const [useLeft, handleLeftChange, setLeftIcon] = useCheckboxState(false);
  const [useRight, handleRightChange, setRightIcon] = useCheckboxState(false);
  const [dense, handleDenseChange, setDense] = useCheckboxState(false);
  const [label, handleLabelChange, setLabel] = useCheckboxState(true);
  const [inline, handleInlineChange] = useCheckboxState(false);
  const [readOnly, handleReadOnlyChange, setReadOnly] = useCheckboxState(false);
  const [error, handleErrorChange, setError] = useCheckboxState(false);
  const [disabled, handleDisabledChange] = useCheckboxState(false);
  const [currentTheme, handleThemeChange] = useChoice(
    "outline",
    event => {
      // the "unstyled" state does not support icons and a label out of the box
      // and requires additional styling instead
      if (event.currentTarget.value === "none") {
        setLeftIcon(false);
        setRightIcon(false);
        setLabel(false);
      } else if (!label) {
        setLabel(true);
      }
    }
  );
  const isUnstyled = currentTheme === "none";
  if (disabled && error) {
    setError(false);
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / TextFieldTypes.tsx View on Github external
const TextFieldTypes: FC = () => {
  const [currentTheme, handleThemeChange] = useChoice(
    "outline"
  );

  return (
    <form>
      <fieldset>
        {themes.map(theme =&gt; (
          </fieldset></form>
github mlaursen / react-md / packages / documentation / components / Demos / Form / TextAreaExample.tsx View on Github external
const TextAreaExample: FC = () =&gt; {
  const [resize, handleResizeChange] = useChoice("auto");
  const [animate, handleAnimateChange] = useCheckboxState(true);
  const [rows, handleRowChange] = useChoice("2");
  const [maxRows, handleMaxRowChange, setMaxRows] = useChoice("-1");
  const rowsInt = parseInt(rows, 10);
  const maxRowsInt = parseInt(maxRows, 10);
  if (maxRowsInt !== -1 &amp;&amp; maxRowsInt &lt; rowsInt) {
    const i = MAX_ROWS.find(value =&gt; value &gt;= rowsInt) || -1;
    setMaxRows(`${i}`);
  }

  return (
     (
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / TextAreaExample.tsx View on Github external
const TextAreaExample: FC = () =&gt; {
  const [resize, handleResizeChange] = useChoice("auto");
  const [animate, handleAnimateChange] = useCheckboxState(true);
  const [rows, handleRowChange] = useChoice("2");
  const [maxRows, handleMaxRowChange, setMaxRows] = useChoice("-1");
  const rowsInt = parseInt(rows, 10);
  const maxRowsInt = parseInt(maxRows, 10);
  if (maxRowsInt !== -1 &amp;&amp; maxRowsInt &lt; rowsInt) {
    const i = MAX_ROWS.find(value =&gt; value &gt;= rowsInt) || -1;
    setMaxRows(`${i}`);
  }

  return (
     (
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / NativeSelectExample.tsx View on Github external
const NativeSelectExample: FC = () =&gt; {
  const [icon, handleIconChange, setIcon] = useCheckboxState(true);
  const [size, handleSizeChange] = useChoice("4");
  const [multiple, handleMultipleChange] = useCheckboxState(false);
  const [optgroup, handleOptgroupChange] = useCheckboxState(false);
  if (multiple &amp;&amp; icon) {
    setIcon(false);
  }

  return (
github mlaursen / react-md / packages / documentation / src / components / Demos / Alert / HandlingDuplicatedMessages.tsx View on Github external
const HandlingDuplicatedMessages: FC = ({
  duplicates,
  onDuplicateChange,
}) =&gt; {
  const addMessage = useAddMessage();
  const [key, handleKeyChange] = useChoice(ONLINE);
  return (
    <form> addMessage(MESSAGES[key])}&gt;
      <fieldset>
            <code>MessageQueue</code>
            {" duplicate behavior"}
          
        }
      &gt;
        </fieldset></form>
github mlaursen / react-md / packages / documentation / components / Demos / Alert / UpdatingMessagePriority.tsx View on Github external
const UpdatingMessagePriority: FC = () =&gt; {
  const addMessage = useAddMessage();
  const [priority, handlePriorityChange] = useChoice("next");
  const queue = useQueue();
  const [running, setRunning] = useState(false);

  if (running &amp;&amp; !queue.length) {
    setRunning(false);
  }

  const exampleNextFlow = useCallback(() =&gt; {
    addMessage({
      messageId: "message-1",
      children: "First normal message",
      messagePriority: "normal",
    });
    addMessage({
      messageId: "message-2",
      children: "Second normal message",
github mlaursen / react-md / packages / documentation / src / components / Demos / Sheet / PositionExamples.tsx View on Github external
const PositionExamples: FC = () =&gt; {
  const [position, handlePositionChange] = useChoice("left");
  const [visible, show, hide] = useToggle(false);

  return (
    
      <fieldset>
        {positions.map(pos =&gt; (
          
        ))}</fieldset>
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / TextAreaExample.tsx View on Github external
const TextAreaExample: FC = () =&gt; {
  const [resize, handleResizeChange] = useChoice("auto");
  const [animate, handleAnimateChange] = useCheckboxState(true);
  const [rows, handleRowChange] = useChoice("2");
  const [maxRows, handleMaxRowChange, setMaxRows] = useChoice("-1");
  const rowsInt = parseInt(rows, 10);
  const maxRowsInt = parseInt(maxRows, 10);
  if (maxRowsInt !== -1 &amp;&amp; maxRowsInt &lt; rowsInt) {
    const i = MAX_ROWS.find(value =&gt; value &gt;= rowsInt) || -1;
    setMaxRows(`${i}`);
  }

  return (
     (
github mlaursen / react-md / packages / documentation / src / components / Demos / Portal / CustomPortalContainer.tsx View on Github external
const CustomPortalContainer: FC = () =&gt; {
  const [selected, handleChange] = useChoice&lt;"0" | "1" | "2"&gt;("0");

  return (
    <div>
      
      </div>

@react-md/form

This package is for creating all the different form input types.

MIT
Latest version published 11 months ago

Package Health Score

66 / 100
Full package analysis