import React, { useState } from 'react'
import { CheckboxControl, ExternalLink, Modal } from '@wordpress/components'
import { __ } from '@wordpress/i18n'
import { useSnippetForm } from '../../../hooks/useSnippetForm'
import { Button } from '../../common/Button'
import { CopyToClipboardButton } from '../../common/CopyToClipboardButton'
import type { Dispatch, SetStateAction } from 'react'
type ShortcodeAtts = Record
const buildShortcodeTag = (tag: string, atts: ShortcodeAtts): string =>
`[${[
tag,
...Object.entries(atts)
.filter(([, value]) => Boolean(value))
.map(([att, value]) =>
'boolean' === typeof value ? att : `${att}=${JSON.stringify(value)}`)
].filter(Boolean).join(' ')}]`
const SHORTCODE_TAG = 'code_snippet'
interface ShortcodeOptions {
php: boolean
format: boolean
shortcodes: boolean
}
interface CheckboxListProps {
options: T[]
checked: Record
disabled: boolean
setChecked: Dispatch>>
optionLabels: Partial>
optionDescriptions: Partial>
}
const CheckboxList = ({
options,
checked,
disabled,
setChecked,
optionLabels,
optionDescriptions
}: CheckboxListProps) =>
{options.map(option =>
setChecked(previous => ({ ...previous, [option]: value }))}
/>
)}
const ShortcodeDescription = () =>
{__('Copy the below shortcode to insert this snippet into a post, page, or other content.', 'code-snippets')}{'\n'}
{__('You can also use the Classic Editor button, Block editor (Pro) or Elementor widget (Pro).', 'code-snippets')}{'\n'}
{__('Learn more', 'code-snippets')}