pict-section-flow 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-flow",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Pict Section Flow Diagram",
5
5
  "main": "source/Pict-Section-Flow.js",
6
6
  "scripts": {
@@ -934,13 +934,6 @@ class PictProviderFlowCSS extends libFableServiceProviderBase
934
934
  .pict-flow-toolbar-btn:active {
935
935
  background-color: var(--pf-button-active-bg);
936
936
  }
937
- .pict-flow-toolbar-btn.danger {
938
- color: var(--pf-button-danger-text);
939
- border-color: var(--pf-button-danger-text);
940
- }
941
- .pict-flow-toolbar-btn.danger:hover {
942
- background-color: var(--pf-button-danger-hover-bg);
943
- }
944
937
  .pict-flow-toolbar-btn-icon {
945
938
  display: inline-flex;
946
939
  align-items: center;
@@ -1397,9 +1390,6 @@ class PictProviderFlowCSS extends libFableServiceProviderBase
1397
1390
  .pict-flow-floating-btn:hover {
1398
1391
  background-color: var(--pf-button-hover-bg);
1399
1392
  }
1400
- .pict-flow-floating-btn.danger:hover {
1401
- background-color: var(--pf-button-danger-hover-bg);
1402
- }
1403
1393
  .pict-flow-floating-separator {
1404
1394
  height: 1px;
1405
1395
  background-color: var(--pf-divider-light);
@@ -104,8 +104,15 @@ class PictProviderFlowNodeTypes extends libPictProvider
104
104
 
105
105
  this._FlowView = (pOptions && pOptions.FlowView) ? pOptions.FlowView : null;
106
106
 
107
- // Initialize with default node types
108
- this._NodeTypes = JSON.parse(JSON.stringify(_DefaultNodeTypes));
107
+ // Initialize with default node types unless explicitly disabled
108
+ if (pOptions && pOptions.IncludeDefaultNodeTypes === false)
109
+ {
110
+ this._NodeTypes = {};
111
+ }
112
+ else
113
+ {
114
+ this._NodeTypes = JSON.parse(JSON.stringify(_DefaultNodeTypes));
115
+ }
109
116
 
110
117
  // Merge any additional node types passed in via options
111
118
  if (pOptions && pOptions.AdditionalNodeTypes && typeof pOptions.AdditionalNodeTypes === 'object')
@@ -25,7 +25,10 @@ const _DefaultConfiguration =
25
25
  <button class="pict-flow-floating-btn" data-flow-action="add-node" title="Add Node">
26
26
  <span id="Flow-FloatingIcon-plus-{~D:Record.FlowViewIdentifier~}"></span>
27
27
  </button>
28
- <button class="pict-flow-floating-btn danger" data-flow-action="delete-selected" title="Delete Selected">
28
+ <button class="pict-flow-floating-btn" data-flow-action="cards-popup" title="Cards">
29
+ <span id="Flow-FloatingIcon-cards-{~D:Record.FlowViewIdentifier~}"></span>
30
+ </button>
31
+ <button class="pict-flow-floating-btn" data-flow-action="delete-selected" title="Delete Selected">
29
32
  <span id="Flow-FloatingIcon-trash-{~D:Record.FlowViewIdentifier~}"></span>
30
33
  </button>
31
34
  <div class="pict-flow-floating-separator"></div>
@@ -42,9 +45,6 @@ const _DefaultConfiguration =
42
45
  <button class="pict-flow-floating-btn" data-flow-action="auto-layout" title="Auto Layout">
43
46
  <span id="Flow-FloatingIcon-auto-layout-{~D:Record.FlowViewIdentifier~}"></span>
44
47
  </button>
45
- <button class="pict-flow-floating-btn" data-flow-action="cards-popup" title="Cards">
46
- <span id="Flow-FloatingIcon-cards-{~D:Record.FlowViewIdentifier~}"></span>
47
- </button>
48
48
  <button class="pict-flow-floating-btn" data-flow-action="layout-popup" title="Layout">
49
49
  <span id="Flow-FloatingIcon-layout-{~D:Record.FlowViewIdentifier~}"></span>
50
50
  </button>
@@ -155,6 +155,27 @@ class PictViewFlowFloatingToolbar extends libPictView
155
155
  // Populate icons
156
156
  this._populateIcons();
157
157
 
158
+ // Hide buttons based on options
159
+ if (tmpFloatingToolbar.length > 0)
160
+ {
161
+ if (this.options.EnableAddNode === false)
162
+ {
163
+ let tmpAddNodeBtn = tmpFloatingToolbar[0].querySelector('[data-flow-action="add-node"]');
164
+ if (tmpAddNodeBtn)
165
+ {
166
+ tmpAddNodeBtn.style.display = 'none';
167
+ }
168
+ }
169
+ if (this.options.EnableCardPalette === false)
170
+ {
171
+ let tmpCardsBtn = tmpFloatingToolbar[0].querySelector('[data-flow-action="cards-popup"]');
172
+ if (tmpCardsBtn)
173
+ {
174
+ tmpCardsBtn.style.display = 'none';
175
+ }
176
+ }
177
+ }
178
+
158
179
  return super.onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent);
159
180
  }
160
181
 
@@ -12,6 +12,8 @@ const _DefaultConfiguration =
12
12
  FlowViewIdentifier: 'Pict-Flow',
13
13
 
14
14
  EnablePalette: true,
15
+ EnableAddNode: true,
16
+ EnableCardPalette: true,
15
17
 
16
18
  CSS: false,
17
19
 
@@ -26,16 +28,14 @@ const _DefaultConfiguration =
26
28
  <span class="pict-flow-toolbar-btn-icon" id="Flow-Toolbar-Icon-plus-{~D:Record.FlowViewIdentifier~}"></span>
27
29
  <span class="pict-flow-toolbar-btn-text">Node</span>
28
30
  </button>
29
- <button class="pict-flow-toolbar-btn danger" data-flow-action="delete-selected" title="Delete Node">
30
- <span class="pict-flow-toolbar-btn-icon" id="Flow-Toolbar-Icon-trash-{~D:Record.FlowViewIdentifier~}"></span>
31
- </button>
32
- </div>
33
- <div class="pict-flow-toolbar-group">
34
31
  <button class="pict-flow-toolbar-btn" data-flow-action="cards-popup" id="Flow-Toolbar-Cards-{~D:Record.FlowViewIdentifier~}" title="Card Palette">
35
32
  <span class="pict-flow-toolbar-btn-icon" id="Flow-Toolbar-Icon-cards-{~D:Record.FlowViewIdentifier~}"></span>
36
33
  <span class="pict-flow-toolbar-btn-text">Cards</span>
37
34
  <span class="pict-flow-toolbar-btn-chevron" id="Flow-Toolbar-CardsChevron-{~D:Record.FlowViewIdentifier~}"></span>
38
35
  </button>
36
+ <button class="pict-flow-toolbar-btn" data-flow-action="delete-selected" title="Delete Node">
37
+ <span class="pict-flow-toolbar-btn-icon" id="Flow-Toolbar-Icon-trash-{~D:Record.FlowViewIdentifier~}"></span>
38
+ </button>
39
39
  </div>
40
40
  <div class="pict-flow-toolbar-group">
41
41
  <button class="pict-flow-toolbar-btn" data-flow-action="layout-popup" id="Flow-Toolbar-Layout-{~D:Record.FlowViewIdentifier~}" title="Manage Layouts">
@@ -157,6 +157,24 @@ class PictViewFlowToolbar extends libPictView
157
157
  // Populate SVG icons for toolbar buttons
158
158
  this._populateToolbarIcons();
159
159
 
160
+ // Hide buttons based on options
161
+ if (this.options.EnableAddNode === false)
162
+ {
163
+ let tmpAddNodeBtn = this.pict.ContentAssignment.getElement(`#Flow-Toolbar-AddNode-${tmpFlowViewIdentifier}`);
164
+ if (tmpAddNodeBtn.length > 0)
165
+ {
166
+ tmpAddNodeBtn[0].style.display = 'none';
167
+ }
168
+ }
169
+ if (this.options.EnableCardPalette === false)
170
+ {
171
+ let tmpCardsBtn = this.pict.ContentAssignment.getElement(`#Flow-Toolbar-Cards-${tmpFlowViewIdentifier}`);
172
+ if (tmpCardsBtn.length > 0)
173
+ {
174
+ tmpCardsBtn[0].style.display = 'none';
175
+ }
176
+ }
177
+
160
178
  return super.onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent);
161
179
  }
162
180
 
@@ -508,38 +526,100 @@ class PictViewFlowToolbar extends libPictView
508
526
  // ── Cards Popup ───────────────────────────────────────────────────────
509
527
 
510
528
  /**
511
- * Build the Cards popup content (reuses palette rendering).
529
+ * Build the Cards popup content with search and categorized palette.
512
530
  * @param {HTMLElement} pContainer
513
531
  */
514
532
  _buildCardsPopup(pContainer)
515
533
  {
516
- this._renderPalette(pContainer);
534
+ // Search wrapper
535
+ let tmpSearchWrapper = document.createElement('div');
536
+ tmpSearchWrapper.className = 'pict-flow-popup-search-wrapper';
537
+
538
+ let tmpSearchIcon = document.createElement('span');
539
+ tmpSearchIcon.className = 'pict-flow-popup-search-icon';
540
+ let tmpIconProvider = this._FlowView ? this._FlowView._IconProvider : null;
541
+ if (tmpIconProvider)
542
+ {
543
+ tmpSearchIcon.innerHTML = tmpIconProvider.getIconSVGMarkup('search', 12);
544
+ }
545
+ tmpSearchWrapper.appendChild(tmpSearchIcon);
546
+
547
+ let tmpSearchInput = document.createElement('input');
548
+ tmpSearchInput.className = 'pict-flow-popup-search';
549
+ tmpSearchInput.setAttribute('type', 'text');
550
+ tmpSearchInput.setAttribute('placeholder', 'Search cards...');
551
+ tmpSearchWrapper.appendChild(tmpSearchInput);
552
+ pContainer.appendChild(tmpSearchWrapper);
553
+
554
+ // Palette list container
555
+ let tmpListDiv = document.createElement('div');
556
+ tmpListDiv.className = 'pict-flow-popup-node-list';
557
+ pContainer.appendChild(tmpListDiv);
558
+
559
+ // Initial population
560
+ this._renderPalette(tmpListDiv, '');
561
+
562
+ // Filter on input
563
+ tmpSearchInput.addEventListener('input', () =>
564
+ {
565
+ this._renderPalette(tmpListDiv, tmpSearchInput.value);
566
+ });
567
+
568
+ // Focus search input
569
+ setTimeout(() => { tmpSearchInput.focus(); }, 50);
517
570
  }
518
571
 
519
572
  /**
520
573
  * Render the card palette with categories and card chips into a container.
521
574
  * @param {HTMLElement} pContainer - The target container element
575
+ * @param {string} [pFilter] - Optional search filter text
522
576
  */
523
- _renderPalette(pContainer)
577
+ _renderPalette(pContainer, pFilter)
524
578
  {
525
579
  if (!this._FlowView || !this._FlowView._NodeTypeProvider) return;
526
580
 
527
- let tmpCategories = this._FlowView._NodeTypeProvider.getCardsByCategory();
528
- let tmpCategoryKeys = Object.keys(tmpCategories);
529
-
530
- if (tmpCategoryKeys.length === 0)
581
+ // Clear existing content
582
+ while (pContainer.firstChild)
531
583
  {
532
- let tmpEmpty = document.createElement('div');
533
- tmpEmpty.className = 'pict-flow-popup-list-empty';
534
- tmpEmpty.textContent = 'No card types available';
535
- pContainer.appendChild(tmpEmpty);
536
- return;
584
+ pContainer.removeChild(pContainer.firstChild);
537
585
  }
538
586
 
587
+ let tmpCategories = this._FlowView._NodeTypeProvider.getCardsByCategory();
588
+ let tmpCategoryKeys = Object.keys(tmpCategories);
589
+ let tmpFilter = (pFilter || '').toLowerCase().trim();
590
+ let tmpTotalMatchCount = 0;
591
+
539
592
  for (let i = 0; i < tmpCategoryKeys.length; i++)
540
593
  {
541
594
  let tmpCategoryName = tmpCategoryKeys[i];
542
595
  let tmpCards = tmpCategories[tmpCategoryName];
596
+ let tmpMatchingCards = [];
597
+
598
+ // Filter cards within this category
599
+ for (let j = 0; j < tmpCards.length; j++)
600
+ {
601
+ let tmpCardConfig = tmpCards[j];
602
+ let tmpMeta = tmpCardConfig.CardMetadata || {};
603
+
604
+ if (tmpFilter)
605
+ {
606
+ let tmpLabel = (tmpCardConfig.Label || '').toLowerCase();
607
+ let tmpCode = (tmpMeta.Code || '').toLowerCase();
608
+ let tmpCategory = tmpCategoryName.toLowerCase();
609
+ if (tmpLabel.indexOf(tmpFilter) < 0 &&
610
+ tmpCode.indexOf(tmpFilter) < 0 &&
611
+ tmpCategory.indexOf(tmpFilter) < 0)
612
+ {
613
+ continue;
614
+ }
615
+ }
616
+
617
+ tmpMatchingCards.push(tmpCardConfig);
618
+ }
619
+
620
+ if (tmpMatchingCards.length === 0) continue;
621
+
622
+ tmpTotalMatchCount += tmpMatchingCards.length;
543
623
 
544
624
  let tmpCategoryDiv = document.createElement('div');
545
625
  tmpCategoryDiv.className = 'pict-flow-palette-category';
@@ -553,9 +633,9 @@ class PictViewFlowToolbar extends libPictView
553
633
  let tmpCardsDiv = document.createElement('div');
554
634
  tmpCardsDiv.className = 'pict-flow-palette-cards';
555
635
 
556
- for (let j = 0; j < tmpCards.length; j++)
636
+ for (let j = 0; j < tmpMatchingCards.length; j++)
557
637
  {
558
- let tmpCardConfig = tmpCards[j];
638
+ let tmpCardConfig = tmpMatchingCards[j];
559
639
  let tmpMeta = tmpCardConfig.CardMetadata || {};
560
640
 
561
641
  let tmpCardEl = document.createElement('div');
@@ -635,6 +715,14 @@ class PictViewFlowToolbar extends libPictView
635
715
  tmpCategoryDiv.appendChild(tmpCardsDiv);
636
716
  pContainer.appendChild(tmpCategoryDiv);
637
717
  }
718
+
719
+ if (tmpTotalMatchCount === 0)
720
+ {
721
+ let tmpEmpty = document.createElement('div');
722
+ tmpEmpty.className = 'pict-flow-popup-list-empty';
723
+ tmpEmpty.textContent = tmpFilter ? 'No matching cards' : 'No card types available';
724
+ pContainer.appendChild(tmpEmpty);
725
+ }
638
726
  }
639
727
 
640
728
  // ── Layout Popup ──────────────────────────────────────────────────────
@@ -1018,7 +1106,9 @@ class PictViewFlowToolbar extends libPictView
1018
1106
  'PictViewFlowFloatingToolbar',
1019
1107
  {
1020
1108
  FlowViewIdentifier: tmpFlowViewIdentifier,
1021
- DefaultDestinationAddress: `#Flow-FloatingToolbar-Container-${tmpFlowViewIdentifier}`
1109
+ DefaultDestinationAddress: `#Flow-FloatingToolbar-Container-${tmpFlowViewIdentifier}`,
1110
+ EnableAddNode: this.options.EnableAddNode,
1111
+ EnableCardPalette: this.options.EnableCardPalette
1022
1112
  }
1023
1113
  );
1024
1114
  this._FloatingToolbarView._ToolbarView = this;
@@ -50,6 +50,9 @@ const _DefaultConfiguration =
50
50
  TargetElementAddress: '#Flow-SVG-Container',
51
51
 
52
52
  EnableToolbar: true,
53
+ EnableAddNode: true,
54
+ EnableCardPalette: true,
55
+ IncludeDefaultNodeTypes: true,
53
56
  EnablePanning: true,
54
57
  EnableZooming: true,
55
58
  EnableNodeDragging: true,
@@ -145,7 +148,7 @@ class PictViewFlow extends libPictView
145
148
  { ServiceType: 'PictProviderFlowIcons', Library: libPictProviderFlowIcons, Property: '_IconProvider', PostInit: 'registerIconTemplates' },
146
149
  { ServiceType: 'PictProviderFlowConnectorShapes', Library: libPictProviderFlowConnectorShapes, Property: '_ConnectorShapesProvider' },
147
150
  { ServiceType: 'PictProviderFlowPanelChrome', Library: libPictProviderFlowPanelChrome, Property: '_PanelChromeProvider' },
148
- { ServiceType: 'PictProviderFlowNodeTypes', Library: libPictProviderFlowNodeTypes, Property: '_NodeTypeProvider', ExtraOptions: () => ({ AdditionalNodeTypes: this.options.NodeTypes }) },
151
+ { ServiceType: 'PictProviderFlowNodeTypes', Library: libPictProviderFlowNodeTypes, Property: '_NodeTypeProvider', ExtraOptions: () => ({ AdditionalNodeTypes: this.options.NodeTypes, IncludeDefaultNodeTypes: this.options.IncludeDefaultNodeTypes }) },
149
152
  { ServiceType: 'PictProviderFlowEventHandler', Library: libPictProviderFlowEventHandler, Property: '_EventHandlerProvider' },
150
153
  { ServiceType: 'PictProviderFlowLayouts', Library: libPictProviderFlowLayouts, Property: '_LayoutProvider', PostInit: 'loadPersistedLayouts' },
151
154
 
@@ -410,7 +413,9 @@ class PictViewFlow extends libPictView
410
413
  {
411
414
  ViewIdentifier: `Flow-Toolbar-${tmpViewIdentifier}`,
412
415
  DefaultDestinationAddress: `#Flow-Toolbar-${tmpViewIdentifier}`,
413
- FlowViewIdentifier: tmpViewIdentifier
416
+ FlowViewIdentifier: tmpViewIdentifier,
417
+ EnableAddNode: this.options.EnableAddNode,
418
+ EnableCardPalette: this.options.EnableCardPalette
414
419
  }
415
420
  ));
416
421
  // Use the toolbar's render method after it's set up