Skip to content

Commit

Permalink
feat: add GeneratedIdElement
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Dec 19, 2024
1 parent 9b8612f commit 15db8d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions questionpy_common/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"CheckboxGroupElement",
"FormElement",
"FormSection",
"GeneratedIdElement",
"GroupElement",
"HiddenElement",
"Option",
Expand Down Expand Up @@ -167,13 +168,23 @@ class RepetitionElement(_BaseElement):
"""Elements that will be repeated."""


class GeneratedIdElement(_BaseElement):
"""Generates a unique ID which won't change across form saves.
Useful to distinguish repetitions without relying on their index, which may change when repetitions are removed.
"""

kind: Literal["id"] = "id"


FormElement: TypeAlias = Annotated[
CheckboxElement
| CheckboxGroupElement
| GroupElement
| HiddenElement
| RadioGroupElement
| RepetitionElement
| GeneratedIdElement
| SelectElement
| StaticTextElement
| TextInputElement
Expand Down

0 comments on commit 15db8d8

Please sign in to comment.