@emuanalytics/flow-rdf-ui 4.1.12 → 4.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,8 +67,8 @@ class FlowUiPanel extends FlowRdfElement {
67
67
  <slot
68
68
  name="header"
69
69
  class="panel__header"
70
- @flow-ui-expand=${this.expand}
71
- @flow-ui-collapse=${this.collapse}
70
+ @flow-ui-expand=${() => this.expand(false)}
71
+ @flow-ui-collapse=${() => this.collapse(false)}
72
72
  ></slot>
73
73
 
74
74
  <div class="panel__body-wrapper">
@@ -37,13 +37,15 @@ class FlowUiPanelHeader extends FlowRdfElement {
37
37
  if (this.fixed) {
38
38
  return;
39
39
  }
40
- this.closed = !this.closed;
41
- this.emit(this.closed ? "flow-ui-collapse" : "flow-ui-expand");
40
+ this.toggleButton.toggle();
42
41
  this.header.focus();
43
42
  }
44
43
  handleAccessoryClick(event) {
45
44
  event.stopPropagation();
46
45
  }
46
+ handleToggleClick(event) {
47
+ event.stopPropagation();
48
+ }
47
49
  handleHeaderKeyDown(event) {
48
50
  if (this.fixed) {
49
51
  return;
@@ -62,8 +64,8 @@ class FlowUiPanelHeader extends FlowRdfElement {
62
64
  }
63
65
  this.emit(this.closed ? "flow-ui-collapse" : "flow-ui-expand");
64
66
  }
65
- handleToggleButtonExpandCollapse(event) {
66
- event.stopPropagation();
67
+ handleExpandCollapse() {
68
+ this.closed = this.toggleButton.closed;
67
69
  }
68
70
  render() {
69
71
  return html`
@@ -83,6 +85,8 @@ class FlowUiPanelHeader extends FlowRdfElement {
83
85
  @click=${this.handleHeaderClick}
84
86
  @keydown=${this.handleHeaderKeyDown}
85
87
  title=""
88
+ @flow-ui-expand=${this.handleExpandCollapse}
89
+ @flow-ui-collapse=${this.handleExpandCollapse}
86
90
  >
87
91
  <slot
88
92
  name="prefix"
@@ -105,10 +109,10 @@ class FlowUiPanelHeader extends FlowRdfElement {
105
109
  ></slot>
106
110
  ${this.fixed ? nothing : html`
107
111
  <flow-ui-split-view-toggle-button
112
+ class="panel-header__toggle-button"
108
113
  position="top"
109
114
  ?closed=${this.closed}
110
- @flow-ui-expand=${this.handleToggleButtonExpandCollapse}
111
- @flow-ui-collapse=${this.handleToggleButtonExpandCollapse}
115
+ @click=${this.handleToggleClick}
112
116
  ></flow-ui-split-view-toggle-button>
113
117
  `}
114
118
  </div>
@@ -119,6 +123,9 @@ FlowUiPanelHeader.styles = styles;
119
123
  __decorateClass([
120
124
  query(".panel-header")
121
125
  ], FlowUiPanelHeader.prototype, "header", 2);
126
+ __decorateClass([
127
+ query(".panel-header__toggle-button")
128
+ ], FlowUiPanelHeader.prototype, "toggleButton", 2);
122
129
  __decorateClass([
123
130
  property({ type: Boolean, reflect: true })
124
131
  ], FlowUiPanelHeader.prototype, "closed", 2);
@@ -384,7 +384,7 @@ const _FlowUiQueryBuilder = class _FlowUiQueryBuilder extends FlowRdfElement {
384
384
  .value=${ruleSet}
385
385
  .config=${this.config}
386
386
  size=${this.size}
387
- !borders=${this.borders}
387
+ ?borders=${this.borders}
388
388
  ?tree-lines=${this.treeLines}
389
389
  @flow-ui-change=${this.handleSubQueryValueChange}
390
390
  @flow-ui-remove=${(ev) => this.handleRemoveRule(ev, index)}
@@ -199,7 +199,7 @@ class FlowUiSplitView extends FlowRdfElement {
199
199
  let sizeDelta = this.sizeToPixels(panel.size) - this.sizeToPixels(panel.closedSize);
200
200
  sizeDelta -= this.shrinkPanels(panelIndex + 1, 1, false, sizeDelta);
201
201
  if (sizeDelta > 0) {
202
- sizeDelta = this.shrinkPanels(panelIndex, -1, false, sizeDelta);
202
+ sizeDelta -= this.shrinkPanels(panelIndex, -1, false, sizeDelta);
203
203
  }
204
204
  if (sizeDelta > 0) {
205
205
  panel.size = "auto";
@@ -337,20 +337,28 @@ class FlowUiSplitView extends FlowRdfElement {
337
337
  return panelSize;
338
338
  });
339
339
  const totalFixedSize = panelSizes.filter((size) => typeof size === "number").reduce((a, b) => a + b, 0);
340
- let availableFlexSize = splitViewSize - totalFixedSize;
341
- let numAutoPanels = panelSizes.filter((size) => size === "auto").length;
342
- for (const [i, panelSize] of panelSizes.entries()) {
340
+ const autoPanels = panelSizes.reduce((accum, panelSize, index) => {
343
341
  if (panelSize === "auto") {
344
- const panelPixelSize = clamp(
345
- availableFlexSize / numAutoPanels,
346
- this.sizeToPixels(this._panels[i].minSize ?? "0px"),
347
- this.sizeToPixels(this._panels[i].maxSize ?? "100%")
348
- );
349
- panelSizes[i] = panelPixelSize;
350
- availableFlexSize -= panelPixelSize;
351
- numAutoPanels--;
342
+ accum.push({ panelIndex: index, size: 0 });
352
343
  }
344
+ return accum;
345
+ }, []);
346
+ let availableFlexSize = splitViewSize - totalFixedSize;
347
+ let layoutIteration = 0;
348
+ while (availableFlexSize > 0 && layoutIteration < 5) {
349
+ availableFlexSize = this.layoutAutoPanels(autoPanels, availableFlexSize, layoutIteration === 0);
350
+ layoutIteration++;
353
351
  }
352
+ autoPanels.forEach((panelInfo) => {
353
+ panelSizes[panelInfo.panelIndex] = panelInfo.size;
354
+ });
355
+ const totalLayoutSize = panelSizes.reduce((a, b) => isNumber(a) && isNumber(b) ? a + b : a, 0);
356
+ if (totalLayoutSize > splitViewSize) {
357
+ console.warn(
358
+ `Total panel size (${totalLayoutSize}px) exceeds split view size (${splitViewSize}px). This may lead to unexpected layout issues.`
359
+ );
360
+ }
361
+ this.positions = panelSizes.map((size) => size + "px");
354
362
  for (const panel of this._panels) {
355
363
  panel.divider = !panel.hidden;
356
364
  }
@@ -358,7 +366,37 @@ class FlowUiSplitView extends FlowRdfElement {
358
366
  if (lastVisiblePanel) {
359
367
  lastVisiblePanel.divider = false;
360
368
  }
361
- this.positions = panelSizes.map((size) => size + "px");
369
+ }
370
+ layoutAutoPanels(autoPanels, totalAutoSize, initialize = false) {
371
+ if (autoPanels?.length === 0) {
372
+ return totalAutoSize;
373
+ }
374
+ if (initialize) {
375
+ autoPanels.forEach((panelInfo) => {
376
+ const panel = this._panels[panelInfo.panelIndex];
377
+ const minSize = this.sizeToPixels(panel.minSize ?? "0px");
378
+ panelInfo.size = minSize;
379
+ totalAutoSize -= minSize;
380
+ });
381
+ }
382
+ const expandableAutoPanels = autoPanels.filter((panelInfo) => {
383
+ const panel = this._panels[panelInfo.panelIndex];
384
+ const panelMaxSize = this.sizeToPixels(panel.maxSize ?? "100%");
385
+ return panelInfo.size < panelMaxSize;
386
+ });
387
+ if (expandableAutoPanels.length > 0) {
388
+ const autoSizePerPanel = totalAutoSize / expandableAutoPanels.length;
389
+ let allocatedSize = 0;
390
+ expandableAutoPanels.forEach((panelInfo) => {
391
+ const panel = this._panels[panelInfo.panelIndex];
392
+ const panelMaxSize = this.sizeToPixels(panel.maxSize ?? "100%");
393
+ const newSize = Math.min(panelInfo.size + autoSizePerPanel, panelMaxSize);
394
+ allocatedSize += newSize - panelInfo.size;
395
+ panelInfo.size = newSize;
396
+ });
397
+ totalAutoSize -= allocatedSize;
398
+ }
399
+ return totalAutoSize;
362
400
  }
363
401
  resizePanels() {
364
402
  const boundingRect = this.splitView.getBoundingClientRect();
@@ -63,6 +63,8 @@ class FlowUiSplitViewDivider extends FlowRdfElement {
63
63
  function __closestFrom(el) {
64
64
  if (!el || el === document || el === window)
65
65
  return null;
66
+ if (el.matches(selector))
67
+ return el;
66
68
  if (el.assignedSlot)
67
69
  el = el.assignedSlot;
68
70
  const found = el.closest(selector);
@@ -3,9 +3,9 @@ import { query, property } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { boolean } from '../../internal/boolean.mjs';
5
5
  import FlowRdfElement from '../../internal/flow-ui-rdf-element.mjs';
6
+ import { isStringFull } from '../../internal/type-checks.mjs';
6
7
  import { setDefaultAnimation } from '../../utilities/animation-registry.mjs';
7
8
  import styles from './split-view-pane.styles.mjs';
8
- import { isStringFull } from '../../internal/type-checks.mjs';
9
9
 
10
10
  var __defProp = Object.defineProperty;
11
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -74,8 +74,14 @@ class FlowUiSplitViewPane extends FlowRdfElement {
74
74
  "split-view-pane--hidden": this.hidden,
75
75
  "split-view-pane--closed": this.closed
76
76
  })}
77
- @flow-ui-expand=${this.expand}
78
- @flow-ui-collapse=${this.collapse}
77
+ @flow-ui-expand=${(ev) => {
78
+ ev.stopPropagation();
79
+ this.expand();
80
+ }}
81
+ @flow-ui-collapse=${(ev) => {
82
+ ev.stopPropagation();
83
+ this.collapse();
84
+ }}
79
85
  >
80
86
  <div part="contents" class="split-view-pane__contents">
81
87
  <slot></slot>
@@ -45,15 +45,22 @@ class FlowUiSplitViewToggleButton extends FlowUiIconButton {
45
45
  this.parentPanelObserver = null;
46
46
  }
47
47
  }
48
+ toggle(emitEvents = true) {
49
+ this.closed = !this.closed;
50
+ if (emitEvents) {
51
+ this.emit(this.closed ? "flow-ui-collapse" : "flow-ui-expand");
52
+ }
53
+ }
48
54
  handleClick(event) {
49
55
  super.handleClick(event);
50
- this.closed = !this.closed;
51
- this.emit(this.closed ? "flow-ui-collapse" : "flow-ui-expand");
56
+ this.toggle();
52
57
  }
53
58
  closestElement(selector, base = this) {
54
59
  function __closestFrom(el) {
55
60
  if (!el || el === document || el === window)
56
61
  return null;
62
+ if (el.matches(selector))
63
+ return el;
57
64
  if (el.assignedSlot)
58
65
  el = el.assignedSlot;
59
66
  const found = el.closest(selector);