@otwdesign/plugin-db 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/admin.tsx +13 -22
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otwdesign/plugin-db",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OTW DB in the OTW CMS admin: browse, query and edit the site's database, and any other, the way TablePlus does.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OTW SRL",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"pg": "^8.23.1",
|
|
39
39
|
"pg-cursor": "^2.22.1",
|
|
40
|
-
"@otwdesign/db-core": "1.0.
|
|
41
|
-
"@otwdesign/db-ui": "1.0.
|
|
40
|
+
"@otwdesign/db-core": "1.0.2",
|
|
41
|
+
"@otwdesign/db-ui": "1.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@otwdesign/sdk": "^1.1.0",
|
package/src/admin.tsx
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { entry } from '@otwdesign/db-ui/entry'
|
|
2
2
|
import { defineAdmin } from '@otwdesign/sdk'
|
|
3
|
+
import { createElement, type CSSProperties } from 'react'
|
|
3
4
|
import db from './index'
|
|
4
5
|
|
|
5
|
-
// React's own types are in scope inside its module.
|
|
6
|
-
declare module 'react' {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
8
|
-
namespace JSX {
|
|
9
|
-
interface IntrinsicElements {
|
|
10
|
-
/** The app, defined by its own script: it mounts wherever it's put. */
|
|
11
|
-
'otw-db-app': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & { config: string }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
6
|
/** The admin entry: Database, the tool inside the admin's own frame. */
|
|
17
7
|
export default defineAdmin(db, (cms) => {
|
|
18
8
|
const base = cms.routes.apiUrl('/')
|
|
@@ -26,23 +16,24 @@ export default defineAdmin(db, (cms) => {
|
|
|
26
16
|
})
|
|
27
17
|
})
|
|
28
18
|
|
|
19
|
+
const frame: CSSProperties = {
|
|
20
|
+
display: 'block',
|
|
21
|
+
height: 'calc(100vh - 150px)',
|
|
22
|
+
minHeight: 480,
|
|
23
|
+
border: '1px solid #dcdce0',
|
|
24
|
+
borderRadius: 6,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
}
|
|
27
|
+
|
|
29
28
|
/** The app's script and its element; the element mounts the app in a shadow root of its own. */
|
|
30
29
|
export function DatabaseScreen({ base }: { base: string }) {
|
|
31
30
|
const config = JSON.stringify({ api: `${base}/api`, style: `${base}/assets/${entry.style}` })
|
|
32
31
|
return (
|
|
33
32
|
<>
|
|
34
33
|
<script type="module" async src={`${base}/assets/${entry.script}`} />
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
display: 'block',
|
|
39
|
-
height: 'calc(100vh - 150px)',
|
|
40
|
-
minHeight: 480,
|
|
41
|
-
border: '1px solid #dcdce0',
|
|
42
|
-
borderRadius: 6,
|
|
43
|
-
overflow: 'hidden',
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
34
|
+
{/* createElement, not JSX: a JSX tag would need the element added to React's global JSX
|
|
35
|
+
types, which a site with its own copy of React's types (a linked checkout) can't take. */}
|
|
36
|
+
{createElement('otw-db-app', { config, style: frame })}
|
|
46
37
|
</>
|
|
47
38
|
)
|
|
48
39
|
}
|