import * as Eq from 'fp-ts/lib/Eq'; import { Functor1 } from 'fp-ts/lib/Functor'; import * as O from 'fp-ts/lib/Option'; import * as Show from 'fp-ts/lib/Show'; import * as RAZ from '@monorail/sharedHelpers/fp-ts-ext/ReadonlyArrayZipper'; /** * A variant of ReadonlyArrayOrZipper which represents the case where no item is selected */ export declare type IsReadonlyArray = { readonly tag: 'isReadonlyArray'; readonly value: ReadonlyArray; }; /** * A variant of ReadonlyArrayOrZipper which represents the case where an item is selected */ export declare type IsReadonlyArrayZipper = { readonly tag: 'isReadonlyArrayZipper'; readonly value: RAZ.ReadonlyArrayZipper; }; /** * Represents a an array-like structure where zero or one item is focused/selected. This is basically a tagged union * with a member that is just a ReadonlyArray and a member that is a ReadonlyArrayZipper. Focus can be set or unset * by using functions that might switch the value between these types. * * If you need a collection that is guaranteed to have a single item focused/selected at all times, see ReadonlyArrayZipper. * * The purpose of this is to make sure the selected item is tracked as an actual member of the collection and not * an optional value that is tracked off to the side. The selected item is a first-class member of the collection. */ export declare type ReadonlyArrayOrZipper = IsReadonlyArray | IsReadonlyArrayZipper; /** * Constructs the variant that has no focus (ReadonlyArray) */ export declare const makeWithNoFocus: (value: readonly A[]) => IsReadonlyArray; /** * Alias for `makeWithNoFocus` */ export declare const makeWithReadonlyArray: (value: readonly A[]) => IsReadonlyArray; /** * Constructs the variant that has a focused value (ReadonlyArrayZipper) */ export declare const makeWithFocus: (value: RAZ.ReadonlyArrayZipper) => IsReadonlyArrayZipper; /** * Alias for `makeWithFocus` */ export declare const makeWithReadonlyArrayZipper: (value: RAZ.ReadonlyArrayZipper) => IsReadonlyArrayZipper; /** * Constructs with the given value at the focus */ export declare const of: (focus: A) => ReadonlyArrayOrZipper; /** * Constructs an empty ReadonlyArrayOrZipper, which is the variant with no focus (and no values) */ export declare const empty: ReadonlyArrayOrZipper; /** * Converts the given value to a ReadonlyArray with each item and an indicator for each item for whether it was focused */ export declare const toReadonlyArrayWithFocusFlag: (fa: ReadonlyArrayOrZipper) => readonly { value: A; isFocus: boolean; }[]; /** * Converts the given value to a ReadonlyArray */ export declare const toReadonlyArray: (fa: ReadonlyArrayOrZipper) => readonly A[]; /** * Indicates if the given value has a focused item */ export declare const hasFocus: (fa: ReadonlyArrayOrZipper) => boolean; /** * Gets the currently-focused value (if there is one) */ export declare const getFocus: (fa: ReadonlyArrayOrZipper) => O.Option; /** * Clears the focus (if there is one) */ export declare const clearFocus: (fa: ReadonlyArrayOrZipper) => IsReadonlyArray; /** * Attempts to move the focus to the given item by finding it in the collection */ export declare const find: (eq: Eq.Eq) => (item: A) => (fa: ReadonlyArrayOrZipper) => O.Option>; /** * Attempts to move the focus to the given item, and if no item is found, returns the input collection unchanged */ export declare const findOrKeep: (eq: Eq.Eq) => (item: A) => (fa: ReadonlyArrayOrZipper) => ReadonlyArrayOrZipper; /** * Attempts to move the focus to the given item, and if it's not found, clears the focus. */ export declare const findOrClear: (eq: Eq.Eq) => (item: A) => (fa: ReadonlyArrayOrZipper) => ReadonlyArrayOrZipper; /** * If the given item is none, clears the focus. If the given item is some, it attempts to focus on it. If the item is not found, * the focus is kept as-is. */ export declare const findOptionalOrKeep: (eq: Eq.Eq) => (oa: O.Option) => (fa: ReadonlyArrayOrZipper) => ReadonlyArrayOrZipper; /** * If the given item is none, clears the focus. If the given item is some, it attempts to focus on it. If the item is not found, * the focus is cleared. */ export declare const findOptionalOrClear: (eq: Eq.Eq) => (oa: O.Option) => (fa: ReadonlyArrayOrZipper) => ReadonlyArrayOrZipper; /** * Maps a function over the collection */ export declare const map_: (fa: ReadonlyArrayOrZipper, f: (a: A) => B) => ReadonlyArrayOrZipper; /** * Maps a function over the collection (pipeable) */ export declare const map: (f: (a: A) => B) => (fa: ReadonlyArrayOrZipper) => ReadonlyArrayOrZipper; export declare const URI = "ReadonlyArrayOrZipper"; export declare type URI = typeof URI; declare module 'fp-ts/lib/HKT' { interface URItoKind { ReadonlyArrayOrZipper: ReadonlyArrayOrZipper; } } export declare const getShow: (showA: Show.Show) => Show.Show>; export declare const getEq: (eqA: Eq.Eq) => Eq.Eq>; export declare const Functor: Functor1; export declare const readonlyArrayOrZipper: Functor1;