Class Dsm<T>

Extended dataset manager with state machine.

Type Parameters

  • T extends object

    Object type representing table structure.

Hierarchy (View Summary)

Constructors

  • Creates an instance of Dsm.

    Type Parameters

    • T extends object

    Parameters

    • params: { core: DsCore<T>; debug?: boolean; hooks?: DsCommonHooks; useClone?: boolean }

      Initialization parameters.

      • core: DsCore<T>

        Core dataset structure.

      • Optionaldebug?: boolean

        Debug mode flag.

      • Optionalhooks?: DsCommonHooks

        Hooks configuration.

      • OptionaluseClone?: boolean

        Whether to use cloning.

    Returns Dsm<T>

Accessors

  • get busy(): boolean

    Checks if the current state is busy (not normal).

    Returns boolean

    true if the state is busy, otherwise false.

  • get isAppling(): boolean

    Checks if the current state is applying.

    Returns boolean

    true if the state is applying, otherwise false.

  • get isNormal(): boolean

    Checks if the current state is normal.

    Returns boolean

    true if the state is normal, otherwise false.

  • get isStarting(): boolean

    Checks if the current state is starting.

    Returns boolean

    true if the state is starting, otherwise false.

  • get isSubmitting(): boolean

    Checks if the current state is submitting.

    Returns boolean

    true if the state is submitting, otherwise false.

  • get mode(): string

    Gets the current mode.

    Returns string

    The current mode name.

  • get rowCnt(): undefined | number

    Gets the row count of the first table. tables[0], useful for single table case

    Returns undefined | number

    The number of rows in the first table or undefined if no tables exist.

  • get rowSel(): undefined | Loc

    Gets the selected row location if only one row is selected. Row loc of rowsSel[0], useful for single selection case

    Returns undefined | Loc

    The selected row location or undefined if multiple or no rows are selected.

  • get rowSelRef(): undefined | T

    Gets the reference to the selected row if only one row is selected. Row reference of rowsSel[0], useful for single selection case

    Returns undefined | T

    The selected row or undefined if multiple or no rows are selected.

  • get rowsSel(): Loc[]

    Gets the selected row locations.

    Returns Loc[]

    An array of selected row locations.

  • get rowsSelRef(): T[]

    Gets references to the selected rows.

    Returns T[]

    An array of selected row values.

  • get stateStr(): string

    Gets the current state as a string.

    Returns string

    The string representation of the current state.

  • get status(): { mode: string; state: DsState }

    Gets the current status.

    Returns { mode: string; state: DsState }

    The current mode and state.

  • get table(): undefined | T[]

    Gets the first table from the core tables. tables[0], useful for single table case

    Returns undefined | T[]

    The first table or undefined if no tables exist.

  • get tables(): T[][]

    Gets all tables in the dataset.

    Returns T[][]

    A two-dimensional array representing the tables.

  • get tablesCnt(): number

    Gets the total number of tables in the dataset.

    Returns number

    The number of tables.

  • get tableSel(): undefined | number

    Gets the selected table index if only one table is selected. table tid of tablesSel[0], useful for single selection case

    Returns undefined | number

    The selected table index or undefined if multiple or no tables are selected.

  • get tableSelRef(): T[]

    Gets the reference to the selected table if only one table is selected. table reference of tablesSel[0], useful for single selection case

    Returns T[]

    The selected table or an empty array if multiple or no tables are selected.

  • get tablesSel(): number[]

    Gets the selected table indices.

    Returns number[]

    An array of selected table indices.

  • get tablesSelRef(): T[][]

    Gets references to the selected tables.

    Returns T[][]

    A two-dimensional array of selected tables.

Methods

  • Applies the current process and updates the state accordingly.

    Parameters

    • Optionaloption: "cancel"

      Determines how the state transitions:

      • undefined: Moves to Appling state and triggers processing.
      • "cancel": Reverts to the previous state.

    Returns boolean

    true if the application was successful, otherwise false.

    If an unknown option is provided in pure JavaScript environments.

  • Handles row selection on mouse click with support for multi-selection modes. Only intended for frontend usage.

    Parameters

    • row: Loc | T

      The row reference or location.

    • e: MouseEvent

      The mouse event triggering the selection.

    • Optionalsort: "reverse" | "forward"

      The sorting direction.

    Returns { success: boolean }

    An object indicating whether the selection was successful.

  • Handles table selection on mouse click with support for multi-selection modes. Only intended for frontend usage.

    Parameters

    • table: number | T[]

      The table reference or index.

    • e: MouseEvent

      The mouse event triggering the selection.

    • Optionalsort: "reverse" | "forward"

      The sorting direction.

    Returns { success: boolean }

    An object indicating whether the selection was successful.

  • Deselects all selected tables and rows.

    Returns void

  • Retrieves the mode configuration registry or a specific mode's configuration.

    Parameters

    • Optionalmode: string

      The mode to retrieve the configuration for.

    Returns undefined | DsModeConfig<any> | Record<string, DsModeConfig<any>>

    The entire mode registry if no mode is specified, otherwise the configuration for the given mode.

  • Find row if a row exists at the given location(loc).

    Parameters

    • loc: Loc

      The location of the row, containing table and row indices.

    Returns { found: boolean; rowRef: undefined | T }

    An object indicating whether the row exists and its reference if found.

  • Find row if a given row reference exists in any table.

    Parameters

    • rowRef: T

      The reference to the row.

    Returns { found: boolean; loc: Loc; row?: T }

    An object indicating whether the row reference exists, its location if found, and the row itself.

  • Find table if a table exists at the given index(tid).

    Parameters

    • t: number

      The index of the table.

    Returns { found: boolean; tableRef: undefined | T[] }

    An object indicating whether the table exists and its reference if found.

  • Find table if a given table reference exists in the core tables.

    Parameters

    • tableRef: T[]

      The reference to the table.

    Returns { found: boolean; tid: number }

    An object indicating whether the table reference exists and its index if found.

  • Checks if both the current mode and state match the specified values.

    Parameters

    • mode: string

      The mode to check.

    • state: DsState

      The state to check.

    Returns boolean

    true if both the mode and state match, otherwise false.

  • Checks if the current mode matches the specified mode.

    Parameters

    • mode: string

      The mode to check.

    Returns boolean

    true if the current mode matches, otherwise false.

  • Checks if a table or row (by index or location) is selected.

    Parameters

    • index: number | Loc

      The table index or row location.

    Returns boolean

    True if the table or row is selected, otherwise false.

  • Checks if a row at the given location is selected.

    Parameters

    • loc: Loc

      The row location.

    Returns boolean

    True if the row is selected, otherwise false.

  • Checks if a row reference is selected.

    Parameters

    • rowRef: T

      The row reference.

    Returns boolean

    True if the row is selected, otherwise false.

  • Checks if a table with the given index is selected.

    Parameters

    • tid: number

      The table index.

    Returns boolean

    True if the table is selected, otherwise false.

  • Checks if a table reference is selected.

    Parameters

    • tableRef: T[]

      The table reference.

    Returns boolean

    True if the table is selected, otherwise false.

  • Checks if the current state matches the specified state.

    Parameters

    Returns boolean

    true if the current state matches, otherwise false.

  • Checks if all given row locations are valid.

    Parameters

    • locs: Loc[]

      The array of row locations.

    Returns boolean

    True if all row locations are valid, otherwise false.

  • Checks if the specified mode is registered.

    Parameters

    • mode: string

      The mode to check.

    Returns boolean

    true if the mode is registered, otherwise false.

  • Checks if all given table IDs are valid.

    Parameters

    • tids: number[]

      The array of table IDs.

    Returns boolean

    True if all table IDs are valid, otherwise false.

  • Registers a new mode with an optional configuration.

    Type Parameters

    • D

      The data type associated with the mode.

    Parameters

    • mode: string

      The name of the mode to register.

    • Optionalconfig: DsModeConfig<D>

      Optional configuration for the mode.

    Returns void

    If the mode is already registered or contains invalid characters.

  • Manipulates rows based on selection and placement rules.

    Parameters

    • Optionalsource: T[]
    • Optionaltarget: {
          changeSel?: boolean;
          place?: "above" | "replace" | "below";
          select?: number[] | Loc[] | "tables" | "rows";
          useClone?: boolean;
          which?: "top" | "all" | "bottom";
      }

    Returns { success: boolean }

    rows (full documentation in main implementation)

  • Modifies rows or creates new tables based on placement rules.

    Parameters

    • source: T[]
    • Optionaltarget: {
          changeSel?: boolean;
          place?: "newTableAbove" | "newTableBelow";
          select?: number[] | "tables";
          useClone?: boolean;
          which?: "top" | "all" | "bottom";
      }

    Returns { success: boolean }

    rows (full documentation in main implementation)

  • Converts row references to their corresponding locations.

    Parameters

    • rows: T[]

      An array of row references.

    Returns { foundAll: boolean; locs: Loc[] }

    An object indicating whether all rows were found and their corresponding locations.

  • Selects a row by its reference or location.

    Parameters

    • row: Loc | T

      The row reference or location.

    • Optionaloption: { multiMode?: MultiMode; sort?: "reverse" | "forward" }

      Selection options, including multi-selection mode and sorting direction.

    Returns { success: boolean }

    An object indicating whether the selection was successful.

  • Selects a table by its reference or index(tid).

    Parameters

    • table: number | T[]

      The table reference or index.

    • Optionaloption: { multiMode?: MultiMode; sort?: "reverse" | "forward" }

      Selection options, including multi-selection mode and sorting direction.

    Returns { success: boolean }

    An object indicating whether the selection was successful.

  • Sorts the selected rows based on table and row indices in the specified direction.

    Parameters

    • Optionaldirection: "reverse" | "forward"

      The sorting direction, defaults to "forward".

    Returns void

  • Sorts the selected table indices in the specified direction.

    Parameters

    • Optionaldirection: "reverse" | "forward"

      The sorting direction, defaults to "forward".

    Returns void

  • Starts a new mode and updates the state accordingly. Fsm start point, start the specified mode

    Parameters

    • mode: string

      The mode to start.

    • Optionaloption: "submitted" | "applied"

      Determines how the state transitions:

      • undefined: Moves to Starting state.
      • "submitted": Skips Starting and moves directly to Submitting state.
      • "applied": Skips Starting and Submitting, moves directly to Appling state, and triggers processing.

    Returns boolean

    true if the mode was successfully started, otherwise false.

    If an unknown option is provided in pure JavaScript environments.

  • Submits the current process and updates the state accordingly.

    Parameters

    • Optionaloption: "applied" | "cancel"

      Determines how the state transitions:

      • undefined: Moves to Submitting state.
      • "cancel": Cancels the process and returns to Normal state.
      • "applied": Skips Submitting, moves directly to Appling state, and triggers processing.

    Returns boolean

    true if the submission was successful, otherwise false.

    If an unknown option is provided in pure JavaScript environments.

  • Converts table references to their corresponding table indices.

    Parameters

    • tables: T[][]

      An array of table references.

    Returns { foundAll: boolean; tids: number[] }

    An object indicating whether all tables were found and their corresponding indices.