import * as UI from '../../src/index'

import { Canvas, Meta, Story } from "@storybook/addon-docs";
import { rawJsonDecorator } from "./decorators";

<Meta title="RDF utilities" />

## allClassUris

Retrieve all RDF class URIs from solid-ui's RDF store

[API docs](https://solidos.github.io/solid-ui/docs/api/modules/_widgets_buttons_.html#allclassuris)

<Canvas withSource="open">
  <Story name="allClassUris" decorators={[rawJsonDecorator]}>
    {() => {
      SolidLogic.store.add(
        $rdf.namedNode("http://example.com/#some-thing"),
        $rdf.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
        $rdf.namedNode("http://example.com/#some-class")
      );
      SolidLogic.store.add(
        $rdf.namedNode("http://example.com/#some-other-thing"),
        $rdf.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
        $rdf.namedNode("http://example.com/#some-other-class")
      );
      return UI.widgets.allClassURIs();
    }}
  </Story>
</Canvas>

## defaultAnnotationStore

Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.

[API docs](https://solidos.github.io/solid-ui/docs/api/modules/_widgets_buttons_.html#defaultannotationstore)

<Canvas withSource="open">
  <Story name="defaultAnnotationStore" decorators={[rawJsonDecorator]}>
    {() => {
      const url = "http://example.com/a/b.html";
      return UI.widgets.defaultAnnotationStore($rdf.namedNode(url));
    }}
  </Story>
</Canvas>

## extractLogURI

To figure out the log URI from the full URI used to invoke the reasoner

[API docs](https://solidos.github.io/solid-ui/docs/api/modules/_widgets_buttons_.html#extractloguri)

<Canvas withSource="open">
  <Story name="extractLogURI" decorators={[rawJsonDecorator]}>
    {() => {
      const url =
        "https://example.com/logFile=http%3A%2F%2Fexample.org%2Flogs.ttl&rulesFile=ttp%3A%2F%2Fexample.org%2Frules.ttl";
      return decodeURIComponent(UI.widgets.extractLogURI(url));
    }}
  </Story>
</Canvas>

## propertyTriage

Figuring which properties we know about

[API docs](https://solidos.github.io/solid-ui/docs/api/modules/_widgets_buttons_.html#propertytriage)

<Canvas withSource="open">
  <Story name="propertyTriage" decorators={[rawJsonDecorator]}>
    {() => {
      // FIXME: make this example return actual possible properties
      const kb = SolidLogic.store;
      return UI.widgets.propertyTriage(kb);
    }}
  </Story>
</Canvas>
