semantics

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name        string `json:"name,omitempty"`
	Type        string `json:"type"`
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`
	Importance  string `json:"importance,omitempty"`
	Optional    bool   `json:"optional,omitempty"`
	Default     any    `json:"default,omitempty"`
	Common      bool   `json:"common,omitempty"`
	Widget      string `json:"widget,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`

	// For group types
	Fields   []Field `json:"fields,omitempty"`
	Expanded bool    `json:"expanded,omitempty"`

	// For list types
	Entity     string `json:"entity,omitempty"`
	Min        int    `json:"min,omitempty"`
	Max        int    `json:"max,omitempty"`
	DefaultNum int    `json:"defaultNum,omitempty"`
	Field      *Field `json:"field,omitempty"`

	// For select and library types - polymorphic options field
	Options interface{} `json:"options,omitempty"`

	// For number types
	MinValue int    `json:"minValue,omitempty"`
	MaxValue int    `json:"maxValue,omitempty"`
	Step     int    `json:"step,omitempty"`
	Unit     string `json:"unit,omitempty"`

	// For text types
	MaxLength int      `json:"maxLength,omitempty"`
	Tags      []string `json:"tags,omitempty"`

	// Widget-specific properties
	ShowWhen *ShowWhen `json:"showWhen,omitempty"`
}

Field represents a single field in an H5P semantics definition

func (*Field) GetLibraryOptions

func (f *Field) GetLibraryOptions() []string

GetLibraryOptions returns the options as a slice of library strings. This is used for library type fields where options contains library names/versions. Returns nil if the options are not in the expected format.

func (*Field) GetSelectOptions

func (f *Field) GetSelectOptions() []SelectOption

GetSelectOptions returns the options as a slice of SelectOption structs. This is used for select type fields where options contains value/label pairs. Returns nil if the options are not in the expected format.

func (*Field) SetLibraryOptions

func (f *Field) SetLibraryOptions(options []string)

SetLibraryOptions sets the options field with library strings.

func (*Field) SetSelectOptions

func (f *Field) SetSelectOptions(options []SelectOption)

SetSelectOptions sets the options field with SelectOption structs.

type SelectOption

type SelectOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

SelectOption represents an option in a select field

type SemanticDefinition

type SemanticDefinition []Field

SemanticDefinition represents the top-level semantics array

type ShowRule

type ShowRule struct {
	Field  string      `json:"field"`
	Equals interface{} `json:"equals"`
}

ShowRule defines a single visibility rule

type ShowWhen

type ShowWhen struct {
	Rules []ShowRule `json:"rules"`
}

ShowWhen defines conditional visibility rules for fields

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL