diff --git a/app/packages/core/src/plugins/SchemaIO/components/ImageView.tsx b/app/packages/core/src/plugins/SchemaIO/components/ImageView.tsx index 65de8275d8..930451b9d9 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/ImageView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/ImageView.tsx @@ -5,12 +5,19 @@ import { getComponentProps } from "../utils"; export default function ImageView(props) { const { schema, data } = props; + const { height, width, alt } = schema?.view || {}; const imageURI = data ?? schema?.default; return ( - + {alt} ); } diff --git a/app/packages/core/src/plugins/SchemaIO/components/InferredView.tsx b/app/packages/core/src/plugins/SchemaIO/components/InferredView.tsx index 78ad1fd888..1eafa9bca4 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/InferredView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/InferredView.tsx @@ -3,12 +3,13 @@ import { generateSchema } from "../utils"; import DynamicIO from "./DynamicIO"; export default function InferredView(props) { - const { schema = {} } = props; + const { data, schema = {} } = props; const { view = {}, default: defaultValue, readOnly } = schema; - const generatedSchema = generateSchema(defaultValue, { + const value = data ?? defaultValue; + const generatedSchema = generateSchema(value, { label: view.label, readOnly: readOnly || view.readOnly, }); - const schemaWithDefault = { ...generatedSchema, default: defaultValue }; + const schemaWithDefault = { ...generatedSchema, default: value }; return ; } diff --git a/app/packages/core/src/plugins/SchemaIO/components/LinkView.tsx b/app/packages/core/src/plugins/SchemaIO/components/LinkView.tsx index 55198460d8..008622a9af 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/LinkView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/LinkView.tsx @@ -4,13 +4,28 @@ import { getComponentProps } from "../utils"; export default function LinkView(props) { const { schema, data = {} } = props; - const { view = {} } = schema; - const { label: viewLabel, href: viewHref } = view; - const { label, href } = data; + const { view = {}, default: defaultValue } = schema; + const { new_window, newWindow } = view; + let { label, href } = view; + const value = data ?? defaultValue; + if (typeof value === "string") { + href = value; + } else { + if (value?.href) { + href = value.href; + } + if (value?.label) { + label = value.label; + } + } return ( - - {label || viewLabel} + + {label} ); diff --git a/app/packages/core/src/plugins/SchemaIO/components/MediaPlayerView.tsx b/app/packages/core/src/plugins/SchemaIO/components/MediaPlayerView.tsx index d945e16b88..c1d4d6f09a 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/MediaPlayerView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/MediaPlayerView.tsx @@ -6,9 +6,10 @@ import { getComponentProps } from "../utils"; export default function MediaPlayerView(props) { const { schema, data } = props; - const { default: defaultValue, playerProps = {} } = schema; - const actualData = data ?? defaultValue; - const mediaUrl = actualData?.url; + const { default: defaultValue } = schema; + const value = data ?? defaultValue; + const mediaUrl = typeof value === "string" ? value : value?.url; + const { view = {} } = schema; const handleEvent = (event) => @@ -32,7 +33,7 @@ export default function MediaPlayerView(props) { diff --git a/fiftyone/operators/types.py b/fiftyone/operators/types.py index e5426dd296..4ac648b254 100644 --- a/fiftyone/operators/types.py +++ b/fiftyone/operators/types.py @@ -446,6 +446,54 @@ def arrow_nav( ) return self.view(name, view, **kwargs) + def map(self, name, key_type, value_type, **kwargs): + """Defines a map property on the object. + + Args: + name: the name of the property + key_type: the type of the keys in the map + value_type: the type of the values in the map + + + Returns: + a :class:`Map` + """ + map_view = MapView(**kwargs) + map_type = Map(key_type=key_type, value_type=value_type) + self.define_property(name, map_type, view=map_view, **kwargs) + return map_type + + def oneof(self, name, types, **kwargs): + """Defines a one-of property on the object. + + Args: + name: the name of the property + types: list of types that are instances of :class:`BaseType` + + + Returns: + a :class:`OneOf` + """ + + one_of = OneOf(types) + self.define_property(name, one_of, **kwargs) + return one_of + + def tuple(self, name, *items, **kwargs): + """Defines a tuple property on the object. + + Args: + name: the name of the property + *items: the types of the items in the tuple + + Returns: + a :class:`Tuple` + """ + tuple_view = TupleView(**kwargs) + tuple_type = Tuple(*items) + self.define_property(name, tuple_type, view=tuple_view, **kwargs) + return tuple_type + def clone(self): """Clones the definition of the object.