@superleapai/flow-ui 2.5.19 → 2.5.21
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/CHANGELOG.md +2 -2
- package/LICENSE +1 -1
- package/README.md +38 -38
- package/components/enum-multiselect.js +119 -56
- package/components/enum-select.js +90 -48
- package/components/file-input.js +111 -49
- package/core/bridge.js +4 -6
- package/core/crm.js +17 -17
- package/core/flow.js +230 -59
- package/core/superleapClient.js +2 -2
- package/dist/superleap-flow.js +271 -2227
- package/dist/superleap-flow.js.map +1 -1
- package/dist/superleap-flow.min.js +2 -2
- package/index.d.ts +31 -20
- package/index.js +41 -30
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EnumSelect Component (vanilla JS, Tailwind)
|
|
3
|
-
* A select component that fetches options from
|
|
3
|
+
* A select component that fetches options from Superleap SDK based on object column metadata.
|
|
4
4
|
* Supports dependent fields, URL-based enums, and search functionality.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Usage:
|
|
7
7
|
* var enumSelect = EnumSelect.create({
|
|
8
8
|
* fieldId: 'status',
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"border-error-border hover:border-error-border-hover focus:border-1/2 focus:border-error-border-hover",
|
|
44
44
|
warning:
|
|
45
45
|
"border-warning-border hover:border-warning-border-hover focus:border-1/2 focus:border-warning-border-hover",
|
|
46
|
-
borderless:
|
|
46
|
+
borderless:
|
|
47
|
+
"border-none shadow-none rounded-0 bg-fill-quarternary-fill-white",
|
|
47
48
|
inline:
|
|
48
49
|
"focus:border-transparent border border-transparent shadow-none rounded-0 bg-fill-quarternary-fill-white hover:bg-fill-tertiary-fill-light-gray hover:border-transparent",
|
|
49
50
|
};
|
|
@@ -52,7 +53,9 @@
|
|
|
52
53
|
large: "px-12 py-8",
|
|
53
54
|
small: "px-8 py-4",
|
|
54
55
|
};
|
|
55
|
-
var placeholderClass = placeholder
|
|
56
|
+
var placeholderClass = placeholder
|
|
57
|
+
? " text-typography-quaternary-text"
|
|
58
|
+
: "";
|
|
56
59
|
var disabledClass = disabled
|
|
57
60
|
? " pointer-events-none cursor-not-allowed bg-fill-tertiary-fill-light-gray text-typography-quaternary-text hover:border-border-primary"
|
|
58
61
|
: "";
|
|
@@ -73,7 +76,10 @@
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
function getDep(name) {
|
|
76
|
-
if (
|
|
79
|
+
if (
|
|
80
|
+
typeof global.FlowUI !== "undefined" &&
|
|
81
|
+
typeof global.FlowUI._getComponent === "function"
|
|
82
|
+
) {
|
|
77
83
|
var c = global.FlowUI._getComponent(name);
|
|
78
84
|
if (c) return c;
|
|
79
85
|
}
|
|
@@ -159,7 +165,13 @@
|
|
|
159
165
|
|
|
160
166
|
var trigger = document.createElement("button");
|
|
161
167
|
trigger.type = "button";
|
|
162
|
-
trigger.className = triggerClasses(
|
|
168
|
+
trigger.className = triggerClasses(
|
|
169
|
+
variant,
|
|
170
|
+
size,
|
|
171
|
+
disabled,
|
|
172
|
+
!value,
|
|
173
|
+
canClear && !!value && !disabled,
|
|
174
|
+
);
|
|
163
175
|
trigger.disabled = disabled;
|
|
164
176
|
trigger.setAttribute("aria-haspopup", "listbox");
|
|
165
177
|
trigger.setAttribute("aria-expanded", "false");
|
|
@@ -175,7 +187,7 @@
|
|
|
175
187
|
"ml-4 box-content flex size-16 items-center justify-center shrink-0 transition-transform duration-200 group-[.open]:rotate-180";
|
|
176
188
|
chevron.innerHTML = CHEVRON_SVG;
|
|
177
189
|
chevron.setAttribute("aria-hidden", "true");
|
|
178
|
-
|
|
190
|
+
|
|
179
191
|
var showChevron = variant !== "inline" || !value;
|
|
180
192
|
if (showChevron) {
|
|
181
193
|
trigger.appendChild(chevron);
|
|
@@ -195,14 +207,8 @@
|
|
|
195
207
|
e.stopPropagation();
|
|
196
208
|
value = "";
|
|
197
209
|
triggerText.textContent = placeholder;
|
|
198
|
-
trigger.className = triggerClasses(
|
|
199
|
-
|
|
200
|
-
size,
|
|
201
|
-
disabled,
|
|
202
|
-
true,
|
|
203
|
-
false
|
|
204
|
-
);
|
|
205
|
-
|
|
210
|
+
trigger.className = triggerClasses(variant, size, disabled, true, false);
|
|
211
|
+
|
|
206
212
|
// Update chevron visibility for inline variant
|
|
207
213
|
var shouldShowChevron = variant !== "inline" || !value;
|
|
208
214
|
if (shouldShowChevron && !chevron.parentNode) {
|
|
@@ -210,17 +216,17 @@
|
|
|
210
216
|
} else if (!shouldShowChevron && chevron.parentNode) {
|
|
211
217
|
chevron.parentNode.removeChild(chevron);
|
|
212
218
|
}
|
|
213
|
-
|
|
219
|
+
|
|
214
220
|
updateClearButton();
|
|
215
221
|
renderOptions();
|
|
216
|
-
|
|
222
|
+
|
|
217
223
|
if (onClear) onClear();
|
|
218
224
|
if (onChange) onChange("");
|
|
219
225
|
});
|
|
220
226
|
triggerWrapper.appendChild(clearBtn);
|
|
221
227
|
|
|
222
228
|
container.appendChild(triggerWrapper);
|
|
223
|
-
|
|
229
|
+
|
|
224
230
|
// Helper to update clear button visibility
|
|
225
231
|
function updateClearButton() {
|
|
226
232
|
if (clearBtn) {
|
|
@@ -231,15 +237,20 @@
|
|
|
231
237
|
// Create dropdown content
|
|
232
238
|
var content = document.createElement("div");
|
|
233
239
|
content.setAttribute("role", "listbox");
|
|
234
|
-
content.className =
|
|
240
|
+
content.className =
|
|
241
|
+
"w-full min-w-[200px] max-h-[30vh] overflow-hidden flex flex-col";
|
|
235
242
|
|
|
236
243
|
// Search input (using InputComponent like phone-input)
|
|
237
244
|
var searchContainer = document.createElement("div");
|
|
238
|
-
searchContainer.className =
|
|
239
|
-
|
|
245
|
+
searchContainer.className =
|
|
246
|
+
"py-2 border-b-1/2 border-border-primary hidden";
|
|
247
|
+
|
|
240
248
|
var searchInputWrapper = null;
|
|
241
249
|
var searchInput = null;
|
|
242
|
-
if (
|
|
250
|
+
if (
|
|
251
|
+
global.InputComponent &&
|
|
252
|
+
typeof global.InputComponent.create === "function"
|
|
253
|
+
) {
|
|
243
254
|
searchInputWrapper = global.InputComponent.create({
|
|
244
255
|
variant: "borderless",
|
|
245
256
|
inputSize: "small",
|
|
@@ -266,12 +277,12 @@
|
|
|
266
277
|
// Fallback to native input with search icon
|
|
267
278
|
var fallbackWrapper = document.createElement("div");
|
|
268
279
|
fallbackWrapper.className = "flex items-center gap-8";
|
|
269
|
-
|
|
280
|
+
|
|
270
281
|
var searchIconSpan = document.createElement("span");
|
|
271
282
|
searchIconSpan.className = "shrink-0 text-typography-tertiary-text";
|
|
272
283
|
searchIconSpan.innerHTML = SEARCH_ICON;
|
|
273
284
|
fallbackWrapper.appendChild(searchIconSpan);
|
|
274
|
-
|
|
285
|
+
|
|
275
286
|
var nativeSearchInput = document.createElement("input");
|
|
276
287
|
nativeSearchInput.type = "text";
|
|
277
288
|
nativeSearchInput.placeholder = "Search...";
|
|
@@ -337,7 +348,8 @@
|
|
|
337
348
|
var filteredOptions = getFilteredOptions();
|
|
338
349
|
|
|
339
350
|
// Update search visibility
|
|
340
|
-
var shouldShowSearch =
|
|
351
|
+
var shouldShowSearch =
|
|
352
|
+
showSearch !== undefined ? showSearch : options.length > 10;
|
|
341
353
|
searchContainer.className = shouldShowSearch
|
|
342
354
|
? "p-8 border-b-1/2 border-border-primary "
|
|
343
355
|
: "p-8 hidden";
|
|
@@ -368,7 +380,7 @@
|
|
|
368
380
|
"hover:bg-fill-tertiary-fill-light-gray focus:bg-fill-tertiary-fill-light-gray",
|
|
369
381
|
isSelected
|
|
370
382
|
? "bg-primary-surface hover:!bg-primary-surface-hover"
|
|
371
|
-
: ""
|
|
383
|
+
: "",
|
|
372
384
|
);
|
|
373
385
|
|
|
374
386
|
var optionContent = document.createElement("span");
|
|
@@ -380,7 +392,10 @@
|
|
|
380
392
|
var badgeConfig = opt.badge_config;
|
|
381
393
|
if (badgeConfig && (badgeConfig.icon_color || badgeConfig.start_icon)) {
|
|
382
394
|
var IconComponent = getIcon();
|
|
383
|
-
if (
|
|
395
|
+
if (
|
|
396
|
+
IconComponent &&
|
|
397
|
+
typeof IconComponent.createIconOrColor === "function"
|
|
398
|
+
) {
|
|
384
399
|
var iconEl = IconComponent.createIconOrColor({
|
|
385
400
|
start_icon: badgeConfig.start_icon,
|
|
386
401
|
icon_color: badgeConfig.icon_color,
|
|
@@ -416,7 +431,6 @@
|
|
|
416
431
|
});
|
|
417
432
|
}
|
|
418
433
|
|
|
419
|
-
|
|
420
434
|
function openDropdown() {
|
|
421
435
|
if (disabled) return;
|
|
422
436
|
document
|
|
@@ -445,7 +459,8 @@
|
|
|
445
459
|
}
|
|
446
460
|
|
|
447
461
|
function toggleDropdown() {
|
|
448
|
-
var isVisible =
|
|
462
|
+
var isVisible =
|
|
463
|
+
popover.element && popover.element.classList.contains("visible");
|
|
449
464
|
if (isVisible) {
|
|
450
465
|
closeDropdown();
|
|
451
466
|
} else {
|
|
@@ -461,7 +476,7 @@
|
|
|
461
476
|
size,
|
|
462
477
|
disabled,
|
|
463
478
|
false,
|
|
464
|
-
canClear && !!value && !disabled
|
|
479
|
+
canClear && !!value && !disabled,
|
|
465
480
|
);
|
|
466
481
|
|
|
467
482
|
// Update chevron visibility for inline variant
|
|
@@ -515,7 +530,10 @@
|
|
|
515
530
|
|
|
516
531
|
trigger.addEventListener("keydown", function (e) {
|
|
517
532
|
if (disabled) return;
|
|
518
|
-
var isVisible =
|
|
533
|
+
var isVisible =
|
|
534
|
+
popover &&
|
|
535
|
+
popover.element &&
|
|
536
|
+
popover.element.classList.contains("visible");
|
|
519
537
|
switch (e.key) {
|
|
520
538
|
case "Enter":
|
|
521
539
|
case " ":
|
|
@@ -590,8 +608,11 @@
|
|
|
590
608
|
// Load options from SDK
|
|
591
609
|
function loadOptions() {
|
|
592
610
|
var client = getClient();
|
|
593
|
-
if (
|
|
594
|
-
|
|
611
|
+
if (
|
|
612
|
+
!client ||
|
|
613
|
+
(typeof client.isAvailable === "function" && !client.isAvailable())
|
|
614
|
+
) {
|
|
615
|
+
error = "Superleap SDK not initialized";
|
|
595
616
|
showError(error);
|
|
596
617
|
if (onError) onError(error);
|
|
597
618
|
return;
|
|
@@ -608,26 +629,38 @@
|
|
|
608
629
|
}
|
|
609
630
|
|
|
610
631
|
var model = sdk.model(objectSlug);
|
|
611
|
-
|
|
632
|
+
|
|
612
633
|
model
|
|
613
634
|
.getField(columnSlug)
|
|
614
635
|
.then(function (field) {
|
|
615
636
|
if (!field) {
|
|
616
|
-
throw new Error(
|
|
637
|
+
throw new Error(
|
|
638
|
+
"Field '" +
|
|
639
|
+
columnSlug +
|
|
640
|
+
"' not found in object '" +
|
|
641
|
+
objectSlug +
|
|
642
|
+
"'",
|
|
643
|
+
);
|
|
617
644
|
}
|
|
618
645
|
|
|
619
646
|
columnData = field;
|
|
620
647
|
|
|
621
648
|
// Check if it's a select/stage field with enum_group
|
|
622
649
|
if (!field.enumGroup || !field.enumGroup.values) {
|
|
623
|
-
throw new Error(
|
|
650
|
+
throw new Error(
|
|
651
|
+
"Field '" + columnSlug + "' does not have enum options",
|
|
652
|
+
);
|
|
624
653
|
}
|
|
625
654
|
|
|
626
655
|
var enumGroup = field.enumGroup;
|
|
627
656
|
var allOptions = enumGroup.values || [];
|
|
628
657
|
|
|
629
658
|
// Handle dependent fields
|
|
630
|
-
if (
|
|
659
|
+
if (
|
|
660
|
+
columnData.is_dependent_field &&
|
|
661
|
+
enumGroup.properties &&
|
|
662
|
+
enumGroup.properties.parent_column_slug
|
|
663
|
+
) {
|
|
631
664
|
var parentSlug = enumGroup.properties.parent_column_slug;
|
|
632
665
|
var parentValue = currentRecordData[parentSlug];
|
|
633
666
|
|
|
@@ -652,14 +685,20 @@
|
|
|
652
685
|
} else {
|
|
653
686
|
// Filter active options (or include archived if it's the selected value)
|
|
654
687
|
options = allOptions.filter(function (option) {
|
|
655
|
-
return
|
|
688
|
+
return (
|
|
689
|
+
option.is_active === 1 ||
|
|
690
|
+
option.is_active === true ||
|
|
691
|
+
option.slug === value
|
|
692
|
+
);
|
|
656
693
|
});
|
|
657
694
|
}
|
|
658
695
|
|
|
659
696
|
// Sort by rank
|
|
660
697
|
options.sort(function (a, b) {
|
|
661
|
-
var rankA =
|
|
662
|
-
|
|
698
|
+
var rankA =
|
|
699
|
+
a.rank !== undefined && a.rank !== null ? a.rank : 999999;
|
|
700
|
+
var rankB =
|
|
701
|
+
b.rank !== undefined && b.rank !== null ? b.rank : 999999;
|
|
663
702
|
return rankA - rankB;
|
|
664
703
|
});
|
|
665
704
|
|
|
@@ -678,9 +717,9 @@
|
|
|
678
717
|
size,
|
|
679
718
|
disabled,
|
|
680
719
|
false,
|
|
681
|
-
canClear && !!value && !disabled
|
|
720
|
+
canClear && !!value && !disabled,
|
|
682
721
|
);
|
|
683
|
-
|
|
722
|
+
|
|
684
723
|
// Update chevron visibility for inline variant
|
|
685
724
|
var shouldShowChevron = variant !== "inline" || !value;
|
|
686
725
|
if (shouldShowChevron && !chevron.parentNode) {
|
|
@@ -688,7 +727,7 @@
|
|
|
688
727
|
} else if (!shouldShowChevron && chevron.parentNode) {
|
|
689
728
|
chevron.parentNode.removeChild(chevron);
|
|
690
729
|
}
|
|
691
|
-
|
|
730
|
+
|
|
692
731
|
updateClearButton();
|
|
693
732
|
}
|
|
694
733
|
}
|
|
@@ -720,9 +759,9 @@
|
|
|
720
759
|
size,
|
|
721
760
|
disabled,
|
|
722
761
|
!value,
|
|
723
|
-
canClear && !!value && !disabled
|
|
762
|
+
canClear && !!value && !disabled,
|
|
724
763
|
);
|
|
725
|
-
|
|
764
|
+
|
|
726
765
|
// Update chevron visibility for inline variant
|
|
727
766
|
var shouldShowChevron = variant !== "inline" || !value;
|
|
728
767
|
if (shouldShowChevron && !chevron.parentNode) {
|
|
@@ -730,7 +769,7 @@
|
|
|
730
769
|
} else if (!shouldShowChevron && chevron.parentNode) {
|
|
731
770
|
chevron.parentNode.removeChild(chevron);
|
|
732
771
|
}
|
|
733
|
-
|
|
772
|
+
|
|
734
773
|
updateClearButton();
|
|
735
774
|
renderOptions();
|
|
736
775
|
};
|
|
@@ -748,10 +787,13 @@
|
|
|
748
787
|
size,
|
|
749
788
|
disabled,
|
|
750
789
|
!value,
|
|
751
|
-
canClear && !!value && !disabled
|
|
790
|
+
canClear && !!value && !disabled,
|
|
752
791
|
);
|
|
753
792
|
updateClearButton();
|
|
754
|
-
var isVisible =
|
|
793
|
+
var isVisible =
|
|
794
|
+
popover &&
|
|
795
|
+
popover.element &&
|
|
796
|
+
popover.element.classList.contains("visible");
|
|
755
797
|
if (disabled && isVisible) closeDropdown();
|
|
756
798
|
};
|
|
757
799
|
|