exlab_wizard.ui.components.credential_field#

Credential field component (Frontend Spec §7.4.1).

Three resting / transient states:

  • not_setStatus: Not set with a [Set] button.

  • setStatus: Set with [Replace] and [Clear].

  • editing – inline password input with Save / Cancel.

Never displays a stored secret.

Functions

begin_edit(state)

Return the editing state, remembering state as the resting target.

cancel_edit(state)

Return the resting state to collapse to when an edit is cancelled.

clear_credential(state)

Return the state after the operator confirms a Clear action.

commit_edit(state, typed_value)

Resolve a Save click.

credential_field(*, label, on_save, on_clear)

Build a credential row (Frontend Spec §7.4.1).

credential_props(state)

Compute the visible labels / button names for a state.

Classes

CredentialState([state, resting])

In-memory state for a credential row.

class exlab_wizard.ui.components.credential_field.CredentialState(state='not_set', resting='not_set')[source]#

Bases: object

In-memory state for a credential row.

resting records which resting state (not_set / set) the row should collapse back to when the operator cancels an edit – a fresh Set cancels back to not_set, a Replace cancels back to set.

Parameters:
resting: str = 'not_set'#
state: str = 'not_set'#
exlab_wizard.ui.components.credential_field.begin_edit(state)[source]#

Return the editing state, remembering state as the resting target.

Idempotent: calling it on an already-editing row leaves resting untouched so a stray double-click does not lose the original resting state.

Parameters:

state (CredentialState)

Return type:

CredentialState

exlab_wizard.ui.components.credential_field.cancel_edit(state)[source]#

Return the resting state to collapse to when an edit is cancelled.

Parameters:

state (CredentialState)

Return type:

CredentialState

exlab_wizard.ui.components.credential_field.clear_credential(state)[source]#

Return the state after the operator confirms a Clear action.

Parameters:

state (CredentialState)

Return type:

CredentialState

exlab_wizard.ui.components.credential_field.commit_edit(state, typed_value)[source]#

Resolve a Save click.

Returns (new_state, should_save). A non-empty typed_value transitions the row to set and signals the caller to invoke its on_save callback; an empty value has nothing to persist, so the row stays in the editor and should_save is False.

Parameters:
Return type:

tuple[CredentialState, bool]

exlab_wizard.ui.components.credential_field.credential_field(*, label, on_save, on_clear, initial_state=None, data_testid=None)[source]#

Build a credential row (Frontend Spec §7.4.1).

Three states drive the row: not_set shows a [Set] button; set shows [Replace] + [Clear]; editing reveals an inline password input with Save / Cancel. on_save is invoked with the typed password when the operator clicks Save with a non-empty value; on_clear is invoked when the operator confirms the Clear action. The stored secret is never displayed.

The row re-renders itself in place on every state transition via a NiceGUI @ui.refreshable body, so the input box, status line, and buttons always reflect the current state.

data_testid, when supplied, is the base for the row’s e2e hooks: <base>-status / -primary / -secondary / -input / -save / -cancel / -clear-confirm.

Parameters:
Return type:

Any

exlab_wizard.ui.components.credential_field.credential_props(state)[source]#

Compute the visible labels / button names for a state.

Returns a dict with state, label, primary_button, secondary_button (optional), and input_visible keys.

Parameters:

state (CredentialState)

Return type:

dict[str, Any]