Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook #309

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
421e0d1
style: update eslint config
tpluscode Nov 26, 2024
0087e5c
refactor: async config
tpluscode Nov 26, 2024
5848b75
build(deps): update lock file
tpluscode Nov 26, 2024
3986736
refactor: useless await
tpluscode Nov 26, 2024
d8c3b9c
fix(wc): default resource node
tpluscode Nov 28, 2024
a20d9c6
fix: typo
tpluscode Nov 28, 2024
4f758ca
refactor: async config
tpluscode Nov 28, 2024
11a9cc1
ci: update actions
tpluscode Nov 28, 2024
7c0401f
feat: add/remove objects
tpluscode Nov 28, 2024
7467131
fix: use single shape from shapes graph
tpluscode Nov 28, 2024
27e95ea
fix(wc): decimal input
tpluscode Nov 28, 2024
b06f7da
docs: storybook
tpluscode Nov 28, 2024
bdb4f18
test: remove old import
tpluscode Nov 28, 2024
e430f48
chore: build fixes
tpluscode Nov 28, 2024
5222fe5
ci: typedocs config
tpluscode Nov 28, 2024
35d4164
build: remove from pack
tpluscode Nov 28, 2024
ff29f65
test: bring back named node
tpluscode Nov 28, 2024
e958589
ci: fix install cmd
tpluscode Nov 28, 2024
c3082eb
Merge remote-tracking branch 'origin/master' into storybook
tpluscode Nov 28, 2024
400e472
Merge remote-tracking branch 'origin/master' into storybook
tpluscode Nov 28, 2024
37cb6ed
Merge remote-tracking branch 'origin/master' into storybook
tpluscode Nov 28, 2024
6f8044a
revert(build): docs mode for storybook
tpluscode Nov 28, 2024
f204d55
build(deps): update lit to v3
tpluscode Nov 28, 2024
1f1c3af
build: storybook node imports
tpluscode Nov 28, 2024
174f06e
Revert "build: storybook node imports"
tpluscode Nov 28, 2024
d7ca476
build: storybook node imports
tpluscode Nov 28, 2024
017d2ef
docs(storybook): assets path
tpluscode Nov 28, 2024
f0bb5df
ci(test): wtr --puppeteer
tpluscode Nov 28, 2024
838c816
fix: relative css path
tpluscode Nov 28, 2024
5fca7a8
build(deps): up @zazuko/env
tpluscode Nov 29, 2024
aaa8390
revert: unwanted state modification
tpluscode Nov 29, 2024
15934de
fix: setting shapes
tpluscode Nov 29, 2024
2d5523e
docs: make stories interactive
tpluscode Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-grapes-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-core": minor
---

Fixed typo in exported type (`MiminalEnvironment` => `MinimalEnvironment`)
5 changes: 5 additions & 0 deletions .changeset/dry-shoes-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-core": patch
---

Fixes setting shapes from dataset
6 changes: 6 additions & 0 deletions .changeset/dull-baboons-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hydrofoil/shaperone-wc-material": patch
"@hydrofoil/shaperone-wc-vaadin": patch
---

Updated core package
7 changes: 7 additions & 0 deletions .changeset/few-clouds-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hydrofoil/shaperone-wc": patch
"@hydrofoil/shaperone-wc-material": patch
"@hydrofoil/shaperone-wc-vaadin": patch
---

Updated `lit` to v3
6 changes: 6 additions & 0 deletions .changeset/hungry-guests-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hydrofoil/shaperone-core": patch
"@hydrofoil/shaperone-wc": patch
---

Native components: `xsd:decimal` would not accept decimal point as a valid input.
5 changes: 5 additions & 0 deletions .changeset/ninety-kiwis-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-wc": patch
---

Native templates: The ability to add and remove property values
6 changes: 6 additions & 0 deletions .changeset/seven-monkeys-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hydrofoil/shaperone-core": patch
"@hydrofoil/shaperone-wc": minor
---

`configure` is now async and required to register the element
5 changes: 5 additions & 0 deletions .changeset/six-islands-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-core": patch
---

When no shape is selected and only one `sh:NodeShape` exists in graph, that shape will be used
5 changes: 5 additions & 0 deletions .changeset/wise-pumas-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shaperone-wc": minor
---

Fixes an issue that the form would not render when the node was `<>` (empty string URI)
27 changes: 22 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,43 @@ jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, "lts/*"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: yarn tsc --noEmit
- run: yarn tsc --noEmit --project tsconfig.build.json
- run: yarn build
- run: npx wsrun -m prepack --noEmit

test:
core-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: yarn test:core
- name: Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

wtr-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: yarn test
- run: yarn test:web --puppeteer
- name: Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:

- uses: nelonoel/[email protected]

- run: npx typedoc
- run: npx typedoc --tsconfig tsconfig.build.json
- name: Docsify variables
env:
DOMAIN: ${{ env.BRANCH_NAME == 'master' && 'forms.hypermedia.app' || format('{0}--shaperone.netlify.app', env.BRANCH_NAME) }}
run: npx json -I -f dist/variables.json -e "this.playground='https://$DOMAIN/playground'"

- run: npm i -g [email protected]

- name: Publish preview
uses: jsmrcaga/action-netlify-deploy@v2.1.0
uses: jsmrcaga/action-netlify-deploy@v2.3.0
if: env.NETLIFY_TOKEN
with:
NETLIFY_AUTH_TOKEN: ${{ env.NETLIFY_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage/
dist/api/
dist/playground/
dist/shaperone-form/
dist/storybook/
!types/**/*.d.ts
*.log
!*.snap.js
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ignore:
- demos
- test-setup.js
- packages/core-tests/test-setup.js
- karma.conf.js
- types
- packages/*/test
Expand Down
4 changes: 2 additions & 2 deletions demos/examples/DescriptionTooltip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TemplateResult } from 'lit'
import type { TemplateResult } from 'lit'
import { html } from '@hydrofoil/shaperone-wc'
import { ComponentDecorator } from '@hydrofoil/shaperone-core/models/components'
import type { ComponentDecorator } from '@hydrofoil/shaperone-core/models/components'
import type { PropertyShape } from '@rdfine/shacl'

function wrap(shape: PropertyShape, result: TemplateResult) {
Expand Down
3 changes: 2 additions & 1 deletion demos/examples/ErrorSummary/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { decorate, FocusNodeTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import type { FocusNodeTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import { decorate } from '@hydrofoil/shaperone-wc/templates.js'
import { html } from '@hydrofoil/shaperone-wc'
import type { ValidationResult } from '@rdfine/shacl'
import { shrink } from '@zazuko/prefixes/shrink'
Expand Down
3 changes: 2 additions & 1 deletion demos/examples/InlineNestedShapes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SingleEditorComponent, html } from '@hydrofoil/shaperone-wc'
import type { SingleEditorComponent } from '@hydrofoil/shaperone-wc'
import { html } from '@hydrofoil/shaperone-wc'
import { dash } from '@tpluscode/rdf-ns-builders'
import { isResource } from 'is-graph-pointer'

Expand Down
7 changes: 4 additions & 3 deletions demos/examples/LanguageMultiSelect/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { MultiEditorComponent, html } from '@hydrofoil/shaperone-wc'
import type { MultiEditorComponent } from '@hydrofoil/shaperone-wc'
import { html } from '@hydrofoil/shaperone-wc'
import $rdf from '@zazuko/env/web.js'
import { MultiEditor, Lazy } from '@hydrofoil/shaperone-core'
import type { MultiEditor, Lazy } from '@hydrofoil/shaperone-core'
import { vcard, rdfs } from '@tpluscode/rdf-ns-builders'
import { getLocalizedLabel } from '@rdfjs-elements/lit-helpers'
import { sort } from '@hydrofoil/shaperone-core/lib/components.js'
import { ShaperoneEnvironment } from '@hydrofoil/shaperone-core/env.js'
import type { ShaperoneEnvironment } from '@hydrofoil/shaperone-core/env.js'

const editor = $rdf.namedNode('http://example.com/LanguageMultiSelect')

Expand Down
3 changes: 2 additions & 1 deletion demos/examples/NestedShapesIndividually/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { dash, rdfs, schema } from '@tpluscode/rdf-ns-builders'
import { html, SingleEditorComponent } from '@hydrofoil/shaperone-wc'
import type { SingleEditorComponent } from '@hydrofoil/shaperone-wc'
import { html } from '@hydrofoil/shaperone-wc'
import type { GraphPointer } from 'clownface'

function label(object?: GraphPointer) {
Expand Down
3 changes: 2 additions & 1 deletion demos/examples/NestedShapesIndividually/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { decorate, FormTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import type { FormTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import { decorate } from '@hydrofoil/shaperone-wc/templates.js'
import { html, css } from '@hydrofoil/shaperone-wc'

export const topmostFocusNodeFormRenderer = decorate((form: FormTemplate): FormTemplate => {
Expand Down
5 changes: 3 additions & 2 deletions demos/examples/StarRating/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
import type { IconName } from '@fortawesome/fontawesome-svg-core'
import { html, SingleEditor, Lazy, SingleEditorComponent } from '@hydrofoil/shaperone-wc'
import type { SingleEditor, Lazy, SingleEditorComponent } from '@hydrofoil/shaperone-wc'
import { html } from '@hydrofoil/shaperone-wc'
import type { UpdateComponentState } from '@hydrofoil/shaperone-core/models/components'
import { schema, xsd } from '@tpluscode/rdf-ns-builders'
import { dash } from '@tpluscode/rdf-ns-builders/loose'
import type { PropertyShape } from '@rdfine/shacl'
import { ShaperoneEnvironment } from '@hydrofoil/shaperone-core/env.js'
import type { ShaperoneEnvironment } from '@hydrofoil/shaperone-core/env.js'
import rdf from '@zazuko/env/web.js'

export interface StarRating {
Expand Down
5 changes: 3 additions & 2 deletions demos/examples/XoneRenderer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { decorate, FocusNodeTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import type { FocusNodeTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import { decorate } from '@hydrofoil/shaperone-wc/templates.js'
import { html } from '@hydrofoil/shaperone-wc'
import { LogicalConstraint } from '@hydrofoil/shaperone-core/models/forms'
import type { LogicalConstraint } from '@hydrofoil/shaperone-core/models/forms'
import type { Shape } from '@rdfine/shacl'
import type { Term } from '@rdfjs/types'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
Expand Down
3 changes: 2 additions & 1 deletion demos/lit-html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"process": "^0.11.10",
"rimraf": "^3.0.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"util": "^0.12.5"
"util": "^0.12.5",
"vite-plugin-top-level-await": "^1.4.4"
}
}
9 changes: 5 additions & 4 deletions demos/lit-html/src/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ import * as shoelaceComponents from '@hydrofoil/shaperone-wc-shoelace/components
import { settings as shoelaceSettings } from '@hydrofoil/shaperone-wc-shoelace/settings.js'
import { configure } from '@hydrofoil/shaperone-wc/configure.js'
import { dash } from '@tpluscode/rdf-ns-builders'
import { Decorate, RenderTemplate, templates } from '@hydrofoil/shaperone-wc/templates.js'
import type { Decorate, RenderTemplate } from '@hydrofoil/shaperone-wc/templates.js'
import { templates } from '@hydrofoil/shaperone-wc/templates.js'
import * as MaterialRenderStrategy from '@hydrofoil/shaperone-wc-material/renderer/index.js'
import shaperoneHydra from '@hydrofoil/shaperone-hydra'
import { validate } from '@hydrofoil/shaperone-rdf-validate-shacl'
import * as xone from '@hydrofoil/shaperone-playground-examples/XoneRenderer/index.js'
import { errorSummary } from '@hydrofoil/shaperone-playground-examples/ErrorSummary/index.js'
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js'
import $rdf from './env.js'
import { ComponentsState } from './state/models/components.js'
import { RendererState } from './state/models/renderer.js'
import type { ComponentsState } from './state/models/components.js'
import type { RendererState } from './state/models/renderer.js'

setBasePath('https://unpkg.com/@shoelace-style/shoelace/dist')
shoelaceSettings.hoist = false

const { editors, components, validation, renderer } = configure($rdf)
const { editors, components, validation, renderer } = await configure($rdf)

export const componentSets: Record<ComponentsState['components'], Record<string, Component>> = {
native: { ...nativeComponents, starRating },
Expand Down
6 changes: 3 additions & 3 deletions demos/lit-html/src/menu/formMenu.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { html, render } from 'lit'
import { ComponentsState } from '../state/models/components.js'
import { RendererState } from '../state/models/renderer.js'
import type { ComponentsState } from '../state/models/components.js'
import type { RendererState } from '../state/models/renderer.js'
import { componentSets } from '../configure.js'
import { Menu } from '../menu.js'
import type { Menu } from '../menu.js'

function componentsMenu(components: ComponentsState): Menu {
return {
Expand Down
6 changes: 3 additions & 3 deletions demos/lit-html/src/menu/resource.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MultiselectComboBox } from 'multiselect-combo-box/multiselect-combo-box'
import type { MultiselectComboBox } from 'multiselect-combo-box/multiselect-combo-box'
import prefixes from '@zazuko/prefixes/prefixes'
import rdf from '@zazuko/env/web.js'
import { State } from '../state/models/resource.js'
import { Menu } from '../menu.js'
import type { State } from '../state/models/resource.js'
import type { Menu } from '../menu.js'

const resourceMenuItem = (() => {
import('@vaadin/vaadin-combo-box/vaadin-combo-box.js')
Expand Down
6 changes: 3 additions & 3 deletions demos/lit-html/src/shaperone-playground-lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import '@vaadin/vaadin-item/vaadin-item.js'
import '@material/mwc-icon/mwc-icon.js'
import '@vaadin-component-factory/vcf-tooltip'
import type { ShaperoneForm } from '@hydrofoil/shaperone-wc'
import '@hydrofoil/shaperone-wc/shaperone-form'
import '@rdfjs-elements/rdf-editor'
import '@rdfjs-elements/rdf-editor/rdf-editor.js'
import '@github/clipboard-copy-element'
import { connect } from '@captaincodeman/rdx'
import type { Quad } from '@rdfjs/types'
import { store, State, Dispatch } from './state/store.js'
import type { State, Dispatch } from './state/store.js'
import { store } from './state/store.js'
import { shapeMenu } from './menu/shape.js'
import { resourceMenu } from './menu/resource.js'
import { formMenu } from './menu/formMenu.js'
Expand Down
4 changes: 2 additions & 2 deletions demos/lit-html/src/state/models/playground.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createModel } from '@captaincodeman/rdx'
import { setLanguages } from '@rdfjs-elements/lit-helpers'
import type { Store } from '../store.js'
import { ComponentsState } from './components.js'
import { RendererState } from './renderer.js'
import type { ComponentsState } from './components.js'
import type { RendererState } from './renderer.js'

export interface State {
sharePopup: boolean
Expand Down
3 changes: 2 additions & 1 deletion demos/lit-html/src/state/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createStore, devtools, ModelStore, StoreDispatch, StoreState, persist } from '@captaincodeman/rdx'
import type { ModelStore, StoreDispatch, StoreState } from '@captaincodeman/rdx'
import { createStore, devtools, persist } from '@captaincodeman/rdx'
import { config } from './config.js'

export type State = StoreState<typeof config>
Expand Down
9 changes: 6 additions & 3 deletions demos/lit-html/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// eslint-disable-next-line import/no-extraneous-dependencies
/* eslint-disable import/no-extraneous-dependencies,import/no-relative-packages */
import topLevelAwait from 'vite-plugin-top-level-await'
import { defineConfig, mergeConfig } from 'vite'
// eslint-disable-next-line import/no-relative-packages
import config from '../../vite.config.js'

export default defineConfig(({ command }) => {
if (command === 'build') {
return mergeConfig(config, {
base: '/playground/',
plugins: [topLevelAwait()],
})
}

return config
return mergeConfig(config, {
plugins: [topLevelAwait()],
})
})
32 changes: 32 additions & 0 deletions demos/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { join, dirname } from 'node:path'
import { StorybookConfig } from '@storybook/web-components-vite'

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
const getAbsolutePath = (value: string) => {
return dirname(require.resolve(join(value, 'package.json')))
}

const config: StorybookConfig = {
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],

addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
],

framework: {
name: getAbsolutePath('@storybook/web-components-vite'),
options: {},
},

staticDirs: [
'../shapes',
'../../../node_modules/@shoelace-style/'
],

docs: {},
}
export default config
2 changes: 2 additions & 0 deletions demos/storybook/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet">
<link rel="stylesheet" href="./shoelace/cdn/themes/light.css" />
Loading