-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: start some tests, add shoelace to playground
- Loading branch information
Showing
25 changed files
with
207 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
types/ | ||
node_modules/ | ||
dist/ | ||
*.snap.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> | ||
<meta name="Description" content="Put your description here."> | ||
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/dist/themes/light.css" /> | ||
<script>try{new EventTarget}catch(e){document.write('<script src="https://unpkg.com/@ungap/[email protected]/min.js"><\x2fscript>')}</script> | ||
|
||
<style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/hydra/test/lib/components/multiInstanceSelector.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from '@open-wc/testing' | ||
import sh1 from '@hydrofoil/shaperone-core/ns.js' | ||
import { decorator } from '../../../lib/components/multiInstanceSelector' | ||
|
||
describe('hydra/lib/components/multiInstancesSelector', () => { | ||
describe('decorator', () => { | ||
it('applies to Multi Instances Selector', () => { | ||
// given | ||
const component = { | ||
editor: sh1.InstancesMultiSelectEditor, | ||
} | ||
|
||
// then | ||
expect(decorator().applicableTo(component)).to.be.true | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Lazy } from '@hydrofoil/shaperone-core' | ||
import * as Core from '@hydrofoil/shaperone-core/components.js' | ||
|
||
export const enumSelect: Lazy<Core.EnumSelectEditor> = { | ||
...Core.enumSelect, | ||
async lazyRender() { | ||
const { select } = await import('./select.js') | ||
|
||
return ({ value, componentState }, { update }) => { | ||
const pointers = componentState.instances || [] | ||
|
||
return select(value, pointers, update) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Lazy } from '@hydrofoil/shaperone-core' | ||
import * as Core from '@hydrofoil/shaperone-core/components.js' | ||
|
||
export const instancesSelect: Lazy<Core.InstancesSelectEditor> = { | ||
...Core.instancesSelect, | ||
async lazyRender() { | ||
const { select } = await import('./select.js') | ||
|
||
return ({ value, componentState }, { update }) => { | ||
const pointers = componentState.instances || [] | ||
|
||
return select(value, pointers, update) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SingleEditorActions } from '@hydrofoil/shaperone-core/models/components' | ||
import { html } from 'lit' | ||
import '@shoelace-style/shoelace/dist/components/select/select.js' | ||
import '@shoelace-style/shoelace/dist/components/menu-item/menu-item.js' | ||
import type { GraphPointer } from 'clownface' | ||
import { repeat } from 'lit/directives/repeat.js' | ||
import { PropertyObjectState } from '@hydrofoil/shaperone-core/models/forms' | ||
import { SlSelect } from '@shoelace-style/shoelace' | ||
import { renderItem } from '../lib/components.js' | ||
import { stop } from '../lib/handlers.js' | ||
import { settings } from '../settings.js' | ||
|
||
export function select(value: PropertyObjectState, pointers: GraphPointer[], update: SingleEditorActions['update']) { | ||
function onChange(e: Event) { | ||
const target = e.target as SlSelect | ||
const selected = pointers.find(({ value }) => value === target.value) | ||
|
||
if (selected) { update(selected.term) } | ||
} | ||
|
||
return html`<sl-select ?hoist="${settings.hoist}" .value=${value.object?.value || ''} @sl-change=${onChange} @sl-hide=${stop}> | ||
${repeat(pointers || [], renderItem)} | ||
</sl-select>` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,12 @@ | |
"is-graph-pointer": "^1.2.2", | ||
"lit": "^2" | ||
}, | ||
"devDependencies": { | ||
"@open-wc/testing": "^3.1.6", | ||
"@rdf-esm/dataset": "^0.5.1", | ||
"@shaperone/testing": "*", | ||
"clownface": "^1.5.1" | ||
}, | ||
"repository": "https://github.com/hypermedia-app/shaperone", | ||
"author": "Tomasz Pluskiewicz <[email protected]>", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
interface Settings { | ||
hoist: boolean | ||
} | ||
|
||
export const settings: Settings = { | ||
hoist: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.