@traefik-labs/faency 13.7.0 → 13.7.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.
- package/README.md +12 -5
- package/dist/components/AriaTable/AriaTable.cjs +48 -22
- package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.js +49 -23
- package/dist/components/AriaTable/AriaTable.js.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.cjs +8 -4
- package/dist/components/AriaTable/AriaTable.vanilla.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.css.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.css.js.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.js +8 -4
- package/dist/components/AriaTable/AriaTable.vanilla.js.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.cjs +5 -2
- package/dist/components/Avatar/Avatar.vanilla.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.css.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.css.js.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.js +5 -2
- package/dist/components/Avatar/Avatar.vanilla.js.map +1 -1
- package/dist/components/Badge/Badge.vanilla.cjs +2 -10
- package/dist/components/Badge/Badge.vanilla.cjs.map +1 -1
- package/dist/components/Badge/Badge.vanilla.css.cjs.map +1 -1
- package/dist/components/Badge/Badge.vanilla.css.js.map +1 -1
- package/dist/components/Badge/Badge.vanilla.js +2 -10
- package/dist/components/Badge/Badge.vanilla.js.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.cjs +5 -11
- package/dist/components/Blockquote/Blockquote.vanilla.cjs.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.css.cjs.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.css.js.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.js +5 -11
- package/dist/components/Blockquote/Blockquote.vanilla.js.map +1 -1
- package/dist/components/Box/Box.vanilla.cjs +2 -10
- package/dist/components/Box/Box.vanilla.cjs.map +1 -1
- package/dist/components/Box/Box.vanilla.css.cjs.map +1 -1
- package/dist/components/Box/Box.vanilla.css.js.map +1 -1
- package/dist/components/Box/Box.vanilla.js +2 -10
- package/dist/components/Box/Box.vanilla.js.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.cjs +2 -10
- package/dist/components/Bubble/Bubble.vanilla.cjs.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.css.cjs.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.css.js.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.js +2 -10
- package/dist/components/Bubble/Bubble.vanilla.js.map +1 -1
- package/dist/components/Button/Button.vanilla.cjs +2 -10
- package/dist/components/Button/Button.vanilla.cjs.map +1 -1
- package/dist/components/Button/Button.vanilla.css.cjs.map +1 -1
- package/dist/components/Button/Button.vanilla.css.js.map +1 -1
- package/dist/components/Button/Button.vanilla.js +2 -10
- package/dist/components/Button/Button.vanilla.js.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.cjs +3 -17
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.cjs.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.css.cjs.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.css.js.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.js +3 -17
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.js.map +1 -1
- package/dist/components/Card/Card.vanilla.cjs +6 -11
- package/dist/components/Card/Card.vanilla.cjs.map +1 -1
- package/dist/components/Card/Card.vanilla.css.cjs.map +1 -1
- package/dist/components/Card/Card.vanilla.css.js.map +1 -1
- package/dist/components/Card/Card.vanilla.js +6 -11
- package/dist/components/Card/Card.vanilla.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +3 -6
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -6
- package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.cjs +3 -10
- package/dist/components/Combobox/Combobox.vanilla.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.css.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.css.js.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.js +3 -10
- package/dist/components/Combobox/Combobox.vanilla.js.map +1 -1
- package/dist/components/Container/Container.vanilla.cjs +5 -11
- package/dist/components/Container/Container.vanilla.cjs.map +1 -1
- package/dist/components/Container/Container.vanilla.css.cjs.map +1 -1
- package/dist/components/Container/Container.vanilla.css.js.map +1 -1
- package/dist/components/Container/Container.vanilla.js +5 -11
- package/dist/components/Container/Container.vanilla.js.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.cjs +5 -11
- package/dist/components/Elevation/Elevation.vanilla.cjs.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.css.cjs.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.css.js.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.js +5 -11
- package/dist/components/Elevation/Elevation.vanilla.js.map +1 -1
- package/dist/components/Field/Field.vanilla.cjs +3 -9
- package/dist/components/Field/Field.vanilla.cjs.map +1 -1
- package/dist/components/Field/Field.vanilla.css.cjs.map +1 -1
- package/dist/components/Field/Field.vanilla.css.js.map +1 -1
- package/dist/components/Field/Field.vanilla.js +3 -9
- package/dist/components/Field/Field.vanilla.js.map +1 -1
- package/dist/components/Flex/Flex.vanilla.cjs +5 -11
- package/dist/components/Flex/Flex.vanilla.cjs.map +1 -1
- package/dist/components/Flex/Flex.vanilla.css.cjs.map +1 -1
- package/dist/components/Flex/Flex.vanilla.css.js.map +1 -1
- package/dist/components/Flex/Flex.vanilla.js +5 -11
- package/dist/components/Flex/Flex.vanilla.js.map +1 -1
- package/dist/components/Grid/Grid.vanilla.cjs +7 -11
- package/dist/components/Grid/Grid.vanilla.cjs.map +1 -1
- package/dist/components/Grid/Grid.vanilla.css.cjs.map +1 -1
- package/dist/components/Grid/Grid.vanilla.css.js.map +1 -1
- package/dist/components/Grid/Grid.vanilla.js +7 -11
- package/dist/components/Grid/Grid.vanilla.js.map +1 -1
- package/dist/components/Heading/Heading.vanilla.cjs +35 -0
- package/dist/components/Heading/Heading.vanilla.cjs.map +1 -0
- package/dist/components/Heading/Heading.vanilla.css.cjs +85 -0
- package/dist/components/Heading/Heading.vanilla.css.cjs.map +1 -0
- package/dist/components/Heading/Heading.vanilla.css.js +74 -0
- package/dist/components/Heading/Heading.vanilla.css.js.map +1 -0
- package/dist/components/Heading/Heading.vanilla.js +30 -0
- package/dist/components/Heading/Heading.vanilla.js.map +1 -0
- package/dist/components/IconButton/IconButton.vanilla.cjs +5 -11
- package/dist/components/IconButton/IconButton.vanilla.cjs.map +1 -1
- package/dist/components/IconButton/IconButton.vanilla.css.cjs.map +1 -1
- package/dist/components/IconButton/IconButton.vanilla.css.js.map +1 -1
- package/dist/components/IconButton/IconButton.vanilla.js +5 -11
- package/dist/components/IconButton/IconButton.vanilla.js.map +1 -1
- package/dist/components/Image/Image.vanilla.cjs +2 -10
- package/dist/components/Image/Image.vanilla.cjs.map +1 -1
- package/dist/components/Image/Image.vanilla.css.cjs.map +1 -1
- package/dist/components/Image/Image.vanilla.css.js.map +1 -1
- package/dist/components/Image/Image.vanilla.js +2 -10
- package/dist/components/Image/Image.vanilla.js.map +1 -1
- package/dist/components/Input/Input.vanilla.cjs +2 -10
- package/dist/components/Input/Input.vanilla.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.js.map +1 -1
- package/dist/components/Input/Input.vanilla.js +2 -10
- package/dist/components/Input/Input.vanilla.js.map +1 -1
- package/dist/components/Label/Label.vanilla.cjs +5 -11
- package/dist/components/Label/Label.vanilla.cjs.map +1 -1
- package/dist/components/Label/Label.vanilla.css.cjs.map +1 -1
- package/dist/components/Label/Label.vanilla.css.js.map +1 -1
- package/dist/components/Label/Label.vanilla.js +5 -11
- package/dist/components/Label/Label.vanilla.js.map +1 -1
- package/dist/components/List/List.vanilla.cjs +10 -18
- package/dist/components/List/List.vanilla.cjs.map +1 -1
- package/dist/components/List/List.vanilla.css.cjs.map +1 -1
- package/dist/components/List/List.vanilla.css.js.map +1 -1
- package/dist/components/List/List.vanilla.js +7 -15
- package/dist/components/List/List.vanilla.js.map +1 -1
- package/dist/components/Meter/Meter.vanilla.cjs +3 -8
- package/dist/components/Meter/Meter.vanilla.cjs.map +1 -1
- package/dist/components/Meter/Meter.vanilla.css.cjs.map +1 -1
- package/dist/components/Meter/Meter.vanilla.css.js.map +1 -1
- package/dist/components/Meter/Meter.vanilla.js +3 -8
- package/dist/components/Meter/Meter.vanilla.js.map +1 -1
- package/dist/components/Panel/Panel.vanilla.cjs +2 -10
- package/dist/components/Panel/Panel.vanilla.cjs.map +1 -1
- package/dist/components/Panel/Panel.vanilla.css.cjs.map +1 -1
- package/dist/components/Panel/Panel.vanilla.css.js.map +1 -1
- package/dist/components/Panel/Panel.vanilla.js +2 -10
- package/dist/components/Panel/Panel.vanilla.js.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.cjs +5 -11
- package/dist/components/Paragraph/Paragraph.vanilla.cjs.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.css.cjs.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.css.js.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.js +5 -11
- package/dist/components/Paragraph/Paragraph.vanilla.js.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.cjs.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.css.cjs.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.css.js.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs +3 -14
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js +3 -14
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.cjs +2 -10
- package/dist/components/Skeleton/Skeleton.vanilla.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.css.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.css.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.js +2 -10
- package/dist/components/Skeleton/Skeleton.vanilla.js.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.cjs +3 -6
- package/dist/components/Spinner/Spinner.vanilla.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.css.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.css.js.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.js +3 -6
- package/dist/components/Spinner/Spinner.vanilla.js.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs +3 -10
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.js.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.js +3 -10
- package/dist/components/SplitLayout/SplitLayout.vanilla.js.map +1 -1
- package/dist/components/Table/Table.vanilla.cjs +8 -4
- package/dist/components/Table/Table.vanilla.cjs.map +1 -1
- package/dist/components/Table/Table.vanilla.css.cjs.map +1 -1
- package/dist/components/Table/Table.vanilla.css.js.map +1 -1
- package/dist/components/Table/Table.vanilla.js +8 -4
- package/dist/components/Table/Table.vanilla.js.map +1 -1
- package/dist/components/Text/Text.vanilla.cjs +5 -11
- package/dist/components/Text/Text.vanilla.cjs.map +1 -1
- package/dist/components/Text/Text.vanilla.css.cjs.map +1 -1
- package/dist/components/Text/Text.vanilla.css.js.map +1 -1
- package/dist/components/Text/Text.vanilla.js +5 -11
- package/dist/components/Text/Text.vanilla.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.css.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.css.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.cjs +2 -10
- package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.js +2 -10
- package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
- package/dist/components/Toast/Toast.vanilla.cjs +4 -15
- package/dist/components/Toast/Toast.vanilla.cjs.map +1 -1
- package/dist/components/Toast/Toast.vanilla.css.cjs.map +1 -1
- package/dist/components/Toast/Toast.vanilla.css.js.map +1 -1
- package/dist/components/Toast/Toast.vanilla.js +4 -15
- package/dist/components/Toast/Toast.vanilla.js.map +1 -1
- package/dist/faency.css +118 -2
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +36800 -0
- package/dist/index.d.ts +248 -94
- package/dist/index.js +3 -1
- package/dist/styles/recipeVariants.cjs +15 -0
- package/dist/styles/recipeVariants.cjs.map +1 -0
- package/dist/styles/recipeVariants.js +15 -0
- package/dist/styles/recipeVariants.js.map +1 -0
- package/dist/styles/themeContext.cjs.map +1 -1
- package/dist/styles/themeContext.js.map +1 -1
- package/dist/styles/themes.css.cjs.map +1 -1
- package/dist/styles/themes.css.js.map +1 -1
- package/dist/styles/tokens.css.cjs.map +1 -1
- package/dist/styles/tokens.css.js.map +1 -1
- package/dist/utils/warnOnce.cjs +8 -1
- package/dist/utils/warnOnce.cjs.map +1 -1
- package/dist/utils/warnOnce.js +8 -1
- package/dist/utils/warnOnce.js.map +1 -1
- package/package.json +32 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.css.js","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
2
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
4
|
import { useIsomorphicLayoutEffect } from "../../utils/useIsomorphicLayoutEffect.js";
|
|
5
5
|
import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
|
|
6
6
|
import { ButtonVanilla } from "../Button/Button.vanilla.js";
|
|
@@ -8,20 +8,17 @@ import { codeContent, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight,
|
|
|
8
8
|
import { Prism } from "./prism-extend.js";
|
|
9
9
|
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
|
|
10
10
|
import { forwardRef, useCallback, useRef, useState } from "react";
|
|
11
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
12
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
12
|
import { Highlight, themes } from "prism-react-renderer";
|
|
14
13
|
// components/CodeBlock/CodeBlock.vanilla.tsx
|
|
15
14
|
var CodeBlockVanilla = forwardRef(({ lang = "text", code, copyable = false, copyText, copiedText, copyButtonAlign = "top right", onCopy, onCopyError, noBorder, wrapText = false, colorScheme, maxHeight = 424, css, style, className, ...props }, ref) => {
|
|
16
|
-
const {
|
|
15
|
+
const { resolvedTheme } = useVanillaExtractTheme();
|
|
17
16
|
const prismTheme = (colorScheme ?? resolvedTheme) === "dark" ? themes.nightOwl : themes.nightOwlLight;
|
|
18
17
|
const isBottom = copyButtonAlign.includes("bottom");
|
|
19
18
|
const isLeft = copyButtonAlign.includes("left");
|
|
20
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
21
19
|
const containerStyles = {
|
|
22
20
|
position: "relative",
|
|
23
|
-
...
|
|
24
|
-
...assignInlineVars(vars)
|
|
21
|
+
...useInlineStyle(css)
|
|
25
22
|
};
|
|
26
23
|
const [copied, setCopied] = useState(false);
|
|
27
24
|
const preRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport {
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useVanillaExtractTheme } from '@/styles/themeContext';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\nimport { useIsomorphicLayoutEffect } from '@/utils/useIsomorphicLayoutEffect';\n\nimport { AccessibleIcon } from '@/components/AccessibleIcon';\nimport { ButtonVanilla } from '@/components/Button';\n\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>, CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const inlineStyle = useInlineStyle(css);\n const containerStyles = { position: 'relative' as const, ...inlineStyle };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={cx(pre, noBorder && preNoBorder, highlightClass, className)}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={cx(\n codeContent,\n copyable && isLeft && isBottom && codeContentBottomPadding,\n copyable && isLeft && !isBottom && codeContentTopPadding,\n )}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAa,mBAAmB,YAE5B,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,kBAAkB,uBAAuB;CAEjD,MAAM,cADkB,eAAe,mBACA,SAAS,OAAO,WAAW,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAG9C,MAAM,kBAAkB;EAAE,UAAU;EAAqB,GADrC,eAAe,GACyB;CAAY;CAExE,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OACb,IACF;CACA,MAAM,mBAAmB,OAAuB,IAAI;CAEpD,MAAM,YAAY,aACf,SAAgC;EAC/B,OAAO,UAAU;EACjB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAuD,UAAU;CACjF,GACA,CAAC,GAAG,CACN;CAEA,gCAAgC;EAC9B,IAAI,CAAC,UAAU;EACf,MAAM,MAAM,OAAO;EACnB,MAAM,UAAU,iBAAiB;EACjC,IAAI,CAAC,OAAO,CAAC,SAAS;EAEtB,MAAM,UAAU,WAAW,IAAI;EAE/B,MAAM,eAAe;GACnB,IAAI,CAAC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CACE,oBAAC,OAAD;IACE,KAAK;IACL,WAAW,GAAG,KAAK,YAAA,aAAyB,gBAAgB,SAAS;IACrE,OAAO;KACL;KACA,GAAG;KACH,iBAAiB;KACjB,GAAG;IACL;IACA,GAAI;IAEJ,UAAA,oBAAC,OAAD;KACE,WAAW,GACT,aACA,YAAY,UAAU,YAAA,aACtB,YAAY,UAAU,CAAC,YAAA,WACzB;KAEC,UAAA,OAAO,KAAK,MAAM,MACjB,oBAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,oBAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,oBAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
2
|
const require_cx = require("../../styles/cx.cjs");
|
|
4
|
-
const
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
4
|
const require_Input_vanilla = require("../Input/Input.vanilla.cjs");
|
|
6
5
|
const require_Combobox_vanilla_css = require("./Combobox.vanilla.css.cjs");
|
|
7
6
|
let react = require("react");
|
|
8
7
|
react = require_runtime.__toESM(react, 1);
|
|
9
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
10
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
9
|
let _radix_ui_react_popover = require("@radix-ui/react-popover");
|
|
12
10
|
_radix_ui_react_popover = require_runtime.__toESM(_radix_ui_react_popover, 1);
|
|
13
11
|
// components/Combobox/Combobox.vanilla.tsx
|
|
14
12
|
var defaultFilter = (suggestion, query) => suggestion.toLowerCase().includes(query.toLowerCase());
|
|
15
13
|
var ComboboxVanilla = (0, react.forwardRef)(({ value: valueProp, defaultValue = "", onValueChange, suggestions, emptyText, filter = defaultFilter, openOnFocus = true, id: idProp, size, disabled, readOnly, className, style, css, onFocus, onBlur, onKeyDown, ...props }, ref) => {
|
|
16
|
-
const
|
|
17
|
-
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
14
|
+
const inlineStyle = require_useInlineStyle.useInlineStyle(css, style);
|
|
18
15
|
const autoId = (0, react.useId)();
|
|
19
16
|
const id = idProp ?? autoId;
|
|
20
17
|
const listId = `${id}-listbox`;
|
|
@@ -86,11 +83,7 @@ var ComboboxVanilla = (0, react.forwardRef)(({ value: valueProp, defaultValue =
|
|
|
86
83
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
87
84
|
ref: anchorRef,
|
|
88
85
|
className: require_cx.cx(require_Combobox_vanilla_css.comboboxAnchor, className),
|
|
89
|
-
style:
|
|
90
|
-
...cssStyles,
|
|
91
|
-
...style,
|
|
92
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
93
|
-
},
|
|
86
|
+
style: inlineStyle,
|
|
94
87
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input_vanilla.InputVanilla, {
|
|
95
88
|
ref,
|
|
96
89
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","processCSSProp","useId","useRef","useState","PopoverPrimitive","cx","comboboxAnchor","assignInlineVars","InputVanilla","comboboxContent","comboboxListbox","comboboxOptionRecipe","comboboxEmptyRecipe"],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { cx } from '../../styles/cx';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input/Input.vanilla';\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div\n ref={anchorRef}\n className={cx(comboboxAnchor, className)}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n >\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,mBAAA,GAAkBA,M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AAS,KAAK;KAClB,MAAK;KACL,iBAAe,UAAU;KACzB,oBAAkB,UAAU,SAAS,KAAK,KAAA;KAC1C,WAAWC,6BAAAA,qBAAqB,EAAE,KAAK,CAAC;KACxC,mBAAmB,UAAU,UAAU,eAAe,KAAK;KAC3D,eAAe,OAAO,UAAU;KAE/B,UAAA;IACC,GAVG,SAAS,KAAK,CAUjB,CACL;GACC,CAAA,IAEJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,MAAK;IAAS,WAAWC,6BAAAA,oBAAoB,EAAE,KAAK,CAAC;IACvD,UAAA;GACE,CAAA;EAEiB,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.cjs","names":["forwardRef","useInlineStyle","useId","useRef","useState","PopoverPrimitive","cx","comboboxAnchor","InputVanilla","comboboxContent","comboboxListbox","comboboxOptionRecipe","comboboxEmptyRecipe"],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '@/components/Input/Input.vanilla';\n\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const inlineStyle = useInlineStyle(css, style);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div ref={anchorRef} className={cx(comboboxAnchor, className)} style={inlineStyle}>\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,mBAAA,GAAkBA,MAAAA,WAAAA,EAE3B,EACE,OAAO,WACP,eAAe,IACf,eACA,aACA,WACA,SAAS,eACT,cAAc,MACd,IAAI,QACJ,MACA,UACA,UACA,WACA,OACA,KACA,SACA,QACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,cAAcC,uBAAAA,eAAe,KAAK,KAAK;CAE7C,MAAM,UAAA,GAASC,MAAAA,MAAAA,CAAM;CACrB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,GAAG,GAAG;CACrB,MAAM,YAAY,UAAkB,GAAG,GAAG,UAAU;CAEpD,MAAM,aAAA,GAAYC,MAAAA,OAAAA,CAAuB,IAAI;CAC7C,MAAM,CAAC,YAAY,kBAAA,GAAiBC,MAAAA,SAAAA,CAAS,YAAY;CACzD,MAAM,QAAQ,aAAa;CAC3B,MAAM,CAAC,MAAM,YAAA,GAAWA,MAAAA,SAAAA,CAAS,KAAK;CACtC,MAAM,CAAC,OAAO,aAAA,GAAYA,MAAAA,SAAAA,CAAS,EAAE;CACrC,MAAM,CAAC,aAAa,m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AkB;GAClB,kBAAkB,MAAM,EAAE,eAAe;GACzC,mBAAmB,MAAM,EAAE,eAAe;GAC1C,oBAAoB,MAAM;IACxB,IAAI,UAAU,SAAS,SAAS,EAAE,MAAc,GAAG,EAAE,eAAe;GACtE;GAEA,cAAc,MAAM,EAAE,eAAe;GAEpC,UAAA,WACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;IACE,IAAI;IACJ,MAAK;IACL,cACE,MAAM,qBAAqB,KAAA,IAAa,MAAM,iBAAiB;IAEjE,mBAAiB,MAAM;IACvB,WAAWC,6BAAAA;IAEV,UAAA,MAAM,KAAK,YAAY,UACtB,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;KAEE,IAAI,SAAS,KAAK;KAClB,MAAK;KACL,iBAAe,UAAU;KACzB,oBAAkB,UAAU,SAAS,KAAK,KAAA;KAC1C,WAAWC,6BAAAA,qBAAqB,EAAE,KAAK,CAAC;KACxC,mBAAmB,UAAU,UAAU,eAAe,KAAK;KAC3D,eAAe,OAAO,UAAU;KAE/B,UAAA;IACC,GAVG,SAAS,KAAK,CAUjB,CACL;GACC,CAAA,IAEJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,MAAK;IAAS,WAAWC,6BAAAA,oBAAoB,EAAE,KAAK,CAAC;IACvD,UAAA;GACE,CAAA;EAEiB,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.css.cjs","names":[
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.css.js","names":[
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
3
|
import { InputVanilla } from "../Input/Input.vanilla.js";
|
|
5
4
|
import { comboboxAnchor, comboboxContent, comboboxEmptyRecipe, comboboxListbox, comboboxOptionRecipe } from "./Combobox.vanilla.css.js";
|
|
6
5
|
import { forwardRef, useEffect, useId, useRef, useState } from "react";
|
|
7
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
8
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
7
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
10
8
|
// components/Combobox/Combobox.vanilla.tsx
|
|
11
9
|
var defaultFilter = (suggestion, query) => suggestion.toLowerCase().includes(query.toLowerCase());
|
|
12
10
|
var ComboboxVanilla = forwardRef(({ value: valueProp, defaultValue = "", onValueChange, suggestions, emptyText, filter = defaultFilter, openOnFocus = true, id: idProp, size, disabled, readOnly, className, style, css, onFocus, onBlur, onKeyDown, ...props }, ref) => {
|
|
13
|
-
const
|
|
14
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
11
|
+
const inlineStyle = useInlineStyle(css, style);
|
|
15
12
|
const autoId = useId();
|
|
16
13
|
const id = idProp ?? autoId;
|
|
17
14
|
const listId = `${id}-listbox`;
|
|
@@ -83,11 +80,7 @@ var ComboboxVanilla = forwardRef(({ value: valueProp, defaultValue = "", onValue
|
|
|
83
80
|
children: /* @__PURE__ */ jsx("div", {
|
|
84
81
|
ref: anchorRef,
|
|
85
82
|
className: cx(comboboxAnchor, className),
|
|
86
|
-
style:
|
|
87
|
-
...cssStyles,
|
|
88
|
-
...style,
|
|
89
|
-
...assignInlineVars(vars)
|
|
90
|
-
},
|
|
83
|
+
style: inlineStyle,
|
|
91
84
|
children: /* @__PURE__ */ jsx(InputVanilla, {
|
|
92
85
|
ref,
|
|
93
86
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.js","names":[],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { cx } from '../../styles/cx';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input/Input.vanilla';\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div\n ref={anchorRef}\n className={cx(comboboxAnchor, className)}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n >\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;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,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.js","names":[],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '@/components/Input/Input.vanilla';\n\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const inlineStyle = useInlineStyle(css, style);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div ref={anchorRef} className={cx(comboboxAnchor, className)} style={inlineStyle}>\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;AAiBA,IAAM,iBAAiB,YAAoB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
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
2
|
const require_cx = require("../../styles/cx.cjs");
|
|
4
|
-
const
|
|
3
|
+
const require_recipeVariants = require("../../styles/recipeVariants.cjs");
|
|
4
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
5
|
const require_Container_vanilla_css = require("./Container.vanilla.css.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_runtime.__toESM(react, 1);
|
|
8
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
9
|
// components/Container/Container.vanilla.tsx
|
|
10
|
+
var containerClass = require_recipeVariants.withVariantKeys(require_Container_vanilla_css.containerRecipe);
|
|
11
11
|
var ContainerVanillaComponent = react.default.forwardRef(({ as, className, css, style, size, noGutter, ...props }, ref) => {
|
|
12
12
|
const Component = as || "div";
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const mergedStyles = {
|
|
16
|
-
...cssStyles,
|
|
17
|
-
...style,
|
|
18
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
19
|
-
};
|
|
20
|
-
const recipeClass = require_Container_vanilla_css.containerRecipe({
|
|
13
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
14
|
+
const recipeClass = containerClass({
|
|
21
15
|
size,
|
|
22
16
|
noGutter
|
|
23
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.vanilla.cjs","names":["
|
|
1
|
+
{"version":3,"file":"Container.vanilla.cjs","names":["withVariantKeys","containerRecipe","React","useInlineStyle","cx"],"sources":["../../../components/Container/Container.vanilla.tsx"],"sourcesContent":["import React, { ElementType } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { containerRecipe } from './Container.vanilla.css';\n\nconst containerClass = withVariantKeys(containerRecipe);\n\ninterface ContainerOwnProps extends RecipeVariantProps<typeof containerRecipe>, CSSProps {}\n\nexport type ContainerProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ContainerOwnProps\n>;\ntype ContainerComponent = PolymorphicComponent<'div', ContainerProps<ElementType>>;\n\nexport const ContainerVanillaComponent = React.forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, size, noGutter, ...props }: ContainerProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || 'div';\n\n const mergedStyles = useInlineStyle(css, style);\n\n const recipeClass = containerClass({ size, noGutter });\n\n return (\n <Component ref={ref} className={cx(recipeClass, className)} style={mergedStyles} {...props} />\n );\n },\n);\n\nContainerVanillaComponent.displayName = 'ContainerVanilla';\n\nexport const ContainerVanilla = ContainerVanillaComponent as ContainerComponent;\n"],"mappings":";;;;;;;;;AAcA,IAAM,iBAAiBA,uBAAAA,gBAAgBC,8BAAAA,eAAe;AAUtD,IAAa,4BAA4BC,MAAAA,QAAM,YAE3C,EAAE,IAAI,WAAW,KAAK,OAAO,MAAM,UAAU,GAAG,SAChD,QACG;CACH,MAAM,YAAY,MAAM;CAExB,MAAM,eAAeC,uBAAAA,eAAe,KAAK,KAAK;CAE9C,MAAM,cAAc,eAAe;EAAE;EAAM;CAAS,CAAC;CAErD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EAAgB;EAAK,WAAWC,WAAAA,GAAG,aAAa,SAAS;EAAG,OAAO;EAAc,GAAI;CAAQ,CAAA;AAEjG,CACF;AAEA,0BAA0B,cAAc;AAExC,IAAa,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.vanilla.css.cjs","names":[
|
|
1
|
+
{"version":3,"file":"Container.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.vanilla.css.js","names":[
|
|
1
|
+
{"version":3,"file":"Container.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { withVariantKeys } from "../../styles/recipeVariants.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
4
|
import { containerRecipe } from "./Container.vanilla.css.js";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
// components/Container/Container.vanilla.tsx
|
|
8
|
+
var containerClass = withVariantKeys(containerRecipe);
|
|
9
9
|
var ContainerVanillaComponent = React.forwardRef(({ as, className, css, style, size, noGutter, ...props }, ref) => {
|
|
10
10
|
const Component = as || "div";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const mergedStyles = {
|
|
14
|
-
...cssStyles,
|
|
15
|
-
...style,
|
|
16
|
-
...assignInlineVars(vars)
|
|
17
|
-
};
|
|
18
|
-
const recipeClass = containerRecipe({
|
|
11
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
12
|
+
const recipeClass = containerClass({
|
|
19
13
|
size,
|
|
20
14
|
noGutter
|
|
21
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.vanilla.js","names":[],"sources":["../../../components/Container/Container.vanilla.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Container.vanilla.js","names":[],"sources":["../../../components/Container/Container.vanilla.tsx"],"sourcesContent":["import React, { ElementType } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { containerRecipe } from './Container.vanilla.css';\n\nconst containerClass = withVariantKeys(containerRecipe);\n\ninterface ContainerOwnProps extends RecipeVariantProps<typeof containerRecipe>, CSSProps {}\n\nexport type ContainerProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ContainerOwnProps\n>;\ntype ContainerComponent = PolymorphicComponent<'div', ContainerProps<ElementType>>;\n\nexport const ContainerVanillaComponent = React.forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, size, noGutter, ...props }: ContainerProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || 'div';\n\n const mergedStyles = useInlineStyle(css, style);\n\n const recipeClass = containerClass({ size, noGutter });\n\n return (\n <Component ref={ref} className={cx(recipeClass, className)} style={mergedStyles} {...props} />\n );\n },\n);\n\nContainerVanillaComponent.displayName = 'ContainerVanilla';\n\nexport const ContainerVanilla = ContainerVanillaComponent as ContainerComponent;\n"],"mappings":";;;;;;;AAcA,IAAM,iBAAiB,gBAAgB,eAAe;AAUtD,IAAa,4BAA4B,MAAM,YAE3C,EAAE,IAAI,WAAW,KAAK,OAAO,MAAM,UAAU,GAAG,SAChD,QACG;CACH,MAAM,YAAY,MAAM;CAExB,MAAM,eAAe,eAAe,KAAK,KAAK;CAE9C,MAAM,cAAc,eAAe;EAAE;EAAM;CAAS,CAAC;CAErD,OACE,oBAAC,WAAD;EAAgB;EAAK,WAAW,GAAG,aAAa,SAAS;EAAG,OAAO;EAAc,GAAI;CAAQ,CAAA;AAEjG,CACF;AAEA,0BAA0B,cAAc;AAExC,IAAa,mBAAmB"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
2
1
|
const require_cx = require("../../styles/cx.cjs");
|
|
3
|
-
const
|
|
2
|
+
const require_recipeVariants = require("../../styles/recipeVariants.cjs");
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
4
4
|
const require_Elevation_vanilla_css = require("./Elevation.vanilla.css.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
// components/Elevation/Elevation.vanilla.tsx
|
|
8
|
+
var elevationClass = require_recipeVariants.withVariantKeys(require_Elevation_vanilla_css.elevationRecipe);
|
|
9
9
|
var ElevationVanillaComponentImpl = (0, react.forwardRef)(({ as, className, css, style, variant, ...props }, ref) => {
|
|
10
10
|
const Component = as || "div";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const mergedStyles = {
|
|
14
|
-
...cssStyles,
|
|
15
|
-
...style,
|
|
16
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
17
|
-
};
|
|
18
|
-
const recipeClass = require_Elevation_vanilla_css.elevationRecipe({ variant });
|
|
11
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
12
|
+
const recipeClass = elevationClass({ variant });
|
|
19
13
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
20
14
|
ref,
|
|
21
15
|
className: require_cx.cx(recipeClass, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.vanilla.cjs","names":["
|
|
1
|
+
{"version":3,"file":"Elevation.vanilla.cjs","names":["withVariantKeys","elevationRecipe","forwardRef","useInlineStyle","cx"],"sources":["../../../components/Elevation/Elevation.vanilla.tsx"],"sourcesContent":["import { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { elevationRecipe } from './Elevation.vanilla.css';\n\nconst elevationClass = withVariantKeys(elevationRecipe);\n\ntype ElevationRecipeVariants = RecipeVariantProps<typeof elevationRecipe>;\n\ninterface ElevationOwnProps extends CSSProps {\n variant?: ElevationRecipeVariants['variant'];\n}\n\nexport type ElevationVanillaProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ElevationOwnProps\n>;\n\ntype ElevationVanillaComponent = PolymorphicComponent<'div', ElevationVanillaProps<ElementType>>;\n\nconst ElevationVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, variant, ...props }: ElevationVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || 'div';\n const mergedStyles = useInlineStyle(css, style);\n const recipeClass = elevationClass({ variant });\n\n return (\n <Component ref={ref} className={cx(recipeClass, className)} style={mergedStyles} {...props} />\n );\n },\n);\n\nElevationVanillaComponentImpl.displayName = 'ElevationVanilla';\n\nexport const ElevationVanilla = ElevationVanillaComponentImpl as ElevationVanillaComponent;\n"],"mappings":";;;;;;;AAcA,IAAM,iBAAiBA,uBAAAA,gBAAgBC,8BAAAA,eAAe;AAetD,IAAM,iCAAA,GAAgCC,MAAAA,WAAAA,EAElC,EAAE,IAAI,WAAW,KAAK,OAAO,SAAS,GAAG,SACzC,QACG;CACH,MAAM,YAAY,MAAM;CACxB,MAAM,eAAeC,uBAAAA,eAAe,KAAK,KAAK;CAC9C,MAAM,cAAc,eAAe,EAAE,QAAQ,CAAC;CAE9C,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EAAgB;EAAK,WAAWC,WAAAA,GAAG,aAAa,SAAS;EAAG,OAAO;EAAc,GAAI;CAAQ,CAAA;AAEjG,CACF;AAEA,8BAA8B,cAAc;AAE5C,IAAa,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.vanilla.css.cjs","names":[
|
|
1
|
+
{"version":3,"file":"Elevation.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.vanilla.css.js","names":[
|
|
1
|
+
{"version":3,"file":"Elevation.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { withVariantKeys } from "../../styles/recipeVariants.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
4
|
import { elevationRecipe } from "./Elevation.vanilla.css.js";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
// components/Elevation/Elevation.vanilla.tsx
|
|
8
|
+
var elevationClass = withVariantKeys(elevationRecipe);
|
|
9
9
|
var ElevationVanillaComponentImpl = forwardRef(({ as, className, css, style, variant, ...props }, ref) => {
|
|
10
10
|
const Component = as || "div";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const mergedStyles = {
|
|
14
|
-
...cssStyles,
|
|
15
|
-
...style,
|
|
16
|
-
...assignInlineVars(vars)
|
|
17
|
-
};
|
|
18
|
-
const recipeClass = elevationRecipe({ variant });
|
|
11
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
12
|
+
const recipeClass = elevationClass({ variant });
|
|
19
13
|
return /* @__PURE__ */ jsx(Component, {
|
|
20
14
|
ref,
|
|
21
15
|
className: cx(recipeClass, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.vanilla.js","names":[],"sources":["../../../components/Elevation/Elevation.vanilla.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Elevation.vanilla.js","names":[],"sources":["../../../components/Elevation/Elevation.vanilla.tsx"],"sourcesContent":["import { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { elevationRecipe } from './Elevation.vanilla.css';\n\nconst elevationClass = withVariantKeys(elevationRecipe);\n\ntype ElevationRecipeVariants = RecipeVariantProps<typeof elevationRecipe>;\n\ninterface ElevationOwnProps extends CSSProps {\n variant?: ElevationRecipeVariants['variant'];\n}\n\nexport type ElevationVanillaProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ElevationOwnProps\n>;\n\ntype ElevationVanillaComponent = PolymorphicComponent<'div', ElevationVanillaProps<ElementType>>;\n\nconst ElevationVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, variant, ...props }: ElevationVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || 'div';\n const mergedStyles = useInlineStyle(css, style);\n const recipeClass = elevationClass({ variant });\n\n return (\n <Component ref={ref} className={cx(recipeClass, className)} style={mergedStyles} {...props} />\n );\n },\n);\n\nElevationVanillaComponentImpl.displayName = 'ElevationVanilla';\n\nexport const ElevationVanilla = ElevationVanillaComponentImpl as ElevationVanillaComponent;\n"],"mappings":";;;;;;;AAcA,IAAM,iBAAiB,gBAAgB,eAAe;AAetD,IAAM,gCAAgC,YAElC,EAAE,IAAI,WAAW,KAAK,OAAO,SAAS,GAAG,SACzC,QACG;CACH,MAAM,YAAY,MAAM;CACxB,MAAM,eAAe,eAAe,KAAK,KAAK;CAC9C,MAAM,cAAc,eAAe,EAAE,QAAQ,CAAC;CAE9C,OACE,oBAAC,WAAD;EAAgB;EAAK,WAAW,GAAG,aAAa,SAAS;EAAG,OAAO;EAAc,GAAI;CAAQ,CAAA;AAEjG,CACF;AAEA,8BAA8B,cAAc;AAE5C,IAAa,mBAAmB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_themeContext = require("../../styles/themeContext.cjs");
|
|
2
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
4
3
|
const require_Box_vanilla = require("../Box/Box.vanilla.cjs");
|
|
5
4
|
const require_Label_vanilla = require("../Label/Label.vanilla.cjs");
|
|
6
5
|
const require_Text_vanilla = require("../Text/Text.vanilla.cjs");
|
|
@@ -9,7 +8,6 @@ const require_Field_vanilla_css = require("./Field.vanilla.css.cjs");
|
|
|
9
8
|
const require_FieldContext = require("./FieldContext.cjs");
|
|
10
9
|
let react = require("react");
|
|
11
10
|
react = require_runtime.__toESM(react, 1);
|
|
12
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
13
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
12
|
// components/Field/Field.vanilla.tsx
|
|
15
13
|
var MESSAGE_CSS = {
|
|
@@ -36,8 +34,7 @@ var FieldVanilla = ({ label, hint, description, error, announceError, labelPosit
|
|
|
36
34
|
...props
|
|
37
35
|
});
|
|
38
36
|
const announcedError = require_FieldContext.useAnnouncedError(Boolean(announceError), hasError ? ids.errorId : void 0, ids.labelId);
|
|
39
|
-
const
|
|
40
|
-
const { style: rootStyle, vars: rootVars } = require_cssProps.processCSSProp(css, colors);
|
|
37
|
+
const rootStyle = require_useInlineStyle.useInlineStyle(css);
|
|
41
38
|
const labelNode = react.default.useMemo(() => {
|
|
42
39
|
if (!hasLabel || !ids.labelId) return null;
|
|
43
40
|
if (typeof label === "function") return label({
|
|
@@ -88,10 +85,7 @@ var FieldVanilla = ({ label, hint, description, error, announceError, labelPosit
|
|
|
88
85
|
value: context,
|
|
89
86
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
90
87
|
className: labelPosition === "start" ? require_Field_vanilla_css.startRow : void 0,
|
|
91
|
-
style:
|
|
92
|
-
...rootStyle,
|
|
93
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(rootVars)
|
|
94
|
-
},
|
|
88
|
+
style: rootStyle,
|
|
95
89
|
onFocus,
|
|
96
90
|
onBlur,
|
|
97
91
|
...groupProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.vanilla.cjs","names":["useFieldRoot","useAnnouncedError","
|
|
1
|
+
{"version":3,"file":"Field.vanilla.cjs","names":["useFieldRoot","useAnnouncedError","useInlineStyle","React","LabelVanilla","TextVanilla","_Fragment","FieldContext","startRow","BoxVanilla","startLabel","startControl","endLabelRow","VisuallyHidden"],"sources":["../../../components/Field/Field.vanilla.tsx"],"sourcesContent":["import React from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { BoxVanilla } from '@/components/Box';\nimport { LabelVanilla } from '@/components/Label';\nimport { TextVanilla } from '@/components/Text';\nimport { VisuallyHidden } from '@/components/VisuallyHidden';\n\nimport { endLabelRow, startControl, startLabel, startRow } from './Field.vanilla.css';\nimport { FieldBaseProps, FieldContext, useAnnouncedError, useFieldRoot } from './FieldContext';\n\nexport type FieldVanillaProps = FieldBaseProps & { css?: CSSProps['css'] };\n\nconst MESSAGE_CSS = { display: 'block', m: 0, mt: '$1', lineHeight: 1.4 };\n// The tall line of a label makes room for a control right under it. Before a hint or beside a control, it is a gap.\nconst COMPACT_LABEL_CSS = { lineHeight: 1.4 };\nconst HINT_ABOVE_CONTROL_CSS = { ...MESSAGE_CSS, mb: '$2' };\n\n/**\n * Gives a label, a hint, a description and an error to the one form control inside it.\n * For more than one control, use `group`.\n */\nexport const FieldVanilla = ({\n label,\n hint,\n description,\n error,\n announceError,\n labelPosition = 'top',\n children,\n css,\n ...props\n}: FieldVanillaProps) => {\n const {\n context,\n ids,\n groupProps,\n messageSize,\n labelFor,\n labelVariant,\n hasLabel,\n hasHint,\n hasDescription,\n hasError,\n onFocus,\n onBlur,\n } = useFieldRoot({ label, hint, description, error, ...props });\n const announcedError = useAnnouncedError(\n Boolean(announceError),\n hasError ? ids.errorId : undefined,\n ids.labelId,\n );\n const rootStyle = useInlineStyle(css);\n\n const labelNode = React.useMemo(() => {\n if (!hasLabel || !ids.labelId) {\n return null;\n }\n if (typeof label === 'function') {\n return label({ variant: labelVariant, htmlFor: labelFor, id: ids.labelId });\n }\n return (\n <LabelVanilla\n variant={labelVariant}\n htmlFor={labelFor}\n id={ids.labelId}\n css={hasHint || labelPosition === 'start' ? COMPACT_LABEL_CSS : undefined}\n >\n {label}\n </LabelVanilla>\n );\n }, [hasLabel, hasHint, label, labelPosition, labelVariant, labelFor, ids.labelId]);\n\n const hintNode = hasHint && (\n <TextVanilla\n as=\"p\"\n id={ids.hintId}\n size={messageSize}\n variant=\"subtle\"\n css={labelPosition === 'top' ? HINT_ABOVE_CONTROL_CSS : MESSAGE_CSS}\n >\n {hint}\n </TextVanilla>\n );\n\n const messages = (\n <>\n {hasDescription && (\n <TextVanilla\n as=\"p\"\n id={ids.descriptionId}\n size={messageSize}\n variant=\"subtle\"\n css={MESSAGE_CSS}\n >\n {description}\n </TextVanilla>\n )}\n {hasError && (\n <TextVanilla as=\"p\" id={ids.errorId} size={messageSize} variant=\"invalid\" css={MESSAGE_CSS}>\n {error}\n </TextVanilla>\n )}\n </>\n );\n\n return (\n <FieldContext.Provider value={context}>\n <div\n className={labelPosition === 'start' ? startRow : undefined}\n style={rootStyle}\n onFocus={onFocus}\n onBlur={onBlur}\n {...groupProps}\n >\n {labelPosition === 'start' ? (\n <>\n <BoxVanilla className={startLabel}>\n {labelNode}\n {hintNode}\n </BoxVanilla>\n <BoxVanilla className={startControl}>\n {children}\n {messages}\n </BoxVanilla>\n </>\n ) : labelPosition === 'end' ? (\n <>\n <BoxVanilla className={endLabelRow}>\n {children}\n {labelNode}\n </BoxVanilla>\n {hintNode}\n {messages}\n </>\n ) : (\n <>\n {labelNode}\n {hintNode}\n {children}\n {messages}\n </>\n )}\n {announceError && <VisuallyHidden aria-live=\"polite\">{announcedError}</VisuallyHidden>}\n </div>\n </FieldContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,cAAc;CAAE,SAAS;CAAS,GAAG;CAAG,IAAI;CAAM,YAAY;AAAI;AAExE,IAAM,oBAAoB,EAAE,YAAY,IAAI;AAC5C,IAAM,yBAAyB;CAAE,GAAG;CAAa,IAAI;AAAK;;;;;AAM1D,IAAa,gBAAgB,EAC3B,OACA,MACA,aACA,OACA,eACA,gBAAgB,OAChB,UACA,KACA,GAAG,YACoB;CACvB,MAAM,EACJ,SACA,KACA,YACA,aACA,UACA,cACA,UACA,SACA,gBACA,UACA,SACA,WACEA,qBAAAA,aAAa;EAAE;EAAO;EAAM;EAAa;EAAO,GAAG;CAAM,CAAC;CAC9D,MAAM,iBAAiBC,qBAAAA,kBACrB,QAAQ,aAAa,GACrB,WAAW,IAAI,UAAU,KAAA,GACzB,IAAI,OACN;CACA,MAAM,YAAYC,uBAAAA,eAAe,GAAG;CAEpC,MAAM,YAAYC,MAAAA,QAAM,cAAc;EACpC,IAAI,CAAC,YAAY,CAAC,IAAI,SACpB,OAAO;EAET,IAAI,OAAO,UAAU,YACnB,OAAO,MAAM;GAAE,SAAS;GAAc,SAAS;GAAU,IAAI,IAAI;EAAQ,CAAC;EAE5E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,cAAD;GACE,SAAS;GACT,SAAS;GACT,IAAI,IAAI;GACR,KAAK,WAAW,kBAAkB,UAAU,oBAAoB,KAAA;GAE/D,UAAA;EACW,CAAA;CAElB,GAAG;EAAC;EAAU;EAAS;EAAO;EAAe;EAAc;EAAU,IAAI;CAAO,CAAC;CAEjF,MAAM,WAAW,WACf,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,aAAD;EACE,IA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,EAAA,CAAA,IAEF,iBAAA,GAAA,kBAAA,KAAA,CAAAN,kBAAAA,UAAA,EAAA,UAAA;IACG;IACA;IACA;IACA;GACD,EAAA,CAAA,GAEH,iBAAiB,iBAAA,GAAA,kBAAA,IAAA,CAACO,uBAAAA,gBAAD;IAAgB,aAAU;IAAU,UAAA;GAA+B,CAAA,CAClF;;CACgB,CAAA;AAE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.vanilla.css.cjs","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"Field.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|