Compare commits

..
Author SHA1 Message Date
STEINNI df194dcb65 better columns VS nodes width and placement 2026-10-14 12:26:44 +00:00
STEINNI fcb1e535ca Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-10-12 13:51:14 +00:00
STEINNI e71800bd1d taskid as data in gantt 2026-10-12 13:50:42 +00:00
STEINNI 256349d23e Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-10-07 09:25:27 +00:00
STEINNI bb1e64218a better gantt vertical alignment 2026-10-07 08:59:22 +00:00
STEINNI 731d6cf55b .gitignore 2026-09-03 13:04:39 +00:00
STEINNI a2c5e1f394 gantt: small css fix 2026-09-02 06:33:47 +00:00
STEINNI 2d80fcf447 gantt: better variable passing from task into markup 2026-09-01 18:55:05 +00:00
STEINNI d027002cb9 gantt: fixed minstart date max endDate to grid on all days 2026-09-01 15:51:15 +00:00
STEINNI 4625067352 gantt days 2026-08-29 14:43:51 +00:00
STEINNI 5a8f93e376 gantt css, dynamic css and colors 2026-08-29 10:13:06 +00:00
STEINNI 6e902b91fd Started bs-gantt 2026-08-28 19:40:56 +00:00
STEINNI 7471a37220 graflow autofit back to percent, and get tween from attr tween 2026-07-30 14:05:33 +00:00
STEINNI 9b0cb2582e better autofit signature 2026-07-30 12:24:26 +00:00
STEINNI 43cd6a85b1 Graflow: Added tween to autofit 2026-07-30 08:48:55 +00:00
STEINNI 47f4e3e6c8 autofit fixed and simplified, thx Mike ! (Mike code readapted for edge cases) 2026-07-29 13:50:47 +00:00
STEINNI dfb1190e7b Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-22 11:55:06 +00:00
STEINNI 6292a64d82 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-22 10:12:40 +00:00
STEINNI e397ee3b2d Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-22 10:11:28 +00:00
STEINNI 9690401dad Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-05 15:16:04 +00:00
STEINNI 63f894f526 portal trick on bz-select options 2026-06-05 15:16:01 +00:00
STEINNI 345be1aa23 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-04 11:27:24 +00:00
STEINNI e14b0c0214 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-06-04 11:26:51 +00:00
STEINNI d073a2e804 better layout complete events 2026-06-04 11:22:39 +00:00
STEINNI 8f41a39a6e Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-05-22 09:17:50 +00:00
STEINNI df6ba88040 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-05-22 09:16:32 +00:00
STEINNI 0b34b37aaf Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-05-22 09:15:42 +00:00
STEINNI 694e610ebb fixed bad autoplace if unfocused while autoplacing 2026-05-22 09:13:52 +00:00
STEINNI 3503fd90ab Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-05-05 13:26:49 +00:00
STEINNI 0c21f7b772 Graflow: unique refs for arrows to fix arrows in subflows 2026-05-05 13:26:29 +00:00
STEINNI 53ed4eea07 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-21 13:58:50 +00:00
STEINNI 605398505a graflow: disabled attribute 2026-04-21 13:55:28 +00:00
STEINNI 4f728a3514 Graflow: standardized event signatures between floLoaded and subflowLoaded and subflowExited 2026-04-16 09:15:11 +00:00
STEINNI 3e7a82edc2 Graflow: standardized event signatures between floLoaded and subflowLoaded 2026-04-16 08:03:32 +00:00
STEINNI a871288c1c Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-14 14:10:35 +00:00
STEINNI 5f8e3865e3 Graflow: autofit fixes for subflows 2026-04-14 14:10:15 +00:00
STEINNI d25a4b548a Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-14 11:04:46 +00:00
STEINNI f031142848 Graflow: more flexible markup in ref-nodes 2026-04-14 11:04:24 +00:00
STEINNI b9b39a2679 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-14 10:40:24 +00:00
STEINNI eb891c8cef Graflow: added parentNodeId to subflowLoaded event 2026-04-14 10:40:08 +00:00
STEINNI 974501fea8 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-14 07:08:04 +00:00
STEINNI 40b12f0c47 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 16:05:27 +00:00
STEINNI 33ea2bd672 Graflow: dataset.subflow 2026-04-13 16:05:12 +00:00
STEINNI ff4a25c1b2 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 15:23:33 +00:00
STEINNI cfe33b8111 Graflow: autofit readded translations 2026-04-13 15:23:15 +00:00
STEINNI 7d3548d597 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 15:21:52 +00:00
STEINNI 9381d82ae5 Graflow: autofit removed translations 2026-04-13 15:21:39 +00:00
STEINNI 839634a3ee Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 15:14:15 +00:00
STEINNI 0e6d23c1e1 Graflow: fixed autofit 2026-04-13 15:14:00 +00:00
STEINNI 8fc680fcb9 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 14:34:19 +00:00
STEINNI 54eb584fd7 Graflow: autofit fix for subflows to include refNodes 2026-04-13 14:33:57 +00:00
STEINNI c16f4a1b42 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 14:15:22 +00:00
STEINNI 0adc966608 Graflow: autofit as atrtibute 2026-04-13 14:14:59 +00:00
STEINNI 733420c90d Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 08:16:13 +00:00
STEINNI e4c4bb7f86 Graflow: subflow enter/exit tween aligned with tween param 2026-04-13 08:15:59 +00:00
STEINNI 2159c3881f Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-13 07:46:04 +00:00
STEINNI bf837e187b graflow: cleanup in subflow child params inheritance 2026-04-13 07:45:53 +00:00
STEINNI 88074b9144 graflow: cleanup in subflow child params inheritance 2026-04-13 07:45:31 +00:00
STEINNI e1e5e8afce Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-10 16:40:55 +00:00
STEINNI 7090bf7a3a graflow: fixed the underscore as separator in internal link storage 2026-04-10 16:40:31 +00:00
STEINNI 6641575423 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-10 15:19:42 +00:00
STEINNI 93ea54da57 graflow: adjust loadnodes from object with clone to avoid polution 2026-04-10 15:19:21 +00:00
STEINNI 5906304b43 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-10 14:51:02 +00:00
STEINNI 9d703f0640 graflow: subflow tweaks 2026-04-10 14:50:54 +00:00
STEINNI c8011123f8 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-10 14:35:21 +00:00
STEINNI 38ed29327e subflow can take js objects or url 2026-04-10 14:35:01 +00:00
STEINNI a921a3cc71 Merge branch 'main' of https://gitea.internike.com/nike/buildoz 2026-04-10 13:32:00 +00:00
STEINNI 511562c502 graflow: loadNodes is triple modes now: url, blob or object 2026-04-10 13:31:39 +00:00
STEINNI 90f45c2c8d graflow: orientation as param 2026-04-10 12:49:39 +00:00
STEINNI 0cc03cf512 BZModalDialog 2026-04-07 16:10:42 +00:00
STEINNI 158e9c4044 import flow OK 2026-03-30 19:57:21 +00:00
STEINNI 334cce8af3 export flow 2026-03-23 20:21:57 +00:00
STEINNI 266036a6ec graflowEditor: fixed gapy bug , graflow: update flow coords after move 2026-03-23 19:45:40 +00:00
STEINNI 0cb4491920 graflowEditor console 2026-03-22 20:42:04 +00:00
STEINNI 710bddd8e4 fixed chicked&egg&connectedCB issue between graflow & editor + fixed no Flow issue in graflow + Fixed nodesMove issue on displaced graflow + graflowEditor: DND ok 2026-03-22 15:29:48 +00:00
STEINNI 4122545cff fixed refacto of this.buildosUrl 2026-03-21 19:01:42 +00:00
STEINNI e58ff43014 fireEvent + graflow uses new-style fireEvent 2026-03-21 15:49:40 +00:00
STEINNI c3624d8aca graflow: autoplace uses live links 2026-03-15 18:54:14 +00:00
STEINNI bf30315217 graflow: debugging autoplace on new links 2026-03-15 18:41:40 +00:00
STEINNI 46a344db74 graflow: improved landing of temp-wire on hovering dest port + improved test5 example to test it 2026-03-15 18:04:51 +00:00
STEINNI 5de7699182 graflow: tempwire on creating new wire 2026-03-15 16:48:37 +00:00
25 changed files with 1912 additions and 232 deletions

No files matched your search

Executable
+17
View File
@@ -0,0 +1,17 @@
.well-known
/brol
/ui/app/config/config.json
log2mail.php
/ui/log2mail.php
/ui/*.sh
/ui/s3sync*.*
/ui/s3sync*
*.sh
.sparcStudio
.~lock*
/ui/squeezed/*
/ui/app/assets/videos/*
/AGENTS.md
/CLAUDE.md
.vscode
.cursor
+7
View File
@@ -0,0 +1,7 @@
{
"folders": [
{
"path": "."
}
]
}
+164 -7
View File
@@ -1,3 +1,34 @@
dialog.bz-modal-dialog{
padding: 0;
border: 2px solid #050;
border-radius: 5px;
min-width: 15em;
}
dialog.bz-modal-dialog header{
background: #050;
text-align: center;
color: white;
padding: .5em;
}
dialog.bz-modal-dialog section{
padding: .5em;
}
dialog.bz-modal-dialog footer{
border-top: 1px solid #CCC;
padding: .5em;
justify-content: center;
display: grid;
grid-template-columns: auto auto;
grid-gap: 2em;
}
dialog.bz-modal-dialog footer button{
min-width: 5em;
}
bz-select { bz-select {
display: block; display: block;
margin: .5em 0 .5em 0; margin: .5em 0 .5em 0;
@@ -23,7 +54,7 @@ bz-select > button::after {
content: "\00BB"; content: "\00BB";
transform: rotate(90deg); transform: rotate(90deg);
position: absolute; position: absolute;
right: 0.5em; right: clamp(-1em, calc(100% - 1em), 0.5em);
top: 0; top: 0;
pointer-events: none; pointer-events: none;
font-size: 1.5em; font-size: 1.5em;
@@ -41,7 +72,17 @@ bz-select > div.options-container{
transition: max-height 0.4s ease; transition: max-height 0.4s ease;
} }
bz-select > div.options-container.open{ pointer-events: auto; max-height: 10em;} bz-select > div.options-container.open{ pointer-events: auto; max-height: 10em;}
bz-select option{ div.options-container.portaled{
pointer-events: none;
position: fixed;
z-index: 10000;
max-height: 0;
overflow: auto;
transition: max-height 0.4s ease;
}
div.options-container.portaled.open{ pointer-events: auto; max-height: 10em;}
bz-select option,
div.options-container option{
background-color: #DDD; background-color: #DDD;
border: 1px solid black; border: 1px solid black;
color: #000; color: #000;
@@ -57,12 +98,14 @@ bz-select option{
margin-top 0.3s ease, margin-top 0.3s ease,
opacity 0.3s ease; opacity 0.3s ease;
} }
bz-select option.open{ bz-select option.open,
div.options-container option.open{
margin: 0; margin: 0;
opacity: 1; opacity: 1;
pointer-events: auto; pointer-events: auto;
} }
bz-select option:hover{ bz-select option:hover,
div.options-container option:hover{
background-color: #44F; background-color: #44F;
color: #FFF; color: #FFF;
} }
@@ -184,7 +227,7 @@ bz-slidepane[side="right"] div.handle {
top: 50%; top: 50%;
width: 11px; width: 11px;
height: 40px; height: 40px;
background: repeating-linear-gradient( to right, rgba(255,255,255,1) 0, rgba(255,255,255,1) 2px, rgba(0,0,0,0.2) 3px, rgba(0,0,0,0.2) 4px ); background: repeating-linear-gradient( to right, rgba(255,255,255,1) 0, rgba(255,255,255,1) 2px, rgba(0,0,0,0.5) 3px, rgba(0,0,0,0.5) 4px );
transform: translateY(-50%); transform: translateY(-50%);
cursor: ew-resize; cursor: ew-resize;
} }
@@ -195,14 +238,16 @@ bz-graflow {
position: relative; position: relative;
display: block; display: block;
width: 100vw; width: 100vw;
height: 50vh; height: 100vh;
box-sizing: border-box; box-sizing: border-box;
overflow: hidden;
} }
bz-graflow .bzgf-main-container{ bz-graflow .bzgf-main-container{
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
overflow: auto;
} }
/* BZGRAFLOW_CORE_START */ /* BZGRAFLOW_CORE_START */
@@ -221,7 +266,7 @@ bz-graflow .bzgf-nodes-container{ /* used to keep the nodes container pointer-ev
} }
bz-graflow .bzgf-nodes-container > * { /* allow the nodes to be moved ! */ bz-graflow .bzgf-nodes-container > * { /* allow the nodes to be moved ! */
pointer-events: auto; pointer-events: auto;
} }
bz-graflow .bzgf-nodes-container .bzgf-node{ position:absolute; } bz-graflow .bzgf-nodes-container .bzgf-node{ position:absolute; }
bz-graflow .bzgf-nodes-container .bzgf-fake-node{ bz-graflow .bzgf-nodes-container .bzgf-fake-node{
@@ -259,5 +304,117 @@ bz-graflow .bzgf-nodes-container .port.selectable:hover{
border: 5px solid #FF08!important; border: 5px solid #FF08!important;
cursor: pointer; cursor: pointer;
} }
bz-graflow .graflow-error{ background:red;color:black;position: absolute;top: 0;left: 50%;transform: translateX(-50%); }
/* BZGRAFLOW_CORE_END */ /* BZGRAFLOW_CORE_END */
bz-grafloweditor {
width: 98vw;
height: 98vh;
margin: auto;
}
bz-grafloweditor .bzgfe-main-container{
height: 100%;
width: 100%;
overflow: hidden;
display: grid;
grid-template-columns: 15vw auto;
grid-gap: 1px;
background: #FFF;
}
bz-grafloweditor .bzgfe-nodes-container{
overflow: auto;
border: 2px solid #000;
display: grid;
grid-auto-flow: row;
justify-items: center;
}
bz-grafloweditor bz-graflow{
height: 100%;
width: 100%;
}
bz-grafloweditor .bzgfe-nodes-container .bzgf-node{
position: relative;
margin: 5px auto;
}
bz-grafloweditor bz-slidepane { z-index: 10; background-color: #0008!important;}
bz-grafloweditor bz-slidepane .inner-console{
padding: 5px;
background: #FFF;
}
bz-grafloweditor .inner-console section{
display: grid;
grid-auto-flow: row;
grid-gap: 5px;
background-color: #DDD;
padding: 5px;
margin: 5px auto;
}
bz-grafloweditor .inner-console section .cols-2{
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 1em;
background-color: #CCC;
min-height: 2.5em;
}
bz-grafloweditor .inner-console section .cols-2 label{
text-align: right;
align-self: center;
}
bz-grafloweditor .inner-console section .cols-2 input{
max-height: 2em;
align-self: center;
}
bz-gantt{
display: block;
position: relative;
--row: 25px;
--bar-gap: 4px; /* space above & below each bar inside its row */
--chart-left: calc(var(--tasks-width, 7em) + 1em); /* where the chart area starts */
}
bz-gantt ul.tasks{
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
bz-gantt ul.tasks li{
box-sizing: border-box;
text-wrap: nowrap;
height: var(--row);
line-height: calc(var(--row) - 1px);
border-bottom: 1px dotted #555;
}
bz-gantt.gantt bz-graflow{
position: absolute;
left: var(--chart-left);
top: calc(var(--chart-top, var(--row)) + var(--bar-gap)); /* first task row, measured in refresh(), plus bar centering gap */
right: 0;
bottom: 0;
width: auto; /* cancel the global bz-graflow 100vw/100vh defaults, */
height: auto; /* so the box stretches between its anchored edges */
}
bz-gantt li.header div.day:first-of-type{ border-left: 1px dotted #555; }
bz-gantt li.header div.day{
position: absolute;
/* anchored to bz-gantt (nearest positioned ancestor): spans all rows */
top: var(--bar-gap);
bottom: 0;
border-right: 1px dotted #555;
font-size: .8em;
text-align: center;
}
bz-gantt li.header div.day.today{
background: #AD8;
z-index: 999;
opacity: .3;
}
+208 -27
View File
@@ -11,10 +11,60 @@
* as long as the copyright notice and license are kept. * as long as the copyright notice and license are kept.
*/ */
function BZModalDialog(title, message) {
const getFields = (dlg) => {
const form = dlg.querySelector('form')
if (!form) return {}
const fd = new FormData(form)
const out = {}
for (const [key, value] of fd.entries()) {
if (Object.prototype.hasOwnProperty.call(out, key)) {
out[key] = Array.isArray(out[key]) ? [...out[key], value] : [out[key], value]
} else {
out[key] = value
}
}
return out
}
return new Promise(resolve => {
const dlg = document.createElement('dialog')
dlg.classList.add('bz-modal-dialog')
dlg.innerHTML = `
<form method="dialog">
<header>${title}</header>
<section>${message}</section>
<footer>
<button value="cancel">Cancel</button>
<button value="ok">OK</button>
</footer>
</form>
`
dlg.addEventListener('close', () => {
const ok = dlg.returnValue.toLowerCase() === 'ok'
if(ok) {
resolve(getFields(dlg))
} else {
resolve(ok)
}
dlg.remove()
})
document.body.appendChild(dlg)
dlg.showModal()
})
}
class Buildoz extends HTMLElement { class Buildoz extends HTMLElement {
// static is evaluated when the class is defined, therefore while buildoz.js is executing.
// therefore document.currentScript refers to buildoz.js (but not later!!)
static _buildozUrl = document.currentScript?.src ?? ''
constructor(){ constructor(){
super() // always call super() first! super() // always call super() first!
this.attrs = {} this.attrs = {}
// Usefull for relative dependencies, to keep lib fully portable
this.buildozUrl = Buildoz._buildozUrl // was defined in the past
} }
static get observedAttributes(){ //observable attributes triggering attributeChangedCallback static get observedAttributes(){ //observable attributes triggering attributeChangedCallback
@@ -48,6 +98,17 @@ class Buildoz extends HTMLElement {
getBZAttribute(attrName){ // Little helper for defaults getBZAttribute(attrName){ // Little helper for defaults
return(this.getAttribute(attrName) || this.defaultAttrs[attrName] ) return(this.getAttribute(attrName) || this.defaultAttrs[attrName] )
} }
fireEvent(eventName, detail){
let myname = this.tagName.toLocaleLowerCase()
myname = myname.substring(myname.indexOf('-')+1)
const eventFullName = `bz:${myname}:${eventName}`
this.dispatchEvent(new CustomEvent(eventFullName, {
detail,
bubbles: true,
composed: true,
}))
}
} }
class BZselect extends Buildoz { class BZselect extends Buildoz {
@@ -74,7 +135,7 @@ class BZselect extends Buildoz {
if(!this.optionscontainer) this.optionscontainer = document.createElement('div') if(!this.optionscontainer) this.optionscontainer = document.createElement('div')
this.optionscontainer.classList.add('options-container') this.optionscontainer.classList.add('options-container')
this.append(this.optionscontainer) this.append(this.optionscontainer)
this.options = this.querySelectorAll('option') this.syncOptions()
if(this.#fillFromMarkup){ //can only do it once and only if fillOptions was not already called !! if(this.#fillFromMarkup){ //can only do it once and only if fillOptions was not already called !!
for(const opt of this.options){ for(const opt of this.options){
this.optionscontainer.append(opt) // Will move is to the right parent this.optionscontainer.append(opt) // Will move is to the right parent
@@ -86,6 +147,15 @@ class BZselect extends Buildoz {
} }
disconnectedCallback() {
if(this.open || this._closing) this.closeDropdown(true)
}
syncOptions() {
if(this.optionscontainer) this.options = this.optionscontainer.querySelectorAll('option')
else this.options = []
}
// static get observedAttributes(){ // Only if you want actions on attr change // static get observedAttributes(){ // Only if you want actions on attr change
// return([...super.observedAttributes, 'disabled']) // return([...super.observedAttributes, 'disabled'])
// } // }
@@ -111,19 +181,104 @@ class BZselect extends Buildoz {
} }
toggle(){ toggle(){
for(const opt of this.options){ if(this.open) this.closeDropdown()
if(this.open) { else this.openDropdown()
opt.classList.remove('open') }
this.optionscontainer.classList.remove('open')
} else { openDropdown() {
document.querySelectorAll('bz-select').forEach((sel) => { document.querySelectorAll('bz-select').forEach((sel) => {
if((sel!==this) && sel.open) sel.toggle() if((sel!==this) && sel.open) sel.closeDropdown(true)
}) })
opt.classList.add('open') this.optionscontainer.classList.add('portaled')
document.body.appendChild(this.optionscontainer)
this.positionPortal()
this.bindPortalListeners()
this.open = true
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if(!this.open) return
this.optionscontainer.classList.add('open') this.optionscontainer.classList.add('open')
for(const opt of this.options) opt.classList.add('open')
})
})
}
closeDropdown(immediate = false) {
if(!this.open) return
this.unbindPortalListeners()
for(const opt of this.options) opt.classList.remove('open')
this.optionscontainer.classList.remove('open')
if(immediate) {
this.clearCloseTransition()
this.finishCloseDropdown()
return
}
this._closing = true
this._onTransitionEnd = (evt) => {
if(evt.target !== this.optionscontainer) return
if(evt.propertyName !== 'max-height') return
this.finishCloseDropdownAfterTransition()
}
this.optionscontainer.addEventListener('transitionend', this._onTransitionEnd)
this._closeTimer = setTimeout(() => this.finishCloseDropdownAfterTransition(), 450)
}
finishCloseDropdownAfterTransition() {
if(!this._closing) return
this.clearCloseTransition()
this.finishCloseDropdown()
}
clearCloseTransition() {
this._closing = false
if(this._closeTimer) clearTimeout(this._closeTimer)
this._closeTimer = null
if(this._onTransitionEnd) {
this.optionscontainer.removeEventListener('transitionend', this._onTransitionEnd)
this._onTransitionEnd = null
}
}
finishCloseDropdown() {
this.optionscontainer.classList.remove('portaled')
this.clearPortalStyles()
if(this.optionscontainer.parentElement !== this) this.append(this.optionscontainer)
this.open = false
}
positionPortal() {
const rect = this.button.getBoundingClientRect()
this.optionscontainer.style.top = `${rect.bottom}px`
this.optionscontainer.style.left = `${rect.left}px`
this.optionscontainer.style.width = `${rect.width}px`
}
clearPortalStyles() {
this.optionscontainer.style.top = ''
this.optionscontainer.style.left = ''
this.optionscontainer.style.width = ''
}
bindPortalListeners() {
this._repositionBound = this.positionPortal.bind(this)
window.addEventListener('scroll', this._repositionBound, true)
window.addEventListener('resize', this._repositionBound)
this._outsideClickBound = (evt) => {
if(this.open && !this.contains(evt.target) && !this.optionscontainer.contains(evt.target)) {
this.closeDropdown()
} }
} }
this.open = !this.open this._outsideClickTimer = setTimeout(() => {
document.addEventListener('click', this._outsideClickBound, true)
}, 0)
}
unbindPortalListeners() {
if(this._repositionBound) window.removeEventListener('scroll', this._repositionBound, true)
if(this._repositionBound) window.removeEventListener('resize', this._repositionBound)
if(this._outsideClickBound) document.removeEventListener('click', this._outsideClickBound, true)
if(this._outsideClickTimer) clearTimeout(this._outsideClickTimer)
this._outsideClickTimer = null
} }
onClick(evt){ onClick(evt){
@@ -135,7 +290,7 @@ class BZselect extends Buildoz {
onOption(value, silent=false){ onOption(value, silent=false){
if(this.getAttribute('disabled') !== null) return if(this.getAttribute('disabled') !== null) return
this.value = value this.value = value
if(!silent) this.toggle() if(!silent && this.open) this.closeDropdown()
} }
addOption(value, markup){ addOption(value, markup){
@@ -146,16 +301,16 @@ class BZselect extends Buildoz {
opt.addEventListener('click',this.onClick.bind(this)) opt.addEventListener('click',this.onClick.bind(this))
if(!this.optionscontainer) this.optionscontainer = document.createElement('div') if(!this.optionscontainer) this.optionscontainer = document.createElement('div')
this.optionscontainer.append(opt) this.optionscontainer.append(opt)
this.options = this.querySelectorAll('option') this.syncOptions()
this.#fillFromMarkup = false this.#fillFromMarkup = false
} }
fillOptions(opts, erase = true){ fillOptions(opts, erase = true){
// Caution: you cannot count on connectedCallback to have run already, because one might fill before adding to the DOM // Caution: you cannot count on connectedCallback to have run already, because one might fill before adding to the DOM
if(erase){ if(erase){
this.options = this.querySelectorAll('option') this.syncOptions()
this.options.forEach(node => { node.remove() }) this.options.forEach(node => { node.remove() })
this.options = this.querySelectorAll('option') this.syncOptions()
this.onOption('', true) // unselect last this.onOption('', true) // unselect last
} }
for(const opt of opts) this.addOption(opt.value, opt.markup) for(const opt of opts) this.addOption(opt.value, opt.markup)
@@ -271,6 +426,8 @@ class BZslidePane extends Buildoz {
} }
this.dragMove = this.dragMove.bind(this) this.dragMove = this.dragMove.bind(this)
this.dragEnd = this.dragEnd.bind(this) this.dragEnd = this.dragEnd.bind(this)
this.lastClientX = 0
this.lastClientY = 0
// Fill with innerHTML or other DOM manip should not allow coating to be removed // Fill with innerHTML or other DOM manip should not allow coating to be removed
this._observer = new MutationObserver(muts => { this.coat() }) this._observer = new MutationObserver(muts => { this.coat() })
} }
@@ -301,36 +458,61 @@ class BZslidePane extends Buildoz {
evt.target.setPointerCapture(evt.pointerId) evt.target.setPointerCapture(evt.pointerId)
this.dragStartX = evt.clientX this.dragStartX = evt.clientX
this.dragStartY = evt.clientY this.dragStartY = evt.clientY
this.lastClientX = evt.clientX
this.lastClientY = evt.clientY
this.handle.addEventListener('pointermove', this.dragMove) this.handle.addEventListener('pointermove', this.dragMove)
this.handle.addEventListener('pointerup', this.dragEnd) this.handle.addEventListener('pointerup', this.dragEnd)
} }
dragMove(evt){ dragMove(evt){
const box = this.getBoundingClientRect() const box = this.getBoundingClientRect()
const parentBox = this.parentElement.getBoundingClientRect() const boundaryEl = this.offsetParent || this.parentElement
let width, height const parentBox = boundaryEl.getBoundingClientRect()
let width, height, min, max
switch(this.getAttribute('side')){ switch(this.getAttribute('side')){
case 'top': case 'top':
height = (evt.clientY > box.top) ? (evt.clientY - box.top) : 0 min = parseInt(this.getBZAttribute('minheight')) || 0
if(height>(parentBox.height/2)) height = Math.floor(parentBox.height/2) if(evt.clientY > (box.top + min)) height = (evt.clientY - box.top)
else if(evt.clientY < this.lastClientY) height = min
else if(evt.clientY > this.lastClientY) height = 0
else break
max = parseInt(this.getBZAttribute('maxheight')) || Math.floor(parentBox.height/2)
height = Math.min(height, parentBox.height, max)
this.style.height = height+'px' this.style.height = height+'px'
break break
case 'bottom': case 'bottom':
height = (evt.clientY < box.bottom) ? (box.bottom - evt.clientY) : 0 min = parseInt(this.getBZAttribute('minheight')) || 0
if(height>(parentBox.height/2)) height = Math.floor(parentBox.height/2) if(evt.clientY < (box.bottom - min)) height = (box.bottom - evt.clientY)
else if(evt.clientY > this.lastClientY) height = min
else if(evt.clientY < this.lastClientY) height = 0
else break
max = parseInt(this.getBZAttribute('maxheight')) || Math.floor(parentBox.height/2)
height = Math.min(height, parentBox.height, max)
this.style.height = height+'px' this.style.height = height+'px'
break break
case 'left': case 'left':
width = (evt.clientX > box.left) ? (evt.clientX - box.left) : 0 min = parseInt(this.getBZAttribute('minwidth')) || 0
if(width>(parentBox.width/2)) width = Math.floor(parentBox.width/2) if(evt.clientX < (box.left + min)) width = (evt.clientX - box.left)
else if(evt.clientX > this.lastClientX) width = min
else if(evt.clientX < this.lastClientX) width = 0
else break
max = parseInt(this.getBZAttribute('maxwidth')) || Math.floor(parentBox.width/2)
width = Math.min(width, parentBox.width, max)
this.style.width = width+'px' this.style.width = width+'px'
break break
case'right': case 'right':
width = (evt.clientX < box.right) ? (box.right - evt.clientX) : 0 min = parseInt(this.getBZAttribute('minwidth')) || 0
if(width>(parentBox.width/2)) width = Math.floor(parentBox.width/2) if(evt.clientX < (box.right - min)) width = (box.right - evt.clientX)
else if(evt.clientX < this.lastClientX) width = min
else if(evt.clientX > this.lastClientX) width = 0
else break
max = parseInt(this.getBZAttribute('maxwidth')) || Math.floor(parentBox.width/2)
width = Math.min(width, parentBox.width, max)
this.style.width = width+'px' this.style.width = width+'px'
break break
} }
this.lastClientX = evt.clientX
this.lastClientY = evt.clientY
} }
dragEnd(evt){ dragEnd(evt){
@@ -340,4 +522,3 @@ class BZslidePane extends Buildoz {
} }
} }
Buildoz.define('slidepane', BZslidePane) Buildoz.define('slidepane', BZslidePane)
+236
View File
@@ -0,0 +1,236 @@
/**
* _ ___ Another
* / |/ (_)______ __ _____
* / / / __(_-</ // (_-<
* /_/|_/_/\__/___/\_, /___/
* /___/
* production !
*
* Licensed under the MIT License:
* This code is free to use and modify,
* as long as the copyright notice and license are kept.
*/
class BZgantt extends Buildoz {
constructor(){
super()
this.defaultAttrs = { }
}
async connectedCallback(){
await customElements.whenDefined('bz-graflow')
super.connectedCallback()
this.rowHeight = parseFloat(getComputedStyle(this).getPropertyValue('--row')) || 30
this.ul = document.createElement('ul')
this.ul.classList.add('tasks')
this.append(this.ul)
this.graflow = document.createElement('bz-graflow')
this._syncAttributesToGraflow()
this.append(this.graflow)
this.fireEvent('domConnected', { gantt: this })
this.dayWidth = this.getBZAttribute('daywidth') || 20
this.dayWidthPadding = 10
if(this.getBZAttribute('nodesfile')) this.nodesfile = this.getBZAttribute('nodesfile')
else this.initGantt()
const dataSrc = this.getBZAttribute('src')
if(dataSrc) this.loadData(dataSrc)
else this.gantt = { "tasks": [] }
}
_syncAttributesToGraflow(){
for(const attr of this.attributes){
if(attr.name === 'flow') continue
this.graflow.setAttribute(attr.name, attr.value)
}
}
async loadData(dataSrc){
let buf, ganttObj
if(dataSrc instanceof Blob){
buf = await dataSrc.text()
try{
ganttObj = JSON.parse(buf)
} catch(err){
this.error('Could not parse gantt data JSON!?', err)
return
}
} else if(typeof dataSrc == 'string') {
const url = dataSrc
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
? (url + '?' + crypto.randomUUID())
: url
const res = await fetch(fetchUrl)
buf = await res.text()
try{
ganttObj = JSON.parse(buf)
} catch(err){
this.error('Could not parse gantt data JSON!?', err)
return
}
} else if(typeof dataSrc == 'object') {
ganttObj = structuredClone(dataSrc)
}
if(!ganttObj.nodesFile){
if(this.getBZAttribute('nodesfile')) ganttObj.nodesFile = this.getBZAttribute('nodesfile')
else {
this.error('No nodesFile in JSON!?')
return
}
}
this.tasks = ganttObj.tasks
this.reorder_tasks()
await this.graflow.loadNodes(ganttObj.nodesFile)
this.refresh()
this.fireEvent('ganttDataLoaded', {
component: this,
})
}
reorder_tasks(){
const byId = new Map(this.tasks.map(t => [t.id, t]))
const children = new Map(this.tasks.map(t => [t.id, []]))
for(const task of this.tasks){
for(const dep of task.dependsOn ?? []){
if(children.has(dep)) children.get(dep).push(task)
}
}
// Subtree weight: number of (unique) descendants of a task
const descendants = new Map()
const countDescendants = (task, seen) => {
for(const child of children.get(task.id)){
if(seen.has(child.id)) continue
seen.add(child.id)
countDescendants(child, seen)
}
return(seen.size)
}
for(const task of this.tasks) descendants.set(task.id, countDescendants(task, new Set()))
const byWeight = (a, b) => descendants.get(a.id) - descendants.get(b.id)
// Depth-first walk, a task is placed once all its dependencies are placed
const ordered = []
const placed = new Set()
const ready = task => (task.dependsOn ?? []).every(dep => placed.has(dep) || !byId.has(dep))
const visit = task => {
if(placed.has(task.id) || !ready(task)) return
placed.add(task.id)
ordered.push(task)
for(const child of [...children.get(task.id)].sort(byWeight)) visit(child)
}
const roots = this.tasks.filter(t => !(t.dependsOn?.length)).sort(byWeight)
for(const root of roots) visit(root)
// Leftovers (circular dependencies) keep their original order
for(const task of this.tasks) if(!placed.has(task.id)) ordered.push(task)
this.tasks = ordered
}
getDayIndex(firstDate, date){
return Math.ceil((date-firstDate)/86400000)
}
buildFlow(){
let firstDate = new Date(this.tasks[0].start)
let lastDate = new Date(this.tasks[0].end)
for(const task of this.tasks){
const startDate = new Date(task.start)
const endDate = new Date(task.end)
if(startDate < firstDate) firstDate = startDate
if(endDate > lastDate) lastDate = endDate
}
const flow = { "nodes": [], "links": [] }
let curY = 0
const endIdx = this.getDayIndex(firstDate, lastDate)
for(const task of this.tasks){
const startIdx = this.getDayIndex(firstDate, new Date(task.start))
const taskEndIdx = this.getDayIndex(firstDate, new Date(task.end))
const markup = {}
for(const [key, value] of Object.entries(task)){
if(value == null || typeof value === 'object') continue
markup[`task.${key}`] = value
}
if(!markup['task.color']) markup['task.color'] = '#CCC'
markup.width = (startIdx<taskEndIdx) ? (taskEndIdx-startIdx) * this.dayWidth : this.dayWidth
flow.nodes.push({
"nodeType": "bar",
"id": task.id,
"coords": {
"x": (startIdx * this.dayWidth) + (startIdx > 0 ? this.dayWidthPadding : 0),
"y": curY,
},
"markup": markup
})
for(const dep of task.dependsOn ?? []){
flow.links.push({ "from": [dep, "out1"], "to": [task.id, "inp1"] })
}
curY += this.rowHeight
}
return([flow, firstDate, endIdx])
}
refresh(){
this.ul.innerHTML = ''
this.headerLi = document.createElement('li')
this.headerLi.classList.add('header')
this.ul.appendChild(this.headerLi)
for(const task of this.tasks){
const li = document.createElement('li')
li.textContent = task.name
li.setAttribute('data-id', task.id)
this.ul.appendChild(li)
}
// Publish the widest label width, used by CSS to place the graflow
const range = document.createRange()
let maxWidth = 0
for(const li of this.ul.children){
range.selectNodeContents(li)
maxWidth = Math.max(maxWidth, range.getBoundingClientRect().width)
}
this.style.setProperty('--tasks-width', Math.ceil(maxWidth) + 'px')
const taskLis = [...this.ul.children].slice(1)
const row = parseFloat(getComputedStyle(this).getPropertyValue('--row')) || this.rowHeight || 25
if(taskLis[0] && taskLis[0].offsetHeight){
this.rowHeight = taskLis[1] ? (taskLis[1].offsetTop - taskLis[0].offsetTop) : taskLis[0].offsetHeight
this.style.setProperty('--chart-top', `${taskLis[0].offsetTop}px`)
} else {
this.rowHeight = row
this.style.setProperty('--chart-top', `${row}px`)
}
const [flow, firstDate, endIdx] = this.buildFlow()
let dayDate = new Date(firstDate)
for(let idx=0; idx<=endIdx; idx++){
const dayDiv = document.createElement('div')
dayDiv.classList.add('day')
dayDiv.style.left = `calc(var(--chart-left) + ${idx * (this.dayWidth + this.dayWidthPadding)}px)`
dayDiv.style.width = (this.dayWidth + this.dayWidthPadding) + 'px'
dayDiv.innerHTML = '&nbsp;' + dayDate.getDate()
if(dayDate.toISOString().substring(0,10) == (new Date()).toISOString().substring(0,10)) dayDiv.classList.add('today')
dayDiv.setAttribute('title', new Intl.DateTimeFormat('fr-FR', {
timeZone: 'Europe/Paris',
day: '2-digit',
month: '2-digit',
year: '2-digit'
}).format(dayDate))
dayDate.setDate(dayDate.getDate() + 1)
this.headerLi.appendChild(dayDiv)
}
this.graflow.loadFlow({
"nodesFile": this.nodesfile,
"flow": flow
})
this.graflow.refresh()
}
}
Buildoz.define('gantt', BZgantt)
+192
View File
@@ -0,0 +1,192 @@
/**
* _ ___ Another
* / |/ (_)______ __ _____
* / / / __(_-</ // (_-<
* /_/|_/_/\__/___/\_, /___/
* /___/
* production !
*
* Licensed under the MIT License:
* This code is free to use and modify,
* as long as the copyright notice and license are kept.
*/
class BZgrafloweditor extends Buildoz{
constructor(){
super()
this.defaultAttrs = { }
}
async connectedCallback() {
await customElements.whenDefined('bz-graflow')
await customElements.whenDefined('bz-slidepane')
await customElements.whenDefined('bz-select')
super.connectedCallback()
const nodesUrl = this.getBZAttribute('nodes')
this.mainContainer = document.createElement('div')
this.mainContainer.classList.add('bzgfe-main-container')
this.nodesContainer = document.createElement('div')
this.nodesContainer.classList.add('bzgfe-nodes-container')
this.mainContainer.append(this.nodesContainer)
this.slidePane = document.createElement('bz-slidepane')
this.slidePane.setAttribute('side', 'right')
this.slidePane.setAttribute('data-output', 'console')
this.slidePane.setAttribute('maxwidth', '350')
this.slidePane.setAttribute('minwidth', '200')
this.fillconsole()
//this.mainContainer.append(this.slidePane)
this.graflow = document.createElement('bz-graflow')
this.graflow.setAttribute('nodes', nodesUrl)
this.graflow.setAttribute('edit', "nodesmove,editwires,dropnodes")
this.graflow.setAttribute('align', "center")
this.graflow.setAttribute('wiretype', "bezier")
this.graflow.setAttribute('tension', "30")
this.graflow.setAttribute('gapx', "80")
this.graflow.setAttribute('gapy', "80")
this.graflow.addEventListener('bz:graflow:domConnected', this.setupDropZone.bind(this))
this.graflow.append(this.slidePane)
this.mainContainer.append(this.graflow)
this.append(this.mainContainer)
document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click',
(evt) => { this.graflow.autoPlace('horizontal', null, null, 1000, null) }
)
document.querySelector('[data-trigger="onAutoplace1V"]').addEventListener('click',
(evt) => { this.graflow.autoPlace('vertical', null, null, 1000, null) }
)
document.querySelector('input[name="tension"]').addEventListener('change',
(evt) => { this.graflow.setAttribute('tension', evt.target.value); this.graflow.refresh() }
)
document.querySelector('input[name="gapx"]').addEventListener('change',
(evt) => { this.graflow.setAttribute('gapx', evt.target.value); this.graflow.refresh() }
)
document.querySelector('input[name="gapy"]').addEventListener('change',
(evt) => { this.graflow.setAttribute('gapy', evt.target.value); this.graflow.refresh() }
)
document.querySelector('bz-select[name="wiretype"]').addEventListener('change',
(evt) => { this.graflow.setAttribute('wiretype', evt.target.value); this.graflow.refresh() }
)
document.querySelector('bz-select[name="align"]').addEventListener('change',
(evt) => { this.graflow.setAttribute('align', evt.target.value); this.graflow.refresh() }
)
this.graflow.addEventListener('bz:graflow:nodesLoaded', this.refreshNodes.bind(this))
this.graflow.loadNodes(nodesUrl)
}
fillconsole(){
this.slidePane.innerHTML = `
<div class="inner-console">
<section>
<button data-trigger="onAutoplace1H">Auto-place Horizontal</button>
<button data-trigger="onAutoplace1V">Auto-place Vertical</button>
<div class="cols-2"><label>GapX</label><input name="gapx" type="number" size="2" value="80"></div>
<div class="cols-2"><label>GapY</label><input name="gapy" type="number" size="2" value="80"></div>
<div class="cols-2">
<label>Alignment</label>
<bz-select name="align">
<option value="center" selected>Center</option>
<option value="first">First</option>
<option value="last">Last</option>
<option value="parent">Parent</option>
</bz-select>
</div>
<div class="cols-2">
<label>Wire Type</label>
<bz-select name="wiretype">
<option value="ortho">Ortho</option>
<option value="straight">Straight</option>
<option value="bezier" selected>Bezier</option>
</bz-select>
</div>
<div class="cols-2"><label>Tension</label><input name="tension" type="number" size="2" value="30"></div>
</section>
<section>
<button data-trigger="onImportFlow">Import Flow</button>
<button data-trigger="onExportFlow">Export Flow</button>
<input type="file" name="importFlow" accept="application/json" style="display: none;">
</section>
</div>
`
this.onImportFlow = this.onImportFlow.bind(this)
this.onExportFlow = this.onExportFlow.bind(this)
this.slidePane.querySelector('button[data-trigger="onExportFlow"]').addEventListener('click', (e) => this.onExportFlow(e)) // indirect so override works !
this.slidePane.querySelector('button[data-trigger="onImportFlow"]').addEventListener('click', (e) => this.onImportFlow(e))// indirect so override works !
}
refreshNodes(e){
for(const nodeType in this.graflow.nodesRegistry){
const nodeDef = this.graflow.nodesRegistry[nodeType]
if(nodeDef.dataset.editor=='exclude') continue
const node = nodeDef.cloneNode(true)
this.makeNodeDraggable(node)
this.nodesContainer.append(node)
}
}
makeNodeDraggable(node){
node.draggable = true
node.style.cursor = 'pointer'
node.addEventListener('dragstart', (evt) => {
evt.dataTransfer.setData('text/plain', node.dataset.nodetype)
evt.dataTransfer.effectAllowed = 'copy'
evt.dataTransfer.setDragImage(node, evt.offsetX, evt.offsetY)
})
}
onNodeDragEnd(evt){
console.log('drag end', evt)
evt.dataTransfer.clearData()
}
setupDropZone(){
const dropZone = this.graflow.wiresContainer
const nodesContainer = this.graflow.nodesContainer
dropZone.addEventListener('dragover', (evt) => {
evt.preventDefault()
evt.dataTransfer.dropEffect = 'copy'
})
dropZone.addEventListener('drop', (evt) => {
evt.preventDefault()
const nodeType = evt.dataTransfer.getData('text/plain')
if(!nodeType || !(nodeType in this.graflow.nodesRegistry)) return
const rect = nodesContainer.getBoundingClientRect()
const x = evt.clientX - rect.left + nodesContainer.scrollLeft
const y = evt.clientY - rect.top + nodesContainer.scrollTop
const id = 'n' + crypto.randomUUID().replace(/-/g, '').slice(0, 8)
this.graflow.addNode({ id, nodeType, coords: { x, y } })
for(const node of this.graflow.flow.nodes){
if(node.id == id){
node.coords.x = x
node.coords.y = y
break
}
}
this.graflow.refresh()
})
}
onImportFlow(e){
const fileInput = this.slidePane.querySelector('input[name="importFlow"]')
fileInput.addEventListener('change', (evt) => {
const file = evt.target.files[0]
if(file) this.graflow.loadFlow(file)
fileInput.value = ''
}, { once: true })
fileInput.click()
}
onExportFlow(e){
const flowDeep = JSON.parse(JSON.stringify(this.graflow.flow))
delete flowDeep.longLinks
const exportObj = {
nodesFile: this.getBZAttribute('nodes'),
flow: flowDeep
}
const flowJson = JSON.stringify(exportObj, null, 2)
const flowBlob = new Blob([flowJson], { type: 'application/json' })
const flowUrl = URL.createObjectURL(flowBlob)
const flowLink = document.createElement('a')
flowLink.href = flowUrl
flowLink.download = 'flow.json'
flowLink.click()
}
}
Buildoz.define('grafloweditor', BZgrafloweditor)
+433 -150
View File
@@ -10,8 +10,6 @@
* This code is free to use and modify, * This code is free to use and modify,
* as long as the copyright notice and license are kept. * as long as the copyright notice and license are kept.
*/ */
const scriptUrl = document.currentScript.src
class BZgraflow extends Buildoz{ class BZgraflow extends Buildoz{
dirVect = { dirVect = {
n: { x: 0, y: -1 }, n: { x: 0, y: -1 },
@@ -32,15 +30,16 @@ class BZgraflow extends Buildoz{
this.stagedNodes = { } this.stagedNodes = { }
this.stagedWires = { } this.stagedWires = { }
this.arrowDefs = null this.arrowDefs = null
this.arrowMarkerId = `arrow-${crypto.randomUUID()}`
this.currentOrientation = null this.currentOrientation = null
} }
static _coreCssPromise = null static _coreCssPromise = null
static async getCoreCss(){ async getCoreCss(){
if(BZgraflow._coreCssPromise) return(await BZgraflow._coreCssPromise) if(BZgraflow._coreCssPromise) return(await BZgraflow._coreCssPromise)
BZgraflow._coreCssPromise = (async() => { BZgraflow._coreCssPromise = (async() => {
const url = new URL('./buildoz.css', scriptUrl) const url = new URL('./buildoz.css', this.buildozUrl)
const res = await fetch(url) const res = await fetch(url)
const css = await res.text() const css = await res.text()
const m = css.match(/\/\*\s*BZGRAFLOW_CORE_START\s*\*\/([\s\S]*?)\/\*\s*BZGRAFLOW_CORE_END\s*\*\//) const m = css.match(/\/\*\s*BZGRAFLOW_CORE_START\s*\*\/([\s\S]*?)\/\*\s*BZGRAFLOW_CORE_END\s*\*\//)
@@ -54,7 +53,7 @@ class BZgraflow extends Buildoz{
if(!this.hasAttribute('isolated')) return if(!this.hasAttribute('isolated')) return
if(this._isolatedCoreInjected) return if(this._isolatedCoreInjected) return
this._isolatedCoreInjected = true this._isolatedCoreInjected = true
const core = await BZgraflow.getCoreCss() const core = await this.getCoreCss()
// Convert light-dom selectors (`bz-graflow ...`) to shadow-dom selectors (`:host ...`) // Convert light-dom selectors (`bz-graflow ...`) to shadow-dom selectors (`:host ...`)
const shadowCss = core.replaceAll('bz-graflow', ':host') const shadowCss = core.replaceAll('bz-graflow', ':host')
const style = document.createElement('style') const style = document.createElement('style')
@@ -68,10 +67,6 @@ class BZgraflow extends Buildoz{
connectedCallback() { connectedCallback() {
super.connectedCallback() super.connectedCallback()
const flowUrl = this.getBZAttribute('flow')
if(!flowUrl) return // Be tolerant: maybe injected later from JS above
// If attribute "isolated" is present, render inside a shadow root.
// Otherwise, render in light DOM (no shadow DOM).
this.hostContainer = document.createElement('div') this.hostContainer = document.createElement('div')
this.hostContainer.classList.add('bzgf-main-container') this.hostContainer.classList.add('bzgf-main-container')
this.mainContainer = this.hasAttribute('isolated') this.mainContainer = this.hasAttribute('isolated')
@@ -98,26 +93,71 @@ class BZgraflow extends Buildoz{
this.NodesReceiver = new DroppingNodes(this, '.bzgf-node') this.NodesReceiver = new DroppingNodes(this, '.bzgf-node')
} }
} }
this.loadFlow(flowUrl) this.fireEvent('domConnected', { graflow: this })
const flowUrl = this.getBZAttribute('flow')
if(flowUrl) this.loadFlow(flowUrl)
else this.initFlow()
}
static get observedAttributes(){
return([...super.observedAttributes, 'disabled'])
}
attributeChangedCallback(name, oldValue, newValue) {
super.attributeChangedCallback(name, oldValue, newValue)
if(name == 'disabled'){
if(newValue === null) {
this.disabled = false
this.style.opacity = 1
this.style.pointerEvents = 'auto'
} else {
this.disabled = true
this.style.opacity = 0.5
this.style.pointerEvents = 'none'
}
this.querySelectorAll('.bzgf-zoom-in, .bzgf-zoom-out').forEach((btn) => {
btn.disabled = this.disabled
})
}
} }
error(msg, err){ error(msg, err){
this.innerHTML = `<div style="background:red;color:black;margin: auto;width: fit-content;">${msg}</div>` this.querySelector('.graflow-error')?.remove()
const errorEl = document.createElement('div')
errorEl.classList.add('graflow-error')
errorEl.innerHTML = `${msg}`
this.appendChild(errorEl)
if(err) console.error(msg, err) if(err) console.error(msg, err)
else console.error(msg) else console.error(msg)
} }
async loadFlow(url){ async loadFlow(source){
const res = await fetch(url+'?'+crypto.randomUUID()) let buf, flowObj
const buf = await res.text() if(source instanceof Blob){
let flowObj buf = await source.text()
try{ try{
flowObj = JSON.parse(buf) flowObj = JSON.parse(buf)
} catch(err){ } catch(err){
this.error('Could not parse flow JSON!?', err) this.error('Could not parse flow JSON!?', err)
return
return }
} else if(typeof source == 'string') {
const url = source
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
? (url + '?' + crypto.randomUUID())
: url
const res = await fetch(fetchUrl)
buf = await res.text()
try{
flowObj = JSON.parse(buf)
} catch(err){
this.error('Could not parse flow JSON!?', err)
return
}
} else if(typeof source == 'object') {
flowObj = structuredClone(source)
} }
if(!flowObj.nodesFile){ if(!flowObj.nodesFile){
this.error('No nodesFile in JSON!?') this.error('No nodesFile in JSON!?')
return return
@@ -125,11 +165,14 @@ class BZgraflow extends Buildoz{
await this.loadNodes(flowObj.nodesFile) await this.loadNodes(flowObj.nodesFile)
this.flow = flowObj.flow this.flow = flowObj.flow
this.refresh() this.refresh()
this.dispatchEvent(new CustomEvent('flowLoaded', { this.fireEvent('flowLoaded', {
detail: { url }, parentNodeId: null,
bubbles: true, component: this,
composed: true, })
})) }
initFlow(){
this.flow = { nodes: [], links: [] }
} }
async loadNodes(url) { async loadNodes(url) {
@@ -142,6 +185,8 @@ class BZgraflow extends Buildoz{
for(const tpl of doc.querySelectorAll('template')){ for(const tpl of doc.querySelectorAll('template')){
if(tpl.id=='svg-arrows'){ if(tpl.id=='svg-arrows'){
this.arrowDefs = tpl.querySelector('defs').cloneNode(true) this.arrowDefs = tpl.querySelector('defs').cloneNode(true)
const defaultArrow = this.arrowDefs.querySelector('#arrow')
if(defaultArrow) defaultArrow.id = this.arrowMarkerId
this.wiresContainer.appendChild(this.arrowDefs) this.wiresContainer.appendChild(this.arrowDefs)
} else { } else {
const rootEl = tpl.content.querySelector('.bzgf-node') const rootEl = tpl.content.querySelector('.bzgf-node')
@@ -172,11 +217,7 @@ class BZgraflow extends Buildoz{
BZgraflow._loadedNodeStyles.add(url) BZgraflow._loadedNodeStyles.add(url)
} }
} }
this.dispatchEvent(new CustomEvent('nodesLoaded', { this.fireEvent('nodesLoaded', { url: url })
detail: { url },
bubbles: true,
composed: true,
}))
} }
addNode(node){ addNode(node){
@@ -189,8 +230,8 @@ class BZgraflow extends Buildoz{
} }
if(typeof(node.data)=='object') Object.assign(this.stagedNodes[id].dataset, node.data) if(typeof(node.data)=='object') Object.assign(this.stagedNodes[id].dataset, node.data)
const portEls = this.stagedNodes[id].querySelectorAll('.port') const portEls = this.stagedNodes[id].querySelectorAll('.port')
this.stagedNodes[id].style.left = (node.coords && node.coords.x) ? `${node.coords.x}px` : '10%' this.stagedNodes[id].style.left = (node.coords && node.coords.x != null) ? `${node.coords.x}px` : '10%'
this.stagedNodes[id].style.top = (node.coords && node.coords.y) ? `${node.coords.y}px` : '10%' this.stagedNodes[id].style.top = (node.coords && node.coords.y != null) ? `${node.coords.y}px` : '10%'
this.stagedNodes[id].dataset.id = id this.stagedNodes[id].dataset.id = id
this.stagedNodes[id].ports = Object.fromEntries(Array.from(portEls).map(item => ([item.dataset.id, { ...item.dataset, el:item }]))) this.stagedNodes[id].ports = Object.fromEntries(Array.from(portEls).map(item => ([item.dataset.id, { ...item.dataset, el:item }])))
if(node.subflow) { if(node.subflow) {
@@ -201,6 +242,7 @@ class BZgraflow extends Buildoz{
this.enterSubflow(id) this.enterSubflow(id)
}) })
this.stagedNodes[id].appendChild(btnEnterSubflow) this.stagedNodes[id].appendChild(btnEnterSubflow)
this.stagedNodes[id].dataset.subflow = true
} }
this.nodesContainer.append(this.stagedNodes[id]) this.nodesContainer.append(this.stagedNodes[id])
if(!this.flow.nodes.find(n => n.id === id)) { if(!this.flow.nodes.find(n => n.id === id)) {
@@ -210,6 +252,7 @@ class BZgraflow extends Buildoz{
} }
enterSubflow(id){ enterSubflow(id){
if(this.disabled || this.hasAttribute('disabled')) return
const nodeEl = this.stagedNodes[id] const nodeEl = this.stagedNodes[id]
if(!nodeEl) return if(!nodeEl) return
@@ -217,34 +260,23 @@ class BZgraflow extends Buildoz{
// scaled down so it fits exactly inside the clicked node, then animate it to full size. // scaled down so it fits exactly inside the clicked node, then animate it to full size.
const nodeBB = nodeEl.getBoundingClientRect() const nodeBB = nodeEl.getBoundingClientRect()
const parentBB = this.getBoundingClientRect() const parentBB = this.getBoundingClientRect()
const flowNode = this.flow?.nodes?.find(n => n.id === id) const flowNode = this.flow?.nodes?.find(n => n.id === id)
const flowUrl = flowNode.subflow.url
const childEl = document.createElement('bz-graflow') const childEl = document.createElement('bz-graflow')
childEl.isSubflow = true childEl.isSubflow = true
childEl.currentOrientation = this.currentOrientation childEl.currentOrientation = this.currentOrientation
childEl.setAttribute('flow', flowUrl) const inheritedAttrs = ['orientation', 'gapx', 'gapy', 'tween', 'align', 'tension', 'wiretype', 'edit', 'autofit'] // ! Not 'isolated' !
childEl.setAttribute('tension', this.getBZAttribute('tension') || '60') for(const attrName of inheritedAttrs){
// Remember which node we "came from" so exitSubflow() can animate back to it. if(this.hasAttribute(attrName)) childEl.setAttribute(attrName, this.getAttribute(attrName))
childEl.dataset.enterNodeId = id }
const btnExitSubflow = document.createElement('button')
btnExitSubflow.classList.add('bzgf-zoom-out')
this.addIcon(btnExitSubflow, 'zoomout')
btnExitSubflow.addEventListener('click', () => {
this.exitSubflow(childEl)
})
// Put the child in the exact same viewport rect as the parent
this.invade(this, childEl)
childEl.hostContainer.appendChild(btnExitSubflow)
childEl.addEventListener('flowLoaded', (e) => { childEl.addEventListener('bz:graflow:flowLoaded', (e) => {
for(const portLink of flowNode.subflow.portLinks){ for(const portLink of flowNode.subflow.portLinks){
const nid = crypto.randomUUID() const nid = crypto.randomUUID()
childEl.addNode({ childEl.addNode({
"nodeType": portLink.refNodeType, "nodeType": portLink.refNodeType,
"id": nid, "id": nid,
"markup": { "parentport": portLink.parentPort } "markup": { ...portLink }
}) })
if(portLink.direction=='in') { if(portLink.direction=='in') {
childEl.addWire({ childEl.addWire({
@@ -258,10 +290,29 @@ class BZgraflow extends Buildoz{
}) })
} }
} }
// Rebuild once refNodes are injected so the final refresh/autofit includes them.
childEl.autoPlace(this.currentOrientation, 60, 60) childEl.refresh()
}, { once:true }) }, { once:true })
if(flowNode.subflow.url) childEl.setAttribute('flow', flowNode.subflow.url)
else {
childEl.addEventListener('bz:graflow:domConnected', async (e) => {
await childEl.loadFlow(flowNode.subflow.flow)
})
}
// Remember which node we "came from" so exitSubflow() can animate back to it.
childEl.dataset.enterNodeId = id
const btnExitSubflow = document.createElement('button')
btnExitSubflow.classList.add('bzgf-zoom-out')
this.addIcon(btnExitSubflow, 'zoomout')
btnExitSubflow.addEventListener('click', () => {
this.exitSubflow(childEl)
})
// Put the child in the exact same viewport rect as the parent
this.invade(this, childEl)
childEl.hostContainer.appendChild(btnExitSubflow)
// Fade out the current (host) graflow while the child scales up // Fade out the current (host) graflow while the child scales up
this.hostContainer.style.opacity = '1' this.hostContainer.style.opacity = '1'
this.hostContainer.style.transition = 'opacity 1000ms ease-in-out' this.hostContainer.style.transition = 'opacity 1000ms ease-in-out'
@@ -286,7 +337,7 @@ class BZgraflow extends Buildoz{
// Force style flush, then animate back to identity (full parent size) // Force style flush, then animate back to identity (full parent size)
childEl.getBoundingClientRect() childEl.getBoundingClientRect()
childEl.style.transition = 'transform 1000ms ease-in-out' childEl.style.transition = `transform ${parseInt(this.getBZAttribute('tween')) || 500}ms ease-in-out`
requestAnimationFrame(() => { requestAnimationFrame(() => {
childEl.style.top = 0; childEl.style.top = 0;
childEl.style.left = 0; childEl.style.left = 0;
@@ -302,12 +353,11 @@ class BZgraflow extends Buildoz{
this.hostContainer.style.visibility = 'hidden' this.hostContainer.style.visibility = 'hidden'
childEl.style.transform = 'none' // Important for nested subflows to position correctly childEl.style.transform = 'none' // Important for nested subflows to position correctly
childEl.style.willChange = '' childEl.style.willChange = ''
newEl.style.overflow = 'auto' childEl.style.overflow = 'auto'
this.dispatchEvent(new CustomEvent('subflowLoaded', { this.fireEvent('subflowLoaded', {
detail: { subflow: childEl }, parentNodeId: id,
bubbles: true, component: childEl
composed: true, })
}))
}, { once:true }) }, { once:true })
} }
@@ -382,11 +432,9 @@ class BZgraflow extends Buildoz{
this.hostContainer.style.opacity = '1' this.hostContainer.style.opacity = '1'
this.hostContainer.style.visibility = 'visible' this.hostContainer.style.visibility = 'visible'
childEl.style.willChange = '' childEl.style.willChange = ''
this.dispatchEvent(new CustomEvent('subflowExited', { this.fireEvent('subflowExited', {
detail: { subflow: childEl }, component: this
bubbles: true, })
composed: true,
}))
}, { once:true }) }, { once:true })
} }
@@ -402,6 +450,10 @@ class BZgraflow extends Buildoz{
return(this.stagedNodes[nid]) return(this.stagedNodes[nid])
} }
makeWireId(nid1, nid2){
return(`${encodeURIComponent(nid1)}|${encodeURIComponent(nid2)}`)
}
addWire(link){ addWire(link){
const [idNode1, idPort1] = link.from const [idNode1, idPort1] = link.from
const [idNode2, idPort2] = link.to const [idNode2, idPort2] = link.to
@@ -410,12 +462,12 @@ class BZgraflow extends Buildoz{
return return
} }
const path = this.linkNodes(idNode1, idPort1, idNode2, idPort2) const path = this.linkNodes(idNode1, idPort1, idNode2, idPort2)
const id = `${idNode1}_${idNode2}` const id = this.makeWireId(idNode1, idNode2)
this.stagedWires[id] = document.createElementNS('http://www.w3.org/2000/svg', 'path') this.stagedWires[id] = document.createElementNS('http://www.w3.org/2000/svg', 'path')
this.stagedWires[id].setAttribute('d', path) this.stagedWires[id].setAttribute('d', path)
this.stagedWires[id].setAttribute('fill', 'none') this.stagedWires[id].setAttribute('fill', 'none')
if(this.arrowDefs && link.endArrow) this.stagedWires[id].setAttribute('marker-end','url(#arrow)') if(this.arrowDefs && link.endArrow) this.stagedWires[id].setAttribute('marker-end',`url(#${this.arrowMarkerId})`)
if(this.arrowDefs && link.startArrow) this.stagedWires[id].setAttribute('marker-start','url(#arrow)') if(this.arrowDefs && link.startArrow) this.stagedWires[id].setAttribute('marker-start',`url(#${this.arrowMarkerId})`)
this.stagedWires[id].classList.add('bzgf-wire') this.stagedWires[id].classList.add('bzgf-wire')
this.stagedWires[id].dataset.id = id this.stagedWires[id].dataset.id = id
this.stagedWires[id].link = link this.stagedWires[id].link = link
@@ -438,23 +490,112 @@ class BZgraflow extends Buildoz{
this.clear() this.clear()
let forceAutoplace = false let forceAutoplace = false
for(const node of this.flow.nodes){ for(const node of this.flow.nodes){
if((!node.coords) || (!node.coords.x) ||(!node.coords.y)) forceAutoplace=true if((!node.coords) || (node.coords.x == null) || (node.coords.y == null)) forceAutoplace=true
this.addNode(node) this.addNode(node)
} }
for(const link of this.flow.links){ for(const link of this.flow.links){
this.addWire(link) this.addWire(link)
} }
if(!this.currentOrientation) { if(!this.currentOrientation) {
const bb=this.getBoundingClientRect() if(this.getBZAttribute('orientation')) {
if(bb.width > bb.height) this.currentOrientation = 'horizontal' this.currentOrientation = this.getBZAttribute('orientation')
else this.currentOrientation = 'vertical' } else {
const bb=this.getBoundingClientRect()
if(bb.width > bb.height) this.currentOrientation = 'horizontal'
else this.currentOrientation = 'vertical'
}
} }
if(forceAutoplace) this.autoPlace(this.currentOrientation) const gapx = parseInt(this.getBZAttribute('gapx')) || 80
this.dispatchEvent(new CustomEvent('refreshed', { const gapy = parseInt(this.getBZAttribute('gapy')) || 80
detail: { }, const finishRefresh = () => {
bubbles: true, this.fireEvent('refreshed', { })
composed: true, if(this.hasAttribute('autofit')){
})) const autofitAttr = this.getAttribute('autofit')
const autofitPerc = (autofitAttr !== null && autofitAttr !== '' && !Number.isNaN(parseFloat(autofitAttr)))
? parseFloat(autofitAttr)
: undefined
if(this._canRunAutoPlace()) this.autofit(autofitPerc)
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPerc))
}
}
const onLayoutComplete = () => {
this.fireEvent('layoutComplete', { })
finishRefresh()
}
if(forceAutoplace) this._scheduleAutoPlaceWhenReady(this.currentOrientation, gapx, gapy, onLayoutComplete)
else onLayoutComplete()
}
disconnectedCallback(){
this._disconnectLayoutObserver()
super.disconnectedCallback?.()
}
_disconnectLayoutObserver(){
if(this._layoutObserver) {
this._layoutObserver.disconnect()
this._layoutObserver = null
}
}
_canRunAutoPlace(){
let nodesHaveLayoutSize = false
const ids = Object.keys(this.stagedNodes || {})
if(ids.length === 0) return(true)
for(const nid of ids){
if(nid.startsWith('longLinkPlaceHolder_')) continue
const el = this.stagedNodes[nid]
if(el && (el.offsetWidth > 0 || el.offsetHeight > 0)) {
nodesHaveLayoutSize=true
break
}
}
return((this.clientWidth > 0 && this.clientHeight > 0) && nodesHaveLayoutSize)
}
/**
* autoPlace uses offsetWidth/offsetHeight; when the host is hidden (display:none / off-screen view)
* those are 0 and layout is wrong. Defer until the element is measurable.
*/
_scheduleLayoutWhenReady(callback){
this._layoutScheduleToken = (this._layoutScheduleToken || 0) + 1
const token = this._layoutScheduleToken
this._disconnectLayoutObserver()
const attempt = () => {
if(token !== this._layoutScheduleToken) return(true)
if(!this._canRunAutoPlace()) return(false)
this._disconnectLayoutObserver()
callback()
return(true)
}
if(attempt()) return
this._layoutObserver = new ResizeObserver(() => { attempt() })
this._layoutObserver.observe(this)
let frames = 0
const rafPoll = () => {
if(token !== this._layoutScheduleToken) return
if(attempt()) return
if(++frames < 12) requestAnimationFrame(rafPoll)
}
requestAnimationFrame(rafPoll)
}
_scheduleAutoPlaceWhenReady(orientation, gapx, gapy, onLayoutComplete){
this._scheduleLayoutWhenReady(() => {
this.autoPlace(orientation, gapx, gapy, null, null, onLayoutComplete)
})
}
_maybeFireLayoutComplete(){
if(this._layoutMovePending > 0) return
if(!this._layoutCompleteHandler) return
const fn = this._layoutCompleteHandler
this._layoutCompleteHandler = null
fn()
} }
// Convert viewport (client) coordinates to this instance's SVG local coordinates. // Convert viewport (client) coordinates to this instance's SVG local coordinates.
@@ -644,32 +785,36 @@ class BZgraflow extends Buildoz{
return(path) return(path)
} }
autoPlace(orientation = 'horizontal', gapx = null, gapy = null, tween = null, align = null){ autoPlace(orientation = null, gapx = null, gapy = null, tween = null, align = null, onLayoutComplete = null){
if(gapx == null) gapx = parseInt(this.getBZAttribute('gapx')) || 80 if(orientation == null) orientation = this.getBZAttribute('orientation') || this.currentOrientation || 'horizontal'
if(gapy == null) gapy = parseInt(this.getBZAttribute('gapy')) || 80 if(gapx == null) gapx = parseInt(this.getBZAttribute('gapx')) || 80
if(tween == null) tween = parseInt(this.getBZAttribute('tween')) || 500 if(gapy == null) gapy = parseInt(this.getBZAttribute('gapy')) || 80
if(align == null) align = this.getBZAttribute('align') || 'center' if(tween == null) tween = parseInt(this.getBZAttribute('tween')) || 500
if(align == null) align = this.getBZAttribute('align') || 'center'
this.currentOrientation = orientation this.currentOrientation = orientation
// Cancel any previous autoPlace() animations by bumping a token. // Cancel any previous autoPlace() animations by bumping a token.
// moveNode() checks this token each frame and will no-op if superseded. // moveNode() checks this token each frame and will no-op if superseded.
this._autoPlaceToken = (this._autoPlaceToken || 0) + 1 this._autoPlaceToken = (this._autoPlaceToken || 0) + 1
const token = this._autoPlaceToken const token = this._autoPlaceToken
this._layoutMovePending = 0
this._layoutCompleteToken = token
this._layoutCompleteHandler = (typeof onLayoutComplete === 'function') ? onLayoutComplete : null
// Cleanup placeholders from previous autoPlace() runs. // Cleanup placeholders from previous autoPlace() runs.
// Each run creates new longLinkPlaceHolder_* IDs; without cleanup they accumulate in the DOM. // Each run creates new longLinkPlaceHolder_* IDs; without cleanup they accumulate in the DOM.
this.clearFakeNodes() this.clearFakeNodes()
let links = Object.values(this.stagedWires).map(w => w?.link).filter(Boolean)
links = links.length ? links : (this.flow?.links || [])
// Loops create infinite recursion in dfs for getting parents & adjacency lists: Remove them ! // Loops create infinite recursion in dfs for getting parents & adjacency lists: Remove them !
let linksWithoutBackEdges let linksWithoutBackEdges
if(this.hasAnyLoop(this.flow.nodes, this.flow.links)){ if(this.hasAnyLoop(this.flow.nodes, links)){
const backEdges = this.findBackEdges(this.flow.nodes, this.flow.links) const backEdges = this.findBackEdges(this.flow.nodes, links)
linksWithoutBackEdges = this.flow.links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0])) linksWithoutBackEdges = links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
} else { } else {
linksWithoutBackEdges = this.flow.links linksWithoutBackEdges = links
} }
const { parents, adj } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges) const { parents, adj } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
const layers = this.computeLayers(this.flow.nodes, parents) const layers = this.computeLayers(this.flow.nodes, parents)
// Layer-0 nodes have no parents, so reorderLayers() (which uses parent ordering) cannot // Layer-0 nodes have no parents, so reorderLayers() (which uses parent ordering) cannot
@@ -718,10 +863,9 @@ class BZgraflow extends Buildoz{
layerWidths.push(totWidth) layerWidths.push(totWidth)
} }
// If any long-links, create placeholders for skipped layers // If any long-links, create placeholders for skipped layers
this._virtualLinks = new Map() this._virtualLinks = new Map()
this.flow.longLinks = this.findLongLinks(this.flow.links) this.flow.longLinks = this.findLongLinks(links)
for(const llink of this.flow.longLinks){ for(const llink of this.flow.longLinks){
let fakeParent = llink.link.from[0] let fakeParent = llink.link.from[0]
for(const layerIdx of llink.skippedLayers){ for(const layerIdx of llink.skippedLayers){
@@ -779,7 +923,7 @@ class BZgraflow extends Buildoz{
y = Math.max(parentsY[parents[nid][0]], y) //TODO handle multiple parents with avg y = Math.max(parentsY[parents[nid][0]], y) //TODO handle multiple parents with avg
} }
placedY = y placedY = y
this.moveNode(nid, x, y, orientation, tween, null, token) this.moveNode(nid, x, y, orientation, tween, token)
if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) { if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) {
parentsY[parents[nid][0]] += gapy + nodeHeight parentsY[parents[nid][0]] += gapy + nodeHeight
} else { } else {
@@ -792,7 +936,7 @@ class BZgraflow extends Buildoz{
} }
placedY = y placedY = y
this.addFakeNode(nid, x, y, wMax*0.75, fakeNodeHeight) this.addFakeNode(nid, x, y, wMax*0.75, fakeNodeHeight)
this.moveNode(nid, x, y, orientation, tween, null, token) this.moveNode(nid, x, y, orientation, tween, token)
// Never increment parentsY for fake nodes: they're placeholders and must not disalign real children // Never increment parentsY for fake nodes: they're placeholders and must not disalign real children
y = Math.max(y, placedY + gapy + fakeNodeHeight) y = Math.max(y, placedY + gapy + fakeNodeHeight)
} }
@@ -813,7 +957,7 @@ class BZgraflow extends Buildoz{
!nid.startsWith('longLinkPlaceHolder_') && nid in parents && parents[nid][0] === pid !nid.startsWith('longLinkPlaceHolder_') && nid in parents && parents[nid][0] === pid
) )
if(firstRealChild && nodeY[pid] !== nodeY[firstRealChild]){ if(firstRealChild && nodeY[pid] !== nodeY[firstRealChild]){
this.moveNode(pid, nodeX[pid], nodeY[firstRealChild], orientation, tween, null, token) this.moveNode(pid, nodeX[pid], nodeY[firstRealChild], orientation, tween, token)
nodeY[pid] = nodeY[firstRealChild] nodeY[pid] = nodeY[firstRealChild]
} }
} }
@@ -842,17 +986,18 @@ class BZgraflow extends Buildoz{
for(const nid of layer){ for(const nid of layer){
if(!nid.startsWith('longLinkPlaceHolder_')){ if(!nid.startsWith('longLinkPlaceHolder_')){
const bb = this.stagedNodes[nid].getBoundingClientRect() const bb = this.stagedNodes[nid].getBoundingClientRect()
this.moveNode(nid, x, y, orientation, tween, null, token) this.moveNode(nid, x, y, orientation, tween, token)
x += gapx + (this.stagedNodes[nid].offsetWidth || bb.width) x += gapx + (this.stagedNodes[nid].offsetWidth || bb.width)
} else { } else {
this.addFakeNode(nid, x, y, fakeNodeWidth, hMax*0.75) this.addFakeNode(nid, x, y, fakeNodeWidth, hMax*0.75)
this.moveNode(nid, x, y, orientation, tween, null, token) this.moveNode(nid, x, y, orientation, tween, token)
x += gapx + fakeNodeWidth x += gapx + fakeNodeWidth
} }
} }
y += hMax + gapy y += hMax + gapy
} }
} }
this._maybeFireLayoutComplete()
} }
clearFakeNodes(){ clearFakeNodes(){
@@ -972,17 +1117,34 @@ class BZgraflow extends Buildoz{
} }
moveNode(nid, destx, desty, orientation, duration = 200, autoPlaceToken = null) { moveNode(nid, destx, desty, orientation, duration = 200, autoPlaceToken = null) {
const t0 = performance.now()
const el0 = this.stagedNodes?.[nid] const el0 = this.stagedNodes?.[nid]
if(!el0) return if(!el0) return
let layoutTracked = false
if(autoPlaceToken != null && autoPlaceToken === this._layoutCompleteToken) {
layoutTracked = true
this._layoutMovePending++
}
const finishLayoutMove = () => {
if(!layoutTracked) return
layoutTracked = false
this._layoutMovePending = Math.max(0, this._layoutMovePending - 1)
this._maybeFireLayoutComplete()
}
const t0 = performance.now()
const bb = el0.getBoundingClientRect() const bb = el0.getBoundingClientRect()
const parentbb = el0.parentElement.getBoundingClientRect() const parentbb = el0.parentElement.getBoundingClientRect()
const x0=bb.x - parentbb.x const x0=bb.x - parentbb.x
const y0 = bb.y - parentbb.y const y0 = bb.y - parentbb.y
function frame(t) { function frame(t) {
if(autoPlaceToken && autoPlaceToken !== this._autoPlaceToken) return if(autoPlaceToken && autoPlaceToken !== this._autoPlaceToken) {
finishLayoutMove()
return
}
const el = this.stagedNodes?.[nid] const el = this.stagedNodes?.[nid]
if(!el) return if(!el) {
finishLayoutMove()
return
}
const p = Math.min((t - t0) / duration, 1) const p = Math.min((t - t0) / duration, 1)
const k = p * p * (3 - 2 * p) // smoothstep const k = p * p * (3 - 2 * p) // smoothstep
const x = x0 + (destx - x0) * k const x = x0 + (destx - x0) * k
@@ -993,11 +1155,14 @@ class BZgraflow extends Buildoz{
if(p < 1) requestAnimationFrame(frame.bind(this)) if(p < 1) requestAnimationFrame(frame.bind(this))
else{ else{
this.dispatchEvent(new CustomEvent('nodeMoved', { const flowNode = this.flow?.nodes?.find(n => n.id === nid)
detail: { nid, x, y }, if(flowNode) {
bubbles: true, if(!flowNode.coords) flowNode.coords = {}
composed: true, flowNode.coords.x = x
})) flowNode.coords.y = y
}
this.fireEvent('nodeMoved', { nid, x, y })
finishLayoutMove()
} }
} }
requestAnimationFrame(frame.bind(this)) requestAnimationFrame(frame.bind(this))
@@ -1005,10 +1170,14 @@ class BZgraflow extends Buildoz{
updateWires(nid, orientation, LondLinkfix = false){ updateWires(nid, orientation, LondLinkfix = false){
const wires = Object.keys(this.stagedWires) const wires = Object.keys(this.stagedWires)
.filter(id => (id.startsWith(nid+'_')||id.endsWith('_'+nid)))
.map(id => this.stagedWires[id]) .map(id => this.stagedWires[id])
.filter(wire => {
const lnk = wire?.link
return(lnk && (lnk.from?.[0] == nid || lnk.to?.[0] == nid))
})
for(const wire of wires){ for(const wire of wires){
const [nid1, nid2] = wire.dataset.id.split('_') const nid1 = wire.link.from[0]
const nid2 = wire.link.to[0]
const lnk = this.getLink(nid1, nid2) const lnk = this.getLink(nid1, nid2)
if(!lnk) continue if(!lnk) continue
if(!this.flow?.longLinks) this.flow.longLinks = [] if(!this.flow?.longLinks) this.flow.longLinks = []
@@ -1021,15 +1190,11 @@ class BZgraflow extends Buildoz{
wire.setAttribute('d', path) wire.setAttribute('d', path)
} }
} }
this.dispatchEvent(new CustomEvent('wiresUpdated', { this.fireEvent('wiresUpdated', { nid, orientation, LondLinkfix })
detail: { nid, orientation, LondLinkfix },
bubbles: true,
composed: true,
}))
} }
getLink(nid1, nid2){ getLink(nid1, nid2){
const wire = this.stagedWires[`${nid1}_${nid2}`] const wire = this.stagedWires[this.makeWireId(nid1, nid2)]
if(wire?.link) return wire.link if(wire?.link) return wire.link
return this._virtualLinks?.get(`${nid1}__${nid2}`) ?? null return this._virtualLinks?.get(`${nid1}__${nid2}`) ?? null
} }
@@ -1138,11 +1303,11 @@ class BZgraflow extends Buildoz{
findLongLinks(links) { findLongLinks(links) {
let linksWithoutBackEdges let linksWithoutBackEdges
if(this.hasAnyLoop(this.flow.nodes, this.flow.links)){ if(this.hasAnyLoop(this.flow.nodes, links)){
const backEdges = this.findBackEdges(this.flow.nodes, this.flow.links) const backEdges = this.findBackEdges(this.flow.nodes, links)
linksWithoutBackEdges = this.flow.links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0])) linksWithoutBackEdges = links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
} else { } else {
linksWithoutBackEdges = this.flow.links linksWithoutBackEdges = links
} }
/// Yes that means we ignore long & back links ! /// Yes that means we ignore long & back links !
const { parents } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges) const { parents } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
@@ -1167,27 +1332,42 @@ class BZgraflow extends Buildoz{
return(crossLayerLinks) return(crossLayerLinks)
} }
autofit(){ autofit(percent=100){
const parentBB = this.parentElement.getBoundingClientRect() const outwidth = Math.max(this.clientWidth, 1)
// Use scroll dimensions for actual content extent (nodes can extend beyond element bounds) const outheight = Math.max(this.clientHeight, 1)
const contentW = Math.max(this.scrollWidth || this.offsetWidth || 1, 1) let inwidth = this.nodesContainer.scrollWidth
const contentH = Math.max(this.scrollHeight || this.offsetHeight || 1, 1) let inheight = this.nodesContainer.scrollHeight
const sx = parentBB.width / contentW try { // SVG scrollWidth ignores overflowing paths; getBBox() covers wire extent.
const sy = parentBB.height / contentH const wireBB = this.wiresContainer.getBBox()
const scale = Math.min(sx, sy) // uniform scale to fit inside parent if(wireBB.width > 0 || wireBB.height > 0){
this.style.transformOrigin = 'top left' inwidth = Math.max(inwidth, wireBB.x + wireBB.width)
this.style.transform = `scale(${scale})` inheight = Math.max(inheight, wireBB.y + wireBB.height)
}
} catch(_){ // getBBox throws if SVG not rendered yet, but should not happen as we have _canRunAutoPlace() / _scheduleLayoutWhenReady()
return
}
const ratio = Math.min( (outwidth / inwidth), (outheight / inheight) ) * (percent / 100)
const tween = parseInt(this.getBZAttribute('tween')) || 0
if(tween > 0){
const transition = `scale ${tween}ms ease-in-out`
this.nodesContainer.style.transition = transition
this.wiresContainer.style.transition = transition
}
this.nodesContainer.style.scale = ratio
this.wiresContainer.style.scale = ratio
this.nodesContainer.style.transformOrigin = 'top left'
this.wiresContainer.style.transformOrigin = 'top left'
} }
} }
Buildoz.define('graflow', BZgraflow) Buildoz.define('graflow', BZgraflow)
class MovingNodes{ class MovingNodes{
constructor(graflow, itemSelector, handleSelector = itemSelector){ constructor(graflow, itemSelector, handleSelector = itemSelector){
this.graflow = graflow this.graflow = graflow
this.itemSelector = itemSelector this.itemSelector = itemSelector
this.handleSelector = handleSelector this.handleSelector = handleSelector
this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container') this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container')
this.state = null
this.interactiveElementsSelector = ` this.interactiveElementsSelector = `
.port, .port,
@@ -1197,7 +1377,10 @@ class MovingNodes{
button, button,
a[href] a[href]
` `
this.graflow.addEventListener('refreshed', this.enableMovingNodes.bind(this)) this._boundPointerDown = this.pointerDown.bind(this)
this._boundPointerMove = this.pointerMove.bind(this)
this._boundPointerUp = this.pointerUp.bind(this)
this.graflow.addEventListener('bz:graflow:refreshed', this.enableMovingNodes.bind(this))
} }
enableMovingNodes() { enableMovingNodes() {
@@ -1210,21 +1393,21 @@ class MovingNodes{
} }
this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item => this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item =>
item.addEventListener('pointerdown', this.pointerDown.bind(this)) item.addEventListener('pointerdown', this._boundPointerDown)
) )
this.nodesContainer.addEventListener('pointermove', this.pointerMove.bind(this)) this.nodesContainer.addEventListener('pointermove', this._boundPointerMove)
this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item => this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item =>
item.addEventListener('pointerup', this.pointerUp.bind(this)) item.addEventListener('pointerup', this._boundPointerUp)
) )
} }
disableMovingNodes(){ disableMovingNodes(){
this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item => this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item =>
item.removeEventListener('pointerdown', this.pointerDown.bind(this)) item.removeEventListener('pointerdown', this._boundPointerDown)
) )
this.nodesContainer.removeEventListener('pointermove', this.pointerMove.bind(this)) this.nodesContainer.removeEventListener('pointermove', this._boundPointerMove)
this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item => this.nodesContainer.querySelectorAll(this.handleSelector).forEach(item =>
item.removeEventListener('pointerup', this.pointerUp.bind(this)) item.removeEventListener('pointerup', this._boundPointerUp)
) )
} }
@@ -1244,17 +1427,17 @@ class MovingNodes{
if(e.target != handle) return if(e.target != handle) return
} }
const rect = node.getBoundingClientRect() const rect = node.getBoundingClientRect()
const parentBB = this.nodesContainer.getBoundingClientRect()
const offsetX = rect.left - parentBB.left + this.nodesContainer.scrollLeft
const offsetY = rect.top - parentBB.top + this.nodesContainer.scrollTop
this.state = { this.state = {
node, node,
handle, handle,
startX: e.clientX, startX: e.clientX,
startY: e.clientY, startY: e.clientY,
offsetX: rect.left, offsetX,
offsetY: rect.top offsetY
} }
const x = e.clientX - this.state.startX + this.state.offsetX const x = e.clientX - this.state.startX + this.state.offsetX
const y = e.clientY - this.state.startY + this.state.offsetY const y = e.clientY - this.state.startY + this.state.offsetY
@@ -1263,7 +1446,7 @@ class MovingNodes{
node.style.left = `${x}px` node.style.left = `${x}px`
node.style.top = `${y}px` node.style.top = `${y}px`
node.style.margin = '0' node.style.margin = '0'
node.style.zIndex = '9999' node.style.zIndex = '3'
node.style.pointerEvents = 'none' node.style.pointerEvents = 'none'
} }
@@ -1279,8 +1462,19 @@ class MovingNodes{
pointerUp(e){ pointerUp(e){
if(!this.state) return if(!this.state) return
this.state.node.releasePointerCapture(e.pointerId) const { node, startX, startY, offsetX, offsetY } = this.state
this.state.node.style.pointerEvents = '' const x = e.clientX - startX + offsetX
const y = e.clientY - startY + offsetY
node.releasePointerCapture(e.pointerId)
node.style.pointerEvents = ''
for(const n of this.graflow.flow.nodes){
if(n.id == node.dataset.id){
n.coords.x = x
n.coords.y = y
break
}
}
this.graflow.fireEvent('nodeMoved', { nodeId: node.dataset.id, x, y })
this.state = null this.state = null
} }
} }
@@ -1291,10 +1485,10 @@ class EditWires{
this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container') this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container')
this.state = null this.state = null
this.graflow.tabIndex = 0 // Make keyboard reactive this.graflow.tabIndex = 0 // Make keyboard reactive
this._boundPointerMove = this.pointerMove.bind(this)
this.graflow.addEventListener('refreshed', this.enableEditWires.bind(this)) this.graflow.addEventListener('bz:graflow:refreshed', this.enableEditWires.bind(this))
this.graflow.addEventListener('refreshed', this.enableSelectPorts.bind(this)) this.graflow.addEventListener('bz:graflow:refreshed', this.enableSelectPorts.bind(this))
this.graflow.addEventListener('wiresUpdated', this.enableEditWires.bind(this)) this.graflow.addEventListener('bz:graflow:wiresUpdated', this.enableEditWires.bind(this))
this.graflow.addEventListener('keyup', this.onKeyUp.bind(this)) this.graflow.addEventListener('keyup', this.onKeyUp.bind(this))
} }
@@ -1310,31 +1504,103 @@ class EditWires{
} }
enableSelectPorts(){ enableSelectPorts(){
this.currentlyHoveredPort = null
const portEls = this.graflow.nodesContainer.querySelectorAll('.port') const portEls = this.graflow.nodesContainer.querySelectorAll('.port')
for(const port of portEls){ for(const port of portEls){
port.addEventListener('click', this.onSelectPort.bind(this)) port.addEventListener('click', this.onSelectPort.bind(this))
port.addEventListener('pointerenter', this._onPortPointerEnter.bind(this))
port.addEventListener('pointerleave', this._onPortPointerLeave.bind(this))
port.classList.add('selectable') port.classList.add('selectable')
} }
} }
_onPortPointerEnter(e){
this.currentlyHoveredPort = e.target.closest('.port')
}
_onPortPointerLeave(e){
if(this.currentlyHoveredPort === e.target.closest('.port')) this.currentlyHoveredPort = null
}
onSelectPort(e){ onSelectPort(e){
const port = e.target const port = e.target
if(this.currentlySelectedPort == port) { if(this.currentlySelectedPort == port) {
this.currentlySelectedPort.style.removeProperty('border') this.currentlySelectedPort.style.removeProperty('border')
this.currentlySelectedPort = null this.currentlySelectedPort = null
this.state = null
this._setWirecoatsPointerEvents('')
this.graflow.mainContainer.removeEventListener('pointermove', this._boundPointerMove)
if(this.tempwire) this.tempwire.remove()
return return
} }
if(this.currentlySelectedPort) { if(this.currentlySelectedPort) {
this.tempwire.remove()
this.tempwire = null
this.makeWireBetweenPorts(this.currentlySelectedPort, port) this.makeWireBetweenPorts(this.currentlySelectedPort, port)
this.enableEditWires() this.enableEditWires()
this.currentlySelectedPort.style.removeProperty('border') this.currentlySelectedPort.style.removeProperty('border')
this.currentlySelectedPort = null this.currentlySelectedPort = null
this.state = null
this._setWirecoatsPointerEvents('')
this.graflow.mainContainer.removeEventListener('pointermove', this._boundPointerMove)
} else { } else {
this.tension = parseInt(this.graflow.getBZAttribute('tension')) || 60
this.wireType = this.graflow.getBZAttribute('wiretype') || 'bezier'
this.currentlySelectedPort = port this.currentlySelectedPort = port
port.style.setProperty('border', '5px solid #FF0', 'important') port.style.setProperty('border', '5px solid #FF0', 'important')
this.state = {
startX: e.clientX,
startY: e.clientY,
port
}
this.tempwire = document.createElementNS('http://www.w3.org/2000/svg', 'path')
this.tempwire.setAttribute('fill', 'none')
this.tempwire.style.pointerEvents = 'none'
this.graflow.wiresContainer.appendChild(this.tempwire)
this.tempwire.classList.add('bzgf-wire')
this._setWirecoatsPointerEvents('none')
this.graflow.mainContainer.addEventListener('pointermove', this._boundPointerMove)
} }
} }
_setWirecoatsPointerEvents(value){
this.graflow.wiresContainer.querySelectorAll('.bzgf-wirecoat').forEach(el => { el.style.pointerEvents = value })
}
pointerMove(e){
if(!this.state) return
const { port } = this.state
const bb = port.getBoundingClientRect()
const p1 = this.graflow.clientToSvg(bb.x + bb.width / 2, bb.y + bb.height / 2)
const p2 = this.graflow.clientToSvg(e.clientX, e.clientY)
const x1 = Math.floor(p1.x)
const y1 = Math.floor(p1.y)
const x2 = Math.floor(p2.x)
const y2 = Math.floor(p2.y)
const dir1 = port.dataset.direction
const oppositeDir = { n: 's', s: 'n', e: 'w', w: 'e' }
const hovered = this.currentlyHoveredPort
const dir2 = (hovered && hovered !== port) ? hovered.dataset.direction : oppositeDir[dir1]
const c1x = x1 + this.tension * this.graflow.dirVect[dir1].x
const c1y = y1 + this.tension * this.graflow.dirVect[dir1].y
const c2x = x2 + this.tension * this.graflow.dirVect[dir2].x
const c2y = y2 + this.tension * this.graflow.dirVect[dir2].y
const node1 = port.closest('.bzgf-node')
const node2 = hovered?.closest('.bzgf-node') ?? { offsetWidth: 0, offsetHeight: 0 }
const seg = this.graflow.buildSegment(
x1, y1,
c1x, c1y,
c2x, c2y,
x2, y2,
this.wireType,
node1, node2,
dir1, dir2,
this.tension)
if(!seg) return
this.tempwire.setAttribute('d', `M ${x1} ${y1} ${seg}`)
}
makeWireBetweenPorts(port1, port2){ makeWireBetweenPorts(port1, port2){
const node1 = port1.closest('.bzgf-node') const node1 = port1.closest('.bzgf-node')
const node2 = port2.closest('.bzgf-node') const node2 = port2.closest('.bzgf-node')
@@ -1347,6 +1613,7 @@ class EditWires{
return('') return('')
} }
this.graflow.addWire({ from: [idNode1, idPort1], to: [idNode2, idPort2] }) this.graflow.addWire({ from: [idNode1, idPort1], to: [idNode2, idPort2] })
this.graflow.fireEvent('wireAdded', { from: [idNode1, idPort1], to: [idNode2, idPort2], id: this.graflow.makeWireId(idNode1, idNode2) })
} }
onSelectWire(e){ onSelectWire(e){
@@ -1362,16 +1629,32 @@ class EditWires{
onKeyUp(e){ onKeyUp(e){
if((e.key == 'Delete') && this.currentlySelectedWire) { if((e.key == 'Delete') && this.currentlySelectedWire) {
this.graflow.flow.links = this.graflow.flow.links.filter(link => link.id != this.currentlySelectedWire.dataset.id) const wireId = this.currentlySelectedWire.dataset.id
this.graflow.stagedWires[this.currentlySelectedWire.dataset.id].remove() const linkToRemove = this.graflow.stagedWires[wireId]?.link
delete(this.graflow.stagedWires[this.currentlySelectedWire.dataset.id]) this.graflow.flow.links = this.graflow.flow.links.filter(link =>
linkToRemove ? link !== linkToRemove : (this.graflow.makeWireId(link.from[0], link.to[0]) !== wireId)
)
this.graflow.stagedWires[wireId]?.remove()
delete this.graflow.stagedWires[wireId]
this.currentlySelectedWire.remove() this.currentlySelectedWire.remove()
this.currentlySelectedWire = null this.currentlySelectedWire = null
this.graflow.fireEvent('wireRemoved', { wireId })
return return
} }
if(e.key == 'Escape') { if(e.key == 'Escape') {
if(this.currentlySelectedWire) this.currentlySelectedWire.style.setProperty('stroke', '#0000', 'important') if(this.currentlySelectedWire) {
this.currentlySelectedWire = null this.currentlySelectedWire.style.setProperty('stroke', '#0000', 'important')
this.currentlySelectedWire = null
}
if(this.currentlySelectedPort) {
this.currentlySelectedPort.style.removeProperty('border')
this.currentlySelectedPort = null
}
if(this.tempwire) {
this.tempwire.remove()
this.tempwire = null
this.graflow.mainContainer.removeEventListener('pointermove', this._boundPointerMove)
}
return return
} }
} }
+46
View File
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>graflow</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
<link type="text/css" rel="stylesheet" href="../buildoz.css">
<script src="../buildoz.js"></script>
<script src="../bzGraflow.js"></script>
<script src="../bzGraflow-editor.js"></script>
<style>
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
font-family: 'glyphs';
src: url('/assets/styles/fonts/glyphs.eot');
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
url('/assets/styles/fonts/glyphs.woff') format('woff'),
url('/assets/styles/fonts/glyphs.svg') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body{
display: grid;
grid-gap: 5px;
background:#888;
font-size: 16px;
}
bz-graflow{
border: 2px solid black;
}
bz-graflow.compunet{ grid-column: 1 / -1; width: 100vw; height: 60vh; background:black; }
</style>
<script>
window.addEventListener('load',()=>{
})
</script>
</head>
<body>
<bz-grafloweditor nodes="./nodesLib/nodesTest1.html" >
</bz-grafloweditor>
</body>
</html>
+60
View File
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>graflow</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
<link type="text/css" rel="stylesheet" href="../buildoz.css">
<script src="../buildoz.js"></script>
<script src="../bzGraflow.js"></script>
<script src="../bzGraflow-editor.js"></script>
<style>
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
font-family: 'glyphs';
src: url('/assets/styles/fonts/glyphs.eot');
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
url('/assets/styles/fonts/glyphs.woff') format('woff'),
url('/assets/styles/fonts/glyphs.svg') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body{
display: grid;
grid-gap: 5px;
background:#888;
font-size: 16px;
}
bz-graflow{
border: 2px solid black;
}
bz-graflow.compunet{ grid-column: 1 / -1; width: 100vw; height: 60vh; background:black; }
</style>
<script>
window.addEventListener('load',()=>{
const editor = document.querySelector('bz-grafloweditor')
editor.onImportFlow = async (e) => {
const fileList = ['testFlow1', 'testFlow2', 'testFlow3']
const result = await BZModalDialog('Select your flow...', `
Available flows:
<select name="flow" style="min-width: 10em;justify-self: center;">
${fileList.map(file => `<option value="${file}">${file}</option>`).join('')}
</select>
`)
console.log('result', result)
}
editor.onExportFlow = (e) => {
console.log('onExportFlow')
}
})
</script>
</head>
<body>
<bz-grafloweditor nodes="./nodesLib/nodesTest1.html" >
</bz-grafloweditor>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
{
"nodesFile": "./nodesLib/nodesGantt.html",
"flow": {
"nodes":[
{ "nodeType": "bar",
"id": "t1",
"coords": { "x": 20, "y": 0},
"markup": { "task": "Task 1", "color": "#0F0", "width": 160 }
},
{ "nodeType": "bar",
"id": "t2",
"coords": { "x": 510, "y": 180},
"markup": { "task": "Task 2", "color": "#CCF", "width": 60 }
},
{ "nodeType": "bar",
"id": "t3",
"coords": { "x": 570, "y": 240},
"markup": { "task": "Task 3", "color": "#FFC", "width": 100 }
},
{ "nodeType": "bar",
"id": "t4",
"coords": { "x": 20, "y": 60},
"markup": { "task": "Task 4", "color": "#FCF", "width": 260 }
},
{ "nodeType": "bar",
"id": "t5",
"coords": { "x": 280, "y": 90},
"markup": { "task": "Task 5", "color": "#CFF", "width": 30 }
},
{ "nodeType": "bar",
"id": "t6",
"coords": { "x": 310, "y": 120},
"markup": { "task": "Task 6", "color": "#FFC", "width": 40 }
},
{ "nodeType": "bar",
"id": "t7",
"coords": { "x": 180, "y": 30},
"markup": { "task": "Task 7", "color": "#FCF", "width": 80 }
},
{ "nodeType": "bar",
"id": "t8",
"coords": { "x": 350, "y": 150},
"markup": { "task": "Task 8", "color": "#CFF", "width": 160 }
},
{ "nodeType": "bar",
"id": "t9",
"coords": { "x": 510, "y": 210},
"markup": { "task": "Task 9", "color": "#FFC", "width": 60 }
}
],
"links": [
{ "from": ["t1", "out1"], "to": ["t7", "inp1"] },
{ "from": ["t7", "out1"], "to": ["t5", "inp1"] },
{ "from": ["t8", "out1"], "to": ["t2", "inp1"] },
{ "from": ["t9", "out1"], "to": ["t3", "inp1"] },
{ "from": ["t4", "out1"], "to": ["t5", "inp1"] },
{ "from": ["t5", "out1"], "to": ["t6", "inp1"] },
{ "from": ["t6", "out1"], "to": ["t8", "inp1"] },
{ "from": ["t8", "out1"], "to": ["t9", "inp1"] }
]
}
}
+4
View File
@@ -33,6 +33,10 @@
{ "nodeType": "console", { "nodeType": "console",
"id": "9999", "id": "9999",
"coords": { "x": 800, "y": 350} "coords": { "x": 800, "y": 350}
},
{ "nodeType": "square",
"id": "prng",
"coords": { "x": 250, "y": 400}
} }
], ],
"links": [ "links": [
@@ -0,0 +1,98 @@
{
"nodesFile": "./nodesLib/nodesEIC.html",
"flow": {
"nodes":[
{ "nodeType": "eicBasic",
"id": "config",
"ncoords": { "x": 50, "y": 120},
"markup": {
"title": "Configure event",
"subtitle": "",
"severity": "warning"
}
},
{ "nodeType": "eicBasic",
"id": "mailinvit",
"ncoords": { "x": 100, "y": 220},
"markup": {
"title": "Candidates invitation mailing",
"subtitle": "",
"severity": "success"
}
},
{ "nodeType": "eicBasic",
"id": "applicationsurvey",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Application survey",
"subtitle": "",
"severity": "success"
}
},
{ "nodeType": "eicBasic",
"id": "enrollment",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Candidates enrollment",
"subtitle": "",
"severity": "secondary"
}
},
{ "nodeType": "eicBasic",
"id": "mailwelcome",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Welcome mailing",
"subtitle": "",
"severity": "warning"
}
},
{ "nodeType": "eicBasic",
"id": "mailrejection",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Rejection mailing",
"subtitle": "",
"severity": "warning"
}
},
{ "nodeType": "eicBasic",
"id": "event",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Event",
"subtitle": "",
"severity": "secondary"
}
},
{ "nodeType": "eicBasic",
"id": "mailstatisfaction",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Satisfaction survey mailing",
"subtitle": "",
"severity": "success"
}
},
{ "nodeType": "eicBasic",
"id": "satisfactionsurvey",
"ncoords": { "x": 150, "y": 320},
"markup": {
"title": "Satisfaction survey",
"subtitle": "",
"severity": "warning"
}
}
],
"links": [
{ "from": ["config", "out1"], "to": ["mailinvit", "in1"] },
{ "from": ["mailinvit", "out1"], "to": ["applicationsurvey", "in1"] },
{ "from": ["applicationsurvey", "out1"], "to": ["enrollment", "in1"] },
{ "from": ["enrollment", "out1"], "to": ["mailwelcome", "in1"] },
{ "from": ["enrollment", "out1"], "to": ["mailrejection", "in1"] },
{ "from": ["mailwelcome", "out1"], "to": ["event", "in1"] },
{ "from": ["event", "out1"], "to": ["mailstatisfaction", "in1"] },
{ "from": ["mailstatisfaction", "out1"], "to": ["satisfactionsurvey", "in1"] }
]
}
}
+38
View File
@@ -0,0 +1,38 @@
<style>
.bzgf-node {
font-family: Arial, Helvetica, sans-serif;
color: black;
text-align: center;
position: absolute;
}
.bzgf-node .body{
border-radius: 4px;
overflow: hidden;
height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px));
line-height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px));
text-overflow: ellipsis;
white-space: nowrap;
font-size: .9em;
padding: 0 2px 0 2px;
}
.bzgf-node .port{
position: absolute;
height: 1px;
width: 1px;
}
.bzgf-node [data-direction="w"]{ left: -4px; top: 50%; }
.bzgf-node [data-direction="e"]{ right: -4px; top: 50%; }
.bzgf-wire{ stroke: #AAA; stroke-width: 1; }
</style>
<template>
<div class="bzgf-node" data-nodetype="bar">
<div class="port" data-type="in" data-id="inp1" data-direction="w"></div>
<div class="port" data-type="out" data-id="out1" data-direction="e"></div>
<div class="body" style="background-color:{color};width:{width}px;" title="{task}">{task}</div>
</div>
</template>
+28 -2
View File
@@ -96,10 +96,21 @@
.bzgf-node[data-nodetype="input"] .title, .bzgf-node[data-nodetype="input"] .title,
.bzgf-node[data-nodetype="console"] .title{ background: #555; } .bzgf-node[data-nodetype="console"] .title{ background: #555; }
.bzgf-node[data-nodetype="square"]{
background: #FAA;
border-color: #A00;
width: 100px;
height: 100px;
}
.bzgf-node[data-nodetype="square"] .title{ background: #555; }
.bzgf-node[data-nodetype="refnodein"], .bzgf-node[data-nodetype="refnodeout"] { .bzgf-node[data-nodetype="refnodein"], .bzgf-node[data-nodetype="refnodeout"] {
width:3em; width:3em;
height:3em; height:3em;
padding: 2px; padding: 2px;
border: none;
} }
.bzgf-node[data-nodetype="refnodein"] .body, .bzgf-node[data-nodetype="refnodeout"] .body{ .bzgf-node[data-nodetype="refnodein"] .body, .bzgf-node[data-nodetype="refnodeout"] .body{
border-radius: 50%; border-radius: 50%;
@@ -108,6 +119,10 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin:0;
}
.bzgf-node[data-nodetype="refnodein"] .port, .bzgf-node[data-nodetype="refnodeout"] .port{
top: 50%;
} }
.bzgf-node[data-nodetype="refnodein"] .body{ background: #0F0; } .bzgf-node[data-nodetype="refnodein"] .body{ background: #0F0; }
.bzgf-node[data-nodetype="refnodeout"] .body{ background: #FF0; } .bzgf-node[data-nodetype="refnodeout"] .body{ background: #FF0; }
@@ -189,14 +204,25 @@
</template> </template>
<template> <template>
<div class="bzgf-node" data-nodetype="refnodein"> <div class="bzgf-node" data-nodetype="square">
<div class="title">PRNG</div>
<div class="body"></div>
<div class="port" data-type="out" data-id="w" data-direction="w"></div>
<div class="port" data-type="out" data-id="n" data-direction="n"></div>
<div class="port" data-type="out" data-id="e" data-direction="e"></div>
<div class="port" data-type="out" data-id="s" data-direction="s"></div>
</div>
</template>
<template>
<div class="bzgf-node" data-nodetype="refnodein" data-editor="exclude">
<div class="body">{parentport}</div> <div class="body">{parentport}</div>
<div class="port" data-type="out" data-id="out1" data-direction="e"></div> <div class="port" data-type="out" data-id="out1" data-direction="e"></div>
</div> </div>
</template> </template>
<template> <template>
<div class="bzgf-node" data-nodetype="refnodeout"> <div class="bzgf-node" data-nodetype="refnodeout" data-editor="exclude">
<div class="body">{parentport}</div> <div class="body">{parentport}</div>
<div class="port" data-type="in" data-id="in1" data-direction="w"></div> <div class="port" data-type="in" data-id="in1" data-direction="w"></div>
</div> </div>
+45 -7
View File
@@ -44,7 +44,7 @@
<tbody> <tbody>
<tr> <tr>
<td><a target="test1" href="./test1.html">test1</a></td> <td><a target="test1" href="./test1.html">test1</a></td>
<td>P42</td> <td>Graflow P42</td>
<td>YES</td> <td>YES</td>
<td>2 depths</td> <td>2 depths</td>
<td></td> <td></td>
@@ -56,7 +56,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test2" href="./test2.html">test2</a></td> <td><a target="test2" href="./test2.html">test2</a></td>
<td>Organigram</td> <td>Graflow Organigram</td>
<td>YES</td> <td>YES</td>
<td></td> <td></td>
<td></td> <td></td>
@@ -68,7 +68,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test3" href="./test3.html">test3</a></td> <td><a target="test3" href="./test3.html">test3</a></td>
<td>EIC simple</td> <td>Graflow EIC simple</td>
<td>NO</td> <td>NO</td>
<td>1 depth</td> <td>1 depth</td>
<td></td> <td></td>
@@ -80,7 +80,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test4" href="./test4.html">test4</a></td> <td><a target="test4" href="./test4.html">test4</a></td>
<td>EIC-ICMP</td> <td>Graflow EIC-ICMP</td>
<td>NO</td> <td>NO</td>
<td></td> <td></td>
<td>X</td> <td>X</td>
@@ -92,7 +92,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test4.5" href="./test4.5.html">test4.5</a></td> <td><a target="test4.5" href="./test4.5.html">test4.5</a></td>
<td>EIC-ICMP II</td> <td>Graflow EIC-ICMP II</td>
<td>NO</td> <td>NO</td>
<td></td> <td></td>
<td></td> <td></td>
@@ -104,7 +104,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test5" href="./test5.html">test5</a></td> <td><a target="test5" href="./test5.html">test5</a></td>
<td>P42</td> <td>Graflow P42</td>
<td>YES</td> <td>YES</td>
<td></td> <td></td>
<td></td> <td></td>
@@ -116,7 +116,7 @@
</tr> </tr>
<tr> <tr>
<td><a target="test6" href="./test6.html">test6</a></td> <td><a target="test6" href="./test6.html">test6</a></td>
<td>16 ports test</td> <td>Graflow 16 ports test</td>
<td>NO</td> <td>NO</td>
<td></td> <td></td>
<td></td> <td></td>
@@ -126,6 +126,44 @@
<td>X</td> <td>X</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td><a target="test6" href="./test7.html">test7</a></td>
<td>Gantt chart 1</td>
<td>YES</td>
<td></td>
<td></td>
<td>Bezier</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<br>
<table>
<thead>
<tr>
<th></th>
<th>Style</th>
<th>Import / Export</th>
</tr>
</thead>
<tbody>
<tr>
<td><a target="etest1" href="./etest1.html">Editor test 1</a></td>
<td>P42</td>
<td>JSON local file</td>
</tr>
<tr>
<td><a target="etest2" href="./etest2.html">Editor test 2</a></td>
<td>EIC</td>
<td>API to MySQL</tr>
</tr>
<!-- <tr>
<td><a target="etest3" href="./etest3.html">Editor test 3</a></td>
<td>16 ports</td>
</tr> -->
</tbody> </tbody>
</table> </table>
</body> </body>
+4 -4
View File
@@ -53,10 +53,10 @@
<script> <script>
window.addEventListener('load',()=>{ window.addEventListener('load',()=>{
let grflw1 = document.querySelector('bz-graflow.compunet') let grflw1 = document.querySelector('bz-graflow.compunet')
grflw1.addEventListener('subflowLoaded', grflw1.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw1 = evt.detail.subflow } (evt) => { grflw1 = evt.detail.component }
) )
grflw1.addEventListener('subflowExited', grflw1.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw1 = evt.target } (evt) => { grflw1 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click',
@@ -91,7 +91,7 @@
<option value="straight">Straight</option> <option value="straight">Straight</option>
<option value="bezier" selected>Bezier</option> <option value="bezier" selected>Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="compunet" type="number" size="2" value="60"></div> <div class="cols-2"><label>tension</label><input data-id="compunet" type="number" size="2" value="60"></div>
</div> </div>
</bz-graflow> </bz-graflow>
+4 -4
View File
@@ -53,10 +53,10 @@
<script> <script>
window.addEventListener('load',()=>{ window.addEventListener('load',()=>{
let grflw3 = document.querySelector('bz-graflow.organi') let grflw3 = document.querySelector('bz-graflow.organi')
grflw3.addEventListener('subflowLoaded', grflw3.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw3 = evt.detail.subflow } (evt) => { grflw3 = evt.detail.component }
) )
grflw3.addEventListener('subflowExited', grflw3.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw3 = evt.target } (evt) => { grflw3 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace3H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace3H"]').addEventListener('click',
@@ -92,7 +92,7 @@
<option value="bezier" selected>Bezier</option> <option value="bezier" selected>Bezier</option>
<option value="parent">Parent</option> <option value="parent">Parent</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="organi" type="number" size="2" value="60"></div> <div class="cols-2"><label>tension</label><input data-id="organi" type="number" size="2" value="60"></div>
</div> </div>
</bz-graflow> </bz-graflow>
+98
View File
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>graflow</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
<link type="text/css" rel="stylesheet" href="../buildoz.css">
<script src="../buildoz.js"></script>
<script src="../bzGraflow.js"></script>
<style>
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
font-family: 'glyphs';
src: url('/assets/styles/fonts/glyphs.eot');
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
url('/assets/styles/fonts/glyphs.woff') format('woff'),
url('/assets/styles/fonts/glyphs.svg') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body{
display: grid;
grid-gap: 5px;
background:#888;
font-size: 16px;
}
.demooptions{
padding: 2px;
position: absolute;
top: 2px;
right: 2px;
width: 10em;
background: #FFFB;
border-radius: 5px;
text-align: center;
z-index:99999;
font-size: .7em;
border: 1px solid #999;
}
.demooptions button{
text-transform: none;
margin: 2px;
font-size: 1em;
}
bz-graflow{
overflow: scroll;
border: 2px solid black;
}
bz-graflow.eic{ grid-column: 1 / -1; width: 120vw; height: 40vh; background: var(--eicui-base-color-grey-10); }
</style>
<script>
window.addEventListener('load',()=>{
let grflw2 = document.querySelector('bz-graflow.eic')
grflw2.setAttribute('tension', document.querySelector('input[data-id="eic"]').value)
grflw2.setAttribute('align', document.querySelector('select[name="align"]').value)
grflw2.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value)
grflw2.addEventListener('bz:graflow:refresh',
(evt) => { grflw2.style.transform = 'scale(.75)'; }
)
document.querySelector('[data-trigger="onAutoplace2H"]').addEventListener('click',
(evt) => { grflw2.autoPlace('horizontal', 100, 30, 1000, document.querySelector('[data-id="eic"]').value) }
)
document.querySelector('[data-trigger="onAutoplace2V"]').addEventListener('click',
(evt) => { grflw2.autoPlace('vertical', 80, 80, 1000, document.querySelector('[data-id="eic"]').value) }
)
document.querySelector('input[data-id="eic"]').addEventListener('change',
(evt) => { grflw2.setAttribute('tension', evt.target.value); grflw2.refresh() }
)
document.querySelector('select[name="wiretype"]').addEventListener('change',
(evt) => { grflw2.setAttribute('wiretype', evt.target.value); grflw2.refresh() }
)
})
</script>
</head>
<body>
<bz-graflow class="eic" flow="./flows/testFlowEvent1.json" tension="50">
<div class="demooptions"> <!-- just for demo purposes -->
<button data-trigger="onAutoplace2H">Auto-place Horizontal</button>
<button data-trigger="onAutoplace2V">Auto-place Vertical</button>
<select name="align" data-id="eic">
<option value="center">Center</option>
<option value="first" selected>First</option>
<option value="last">Last</option>
<option value="parent">Parent</option>
</select>
<select name="wiretype">
<option value="ortho">Ortho</option>
<option value="straight">Straight</option>
<option value="bezier" selected>Bezier</option>
</select>
<div class="cols-2"><label>tension</label><input data-id="eic" type="number" size="2" value="50"></div>
</div>
</bz-graflow>
</body>
</html>
+5 -5
View File
@@ -56,10 +56,10 @@
grflw2.setAttribute('tension', document.querySelector('input[data-id="eic"]').value) grflw2.setAttribute('tension', document.querySelector('input[data-id="eic"]').value)
grflw2.setAttribute('align', document.querySelector('select[name="align"]').value) grflw2.setAttribute('align', document.querySelector('select[name="align"]').value)
grflw2.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value) grflw2.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value)
grflw2.addEventListener('subflowLoaded', grflw2.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw2 = evt.detail.subflow } (evt) => { grflw2 = evt.detail.component }
) )
grflw2.addEventListener('subflowExited', grflw2.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw2 = evt.target } (evt) => { grflw2 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace2H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace2H"]').addEventListener('click',
@@ -79,7 +79,7 @@
</head> </head>
<body> <body>
<bz-graflow class="eic" flow="./flows/testFlowEic.json" tension="60"> <bz-graflow class="eic" flow="./flows/testFlowEic.json" tension="60" autofit="500">
<div class="demooptions"> <!-- just for demo purposes --> <div class="demooptions"> <!-- just for demo purposes -->
<button data-trigger="onAutoplace2H">Auto-place Horizontal</button> <button data-trigger="onAutoplace2H">Auto-place Horizontal</button>
<button data-trigger="onAutoplace2V">Auto-place Vertical</button> <button data-trigger="onAutoplace2V">Auto-place Vertical</button>
@@ -94,7 +94,7 @@
<option value="straight"selected>Straight</option> <option value="straight"selected>Straight</option>
<option value="bezier">Bezier</option> <option value="bezier">Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="eic" type="number" size="2" value="1"></div> <div class="cols-2"><label>tension</label><input data-id="eic" type="number" size="2" value="1"></div>
</div> </div>
</bz-graflow> </bz-graflow>
</body> </body>
+4 -4
View File
@@ -56,10 +56,10 @@
grflw4.setAttribute('tension', document.querySelector('input[data-id="icmp"]').value) grflw4.setAttribute('tension', document.querySelector('input[data-id="icmp"]').value)
grflw4.setAttribute('align', document.querySelector('select[name="align"]').value) grflw4.setAttribute('align', document.querySelector('select[name="align"]').value)
grflw4.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value) grflw4.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value)
grflw4.addEventListener('subflowLoaded', grflw4.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw4 = evt.detail.subflow } (evt) => { grflw4 = evt.detail.component }
) )
grflw4.addEventListener('subflowExited', grflw4.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw4 = evt.target } (evt) => { grflw4 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace4H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace4H"]').addEventListener('click',
@@ -94,7 +94,7 @@
<option value="straight">Straight</option> <option value="straight">Straight</option>
<option value="bezier">Bezier</option> <option value="bezier">Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="icmp" type="number" size="2" value="20"></div> <div class="cols-2"><label>tension</label><input data-id="icmp" type="number" size="2" value="20"></div>
</div> </div>
</bz-graflow> </bz-graflow>
</body> </body>
+20 -14
View File
@@ -45,19 +45,25 @@
font-size: 1em; font-size: 1em;
} }
bz-graflow{ bz-graflow{
overflow: scroll;
border: 2px solid black; border: 2px solid black;
} }
bz-graflow.icmp{ grid-column: 1 / -1; width: 100vw; height: 80vh; background: var(--eicui-base-color-grey-10); } /* Fill the demo frame — autofit sizes to the graflow box, not the parent */
bz-graflow.icmp{
width: 100%;
height: 100%;
background: var(--eicui-base-color-grey-10);
}
.container { .container {
resize: both; resize: both;
overflow: auto; /* required in practice */ overflow: hidden;
min-width: 800px; width: 90vw;
min-height: 300px; height: 80vh;
border: 1px solid #999; min-width: 400px;
min-height: 240px;
padding: 0; padding: 0;
position: relative; position: relative;
border:2px solid #A00 border: 2px solid #A00;
box-sizing: border-box;
} }
.container::after { .container::after {
content: ""; content: "";
@@ -82,10 +88,10 @@
const severities = ['primary', 'info', 'success', 'warning', 'danger', 'accent'] const severities = ['primary', 'info', 'success', 'warning', 'danger', 'accent']
let grflw4 = document.querySelector('bz-graflow.icmp') let grflw4 = document.querySelector('bz-graflow.icmp')
grflw4.addEventListener('subflowLoaded', grflw4.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw4 = evt.detail.subflow } (evt) => { grflw4 = evt.detail.component }
) )
grflw4.addEventListener('subflowExited', grflw4.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw4 = evt.target } (evt) => { grflw4 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace4H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace4H"]').addEventListener('click',
@@ -102,7 +108,6 @@
) )
const el = document.querySelector('.container') const el = document.querySelector('.container')
let timer = null // debounce
const ro = new ResizeObserver(([entry]) => { const ro = new ResizeObserver(([entry]) => {
const grfl = entry.target.querySelector('bz-graflow') const grfl = entry.target.querySelector('bz-graflow')
grfl.autofit() grfl.autofit()
@@ -110,14 +115,15 @@
ro.observe(el) ro.observe(el)
let aifmi = null; let sidx=0; let aifmi = null; let sidx=0;
const sevanimation = () => { console.log('sevanimation') const sevanimation = () => {
severities.forEach(severity => aifmi.removeAttribute(severity)) severities.forEach(severity => aifmi.removeAttribute(severity))
aifmi.setAttribute(severities[sidx], '') aifmi.setAttribute(severities[sidx], '')
sidx++ sidx++
if (sidx >= severities.length) sidx = 0 if (sidx >= severities.length) sidx = 0
setTimeout(sevanimation, 1000) setTimeout(sevanimation, 1000)
} }
grflw4.addEventListener('refreshed',() => { grflw4.addEventListener('bz:graflow:refreshed',() => {
if(aifmi) return
aifmi = grflw4.stagedNodes['aifm-investment'].querySelector('.body') aifmi = grflw4.stagedNodes['aifm-investment'].querySelector('.body')
sevanimation() sevanimation()
}) })
@@ -143,7 +149,7 @@
<option value="straight">Straight</option> <option value="straight">Straight</option>
<option value="bezier" selected>Bezier</option> <option value="bezier" selected>Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="icmp" type="number" size="2" value="60"></div> <div class="cols-2"><label>tension</label><input data-id="icmp" type="number" size="2" value="60"></div>
</div> </div>
</bz-graflow> </bz-graflow>
</div> </div>
+4 -4
View File
@@ -53,10 +53,10 @@
<script> <script>
window.addEventListener('load',()=>{ window.addEventListener('load',()=>{
let grflw1 = document.querySelector('bz-graflow.compunet') let grflw1 = document.querySelector('bz-graflow.compunet')
grflw1.addEventListener('subflowLoaded', grflw1.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw1 = evt.detail.subflow } (evt) => { grflw1 = evt.detail.component }
) )
grflw1.addEventListener('subflowExited', grflw1.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw1 = evt.target } (evt) => { grflw1 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click',
@@ -91,7 +91,7 @@
<option value="straight">Straight</option> <option value="straight">Straight</option>
<option value="bezier" selected>Bezier</option> <option value="bezier" selected>Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="compunet" type="number" size="2" value="60"></div> <div class="cols-2"><label>tension</label><input data-id="compunet" type="number" size="2" value="60"></div>
</div> </div>
</bz-graflow> </bz-graflow>
+4 -4
View File
@@ -56,10 +56,10 @@
grflw1.setAttribute('tension', document.querySelector('input[data-id="compunet"]').value) grflw1.setAttribute('tension', document.querySelector('input[data-id="compunet"]').value)
grflw1.setAttribute('align', document.querySelector('select[name="align"]').value) grflw1.setAttribute('align', document.querySelector('select[name="align"]').value)
grflw1.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value) grflw1.setAttribute('wiretype', document.querySelector('select[name="wiretype"]').value)
grflw1.addEventListener('subflowLoaded', grflw1.addEventListener('bz:graflow:subflowLoaded',
(evt) => { grflw1 = evt.detail.subflow } (evt) => { grflw1 = evt.detail.component }
) )
grflw1.addEventListener('subflowExited', grflw1.addEventListener('bz:graflow:subflowExited',
(evt) => { grflw1 = evt.target } (evt) => { grflw1 = evt.target }
) )
document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click', document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click',
@@ -94,7 +94,7 @@
<option value="straight">Straight</option> <option value="straight">Straight</option>
<option value="bezier">Bezier</option> <option value="bezier">Bezier</option>
</select> </select>
<div class-"cols-2"=""><label>tension</label><input data-id="compunet" type="number" size="2" value="20"></div> <div class="cols-2"><label>tension</label><input data-id="compunet" type="number" size="2" value="20"></div>
</div> </div>
</bz-graflow> </bz-graflow>
+76
View File
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>graflow</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
<link type="text/css" rel="stylesheet" href="../buildoz.css">
<script src="../buildoz.js"></script>
<script src="../bzGraflow.js"></script>
<style>
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
font-family: 'glyphs';
src: url('/assets/styles/fonts/glyphs.eot');
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
url('/assets/styles/fonts/glyphs.woff') format('woff'),
url('/assets/styles/fonts/glyphs.svg') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body{
background:#888;
font-size: 16px;
}
.gantt-wrap{
position: relative;
--row: 30px;
}
ul.tasks{
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
ul.tasks li{
box-sizing: border-box;
text-wrap: nowrap;
height: var(--row);
line-height: calc(var(--row) - 1px);
border-bottom: 1px dotted #555;
}
bz-graflow.gantt{
position: absolute;
left: 10em;
top: 6px;
right: 0;
bottom: 0;
}
</style>
<script>
window.addEventListener('load',()=>{
let grflw1 = document.querySelector('bz-graflow.gantt')
})
</script>
</head>
<body>
<div class="gantt-wrap">
<ul class="tasks">
<li>Task 1</li>
<li>Task 7</li>
<li>Task 4</li>
<li>Task 5</li>
<li>Task 6</li>
<li>Task 8</li>
<li>Task 2</li>
<li>Task 9</li>
<li>Task 3</li>
</ul>
<bz-graflow class="gantt" flow="./flows/gantt.json" tension="60" isolated></bz-graflow>
</div>
</body>
</html>
+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>graflow</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
<link type="text/css" rel="stylesheet" href="../buildoz.css">
<script src="../buildoz.js"></script>
<script src="../bzGraflow.js"></script>
<script src="../bzGantt.js"></script>
<style>
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
font-family: 'glyphs';
src: url('/assets/styles/fonts/glyphs.eot');
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
url('/assets/styles/fonts/glyphs.woff') format('woff'),
url('/assets/styles/fonts/glyphs.svg') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
body{
background:#888;
font-size: 16px;
}
</style>
<script>
const ganttData = {
"tasks": [
{ "id": "t1", "name": "Task 1", "start": "2026-08-25", "end":"2026-08-29", "color": "#8F8" },
{ "id": "t2", "name": "Task 2", "start": "2026-09-08", "end":"2026-09-13", "color": "#F8F", "dependsOn": ["t8"] },
{ "id": "t3", "name": "Task 3", "start": "2026-09-13", "end":"2026-09-18", "color": "#FF8", "dependsOn": ["t9"] },
{ "id": "t4", "name": "Task 4", "start": "2026-08-25", "end":"2026-09-03", "color": "#F88" },
{ "id": "t5", "name": "Task 5", "start": "2026-08-29", "end":"2026-08-31", "color": "#88F", "dependsOn": ["t4", "t7"] },
{ "id": "t6", "name": "Task 6", "start": "2026-08-31", "end":"2026-09-01", "color": "#8F8", "dependsOn": ["t5"] },
{ "id": "t7", "name": "Task 7", "start": "2026-08-29", "end":"2026-09-01", "color": "#88F", "dependsOn": ["t1"] },
{ "id": "t8", "name": "Task 8 which is quite long", "start": "2026-09-01", "end":"2026-09-08", "color": "#8F8", "dependsOn": ["t6"] },
{ "id": "t9", "name": "Task 9", "start": "2026-09-08", "end":"2026-09-11", "color": "#F8F", "dependsOn": ["t8"] },
]
}
window.addEventListener('load',()=>{
let gantt = document.querySelector('bz-gantt.gantt')
gantt.loadData(ganttData)
gantt.refresh()
})
</script>
</head>
<body>
<bz-gantt class="gantt" nodesfile="./nodesLib/nodesGantt.html" tension="60" isolated></bz-gantt>
</body>
</html>