@traefik-labs/faency 13.1.0 → 13.2.0

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.
Files changed (123) hide show
  1. package/dist/components/Badge/Badge.cjs +1 -5
  2. package/dist/components/Badge/Badge.cjs.map +1 -1
  3. package/dist/components/Badge/Badge.js +2 -6
  4. package/dist/components/Badge/Badge.js.map +1 -1
  5. package/dist/components/Button/Button.cjs +1 -2
  6. package/dist/components/Button/Button.cjs.map +1 -1
  7. package/dist/components/Button/Button.js +2 -3
  8. package/dist/components/Button/Button.js.map +1 -1
  9. package/dist/components/Checkbox/Checkbox.cjs +15 -2
  10. package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
  11. package/dist/components/Checkbox/Checkbox.js +15 -2
  12. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  13. package/dist/components/Checkbox/Checkbox.themes.cjs +4 -2
  14. package/dist/components/Checkbox/Checkbox.themes.cjs.map +1 -1
  15. package/dist/components/Checkbox/Checkbox.themes.js +4 -2
  16. package/dist/components/Checkbox/Checkbox.themes.js.map +1 -1
  17. package/dist/components/CodeBlock/CodeBlock.cjs +2 -1
  18. package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
  19. package/dist/components/CodeBlock/CodeBlock.js +3 -2
  20. package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
  21. package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +2 -1
  22. package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
  23. package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -2
  24. package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
  25. package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs +1 -1
  26. package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs.map +1 -1
  27. package/dist/components/DateTimePickerInput/DateTimePickerInput.js +1 -1
  28. package/dist/components/DateTimePickerInput/DateTimePickerInput.js.map +1 -1
  29. package/dist/components/Field/Field.cjs +91 -0
  30. package/dist/components/Field/Field.cjs.map +1 -0
  31. package/dist/components/Field/Field.js +89 -0
  32. package/dist/components/Field/Field.js.map +1 -0
  33. package/dist/components/Field/Field.vanilla.cjs +95 -0
  34. package/dist/components/Field/Field.vanilla.cjs.map +1 -0
  35. package/dist/components/Field/Field.vanilla.css.cjs +6 -0
  36. package/dist/components/Field/Field.vanilla.css.cjs.map +1 -0
  37. package/dist/components/Field/Field.vanilla.css.js +6 -0
  38. package/dist/components/Field/Field.vanilla.css.js.map +1 -0
  39. package/dist/components/Field/Field.vanilla.js +93 -0
  40. package/dist/components/Field/Field.vanilla.js.map +1 -0
  41. package/dist/components/Field/FieldContext.cjs +136 -0
  42. package/dist/components/Field/FieldContext.cjs.map +1 -0
  43. package/dist/components/Field/FieldContext.js +130 -0
  44. package/dist/components/Field/FieldContext.js.map +1 -0
  45. package/dist/components/Input/Input.cjs +31 -6
  46. package/dist/components/Input/Input.cjs.map +1 -1
  47. package/dist/components/Input/Input.js +31 -6
  48. package/dist/components/Input/Input.js.map +1 -1
  49. package/dist/components/Input/Input.vanilla.cjs +17 -4
  50. package/dist/components/Input/Input.vanilla.cjs.map +1 -1
  51. package/dist/components/Input/Input.vanilla.css.cjs.map +1 -1
  52. package/dist/components/Input/Input.vanilla.css.js.map +1 -1
  53. package/dist/components/Input/Input.vanilla.js +17 -4
  54. package/dist/components/Input/Input.vanilla.js.map +1 -1
  55. package/dist/components/Radio/Radio.cjs +21 -1
  56. package/dist/components/Radio/Radio.cjs.map +1 -1
  57. package/dist/components/Radio/Radio.js +21 -1
  58. package/dist/components/Radio/Radio.js.map +1 -1
  59. package/dist/components/Radio/Radio.themes.cjs +4 -2
  60. package/dist/components/Radio/Radio.themes.cjs.map +1 -1
  61. package/dist/components/Radio/Radio.themes.js +4 -2
  62. package/dist/components/Radio/Radio.themes.js.map +1 -1
  63. package/dist/components/Select/Select.cjs +33 -4
  64. package/dist/components/Select/Select.cjs.map +1 -1
  65. package/dist/components/Select/Select.js +33 -4
  66. package/dist/components/Select/Select.js.map +1 -1
  67. package/dist/components/Switch/Switch.cjs +19 -5
  68. package/dist/components/Switch/Switch.cjs.map +1 -1
  69. package/dist/components/Switch/Switch.js +19 -5
  70. package/dist/components/Switch/Switch.js.map +1 -1
  71. package/dist/components/Switch/Switch.themes.cjs +4 -2
  72. package/dist/components/Switch/Switch.themes.cjs.map +1 -1
  73. package/dist/components/Switch/Switch.themes.js +4 -2
  74. package/dist/components/Switch/Switch.themes.js.map +1 -1
  75. package/dist/components/Text/Text.themes.cjs +2 -2
  76. package/dist/components/Text/Text.themes.cjs.map +1 -1
  77. package/dist/components/Text/Text.themes.js +2 -2
  78. package/dist/components/Text/Text.themes.js.map +1 -1
  79. package/dist/components/Text/Text.vanilla.cjs +36 -0
  80. package/dist/components/Text/Text.vanilla.cjs.map +1 -0
  81. package/dist/components/Text/Text.vanilla.css.cjs +55 -0
  82. package/dist/components/Text/Text.vanilla.css.cjs.map +1 -0
  83. package/dist/components/Text/Text.vanilla.css.js +56 -0
  84. package/dist/components/Text/Text.vanilla.css.js.map +1 -0
  85. package/dist/components/Text/Text.vanilla.js +36 -0
  86. package/dist/components/Text/Text.vanilla.js.map +1 -0
  87. package/dist/components/TextField/TextField.cjs +74 -78
  88. package/dist/components/TextField/TextField.cjs.map +1 -1
  89. package/dist/components/TextField/TextField.js +74 -78
  90. package/dist/components/TextField/TextField.js.map +1 -1
  91. package/dist/components/TextField/TextField.vanilla.cjs +70 -86
  92. package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
  93. package/dist/components/TextField/TextField.vanilla.css.cjs +10 -0
  94. package/dist/components/TextField/TextField.vanilla.css.cjs.map +1 -0
  95. package/dist/components/TextField/TextField.vanilla.css.js +8 -0
  96. package/dist/components/TextField/TextField.vanilla.css.js.map +1 -0
  97. package/dist/components/TextField/TextField.vanilla.js +71 -87
  98. package/dist/components/TextField/TextField.vanilla.js.map +1 -1
  99. package/dist/components/Textarea/Textarea.cjs +51 -41
  100. package/dist/components/Textarea/Textarea.cjs.map +1 -1
  101. package/dist/components/Textarea/Textarea.js +51 -41
  102. package/dist/components/Textarea/Textarea.js.map +1 -1
  103. package/dist/components/Textarea/Textarea.vanilla.cjs +49 -49
  104. package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
  105. package/dist/components/Textarea/Textarea.vanilla.css.cjs.map +1 -1
  106. package/dist/components/Textarea/Textarea.vanilla.css.js.map +1 -1
  107. package/dist/components/Textarea/Textarea.vanilla.js +49 -49
  108. package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
  109. package/dist/faency.css +170 -14
  110. package/dist/index.cjs +7 -1
  111. package/dist/index.d.ts +375 -0
  112. package/dist/index.js +5 -2
  113. package/dist/styles/themeContext.cjs +2 -1
  114. package/dist/styles/themeContext.cjs.map +1 -1
  115. package/dist/styles/themeContext.js +3 -2
  116. package/dist/styles/themeContext.js.map +1 -1
  117. package/dist/styles/themes.css.cjs.map +1 -1
  118. package/dist/styles/themes.css.js.map +1 -1
  119. package/dist/utils/useIsomorphicLayoutEffect.cjs +6 -0
  120. package/dist/utils/useIsomorphicLayoutEffect.cjs.map +1 -0
  121. package/dist/utils/useIsomorphicLayoutEffect.js +6 -0
  122. package/dist/utils/useIsomorphicLayoutEffect.js.map +1 -0
  123. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\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 css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\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 systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\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 useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\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 (isBottomAlign) {\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 copyButton = copyable ? (\n <Button\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 </Button>\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 <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\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 </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"mappings":";;;;;;;;;;;AAuBA,IAAM,MAAM,OAAO,OAAO;CACxB,GAAG;CACH,cAAc;CACd,UAAU;CACV,QAAQ;CACR,UAAU;CACV,YAAY;CAEZ,UAAU,EACR,UAAU,EACR,MAAM,EAAE,QAAQ,OAAO,EACzB,EACF;AACF,CAAC;AAED,IAAM,oBAAoB,OAAO,OAAO;CACtC,UAAU;CACV,QAAQ;CACR,UAAU,EACR,UAAU;EACR,KAAK;GAAE,KAAK;GAAM,OAAO;EAAK;EAC9B,SAAS;GAAE,KAAK;GAAM,MAAM;EAAK;EACjC,aAAa;GAAE,QAAQ;GAAM,OAAO;EAAK;EACzC,YAAY;GAAE,QAAQ;GAAM,MAAM;EAAK;CACzC,EACF;CAEA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC;AAkBD,IAAa,YAAY,YAErB,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,K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AAO,QAChB,oBAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,oBAAC,mBAAD;IAAmB,KAAK;IAAkB,UAAU;IACjD,UAAA;GACgB,CAAA,CAElB;;CAEE,CAAA;AAEf,CACF;AAEA,UAAU,cAAc"}
1
+ {"version":3,"file":"CodeBlock.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { ComponentProps, forwardRef, useCallback, useRef, useState } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\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 css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\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 systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\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 isBottomAlign = isBottom;\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 (isBottomAlign) {\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 copyButton = copyable ? (\n <Button\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 </Button>\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 <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\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 </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\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AAS,OAAO,OAAO;EAEhD,WAAA,EACA,WAAW,gBACX,OAAO,gBACP,QACA,cACA,oBAEA,qBAAC,KAAD;GAAK,KAAK;IAAE,UAAU;IAAY,GAAG;GAAI;GAAzC,UAAA,CACE,oBAAC,KAAD;IACE,KAAK;IACL,WAAW,CAAC,gBAAgB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IAC/D,OAAO;KAAE;KAAW,GAAG;KAAgB,iBAAiB;KAAW,GAAG;IAAM;IAClE;IACV,GAAI;IAEJ,UAAA,oBAAC,KAAD;KACE,KAAK;MACH,GAAG;MACH,GAAI,YAAY,UAAU,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;MACrD,GAAI,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;KACxD;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,mBAAD;IAAmB,KAAK;IAAkB,UAAU;IACjD,UAAA;GACgB,CAAA,CAElB;;CAEE,CAAA;AAEf,CACF;AAEA,UAAU,cAAc"}
@@ -1,6 +1,7 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_AccessibleIcon = require("../AccessibleIcon/AccessibleIcon.cjs");
3
3
  const require_cssProps = require("../../styles/cssProps.cjs");
4
+ const require_useIsomorphicLayoutEffect = require("../../utils/useIsomorphicLayoutEffect.cjs");
4
5
  const require_themeContext = require("../../styles/themeContext.cjs");
5
6
  const require_Button_vanilla = require("../Button/Button.vanilla.cjs");
6
7
  require("./prism-extend.cjs");
@@ -31,7 +32,7 @@ var CodeBlockVanilla = (0, react.forwardRef)(({ lang = "text", code, copyable =
31
32
  if (typeof ref === "function") ref(node);
32
33
  else if (ref) ref.current = node;
33
34
  }, [ref]);
34
- (0, react.useLayoutEffect)(() => {
35
+ require_useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
35
36
  if (!copyable) return;
36
37
  const pre = preRef.current;
37
38
  const wrapper = buttonWrapperRef.current;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","ButtonVanilla","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","pre","preNoBorder","codeContent","codeContentBottomPadding","codeContentTopPadding"],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\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 { colors, 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 { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\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 useLayoutEffect(() => {\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={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\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":";;;;;;;;;;;;;;AAkDA,IAAa,oBAAA,GAAmBA,MAAAA,WAAAA,EAE5B,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,QAAQ,kBAAkBC,qBAAAA,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAASC,qBAAAA,OAAO,WAAWA,qBAAAA,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,MAAM,kBAAkB;EACtB,UAAU;EACV,GAAG;EACH,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAC1B;CAEA,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAS,KAAK;CAE1C,MAAM,UAAA,GAASC,MAAAA,OAAAA,CACb,IACF;CACA,MAAM,oBAAA,GAAmBA,MAAAA,OAAAA,CAAuB,IAAI;CAEpD,MAAM,aAAA,GAAYC,MAAAA,YAAAA,EACf,SAAgC;EAC/B,OAAO,UAAU;EACjB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAuD,UAAU;CACjF,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C,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
1
+ {"version":3,"file":"CodeBlock.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","ButtonVanilla","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","pre","preNoBorder","codeContent","codeContentBottomPadding","codeContentTopPadding"],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\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 { colors, 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 { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\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={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\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":";;;;;;;;;;;;;;;AA4CA,IAAa,oBAAA,GAAmBA,MAAAA,WAAAA,EAE5B,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,QAAQ,kBAAkBC,qBAAAA,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAASC,qBAAAA,OAAO,WAAWA,qBAAAA,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,MAAM,kBAAkB;EACtB,UAAU;EACV,GAAG;EACH,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAC1B;CAEA,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAS,KAAK;CAE1C,MAAM,UAAA,GAASC,MAAAA,OAAAA,CACb,IACF;CACA,MAAM,oBAAA,GAAmBA,MAAAA,OAAAA,CAAuB,IAAI;CAEpD,MAAM,aAAA,GAAYC,MAAAA,YAAAA,EACf,SAAgC;EAC/B,OAAO,UAAU;EACjB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAuD,UAAU;CACjF,GACA,CAAC,GAAG,CACN;CAEA,kCAAA,gCAAgC;EAC9B,IAAI,CAAC,U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,kBAAA,IAAA,CAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
@@ -1,11 +1,12 @@
1
1
  import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
2
2
  import { processCSSProp } from "../../styles/cssProps.js";
3
+ import { useIsomorphicLayoutEffect } from "../../utils/useIsomorphicLayoutEffect.js";
3
4
  import { useVanillaExtractTheme } from "../../styles/themeContext.js";
4
5
  import { ButtonVanilla } from "../Button/Button.vanilla.js";
5
6
  import { Prism } from "./prism-extend.js";
6
7
  import { codeContent, codeContentBottomPadding, codeContentTopPadding, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight, copyButtonWrapperTop, copyButtonWrapperTopLeft, pre, preNoBorder } from "./CodeBlock.vanilla.css.js";
7
8
  import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
8
- import { forwardRef, useCallback, useLayoutEffect, useRef, useState } from "react";
9
+ import { forwardRef, useCallback, useRef, useState } from "react";
9
10
  import { assignInlineVars } from "@vanilla-extract/dynamic";
10
11
  import { jsx, jsxs } from "react/jsx-runtime";
11
12
  import { Highlight, themes } from "prism-react-renderer";
@@ -29,7 +30,7 @@ var CodeBlockVanilla = forwardRef(({ lang = "text", code, copyable = false, copy
29
30
  if (typeof ref === "function") ref(node);
30
31
  else if (ref) ref.current = node;
31
32
  }, [ref]);
32
- useLayoutEffect(() => {
33
+ useIsomorphicLayoutEffect(() => {
33
34
  if (!copyable) return;
34
35
  const pre = preRef.current;
35
36
  const wrapper = buttonWrapperRef.current;
@@ -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 { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\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 { colors, 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 { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\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 useLayoutEffect(() => {\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={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\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":";;;;;;;;;;;;AAkDA,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,QAAQ,kBAAkB,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAAS,OAAO,WAAW,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAAS,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AK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
1
+ {"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\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 { colors, 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 { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\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={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\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":";;;;;;;;;;;;;AA4CA,IAAa,mBAAmB,YAE5B,EACE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f,KAAK,GAAG;KAEV,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"}
@@ -87,7 +87,7 @@ var DateTimePickerInput = react.default.forwardRef(({ inputCSS, inputProps, onCh
87
87
  ref: fowardedRef,
88
88
  children: [
89
89
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
90
- startAdornment: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CalendarIcon, {}),
90
+ startAdornment: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CalendarIcon, { "aria-hidden": true }),
91
91
  ...getReferenceProps(),
92
92
  ...inputProps,
93
93
  css: {
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePickerInput.cjs","names":["styled","React","useRef","useState","useMemo","offset","flip","shift","arrow","useFloating","autoUpdate","useClick","useDismiss","useRole","useInteractions","Input","CalendarIcon","parse","FloatingFocusManager","Card","DateTimePicker","format","FloatingArrow"],"sources":["../../../components/DateTimePickerInput/DateTimePickerInput.tsx"],"sourcesContent":["import {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n offset,\n Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useRole,\n} from '@floating-ui/react';\nimport { CalendarIcon } from '@radix-ui/react-icons';\nimport { DPUserConfig } from '@rehookify/datepicker';\nimport { format, parse } from 'date-fns';\nimport React, { MouseEventHandler, Ref, useMemo, useRef, useState } from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { Card } from '../Card';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { Input, InputHandle } from '../Input';\n\nconst StyledWrapper = styled('div', {\n display: 'flex',\n position: 'relative',\n width: '100%',\n\n '& .firefox-patch': {\n display: 'none',\n },\n\n '@supports (-moz-appearance: none)': {\n '& .firefox-patch': {\n display: 'block',\n width: '20px',\n height: '20px',\n position: 'absolute',\n right: '17px',\n top: '6px',\n background: '$inputBg',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n },\n\n '@hover': {\n '&:hover .firefox-patch': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n },\n});\n\nexport type DateTimePickerInputProps = Omit<DPUserConfig, 'onDatesChange' | 'selectedDates'> & {\n inputCSS?: CSS;\n inputProps?: Omit<typeof Input, 'css' | 'onChange' | 'ref' | 'value'>;\n onChange?: (d: Date[]) => void;\n pickerCSS?: CSS;\n pickerPlacement?: Placement;\n showDatePresets?: boolean;\n showTimePicker?: boolean;\n};\n\nexport type DateTimePickerInputVariants = VariantProps<DateTimePickerInputProps>;\n\nexport const DateTimePickerInput = React.forwardRef<\n React.ElementRef<typeof StyledWrapper>,\n DateTimePickerInputProps\n>(\n (\n {\n inputCSS,\n inputProps,\n onChange,\n pickerCSS,\n pickerPlacement,\n showDatePresets,\n showTimePicker,\n ...pickerProps\n },\n fowardedRef,\n ) => {\n const formatStr = \"yyyy-MM-dd'T'HH:mm\";\n\n const arrowRef = useRef(null);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [selectedDates, setSelectedDates] = useState<Date[]>([]);\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n\n const middleware = useMemo(\n () => [\n offset(10),\n flip(),\n shift(),\n // arrowRef is passed to floating-ui which handles it correctly\n arrow({ element: arrowRef }),\n ],\n [],\n );\n\n const { refs, floatingStyles, context } = useFloating({\n open: isPickerOpen,\n onOpenChange: setIsPickerOpen,\n placement: pickerPlacement,\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);\n const { onClick: onFirefoxPatchClick } = getReferenceProps();\n\n return (\n <StyledWrapper ref={fowardedRef}>\n <Input\n startAdornment={<CalendarIcon />}\n {...getReferenceProps()}\n {...inputProps}\n css={{ '& input::-webkit-calendar-picker-indicator': { display: 'none' }, ...inputCSS }}\n onChange={(evt) => {\n const value = evt.currentTarget.value;\n setInputValue(value);\n try {\n const newDates = (value as string)\n .split(',')\n .map((d) => parse(d.trim(), formatStr, new Date()));\n setSelectedDates(newDates);\n if (onChange) onChange(newDates);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (err) {\n // empty\n }\n }}\n ref={refs.setReference as Ref<InputHandle>}\n type=\"datetime-local\"\n value={inputValue}\n />\n <div\n className=\"firefox-patch\"\n onClick={onFirefoxPatchClick as MouseEventHandler<HTMLDivElement>}\n />\n {isPickerOpen && (\n <FloatingFocusManager context={context} initialFocus={-1} modal={false}>\n {/* refs.setFloating is a stable callback ref from floating-ui */}\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <Card>\n <DateTimePicker\n {...pickerProps}\n css={pickerCSS}\n onDatesChange={(d) => {\n setSelectedDates(d);\n setInputValue(d.map((date) => format(date, formatStr)).join(', '));\n if (onChange) onChange(d);\n }}\n onFastTravelClick={() => setIsPickerOpen(false)}\n onTimeButtonClick={() => setIsPickerOpen(false)}\n selectedDates={selectedDates}\n showDatePresets={showDatePresets}\n showTimePicker={showTimePicker}\n />\n </Card>\n <FloatingArrow ref={arrowRef} context={context} fill=\"var(--colors-01dp)\" />\n </div>\n </FloatingFocusManager>\n )}\n </StyledWrapper>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAM,gBAAgBA,wBAAAA,OAAO,OAAO;CAClC,SAAS;CACT,UAAU;CACV,OAAO;CAEP,oBAAoB,EAClB,SAAS,OACX;CAEA,qCAAqC;EACnC,oBAAoB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACR,UAAU;GACV,OAAO;GACP,KAAK;GACL,YAAY;GAEZ,aAAa;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GACA,YAAY;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GAEA,mBAAmB;IACjB,aAAa,EACX,iBAAiB,gBACnB;IACA,YAAY;KACV,iBAAiB;KACjB,SAAS;IACX;GACF;EACF;EAEA,UAAU,EACR,0BAA0B;GACxB,aAAa,EACX,iBAAiB,gBACnB;GACA,YAAY;IACV,iBAAiB;IACjB,SAAS;GACX;EACF,EACF;CACF;AACF,CAAC;AAcD,IAAa,sBAAsBC,MAAAA,QAAM,YAKrC,EACE,UACA,YACA,UACA,WACA,iBACA,iBACA,gBACA,GAAG,eAEL,gBACG;CACH,MAAM,YAAY;CAElB,MAAM,YAAA,GAAWC,MAAAA,OAAAA,CAAO,IAAI;CAE5B,MAAM,CAAC,YAAY,kBAAA,GAAiBC,MAAAA,SAAAA,CAAiB,EAAE;CACvD,MAAM,CAAC,eAAe,qBAAA,GAAoBA,MAAAA,SAAAA,CAAiB,CAAC,CAAC;CAC7D,MAAM,CAAC,cAAc,oBAAA,GAAmBA,MAAAA,SAAAA,CAAS,KAAK;CAEtD,MAAM,cAAA,GAAaC,MAA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;IACF;IACA,KAAK,KAAK;IACV,MAAK;IACL,OAAO;GACR,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACE,WAAU;IACV,SAAS;GACV,CAAA;GACA,gBACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,sBAAD;IAA+B;IAAS,cAAc;IAAI,OAAO;IAE/D,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;KAAK,KAAK,KAAK;KAAa,OAAO;KAAgB,GAAI,iBAAiB;KAAxE,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,gBAAD;MACE,GAAI;MACJ,KAAK;MACL,gBAAgB,MAAM;OACpB,iBAAiB,CAAC;OAClB,cAAc,EAAE,KAAK,UAAA,GAASC,SAAAA,OAAAA,CAAO,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;OACjE,IAAI,UAAU,SAAS,CAAC;MAC1B;MACA,yBAAyB,gBAAgB,KAAK;MAC9C,yBAAyB,gBAAgB,KAAK;MAC/B;MACE;MACD;KACjB,CAAA,EACG,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,eAAD;MAAe,KAAK;MAAmB;MAAS,MAAK;KAAsB,CAAA,CACxE;;GACe,CAAA;EAEX;;AAEnB,CACF"}
1
+ {"version":3,"file":"DateTimePickerInput.cjs","names":["styled","React","useRef","useState","useMemo","offset","flip","shift","arrow","useFloating","autoUpdate","useClick","useDismiss","useRole","useInteractions","Input","CalendarIcon","parse","FloatingFocusManager","Card","DateTimePicker","format","FloatingArrow"],"sources":["../../../components/DateTimePickerInput/DateTimePickerInput.tsx"],"sourcesContent":["import {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n offset,\n Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useRole,\n} from '@floating-ui/react';\nimport { CalendarIcon } from '@radix-ui/react-icons';\nimport { DPUserConfig } from '@rehookify/datepicker';\nimport { format, parse } from 'date-fns';\nimport React, { MouseEventHandler, Ref, useMemo, useRef, useState } from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { Card } from '../Card';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { Input, InputHandle } from '../Input';\n\nconst StyledWrapper = styled('div', {\n display: 'flex',\n position: 'relative',\n width: '100%',\n\n '& .firefox-patch': {\n display: 'none',\n },\n\n '@supports (-moz-appearance: none)': {\n '& .firefox-patch': {\n display: 'block',\n width: '20px',\n height: '20px',\n position: 'absolute',\n right: '17px',\n top: '6px',\n background: '$inputBg',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n },\n\n '@hover': {\n '&:hover .firefox-patch': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n },\n});\n\nexport type DateTimePickerInputProps = Omit<DPUserConfig, 'onDatesChange' | 'selectedDates'> & {\n inputCSS?: CSS;\n inputProps?: Omit<typeof Input, 'css' | 'onChange' | 'ref' | 'value'>;\n onChange?: (d: Date[]) => void;\n pickerCSS?: CSS;\n pickerPlacement?: Placement;\n showDatePresets?: boolean;\n showTimePicker?: boolean;\n};\n\nexport type DateTimePickerInputVariants = VariantProps<DateTimePickerInputProps>;\n\nexport const DateTimePickerInput = React.forwardRef<\n React.ElementRef<typeof StyledWrapper>,\n DateTimePickerInputProps\n>(\n (\n {\n inputCSS,\n inputProps,\n onChange,\n pickerCSS,\n pickerPlacement,\n showDatePresets,\n showTimePicker,\n ...pickerProps\n },\n fowardedRef,\n ) => {\n const formatStr = \"yyyy-MM-dd'T'HH:mm\";\n\n const arrowRef = useRef(null);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [selectedDates, setSelectedDates] = useState<Date[]>([]);\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n\n const middleware = useMemo(\n () => [\n offset(10),\n flip(),\n shift(),\n // arrowRef is passed to floating-ui which handles it correctly\n arrow({ element: arrowRef }),\n ],\n [],\n );\n\n const { refs, floatingStyles, context } = useFloating({\n open: isPickerOpen,\n onOpenChange: setIsPickerOpen,\n placement: pickerPlacement,\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);\n const { onClick: onFirefoxPatchClick } = getReferenceProps();\n\n return (\n <StyledWrapper ref={fowardedRef}>\n <Input\n startAdornment={<CalendarIcon aria-hidden />}\n {...getReferenceProps()}\n {...inputProps}\n css={{ '& input::-webkit-calendar-picker-indicator': { display: 'none' }, ...inputCSS }}\n onChange={(evt) => {\n const value = evt.currentTarget.value;\n setInputValue(value);\n try {\n const newDates = (value as string)\n .split(',')\n .map((d) => parse(d.trim(), formatStr, new Date()));\n setSelectedDates(newDates);\n if (onChange) onChange(newDates);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (err) {\n // empty\n }\n }}\n ref={refs.setReference as Ref<InputHandle>}\n type=\"datetime-local\"\n value={inputValue}\n />\n <div\n className=\"firefox-patch\"\n onClick={onFirefoxPatchClick as MouseEventHandler<HTMLDivElement>}\n />\n {isPickerOpen && (\n <FloatingFocusManager context={context} initialFocus={-1} modal={false}>\n {/* refs.setFloating is a stable callback ref from floating-ui */}\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <Card>\n <DateTimePicker\n {...pickerProps}\n css={pickerCSS}\n onDatesChange={(d) => {\n setSelectedDates(d);\n setInputValue(d.map((date) => format(date, formatStr)).join(', '));\n if (onChange) onChange(d);\n }}\n onFastTravelClick={() => setIsPickerOpen(false)}\n onTimeButtonClick={() => setIsPickerOpen(false)}\n selectedDates={selectedDates}\n showDatePresets={showDatePresets}\n showTimePicker={showTimePicker}\n />\n </Card>\n <FloatingArrow ref={arrowRef} context={context} fill=\"var(--colors-01dp)\" />\n </div>\n </FloatingFocusManager>\n )}\n </StyledWrapper>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAM,gBAAgBA,wBAAAA,OAAO,OAAO;CAClC,SAAS;CACT,UAAU;CACV,OAAO;CAEP,oBAAoB,EAClB,SAAS,OACX;CAEA,qCAAqC;EACnC,oBAAoB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACR,UAAU;GACV,OAAO;GACP,KAAK;GACL,YAAY;GAEZ,aAAa;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GACA,YAAY;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GAEA,mBAAmB;IACjB,aAAa,EACX,iBAAiB,gBACnB;IACA,YAAY;KACV,iBAAiB;KACjB,SAAS;IACX;GACF;EACF;EAEA,UAAU,EACR,0BAA0B;GACxB,aAAa,EACX,iBAAiB,gBACnB;GACA,YAAY;IACV,iBAAiB;IACjB,SAAS;GACX;EACF,EACF;CACF;AACF,CAAC;AAcD,IAAa,sBAAsBC,MAAAA,QAAM,YAKrC,EACE,UACA,YACA,UACA,WACA,iBACA,iBACA,gBACA,GAAG,eAEL,gBACG;CACH,MAAM,YAAY;CAElB,MAAM,YAAA,GAAWC,MAAAA,OAAAA,CAAO,IAAI;CAE5B,MAAM,CAAC,YAAY,kBAAA,GAAiBC,MAAAA,SAAAA,CAAiB,EAAE;CACvD,MAAM,CAAC,eAAe,qBAAA,GAAoBA,MAAAA,SAAAA,CAAiB,CAAC,CAAC;CAC7D,MAAM,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,KAAK,CAAC,CAAC;MACpD,iBAAiB,QAAQ;MACzB,IAAI,UAAU,SAAS,QAAQ;KAEjC,SAAS,KAAK,CAEd;IACF;IACA,KAAK,KAAK;IACV,MAAK;IACL,OAAO;GACR,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACE,WAAU;IACV,SAAS;GACV,CAAA;GACA,gBACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,sBAAD;IAA+B;IAAS,cAAc;IAAI,OAAO;IAE/D,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;KAAK,KAAK,KAAK;KAAa,OAAO;KAAgB,GAAI,iBAAiB;KAAxE,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,gBAAD;MACE,GAAI;MACJ,KAAK;MACL,gBAAgB,MAAM;OACpB,iBAAiB,CAAC;OAClB,cAAc,EAAE,KAAK,UAAA,GAASC,SAAAA,OAAAA,CAAO,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;OACjE,IAAI,UAAU,SAAS,CAAC;MAC1B;MACA,yBAAyB,gBAAgB,KAAK;MAC9C,yBAAyB,gBAAgB,KAAK;MAC/B;MACE;MACD;KACjB,CAAA,EACG,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,eAAD;MAAe,KAAK;MAAmB;MAAS,MAAK;KAAsB,CAAA,CACxE;;GACe,CAAA;EAEX;;AAEnB,CACF"}
@@ -85,7 +85,7 @@ var DateTimePickerInput = React.forwardRef(({ inputCSS, inputProps, onChange, pi
85
85
  ref: fowardedRef,
86
86
  children: [
87
87
  /* @__PURE__ */ jsx(Input, {
88
- startAdornment: /* @__PURE__ */ jsx(CalendarIcon, {}),
88
+ startAdornment: /* @__PURE__ */ jsx(CalendarIcon, { "aria-hidden": true }),
89
89
  ...getReferenceProps(),
90
90
  ...inputProps,
91
91
  css: {
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePickerInput.js","names":[],"sources":["../../../components/DateTimePickerInput/DateTimePickerInput.tsx"],"sourcesContent":["import {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n offset,\n Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useRole,\n} from '@floating-ui/react';\nimport { CalendarIcon } from '@radix-ui/react-icons';\nimport { DPUserConfig } from '@rehookify/datepicker';\nimport { format, parse } from 'date-fns';\nimport React, { MouseEventHandler, Ref, useMemo, useRef, useState } from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { Card } from '../Card';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { Input, InputHandle } from '../Input';\n\nconst StyledWrapper = styled('div', {\n display: 'flex',\n position: 'relative',\n width: '100%',\n\n '& .firefox-patch': {\n display: 'none',\n },\n\n '@supports (-moz-appearance: none)': {\n '& .firefox-patch': {\n display: 'block',\n width: '20px',\n height: '20px',\n position: 'absolute',\n right: '17px',\n top: '6px',\n background: '$inputBg',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n },\n\n '@hover': {\n '&:hover .firefox-patch': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n },\n});\n\nexport type DateTimePickerInputProps = Omit<DPUserConfig, 'onDatesChange' | 'selectedDates'> & {\n inputCSS?: CSS;\n inputProps?: Omit<typeof Input, 'css' | 'onChange' | 'ref' | 'value'>;\n onChange?: (d: Date[]) => void;\n pickerCSS?: CSS;\n pickerPlacement?: Placement;\n showDatePresets?: boolean;\n showTimePicker?: boolean;\n};\n\nexport type DateTimePickerInputVariants = VariantProps<DateTimePickerInputProps>;\n\nexport const DateTimePickerInput = React.forwardRef<\n React.ElementRef<typeof StyledWrapper>,\n DateTimePickerInputProps\n>(\n (\n {\n inputCSS,\n inputProps,\n onChange,\n pickerCSS,\n pickerPlacement,\n showDatePresets,\n showTimePicker,\n ...pickerProps\n },\n fowardedRef,\n ) => {\n const formatStr = \"yyyy-MM-dd'T'HH:mm\";\n\n const arrowRef = useRef(null);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [selectedDates, setSelectedDates] = useState<Date[]>([]);\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n\n const middleware = useMemo(\n () => [\n offset(10),\n flip(),\n shift(),\n // arrowRef is passed to floating-ui which handles it correctly\n arrow({ element: arrowRef }),\n ],\n [],\n );\n\n const { refs, floatingStyles, context } = useFloating({\n open: isPickerOpen,\n onOpenChange: setIsPickerOpen,\n placement: pickerPlacement,\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);\n const { onClick: onFirefoxPatchClick } = getReferenceProps();\n\n return (\n <StyledWrapper ref={fowardedRef}>\n <Input\n startAdornment={<CalendarIcon />}\n {...getReferenceProps()}\n {...inputProps}\n css={{ '& input::-webkit-calendar-picker-indicator': { display: 'none' }, ...inputCSS }}\n onChange={(evt) => {\n const value = evt.currentTarget.value;\n setInputValue(value);\n try {\n const newDates = (value as string)\n .split(',')\n .map((d) => parse(d.trim(), formatStr, new Date()));\n setSelectedDates(newDates);\n if (onChange) onChange(newDates);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (err) {\n // empty\n }\n }}\n ref={refs.setReference as Ref<InputHandle>}\n type=\"datetime-local\"\n value={inputValue}\n />\n <div\n className=\"firefox-patch\"\n onClick={onFirefoxPatchClick as MouseEventHandler<HTMLDivElement>}\n />\n {isPickerOpen && (\n <FloatingFocusManager context={context} initialFocus={-1} modal={false}>\n {/* refs.setFloating is a stable callback ref from floating-ui */}\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <Card>\n <DateTimePicker\n {...pickerProps}\n css={pickerCSS}\n onDatesChange={(d) => {\n setSelectedDates(d);\n setInputValue(d.map((date) => format(date, formatStr)).join(', '));\n if (onChange) onChange(d);\n }}\n onFastTravelClick={() => setIsPickerOpen(false)}\n onTimeButtonClick={() => setIsPickerOpen(false)}\n selectedDates={selectedDates}\n showDatePresets={showDatePresets}\n showTimePicker={showTimePicker}\n />\n </Card>\n <FloatingArrow ref={arrowRef} context={context} fill=\"var(--colors-01dp)\" />\n </div>\n </FloatingFocusManager>\n )}\n </StyledWrapper>\n );\n },\n);\n"],"mappings":";;;;;;;;;;AAyBA,IAAM,gBAAgB,OAAO,OAAO;CAClC,SAAS;CACT,UAAU;CACV,OAAO;CAEP,oBAAoB,EAClB,SAAS,OACX;CAEA,qCAAqC;EACnC,oBAAoB;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;GACR,UAAU;GACV,OAAO;GACP,KAAK;GACL,YAAY;GAEZ,aAAa;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GACA,YAAY;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,eAAe;GACjB;GAEA,mBAAmB;IACjB,aAAa,EACX,iBAAiB,gBACnB;IACA,YAAY;KACV,iBAAiB;KACjB,SAAS;IACX;GACF;EACF;EAEA,UAAU,EACR,0BAA0B;GACxB,aAAa,EACX,iBAAiB,gBACnB;GACA,YAAY;IACV,iBAAiB;IACjB,SAAS;GACX;EACF,EACF;CACF;AACF,CAAC;AAcD,IAAa,sBAAsB,MAAM,YAKrC,EACE,UACA,YACA,UACA,WACA,iBACA,iBACA,gBACA,GAAG,eAEL,gBACG;C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IAA+B;IAAS,cAAc;IAAI,OAAO;IAE/D,UAAA,qBAAC,OAAD;KAAK,KAAK,KAAK;KAAa,OAAO;KAAgB,GAAI,iBAAiB;KAAxE,UAAA,CACE,oBAAC,MAAD,EAAA,UACE,oBAAC,gBAAD;MACE,GAAI;MACJ,KAAK;MACL,gBAAgB,MAAM;OACpB,iBAAiB,CAAC;OAClB,cAAc,EAAE,KAAK,SAAS,OAAO,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;OACjE,IAAI,UAAU,SAAS,CAAC;MAC1B;MACA,yBAAyB,gBAAgB,KAAK;MAC9C,yBAAyB,gBAAgB,KAAK;MAC/B;MACE;MACD;KACjB,CAAA,EACG,CAAA,GACN,oBAAC,eAAD;MAAe,KAAK;MAAmB;MAAS,MAAK;KAAsB,CAAA,CACxE;;GACe,CAAA;EAEX;;AAEnB,CACF"}
1
+ {"version":3,"file":"DateTimePickerInput.js","names":[],"sources":["../../../components/DateTimePickerInput/DateTimePickerInput.tsx"],"sourcesContent":["import {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n offset,\n Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useRole,\n} from '@floating-ui/react';\nimport { CalendarIcon } from '@radix-ui/react-icons';\nimport { DPUserConfig } from '@rehookify/datepicker';\nimport { format, parse } from 'date-fns';\nimport React, { MouseEventHandler, Ref, useMemo, useRef, useState } from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { Card } from '../Card';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { Input, InputHandle } from '../Input';\n\nconst StyledWrapper = styled('div', {\n display: 'flex',\n position: 'relative',\n width: '100%',\n\n '& .firefox-patch': {\n display: 'none',\n },\n\n '@supports (-moz-appearance: none)': {\n '& .firefox-patch': {\n display: 'block',\n width: '20px',\n height: '20px',\n position: 'absolute',\n right: '17px',\n top: '6px',\n background: '$inputBg',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$inputFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n },\n\n '@hover': {\n '&:hover .firefox-patch': {\n '&::before': {\n backgroundColor: '$inputHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n },\n});\n\nexport type DateTimePickerInputProps = Omit<DPUserConfig, 'onDatesChange' | 'selectedDates'> & {\n inputCSS?: CSS;\n inputProps?: Omit<typeof Input, 'css' | 'onChange' | 'ref' | 'value'>;\n onChange?: (d: Date[]) => void;\n pickerCSS?: CSS;\n pickerPlacement?: Placement;\n showDatePresets?: boolean;\n showTimePicker?: boolean;\n};\n\nexport type DateTimePickerInputVariants = VariantProps<DateTimePickerInputProps>;\n\nexport const DateTimePickerInput = React.forwardRef<\n React.ElementRef<typeof StyledWrapper>,\n DateTimePickerInputProps\n>(\n (\n {\n inputCSS,\n inputProps,\n onChange,\n pickerCSS,\n pickerPlacement,\n showDatePresets,\n showTimePicker,\n ...pickerProps\n },\n fowardedRef,\n ) => {\n const formatStr = \"yyyy-MM-dd'T'HH:mm\";\n\n const arrowRef = useRef(null);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [selectedDates, setSelectedDates] = useState<Date[]>([]);\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n\n const middleware = useMemo(\n () => [\n offset(10),\n flip(),\n shift(),\n // arrowRef is passed to floating-ui which handles it correctly\n arrow({ element: arrowRef }),\n ],\n [],\n );\n\n const { refs, floatingStyles, context } = useFloating({\n open: isPickerOpen,\n onOpenChange: setIsPickerOpen,\n placement: pickerPlacement,\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);\n const { onClick: onFirefoxPatchClick } = getReferenceProps();\n\n return (\n <StyledWrapper ref={fowardedRef}>\n <Input\n startAdornment={<CalendarIcon aria-hidden />}\n {...getReferenceProps()}\n {...inputProps}\n css={{ '& input::-webkit-calendar-picker-indicator': { display: 'none' }, ...inputCSS }}\n onChange={(evt) => {\n const value = evt.currentTarget.value;\n setInputValue(value);\n try {\n const newDates = (value as string)\n .split(',')\n .map((d) => parse(d.trim(), formatStr, new Date()));\n setSelectedDates(newDates);\n if (onChange) onChange(newDates);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (err) {\n // empty\n }\n }}\n ref={refs.setReference as Ref<InputHandle>}\n type=\"datetime-local\"\n value={inputValue}\n />\n <div\n className=\"firefox-patch\"\n onClick={onFirefoxPatchClick as MouseEventHandler<HTMLDivElement>}\n />\n {isPickerOpen && (\n <FloatingFocusManager context={context} initialFocus={-1} modal={false}>\n {/* refs.setFloating is a stable callback ref from floating-ui */}\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <Card>\n <DateTimePicker\n {...pickerProps}\n css={pickerCSS}\n onDatesChange={(d) => {\n setSelectedDates(d);\n setInputValue(d.map((date) => format(date, formatStr)).join(', '));\n if (onChange) onChange(d);\n }}\n onFastTravelClick={() => setIsPickerOpen(false)}\n onTimeButtonClick={() => setIsPickerOpen(false)}\n selectedDates={selectedDates}\n showDatePresets={showDatePresets}\n showTimePicker={showTimePicker}\n />\n </Card>\n <FloatingArrow ref={arrowRef} context={context} fill=\"var(--colors-01dp)\" />\n </div>\n </FloatingFocusManager>\n )}\n </StyledWrapper>\n );\n },\n);\n"],"mappings":";;;;;;;;;;AAyBA,IAAM,gBAAgB,OAAO,OAAO;CAClC,SAAS;CACT,UAAU;CACV,OAAO;CAEP,oBAAoB,EAClB,SAAS,OACX;CAEA,qCAAqC;EACnC,oBAAoB;GAClB,SAAS;GACT,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oBAAC,cAAD,EAAc,eAAA,KAAa,CAAA;IAC3C,GAAI,kBAAkB;IACtB,GAAI;IACJ,KAAK;KAAE,8CAA8C,EAAE,SAAS,OAAO;KAAG,GAAG;IAAS;IACtF,WAAW,QAAQ;KACjB,MAAM,QAAQ,IAAI,cAAc;KAChC,cAAc,KAAK;KACnB,IAAI;MACF,MAAM,WAAY,MACf,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,MAAM,EAAE,KAAK,GAAG,2BAAW,IAAI,KAAK,CAAC,CAAC;MACpD,iBAAiB,QAAQ;MACzB,IAAI,UAAU,SAAS,QAAQ;KAEjC,SAAS,KAAK,CAEd;IACF;IACA,KAAK,KAAK;IACV,MAAK;IACL,OAAO;GACR,CAAA;GACD,oBAAC,OAAD;IACE,WAAU;IACV,SAAS;GACV,CAAA;GACA,gBACC,oBAAC,sBAAD;IAA+B;IAAS,cAAc;IAAI,OAAO;IAE/D,UAAA,qBAAC,OAAD;KAAK,KAAK,KAAK;KAAa,OAAO;KAAgB,GAAI,iBAAiB;KAAxE,UAAA,CACE,oBAAC,MAAD,EAAA,UACE,oBAAC,gBAAD;MACE,GAAI;MACJ,KAAK;MACL,gBAAgB,MAAM;OACpB,iBAAiB,CAAC;OAClB,cAAc,EAAE,KAAK,SAAS,OAAO,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;OACjE,IAAI,UAAU,SAAS,CAAC;MAC1B;MACA,yBAAyB,gBAAgB,KAAK;MAC9C,yBAAyB,gBAAgB,KAAK;MAC/B;MACE;MACD;KACjB,CAAA,EACG,CAAA,GACN,oBAAC,eAAD;MAAe,KAAK;MAAmB;MAAS,MAAK;KAAsB,CAAA,CACxE;;GACe,CAAA;EAEX;;AAEnB,CACF"}
@@ -0,0 +1,91 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_Box = require("../Box/Box.cjs");
3
+ const require_Text = require("../Text/Text.cjs");
4
+ const require_Label = require("../Label/Label.cjs");
5
+ const require_FieldContext = require("./FieldContext.cjs");
6
+ const require_VisuallyHidden = require("../VisuallyHidden/VisuallyHidden.cjs");
7
+ let react = require("react");
8
+ react = require_runtime.__toESM(react, 1);
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ // components/Field/Field.tsx
11
+ var MESSAGE_CSS = {
12
+ display: "block",
13
+ m: 0,
14
+ mt: "$1"
15
+ };
16
+ /**
17
+ * Gives a label, a description and an error to the one form control inside it.
18
+ * Its label connects to one control, so do not put two controls in one Field.
19
+ */
20
+ var Field = ({ label, description, error, announceError, labelPosition = "top", children, css, ...props }) => {
21
+ const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } = require_FieldContext.useFieldRoot({
22
+ label,
23
+ description,
24
+ error,
25
+ ...props
26
+ });
27
+ const announcedError = require_FieldContext.useAnnouncedError(Boolean(announceError), hasError ? context.errorId : void 0, context.labelId);
28
+ const labelNode = react.default.useMemo(() => {
29
+ if (!hasLabel || !context.labelId) return null;
30
+ if (typeof label === "function") return label({
31
+ variant: labelVariant,
32
+ htmlFor: labelFor,
33
+ id: context.labelId
34
+ });
35
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Label.Label, {
36
+ variant: labelVariant,
37
+ htmlFor: labelFor,
38
+ id: context.labelId,
39
+ children: label
40
+ });
41
+ }, [
42
+ hasLabel,
43
+ label,
44
+ labelVariant,
45
+ labelFor,
46
+ context.labelId
47
+ ]);
48
+ const errorNode = hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
49
+ as: "p",
50
+ id: context.errorId,
51
+ size: "0",
52
+ variant: "invalid",
53
+ css: MESSAGE_CSS,
54
+ children: error
55
+ });
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldContext.FieldContext.Provider, {
57
+ value: context,
58
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box.Box, {
59
+ css,
60
+ onFocus,
61
+ onBlur,
62
+ children: [
63
+ labelPosition === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box.Box, {
64
+ css: {
65
+ display: "flex",
66
+ alignItems: "center",
67
+ gap: "$2",
68
+ "& > [role=\"switch\"]": { m: 0 }
69
+ },
70
+ children: [children, labelNode]
71
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [labelNode, children] }),
72
+ hasDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
73
+ as: "p",
74
+ id: context.descriptionId,
75
+ size: "0",
76
+ variant: "subtle",
77
+ css: MESSAGE_CSS,
78
+ children: description
79
+ }),
80
+ errorNode,
81
+ announceError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_VisuallyHidden.VisuallyHidden, {
82
+ "aria-live": "polite",
83
+ children: announcedError
84
+ })
85
+ ]
86
+ })
87
+ });
88
+ };
89
+ exports.Field = Field;
90
+
91
+ //# sourceMappingURL=Field.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.cjs","names":["useFieldRoot","useAnnouncedError","React","Label","Text","FieldContext","Box","_Fragment","VisuallyHidden"],"sources":["../../../components/Field/Field.tsx"],"sourcesContent":["import React from 'react';\n\nimport { CSS } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Label } from '../Label';\nimport { Text } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { FieldBaseProps, FieldContext, useAnnouncedError, useFieldRoot } from './FieldContext';\n\nexport type FieldProps = FieldBaseProps & { css?: CSS };\n\nconst MESSAGE_CSS = { display: 'block', m: 0, mt: '$1' };\n\n/**\n * Gives a label, a description and an error to the one form control inside it.\n * Its label connects to one control, so do not put two controls in one Field.\n */\nexport const Field = ({\n label,\n description,\n error,\n announceError,\n labelPosition = 'top',\n children,\n css,\n ...props\n}: FieldProps) => {\n const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } =\n useFieldRoot({ label, description, error, ...props });\n const announcedError = useAnnouncedError(\n Boolean(announceError),\n hasError ? context.errorId : undefined,\n context.labelId,\n );\n\n const labelNode = React.useMemo(() => {\n if (!hasLabel || !context.labelId) {\n return null;\n }\n if (typeof label === 'function') {\n return label({ variant: labelVariant, htmlFor: labelFor, id: context.labelId });\n }\n return (\n <Label variant={labelVariant} htmlFor={labelFor} id={context.labelId}>\n {label}\n </Label>\n );\n }, [hasLabel, label, labelVariant, labelFor, context.labelId]);\n\n const errorNode = hasError && (\n <Text as=\"p\" id={context.errorId} size=\"0\" variant=\"invalid\" css={MESSAGE_CSS}>\n {error}\n </Text>\n );\n\n return (\n <FieldContext.Provider value={context}>\n <Box css={css} onFocus={onFocus} onBlur={onBlur}>\n {labelPosition === 'end' ? (\n <Box\n css={{\n display: 'flex',\n alignItems: 'center',\n gap: '$2',\n '& > [role=\"switch\"]': { m: 0 },\n }}\n >\n {children}\n {labelNode}\n </Box>\n ) : (\n <>\n {labelNode}\n {children}\n </>\n )}\n {hasDescription && (\n <Text as=\"p\" id={context.descriptionId} size=\"0\" variant=\"subtle\" css={MESSAGE_CSS}>\n {description}\n </Text>\n )}\n {errorNode}\n {announceError && <VisuallyHidden aria-live=\"polite\">{announcedError}</VisuallyHidden>}\n </Box>\n </FieldContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;AAWA,IAAM,cAAc;CAAE,SAAS;CAAS,GAAG;CAAG,IAAI;AAAK;;;;;AAMvD,IAAa,SAAS,EACpB,OACA,aACA,OACA,eACA,gBAAgB,OAChB,UACA,KACA,GAAG,YACa;CAChB,MAAM,EAAE,SAAS,UAAU,cAAc,UAAU,gBAAgB,UAAU,SAAS,WACpFA,qBAAAA,aAAa;EAAE;EAAO;EAAa;EAAO,GAAG;CAAM,CAAC;CACtD,MAAM,iBAAiBC,qBAAAA,kBACrB,QAAQ,aAAa,GACrB,WAAW,QAAQ,UAAU,KAAA,GAC7B,QAAQ,OACV;CAEA,MAAM,YAAYC,MAAAA,QAAM,cAAc;EACpC,IA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89 @@
1
+ import { Box } from "../Box/Box.js";
2
+ import { Text } from "../Text/Text.js";
3
+ import { Label } from "../Label/Label.js";
4
+ import { FieldContext, useAnnouncedError, useFieldRoot } from "./FieldContext.js";
5
+ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
6
+ import React from "react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ // components/Field/Field.tsx
9
+ var MESSAGE_CSS = {
10
+ display: "block",
11
+ m: 0,
12
+ mt: "$1"
13
+ };
14
+ /**
15
+ * Gives a label, a description and an error to the one form control inside it.
16
+ * Its label connects to one control, so do not put two controls in one Field.
17
+ */
18
+ var Field = ({ label, description, error, announceError, labelPosition = "top", children, css, ...props }) => {
19
+ const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } = useFieldRoot({
20
+ label,
21
+ description,
22
+ error,
23
+ ...props
24
+ });
25
+ const announcedError = useAnnouncedError(Boolean(announceError), hasError ? context.errorId : void 0, context.labelId);
26
+ const labelNode = React.useMemo(() => {
27
+ if (!hasLabel || !context.labelId) return null;
28
+ if (typeof label === "function") return label({
29
+ variant: labelVariant,
30
+ htmlFor: labelFor,
31
+ id: context.labelId
32
+ });
33
+ return /* @__PURE__ */ jsx(Label, {
34
+ variant: labelVariant,
35
+ htmlFor: labelFor,
36
+ id: context.labelId,
37
+ children: label
38
+ });
39
+ }, [
40
+ hasLabel,
41
+ label,
42
+ labelVariant,
43
+ labelFor,
44
+ context.labelId
45
+ ]);
46
+ const errorNode = hasError && /* @__PURE__ */ jsx(Text, {
47
+ as: "p",
48
+ id: context.errorId,
49
+ size: "0",
50
+ variant: "invalid",
51
+ css: MESSAGE_CSS,
52
+ children: error
53
+ });
54
+ return /* @__PURE__ */ jsx(FieldContext.Provider, {
55
+ value: context,
56
+ children: /* @__PURE__ */ jsxs(Box, {
57
+ css,
58
+ onFocus,
59
+ onBlur,
60
+ children: [
61
+ labelPosition === "end" ? /* @__PURE__ */ jsxs(Box, {
62
+ css: {
63
+ display: "flex",
64
+ alignItems: "center",
65
+ gap: "$2",
66
+ "& > [role=\"switch\"]": { m: 0 }
67
+ },
68
+ children: [children, labelNode]
69
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [labelNode, children] }),
70
+ hasDescription && /* @__PURE__ */ jsx(Text, {
71
+ as: "p",
72
+ id: context.descriptionId,
73
+ size: "0",
74
+ variant: "subtle",
75
+ css: MESSAGE_CSS,
76
+ children: description
77
+ }),
78
+ errorNode,
79
+ announceError && /* @__PURE__ */ jsx(VisuallyHidden, {
80
+ "aria-live": "polite",
81
+ children: announcedError
82
+ })
83
+ ]
84
+ })
85
+ });
86
+ };
87
+ export { Field };
88
+
89
+ //# sourceMappingURL=Field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.js","names":["_Fragment"],"sources":["../../../components/Field/Field.tsx"],"sourcesContent":["import React from 'react';\n\nimport { CSS } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Label } from '../Label';\nimport { Text } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { FieldBaseProps, FieldContext, useAnnouncedError, useFieldRoot } from './FieldContext';\n\nexport type FieldProps = FieldBaseProps & { css?: CSS };\n\nconst MESSAGE_CSS = { display: 'block', m: 0, mt: '$1' };\n\n/**\n * Gives a label, a description and an error to the one form control inside it.\n * Its label connects to one control, so do not put two controls in one Field.\n */\nexport const Field = ({\n label,\n description,\n error,\n announceError,\n labelPosition = 'top',\n children,\n css,\n ...props\n}: FieldProps) => {\n const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } =\n useFieldRoot({ label, description, error, ...props });\n const announcedError = useAnnouncedError(\n Boolean(announceError),\n hasError ? context.errorId : undefined,\n context.labelId,\n );\n\n const labelNode = React.useMemo(() => {\n if (!hasLabel || !context.labelId) {\n return null;\n }\n if (typeof label === 'function') {\n return label({ variant: labelVariant, htmlFor: labelFor, id: context.labelId });\n }\n return (\n <Label variant={labelVariant} htmlFor={labelFor} id={context.labelId}>\n {label}\n </Label>\n );\n }, [hasLabel, label, labelVariant, labelFor, context.labelId]);\n\n const errorNode = hasError && (\n <Text as=\"p\" id={context.errorId} size=\"0\" variant=\"invalid\" css={MESSAGE_CSS}>\n {error}\n </Text>\n );\n\n return (\n <FieldContext.Provider value={context}>\n <Box css={css} onFocus={onFocus} onBlur={onBlur}>\n {labelPosition === 'end' ? (\n <Box\n css={{\n display: 'flex',\n alignItems: 'center',\n gap: '$2',\n '& > [role=\"switch\"]': { m: 0 },\n }}\n >\n {children}\n {labelNode}\n </Box>\n ) : (\n <>\n {labelNode}\n {children}\n </>\n )}\n {hasDescription && (\n <Text as=\"p\" id={context.descriptionId} size=\"0\" variant=\"subtle\" css={MESSAGE_CSS}>\n {description}\n </Text>\n )}\n {errorNode}\n {announceError && <VisuallyHidden aria-live=\"polite\">{announcedError}</VisuallyHidden>}\n </Box>\n </FieldContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AAWA,IAAM,cAAc;CAAE,SAAS;CAAS,GAAG;CAAG,IAAI;AAAK;;;;;AAMvD,IAAa,SAAS,EACpB,OACA,aACA,OACA,eACA,gBAAgB,OAChB,UACA,KACA,GAAG,YACa;CAChB,MAAM,EAAE,SAAS,UAAU,cAAc,UAAU,gBAAgB,UAAU,SAAS,WACpF,aAAa;EAAE;EAAO;EAAa;EAAO,GAAG;CAAM,CAAC;CACtD,MAAM,iBAAiB,kBACrB,QAAQ,aAAa,GACrB,WAAW,QAAQ,UAAU,KAAA,GAC7B,QAAQ,OACV;CAEA,MAAM,YAAY,MAAM,cAAc;EACpC,IAAI,CAAC,YAAY,CAAC,QAAQ,SACxB,OAAO;EAET,IAAI,OAAO,UAAU,YACnB,OAAO,MAAM;GAAE,SAAS;GAAc,SAAS;GAAU,IAAI,QAAQ;EAAQ,CAAC;EAEhF,OACE,oBAAC,OAAD;GAAO,SAAS;GAAc,SAAS;GAAU,IAAI,QAAQ;GAC1D,UAAA;EACI,CAAA;CAEX,GAAG;EAAC;EAAU;EAAO;EAAc;EAAU,QAAQ;CAAO,CAAC;CAE7D,MAAM,YAAY,YAChB,oBAAC,MAAD;EAAM,IAAG;EAAI,IAAI,QAAQ;EAAS,MAAK;EAAI,SAAQ;EAAU,KAAK;EAC/D,UAAA;CACG,CAAA;CAGR,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAC5B,UAAA,qBAAC,KAAD;GAAU;GAAc;GAAiB;GAAzC,UAAA;IACG,kBAAkB,QACjB,qBAAC,KAAD;KACE,KAAK;MACH,SAAS;MACT,YAAY;MACZ,KAAK;MACL,yBAAuB,EAAE,GAAG,EAAE;KAChC;KANF,UAAA,CAQG,UACA,SACE;IAEL,CAAA,IAAA,qBAAAA,UAAA,EAAA,UAAA,CACG,WACA,QACD,EAAA,CAAA;IAEH,kBACC,oBAAC,MAAD;KAAM,IAAG;KAAI,IAAI,QAAQ;KAAe,MAAK;KAAI,SAAQ;KAAS,KAAK;KACpE,UAAA;IACG,CAAA;IAEP;IACA,iBAAiB,oBAAC,gBAAD;KAAgB,aAAU;KAAU,UAAA;IAA+B,CAAA;GAClF;;CACgB,CAAA;AAE3B"}
@@ -0,0 +1,95 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_cssProps = require("../../styles/cssProps.cjs");
3
+ const require_themeContext = require("../../styles/themeContext.cjs");
4
+ const require_Box_vanilla = require("../Box/Box.vanilla.cjs");
5
+ const require_Text_vanilla = require("../Text/Text.vanilla.cjs");
6
+ const require_Label_vanilla = require("../Label/Label.vanilla.cjs");
7
+ const require_FieldContext = require("./FieldContext.cjs");
8
+ const require_VisuallyHidden = require("../VisuallyHidden/VisuallyHidden.cjs");
9
+ const require_Field_vanilla_css = require("./Field.vanilla.css.cjs");
10
+ let react = require("react");
11
+ react = require_runtime.__toESM(react, 1);
12
+ let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
13
+ let react_jsx_runtime = require("react/jsx-runtime");
14
+ // components/Field/Field.vanilla.tsx
15
+ var MESSAGE_CSS = {
16
+ display: "block",
17
+ m: 0,
18
+ mt: "$1"
19
+ };
20
+ /**
21
+ * Gives a label, a description and an error to the one form control inside it.
22
+ * Its label connects to one control, so do not put two controls in one Field.
23
+ */
24
+ var FieldVanilla = ({ label, description, error, announceError, labelPosition = "top", children, css, ...props }) => {
25
+ const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } = require_FieldContext.useFieldRoot({
26
+ label,
27
+ description,
28
+ error,
29
+ ...props
30
+ });
31
+ const announcedError = require_FieldContext.useAnnouncedError(Boolean(announceError), hasError ? context.errorId : void 0, context.labelId);
32
+ const { colors } = require_themeContext.useVanillaExtractTheme();
33
+ const { style: rootStyle, vars: rootVars } = require_cssProps.processCSSProp(css, colors);
34
+ const labelNode = react.default.useMemo(() => {
35
+ if (!hasLabel || !context.labelId) return null;
36
+ if (typeof label === "function") return label({
37
+ variant: labelVariant,
38
+ htmlFor: labelFor,
39
+ id: context.labelId
40
+ });
41
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Label_vanilla.LabelVanilla, {
42
+ variant: labelVariant,
43
+ htmlFor: labelFor,
44
+ id: context.labelId,
45
+ children: label
46
+ });
47
+ }, [
48
+ hasLabel,
49
+ label,
50
+ labelVariant,
51
+ labelFor,
52
+ context.labelId
53
+ ]);
54
+ const errorNode = hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text_vanilla.TextVanilla, {
55
+ as: "p",
56
+ id: context.errorId,
57
+ size: "0",
58
+ variant: "invalid",
59
+ css: MESSAGE_CSS,
60
+ children: error
61
+ });
62
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldContext.FieldContext.Provider, {
63
+ value: context,
64
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
65
+ style: {
66
+ ...rootStyle,
67
+ ...(0, _vanilla_extract_dynamic.assignInlineVars)(rootVars)
68
+ },
69
+ onFocus,
70
+ onBlur,
71
+ children: [
72
+ labelPosition === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box_vanilla.BoxVanilla, {
73
+ className: require_Field_vanilla_css.endLabelRow,
74
+ children: [children, labelNode]
75
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [labelNode, children] }),
76
+ hasDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text_vanilla.TextVanilla, {
77
+ as: "p",
78
+ id: context.descriptionId,
79
+ size: "0",
80
+ variant: "subtle",
81
+ css: MESSAGE_CSS,
82
+ children: description
83
+ }),
84
+ errorNode,
85
+ announceError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_VisuallyHidden.VisuallyHidden, {
86
+ "aria-live": "polite",
87
+ children: announcedError
88
+ })
89
+ ]
90
+ })
91
+ });
92
+ };
93
+ exports.FieldVanilla = FieldVanilla;
94
+
95
+ //# sourceMappingURL=Field.vanilla.cjs.map