@langchain/macaw-components 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.css +5 -5
- package/dist/catalog.json +535 -480
- package/dist/components/Accordion/Accordion.d.ts +63 -0
- package/dist/components/Accordion/Accordion.js +170 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Attachment/Attachment.js +3 -3
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Banner/Banner.js +2 -2
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/constants.js +2 -2
- package/dist/components/Button/constants.js.map +1 -1
- package/dist/components/ChartCard/ChartCard.js +2 -2
- package/dist/components/ChartLegend/ChartLegend.js +1 -1
- package/dist/components/ChartTooltip/ChartTooltip.js +2 -2
- package/dist/components/ChartTooltip/ChartTooltip.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Code/CodeLite.js +2 -2
- package/dist/components/Code/index.js +1 -1
- package/dist/components/Command/Command.js +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/Command/CommandMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +3 -2
- package/dist/components/CopyButton/CopyButton.js +7 -2
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/Dialog/index.d.ts +3 -2
- package/dist/components/Dialog/index.js +47 -20
- package/dist/components/Dialog/index.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/ErrorMessage/ErrorMessage.js +3 -3
- package/dist/components/GroupedTabs/GroupedTabs.d.ts +3 -2
- package/dist/components/GroupedTabs/GroupedTabs.js +3 -1
- package/dist/components/GroupedTabs/GroupedTabs.js.map +1 -1
- package/dist/components/IconButton/IconButton.js +2 -2
- package/dist/components/Input/Input.js +8 -7
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/inputStyles.js +4 -4
- package/dist/components/Input/inputStyles.js.map +1 -1
- package/dist/components/Link/Link.js +3 -3
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/Pane/Pane.d.ts +3 -2
- package/dist/components/Pane/Pane.js +109 -103
- package/dist/components/Pane/Pane.js.map +1 -1
- package/dist/components/Popover/Popover.js +15 -4
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Popover/constants.d.ts +1 -1
- package/dist/components/Popover/constants.js +1 -1
- package/dist/components/Popover/constants.js.map +1 -1
- package/dist/components/Select/Select.d.ts +10 -1
- package/dist/components/Select/Select.js +7 -5
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectPrimitive.js +6 -4
- package/dist/components/Select/SelectPrimitive.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/SplitViewPane/SplitViewPaneHeader.js +2 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +27 -0
- package/dist/components/StatusBadge/StatusBadge.js +42 -0
- package/dist/components/StatusBadge/StatusBadge.js.map +1 -0
- package/dist/components/StatusBadge/index.d.ts +2 -0
- package/dist/components/StatusBadge/index.js +2 -0
- package/dist/components/Tabs/index.d.ts +3 -2
- package/dist/components/Tabs/index.js +3 -1
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/Textarea.js +8 -8
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Toast/index.js +3 -3
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js +2 -2
- package/dist/components/Typeahead/TypeaheadView.js +10 -10
- package/dist/components/Typeahead/TypeaheadView.js.map +1 -1
- package/dist/components/UnsavedChangesDialog.js +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +7 -6
- package/dist/icons/LongTailPhosphorIcons.js +1 -1
- package/dist/icons/PaddedPhosphorIcons.js +2 -2
- package/dist/index.js +7 -6
- package/dist/utilities.css +1 -1
- package/dist/utils/ModalLayerContext.d.ts +23 -0
- package/dist/utils/ModalLayerContext.js +92 -0
- package/dist/utils/ModalLayerContext.js.map +1 -0
- package/dist/utils/cn.js +4 -0
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/dataAttributes.d.ts +9 -0
- package/dist/utils/dataAttributes.js +13 -0
- package/dist/utils/dataAttributes.js.map +1 -0
- package/docs/DESIGN.md +21 -1
- package/docs/STYLES.md +84 -44
- package/package.json +20 -3
- package/tailwind.preset.cjs +11 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":[],"sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\nimport { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { useDebouncedCallback } from 'use-debounce';\n\nimport { CalendarBlankIcon } from '@phosphor-icons/react/dist/ssr/CalendarBlank';\nimport { EyeIcon } from '@phosphor-icons/react/dist/ssr/Eye';\nimport { EyeSlashIcon } from '@phosphor-icons/react/dist/ssr/EyeSlash';\nimport { PaperclipIcon } from '@phosphor-icons/react/dist/ssr/Paperclip';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport type { IconComponent } from '../../utils/icon-types';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n INPUT_TEXT_CLASSES,\n} from './inputStyles';\nimport type { InputSize } from './inputStyles';\n\nexport type InputIconAction = Pick<\n ComponentProps<typeof IconButton>,\n 'icon' | 'label' | 'disabled' | 'tooltipProps'\n> & {\n onClick: NonNullable<ComponentProps<typeof IconButton>['onClick']>;\n};\n\nexport interface InputProps {\n /** Exact outer height. The default lg tier preserves the legacy 40px field. */\n size?: InputSize;\n variant?: 'outlined' | 'plain';\n /** Decorative icon. Input owns its size and color. */\n leftIcon?: IconComponent;\n /** Decorative icon. Input owns its size and color. */\n rightIcon?: IconComponent;\n /** Plain icon button. Takes precedence over leftIcon. */\n leftAction?: InputIconAction;\n /** Plain icon button. Takes precedence over rightIcon; precedes the password toggle. */\n rightAction?: InputIconAction;\n /** Custom content; overrides leftIcon/leftAction and the default file icon. */\n leftDecorator?: ReactNode;\n /** Custom content; overrides rightIcon/rightAction. The password toggle remains last. */\n rightDecorator?: ReactNode;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Whether the input has an error state */\n isError?: boolean;\n /** Label text displayed above the input */\n label?: string | ReactNode;\n /** Hint text displayed below the input */\n hintText?: string;\n /** Current input value */\n value?: string | null;\n /** Change handler that will be debounced */\n onChange: (\n value: string,\n event?: React.ChangeEvent<HTMLInputElement>\n ) => void;\n /** Placeholder text */\n placeholder?: string;\n /**\n * Input type. Limited to the \"text-like\" native types that share this\n * component's styled-text rendering and string value contract. `password`\n * renders a masked secret field with a show/hide toggle. `date` uses the\n * browser's native date picker; its value is a `YYYY-MM-DD` string.\n * `datetime-local` uses the native date+time picker; its value is a\n * `YYYY-MM-DDTHH:mm` string in the viewer's local time. `file` is\n * uncontrolled: read the selection from `event.target.files` on the change\n * event, and scope it with `accept`/`multiple`.\n */\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'number'\n | 'url'\n | 'date'\n | 'datetime-local'\n | 'file';\n /** Debounce delay in milliseconds (default: 300). Ignored for `type=\"file\"`. */\n debounceMs?: number;\n /** Additional CSS classes */\n className?: string;\n /** Input ID for accessibility */\n id?: string;\n /** Input name for forms */\n name?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Auto focus on mount */\n autoFocus?: boolean;\n /** CSS class for the input container */\n inputContainerClassName?: string;\n /**\n * Which files the picker offers, as a comma-separated list of extensions or\n * MIME types (`'.csv,.json'`, `'image/*'`). `type=\"file\"` only. The browser\n * treats this as a filter, not a guarantee — validate the selection too.\n */\n accept?: string;\n /** Whether more than one file can be picked. `type=\"file\"` only. */\n multiple?: boolean;\n}\n\nfunction InputIconSlot({\n icon,\n action,\n size,\n disabled,\n}: {\n icon?: IconComponent;\n action?: InputIconAction;\n size: InputSize;\n disabled: boolean;\n}) {\n const isDisabled = disabled || action?.disabled;\n const colorClassName = isDisabled\n ? 'text-icon-disabled'\n : 'text-icon-secondary';\n\n return action ? (\n <IconButton\n {...action}\n color=\"secondary\"\n variant=\"plain\"\n size={CONTROL_ICON_SIZES[size].buttonSize}\n className={colorClassName}\n iconWeight=\"regular\"\n disabled={isDisabled}\n onMouseDown={(event) => event.preventDefault()}\n />\n ) : icon ? (\n <Icon\n aria-hidden\n icon={icon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={colorClassName}\n weight=\"regular\"\n />\n ) : null;\n}\n\nfunction FileSelection({\n size,\n fileNames,\n placeholder,\n}: {\n size: InputSize;\n fileNames: string[];\n placeholder?: string;\n}) {\n const summary =\n fileNames.length > 1 ? `${fileNames.length} files selected` : fileNames[0];\n const textClasses = INPUT_TEXT_CLASSES[size];\n\n return (\n <>\n <Text\n aria-hidden\n as=\"span\"\n className={cn(\n textClasses,\n 'min-w-0 flex-1 truncate',\n summary ? 'text-primary' : 'text-placeholder'\n )}\n >\n {summary ?? placeholder ?? 'No file selected'}\n </Text>\n <Text\n aria-hidden\n as=\"span\"\n weight=\"medium\"\n className={cn(textClasses, 'shrink-0 text-secondary')}\n >\n Browse\n </Text>\n </>\n );\n}\n\nexport const Input = forwardRef<\n HTMLInputElement,\n InputProps &\n Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof InputProps>\n>(\n (\n {\n size = 'lg',\n variant = 'outlined',\n leftIcon,\n rightIcon,\n leftAction,\n rightAction,\n leftDecorator,\n rightDecorator,\n disabled = false,\n isError = false,\n label,\n hintText,\n value,\n onChange,\n placeholder,\n type = 'text',\n debounceMs = 0,\n className,\n inputContainerClassName,\n id,\n name,\n required = false,\n autoFocus = false,\n accept,\n multiple,\n 'aria-describedby': ariaDescribedBy,\n ...rest\n },\n ref\n ) => {\n const generatedId = useId();\n const inputId = id || generatedId;\n const hintTextId = `${inputId}-hint`;\n const describedBy =\n [hintText ? hintTextId : undefined, ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined;\n const shouldDebounce = debounceMs > 0;\n const isFileInput = type === 'file';\n const isPasswordInput = type === 'password';\n const isDateInput = type === 'date' || type === 'datetime-local';\n const [internalValue, setInternalValue] = useState(value);\n const [isPasswordVisible, setIsPasswordVisible] = useState(false);\n const [selectedFileNames, setSelectedFileNames] = useState<string[]>([]);\n const debouncedOnChange = useDebouncedCallback(onChange, debounceMs);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (!shouldDebounce) return;\n return () => debouncedOnChange.flush();\n }, [shouldDebounce, debouncedOnChange]);\n\n // Skip the click forwarded below, which would otherwise re-enter here.\n const openFilePicker = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n disabled ||\n (target instanceof Element &&\n target.closest(\n 'button, a, input, select, textarea, summary, [role=\"button\"], [role=\"link\"], [contenteditable=\"true\"]'\n ))\n ) {\n return;\n }\n fileInputRef.current?.click();\n };\n\n useEffect(() => {\n if (shouldDebounce) setInternalValue(value);\n }, [shouldDebounce, value]);\n\n useEffect(() => {\n if (!isPasswordInput) {\n setIsPasswordVisible(false);\n }\n }, [isPasswordInput]);\n\n useEffect(() => {\n const form = isFileInput ? fileInputRef.current?.form : null;\n if (!form) return;\n\n const clearFileSelection = () => setSelectedFileNames([]);\n form.addEventListener('reset', clearFileSelection);\n return () => form.removeEventListener('reset', clearFileSelection);\n }, [isFileInput]);\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n if (isFileInput) {\n onChange(newValue, e);\n setSelectedFileNames(\n Array.from(e.target.files ?? []).map((file) => file.name)\n );\n return;\n }\n\n if (shouldDebounce) {\n setInternalValue(newValue);\n debouncedOnChange(newValue);\n } else {\n onChange(newValue, e);\n }\n };\n\n const inputContainerClasses = getInputContainerClasses({\n size,\n variant,\n isError,\n disabled,\n className: inputContainerClassName,\n });\n\n const inputClasses = isFileInput\n ? 'sr-only'\n : getInputElementClasses({\n size,\n disabled,\n className: cn(\n isPasswordInput && !isPasswordVisible && 'text-security',\n isDateInput && [\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:size-[var(--control-icon-size)]',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:m-0',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:p-0',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:opacity-0',\n ]\n ),\n });\n\n const effectiveLeftIcon =\n leftIcon ?? (isFileInput ? PaperclipIcon : undefined);\n const hasCustomLeftDecorator = leftDecorator != null;\n const hasCustomRightDecorator = rightDecorator != null;\n const effectiveLeftDecorator =\n leftDecorator ??\n (effectiveLeftIcon || leftAction ? (\n <InputIconSlot\n icon={effectiveLeftIcon}\n action={leftAction}\n size={size}\n disabled={disabled}\n />\n ) : null);\n const rightContent =\n rightDecorator ??\n (rightIcon || rightAction ? (\n <InputIconSlot\n icon={rightIcon}\n action={rightAction}\n size={size}\n disabled={disabled}\n />\n ) : null);\n // Offset only known edge buttons by their glyph inset, including the border.\n const leftActionOffset =\n !hasCustomLeftDecorator && leftAction\n ? CONTROL_ICON_SIZES[size].actionOffset\n : undefined;\n const rightActionOffset =\n isPasswordInput || (!hasCustomRightDecorator && rightAction)\n ? CONTROL_ICON_SIZES[size].actionOffset\n : undefined;\n const effectiveRightDecorator =\n rightContent || isPasswordInput ? (\n <>\n {rightContent}\n {isPasswordInput && (\n <InputIconSlot\n size={size}\n disabled={disabled}\n action={{\n icon: isPasswordVisible ? EyeSlashIcon : EyeIcon,\n label: 'toggle password visibility',\n tooltipProps: { disabled: true },\n onClick: () => setIsPasswordVisible((show) => !show),\n }}\n />\n )}\n </>\n ) : null;\n\n const nativeInput = (\n // eslint-disable-next-line react/forbid-elements\n <input\n ref={isFileInput ? mergeRefs([fileInputRef, ref]) : ref}\n id={inputId}\n name={name ?? (typeof label === 'string' ? label : undefined)}\n type={\n isPasswordInput ? (isPasswordVisible ? 'text' : 'password') : type\n }\n value={\n isFileInput\n ? undefined\n : shouldDebounce\n ? (internalValue ?? '')\n : value === null\n ? ''\n : value\n }\n onChange={handleInputChange}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoFocus={autoFocus}\n accept={accept}\n multiple={multiple}\n aria-describedby={describedBy}\n aria-invalid={isError || undefined}\n className={inputClasses}\n {...rest}\n />\n );\n\n return (\n <div className={cn('w-full', className)}>\n {label && (\n <Text\n as=\"label\"\n htmlFor={inputId}\n className={cn(\n 'mb-space-1 block text-sm font-medium text-primary',\n disabled && 'text-disabled'\n )}\n variant=\"xs\"\n >\n {label}\n {required && (\n <span className=\"ml-space-1 text-error-secondary\">*</span>\n )}\n </Text>\n )}\n\n <div\n className={cn(\n inputContainerClasses,\n isFileInput && !disabled && 'cursor-pointer'\n )}\n onClick={isFileInput ? openFilePicker : undefined}\n >\n {effectiveLeftDecorator && (\n <div\n className={DECORATOR_CLASSES}\n style={{ marginInlineStart: leftActionOffset }}\n >\n {effectiveLeftDecorator}\n </div>\n )}\n\n {isFileInput && (\n <FileSelection\n size={size}\n fileNames={selectedFileNames}\n placeholder={placeholder}\n />\n )}\n\n {isDateInput ? (\n <div\n className={cn(\n 'relative flex min-w-0 flex-1 items-center',\n CONTROL_ICON_SIZES[size].sizeVariableClassName\n )}\n >\n {nativeInput}\n {/* The native picker target stays interactive beneath this glyph. */}\n <span className=\"pointer-events-none absolute inset-y-0 end-0 hidden items-center supports-[selector(input::-webkit-calendar-picker-indicator)]:flex\">\n <InputIconSlot\n icon={CalendarBlankIcon}\n size={size}\n disabled={disabled}\n />\n </span>\n </div>\n ) : (\n nativeInput\n )}\n\n {effectiveRightDecorator && (\n <div\n className={cn(DECORATOR_CLASSES, 'gap-space-1')}\n style={{ marginInlineEnd: rightActionOffset }}\n >\n {effectiveRightDecorator}\n </div>\n )}\n </div>\n\n {hintText && (\n <Text\n id={hintTextId}\n className={cn(\n 'mt-space-1 text-xs',\n isError ? 'text-error-secondary' : 'text-tertiary'\n )}\n variant=\"xs\"\n weight=\"normal\"\n >\n {hintText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;;;;;;;;;;;AA4GA,SAAS,cAAc,EACrB,MACA,QACA,MACA,YAMC;CACD,MAAM,aAAa,YAAY,QAAQ;CACvC,MAAM,iBAAiB,aACnB,uBACA;CAEJ,OAAO,SACL,oBAAC,YAAD;EACE,GAAI;EACJ,OAAM;EACN,SAAQ;EACR,MAAM,mBAAmB,KAAK,CAAC;EAC/B,WAAW;EACX,YAAW;EACX,UAAU;EACV,cAAc,UAAU,MAAM,eAAe;CAC9C,CAAA,IACC,OACF,oBAAC,MAAD;EACE,eAAA;EACM;EACN,eAAe,mBAAmB,KAAK,CAAC;EACxC,WAAW;EACX,QAAO;CACR,CAAA,IACC;AACN;AAEA,SAAS,cAAc,EACrB,MACA,WACA,eAKC;CACD,MAAM,UACJ,UAAU,SAAS,IAAI,GAAG,UAAU,OAAO,mBAAmB,UAAU;CAC1E,MAAM,cAAc,mBAAmB;CAEvC,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,MAAD;EACE,eAAA;EACA,IAAG;EACH,WAAW,GACT,aACA,2BACA,UAAU,iBAAiB,kBAC7B;EAEC,UAAA,WAAW,eAAe;CACvB,CAAA,GACN,oBAAC,MAAD;EACE,eAAA;EACA,I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C,QAAD;OAAM,WAAU;OACd,UAAA,oBAAC,eAAD;QACE,MAAM;QACA;QACI;OACX,CAAA;MACG,CAAA,CACH;KAEL,CAAA,IAAA;KAGD,2BACC,oBAAC,OAAD;MACE,WAAW,GAAA,mCAAsB,aAAa;MAC9C,OAAO,EAAE,iBAAiB,kBAAkB;MAE3C,UAAA;KACE,CAAA;IAEJ;;GAEJ,YACC,oBAAC,MAAD;IACE,IAAI;IACJ,WAAW,GACT,sBACA,UAAU,yBAAyB,eACrC;IACA,SAAQ;IACR,QAAO;IAEN,UAAA;GACG,CAAA;EAEL;;AAET,CACF;AAEA,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"Input.js","names":[],"sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\nimport { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { useDebouncedCallback } from 'use-debounce';\n\nimport { CalendarBlankIcon } from '@phosphor-icons/react/dist/ssr/CalendarBlank';\nimport { EyeIcon } from '@phosphor-icons/react/dist/ssr/Eye';\nimport { EyeSlashIcon } from '@phosphor-icons/react/dist/ssr/EyeSlash';\nimport { PaperclipIcon } from '@phosphor-icons/react/dist/ssr/Paperclip';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport type { IconComponent } from '../../utils/icon-types';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n INPUT_TEXT_CLASSES,\n} from './inputStyles';\nimport type { InputSize } from './inputStyles';\n\nexport type InputIconAction = Pick<\n ComponentProps<typeof IconButton>,\n 'icon' | 'label' | 'disabled' | 'tooltipProps'\n> & {\n onClick: NonNullable<ComponentProps<typeof IconButton>['onClick']>;\n};\n\nexport interface InputProps {\n /** Exact outer height. The default lg tier preserves the legacy 40px field. */\n size?: InputSize;\n variant?: 'outlined' | 'plain';\n /** Decorative icon. Input owns its size and color. */\n leftIcon?: IconComponent;\n /** Decorative icon. Input owns its size and color. */\n rightIcon?: IconComponent;\n /** Plain icon button. Takes precedence over leftIcon. */\n leftAction?: InputIconAction;\n /** Plain icon button. Takes precedence over rightIcon; precedes the password toggle. */\n rightAction?: InputIconAction;\n /** Custom content; overrides leftIcon/leftAction and the default file icon. */\n leftDecorator?: ReactNode;\n /** Custom content; overrides rightIcon/rightAction. The password toggle remains last. */\n rightDecorator?: ReactNode;\n /** Whether the input is disabled */\n disabled?: boolean;\n /** Whether the input has an error state */\n isError?: boolean;\n /** Label text displayed above the input */\n label?: string | ReactNode;\n /** Hint text displayed below the input */\n hintText?: string;\n /** Current input value */\n value?: string | null;\n /** Change handler that will be debounced */\n onChange: (\n value: string,\n event?: React.ChangeEvent<HTMLInputElement>\n ) => void;\n /** Placeholder text */\n placeholder?: string;\n /**\n * Input type. Limited to the \"text-like\" native types that share this\n * component's styled-text rendering and string value contract. `password`\n * renders a masked secret field with a show/hide toggle. `date` uses the\n * browser's native date picker; its value is a `YYYY-MM-DD` string.\n * `datetime-local` uses the native date+time picker; its value is a\n * `YYYY-MM-DDTHH:mm` string in the viewer's local time. `file` is\n * uncontrolled: read the selection from `event.target.files` on the change\n * event, and scope it with `accept`/`multiple`.\n */\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'number'\n | 'url'\n | 'date'\n | 'datetime-local'\n | 'file';\n /** Debounce delay in milliseconds (default: 300). Ignored for `type=\"file\"`. */\n debounceMs?: number;\n /** Additional CSS classes */\n className?: string;\n /** Input ID for accessibility */\n id?: string;\n /** Input name for forms */\n name?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Auto focus on mount */\n autoFocus?: boolean;\n /** CSS class for the input container */\n inputContainerClassName?: string;\n /**\n * Which files the picker offers, as a comma-separated list of extensions or\n * MIME types (`'.csv,.json'`, `'image/*'`). `type=\"file\"` only. The browser\n * treats this as a filter, not a guarantee — validate the selection too.\n */\n accept?: string;\n /** Whether more than one file can be picked. `type=\"file\"` only. */\n multiple?: boolean;\n}\n\nfunction InputIconSlot({\n icon,\n action,\n size,\n disabled,\n}: {\n icon?: IconComponent;\n action?: InputIconAction;\n size: InputSize;\n disabled: boolean;\n}) {\n const isDisabled = disabled || action?.disabled;\n const colorClassName = isDisabled\n ? 'text-icon-disabled'\n : 'text-icon-secondary';\n\n return action ? (\n <IconButton\n {...action}\n color=\"secondary\"\n variant=\"plain\"\n size={CONTROL_ICON_SIZES[size].buttonSize}\n className={colorClassName}\n iconWeight=\"regular\"\n disabled={isDisabled}\n onMouseDown={(event) => event.preventDefault()}\n />\n ) : icon ? (\n <Icon\n aria-hidden\n icon={icon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={colorClassName}\n weight=\"regular\"\n />\n ) : null;\n}\n\nfunction FileSelection({\n size,\n fileNames,\n placeholder,\n disabled,\n}: {\n size: InputSize;\n fileNames: string[];\n placeholder?: string;\n disabled: boolean;\n}) {\n const summary =\n fileNames.length > 1 ? `${fileNames.length} files selected` : fileNames[0];\n const textClasses = INPUT_TEXT_CLASSES[size];\n\n return (\n <>\n <Text\n aria-hidden\n as=\"span\"\n className={cn(\n textClasses,\n 'min-w-0 flex-1 truncate',\n summary ? 'text-primary' : 'text-placeholder',\n disabled && 'text-disabled'\n )}\n >\n {summary ?? placeholder ?? 'No file selected'}\n </Text>\n <Text\n aria-hidden\n as=\"span\"\n weight=\"medium\"\n className={cn(\n textClasses,\n 'shrink-0 text-secondary',\n disabled && 'text-disabled'\n )}\n >\n Browse\n </Text>\n </>\n );\n}\n\nexport const Input = forwardRef<\n HTMLInputElement,\n InputProps &\n Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof InputProps>\n>(\n (\n {\n size = 'lg',\n variant = 'outlined',\n leftIcon,\n rightIcon,\n leftAction,\n rightAction,\n leftDecorator,\n rightDecorator,\n disabled = false,\n isError = false,\n label,\n hintText,\n value,\n onChange,\n placeholder,\n type = 'text',\n debounceMs = 0,\n className,\n inputContainerClassName,\n id,\n name,\n required = false,\n autoFocus = false,\n accept,\n multiple,\n 'aria-describedby': ariaDescribedBy,\n ...rest\n },\n ref\n ) => {\n const generatedId = useId();\n const inputId = id || generatedId;\n const hintTextId = `${inputId}-hint`;\n const describedBy =\n [hintText ? hintTextId : undefined, ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined;\n const shouldDebounce = debounceMs > 0;\n const isFileInput = type === 'file';\n const isPasswordInput = type === 'password';\n const isDateInput = type === 'date' || type === 'datetime-local';\n const [internalValue, setInternalValue] = useState(value);\n const [isPasswordVisible, setIsPasswordVisible] = useState(false);\n const [selectedFileNames, setSelectedFileNames] = useState<string[]>([]);\n const debouncedOnChange = useDebouncedCallback(onChange, debounceMs);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (!shouldDebounce) return;\n return () => debouncedOnChange.flush();\n }, [shouldDebounce, debouncedOnChange]);\n\n // Skip the click forwarded below, which would otherwise re-enter here.\n const openFilePicker = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n disabled ||\n (target instanceof Element &&\n target.closest(\n 'button, a, input, select, textarea, summary, [role=\"button\"], [role=\"link\"], [contenteditable=\"true\"]'\n ))\n ) {\n return;\n }\n fileInputRef.current?.click();\n };\n\n useEffect(() => {\n if (shouldDebounce) setInternalValue(value);\n }, [shouldDebounce, value]);\n\n useEffect(() => {\n if (!isPasswordInput) {\n setIsPasswordVisible(false);\n }\n }, [isPasswordInput]);\n\n useEffect(() => {\n const form = isFileInput ? fileInputRef.current?.form : null;\n if (!form) return;\n\n const clearFileSelection = () => setSelectedFileNames([]);\n form.addEventListener('reset', clearFileSelection);\n return () => form.removeEventListener('reset', clearFileSelection);\n }, [isFileInput]);\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n if (isFileInput) {\n onChange(newValue, e);\n setSelectedFileNames(\n Array.from(e.target.files ?? []).map((file) => file.name)\n );\n return;\n }\n\n if (shouldDebounce) {\n setInternalValue(newValue);\n debouncedOnChange(newValue);\n } else {\n onChange(newValue, e);\n }\n };\n\n const inputContainerClasses = getInputContainerClasses({\n size,\n variant,\n isError,\n disabled,\n className: inputContainerClassName,\n });\n\n const inputClasses = isFileInput\n ? 'sr-only'\n : getInputElementClasses({\n size,\n disabled,\n className: cn(\n isPasswordInput && !isPasswordVisible && 'text-security',\n isDateInput && [\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:size-[var(--control-icon-size)]',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:m-0',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:p-0',\n 'supports-[selector(input::-webkit-calendar-picker-indicator)]:[&::-webkit-calendar-picker-indicator]:opacity-0',\n ]\n ),\n });\n\n const effectiveLeftIcon =\n leftIcon ?? (isFileInput ? PaperclipIcon : undefined);\n const hasCustomLeftDecorator = leftDecorator != null;\n const hasCustomRightDecorator = rightDecorator != null;\n const effectiveLeftDecorator =\n leftDecorator ??\n (effectiveLeftIcon || leftAction ? (\n <InputIconSlot\n icon={effectiveLeftIcon}\n action={leftAction}\n size={size}\n disabled={disabled}\n />\n ) : null);\n const rightContent =\n rightDecorator ??\n (rightIcon || rightAction ? (\n <InputIconSlot\n icon={rightIcon}\n action={rightAction}\n size={size}\n disabled={disabled}\n />\n ) : null);\n // Offset only known edge buttons by their glyph inset, including the border.\n const leftActionOffset =\n !hasCustomLeftDecorator && leftAction\n ? CONTROL_ICON_SIZES[size].actionOffset\n : undefined;\n const rightActionOffset =\n isPasswordInput || (!hasCustomRightDecorator && rightAction)\n ? CONTROL_ICON_SIZES[size].actionOffset\n : undefined;\n const effectiveRightDecorator =\n rightContent || isPasswordInput ? (\n <>\n {rightContent}\n {isPasswordInput && (\n <InputIconSlot\n size={size}\n disabled={disabled}\n action={{\n icon: isPasswordVisible ? EyeSlashIcon : EyeIcon,\n label: 'toggle password visibility',\n tooltipProps: { disabled: true },\n onClick: () => setIsPasswordVisible((show) => !show),\n }}\n />\n )}\n </>\n ) : null;\n\n const nativeInput = (\n // eslint-disable-next-line react/forbid-elements\n <input\n ref={isFileInput ? mergeRefs([fileInputRef, ref]) : ref}\n id={inputId}\n name={name ?? (typeof label === 'string' ? label : undefined)}\n type={\n isPasswordInput ? (isPasswordVisible ? 'text' : 'password') : type\n }\n value={\n isFileInput\n ? undefined\n : shouldDebounce\n ? (internalValue ?? '')\n : value === null\n ? ''\n : value\n }\n onChange={handleInputChange}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoFocus={autoFocus}\n accept={accept}\n multiple={multiple}\n aria-describedby={describedBy}\n aria-invalid={isError || undefined}\n className={inputClasses}\n {...rest}\n />\n );\n\n return (\n <div className={cn('w-full', className)}>\n {label && (\n <Text\n as=\"label\"\n htmlFor={inputId}\n className={cn(\n 'mb-space-1 block text-sm font-medium text-primary',\n disabled && 'text-disabled'\n )}\n variant=\"xs\"\n >\n {label}\n {required && (\n <span className=\"ml-space-1 text-error-secondary\">*</span>\n )}\n </Text>\n )}\n\n <div\n className={cn(\n inputContainerClasses,\n isFileInput && !disabled && 'cursor-pointer'\n )}\n onClick={isFileInput ? openFilePicker : undefined}\n >\n {effectiveLeftDecorator && (\n <div\n className={cn(DECORATOR_CLASSES, disabled && 'text-disabled')}\n style={{ marginInlineStart: leftActionOffset }}\n >\n {effectiveLeftDecorator}\n </div>\n )}\n\n {isFileInput && (\n <FileSelection\n size={size}\n fileNames={selectedFileNames}\n placeholder={placeholder}\n disabled={disabled}\n />\n )}\n\n {isDateInput ? (\n <div\n className={cn(\n 'relative flex min-w-0 flex-1 items-center',\n CONTROL_ICON_SIZES[size].sizeVariableClassName\n )}\n >\n {nativeInput}\n {/* The native picker target stays interactive beneath this glyph. */}\n <span className=\"pointer-events-none absolute inset-y-0 end-0 hidden items-center supports-[selector(input::-webkit-calendar-picker-indicator)]:flex\">\n <InputIconSlot\n icon={CalendarBlankIcon}\n size={size}\n disabled={disabled}\n />\n </span>\n </div>\n ) : (\n nativeInput\n )}\n\n {effectiveRightDecorator && (\n <div\n className={cn(\n DECORATOR_CLASSES,\n 'gap-space-1',\n disabled && 'text-disabled'\n )}\n style={{ marginInlineEnd: rightActionOffset }}\n >\n {effectiveRightDecorator}\n </div>\n )}\n </div>\n\n {hintText && (\n <Text\n id={hintTextId}\n className={cn(\n 'mt-space-1 text-xs',\n isError ? 'text-error-secondary' : 'text-tertiary'\n )}\n variant=\"xs\"\n weight=\"normal\"\n >\n {hintText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;;;;;;;;;;;AA4GA,SAAS,cAAc,EACrB,MACA,QACA,MACA,YAMC;CACD,MAAM,aAAa,YAAY,QAAQ;CACvC,MAAM,iBAAiB,aACnB,uBACA;CAEJ,OAAO,SACL,oBAAC,YAAD;EACE,GAAI;EACJ,OAAM;EACN,SAAQ;EACR,MAAM,mBAAmB,KAAK,CAAC;EAC/B,WAAW;EACX,YAAW;EACX,UAAU;EACV,cAAc,UAAU,MAAM,eAAe;CAC9C,CAAA,IACC,OACF,oBAAC,MAAD;EACE,eAAA;EACM;EACN,eAAe,mBAAmB,KAAK,CAAC;EACxC,WAAW;EACX,QAAO;CACR,CAAA,IACC;AACN;AAEA,SAAS,cAAc,EACrB,MACA,WACA,aACA,YAMC;CACD,MAAM,UACJ,UAAU,SAAS,IAAI,GAAG,UAAU,OAAO,mBAAmB,UAAU;CAC1E,MAAM,cAAc,mBAAmB;CAEvC,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,MAAD;EACE,eAAA;EACA,IAAG;EACH,WAAW,GACT,aACA,2BACA,UAAU,iBAAiB,oBAC3B,YAAY,eACd;EAEC,UAAA,WAAW,eAAe;CACvB,CAAA,GACN,oBAAC,MAAD;EACE,eAAA;EACA,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AC,qBAC3B;MAJF,UAAA,CAMG,aAED,oBAAC,QAAD;OAAM,WAAU;OACd,UAAA,oBAAC,eAAD;QACE,MAAM;QACA;QACI;OACX,CAAA;MACG,CAAA,CACH;KAEL,CAAA,IAAA;KAGD,2BACC,oBAAC,OAAD;MACE,WAAW,GAAA,mCAET,eACA,YAAY,eACd;MACA,OAAO,EAAE,iBAAiB,kBAAkB;MAE3C,UAAA;KACE,CAAA;IAEJ;;GAEJ,YACC,oBAAC,MAAD;IACE,IAAI;IACJ,WAAW,GACT,sBACA,UAAU,yBAAyB,eACrC;IACA,SAAQ;IACR,QAAO;IAEN,UAAA;GACG,CAAA;EAEL;;AAET,CACF;AAEA,MAAM,cAAc"}
|
|
@@ -26,16 +26,16 @@ var INPUT_TEXT_CLASSES = {
|
|
|
26
26
|
function getInputContainerClasses({ size, variant, isError = false, disabled = false, className }) {
|
|
27
27
|
const outlined = variant === "outlined";
|
|
28
28
|
return cn("box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]", CONTROL_SIZES[size].heightClassName, INPUT_HORIZONTAL_PADDING_CLASSES[size], INPUT_RADIUS_CLASSES[size], "focus-within:outline-hidden", {
|
|
29
|
-
"border border-
|
|
30
|
-
"border border-transparent bg-
|
|
31
|
-
}, outlined && !disabled && !isError && "[&:hover:not(:focus-within)]:border-
|
|
29
|
+
"border border-muted bg-input": variant === "outlined",
|
|
30
|
+
"border border-transparent bg-input": variant === "plain"
|
|
31
|
+
}, outlined && !disabled && !isError && "[&:hover:not(:focus-within)]:border-subtle", !disabled && !isError && (outlined ? "focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]" : "focus-within:border-focus"), !disabled && isError && (outlined ? "border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]" : "border-error-strong focus-within:border-error-strong"), disabled && "cursor-not-allowed border-muted bg-input-disabled text-disabled", className);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Shared styling for the inner input element (unstyled, fills container).
|
|
35
35
|
* Used by both the design system Input and CommandInput.
|
|
36
36
|
*/
|
|
37
37
|
function getInputElementClasses({ size, disabled = false, className }) {
|
|
38
|
-
return cn("min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-hidden", INPUT_TEXT_CLASSES[size], "placeholder:text-placeholder", disabled && "cursor-not-allowed", className);
|
|
38
|
+
return cn("min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-hidden", INPUT_TEXT_CLASSES[size], "placeholder:text-placeholder", disabled && "cursor-not-allowed text-disabled placeholder:text-disabled", className);
|
|
39
39
|
}
|
|
40
40
|
/** Shared styling for decorator wrappers. */
|
|
41
41
|
var DECORATOR_CLASSES = "flex items-center text-tertiary";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputStyles.js","names":[],"sources":["../../../src/components/Input/inputStyles.ts"],"sourcesContent":["import { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\n\nexport type InputSize = ControlSize;\nexport type InputVariant = 'outlined' | 'plain';\n\nexport const INPUT_HORIZONTAL_PADDING_CLASSES: Record<InputSize, string> = {\n xs: 'px-space-1',\n sm: 'px-space-2',\n md: 'px-space-3',\n lg: 'px-space-3',\n};\n\nexport const INPUT_RADIUS_CLASSES: Record<InputSize, string> = {\n xs: 'rounded-xs',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-md',\n};\n\nexport const INPUT_TEXT_CLASSES: Record<InputSize, string> = {\n xs: 'text-xxs leading-[1.15]',\n sm: 'text-xs',\n md: 'text-sm leading-normal',\n lg: 'text-sm leading-normal',\n};\n\n/**\n * Shared styling for input containers (border, padding, rounding, variant).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputContainerClasses({\n size,\n variant,\n isError = false,\n disabled = false,\n className,\n}: {\n size: InputSize;\n variant: InputVariant;\n isError?: boolean;\n disabled?: boolean;\n className?: string;\n}) {\n const outlined = variant === 'outlined';\n return cn(\n 'box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].heightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n 'focus-within:outline-hidden',\n {\n 'border border-
|
|
1
|
+
{"version":3,"file":"inputStyles.js","names":[],"sources":["../../../src/components/Input/inputStyles.ts"],"sourcesContent":["import { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\n\nexport type InputSize = ControlSize;\nexport type InputVariant = 'outlined' | 'plain';\n\nexport const INPUT_HORIZONTAL_PADDING_CLASSES: Record<InputSize, string> = {\n xs: 'px-space-1',\n sm: 'px-space-2',\n md: 'px-space-3',\n lg: 'px-space-3',\n};\n\nexport const INPUT_RADIUS_CLASSES: Record<InputSize, string> = {\n xs: 'rounded-xs',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-md',\n};\n\nexport const INPUT_TEXT_CLASSES: Record<InputSize, string> = {\n xs: 'text-xxs leading-[1.15]',\n sm: 'text-xs',\n md: 'text-sm leading-normal',\n lg: 'text-sm leading-normal',\n};\n\n/**\n * Shared styling for input containers (border, padding, rounding, variant).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputContainerClasses({\n size,\n variant,\n isError = false,\n disabled = false,\n className,\n}: {\n size: InputSize;\n variant: InputVariant;\n isError?: boolean;\n disabled?: boolean;\n className?: string;\n}) {\n const outlined = variant === 'outlined';\n return cn(\n 'box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].heightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n 'focus-within:outline-hidden',\n {\n 'border border-muted bg-input': variant === 'outlined',\n 'border border-transparent bg-input': variant === 'plain',\n },\n outlined &&\n !disabled &&\n !isError &&\n '[&:hover:not(:focus-within)]:border-subtle',\n !disabled &&\n !isError &&\n (outlined\n ? 'focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]'\n : 'focus-within:border-focus'),\n !disabled &&\n isError &&\n (outlined\n ? 'border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]'\n : 'border-error-strong focus-within:border-error-strong'),\n disabled &&\n 'cursor-not-allowed border-muted bg-input-disabled text-disabled',\n className\n );\n}\n\n/**\n * Shared styling for the inner input element (unstyled, fills container).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputElementClasses({\n size,\n disabled = false,\n className,\n}: {\n size: InputSize;\n disabled?: boolean;\n className?: string;\n}) {\n return cn(\n 'min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-hidden',\n INPUT_TEXT_CLASSES[size],\n 'placeholder:text-placeholder',\n disabled && 'cursor-not-allowed text-disabled placeholder:text-disabled',\n className\n );\n}\n\n/** Shared styling for decorator wrappers. */\nexport const DECORATOR_CLASSES = 'flex items-center text-tertiary';\n"],"mappings":";;;AAMA,IAAa,mCAA8D;CACzE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,uBAAkD;CAC7D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,qBAAgD;CAC3D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;;;;;AAMA,SAAgB,yBAAyB,EACvC,MACA,SACA,UAAU,OACV,WAAW,OACX,aAOC;CACD,MAAM,WAAW,YAAY;CAC7B,OAAO,GACL,yGACA,cAAc,KAAK,CAAC,iBACpB,iCAAiC,OACjC,qBAAqB,OACrB,+BACA;EACE,gCAAgC,YAAY;EAC5C,sCAAsC,YAAY;CACpD,GACA,YACE,CAAC,YACD,CAAC,WACD,8CACF,CAAC,YACC,CAAC,YACA,WACG,kFACA,8BACN,CAAC,YACC,YACC,WACG,oHACA,yDACN,YACE,mEACF,SACF;AACF;;;;;AAMA,SAAgB,uBAAuB,EACrC,MACA,WAAW,OACX,aAKC;CACD,OAAO,GACL,2EACA,mBAAmB,OACnB,gCACA,YAAY,8DACZ,SACF;AACF;;AAGA,IAAa,oBAAoB"}
|
|
@@ -9,16 +9,16 @@ var TextContent = (children, leftDecorator, rightDecorator, iconWeight) => {
|
|
|
9
9
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
10
10
|
LeftIcon && /* @__PURE__ */ jsx(LeftIcon, {
|
|
11
11
|
"aria-hidden": true,
|
|
12
|
-
className: "h-[1em] w-[1em] flex-shrink-0 text-link dark:text-
|
|
12
|
+
className: "h-[1em] w-[1em] flex-shrink-0 text-link dark:text-link dark:group-hover:text-link-hover",
|
|
13
13
|
weight: iconWeight
|
|
14
14
|
}),
|
|
15
15
|
/* @__PURE__ */ jsx("span", {
|
|
16
|
-
className: "text-link underline-offset-2 hover:text-link-hover hover:underline hover:decoration-ls-neutral-300 hover:decoration-1 dark:text-
|
|
16
|
+
className: "text-link underline-offset-2 hover:text-link-hover hover:underline hover:decoration-ls-neutral-300 hover:decoration-1 dark:text-link dark:hover:text-link-hover dark:hover:decoration-ls-neutral-400",
|
|
17
17
|
children
|
|
18
18
|
}),
|
|
19
19
|
RightIcon && /* @__PURE__ */ jsx(RightIcon, {
|
|
20
20
|
"aria-hidden": true,
|
|
21
|
-
className: "h-[1em] w-[1em] flex-shrink-0 text-link dark:text-
|
|
21
|
+
className: "h-[1em] w-[1em] flex-shrink-0 text-link dark:text-link dark:group-hover:text-link-hover",
|
|
22
22
|
weight: iconWeight
|
|
23
23
|
})
|
|
24
24
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":[],"sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n type AnchorHTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { cn } from '../../utils/cn';\nimport type { IconComponent, IconWeight } from '../../utils/icon-types';\nimport { textVariantClasses } from '../Text';\nimport type { TextProps } from '../Text';\n\ntype LinkRenderElement = ReactElement<{\n children?: ReactNode;\n className?: string;\n [key: string]: unknown;\n}>;\n\ntype LinkProps = {\n /** Typography size — mirrors <Text> styles */\n variant?: TextProps['variant'];\n leftDecorator?: IconComponent;\n rightDecorator?: IconComponent;\n /** Phosphor weight used for decorator icons. */\n iconWeight?: IconWeight;\n} & (\n
|
|
1
|
+
{"version":3,"file":"Link.js","names":[],"sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n type AnchorHTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { cn } from '../../utils/cn';\nimport type { IconComponent, IconWeight } from '../../utils/icon-types';\nimport { textVariantClasses } from '../Text';\nimport type { TextProps } from '../Text';\n\ntype LinkRenderElement = ReactElement<{\n children?: ReactNode;\n className?: string;\n [key: string]: unknown;\n}>;\n\ntype LinkProps = {\n /** Typography size — mirrors <Text> styles */\n variant?: TextProps['variant'];\n leftDecorator?: IconComponent;\n rightDecorator?: IconComponent;\n /** Phosphor weight used for decorator icons. */\n iconWeight?: IconWeight;\n} & (\n | (AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** Render a native anchor with this URL. */\n href: string;\n as?: never;\n })\n | (Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {\n /**\n * Render link styling through a routing framework's anchor component.\n * For example: `as={<RouterLink to=\"/runs\" />}`.\n */\n as: LinkRenderElement;\n href?: never;\n })\n );\n\nconst TextContent = (\n children: React.ReactNode,\n leftDecorator: IconComponent | undefined,\n rightDecorator: IconComponent | undefined,\n iconWeight: IconWeight | undefined\n) => {\n const LeftIcon = leftDecorator;\n const RightIcon = rightDecorator;\n return (\n <>\n {LeftIcon && (\n <LeftIcon\n aria-hidden\n className=\"h-[1em] w-[1em] flex-shrink-0 text-link dark:text-link dark:group-hover:text-link-hover\"\n weight={iconWeight}\n />\n )}\n <span className=\"text-link underline-offset-2 hover:text-link-hover hover:underline hover:decoration-ls-neutral-300 hover:decoration-1 dark:text-link dark:hover:text-link-hover dark:hover:decoration-ls-neutral-400\">\n {children}\n </span>\n {RightIcon && (\n <RightIcon\n aria-hidden\n className=\"h-[1em] w-[1em] flex-shrink-0 text-link dark:text-link dark:group-hover:text-link-hover\"\n weight={iconWeight}\n />\n )}\n </>\n );\n};\n\nconst Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n {\n variant = 'body',\n leftDecorator,\n rightDecorator,\n iconWeight,\n className,\n children,\n as,\n ...props\n },\n ref\n ) => {\n const containerClass = cn(\n 'group inline-flex items-center gap-[2px]',\n textVariantClasses[variant],\n className\n );\n\n const content = TextContent(\n children,\n leftDecorator,\n rightDecorator,\n iconWeight\n );\n\n if (as) {\n if (!isValidElement(as)) return null;\n\n return cloneElement(as, {\n ...props,\n ref,\n className: cn(as.props.className, containerClass),\n children: content,\n });\n }\n\n const { href, ...anchorProps } = props;\n return (\n // eslint-disable-next-line react/forbid-elements\n <a ref={ref} href={href} className={containerClass} {...anchorProps}>\n {content}\n </a>\n );\n }\n);\n\nLink.displayName = 'Link';\n\nexport { Link };\nexport type { LinkProps };\n"],"mappings":";;;;;AA2CA,IAAM,eACJ,UACA,eACA,gBACA,eACG;CACH,MAAM,WAAW;CACjB,MAAM,YAAY;CAClB,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,YACC,oBAAC,UAAD;GACE,eAAA;GACA,WAAU;GACV,QAAQ;EACT,CAAA;EAEH,oBAAC,QAAD;GAAM,WAAU;GACb;EACG,CAAA;EACL,aACC,oBAAC,WAAD;GACE,eAAA;GACA,WAAU;GACV,QAAQ;EACT,CAAA;CAEH,EAAA,CAAA;AAEN;AAEA,IAAM,OAAO,YAET,EACE,UAAU,QACV,eACA,gBACA,YACA,WACA,UACA,IACA,GAAG,SAEL,QACG;CACH,MAAM,iBAAiB,GACrB,4CACA,mBAAmB,UACnB,SACF;CAEA,MAAM,UAAU,YACd,UACA,eACA,gBACA,UACF;CAEA,IAAI,IAAI;EACN,IAAI,CAAC,eAAe,EAAE,GAAG,OAAO;EAEhC,OAAO,aAAa,IAAI;GACtB,GAAG;GACH;GACA,WAAW,GAAG,GAAG,MAAM,WAAW,cAAc;GAChD,UAAU;EACZ,CAAC;CACH;CAEA,MAAM,EAAE,MAAM,GAAG,gBAAgB;CACjC,OAEE,oBAAC,KAAD;EAAQ;EAAW;EAAM,WAAW;EAAgB,GAAI;EACrD,UAAA;CACA,CAAA;AAEP,CACF;AAEA,KAAK,cAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
3
|
+
interface CorePaneProps extends DataAttributes {
|
|
3
4
|
open: boolean;
|
|
4
5
|
animation?: boolean;
|
|
5
6
|
onClose: () => void;
|
|
@@ -25,5 +26,5 @@ export interface PaneProps extends CorePaneProps {
|
|
|
25
26
|
onBack?: () => void;
|
|
26
27
|
scrollRef?: React.RefObject<HTMLDivElement | null>;
|
|
27
28
|
}
|
|
28
|
-
export declare function Pane({ open, animation, onClose, onBack, title, description, children, className, noBackArrow, headerClassName, titleClassName, descriptionClassName, topBarRightElement, dialogStyle, transparentBackdrop, scrollRef, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex, }: PaneProps): import("react").JSX.Element;
|
|
29
|
+
export declare function Pane({ open, animation, onClose, onBack, title, description, children, className, noBackArrow, headerClassName, titleClassName, descriptionClassName, topBarRightElement, dialogStyle, transparentBackdrop, scrollRef, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex, ...rest }: PaneProps): import("react").JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { CaretDoubleRightIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
|
-
import { Text } from "../Text/Text.js";
|
|
3
3
|
import zIndices from "../../utils/zIndices.js";
|
|
4
4
|
import { useZIndex } from "../../utils/useZIndex.js";
|
|
5
5
|
import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
6
|
+
import { Text } from "../Text/Text.js";
|
|
6
7
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
7
|
-
import {
|
|
8
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
8
9
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
10
|
+
import { ModalLayerProvider, useCurrentModalLayer, useModalLayer } from "../../utils/ModalLayerContext.js";
|
|
9
11
|
import { DialogContainerContext } from "../Dialog/index.js";
|
|
10
12
|
import { ScrollParentContext, useScrollParent } from "../../utils/VirtuosoCustomScrollParentContext/useScrollParent.js";
|
|
11
13
|
import { ScrollParentProvider } from "../../utils/VirtuosoCustomScrollParentContext/index.js";
|
|
@@ -16,32 +18,38 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
16
18
|
import * as RadixDialog from "@radix-ui/react-dialog";
|
|
17
19
|
//#region packages/components/src/components/Pane/Pane.tsx
|
|
18
20
|
var PaneDepth = createContext(1);
|
|
19
|
-
function PlainPane({ open, animation, onClose, children, dialogStyle, transparentBackdrop, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex }) {
|
|
21
|
+
function PlainPane({ open, animation, onClose, children, dialogStyle, transparentBackdrop, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex: paneZIndex, ...rest }) {
|
|
20
22
|
const depth = useContext(PaneDepth);
|
|
23
|
+
const layer = useCurrentModalLayer();
|
|
21
24
|
const scrollParentRef = useScrollParent();
|
|
22
|
-
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
|
23
25
|
const [contentNode, setContentNode] = useState(null);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (requireConfirmationOnClose) setShowConfirmModal(true);
|
|
27
|
-
else onClose();
|
|
28
|
-
};
|
|
29
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RadixDialog.Root, {
|
|
30
|
-
open,
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(RadixDialog.Root, {
|
|
27
|
+
open: open && !layer?.suspended,
|
|
31
28
|
onOpenChange: (o) => {
|
|
32
|
-
if (!o)
|
|
29
|
+
if (!o) onClose();
|
|
33
30
|
},
|
|
34
|
-
children: /* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
children: /* @__PURE__ */ jsxs(RadixDialog.Portal, {
|
|
32
|
+
forceMount: open || void 0,
|
|
33
|
+
children: [/* @__PURE__ */ jsx(RadixDialog.Overlay, {
|
|
34
|
+
forceMount: open || void 0,
|
|
35
|
+
"data-pane-interaction-boundary": true,
|
|
36
|
+
className: cn("fixed inset-0 bg-overlay", animation && "data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none", transparentBackdrop ? "bg-transparent" : ""),
|
|
37
|
+
style: {
|
|
38
|
+
zIndex: paneZIndex,
|
|
39
|
+
...!transparentBackdrop && layer?.backdropStyle,
|
|
40
|
+
display: layer?.suspended ? "none" : void 0
|
|
41
|
+
}
|
|
42
|
+
}), /* @__PURE__ */ jsx(RadixDialog.Content, {
|
|
43
|
+
...pickDataAttributes(rest),
|
|
44
|
+
forceMount: open || void 0,
|
|
39
45
|
ref: mergeRefs([scrollParentRef, setContentNode]),
|
|
40
|
-
className: cn("
|
|
46
|
+
className: cn("fixed inset-0 flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg", "focus:outline-hidden focus-visible:outline-hidden", animation && "data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none"),
|
|
41
47
|
style: {
|
|
42
48
|
marginLeft: `${depth * 5}rem`,
|
|
43
49
|
marginRight: `var(--polly-chat-width, 0px)`,
|
|
44
|
-
...dialogStyle
|
|
50
|
+
...dialogStyle,
|
|
51
|
+
zIndex: paneZIndex + 1,
|
|
52
|
+
display: layer?.suspended ? "none" : void 0
|
|
45
53
|
},
|
|
46
54
|
onScroll: (e) => handleScroll?.(e.nativeEvent),
|
|
47
55
|
onOpenAutoFocus: (e) => {
|
|
@@ -54,7 +62,7 @@ function PlainPane({ open, animation, onClose, children, dialogStyle, transparen
|
|
|
54
62
|
if (e.defaultPrevented) return;
|
|
55
63
|
if (requireConfirmationOnClose) {
|
|
56
64
|
e.preventDefault();
|
|
57
|
-
|
|
65
|
+
onClose();
|
|
58
66
|
}
|
|
59
67
|
},
|
|
60
68
|
onPointerDownOutside: preventInteractOutside ? (e) => {
|
|
@@ -64,7 +72,7 @@ function PlainPane({ open, animation, onClose, children, dialogStyle, transparen
|
|
|
64
72
|
e.preventDefault();
|
|
65
73
|
} : void 0,
|
|
66
74
|
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
67
|
-
value: paneZIndex,
|
|
75
|
+
value: paneZIndex + 1,
|
|
68
76
|
children: /* @__PURE__ */ jsx(DialogContainerContext.Provider, {
|
|
69
77
|
value: contentNode,
|
|
70
78
|
children: /* @__PURE__ */ jsx(TopBarPaneSlot.Context, { children: /* @__PURE__ */ jsx(PaneDepth.Provider, {
|
|
@@ -73,93 +81,91 @@ function PlainPane({ open, animation, onClose, children, dialogStyle, transparen
|
|
|
73
81
|
}) })
|
|
74
82
|
})
|
|
75
83
|
})
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
isOpen: showConfirmModal,
|
|
80
|
-
onClose: () => setShowConfirmModal(false),
|
|
81
|
-
onDiscard: () => {
|
|
82
|
-
setShowConfirmModal(false);
|
|
83
|
-
onClose();
|
|
84
|
-
},
|
|
85
|
-
title: "Unsaved Changes",
|
|
86
|
-
description: "You may have unsaved changes. Are you sure you want to exit?",
|
|
87
|
-
discardCopy: "Exit"
|
|
88
|
-
})] });
|
|
84
|
+
})]
|
|
85
|
+
})
|
|
86
|
+
}) });
|
|
89
87
|
}
|
|
90
|
-
function Pane({ open, animation = true, onClose, onBack, title, description, children, className, noBackArrow, headerClassName, titleClassName, descriptionClassName, topBarRightElement, dialogStyle, transparentBackdrop, scrollRef, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex }) {
|
|
88
|
+
function Pane({ open, animation = true, onClose, onBack, title, description, children, className, noBackArrow, headerClassName, titleClassName, descriptionClassName, topBarRightElement, dialogStyle, transparentBackdrop, scrollRef, handleScroll, preventInteractOutside, onEscapeKeyDown, requireConfirmationOnClose, zIndex, ...rest }) {
|
|
89
|
+
const layer = useModalLayer(open);
|
|
90
|
+
const paneZIndex = useZIndex(layer.zIndex ?? zIndex ?? zIndices.pane);
|
|
91
91
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
else if (requireConfirmationOnClose) setShowConfirmModal(true);
|
|
92
|
+
const requestClose = () => {
|
|
93
|
+
if (requireConfirmationOnClose) setShowConfirmModal(true);
|
|
95
94
|
else onClose();
|
|
96
95
|
};
|
|
97
|
-
const paneComponent = /* @__PURE__ */ jsxs(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
96
|
+
const paneComponent = /* @__PURE__ */ jsxs(ModalLayerProvider, {
|
|
97
|
+
layer,
|
|
98
|
+
children: [/* @__PURE__ */ jsxs(PlainPane, {
|
|
99
|
+
...pickDataAttributes(rest),
|
|
100
|
+
open,
|
|
101
|
+
animation,
|
|
102
|
+
onClose: requestClose,
|
|
103
|
+
dialogStyle,
|
|
104
|
+
transparentBackdrop,
|
|
105
|
+
handleScroll,
|
|
106
|
+
preventInteractOutside,
|
|
107
|
+
onEscapeKeyDown,
|
|
108
|
+
requireConfirmationOnClose,
|
|
109
|
+
zIndex: paneZIndex,
|
|
110
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
111
|
+
className: cn("sticky top-0 flex items-center gap-space-1 border-b border-b-subtle bg-elevated py-1.5 pl-[10px] pr-space-4", headerClassName),
|
|
112
|
+
"data-testid": `pane-header-${title}`,
|
|
113
|
+
style: { zIndex: zIndices.paneHeader },
|
|
114
|
+
children: [
|
|
115
|
+
!noBackArrow && /* @__PURE__ */ jsx(IconButton, {
|
|
116
|
+
label: "Close",
|
|
117
|
+
icon: CaretDoubleRightIcon,
|
|
118
|
+
onClick: onBack ?? requestClose,
|
|
119
|
+
variant: "plain",
|
|
120
|
+
size: "sm",
|
|
121
|
+
iconClassName: "size-5 text-quaternary"
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsxs("div", {
|
|
124
|
+
className: "flex min-w-0 flex-col gap-space-1",
|
|
125
|
+
children: [/* @__PURE__ */ jsx(RadixDialog.Title, {
|
|
126
|
+
asChild: true,
|
|
127
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
128
|
+
as: "h2",
|
|
129
|
+
variant: "h3",
|
|
130
|
+
color: "secondary",
|
|
131
|
+
className: cn("min-w-0", titleClassName),
|
|
132
|
+
children: title
|
|
133
|
+
})
|
|
134
|
+
}), description && /* @__PURE__ */ jsx(RadixDialog.Description, {
|
|
135
|
+
asChild: true,
|
|
136
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
137
|
+
as: "p",
|
|
138
|
+
variant: "sm",
|
|
139
|
+
color: "tertiary",
|
|
140
|
+
className: descriptionClassName,
|
|
141
|
+
children: description
|
|
142
|
+
})
|
|
143
|
+
})]
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsxs("div", {
|
|
146
|
+
className: "flex min-w-0 flex-1 items-center justify-end gap-space-2",
|
|
147
|
+
children: [topBarRightElement, /* @__PURE__ */ jsx(TopBarPaneSlot.Slot, { className: "flex items-center gap-space-2 empty:hidden" })]
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
151
|
+
className: cn("flex-1 pb-space-8 pl-space-7 pr-space-4 pt-space-4", className),
|
|
152
|
+
children
|
|
153
|
+
})]
|
|
154
|
+
}), /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
155
|
+
value: paneZIndex + 1,
|
|
156
|
+
children: /* @__PURE__ */ jsx(UnsavedChangesDialog, {
|
|
157
|
+
isOpen: showConfirmModal,
|
|
158
|
+
onClose: () => setShowConfirmModal(false),
|
|
159
|
+
onDiscard: () => {
|
|
160
|
+
setShowConfirmModal(false);
|
|
161
|
+
onClose();
|
|
162
|
+
},
|
|
163
|
+
title: "Unsaved Changes",
|
|
164
|
+
description: "You may have unsaved changes. Are you sure you want to exit?",
|
|
165
|
+
discardCopy: "Exit"
|
|
166
|
+
})
|
|
151
167
|
})]
|
|
152
|
-
})
|
|
153
|
-
isOpen: showConfirmModal,
|
|
154
|
-
onClose: () => setShowConfirmModal(false),
|
|
155
|
-
onDiscard: () => {
|
|
156
|
-
setShowConfirmModal(false);
|
|
157
|
-
onClose();
|
|
158
|
-
},
|
|
159
|
-
title: "Unsaved Changes",
|
|
160
|
-
description: "You may have unsaved changes. Are you sure you want to exit?",
|
|
161
|
-
discardCopy: "Exit"
|
|
162
|
-
})] });
|
|
168
|
+
});
|
|
163
169
|
return scrollRef ? /* @__PURE__ */ jsx(ScrollParentContext.Provider, {
|
|
164
170
|
value: scrollRef,
|
|
165
171
|
children: paneComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pane.js","names":[],"sources":["../../../src/components/Pane/Pane.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport { createContext, useContext, useState } from 'react';\n\nimport * as RadixDialog from '@radix-ui/react-dialog';\n\nimport { CaretDoubleRightIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ScrollParentProvider } from '../../utils/VirtuosoCustomScrollParentContext';\nimport {\n ScrollParentContext,\n useScrollParent,\n} from '../../utils/VirtuosoCustomScrollParentContext/useScrollParent';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { DialogContainerContext } from '../Dialog';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport UnsavedChangesDialog from '../UnsavedChangesDialog';\nimport { TopBarPaneSlot } from './Pane.utils';\n\nconst PaneDepth = createContext<number>(1);\n\ninterface CorePaneProps {\n open: boolean;\n animation?: boolean;\n onClose: () => void;\n children: ReactNode;\n dialogStyle?: CSSProperties;\n transparentBackdrop?: boolean;\n handleScroll?: (e: Event) => void;\n preventInteractOutside?: boolean;\n /** Escape pressed while the pane is open. preventDefault() keeps it open. */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n requireConfirmationOnClose?: boolean;\n zIndex?: number;\n}\n\nexport interface PaneProps extends CorePaneProps {\n title: string;\n description?: ReactNode;\n noBackArrow?: boolean;\n className?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n topBarRightElement?: ReactNode;\n onBack?: () => void;\n scrollRef?: React.RefObject<HTMLDivElement | null>;\n}\n\nfunction PlainPane({\n open,\n animation,\n onClose,\n children,\n dialogStyle,\n transparentBackdrop,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: CorePaneProps) {\n const depth = useContext(PaneDepth);\n const scrollParentRef = useScrollParent();\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n const paneZIndex = useZIndex(zIndex ?? zIndices.pane);\n\n const handleRequestClose = () => {\n if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n return (\n <>\n <RadixDialog.Root\n open={open}\n onOpenChange={(o) => {\n if (!o) handleRequestClose();\n }}\n >\n <RadixDialog.Portal>\n <RadixDialog.Overlay\n data-pane-interaction-boundary\n className={cn(\n 'fixed inset-0 bg-overlay',\n animation &&\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n transparentBackdrop ? 'bg-transparent' : ''\n )}\n style={{\n zIndex: paneZIndex,\n }}\n >\n <RadixDialog.Content\n ref={mergeRefs([scrollParentRef, setContentNode])}\n className={cn(\n 'relative flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg',\n 'focus:outline-hidden focus-visible:outline-hidden',\n animation &&\n 'data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none'\n )}\n style={{\n marginLeft: `${depth * 5.0}rem`,\n marginRight: `var(--polly-chat-width, 0px)`,\n ...dialogStyle,\n }}\n onScroll={(e) => handleScroll?.(e.nativeEvent)}\n onOpenAutoFocus={(e) => {\n e.preventDefault();\n const target = e.currentTarget as HTMLDivElement;\n if (target) {\n target.focus();\n }\n }}\n onEscapeKeyDown={(e) => {\n onEscapeKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (requireConfirmationOnClose) {\n e.preventDefault();\n setShowConfirmModal(true);\n }\n }}\n onPointerDownOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n onInteractOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n >\n <ZIndexProvider value={paneZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n <TopBarPaneSlot.Context>\n <PaneDepth.Provider value={depth + 1}>\n {children}\n </PaneDepth.Provider>\n </TopBarPaneSlot.Context>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialog.Content>\n </RadixDialog.Overlay>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n </>\n );\n}\n\nexport function Pane({\n open,\n animation = true,\n onClose,\n onBack,\n title,\n description,\n children,\n className,\n noBackArrow,\n headerClassName,\n titleClassName,\n descriptionClassName,\n topBarRightElement,\n dialogStyle,\n transparentBackdrop,\n scrollRef,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: PaneProps) {\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n\n const handleCloseClick = () => {\n if (onBack) {\n onBack();\n } else if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n const paneComponent = (\n <>\n <PlainPane\n open={open}\n animation={animation}\n onClose={onClose}\n dialogStyle={dialogStyle}\n transparentBackdrop={transparentBackdrop}\n handleScroll={handleScroll}\n preventInteractOutside={preventInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n requireConfirmationOnClose={requireConfirmationOnClose}\n zIndex={zIndex}\n >\n <header\n className={cn(\n 'sticky top-0 flex items-center gap-space-1 border-b border-b-subtle bg-elevated py-1.5 pl-[10px] pr-space-4',\n headerClassName\n )}\n data-testid={`pane-header-${title}`}\n style={{ zIndex: zIndices.paneHeader }}\n >\n {!noBackArrow && (\n <IconButton\n label=\"Close\"\n icon={CaretDoubleRightIcon}\n onClick={handleCloseClick}\n variant=\"plain\"\n size=\"sm\"\n iconClassName=\"size-5 text-quaternary\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n <RadixDialog.Title asChild>\n <Text\n as=\"h2\"\n variant=\"h3\"\n color=\"secondary\"\n className={cn('min-w-0', titleClassName)}\n >\n {title}\n </Text>\n </RadixDialog.Title>\n {description && (\n <RadixDialog.Description asChild>\n <Text\n as=\"p\"\n variant=\"sm\"\n color=\"tertiary\"\n className={descriptionClassName}\n >\n {description}\n </Text>\n </RadixDialog.Description>\n )}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end gap-space-2\">\n {topBarRightElement}\n <TopBarPaneSlot.Slot className=\"flex items-center gap-space-2 empty:hidden\" />\n </div>\n </header>\n <div\n className={cn(\n 'flex-1 pb-space-8 pl-space-7 pr-space-4 pt-space-4',\n className\n )}\n >\n {children}\n </div>\n </PlainPane>\n {!onBack && (\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n )}\n </>\n );\n return scrollRef ? (\n <ScrollParentContext.Provider value={scrollRef}>\n {paneComponent}\n </ScrollParentContext.Provider>\n ) : (\n <ScrollParentProvider>{paneComponent}</ScrollParentProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,YAAY,cAAsB,CAAC;AA8BzC,SAAS,UAAU,EACjB,MACA,WACA,SACA,UACA,aACA,qBACA,cACA,wBACA,iBACA,4BACA,UACgB;CAChB,MAAM,QAAQ,WAAW,SAAS;CAClC,MAAM,kBAAkB,g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AW;OAEV,UAAA;MACG,CAAA;KACiB,CAAA,CAExB;;IACL,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,oBACD,oBAAC,eAAe,MAAhB,EAAqB,WAAU,6CAA8C,CAAA,CAC1E;;GACC;EACR,CAAA,GAAA,oBAAC,OAAD;GACE,WAAW,GACT,sDACA,SACF;GAEC;EACE,CAAA,CACI;CACV,CAAA,GAAA,CAAC,UACA,oBAAC,sBAAD;EACE,QAAQ;EACR,eAAe,oBAAoB,KAAK;EACxC,iBAAiB;GACf,oBAAoB,KAAK;GACzB,QAAQ;EACV;EACA,OAAM;EACN,aAAY;EACZ,aAAY;CACb,CAAA,CAEH,EAAA,CAAA;CAEJ,OAAO,YACL,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAClC,UAAA;CAC2B,CAAA,IAE9B,oBAAC,sBAAD,EAAA,UAAuB,cAAoC,CAAA;AAE/D"}
|
|
1
|
+
{"version":3,"file":"Pane.js","names":[],"sources":["../../../src/components/Pane/Pane.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport { createContext, useContext, useState } from 'react';\n\nimport * as RadixDialog from '@radix-ui/react-dialog';\n\nimport { CaretDoubleRightIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport {\n ModalLayerProvider,\n useCurrentModalLayer,\n useModalLayer,\n} from '../../utils/ModalLayerContext';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ScrollParentProvider } from '../../utils/VirtuosoCustomScrollParentContext';\nimport {\n ScrollParentContext,\n useScrollParent,\n} from '../../utils/VirtuosoCustomScrollParentContext/useScrollParent';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { DialogContainerContext } from '../Dialog';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport UnsavedChangesDialog from '../UnsavedChangesDialog';\nimport { TopBarPaneSlot } from './Pane.utils';\n\nconst PaneDepth = createContext<number>(1);\n\ninterface CorePaneProps extends DataAttributes {\n open: boolean;\n animation?: boolean;\n onClose: () => void;\n children: ReactNode;\n dialogStyle?: CSSProperties;\n transparentBackdrop?: boolean;\n handleScroll?: (e: Event) => void;\n preventInteractOutside?: boolean;\n /** Escape pressed while the pane is open. preventDefault() keeps it open. */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n requireConfirmationOnClose?: boolean;\n zIndex?: number;\n}\n\nexport interface PaneProps extends CorePaneProps {\n title: string;\n description?: ReactNode;\n noBackArrow?: boolean;\n className?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n topBarRightElement?: ReactNode;\n onBack?: () => void;\n scrollRef?: React.RefObject<HTMLDivElement | null>;\n}\n\nfunction PlainPane({\n open,\n animation,\n onClose,\n children,\n dialogStyle,\n transparentBackdrop,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex: paneZIndex,\n ...rest\n}: CorePaneProps & { zIndex: number }) {\n const depth = useContext(PaneDepth);\n const layer = useCurrentModalLayer();\n const scrollParentRef = useScrollParent();\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <>\n <RadixDialog.Root\n open={open && !layer?.suspended}\n onOpenChange={(o) => {\n if (!o) onClose();\n }}\n >\n <RadixDialog.Portal forceMount={open || undefined}>\n <RadixDialog.Overlay\n forceMount={open || undefined}\n data-pane-interaction-boundary\n className={cn(\n 'fixed inset-0 bg-overlay',\n animation &&\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n transparentBackdrop ? 'bg-transparent' : ''\n )}\n style={{\n zIndex: paneZIndex,\n ...(!transparentBackdrop && layer?.backdropStyle),\n display: layer?.suspended ? 'none' : undefined,\n }}\n />\n <RadixDialog.Content\n {...pickDataAttributes(rest)}\n forceMount={open || undefined}\n ref={mergeRefs([scrollParentRef, setContentNode])}\n className={cn(\n 'fixed inset-0 flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg',\n 'focus:outline-hidden focus-visible:outline-hidden',\n animation &&\n 'data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none'\n )}\n style={{\n marginLeft: `${depth * 5.0}rem`,\n marginRight: `var(--polly-chat-width, 0px)`,\n ...dialogStyle,\n zIndex: paneZIndex + 1,\n display: layer?.suspended ? 'none' : undefined,\n }}\n onScroll={(e) => handleScroll?.(e.nativeEvent)}\n onOpenAutoFocus={(e) => {\n e.preventDefault();\n const target = e.currentTarget as HTMLDivElement;\n if (target) {\n target.focus();\n }\n }}\n onEscapeKeyDown={(e) => {\n onEscapeKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (requireConfirmationOnClose) {\n e.preventDefault();\n onClose();\n }\n }}\n onPointerDownOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n onInteractOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n >\n <ZIndexProvider value={paneZIndex + 1}>\n <DialogContainerContext.Provider value={contentNode}>\n <TopBarPaneSlot.Context>\n <PaneDepth.Provider value={depth + 1}>\n {children}\n </PaneDepth.Provider>\n </TopBarPaneSlot.Context>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialog.Content>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n </>\n );\n}\n\nexport function Pane({\n open,\n animation = true,\n onClose,\n onBack,\n title,\n description,\n children,\n className,\n noBackArrow,\n headerClassName,\n titleClassName,\n descriptionClassName,\n topBarRightElement,\n dialogStyle,\n transparentBackdrop,\n scrollRef,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n ...rest\n}: PaneProps) {\n const layer = useModalLayer(open);\n const paneZIndex = useZIndex(layer.zIndex ?? zIndex ?? zIndices.pane);\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n const requestClose = () => {\n if (requireConfirmationOnClose) setShowConfirmModal(true);\n else onClose();\n };\n const paneComponent = (\n <ModalLayerProvider layer={layer}>\n <PlainPane\n {...pickDataAttributes(rest)}\n open={open}\n animation={animation}\n onClose={requestClose}\n dialogStyle={dialogStyle}\n transparentBackdrop={transparentBackdrop}\n handleScroll={handleScroll}\n preventInteractOutside={preventInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n requireConfirmationOnClose={requireConfirmationOnClose}\n zIndex={paneZIndex}\n >\n <header\n className={cn(\n 'sticky top-0 flex items-center gap-space-1 border-b border-b-subtle bg-elevated py-1.5 pl-[10px] pr-space-4',\n headerClassName\n )}\n data-testid={`pane-header-${title}`}\n style={{ zIndex: zIndices.paneHeader }}\n >\n {!noBackArrow && (\n <IconButton\n label=\"Close\"\n icon={CaretDoubleRightIcon}\n onClick={onBack ?? requestClose}\n variant=\"plain\"\n size=\"sm\"\n iconClassName=\"size-5 text-quaternary\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n <RadixDialog.Title asChild>\n <Text\n as=\"h2\"\n variant=\"h3\"\n color=\"secondary\"\n className={cn('min-w-0', titleClassName)}\n >\n {title}\n </Text>\n </RadixDialog.Title>\n {description && (\n <RadixDialog.Description asChild>\n <Text\n as=\"p\"\n variant=\"sm\"\n color=\"tertiary\"\n className={descriptionClassName}\n >\n {description}\n </Text>\n </RadixDialog.Description>\n )}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end gap-space-2\">\n {topBarRightElement}\n <TopBarPaneSlot.Slot className=\"flex items-center gap-space-2 empty:hidden\" />\n </div>\n </header>\n <div\n className={cn(\n 'flex-1 pb-space-8 pl-space-7 pr-space-4 pt-space-4',\n className\n )}\n >\n {children}\n </div>\n </PlainPane>\n <ZIndexProvider value={paneZIndex + 1}>\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n </ZIndexProvider>\n </ModalLayerProvider>\n );\n return scrollRef ? (\n <ScrollParentContext.Provider value={scrollRef}>\n {paneComponent}\n </ScrollParentContext.Provider>\n ) : (\n <ScrollParentProvider>{paneComponent}</ScrollParentProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,IAAM,YAAY,cAAsB,CAAC;AA8BzC,SAAS,UAAU,EACjB,MACA,WACA,SACA,UACA,aACA,qBACA,cACA,wBACA,iBACA,4BACA,QAAQ,YACR,GAAG,QACkC;CACrC,MAAM,QAAQ,WAAW,SAAS;CAClC,MAAM,QAAQ,qBAAqB;CACnC,MAAM,kBAAkB,gBAAgB;CACxC,MAAM,CAAC,aAAa,kBAAkB,SAAgC,IAAI;CAE1E,OACE,oBAAA,YAAA,EAAA,UACE,oBAAC,YAAY,MAAb;EACE,MAAM,QAAQ,CAAC,OAAO;EACtB,eAAe,MAAM;GACnB,IAAI,CAAC,GAAG,QAAQ;EAClB;EAEA,UAAA,qBAAC,YAAY,QAAb;GAAoB,YAAY,QAAQ,KAAA;GAAxC,UAAA,CACE,oBAAC,YAAY,SAAb;IACE,YAAY,QAAQ,KAAA;IACpB,kCAAA;IACA,WAAW,GACT,4BACA,aACE,2GACF,sBAAsB,mBAAmB,EAC3C;IACA,OAAO;KACL,QAAQ;KACR,GAAI,CAAC,uBAAuB,OAAO;KACnC,SAAS,OAAO,YAAY,SAAS,KAAA;IACvC;GACD,CAAA,GACD,oBAAC,YAAY,SAAb;IACE,GAAI,mBAAmB,IAAI;IAC3B,YAAY,QAAQ,KAAA;IACpB,KAAK,UAAU,CAAC,iBAAiB,cAAc,CAAC;IAChD,WAAW,GACT,6FACA,qDACA,aACE,yGACJ;IACA,OAAO;KACL,YAAY,GAAG,QAAQ,EAAI;KAC3B,aAAa;KACb,GAA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|
import { useDialogContainer } from "../Dialog/index.js";
|
|
6
6
|
import { popoverSurfaceClassName } from "./constants.js";
|
|
7
7
|
import { forwardRef } from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
10
10
|
//#region packages/components/src/components/Popover/Popover.tsx
|
|
11
11
|
var Popover = PopoverPrimitive.Root;
|
|
12
12
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
13
13
|
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
14
|
-
var PopoverArrow = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Arrow, {
|
|
14
|
+
var PopoverArrow = forwardRef(({ className, asChild, children, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Arrow, {
|
|
15
15
|
ref,
|
|
16
|
-
className: cn("fill-popover", className),
|
|
17
|
-
...props
|
|
16
|
+
className: cn("overflow-visible fill-popover stroke-subtle", !asChild && "-translate-y-px", className),
|
|
17
|
+
...props,
|
|
18
|
+
asChild: true,
|
|
19
|
+
children: asChild ? children : /* @__PURE__ */ jsxs("svg", { children: [/* @__PURE__ */ jsx("polygon", {
|
|
20
|
+
points: "0,0 30,0 15,10",
|
|
21
|
+
stroke: "none"
|
|
22
|
+
}), /* @__PURE__ */ jsx("polyline", {
|
|
23
|
+
points: "0,0 15,10 30,0",
|
|
24
|
+
fill: "none",
|
|
25
|
+
strokeWidth: 1,
|
|
26
|
+
vectorEffect: "non-scaling-stroke"
|
|
27
|
+
})] })
|
|
18
28
|
}));
|
|
19
29
|
PopoverArrow.displayName = "PopoverArrow";
|
|
20
30
|
var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4, forceMount, container, children, ...props }, ref) => {
|
|
@@ -29,6 +39,7 @@ var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4,
|
|
|
29
39
|
sideOffset,
|
|
30
40
|
forceMount,
|
|
31
41
|
className: cn(popoverSurfaceClassName, className),
|
|
42
|
+
collisionBoundary: dialogContainer ?? void 0,
|
|
32
43
|
...props,
|
|
33
44
|
style: {
|
|
34
45
|
zIndex,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { useDialogContainer } from '../Dialog';\nimport { popoverSurfaceClassName } from './constants';\n\nexport const Popover = PopoverPrimitive.Root;\n\nexport const PopoverTrigger = PopoverPrimitive.Trigger;\nexport const PopoverAnchor = PopoverPrimitive.Anchor;\n\nexport const PopoverArrow = forwardRef<\n ElementRef<typeof PopoverPrimitive.Arrow>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>\n>(({ className, ...props }, ref) => (\n <PopoverPrimitive.Arrow\n ref={ref}\n className={cn('fill-popover'
|
|
1
|
+
{"version":3,"file":"Popover.js","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { useDialogContainer } from '../Dialog';\nimport { popoverSurfaceClassName } from './constants';\n\nexport const Popover = PopoverPrimitive.Root;\n\nexport const PopoverTrigger = PopoverPrimitive.Trigger;\nexport const PopoverAnchor = PopoverPrimitive.Anchor;\n\nexport const PopoverArrow = forwardRef<\n ElementRef<typeof PopoverPrimitive.Arrow>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>\n>(({ className, asChild, children, ...props }, ref) => (\n <PopoverPrimitive.Arrow\n ref={ref}\n className={cn(\n 'overflow-visible fill-popover stroke-subtle',\n !asChild && '-translate-y-px',\n className\n )}\n {...props}\n asChild\n >\n {asChild ? (\n children\n ) : (\n <svg>\n <polygon points=\"0,0 30,0 15,10\" stroke=\"none\" />\n <polyline\n points=\"0,0 15,10 30,0\"\n fill=\"none\"\n strokeWidth={1}\n vectorEffect=\"non-scaling-stroke\"\n />\n </svg>\n )}\n </PopoverPrimitive.Arrow>\n));\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport const PopoverContent = forwardRef<\n ElementRef<typeof PopoverPrimitive.Content>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {\n /**\n * Portal target for the popover. When omitted, the popover automatically\n * portals into the enclosing modal `Dialog` (if any) so it stays\n * mouse-interactive, and falls back to `document.body` otherwise.\n */\n container?: HTMLElement | null;\n }\n>(\n (\n {\n className,\n align = 'center',\n sideOffset = 4,\n forceMount,\n container,\n children,\n ...props\n },\n ref\n ) => {\n const zIndex = useZIndex(zIndices.popover);\n // Portal into the enclosing modal Dialog (null when not inside one) so the\n // popover stays inside the dialog's pointer-events-interactive region.\n const dialogContainer = useDialogContainer();\n\n return (\n <PopoverPrimitive.Portal\n forceMount={forceMount}\n // Fall back to `undefined` (not `null`) when there is no dialog: Radix's\n // Portal only defaults to `document.body` when `container` is absent, so\n // an explicit `null` leaves non-forceMount popovers unrendered.\n container={container ?? dialogContainer ?? undefined}\n >\n <PopoverPrimitive.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n forceMount={forceMount}\n className={cn(popoverSurfaceClassName, className)}\n collisionBoundary={dialogContainer ?? undefined}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n );\n }\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n"],"mappings":";;;;;;;;;;AAYA,IAAa,UAAU,iBAAiB;AAExC,IAAa,iBAAiB,iBAAiB;AAC/C,IAAa,gBAAgB,iBAAiB;AAE9C,IAAa,eAAe,YAGzB,EAAE,WAAW,SAAS,UAAU,GAAG,SAAS,QAC7C,oBAAC,iBAAiB,OAAlB;CACO;CACL,WAAW,GACT,+CACA,CAAC,WAAW,mBACZ,SACF;CACA,GAAI;CACJ,SAAA;CAEC,UAAA,UACC,WAEA,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,WAAD;EAAS,QAAO;EAAiB,QAAO;CAAQ,CAAA,GAChD,oBAAC,YAAD;EACE,QAAO;EACP,MAAK;EACL,aAAa;EACb,cAAa;CACd,CAAA,CACE,EAAA,CAAA;AAEe,CAAA,CACzB;AACD,aAAa,cAAc;AAE3B,IAAa,iBAAiB,YAY1B,EACE,WACA,QAAQ,UACR,aAAa,GACb,YACA,WACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,SAAS,UAAU,SAAS,OAAO;CAGzC,MAAM,kBAAkB,mBAAmB;CAE3C,OACE,oBAAC,iBAAiB,QAAlB;EACc;EAIZ,WAAW,aAAa,mBAAmB,KAAA;EAE3C,UAAA,oBAAC,iBAAiB,SAAlB;GACO;GACE;GACK;GACA;GACZ,WAAW,GAAG,yBAAyB,SAAS;GAChD,mBAAmB,mBAAmB,KAAA;GACtC,GAAI;GACJ,OAAO;IAAE;IAAQ,GAAG,MAAM;GAAM;GAEhC,UAAA,oBAAC,gBAAD;IAAgB,OAAO;IAAS;GAAyB,CAAA;EACjC,CAAA;CACH,CAAA;AAE7B,CACF;AACA,eAAe,cAAc,iBAAiB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const popoverSurfaceClassName = "w-72 rounded-md bg-popover p-space-4 outline-hidden
|
|
1
|
+
export declare const popoverSurfaceClassName = "w-72 rounded-md border border-subtle bg-popover p-space-4 shadow-md outline-hidden dark:shadow-none";
|