git » sdk » commit 569f9b2

Parse cheogram extensions

author Stephen Paul Weber
2026-11-12 04:49:50 UTC
committer Stephen Paul Weber
2026-11-12 04:49:50 UTC
parent cfcc9c562e8b847bfe620b63cbff5bc560693324

Parse cheogram extensions

borogove/DataForm.hx +30 -2

diff --git a/borogove/DataForm.hx b/borogove/DataForm.hx
index a411611..04bceb1 100644
--- a/borogove/DataForm.hx
+++ b/borogove/DataForm.hx
@@ -59,6 +59,9 @@ abstract Field(Stanza) from Stanza to Stanza {
 	public var rangeMax(get, never): Null<String>;
 	public var regex(get, never): Null<String>;
 	public var required(get, never): Bool;
+	public var mediaSelector(get, never): Bool;
+	public var prefixLabel(get, never): Null<String>;
+	public var suffixLabel(get, never): Null<String>;
 
 	inline public function get_name() {
 		return this.attr.get("var") ?? "";
@@ -149,6 +152,18 @@ abstract Field(Stanza) from Stanza to Stanza {
 		return this.getChild("required") != null;
 	}
 
+	inline public function get_mediaSelector() {
+		return this.getChild("media-selector", "https://ns.cheogram.com/") != null;
+	}
+
+	inline public function get_prefixLabel() {
+		return this.getChildText("x", "https://ns.cheogram.com/prefix-label");
+	}
+
+	inline public function get_suffixLabel() {
+		return this.getChildText("x", "https://ns.cheogram.com/suffix-label");
+	}
+
 	@:to
 	inline public function toFormField(): FormField {
 		return this == null ? null : new FormField(this);
@@ -158,6 +173,7 @@ abstract Field(Stanza) from Stanza to Stanza {
 abstract Option(Stanza) from Stanza to Stanza {
 	public var label(get, never): Null<String>;
 	public var value(get, never): Null<String>;
+	public var svg(get, never): Null<String>;
 
 	inline public function get_label() {
 		return this.attr.get("label");
@@ -167,6 +183,10 @@ abstract Option(Stanza) from Stanza to Stanza {
 		return this.getChildText("value");
 	}
 
+	inline public function get_svg() {
+		return this.getChild("svg", "http://www.w3.org/2000/svg")?.serialize();
+	}
+
 	@:to
 	inline public function toFormOption(): FormOption {
 		return this == null ? null : FormOption.fromOption(this);
@@ -191,6 +211,9 @@ class FormField {
 	public final rangeMin: Null<String>;
 	public final rangeMax: Null<String>;
 	public final regex: Null<String>;
+	public final mediaSelector: Bool;
+	public final prefixLabel: Null<String>;
+	public final suffixLabel: Null<String>;
 
 	@:allow(borogove)
 	private function new(field: Field) {
@@ -206,6 +229,9 @@ class FormField {
 		rangeMin = field.rangeMin;
 		rangeMax = field.rangeMax;
 		regex = field.regex;
+		mediaSelector = field.mediaSelector;
+		prefixLabel = field.prefixLabel;
+		suffixLabel = field.suffixLabel;
 	}
 }
 
@@ -217,15 +243,17 @@ class FormField {
 class FormOption {
 	public final label: String;
 	public final value: String;
+	public final svg: Null<String>;
 
 	@:allow(borogove)
-	private function new(label: Null<String>, value: Null<String>) {
+	private function new(label: Null<String>, value: Null<String>, svg: Null<String> = null) {
 		this.label = label ?? value;
 		this.value = value ?? "";
+		this.svg = svg ?? null;
 	}
 
 	@:allow(borogove)
 	private static function fromOption(option: Option) {
-		return new FormOption(option.label, option.value);
+		return new FormOption(option.label, option.value, option.svg);
 	}
 }