import { CodeBlock, ConfigBlock } from "@src/helpers/DocBlocks";
import OPTIONS from "./constants";
import Dropdown from "./Dropdown";
import DateIcon from "@src/icons/date.svg";
import ArrowDownIconV2 from "@src/components/UI/Icon/Icons/ArrowDownIconV2";
import ProactiveMessagingIcon from "@src/components/UI/Icon/MultiColouredIcons/ProactiveMessagingIcon";

# Dropdown

> A regular dropdown. Adheres to Haptik's Design System.

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
    marginTop: "3rem"
  }}
>
<CodeBlock title="Themed">
  {(value, setValue) => (
      <Dropdown
        themed
        placeholder="Select a value"
        options={OPTIONS.THEMED}
        label="Label"
        value={value}
        onChange={setValue}
      />
    )}
</CodeBlock>

<CodeBlock title="Themed">
  {(value, setValue) => (
      <Dropdown
        themed
        options={[
          { text: "SMS" },
          { text: "WhatsApp" },
        ]}
        value="Proactive Messaging"
        onChange={setValue}
        style={{ width: "210px" }}
        icon={ProactiveMessagingIcon}
        arrowIcon={<ArrowDownIconV2 size="extraSmall" />}
      />
    )}
</CodeBlock>

<CodeBlock title="Regular">
{(value, setValue) => (
    <Dropdown
    placeholder="Test placeholder"
    className="my-dropdown"
    prefixClassName="my-yoooo"
    options={OPTIONS.DEFAULT}
    label="This is a label"
    value={value}
    onChange={setValue}
    />
)}

</CodeBlock>
</div>

## Configuration

<ConfigBlock of={Dropdown} />

## Examples

#### Default

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>
<CodeBlock title="Themed">
  {(value, setValue) => (
      <Dropdown
        themed
        placeholder="Select a value"
        options={OPTIONS.THEMED}
        label="Label"
        value={value}
        onChange={setValue}
      />
    )}
</CodeBlock>

<CodeBlock title="Regular">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.DEFAULT}
      label="This is a label"
      value={value}
      onChange={setValue}
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Select a value"
      options={OPTIONS.THEMED}
      value={value}
      label="This is a label"
      value={value}
      onChange={setValue}
      icon={DateIcon}
      themed
    />
  )}
</CodeBlock>

<CodeBlock title="Themed, small with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Select a value"
      options={OPTIONS.THEMED}
      value={value}
      label="This is a label"
      value={value}
      onChange={setValue}
      icon={DateIcon}
      themed
      size="small"
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### With Search

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>
<CodeBlock title="Themed">
  {(value, setValue) => (
      <Dropdown
        themed
        placeholder="Select a value"
        options={OPTIONS.THEMED}
        label="Label"
        value={value}
        onChange={setValue}
        withSearch
      />
    )}
</CodeBlock>

<CodeBlock title="Regular">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.DEFAULT}
      label="This is a label"
      value={value}
      onChange={setValue}
      withSearch
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Select a value"
      options={OPTIONS.THEMED}
      label="Label"
      value={value}
      onChange={setValue}
      withSearch
      icon={DateIcon}
    />
    )}
</CodeBlock>
</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### With Multiple

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>
<CodeBlock title="Themed">
  {(value, setValue) => (
      <Dropdown
        themed
        placeholder="Select items"
        options={OPTIONS.THEMED}
        label="Label"
        value={value}
        onChange={setValue}
        withMultiple
        withSearch
      />
    )}
</CodeBlock>

<CodeBlock title="Regular">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.DEFAULT}
      label="This is a label"
      value={value}
      onChange={setValue}
      withMultiple
      withSearch
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Select items"
      options={OPTIONS.THEMED}
      label="Label"
      value={value}
      onChange={setValue}
      withMultiple
      withSearch
      icon={DateIcon}
    />
    )}
</CodeBlock>
</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### With Multiple, With Search & With Checkbox 🧐

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed" defaultValue={[{ title: "Option text 1" }]}>
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withSearch
      withCheckbox
    />
  )}
</CodeBlock>

<CodeBlock title="Default" defaultValue={[{ title: "Option text 1" }]}>
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withSearch
      withCheckbox
    />
  )}
</CodeBlock>

<CodeBlock
  title="Themed with prefix icon"
  defaultValue={[{ title: "Option text 1" }]}
>
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withSearch
      withCheckbox
      icon={DateIcon}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### With Multiple & With Checkbox

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed" defaultValue={[{ title: "Option text 1" }]}>
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withCheckbox
    />
  )}
</CodeBlock>

<CodeBlock title="Default" defaultValue={[{ title: "Option text 1" }]}>
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withCheckbox
    />
  )}
</CodeBlock>

<CodeBlock
  title="Themed with prefix icon"
  defaultValue={[{ title: "Option text 1" }]}
>
  {(value, setValue) => (
    <Dropdown
      themed
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.SEARCH}
      label="This is the label"
      value={value}
      onChange={setValue}
      optionKey="title"
      searchKeys={["title"]}
      withMultiple
      withCheckbox
      icon={DateIcon}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### With Create

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.THEMED}
      label="This is the label"
      value={value}
      onChange={setValue}
      withCreate
      withSearch
      themed
    />
  )}
</CodeBlock>

<CodeBlock title="Default">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.DEFAULT}
      label="This is the label"
      value={value}
      onChange={setValue}
      withCreate
      withSearch
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      options={OPTIONS.THEMED}
      label="This is the label"
      value={value}
      onChange={setValue}
      withCreate
      withSearch
      themed
      icon={DateIcon}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### Disabled

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={[{ text: "Nice" }]}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      themed
      disabled
    />
  )}
</CodeBlock>

<CodeBlock title="Default">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={[{ text: "Option text 1" }]}
      options={OPTIONS.DEFAULT}
      label="This is the label"
      onChange={setValue}
      disabled
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={[{ text: "Nice" }]}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      themed
      disabled
      icon={DateIcon}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### Simple Array

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
    />
  )}
</CodeBlock>

<CodeBlock title="Default">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={OPTIONS.DEFAULT}
      label="This is the label"
      onChange={setValue}
      withSearch
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
      icon={DateIcon}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### Style

> These styles will only get applied to the main dropdown wrapper and only for themed prop

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      value={value}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
      style={{
        padding: 10,
        border: "1px solid blue",
        borderRadius: 5,
      }}
    />
  )}
</CodeBlock>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### Error

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
      error="Nope!"
    />
  )}
</CodeBlock>

<CodeBlock title="Default">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={OPTIONS.DEFAULT}
      label="This is the label"
      onChange={setValue}
      withSearch
      error="Noooo!"
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      value={value}
      options={OPTIONS.THEMED}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
      icon={DateIcon}
      style={{
        padding: 10,
        border: "1px solid blue",
        borderRadius: 5,
      }}
    />
  )}
</CodeBlock>

</div>

<div style={{ marginBottom: 30, marginTop: 30, border: "1px solid #d5d5d5" }} />

#### Empty State

<div
  style={{
    display: "grid",
    gridTemplateColumns: "50% 48%",
    gridColumnGap: "15px",
  }}
>

<CodeBlock title="Themed">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={[]}
      label="This is the label"
      onChange={setValue}
      withSearch
      themed
    />
  )}
</CodeBlock>

<CodeBlock title="Default">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={[]}
      label="This is the label"
      onChange={setValue}
      withSearch
    />
  )}
</CodeBlock>

<CodeBlock title="Themed with prefix icon">
  {(value, setValue) => (
    <Dropdown
      placeholder="Test placeholder"
      className="my-dropdown"
      prefixClassName="my-yoooo"
      value={value}
      options={[]}
      label="This is the label"
      onChange={setValue}
      withSearch
      icon={DateIcon}
      themed
    />
  )}
</CodeBlock>

</div>
