@artsy/palette 46.4.0 → 46.5.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 (38) hide show
  1. package/dist/cjs/elements/AutocompleteInput/AutocompleteInput.js +3 -1
  2. package/dist/cjs/elements/AutocompleteInput/AutocompleteInput.js.map +1 -1
  3. package/dist/cjs/elements/BaseTabs/BaseTab.d.ts +2 -2
  4. package/dist/cjs/elements/Dropdown/Dropdown.d.ts +17 -3
  5. package/dist/cjs/elements/Dropdown/Dropdown.js +124 -174
  6. package/dist/cjs/elements/Dropdown/Dropdown.js.map +1 -1
  7. package/dist/cjs/elements/MultiSelect/MultiSelect.js +4 -2
  8. package/dist/cjs/elements/MultiSelect/MultiSelect.js.map +1 -1
  9. package/dist/cjs/elements/Pointer/Pointer.d.ts +21 -14
  10. package/dist/cjs/elements/Pointer/Pointer.js +65 -135
  11. package/dist/cjs/elements/Pointer/Pointer.js.map +1 -1
  12. package/dist/cjs/elements/Popover/Popover.js +12 -11
  13. package/dist/cjs/elements/Popover/Popover.js.map +1 -1
  14. package/dist/cjs/elements/SelectInput/SelectInput.js +3 -1
  15. package/dist/cjs/elements/SelectInput/SelectInput.js.map +1 -1
  16. package/dist/cjs/elements/Sup/Sup.d.ts +1 -1
  17. package/dist/cjs/elements/Tooltip/Tooltip.js +16 -17
  18. package/dist/cjs/elements/Tooltip/Tooltip.js.map +1 -1
  19. package/dist/cjs/utils/usePosition.d.ts +70 -37
  20. package/dist/cjs/utils/usePosition.js +110 -349
  21. package/dist/cjs/utils/usePosition.js.map +1 -1
  22. package/dist/esm/elements/AutocompleteInput/AutocompleteInput.js +3 -1
  23. package/dist/esm/elements/AutocompleteInput/AutocompleteInput.js.map +1 -1
  24. package/dist/esm/elements/Dropdown/Dropdown.js +124 -173
  25. package/dist/esm/elements/Dropdown/Dropdown.js.map +1 -1
  26. package/dist/esm/elements/MultiSelect/MultiSelect.js +4 -2
  27. package/dist/esm/elements/MultiSelect/MultiSelect.js.map +1 -1
  28. package/dist/esm/elements/Pointer/Pointer.js +66 -134
  29. package/dist/esm/elements/Pointer/Pointer.js.map +1 -1
  30. package/dist/esm/elements/Popover/Popover.js +13 -12
  31. package/dist/esm/elements/Popover/Popover.js.map +1 -1
  32. package/dist/esm/elements/SelectInput/SelectInput.js +3 -1
  33. package/dist/esm/elements/SelectInput/SelectInput.js.map +1 -1
  34. package/dist/esm/elements/Tooltip/Tooltip.js +17 -18
  35. package/dist/esm/elements/Tooltip/Tooltip.js.map +1 -1
  36. package/dist/esm/utils/usePosition.js +109 -343
  37. package/dist/esm/utils/usePosition.js.map +1 -1
  38. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"SelectInput.js","names":["_composeReactRefs","_interopRequireDefault","require","_themeGet","_react","_interopRequireWildcard","_styledComponents","_styledSystem","_utils","_Box","_Text","_tokens","_RequiredField","_SelectInputList","_Select","_Clickable","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","SelectInput","exports","React","forwardRef","className","enableSearch","disabled","dropdownValue","error","focus","hover","label","inputValue","onSelect","options","required","selectWidth","optionTextMinWidth","rest","forwardedRef","length","Error","inputRef","useRef","containerRef","defaultOption","useMemo","find","option","value","boxProps","inputProps","splitBoxProps","open","setOpen","useState","selectedOption","setSelectedOption","anchorRef","tooltipRef","usePosition","position","offset","active","flip","width","useWidthOf","ref","inputName","name","handleSelect","current","handleFocusChange","useCallback","focused","containsFocusRef","useContainsFocus","onChange","handleClose","jsxs","Box","composeRefs","children","SelectInputContainer","placeholder","jsx","SelectInputSelect","onClick","text","SelectInputInput","maxLength","SelectInputLabel","htmlFor","SelectInputDropdown","role","SelectInputList","onClose","RequiredField","mt","ml","Text","variant","mr","color","textAlign","displayName","styled","withConfig","componentId","props","css","SELECT_INPUT_STATES","completed","Clickable","caretMixin","p","themeGet","input","systemHeight"],"sources":["../../../../src/elements/SelectInput/SelectInput.tsx"],"sourcesContent":["import composeRefs from \"@seznam/compose-react-refs\"\nimport { themeGet } from \"@styled-system/theme-get\"\nimport React, { useCallback, useMemo, useRef, useState } from \"react\"\nimport styled, { css } from \"styled-components\"\nimport { height as systemHeight } from \"styled-system\"\nimport { useContainsFocus, usePosition, useWidthOf } from \"../../utils\"\nimport { Box, splitBoxProps } from \"../Box\"\nimport { InputProps } from \"../Input\"\nimport { Text, TextProps } from \"../Text\"\nimport { SELECT_INPUT_STATES } from \"./tokens\"\nimport { RequiredField } from \"../../shared/RequiredField\"\nimport { Option, SelectInputList } from \"./SelectInputList\"\nimport { caretMixin } from \"../Select\"\nimport { Clickable, ClickableProps } from \"../Clickable\"\n\nexport interface SelectInputProps extends Omit<InputProps, \"onSelect\"> {\n active?: boolean\n enableSearch?: boolean\n disabled?: boolean\n dropdownValue?: string\n error?: string | boolean\n focus?: boolean\n hover?: boolean\n inputValue?: string\n label: string\n onSelect: (option: Option) => void\n options: Option[]\n required?: boolean\n /** Controls the width of the left hand select dropdown UI */\n selectWidth?: ClickableProps[\"width\"]\n /** Controls the gap between the text and name labels in select options */\n optionTextMinWidth?: TextProps[\"minWidth\"]\n}\n\nexport const SelectInput = React.forwardRef<HTMLInputElement, SelectInputProps>(\n (\n {\n className,\n enableSearch,\n disabled,\n dropdownValue,\n error,\n focus,\n hover,\n label,\n inputValue,\n onSelect,\n options,\n required,\n selectWidth,\n optionTextMinWidth,\n ...rest\n },\n forwardedRef\n ) => {\n if (options.length === 0) {\n throw new Error(\n \"Palette SelectInput requires at least 1 option in the options prop\"\n )\n }\n\n const inputRef = useRef<HTMLInputElement | null>(null)\n const containerRef = useRef<HTMLDivElement | null>(null)\n\n const defaultOption = useMemo(\n () =>\n dropdownValue &&\n options.find((option) => option.value === dropdownValue),\n [dropdownValue, options]\n )\n\n const [boxProps, inputProps] = splitBoxProps(rest)\n\n const [open, setOpen] = useState(false)\n const [selectedOption, setSelectedOption] = useState(\n defaultOption || options[0]\n )\n\n const { anchorRef, tooltipRef } = usePosition({\n position: \"bottom\",\n offset: 10,\n active: open,\n flip: false,\n })\n\n const { width } = useWidthOf({ ref: anchorRef })\n\n const inputName = inputProps.name || \"palette-select-input\"\n\n const handleSelect = (option: Option) => {\n setSelectedOption(option)\n setOpen(false)\n inputRef.current?.focus()\n onSelect?.(option)\n }\n\n const handleFocusChange = useCallback(\n (focused: boolean) => {\n if (focused || !open) return\n setOpen(false)\n },\n [open]\n )\n\n // Handle closing the dropdown when clicking outside of the input\n // or when focus leaves the input completely\n const { ref: containsFocusRef } = useContainsFocus({\n onChange: handleFocusChange,\n })\n\n const handleClose = () => {\n setOpen(false)\n }\n\n return (\n <Box\n ref={composeRefs(containerRef, containsFocusRef) as any}\n width=\"100%\"\n className={className}\n {...boxProps}\n >\n <SelectInputContainer\n ref={anchorRef as any}\n open={open}\n hover={hover}\n focus={focus}\n error={error}\n disabled={disabled}\n placeholder={inputProps.placeholder}\n >\n <SelectInputSelect\n data-testid=\"country-picker\"\n disabled={disabled}\n onClick={() => {\n setOpen(!disabled && !open)\n }}\n width={selectWidth}\n >\n {selectedOption.text}\n </SelectInputSelect>\n\n <SelectInputInput\n disabled={disabled}\n ref={composeRefs(inputRef, forwardedRef)}\n required={required}\n name={inputName}\n maxLength={25}\n placeholder={inputProps.placeholder}\n value={inputValue}\n {...inputProps}\n />\n\n <SelectInputLabel htmlFor={inputName}>{label}</SelectInputLabel>\n </SelectInputContainer>\n\n {open && (\n <SelectInputDropdown\n ref={tooltipRef as any}\n role=\"listbox\"\n width={width}\n >\n <SelectInputList\n options={options}\n onSelect={handleSelect}\n onClose={handleClose}\n enableSearch={enableSearch}\n optionTextMinWidth={optionTextMinWidth}\n />\n </SelectInputDropdown>\n )}\n\n {required && !(error && typeof error === \"string\") && (\n <RequiredField mt={0.5} ml={1} disabled={disabled} />\n )}\n\n {error && typeof error === \"string\" && (\n <Text variant=\"xs\" mt={0.5} mr={1} color=\"red100\" textAlign=\"right\">\n {error}\n </Text>\n )}\n </Box>\n )\n }\n)\n\nSelectInput.displayName = \"SelectInput\"\n\ntype ContainerProps = Pick<\n SelectInputProps,\n \"disabled\" | \"error\" | \"hover\" | \"focus\" | \"placeholder\"\n> & { open: boolean }\n\nconst SelectInputContainer = styled(Box)<ContainerProps>`\n position: relative;\n display: flex;\n flex-direction: row;\n\n ${(props) => {\n return css`\n ${SELECT_INPUT_STATES.default}\n ${props.hover && SELECT_INPUT_STATES.hover}\n ${(props.focus || props.open) && SELECT_INPUT_STATES.focus}\n ${props.disabled && SELECT_INPUT_STATES.disabled}\n ${props.error && SELECT_INPUT_STATES.error}\n\n &:hover {\n /* Applies hover style if the dropdown is not visible or the input is disabled */\n ${!props.open && !props.disabled && SELECT_INPUT_STATES.hover}\n }\n\n &:focus-within {\n ${!props.disabled && SELECT_INPUT_STATES.focus}\n\n &:has(input:not(:placeholder-shown)) {\n ${SELECT_INPUT_STATES.active}\n ${props.error && SELECT_INPUT_STATES.error};\n }\n }\n\n &:has(input:not(:placeholder-shown)) {\n ${!!props.placeholder && SELECT_INPUT_STATES.completed}\n ${props.error && SELECT_INPUT_STATES.error};\n }\n `\n }}\n`\n\nconst SelectInputSelect = styled(Clickable)<{ disabled?: boolean }>`\n ${caretMixin}\n display: flex;\n align-items: center;\n position: relative;\n min-width: ${(p) => p.width ?? 120}px;\n border: 1px solid;\n border-right: 0;\n /* 24px = space.1 + 4px-wide caret + space.1 */\n padding: 0 24px 0 ${themeGet(\"space.1\")};\n font-family: ${themeGet(\"fonts.sans\")};\n border-radius: 3px 0 0 3px;\n border-color: ${themeGet(\"colors.mono30\")};\n cursor: pointer;\n line-height: 1;\n transition: color 0.25s, border-color 0.25s;\n height: 50px;\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n color: ${themeGet(\"colors.mono100\")};\n &:focus {\n outline: none;\n text-decoration: underline;\n color: ${themeGet(\"colors.blue100\")};\n }\n`\n\nconst SelectInputDropdown = styled(Box)`\n box-shadow: ${themeGet(\"effects.dropShadow\")};\n background: ${themeGet(\"colors.mono0\")};\n z-index: 1;\n padding: ${themeGet(\"space.1\")};\n`\n\nconst SelectInputInput = styled.input`\n width: 100%;\n background-color: ${themeGet(\"colors.mono0\")};\n padding: 0 ${themeGet(\"space.1\")};\n appearance: none;\n outline: none;\n line-height: 1;\n border: 1px solid;\n border-radius: 0 3px 3px 0;\n transition: color 0.25s, border-color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n color: ${themeGet(\"colors.mono100\")};\n border-color: ${themeGet(\"colors.mono30\")};\n ${systemHeight}\n\n ::placeholder {\n color: ${themeGet(\"colors.mono60\")};\n transition: color 0.25s;\n }\n`\n\nconst SelectInputLabel = styled.label`\n position: absolute;\n top: 0;\n left: 5px;\n padding: 0 5px;\n background-color: transparent;\n transform: translateY(-50%);\n transition: color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n pointer-events: none;\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n color: ${themeGet(\"colors.mono60\")};\n\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n top: 50%;\n left: 0;\n height: 2px;\n width: 100%;\n background-color: ${themeGet(\"colors.mono0\")};\n z-index: -1;\n }\n`\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;AAC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AG,WAAA;AAAA,mUAQpB,IAAAQ,kBAAQ,EAAC,YAAY,CAAC,EAExB,IAAAA,kBAAQ,EAAC,0BAA0B,CAAC,EACxC,IAAAA,kBAAQ,EAAC,eAAe,CAAC,EAUZ,IAAAA,kBAAQ,EAAC,cAAc,CAAC,CAG/C"}
1
+ {"version":3,"file":"SelectInput.js","names":["_composeReactRefs","_interopRequireDefault","require","_themeGet","_react","_interopRequireWildcard","_styledComponents","_styledSystem","_utils","_Box","_Text","_tokens","_RequiredField","_SelectInputList","_Select","_Clickable","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","SelectInput","exports","React","forwardRef","className","enableSearch","disabled","dropdownValue","error","focus","hover","label","inputValue","onSelect","options","required","selectWidth","optionTextMinWidth","rest","forwardedRef","length","Error","inputRef","useRef","containerRef","defaultOption","useMemo","find","option","value","boxProps","inputProps","splitBoxProps","open","setOpen","useState","selectedOption","setSelectedOption","anchorRef","tooltipRef","floatingStyles","usePosition","position","offset","active","flip","width","useWidthOf","ref","inputName","name","handleSelect","current","handleFocusChange","useCallback","focused","containsFocusRef","useContainsFocus","onChange","handleClose","jsxs","Box","composeRefs","children","SelectInputContainer","placeholder","jsx","SelectInputSelect","onClick","text","SelectInputInput","maxLength","SelectInputLabel","htmlFor","SelectInputDropdown","role","style","SelectInputList","onClose","RequiredField","mt","ml","Text","variant","mr","color","textAlign","displayName","styled","withConfig","componentId","props","css","SELECT_INPUT_STATES","completed","Clickable","caretMixin","p","themeGet","input","systemHeight"],"sources":["../../../../src/elements/SelectInput/SelectInput.tsx"],"sourcesContent":["import composeRefs from \"@seznam/compose-react-refs\"\nimport { themeGet } from \"@styled-system/theme-get\"\nimport React, { useCallback, useMemo, useRef, useState } from \"react\"\nimport styled, { css } from \"styled-components\"\nimport { height as systemHeight } from \"styled-system\"\nimport { useContainsFocus, usePosition, useWidthOf } from \"../../utils\"\nimport { Box, splitBoxProps } from \"../Box\"\nimport { InputProps } from \"../Input\"\nimport { Text, TextProps } from \"../Text\"\nimport { SELECT_INPUT_STATES } from \"./tokens\"\nimport { RequiredField } from \"../../shared/RequiredField\"\nimport { Option, SelectInputList } from \"./SelectInputList\"\nimport { caretMixin } from \"../Select\"\nimport { Clickable, ClickableProps } from \"../Clickable\"\n\nexport interface SelectInputProps extends Omit<InputProps, \"onSelect\"> {\n active?: boolean\n enableSearch?: boolean\n disabled?: boolean\n dropdownValue?: string\n error?: string | boolean\n focus?: boolean\n hover?: boolean\n inputValue?: string\n label: string\n onSelect: (option: Option) => void\n options: Option[]\n required?: boolean\n /** Controls the width of the left hand select dropdown UI */\n selectWidth?: ClickableProps[\"width\"]\n /** Controls the gap between the text and name labels in select options */\n optionTextMinWidth?: TextProps[\"minWidth\"]\n}\n\nexport const SelectInput = React.forwardRef<HTMLInputElement, SelectInputProps>(\n (\n {\n className,\n enableSearch,\n disabled,\n dropdownValue,\n error,\n focus,\n hover,\n label,\n inputValue,\n onSelect,\n options,\n required,\n selectWidth,\n optionTextMinWidth,\n ...rest\n },\n forwardedRef\n ) => {\n if (options.length === 0) {\n throw new Error(\n \"Palette SelectInput requires at least 1 option in the options prop\"\n )\n }\n\n const inputRef = useRef<HTMLInputElement | null>(null)\n const containerRef = useRef<HTMLDivElement | null>(null)\n\n const defaultOption = useMemo(\n () =>\n dropdownValue &&\n options.find((option) => option.value === dropdownValue),\n [dropdownValue, options]\n )\n\n const [boxProps, inputProps] = splitBoxProps(rest)\n\n const [open, setOpen] = useState(false)\n const [selectedOption, setSelectedOption] = useState(\n defaultOption || options[0]\n )\n\n const { anchorRef, tooltipRef, floatingStyles } = usePosition({\n position: \"bottom\",\n offset: 10,\n active: open,\n flip: false,\n })\n\n const { width } = useWidthOf({ ref: anchorRef })\n\n const inputName = inputProps.name || \"palette-select-input\"\n\n const handleSelect = (option: Option) => {\n setSelectedOption(option)\n setOpen(false)\n inputRef.current?.focus()\n onSelect?.(option)\n }\n\n const handleFocusChange = useCallback(\n (focused: boolean) => {\n if (focused || !open) return\n setOpen(false)\n },\n [open]\n )\n\n // Handle closing the dropdown when clicking outside of the input\n // or when focus leaves the input completely\n const { ref: containsFocusRef } = useContainsFocus({\n onChange: handleFocusChange,\n })\n\n const handleClose = () => {\n setOpen(false)\n }\n\n return (\n <Box\n ref={composeRefs(containerRef, containsFocusRef) as any}\n width=\"100%\"\n className={className}\n {...boxProps}\n >\n <SelectInputContainer\n ref={anchorRef as any}\n open={open}\n hover={hover}\n focus={focus}\n error={error}\n disabled={disabled}\n placeholder={inputProps.placeholder}\n >\n <SelectInputSelect\n data-testid=\"country-picker\"\n disabled={disabled}\n onClick={() => {\n setOpen(!disabled && !open)\n }}\n width={selectWidth}\n >\n {selectedOption.text}\n </SelectInputSelect>\n\n <SelectInputInput\n disabled={disabled}\n ref={composeRefs(inputRef, forwardedRef)}\n required={required}\n name={inputName}\n maxLength={25}\n placeholder={inputProps.placeholder}\n value={inputValue}\n {...inputProps}\n />\n\n <SelectInputLabel htmlFor={inputName}>{label}</SelectInputLabel>\n </SelectInputContainer>\n\n {open && (\n <SelectInputDropdown\n ref={tooltipRef as any}\n role=\"listbox\"\n width={width}\n style={floatingStyles}\n >\n <SelectInputList\n options={options}\n onSelect={handleSelect}\n onClose={handleClose}\n enableSearch={enableSearch}\n optionTextMinWidth={optionTextMinWidth}\n />\n </SelectInputDropdown>\n )}\n\n {required && !(error && typeof error === \"string\") && (\n <RequiredField mt={0.5} ml={1} disabled={disabled} />\n )}\n\n {error && typeof error === \"string\" && (\n <Text variant=\"xs\" mt={0.5} mr={1} color=\"red100\" textAlign=\"right\">\n {error}\n </Text>\n )}\n </Box>\n )\n }\n)\n\nSelectInput.displayName = \"SelectInput\"\n\ntype ContainerProps = Pick<\n SelectInputProps,\n \"disabled\" | \"error\" | \"hover\" | \"focus\" | \"placeholder\"\n> & { open: boolean }\n\nconst SelectInputContainer = styled(Box)<ContainerProps>`\n position: relative;\n display: flex;\n flex-direction: row;\n\n ${(props) => {\n return css`\n ${SELECT_INPUT_STATES.default}\n ${props.hover && SELECT_INPUT_STATES.hover}\n ${(props.focus || props.open) && SELECT_INPUT_STATES.focus}\n ${props.disabled && SELECT_INPUT_STATES.disabled}\n ${props.error && SELECT_INPUT_STATES.error}\n\n &:hover {\n /* Applies hover style if the dropdown is not visible or the input is disabled */\n ${!props.open && !props.disabled && SELECT_INPUT_STATES.hover}\n }\n\n &:focus-within {\n ${!props.disabled && SELECT_INPUT_STATES.focus}\n\n &:has(input:not(:placeholder-shown)) {\n ${SELECT_INPUT_STATES.active}\n ${props.error && SELECT_INPUT_STATES.error};\n }\n }\n\n &:has(input:not(:placeholder-shown)) {\n ${!!props.placeholder && SELECT_INPUT_STATES.completed}\n ${props.error && SELECT_INPUT_STATES.error};\n }\n `\n }}\n`\n\nconst SelectInputSelect = styled(Clickable)<{ disabled?: boolean }>`\n ${caretMixin}\n display: flex;\n align-items: center;\n position: relative;\n min-width: ${(p) => p.width ?? 120}px;\n border: 1px solid;\n border-right: 0;\n /* 24px = space.1 + 4px-wide caret + space.1 */\n padding: 0 24px 0 ${themeGet(\"space.1\")};\n font-family: ${themeGet(\"fonts.sans\")};\n border-radius: 3px 0 0 3px;\n border-color: ${themeGet(\"colors.mono30\")};\n cursor: pointer;\n line-height: 1;\n transition: color 0.25s, border-color 0.25s;\n height: 50px;\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n color: ${themeGet(\"colors.mono100\")};\n &:focus {\n outline: none;\n text-decoration: underline;\n color: ${themeGet(\"colors.blue100\")};\n }\n`\n\nconst SelectInputDropdown = styled(Box)`\n box-shadow: ${themeGet(\"effects.dropShadow\")};\n background: ${themeGet(\"colors.mono0\")};\n z-index: 1;\n padding: ${themeGet(\"space.1\")};\n`\n\nconst SelectInputInput = styled.input`\n width: 100%;\n background-color: ${themeGet(\"colors.mono0\")};\n padding: 0 ${themeGet(\"space.1\")};\n appearance: none;\n outline: none;\n line-height: 1;\n border: 1px solid;\n border-radius: 0 3px 3px 0;\n transition: color 0.25s, border-color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n color: ${themeGet(\"colors.mono100\")};\n border-color: ${themeGet(\"colors.mono30\")};\n ${systemHeight}\n\n ::placeholder {\n color: ${themeGet(\"colors.mono60\")};\n transition: color 0.25s;\n }\n`\n\nconst SelectInputLabel = styled.label`\n position: absolute;\n top: 0;\n left: 5px;\n padding: 0 5px;\n background-color: transparent;\n transform: translateY(-50%);\n transition: color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n pointer-events: none;\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n color: ${themeGet(\"colors.mono60\")};\n\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n top: 50%;\n left: 0;\n height: 2px;\n width: 100%;\n background-color: ${themeGet(\"colors.mono0\")};\n z-index: -1;\n }\n`\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;AACA,IAAAW,gBAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AAAwD,IAAAc,WAAA,GAAAd,OAAA;AAAA,SAAAe,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAA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A,kBAAQ,EAAC,cAAc,CAAC,CAG/C"}
@@ -4,7 +4,7 @@ export declare const Sup: import("styled-components/dist/types").IStyledComponen
4
4
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
5
5
  }, Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("..").BoxProps> & import("..").BoxProps, "ref"> & {
6
6
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
- }>, TextProps>, "p" | "top" | "bottom" | "left" | "right" | "position" | "padding" | "width" | "height" | "gap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "backgroundImage" | "backgroundRepeat" | "backgroundSize" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "boxShadow" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pointerEvents" | "textAlign" | "textTransform" | "verticalAlign" | "zIndex" | "background" | "backgroundPosition" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "gridArea" | "lineClamp" | "margin" | "overflow" | "bg" | "borderX" | "borderY" | "size" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "textColor" | "variant" | "hyphenate" | "overflowEllipsis"> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & Omit<import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, "color"> & {
7
+ }>, TextProps>, "p" | "top" | "bottom" | "left" | "right" | "padding" | "width" | "height" | "position" | "size" | "flex" | "border" | "gap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "backgroundImage" | "backgroundRepeat" | "backgroundSize" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "boxShadow" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pointerEvents" | "textAlign" | "textTransform" | "verticalAlign" | "zIndex" | "background" | "backgroundPosition" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "gridArea" | "lineClamp" | "margin" | "overflow" | "bg" | "borderX" | "borderY" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "textColor" | "variant" | "hyphenate" | "overflowEllipsis"> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & Omit<import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, "color"> & {
8
8
  variant?: import("styled-system").ResponsiveValue<import("@artsy/palette-tokens/dist/typography/v3").TextVariant>;
9
9
  textColor?: import("styled-system").ResponsiveValue<import("@artsy/palette-tokens").Color>;
10
10
  lineClamp?: number;
@@ -52,16 +52,18 @@ const Tooltip = ({
52
52
  const deactivate = () => {
53
53
  setActive(false);
54
54
  };
55
+ const arrowRef = (0, _react.useRef)(null);
55
56
  const {
56
57
  anchorRef,
57
58
  tooltipRef,
58
- state: {
59
- isFlipped
60
- }
59
+ floatingStyles,
60
+ context,
61
+ rects
61
62
  } = (0, _usePosition.usePosition)({
62
63
  position: placement,
63
64
  offset,
64
- active: visible ?? active
65
+ active: visible ?? active,
66
+ arrowRef: arrowRef
65
67
  });
66
68
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
67
69
  children: [/*#__PURE__*/_react.default.cloneElement(children, {
@@ -77,20 +79,17 @@ const Tooltip = ({
77
79
  variant: variant,
78
80
  width: width,
79
81
  zIndex: zIndex,
80
- style:
81
- // If visible is explictly set to `false` then the tooltip should be hidden
82
- // Otherwise it should be visible or utilize the active state.
83
- visible !== false ? {
84
- opacity: visible ?? active ? 1 : 0
85
- } : {
86
- opacity: 0
82
+ style: {
83
+ ...floatingStyles,
84
+ // If visible is explictly set to `false` then the tooltip should be hidden
85
+ // Otherwise it should be visible or utilize the active state.
86
+ opacity: visible !== false ? visible ?? active ? 1 : 0 : 0
87
87
  },
88
88
  children: [pointer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pointer.Pointer, {
89
- anchorRef: anchorRef,
90
- tooltipRef: tooltipRef,
91
- variant: variant,
92
- placement: placement,
93
- isFlipped: isFlipped
89
+ ref: arrowRef,
90
+ context: context,
91
+ rects: rects,
92
+ variant: variant
94
93
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Panel, {
95
94
  variant: variant,
96
95
  p: 1,
@@ -107,7 +106,7 @@ exports.Tooltip = Tooltip;
107
106
  const Tip = (0, _styledComponents.default)(_Box.Box).withConfig({
108
107
  displayName: "Tooltip__Tip",
109
108
  componentId: "sc-ymkaxc-0"
110
- })(["position:absolute;transition:opacity 250ms ease-out;text-align:left;box-shadow:", ";cursor:default;pointer-events:none;font-weight:normal;font-style:normal;", ""], (0, _themeGet.themeGet)("effects.dropShadow"), (0, _styledSystem.variant)({
109
+ })(["transition:opacity 250ms ease-out;text-align:left;box-shadow:", ";cursor:default;pointer-events:none;font-weight:normal;font-style:normal;", ""], (0, _themeGet.themeGet)("effects.dropShadow"), (0, _styledSystem.variant)({
111
110
  variants: TOOLTIP_VARIANTS
112
111
  }));
113
112
  const Panel = (0, _styledComponents.default)(_Box.Box).withConfig({
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_styledSystem","_helpers","_usePosition","_Box","_Pointer","_Text","_themeGet","_jsxRuntime","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TOOLTIP_VARIANTS","exports","defaultLight","backgroundColor","color","defaultDark","Tooltip","children","content","width","offset","placement","pointer","variant","visible","zIndex","rest","active","setActive","useState","handleClick","prevActive","activate","deactivate","anchorRef","tooltipRef","state","isFlipped","usePosition","position","jsxs","Fragment","React","cloneElement","ref","tabIndex","onClick","compose","props","onMouseOver","onMouseOut","onFocus","onBlur","Tip","style","opacity","jsx","Pointer","Panel","p","isText","Text","styled","Box","withConfig","displayName","componentId","themeGet","variants","a","b","args"],"sources":["../../../../src/elements/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useState } from \"react\"\nimport styled from \"styled-components\"\nimport { variant } from \"styled-system\"\nimport { isText } from \"../../helpers\"\nimport { Position, usePosition } from \"../../utils/usePosition\"\nimport { Box, BoxProps } from \"../Box\"\nimport { Pointer } from \"../Pointer\"\nimport { Text } from \"../Text\"\nimport { themeGet } from \"@styled-system/theme-get\"\n\nexport const TOOLTIP_VARIANTS = {\n defaultLight: {\n backgroundColor: \"mono0\",\n color: \"mono100\",\n },\n defaultDark: {\n backgroundColor: \"mono100\",\n color: \"mono0\",\n },\n}\n\nexport type TooltipVariant = keyof typeof TOOLTIP_VARIANTS\n\nexport interface TooltipProps extends BoxProps {\n /** Anchor element to attach to tooltip */\n children: React.ReactElement<any, string | React.JSXElementConstructor<any>>\n /** Content of tooltip */\n content: React.ReactNode\n offset?: number\n placement?: Position\n pointer?: boolean\n variant?: TooltipVariant\n visible?: boolean\n}\n\n/**\n * A tooltip\n */\nexport const Tooltip: React.FC<React.PropsWithChildren<TooltipProps>> = ({\n children,\n content,\n width = 230,\n offset = 10,\n placement = \"top\",\n pointer = false,\n variant = \"defaultLight\",\n visible,\n zIndex = 1,\n ...rest\n}) => {\n const [active, setActive] = useState(false)\n\n const handleClick = () => {\n setActive((prevActive) => !prevActive)\n }\n\n const activate = () => {\n setActive(true)\n }\n\n const deactivate = () => {\n setActive(false)\n }\n\n const {\n anchorRef,\n tooltipRef,\n state: { isFlipped },\n } = usePosition({\n position: placement,\n offset,\n active: visible ?? active,\n })\n\n return (\n <>\n {React.cloneElement(children, {\n ref: anchorRef,\n tabIndex: 0,\n onClick: compose(handleClick, children.props?.onClick),\n onMouseOver: compose(activate, children.props?.onMouseOver),\n onMouseOut: compose(deactivate, children.props?.onMouseOut),\n onFocus: compose(activate, children.props?.onFocus),\n onBlur: compose(deactivate, children.props?.onBlur),\n })}\n\n <Tip\n ref={tooltipRef as any}\n variant={variant}\n width={width}\n zIndex={zIndex}\n style={\n // If visible is explictly set to `false` then the tooltip should be hidden\n // Otherwise it should be visible or utilize the active state.\n visible !== false\n ? {\n opacity: visible ?? active ? 1 : 0,\n }\n : { opacity: 0 }\n }\n >\n {pointer && (\n <Pointer\n anchorRef={anchorRef}\n tooltipRef={tooltipRef}\n variant={variant}\n placement={placement}\n isFlipped={isFlipped}\n />\n )}\n\n <Panel variant={variant} p={1} {...rest}>\n {isText(content) ? <Text variant=\"xs\">{content}</Text> : content}\n </Panel>\n </Tip>\n </>\n )\n}\n\nconst Tip = styled(Box)<{ variant?: TooltipVariant }>`\n position: absolute;\n transition: opacity 250ms ease-out;\n text-align: left;\n box-shadow: ${themeGet(\"effects.dropShadow\")};\n cursor: default;\n pointer-events: none;\n font-weight: normal;\n font-style: normal;\n ${variant({ variants: TOOLTIP_VARIANTS })}\n`\n\nconst Panel = styled(Box)<{ variant?: TooltipVariant }>`\n ${variant({ variants: TOOLTIP_VARIANTS })}\n`\n\nconst compose = (a?: (...args: any) => any, b?: (...args: any) => any) => {\n return (...args) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AAA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AQ,GAAGA;MAAO,EAC1D;IAAA,EACJ;EAAA,EACL;AAEP,CAAC;AAAAP,OAAA,CAAAK,OAAA,GAAAA,OAAA;AAED,MAAMqC,GAAG,GAAG,IAAAS,yBAAM,EAACC,QAAG,CAAC,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,yKAIP,IAAAC,kBAAQ,EAAC,oBAAoB,CAAC,EAK1C,IAAA5C,qBAAO,EAAC;EAAE6C,QAAQ,EAAE1D;AAAiB,CAAC,CAAC,CAC1C;AAED,MAAMgD,KAAK,GAAG,IAAAI,yBAAM,EAACC,QAAG,CAAC,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,aACrB,IAAA3C,qBAAO,EAAC;EAAE6C,QAAQ,EAAE1D;AAAiB,CAAC,CAAC,CAC1C;AAED,MAAMqC,OAAO,GAAGA,CAACsB,CAAyB,EAAEC,CAAyB,KAAK;EACxE,OAAO,CAAC,GAAGC,IAAI,KAAK;IAClBF,CAAC,GAAG,GAAGE,IAAI,CAAC;IACZD,CAAC,GAAG,GAAGC,IAAI,CAAC;EACd,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"Tooltip.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_styledSystem","_helpers","_usePosition","_Box","_Pointer","_Text","_themeGet","_jsxRuntime","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TOOLTIP_VARIANTS","exports","defaultLight","backgroundColor","color","defaultDark","Tooltip","children","content","width","offset","placement","pointer","variant","visible","zIndex","rest","active","setActive","useState","handleClick","prevActive","activate","deactivate","arrowRef","useRef","anchorRef","tooltipRef","floatingStyles","context","rects","usePosition","position","jsxs","Fragment","React","cloneElement","ref","tabIndex","onClick","compose","props","onMouseOver","onMouseOut","onFocus","onBlur","Tip","style","opacity","jsx","Pointer","Panel","p","isText","Text","styled","Box","withConfig","displayName","componentId","themeGet","variants","a","b","args"],"sources":["../../../../src/elements/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\"\nimport styled from \"styled-components\"\nimport { variant } from \"styled-system\"\nimport { isText } from \"../../helpers\"\nimport { Position, usePosition } from \"../../utils/usePosition\"\nimport { Box, BoxProps } from \"../Box\"\nimport { Pointer } from \"../Pointer\"\nimport { Text } from \"../Text\"\nimport { themeGet } from \"@styled-system/theme-get\"\n\nexport const TOOLTIP_VARIANTS = {\n defaultLight: {\n backgroundColor: \"mono0\",\n color: \"mono100\",\n },\n defaultDark: {\n backgroundColor: \"mono100\",\n color: \"mono0\",\n },\n}\n\nexport type TooltipVariant = keyof typeof TOOLTIP_VARIANTS\n\nexport interface TooltipProps extends BoxProps {\n /** Anchor element to attach to tooltip */\n children: React.ReactElement<any, string | React.JSXElementConstructor<any>>\n /** Content of tooltip */\n content: React.ReactNode\n offset?: number\n placement?: Position\n pointer?: boolean\n variant?: TooltipVariant\n visible?: boolean\n}\n\n/**\n * A tooltip\n */\nexport const Tooltip: React.FC<React.PropsWithChildren<TooltipProps>> = ({\n children,\n content,\n width = 230,\n offset = 10,\n placement = \"top\",\n pointer = false,\n variant = \"defaultLight\",\n visible,\n zIndex = 1,\n ...rest\n}) => {\n const [active, setActive] = useState(false)\n\n const handleClick = () => {\n setActive((prevActive) => !prevActive)\n }\n\n const activate = () => {\n setActive(true)\n }\n\n const deactivate = () => {\n setActive(false)\n }\n\n const arrowRef = useRef<SVGSVGElement | null>(null)\n\n const {\n anchorRef,\n tooltipRef,\n floatingStyles,\n context,\n rects,\n } = usePosition({\n position: placement,\n offset,\n active: visible ?? active,\n arrowRef: arrowRef as React.RefObject<Element | null>,\n })\n\n return (\n <>\n {React.cloneElement(children, {\n ref: anchorRef,\n tabIndex: 0,\n onClick: compose(handleClick, children.props?.onClick),\n onMouseOver: compose(activate, children.props?.onMouseOver),\n onMouseOut: compose(deactivate, children.props?.onMouseOut),\n onFocus: compose(activate, children.props?.onFocus),\n onBlur: compose(deactivate, children.props?.onBlur),\n })}\n\n <Tip\n ref={tooltipRef as any}\n variant={variant}\n width={width}\n zIndex={zIndex}\n style={{\n ...floatingStyles,\n // If visible is explictly set to `false` then the tooltip should be hidden\n // Otherwise it should be visible or utilize the active state.\n opacity: visible !== false ? (visible ?? active ? 1 : 0) : 0,\n }}\n >\n {pointer && (\n <Pointer\n ref={arrowRef}\n context={context}\n rects={rects}\n variant={variant}\n />\n )}\n\n <Panel variant={variant} p={1} {...rest}>\n {isText(content) ? <Text variant=\"xs\">{content}</Text> : content}\n </Panel>\n </Tip>\n </>\n )\n}\n\nconst Tip = styled(Box)<{ variant?: TooltipVariant }>`\n transition: opacity 250ms ease-out;\n text-align: left;\n box-shadow: ${themeGet(\"effects.dropShadow\")};\n cursor: default;\n pointer-events: none;\n font-weight: normal;\n font-style: normal;\n ${variant({ variants: TOOLTIP_VARIANTS })}\n`\n\nconst Panel = styled(Box)<{ variant?: TooltipVariant }>`\n ${variant({ variants: TOOLTIP_VARIANTS })}\n`\n\nconst compose = (a?: (...args: any) => any, b?: (...args: any) => any) => {\n return (...args) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAE,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAA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A,EACJ;EAAA,EACL;AAEP,CAAC;AAAAP,OAAA,CAAAK,OAAA,GAAAA,OAAA;AAED,MAAMwC,GAAG,GAAG,IAAAS,yBAAM,EAACC,QAAG,CAAC,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,uJAGP,IAAAC,kBAAQ,EAAC,oBAAoB,CAAC,EAK1C,IAAA/C,qBAAO,EAAC;EAAEgD,QAAQ,EAAE7D;AAAiB,CAAC,CAAC,CAC1C;AAED,MAAMmD,KAAK,GAAG,IAAAI,yBAAM,EAACC,QAAG,CAAC,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,aACrB,IAAA9C,qBAAO,EAAC;EAAEgD,QAAQ,EAAE7D;AAAiB,CAAC,CAAC,CAC1C;AAED,MAAMwC,OAAO,GAAGA,CAACsB,CAAyB,EAAEC,CAAyB,KAAK;EACxE,OAAO,CAAC,GAAGC,IAAI,KAAK;IAClBF,CAAC,GAAG,GAAGE,IAAI,CAAC;IACZD,CAAC,GAAG,GAAGC,IAAI,CAAC;EACd,CAAC;AACH,CAAC"}
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+ import { Placement, AutoPlacementOptions, FlipOptions } from "@floating-ui/react";
1
3
  export declare const POSITION: {
2
4
  readonly "top-start": "top-start";
3
5
  readonly top: "top";
@@ -13,16 +15,29 @@ export declare const POSITION: {
13
15
  readonly "right-end": "right-end";
14
16
  };
15
17
  export type Position = keyof typeof POSITION;
16
- interface TargetPosition {
17
- x: number;
18
- y: number;
18
+ export type PositionFlip = boolean | FlipOptions;
19
+ export type PositionAutoPlacement = boolean | AutoPlacementOptions;
20
+ /** Element rects captured mid-middleware-chain. */
21
+ export interface PositionRects {
22
+ reference: {
23
+ width: number;
24
+ height: number;
25
+ x: number;
26
+ y: number;
27
+ };
28
+ floating: {
29
+ width: number;
30
+ height: number;
31
+ x: number;
32
+ y: number;
33
+ };
19
34
  }
20
35
  /**
21
36
  * Will position the floating element (tooltip) relative to the anchor element,
22
37
  * using `position: fixed` and in such a way that it shouldn't ever appear
23
38
  * partially offscreen and will move correctly when the parent is scrolled.
24
39
  */
25
- export declare const usePosition: ({ key, position, offset, active, flip, clamp, padding, }: {
40
+ export declare const usePosition: ({ key, position, offset, active, flip, clamp, padding, autoPlacement, arrowRef, onOpenChange, }: {
26
41
  /** Listen to changes on this value */
27
42
  key?: string | number | boolean;
28
43
  /** Placement relative to anchor */
@@ -31,46 +46,65 @@ export declare const usePosition: ({ key, position, offset, active, flip, clamp,
31
46
  offset?: number;
32
47
  /** Optionally disable for performance (default: `true`) */
33
48
  active?: boolean;
34
- /** Optionally disable flipping (default: `true`) */
35
- flip?: boolean;
36
- /** Optionally disable clamping (default: `true`) */
49
+ /**
50
+ * Flip to the opposite side when there is no space. Cannot be combined with
51
+ * `autoPlacement`. (default: `true`)
52
+ */
53
+ flip?: PositionFlip;
54
+ /** Optionally disable clamping along the axis (default: `true`) */
37
55
  clamp?: boolean;
38
56
  /** Add boundary padding (default: `0`) used when clamping */
39
57
  padding?: number;
58
+ /**
59
+ * When true, automatically selects the placement with the most available
60
+ * space instead of using `flip`. Mutually exclusive with `flip`.
61
+ * (default: `false`)
62
+ */
63
+ autoPlacement?: PositionAutoPlacement;
64
+ /**
65
+ * Ref to the arrow/pointer element. When provided, the `arrow()` middleware
66
+ * is added so that `arrowData` is populated with the exact x/y offset needed
67
+ * to keep the arrow pointing at the anchor even after shift clamping.
68
+ */
69
+ arrowRef?: React.RefObject<Element | null>;
70
+ /**
71
+ * Called by Floating UI interaction hooks (useHover, useClick, useDismiss)
72
+ * whenever they want to open or close the floating element.
73
+ * `reason` identifies the source ('hover', 'click', 'escape-key', etc.).
74
+ */
75
+ onOpenChange?: (open: boolean, event?: Event, reason?: string) => void;
40
76
  }) => {
41
- tooltipRef: import("react").MutableRefObject<HTMLElement | null>;
42
- anchorRef: import("react").MutableRefObject<HTMLElement | null>;
77
+ tooltipRef: React.MutableRefObject<HTMLElement | null>;
78
+ anchorRef: React.MutableRefObject<HTMLElement | null>;
79
+ resolvedPlacement: Position;
80
+ arrowData: {
81
+ x?: number;
82
+ y?: number;
83
+ } | undefined;
84
+ rects: PositionRects | undefined;
85
+ context: {
86
+ x: number;
87
+ y: number;
88
+ placement: Placement;
89
+ strategy: import("@floating-ui/utils").Strategy;
90
+ middlewareData: import("@floating-ui/core").MiddlewareData;
91
+ isPositioned: boolean;
92
+ update: () => void;
93
+ floatingStyles: React.CSSProperties;
94
+ open: boolean;
95
+ onOpenChange: (open: boolean, event?: Event, reason?: import("@floating-ui/react").OpenChangeReason) => void;
96
+ events: import("@floating-ui/react").FloatingEvents;
97
+ dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
98
+ nodeId: string | undefined;
99
+ floatingId: string | undefined;
100
+ refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
101
+ elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
102
+ };
43
103
  state: {
44
104
  isFlipped: boolean;
45
105
  };
106
+ floatingStyles: React.CSSProperties;
46
107
  };
47
- interface PlaceTooltip {
48
- anchor: HTMLElement;
49
- tooltip: HTMLElement;
50
- position: Position;
51
- offset?: number;
52
- boundaryRect?: DOMRect;
53
- flip?: boolean;
54
- clamp?: boolean;
55
- padding?: number;
56
- }
57
- export declare const placeTooltip: ({ anchor, tooltip, position, offset, boundaryRect, flip, clamp, padding, }: PlaceTooltip) => {
58
- isFlipped: boolean;
59
- };
60
- export declare const getPosition: ({ elementRect, tooltipRect, position, }: {
61
- elementRect: Pick<DOMRect, "width" | "height" | "top" | "right" | "bottom" | "left">;
62
- tooltipRect: Pick<DOMRect, "width" | "height">;
63
- position: Position;
64
- }) => TargetPosition;
65
- export declare const translateWithOffset: (targetPosition: TargetPosition, position: Position, offset: number) => string;
66
- export declare const getDocumentBoundingRect: () => DOMRect;
67
- interface ShouldFlip {
68
- targetPosition: TargetPosition;
69
- position: Position;
70
- boundaryRect: Pick<DOMRect, "top" | "right" | "bottom" | "left">;
71
- tooltipRect: Pick<DOMRect, "width" | "height">;
72
- }
73
- export declare const shouldFlip: ({ targetPosition, position, boundaryRect, tooltipRect, }: ShouldFlip) => boolean;
74
108
  /**
75
109
  * Calculate the maximum height available for a tooltip based on its placement and viewport constraints.
76
110
  */
@@ -79,4 +113,3 @@ export declare const calculateMaxHeight: ({ anchorRect, position, offset, }: {
79
113
  position: Position;
80
114
  offset?: number;
81
115
  }) => number;
82
- export {};