import { Area } from 'react-easy-crop/types'; import { OverridableComponent } from '@material-ui/core/OverridableComponent'; import { IconProps, SvgIconTypeMap } from '@material-ui/core'; import React, { Dispatch } from 'react'; import { Maybe } from '../../util/types'; import { Color, Font } from '../../hooks/useFetch'; import { MetaWord } from '../../util/typesetting'; import { NoteState } from '../../util/svg'; export type { NoteState } from '../../util/svg'; export declare type FlowStep = 0 | 1 | 2 | 3 | 4 | -1; export declare type EditorHeader = { title: string; type: 'image' | 'text'; }; export declare type Snackbar = { id: number; message: string; }; export declare type ErrorModal = { title: string; message: string; confirmText?: string; cancelText?: string; onConfirm?: () => void; onCancel?: () => void; }; export declare type EditorDrawer = { isVisible?: boolean; title: string; type: 'color' | 'font' | 'ideas' | 'layout'; /** * If `true`, the drawer should use the overlay. */ isTemporary?: boolean; /** * Provide an optional icon for the drawer header. */ Icon?: React.FC | React.FC> | OverridableComponent, 'svg'>>; }; export declare type LayoutOption = 'note' | 'image' | 'both'; export interface ScaledFont extends Font { containerWidth: number; containerHeight: number; scaleFactor: number; } export interface CropData extends Area { rotation: number; } export interface LoadedNote extends NoteState { noteResourceId: number | string; message: string; } export declare const BAD_WORDS_MESSAGE = "Sorry, certain words in your message violate our Content Policy. They have been changed to asterisks."; export declare const UNSUPPORTED_CHARS_MESSAGE: (characters: string[]) => string; export interface PersonalizationState extends NoteState { /** * @default 'both' */ layout: LayoutOption; /** * User's personal message. */ message: string; /** * Message broken into lines. */ messageLines: MetaWord[][]; /** * Boolean indicating whether a gift card order * was included in the personalization options */ hasGiftCard: boolean; /** * Current flow step. * @default 0 */ activeStep: FlowStep; /** max ammount of steps in the flow */ progressMax: number; /** * Previous flow step. */ prevStep?: Omit; /** * When provided, the editor header will appear. * @default null */ editorHeader?: Maybe; /** * List of snackbars shown to the user; an empty array means none are provided * @default [] */ snackbar: Snackbar[]; /** * When provided, error modal appears. Defaults to generic messages. */ errorModal?: Maybe; /** * Data for image cropping. */ cropData?: Maybe; /** * Currently loading an existing note. * @default false */ isLoadingNote: boolean; /** * Colors provided by embla. * @default [] */ colors: Color[]; /** * Fonts provided by embla. * @default [] */ fonts: Font[]; /** * Persistent drawer, if it should be visible. This drawer pushes other * content in the flow up when it renders. */ editorDrawer?: Maybe; showMessageTextarea: boolean; /** * Font scaled for WYSIWYG */ scaledFont: ScaledFont; /** * Note resource to look up if editing an existing note. Copied to state * from props so that sasquatch can control it for new notes. */ internalNoteResourceId?: number | string; isSavingNote: boolean; svg?: Maybe; /** * Max canvas dimensions for the device determined by canvas-size. */ canvasLimitation?: { width: number; height: number; }; isMessageNearLimit: boolean; isMessageTooLong: boolean; badWords: string[]; /** * File uploaded by the user. */ originalImageBlob?: Maybe; /** * Cropped image file we create. We upload this to cloudinary. */ croppedImageBlob?: Maybe; /** * Image url for preview created in the browser before upload. */ croppedImageSrc?: Maybe; /** * Cloudinary-hosted version of the uploaded and cropped image, which gets * attached to the note. */ cloudinaryImageSrc?: Maybe; /** * Dictates whether or not the confirmation dialog appears on close. * @default false */ shouldConfirmBeforeClose: boolean; } interface Props { children: React.ReactNode; } interface NoteChange extends Omit { message?: string; } export declare type Action = { type: T; payload?: P; }; export declare type ActionTypes = Action<'SET_IMAGE_SRC', Maybe<{ src: string; file: File | Blob; }>> | Action<'SET_CROPPED_IMAGE_SRC', Maybe> | Action<'SET_CROPPED_IMAGE_BLOB', Maybe> | Action<'SET_CROPPED_IMAGE', { blob: Blob; url: string; }> | Action<'SET_CROP_DATA', Maybe> | Action<'SET_ACTIVE_STEP', FlowStep> | Action<'NEXT'> | Action<'BACK'> | Action<'SET_MESSAGE', string> | Action<'SHOW_EDITOR_HEADER', EditorHeader> | Action<'HIDE_EDITOR_HEADER'> | Action<'SHOW_SNACKBAR', string> | Action<'HIDE_SNACKBAR', Snackbar> | Action<'SHOW_MESSAGE_TEXTAREA'> | Action<'HIDE_MESSAGE_TEXTAREA'> | Action<'SET_EDITOR_DRAWER', EditorDrawer> | Action<'HIDE_EDITOR_DRAWER'> | Action<'SHOW_ERROR_MODAL', ErrorModal> | Action<'HIDE_ERROR_MODAL'> | Action<'SET_LOADING_NOTE', boolean> | Action<'SET_COLORS', Color[]> | Action<'SET_FONTS', Font[]> | Action<'SET_COLOR', Maybe> | Action<'SET_FONT', Font> | Action<'SET_SCALED_FONT', ScaledFont> | Action<'SET_ALIGNMENT', string> | Action<'SET_NOTE_STATE', LoadedNote> | Action<'SET_LAYOUT', LayoutOption> | Action<'SET_INTERNAL_NOTE_RESOURCE_ID', number | string> | Action<'SET_SVG', Maybe> | Action<'SET_SAVING_NOTE', boolean> | Action<'SET_CANVAS_LIMITATION', { width: number; height: number; }> | Action<'SAVE_NOTE_RESULT', { id: string | number; cloudinaryUrl?: Maybe; }> | Action<'SAVING_NOTE_FAILED'> | Action<'REMOVE_IMAGE'> | Action<'RESET_NOTE_CHANGES', NoteChange> | Action<'SET_SHOULD_CONFIRM_BEFORE_CLOSE', boolean> | Action<'SET_HAS_GIFT_CARD', boolean>; export declare type StateContextType = [ state: PersonalizationState, dispatch: Dispatch ]; export declare const StateContext: React.Context; declare const StateProvider: ({ children }: Props) => JSX.Element; export declare const useStateContext: () => StateContextType; export default StateProvider;