{"version":3,"file":"contexts.mjs","sources":["../../../src/primitives/EmojiPicker/contexts.ts"],"sourcesContent":["import type { Resolve } from \"@liveblocks/core\";\nimport { nn } from \"@liveblocks/core\";\nimport type { Dispatch, KeyboardEvent, SetStateAction } from \"react\";\nimport { createContext, useContext } from \"react\";\n\nimport type {\n  EmojiPickerData,\n  EmojiPickerInteraction,\n  EmojiPickerSelectionDirection,\n} from \"./types\";\n\ntype EmojiPickerContextData =\n  | {\n      data?: never;\n      error?: never;\n      isLoading: true;\n    }\n  | {\n      data: EmojiPickerData;\n      error?: never;\n      isLoading: false;\n    }\n  | {\n      data?: never;\n      error: Error;\n      isLoading: false;\n    };\n\nexport type EmojiPickerContext = Resolve<\n  EmojiPickerContextData & {\n    columns: number;\n    onSearch: (search: string) => void;\n    selectCurrentEmoji: () => void;\n    onEmojiSelect?: (emoji: string) => void;\n    selectedColumnIndex: number;\n    selectedRowIndex: number;\n    moveSelection: (\n      direction: EmojiPickerSelectionDirection,\n      event: KeyboardEvent<HTMLInputElement>\n    ) => void;\n    setPointerSelection: (columnIndex: number, rowIndex: number) => void;\n    interaction: EmojiPickerInteraction;\n    setInteraction: Dispatch<SetStateAction<EmojiPickerInteraction>>;\n  }\n>;\n\nexport const EmojiPickerContext = createContext<EmojiPickerContext | null>(\n  null\n);\n\nexport function useEmojiPicker(): EmojiPickerContext {\n  const emojiPickerContext = useContext(EmojiPickerContext);\n\n  return nn(\n    emojiPickerContext,\n    \"EmojiPicker.Root is missing from the React tree.\"\n  );\n}\n"],"names":[],"mappings":";;;AA8CO,MAAM,kBAAqB,GAAA,aAAA;AAAA,EAChC,IAAA;AACF,EAAA;AAEO,SAAS,cAAqC,GAAA;AACnD,EAAM,MAAA,kBAAA,GAAqB,WAAW,kBAAkB,CAAA,CAAA;AAExD,EAAO,OAAA,EAAA;AAAA,IACL,kBAAA;AAAA,IACA,kDAAA;AAAA,GACF,CAAA;AACF;;;;"}