77
88import * as UI from 'solid-ui'
99import * as $rdf from 'rdflib'
10+ import type { DataBrowserContext , RenderEnvironment } from 'pane-registry'
11+ import type { BlankNode , Literal , NamedNode , Statement } from 'rdflib'
12+ import './defaultPane.css'
1013
1114const ns = UI . ns
15+ /* Types were generated by Generative AI (GPT-5.4 in GitHub Copilot) based on the following prompt:
16+ Generate TypeScript types for the default pane. */
17+ type DefaultPaneSubject = NamedNode | BlankNode | Literal
1218
13- export const defaultPane = {
19+ type DefaultPaneDefinition = {
20+ icon : string
21+ name : string
22+ audience : NamedNode [ ]
23+ label : ( subject : DefaultPaneSubject ) => string
24+ render : ( subject : DefaultPaneSubject , context : DataBrowserContext ) => HTMLDivElement
25+ }
26+
27+ type DefaultPaneOutliner = {
28+ appendPropertyTRs : (
29+ parent : HTMLElement ,
30+ statements : Statement [ ] ,
31+ inverse : boolean ,
32+ filter : ( pred : NamedNode , inverse : boolean ) => boolean
33+ ) => void
34+ UserInput : {
35+ addNewPredicateObject : ( event : Event ) => void
36+ }
37+ }
38+
39+ export const defaultPane : DefaultPaneDefinition = {
1440 icon : UI . icons . originalIconBase + 'about.png' ,
1541
1642 name : 'default' ,
1743
1844 audience : [ ns . solid ( 'Developer' ) ] ,
1945
20- label : function ( _subject ) {
46+ label : function ( _subject : DefaultPaneSubject ) : string {
2147 return 'about '
2248 } ,
2349
24- render : function ( subject , context ) {
50+ render : function (
51+ subject : DefaultPaneSubject ,
52+ context : DataBrowserContext
53+ ) : HTMLDivElement {
2554 const dom = context . dom
2655
27- const filter = function ( pred , inverse ) {
56+ function applyEnvironmentAttributes ( element : HTMLDivElement ) : void {
57+ const environment = ( context . environment ?? { } ) as Partial < RenderEnvironment >
58+ element . dataset . layout = environment . layout ?? 'desktop'
59+ }
60+
61+ const filter = function ( pred : NamedNode , inverse : boolean ) : boolean {
2862 if (
2963 typeof context . session . paneRegistry . byName ( 'internal' ) . predicates [
3064 pred . uri
@@ -41,19 +75,23 @@ export const defaultPane = {
4175 return true
4276 }
4377
44- const outliner = context . getOutliner ( dom )
78+ const outliner = context . getOutliner ( dom ) as DefaultPaneOutliner
4579 const kb = context . session . store
4680 // var outline = outliner; // @@
4781 UI . log . info ( '@defaultPane.render, dom is now ' + dom . location )
48- subject = kb . canon ( subject )
82+ subject = kb . canon ( subject ) as DefaultPaneSubject
4983 const div = dom . createElement ( 'div' )
5084 div . setAttribute ( 'class' , 'defaultPane' )
85+ applyEnvironmentAttributes ( div )
5186 // appendRemoveIcon(div, subject, div)
5287
53- let plist = kb . statementsMatching ( subject )
88+ let plist = subject . termType === 'Literal' ? [ ] : kb . statementsMatching ( subject )
5489 outliner . appendPropertyTRs ( div , plist , false , filter )
5590 plist = kb . statementsMatching ( undefined , undefined , subject )
5691 outliner . appendPropertyTRs ( div , plist , true , filter )
92+ const subjectStatement = subject . termType === 'BlankNode'
93+ ? kb . anyStatementMatching ( subject )
94+ : undefined
5795 if (
5896 subject . termType === 'Literal' &&
5997 subject . value . slice ( 0 , 7 ) === 'http://'
@@ -69,10 +107,11 @@ export const defaultPane = {
69107 ( subject . termType === 'NamedNode' &&
70108 kb . updater . editable ( $rdf . Util . uri . docpart ( subject . uri ) , kb ) ) ||
71109 ( subject . termType === 'BlankNode' &&
72- kb . anyStatementMatching ( subject ) &&
73- kb . anyStatementMatching ( subject ) . why &&
74- kb . anyStatementMatching ( subject ) . why . uri &&
75- kb . updater . editable ( kb . anyStatementMatching ( subject ) . why . uri ) )
110+ subjectStatement &&
111+ subjectStatement . why &&
112+ 'uri' in subjectStatement . why &&
113+ typeof subjectStatement . why . uri === 'string' &&
114+ kb . updater . editable ( subjectStatement . why . uri ) )
76115 // check the document containing something about of the bnode @@ what about as object?
77116 /* ! && HCIoptions["bottom insert highlights"].enabled */
78117 ) {
0 commit comments