@budibase/bbui 3.3.0 → 3.3.2
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/dist/bbui.mjs +131 -61
- package/package.json +2 -2
- package/src/Actions/{position_dropdown.js → position_dropdown.ts} +79 -57
- package/src/Form/Core/Checkbox.svelte +8 -7
- package/src/Form/Core/CheckboxGroup.svelte +13 -8
- package/src/Form/Core/Combobox.svelte +22 -11
- package/src/Popover/Popover.svelte +21 -16
package/dist/bbui.mjs
CHANGED
|
@@ -3694,25 +3694,9 @@ class StatusLight extends SvelteComponent {
|
|
|
3694
3694
|
});
|
|
3695
3695
|
}
|
|
3696
3696
|
}
|
|
3697
|
-
const Strategies = {
|
|
3698
|
-
StartToStart: "StartToStart",
|
|
3699
|
-
// e.g. left alignment
|
|
3700
|
-
EndToEnd: "EndToEnd",
|
|
3701
|
-
// e.g. right alignment
|
|
3702
|
-
StartToEnd: "StartToEnd",
|
|
3703
|
-
// e.g. right-outside alignment
|
|
3704
|
-
EndToStart: "EndToStart",
|
|
3705
|
-
// e.g. left-outside alignment
|
|
3706
|
-
MidPoint: "MidPoint",
|
|
3707
|
-
// centers relative to midpoints
|
|
3708
|
-
ScreenEdge: "ScreenEdge"
|
|
3709
|
-
// locks to screen edge
|
|
3710
|
-
};
|
|
3711
3697
|
function positionDropdown(f, u) {
|
|
3712
3698
|
let p, m = u;
|
|
3713
|
-
const v = () => {
|
|
3714
|
-
y(m);
|
|
3715
|
-
}, y = (w) => {
|
|
3699
|
+
const v = () => y(m), y = (w) => {
|
|
3716
3700
|
const {
|
|
3717
3701
|
anchor: T,
|
|
3718
3702
|
align: D,
|
|
@@ -3732,8 +3716,8 @@ function positionDropdown(f, u) {
|
|
|
3732
3716
|
maxHeight: L,
|
|
3733
3717
|
minWidth: N ? $.width : P,
|
|
3734
3718
|
maxWidth: N ? $.width : R,
|
|
3735
|
-
left:
|
|
3736
|
-
top:
|
|
3719
|
+
left: 0,
|
|
3720
|
+
top: 0
|
|
3737
3721
|
};
|
|
3738
3722
|
if (typeof Z == "function")
|
|
3739
3723
|
oe = Z($, ee, {
|
|
@@ -3745,54 +3729,53 @@ function positionDropdown(f, u) {
|
|
|
3745
3729
|
!oe.maxHeight && Y && (oe.maxHeight = Ie);
|
|
3746
3730
|
}, se = (Ie) => {
|
|
3747
3731
|
switch (Ie) {
|
|
3748
|
-
case
|
|
3732
|
+
case "StartToStart":
|
|
3749
3733
|
default:
|
|
3750
3734
|
oe.left = $.left;
|
|
3751
3735
|
break;
|
|
3752
|
-
case
|
|
3736
|
+
case "EndToEnd":
|
|
3753
3737
|
oe.left = $.right - ee.width;
|
|
3754
3738
|
break;
|
|
3755
|
-
case
|
|
3739
|
+
case "StartToEnd":
|
|
3756
3740
|
oe.left = $.right + W;
|
|
3757
3741
|
break;
|
|
3758
|
-
case
|
|
3742
|
+
case "EndToStart":
|
|
3759
3743
|
oe.left = $.left - ee.width - W;
|
|
3760
3744
|
break;
|
|
3761
|
-
case
|
|
3745
|
+
case "MidPoint":
|
|
3762
3746
|
oe.left = $.left + $.width / 2 - ee.width / 2;
|
|
3763
3747
|
break;
|
|
3764
|
-
case
|
|
3748
|
+
case "ScreenEdge":
|
|
3765
3749
|
oe.left = te - ee.width - pe;
|
|
3766
3750
|
break;
|
|
3767
3751
|
}
|
|
3768
3752
|
}, xe = (Ie) => {
|
|
3769
3753
|
switch (Ie) {
|
|
3770
|
-
case
|
|
3754
|
+
case "StartToStart":
|
|
3771
3755
|
oe.top = $.top, de(he - $.top - pe);
|
|
3772
3756
|
break;
|
|
3773
|
-
case
|
|
3757
|
+
case "EndToEnd":
|
|
3774
3758
|
oe.top = $.bottom - ee.height, de($.bottom - pe);
|
|
3775
3759
|
break;
|
|
3776
|
-
case
|
|
3760
|
+
case "StartToEnd":
|
|
3777
3761
|
default:
|
|
3778
3762
|
oe.top = $.bottom + W, de(he - $.bottom - pe);
|
|
3779
3763
|
break;
|
|
3780
|
-
case
|
|
3764
|
+
case "EndToStart":
|
|
3781
3765
|
oe.top = $.top - ee.height - W, de($.top - pe);
|
|
3782
3766
|
break;
|
|
3783
|
-
case
|
|
3767
|
+
case "MidPoint":
|
|
3784
3768
|
oe.top = $.top + $.height / 2 - ee.height / 2;
|
|
3785
3769
|
break;
|
|
3786
|
-
case
|
|
3770
|
+
case "ScreenEdge":
|
|
3787
3771
|
oe.top = he - ee.height - pe, de(he - 2 * pe);
|
|
3788
3772
|
break;
|
|
3789
3773
|
}
|
|
3790
3774
|
};
|
|
3791
|
-
se(D === "right" ?
|
|
3775
|
+
se(D === "right" ? "EndToEnd" : D === "right-outside" || D === "right-context-menu" ? "StartToEnd" : D === "left-outside" || D === "left-context-menu" ? "EndToStart" : D === "center" ? "MidPoint" : "StartToStart"), D === "right-outside" || D === "left-outside" ? xe("MidPoint") : D === "right-context-menu" || D === "left-context-menu" ? (xe("StartToStart"), oe.top && (oe.top -= 5)) : xe("StartToEnd"), we() && (D === "left" ? se("EndToEnd") : D === "right-outside" && se("EndToStart")), be() && (K ? (xe("MidPoint"), be() && xe("ScreenEdge"), se("StartToEnd"), we() && se("EndToStart")) : xe(D === "left-outside" || D === "right-outside" ? "ScreenEdge" : "EndToStart"));
|
|
3792
3776
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
});
|
|
3777
|
+
for (const [we, be] of Object.entries(oe))
|
|
3778
|
+
f.style.setProperty(we, be ? `${be}px` : null);
|
|
3796
3779
|
}, k = (w) => {
|
|
3797
3780
|
m = w, p && p.disconnect();
|
|
3798
3781
|
const { anchor: T } = w;
|
|
@@ -4131,7 +4114,7 @@ const animationDuration = 260, clickOutside_function = () => {
|
|
|
4131
4114
|
function instance$1S(f, u, p) {
|
|
4132
4115
|
let m, { $$slots: v = {}, $$scope: y } = u;
|
|
4133
4116
|
const k = createEventDispatcher();
|
|
4134
|
-
let { anchor: w } = u, { align: T = "right" } = u, { portalTarget: D } = u, { minWidth: L } = u, { maxWidth: R } = u, { maxHeight: P } = u, { open: N = !1 } = u, { useAnchorWidth: W = !1 } = u, { dismissible: Z = !0 } = u, { offset: Y = 4 } = u, { customHeight: K } = u, { animate: $ = !0 } = u, { customZindex: ee } = u, { handlePostionUpdate: te } = u, { showPopover: he = !0 } = u, { clickOutsideOverride: pe = !1 } = u, { resizable: oe = !0 } = u, { wrap: we = !1 } = u, be, de = !1;
|
|
4117
|
+
let { anchor: w } = u, { align: T = "right" } = u, { portalTarget: D = void 0 } = u, { minWidth: L = void 0 } = u, { maxWidth: R = void 0 } = u, { maxHeight: P = void 0 } = u, { open: N = !1 } = u, { useAnchorWidth: W = !1 } = u, { dismissible: Z = !0 } = u, { offset: Y = 4 } = u, { customHeight: K = void 0 } = u, { animate: $ = !0 } = u, { customZindex: ee = void 0 } = u, { handlePostionUpdate: te = void 0 } = u, { showPopover: he = !0 } = u, { clickOutsideOverride: pe = !1 } = u, { resizable: oe = !0 } = u, { wrap: we = !1 } = u, be, de = !1;
|
|
4135
4118
|
const se = () => {
|
|
4136
4119
|
k("open"), p(0, N = !0);
|
|
4137
4120
|
}, xe = () => {
|
|
@@ -4145,10 +4128,9 @@ function instance$1S(f, u, p) {
|
|
|
4145
4128
|
qe = Be === w, Be = Be.parentNode;
|
|
4146
4129
|
qe && ge.stopPropagation(), xe();
|
|
4147
4130
|
}
|
|
4148
|
-
}
|
|
4149
|
-
function le(ge) {
|
|
4131
|
+
}, le = (ge) => {
|
|
4150
4132
|
pe && N && ge.key === "Escape" && xe();
|
|
4151
|
-
}
|
|
4133
|
+
};
|
|
4152
4134
|
onDestroy(() => {
|
|
4153
4135
|
clearTimeout(be);
|
|
4154
4136
|
});
|
|
@@ -6915,13 +6897,13 @@ function create_fragment$1K(f) {
|
|
|
6915
6897
|
};
|
|
6916
6898
|
}
|
|
6917
6899
|
function instance$1J(f, u, p) {
|
|
6918
|
-
let { value: m =
|
|
6900
|
+
let { value: m = void 0 } = u, { id: v = void 0 } = u, { placeholder: y = "Choose an option or type" } = u, { disabled: k = !1 } = u, { readonly: w = !1 } = u, { options: T = [] } = u, { getOptionLabel: D = (be) => `${be}` } = u, { getOptionValue: L = (be) => `${be}` } = u;
|
|
6919
6901
|
const R = createEventDispatcher();
|
|
6920
6902
|
let P = !1, N = !1, W;
|
|
6921
6903
|
const Z = (be) => {
|
|
6922
6904
|
R("change", be), p(8, P = !1);
|
|
6923
6905
|
}, Y = (be) => {
|
|
6924
|
-
const de = be.
|
|
6906
|
+
const de = be.currentTarget.value;
|
|
6925
6907
|
R("type", de), Z(de);
|
|
6926
6908
|
}, K = (be) => {
|
|
6927
6909
|
R("pick", be), Z(be);
|
|
@@ -32338,15 +32320,15 @@ function create_fragment$1q(f) {
|
|
|
32338
32320
|
};
|
|
32339
32321
|
}
|
|
32340
32322
|
function instance$1p(f, u, p) {
|
|
32341
|
-
let m, { value: v = !1 } = u, { id: y =
|
|
32323
|
+
let m, { value: v = !1 } = u, { id: y = void 0 } = u, { text: k = void 0 } = u, { disabled: w = !1 } = u, { readonly: T = !1 } = u, { size: D = "M" } = u, { indeterminate: L = !1 } = u;
|
|
32342
32324
|
const R = createEventDispatcher(), P = (N) => {
|
|
32343
|
-
R("change", N.
|
|
32325
|
+
R("change", N.currentTarget.checked);
|
|
32344
32326
|
};
|
|
32345
32327
|
return f.$$set = (N) => {
|
|
32346
32328
|
"value" in N && p(0, v = N.value), "id" in N && p(1, y = N.id), "text" in N && p(2, k = N.text), "disabled" in N && p(3, w = N.disabled), "readonly" in N && p(4, T = N.readonly), "size" in N && p(8, D = N.size), "indeterminate" in N && p(5, L = N.indeterminate);
|
|
32347
32329
|
}, f.$$.update = () => {
|
|
32348
32330
|
f.$$.dirty & /*size*/
|
|
32349
|
-
256 && p(6, m = `spectrum-Checkbox--size${D
|
|
32331
|
+
256 && p(6, m = `spectrum-Checkbox--size${D}`);
|
|
32350
32332
|
}, [v, y, k, w, T, L, m, P, D];
|
|
32351
32333
|
}
|
|
32352
32334
|
class Checkbox extends SvelteComponent {
|
|
@@ -48490,7 +48472,7 @@ function create_fragment$16(f) {
|
|
|
48490
48472
|
};
|
|
48491
48473
|
}
|
|
48492
48474
|
function instance$15(f, u, p) {
|
|
48493
|
-
let { direction: m = "vertical" } = u, { value: v = [] } = u, { options: y = [] } = u, { disabled: k = !1 } = u, { readonly: w = !1 } = u, { getOptionLabel: T = (N) => N } = u, { getOptionValue: D = (N) => N } = u;
|
|
48475
|
+
let { direction: m = "vertical" } = u, { value: v = [] } = u, { options: y = [] } = u, { disabled: k = !1 } = u, { readonly: w = !1 } = u, { getOptionLabel: T = (N) => `${N}` } = u, { getOptionValue: D = (N) => N } = u;
|
|
48494
48476
|
const L = createEventDispatcher(), R = (N) => {
|
|
48495
48477
|
v.includes(N) ? L("change", v.filter((W) => W !== N)) : L("change", [...v, N]);
|
|
48496
48478
|
}, P = (N) => R(N);
|
|
@@ -58592,7 +58574,93 @@ class InternalRenderer extends SvelteComponent {
|
|
|
58592
58574
|
super(), init$1(this, u, instance$p, create_fragment$p, safe_not_equal, { value: 1 });
|
|
58593
58575
|
}
|
|
58594
58576
|
}
|
|
58595
|
-
var
|
|
58577
|
+
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
58578
|
+
function getDefaultExportFromCjs(f) {
|
|
58579
|
+
return f && f.__esModule && Object.prototype.hasOwnProperty.call(f, "default") ? f.default : f;
|
|
58580
|
+
}
|
|
58581
|
+
function createCommonjsModule(f) {
|
|
58582
|
+
var u = { exports: {} };
|
|
58583
|
+
return f(u, u.exports), u.exports;
|
|
58584
|
+
}
|
|
58585
|
+
var indexOf$1 = [].indexOf, indexof = function(f, u) {
|
|
58586
|
+
if (indexOf$1)
|
|
58587
|
+
return f.indexOf(u);
|
|
58588
|
+
for (var p = 0; p < f.length; ++p)
|
|
58589
|
+
if (f[p] === u)
|
|
58590
|
+
return p;
|
|
58591
|
+
return -1;
|
|
58592
|
+
}, vmBrowserify = createCommonjsModule(function(module, exports) {
|
|
58593
|
+
var iFrame = null, Object_keys = function(f) {
|
|
58594
|
+
if (Object.keys)
|
|
58595
|
+
return Object.keys(f);
|
|
58596
|
+
var u = [];
|
|
58597
|
+
for (var p in f)
|
|
58598
|
+
u.push(p);
|
|
58599
|
+
return u;
|
|
58600
|
+
}, forEach = function(f, u) {
|
|
58601
|
+
if (f.forEach)
|
|
58602
|
+
return f.forEach(u);
|
|
58603
|
+
for (var p = 0; p < f.length; p++)
|
|
58604
|
+
u(f[p], p, f);
|
|
58605
|
+
}, defineProp = function() {
|
|
58606
|
+
try {
|
|
58607
|
+
return Object.defineProperty({}, "_", {}), function(f, u, p) {
|
|
58608
|
+
Object.defineProperty(f, u, { writable: !0, enumerable: !1, configurable: !0, value: p });
|
|
58609
|
+
};
|
|
58610
|
+
} catch {
|
|
58611
|
+
return function(u, p, m) {
|
|
58612
|
+
u[p] = m;
|
|
58613
|
+
};
|
|
58614
|
+
}
|
|
58615
|
+
}(), globals = ["Array", "Boolean", "Date", "Error", "EvalError", "Function", "Infinity", "JSON", "Math", "NaN", "Number", "Object", "RangeError", "ReferenceError", "RegExp", "String", "SyntaxError", "TypeError", "URIError", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "isFinite", "isNaN", "parseFloat", "parseInt", "undefined", "unescape", "window", "document"];
|
|
58616
|
+
function Context() {
|
|
58617
|
+
}
|
|
58618
|
+
Context.prototype = {};
|
|
58619
|
+
var Script = exports.Script = function(f) {
|
|
58620
|
+
if (!(this instanceof Script))
|
|
58621
|
+
return new Script(f);
|
|
58622
|
+
iFrame || ((iFrame = document.createElement("iframe")).setAttribute("sandbox", "allow-scripts allow-same-origin"), iFrame.style || (iFrame.style = {}), iFrame.style.display = "none", document.body.appendChild(iFrame)), this.code = f, this.iFrame = iFrame;
|
|
58623
|
+
};
|
|
58624
|
+
Script.prototype.runInContext = function(f) {
|
|
58625
|
+
if (!(f instanceof Context))
|
|
58626
|
+
throw new TypeError("needs a 'context' argument.");
|
|
58627
|
+
var u = this.iFrame.contentWindow, p = Object_keys(u);
|
|
58628
|
+
let m = [];
|
|
58629
|
+
var v = u.eval, y = u.execScript;
|
|
58630
|
+
forEach(Object_keys(f), function(T) {
|
|
58631
|
+
if (u[T] !== void 0) {
|
|
58632
|
+
let D = { key: T, value: u[T] };
|
|
58633
|
+
m.push(D);
|
|
58634
|
+
}
|
|
58635
|
+
u[T] = f[T];
|
|
58636
|
+
}), !v && y && (y.call(u, "null"), v = u.eval);
|
|
58637
|
+
var k = Object_keys(u), w = v.call(u, this.code);
|
|
58638
|
+
return forEach(Object_keys(u), function(T) {
|
|
58639
|
+
(T in f || indexof(k, T) === -1) && (indexof(globals, T) === -1 ? f[T] = u[T] : defineProp(f, T, u[T])), indexof(p, T) === -1 && delete u[T];
|
|
58640
|
+
}), forEach(m, function(T) {
|
|
58641
|
+
u[T.key] = T.value;
|
|
58642
|
+
}), w;
|
|
58643
|
+
}, Script.prototype.runInThisContext = function() {
|
|
58644
|
+
return eval(this.code);
|
|
58645
|
+
}, Script.prototype.runInNewContext = function(f) {
|
|
58646
|
+
var u = Script.createContext(f), p = this.runInContext(u);
|
|
58647
|
+
return forEach(Object_keys(u), function(m) {
|
|
58648
|
+
f[m] = u[m];
|
|
58649
|
+
}), p;
|
|
58650
|
+
}, forEach(Object_keys(Script.prototype), function(f) {
|
|
58651
|
+
exports[f] = Script[f] = function(u) {
|
|
58652
|
+
var p = Script(u);
|
|
58653
|
+
return p[f].apply(p, [].slice.call(arguments, 1));
|
|
58654
|
+
};
|
|
58655
|
+
}), exports.createScript = function(f) {
|
|
58656
|
+
return exports.Script(f);
|
|
58657
|
+
}, exports.createContext = Script.createContext = function(f) {
|
|
58658
|
+
var u = new Context();
|
|
58659
|
+
return typeof f == "object" && forEach(Object_keys(f), function(p) {
|
|
58660
|
+
u[p] = f[p];
|
|
58661
|
+
}), u;
|
|
58662
|
+
};
|
|
58663
|
+
}), global$1 = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, _defineProp;
|
|
58596
58664
|
function Object_keys(f) {
|
|
58597
58665
|
if (Object.keys)
|
|
58598
58666
|
return Object.keys(f);
|
|
@@ -58633,6 +58701,9 @@ function otherRunInContext(f, u) {
|
|
|
58633
58701
|
var p = Object_keys(global$1);
|
|
58634
58702
|
return p.push("with (this.__ctx__){return eval(this.__code__)}"), Function.apply(null, p).apply({ __code__: f, __ctx__: u });
|
|
58635
58703
|
}
|
|
58704
|
+
function createScript(f) {
|
|
58705
|
+
return new Script(f);
|
|
58706
|
+
}
|
|
58636
58707
|
function createContext(f) {
|
|
58637
58708
|
if (isContext(f))
|
|
58638
58709
|
return f;
|
|
@@ -58641,6 +58712,12 @@ function createContext(f) {
|
|
|
58641
58712
|
u[p] = f[p];
|
|
58642
58713
|
}), u;
|
|
58643
58714
|
}
|
|
58715
|
+
function runInContext(f, u, p) {
|
|
58716
|
+
return new Script(f).runInContext(u, p);
|
|
58717
|
+
}
|
|
58718
|
+
function runInThisContext(f, u) {
|
|
58719
|
+
return new Script(f).runInThisContext(u);
|
|
58720
|
+
}
|
|
58644
58721
|
function isContext(f) {
|
|
58645
58722
|
return f instanceof Context;
|
|
58646
58723
|
}
|
|
@@ -58675,7 +58752,7 @@ Context.prototype = {}, Script.prototype.runInContext = function(f) {
|
|
|
58675
58752
|
f[m] = u[m];
|
|
58676
58753
|
}), p;
|
|
58677
58754
|
};
|
|
58678
|
-
var _indexOf = [].indexOf;
|
|
58755
|
+
var vm = { runInContext, isContext, createContext, createScript, Script, runInThisContext, runInNewContext }, _indexOf = [].indexOf;
|
|
58679
58756
|
function indexOf(f, u) {
|
|
58680
58757
|
if (_indexOf)
|
|
58681
58758
|
return f.indexOf(u);
|
|
@@ -58684,14 +58761,6 @@ function indexOf(f, u) {
|
|
|
58684
58761
|
return p;
|
|
58685
58762
|
return -1;
|
|
58686
58763
|
}
|
|
58687
|
-
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
58688
|
-
function getDefaultExportFromCjs(f) {
|
|
58689
|
-
return f && f.__esModule && Object.prototype.hasOwnProperty.call(f, "default") ? f.default : f;
|
|
58690
|
-
}
|
|
58691
|
-
function createCommonjsModule(f) {
|
|
58692
|
-
var u = { exports: {} };
|
|
58693
|
-
return f(u, u.exports), u.exports;
|
|
58694
|
-
}
|
|
58695
58764
|
var utils$3 = createCommonjsModule(function(f, u) {
|
|
58696
58765
|
u.__esModule = !0, u.extend = k, u.indexOf = function(L, R) {
|
|
58697
58766
|
for (var P = 0, N = L.length; P < N; P++)
|
|
@@ -69527,12 +69596,13 @@ function findHBSBlocks(f) {
|
|
|
69527
69596
|
return p ?? [];
|
|
69528
69597
|
}
|
|
69529
69598
|
function browserJSSetup() {
|
|
69530
|
-
|
|
69531
|
-
|
|
69532
|
-
|
|
69533
|
-
|
|
69534
|
-
|
|
69535
|
-
|
|
69599
|
+
const f = isTest() ? vm : vmBrowserify;
|
|
69600
|
+
setJSRunner((u, p) => {
|
|
69601
|
+
f.createContext(p);
|
|
69602
|
+
const m = frontendWrapJS(u), v = f.runInNewContext(m, p);
|
|
69603
|
+
if (v.error)
|
|
69604
|
+
throw new UserScriptError(v.error);
|
|
69605
|
+
return v.result;
|
|
69536
69606
|
});
|
|
69537
69607
|
}
|
|
69538
69608
|
function defaultJSSetup() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/bbui",
|
|
3
3
|
"description": "A UI solution used in the different Budibase projects.",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.2",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"svelte": "src/index.ts",
|
|
7
7
|
"module": "dist/bbui.mjs",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "5ffd630cc8ca4b533986ee1d830404a496365385"
|
|
103
103
|
}
|
|
@@ -8,27 +8,52 @@
|
|
|
8
8
|
|
|
9
9
|
// Strategies are defined as [Popover]To[Anchor].
|
|
10
10
|
// They can apply for both horizontal and vertical alignment.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
type Strategy =
|
|
12
|
+
| "StartToStart"
|
|
13
|
+
| "EndToEnd"
|
|
14
|
+
| "StartToEnd"
|
|
15
|
+
| "EndToStart"
|
|
16
|
+
| "MidPoint"
|
|
17
|
+
| "ScreenEdge"
|
|
18
|
+
|
|
19
|
+
export interface Styles {
|
|
20
|
+
maxHeight?: number
|
|
21
|
+
minWidth?: number
|
|
22
|
+
maxWidth?: number
|
|
23
|
+
offset?: number
|
|
24
|
+
left: number
|
|
25
|
+
top: number
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
export
|
|
21
|
-
|
|
28
|
+
export type UpdateHandler = (
|
|
29
|
+
anchorBounds: DOMRect,
|
|
30
|
+
elementBounds: DOMRect,
|
|
31
|
+
styles: Styles
|
|
32
|
+
) => Styles
|
|
33
|
+
|
|
34
|
+
interface Opts {
|
|
35
|
+
anchor?: HTMLElement
|
|
36
|
+
align: string
|
|
37
|
+
maxHeight?: number
|
|
38
|
+
maxWidth?: number
|
|
39
|
+
minWidth?: number
|
|
40
|
+
useAnchorWidth: boolean
|
|
41
|
+
offset: number
|
|
42
|
+
customUpdate?: UpdateHandler
|
|
43
|
+
resizable: boolean
|
|
44
|
+
wrap: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default function positionDropdown(element: HTMLElement, opts: Opts) {
|
|
48
|
+
let resizeObserver: ResizeObserver
|
|
22
49
|
let latestOpts = opts
|
|
23
50
|
|
|
24
51
|
// We need a static reference to this function so that we can properly
|
|
25
52
|
// clean up the scroll listener.
|
|
26
|
-
const scrollUpdate = () =>
|
|
27
|
-
updatePosition(latestOpts)
|
|
28
|
-
}
|
|
53
|
+
const scrollUpdate = () => updatePosition(latestOpts)
|
|
29
54
|
|
|
30
55
|
// Updates the position of the dropdown
|
|
31
|
-
const updatePosition = opts => {
|
|
56
|
+
const updatePosition = (opts: Opts) => {
|
|
32
57
|
const {
|
|
33
58
|
anchor,
|
|
34
59
|
align,
|
|
@@ -51,12 +76,12 @@ export default function positionDropdown(element, opts) {
|
|
|
51
76
|
const winWidth = window.innerWidth
|
|
52
77
|
const winHeight = window.innerHeight
|
|
53
78
|
const screenOffset = 8
|
|
54
|
-
let styles = {
|
|
79
|
+
let styles: Styles = {
|
|
55
80
|
maxHeight,
|
|
56
81
|
minWidth: useAnchorWidth ? anchorBounds.width : minWidth,
|
|
57
82
|
maxWidth: useAnchorWidth ? anchorBounds.width : maxWidth,
|
|
58
|
-
left:
|
|
59
|
-
top:
|
|
83
|
+
left: 0,
|
|
84
|
+
top: 0,
|
|
60
85
|
}
|
|
61
86
|
|
|
62
87
|
// Ignore all our logic for custom logic
|
|
@@ -81,67 +106,67 @@ export default function positionDropdown(element, opts) {
|
|
|
81
106
|
}
|
|
82
107
|
|
|
83
108
|
// Applies a dynamic max height constraint if appropriate
|
|
84
|
-
const applyMaxHeight = height => {
|
|
109
|
+
const applyMaxHeight = (height: number) => {
|
|
85
110
|
if (!styles.maxHeight && resizable) {
|
|
86
111
|
styles.maxHeight = height
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
// Applies the X strategy to our styles
|
|
91
|
-
const applyXStrategy = strategy => {
|
|
116
|
+
const applyXStrategy = (strategy: Strategy) => {
|
|
92
117
|
switch (strategy) {
|
|
93
|
-
case
|
|
118
|
+
case "StartToStart":
|
|
94
119
|
default:
|
|
95
120
|
styles.left = anchorBounds.left
|
|
96
121
|
break
|
|
97
|
-
case
|
|
122
|
+
case "EndToEnd":
|
|
98
123
|
styles.left = anchorBounds.right - elementBounds.width
|
|
99
124
|
break
|
|
100
|
-
case
|
|
125
|
+
case "StartToEnd":
|
|
101
126
|
styles.left = anchorBounds.right + offset
|
|
102
127
|
break
|
|
103
|
-
case
|
|
128
|
+
case "EndToStart":
|
|
104
129
|
styles.left = anchorBounds.left - elementBounds.width - offset
|
|
105
130
|
break
|
|
106
|
-
case
|
|
131
|
+
case "MidPoint":
|
|
107
132
|
styles.left =
|
|
108
133
|
anchorBounds.left +
|
|
109
134
|
anchorBounds.width / 2 -
|
|
110
135
|
elementBounds.width / 2
|
|
111
136
|
break
|
|
112
|
-
case
|
|
137
|
+
case "ScreenEdge":
|
|
113
138
|
styles.left = winWidth - elementBounds.width - screenOffset
|
|
114
139
|
break
|
|
115
140
|
}
|
|
116
141
|
}
|
|
117
142
|
|
|
118
143
|
// Applies the Y strategy to our styles
|
|
119
|
-
const applyYStrategy = strategy => {
|
|
144
|
+
const applyYStrategy = (strategy: Strategy) => {
|
|
120
145
|
switch (strategy) {
|
|
121
|
-
case
|
|
146
|
+
case "StartToStart":
|
|
122
147
|
styles.top = anchorBounds.top
|
|
123
148
|
applyMaxHeight(winHeight - anchorBounds.top - screenOffset)
|
|
124
149
|
break
|
|
125
|
-
case
|
|
150
|
+
case "EndToEnd":
|
|
126
151
|
styles.top = anchorBounds.bottom - elementBounds.height
|
|
127
152
|
applyMaxHeight(anchorBounds.bottom - screenOffset)
|
|
128
153
|
break
|
|
129
|
-
case
|
|
154
|
+
case "StartToEnd":
|
|
130
155
|
default:
|
|
131
156
|
styles.top = anchorBounds.bottom + offset
|
|
132
157
|
applyMaxHeight(winHeight - anchorBounds.bottom - screenOffset)
|
|
133
158
|
break
|
|
134
|
-
case
|
|
159
|
+
case "EndToStart":
|
|
135
160
|
styles.top = anchorBounds.top - elementBounds.height - offset
|
|
136
161
|
applyMaxHeight(anchorBounds.top - screenOffset)
|
|
137
162
|
break
|
|
138
|
-
case
|
|
163
|
+
case "MidPoint":
|
|
139
164
|
styles.top =
|
|
140
165
|
anchorBounds.top +
|
|
141
166
|
anchorBounds.height / 2 -
|
|
142
167
|
elementBounds.height / 2
|
|
143
168
|
break
|
|
144
|
-
case
|
|
169
|
+
case "ScreenEdge":
|
|
145
170
|
styles.top = winHeight - elementBounds.height - screenOffset
|
|
146
171
|
applyMaxHeight(winHeight - 2 * screenOffset)
|
|
147
172
|
break
|
|
@@ -150,81 +175,78 @@ export default function positionDropdown(element, opts) {
|
|
|
150
175
|
|
|
151
176
|
// Determine X strategy
|
|
152
177
|
if (align === "right") {
|
|
153
|
-
applyXStrategy(
|
|
178
|
+
applyXStrategy("EndToEnd")
|
|
154
179
|
} else if (align === "right-outside" || align === "right-context-menu") {
|
|
155
|
-
applyXStrategy(
|
|
180
|
+
applyXStrategy("StartToEnd")
|
|
156
181
|
} else if (align === "left-outside" || align === "left-context-menu") {
|
|
157
|
-
applyXStrategy(
|
|
182
|
+
applyXStrategy("EndToStart")
|
|
158
183
|
} else if (align === "center") {
|
|
159
|
-
applyXStrategy(
|
|
184
|
+
applyXStrategy("MidPoint")
|
|
160
185
|
} else {
|
|
161
|
-
applyXStrategy(
|
|
186
|
+
applyXStrategy("StartToStart")
|
|
162
187
|
}
|
|
163
188
|
|
|
164
189
|
// Determine Y strategy
|
|
165
190
|
if (align === "right-outside" || align === "left-outside") {
|
|
166
|
-
applyYStrategy(
|
|
191
|
+
applyYStrategy("MidPoint")
|
|
167
192
|
} else if (
|
|
168
193
|
align === "right-context-menu" ||
|
|
169
194
|
align === "left-context-menu"
|
|
170
195
|
) {
|
|
171
|
-
applyYStrategy(
|
|
172
|
-
styles.top
|
|
196
|
+
applyYStrategy("StartToStart")
|
|
197
|
+
if (styles.top) {
|
|
198
|
+
styles.top -= 5 // Manual adjustment for action menu padding
|
|
199
|
+
}
|
|
173
200
|
} else {
|
|
174
|
-
applyYStrategy(
|
|
201
|
+
applyYStrategy("StartToEnd")
|
|
175
202
|
}
|
|
176
203
|
|
|
177
204
|
// Handle screen overflow
|
|
178
205
|
if (doesXOverflow()) {
|
|
179
206
|
// Swap left to right
|
|
180
207
|
if (align === "left") {
|
|
181
|
-
applyXStrategy(
|
|
208
|
+
applyXStrategy("EndToEnd")
|
|
182
209
|
}
|
|
183
210
|
// Swap right-outside to left-outside
|
|
184
211
|
else if (align === "right-outside") {
|
|
185
|
-
applyXStrategy(
|
|
212
|
+
applyXStrategy("EndToStart")
|
|
186
213
|
}
|
|
187
214
|
}
|
|
188
215
|
if (doesYOverflow()) {
|
|
189
216
|
// If wrapping, lock to the bottom of the screen and also reposition to
|
|
190
217
|
// the side to not block the anchor
|
|
191
218
|
if (wrap) {
|
|
192
|
-
applyYStrategy(
|
|
219
|
+
applyYStrategy("MidPoint")
|
|
193
220
|
if (doesYOverflow()) {
|
|
194
|
-
applyYStrategy(
|
|
221
|
+
applyYStrategy("ScreenEdge")
|
|
195
222
|
}
|
|
196
|
-
applyXStrategy(
|
|
223
|
+
applyXStrategy("StartToEnd")
|
|
197
224
|
if (doesXOverflow()) {
|
|
198
|
-
applyXStrategy(
|
|
225
|
+
applyXStrategy("EndToStart")
|
|
199
226
|
}
|
|
200
227
|
}
|
|
201
228
|
// Othewise invert as normal
|
|
202
229
|
else {
|
|
203
230
|
// If using an outside strategy then lock to the bottom of the screen
|
|
204
231
|
if (align === "left-outside" || align === "right-outside") {
|
|
205
|
-
applyYStrategy(
|
|
232
|
+
applyYStrategy("ScreenEdge")
|
|
206
233
|
}
|
|
207
234
|
// Otherwise flip above
|
|
208
235
|
else {
|
|
209
|
-
applyYStrategy(
|
|
236
|
+
applyYStrategy("EndToStart")
|
|
210
237
|
}
|
|
211
238
|
}
|
|
212
239
|
}
|
|
213
240
|
}
|
|
214
241
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
element.style[style] = `${value.toFixed(0)}px`
|
|
219
|
-
} else {
|
|
220
|
-
element.style[style] = null
|
|
221
|
-
}
|
|
222
|
-
})
|
|
242
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
243
|
+
element.style.setProperty(key, value ? `${value}px` : null)
|
|
244
|
+
}
|
|
223
245
|
}
|
|
224
246
|
|
|
225
247
|
// The actual svelte action callback which creates observers on the relevant
|
|
226
248
|
// DOM elements
|
|
227
|
-
const update = newOpts => {
|
|
249
|
+
const update = (newOpts: Opts) => {
|
|
228
250
|
latestOpts = newOpts
|
|
229
251
|
|
|
230
252
|
// Cleanup old state
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/checkbox/dist/index-vars.css"
|
|
3
3
|
import "@spectrum-css/fieldgroup/dist/index-vars.css"
|
|
4
4
|
import { createEventDispatcher } from "svelte"
|
|
5
|
+
import type { ChangeEventHandler } from "svelte/elements"
|
|
5
6
|
|
|
6
7
|
export let value = false
|
|
7
|
-
export let id =
|
|
8
|
-
export let text =
|
|
8
|
+
export let id: string | undefined = undefined
|
|
9
|
+
export let text: string | undefined = undefined
|
|
9
10
|
export let disabled = false
|
|
10
11
|
export let readonly = false
|
|
11
|
-
export let size
|
|
12
|
+
export let size: "S" | "M" | "L" | "XL" = "M"
|
|
12
13
|
export let indeterminate = false
|
|
13
14
|
|
|
14
15
|
const dispatch = createEventDispatcher()
|
|
15
|
-
const onChange = event => {
|
|
16
|
-
dispatch("change", event.
|
|
16
|
+
const onChange: ChangeEventHandler<HTMLInputElement> = event => {
|
|
17
|
+
dispatch("change", event.currentTarget.checked)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
$: sizeClass = `spectrum-Checkbox--size${size
|
|
20
|
+
$: sizeClass = `spectrum-Checkbox--size${size}`
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<label
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
type O = any
|
|
3
|
+
type V = any
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script lang="ts" generics="O, V">
|
|
2
7
|
import "@spectrum-css/fieldgroup/dist/index-vars.css"
|
|
3
8
|
import "@spectrum-css/radio/dist/index-vars.css"
|
|
4
9
|
import { createEventDispatcher } from "svelte"
|
|
5
10
|
|
|
6
|
-
export let direction = "vertical"
|
|
7
|
-
export let value = []
|
|
8
|
-
export let options = []
|
|
11
|
+
export let direction: "horizontal" | "vertical" = "vertical"
|
|
12
|
+
export let value: V[] = []
|
|
13
|
+
export let options: O[] = []
|
|
9
14
|
export let disabled = false
|
|
10
15
|
export let readonly = false
|
|
11
|
-
export let getOptionLabel = option => option
|
|
12
|
-
export let getOptionValue = option => option
|
|
16
|
+
export let getOptionLabel = (option: O) => `${option}`
|
|
17
|
+
export let getOptionValue = (option: O) => option as unknown as V
|
|
13
18
|
|
|
14
|
-
const dispatch = createEventDispatcher()
|
|
19
|
+
const dispatch = createEventDispatcher<{ change: V[] }>()
|
|
15
20
|
|
|
16
|
-
const onChange = optionValue => {
|
|
21
|
+
const onChange = (optionValue: V) => {
|
|
17
22
|
if (!value.includes(optionValue)) {
|
|
18
23
|
dispatch("change", [...value, optionValue])
|
|
19
24
|
} else {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
type O = any
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="O">
|
|
6
|
+
import type { ChangeEventHandler } from "svelte/elements"
|
|
7
|
+
|
|
2
8
|
import "@spectrum-css/inputgroup/dist/index-vars.css"
|
|
3
9
|
import "@spectrum-css/popover/dist/index-vars.css"
|
|
4
10
|
import "@spectrum-css/menu/dist/index-vars.css"
|
|
@@ -6,33 +12,38 @@
|
|
|
6
12
|
import clickOutside from "../../Actions/click_outside"
|
|
7
13
|
import Popover from "../../Popover/Popover.svelte"
|
|
8
14
|
|
|
9
|
-
export let value =
|
|
10
|
-
export let id =
|
|
15
|
+
export let value: string | undefined = undefined
|
|
16
|
+
export let id: string | undefined = undefined
|
|
11
17
|
export let placeholder = "Choose an option or type"
|
|
12
18
|
export let disabled = false
|
|
13
19
|
export let readonly = false
|
|
14
|
-
export let options = []
|
|
15
|
-
export let getOptionLabel = option => option
|
|
16
|
-
export let getOptionValue = option => option
|
|
20
|
+
export let options: O[] = []
|
|
21
|
+
export let getOptionLabel = (option: O) => `${option}`
|
|
22
|
+
export let getOptionValue = (option: O) => `${option}`
|
|
17
23
|
|
|
18
|
-
const dispatch = createEventDispatcher
|
|
24
|
+
const dispatch = createEventDispatcher<{
|
|
25
|
+
change: string
|
|
26
|
+
blur: void
|
|
27
|
+
type: string
|
|
28
|
+
pick: string
|
|
29
|
+
}>()
|
|
19
30
|
|
|
20
31
|
let open = false
|
|
21
32
|
let focus = false
|
|
22
33
|
let anchor
|
|
23
34
|
|
|
24
|
-
const selectOption = value => {
|
|
35
|
+
const selectOption = (value: string) => {
|
|
25
36
|
dispatch("change", value)
|
|
26
37
|
open = false
|
|
27
38
|
}
|
|
28
39
|
|
|
29
|
-
const onType = e => {
|
|
30
|
-
const value = e.
|
|
40
|
+
const onType: ChangeEventHandler<HTMLInputElement> = e => {
|
|
41
|
+
const value = e.currentTarget.value
|
|
31
42
|
dispatch("type", value)
|
|
32
43
|
selectOption(value)
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
const onPick = value => {
|
|
46
|
+
const onPick = (value: string) => {
|
|
36
47
|
dispatch("pick", value)
|
|
37
48
|
selectOption(value)
|
|
38
49
|
}
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/popover/dist/index-vars.css"
|
|
3
|
+
// @ts-expect-error no types for the version of svelte-portal we're on.
|
|
3
4
|
import Portal from "svelte-portal"
|
|
4
5
|
import { createEventDispatcher, getContext, onDestroy } from "svelte"
|
|
5
|
-
import positionDropdown
|
|
6
|
+
import positionDropdown, {
|
|
7
|
+
type UpdateHandler,
|
|
8
|
+
} from "../Actions/position_dropdown"
|
|
6
9
|
import clickOutside from "../Actions/click_outside"
|
|
7
10
|
import { fly } from "svelte/transition"
|
|
8
11
|
import Context from "../context"
|
|
12
|
+
import type { KeyboardEventHandler } from "svelte/elements"
|
|
9
13
|
|
|
10
|
-
const dispatch = createEventDispatcher()
|
|
14
|
+
const dispatch = createEventDispatcher<{ open: void; close: void }>()
|
|
11
15
|
|
|
12
|
-
export let anchor
|
|
13
|
-
export let align
|
|
14
|
-
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
16
|
+
export let anchor: HTMLElement
|
|
17
|
+
export let align: "left" | "right" | "left-outside" | "right-outside" =
|
|
18
|
+
"right"
|
|
19
|
+
export let portalTarget: string | undefined = undefined
|
|
20
|
+
export let minWidth: number | undefined = undefined
|
|
21
|
+
export let maxWidth: number | undefined = undefined
|
|
22
|
+
export let maxHeight: number | undefined = undefined
|
|
18
23
|
export let open = false
|
|
19
24
|
export let useAnchorWidth = false
|
|
20
25
|
export let dismissible = true
|
|
21
26
|
export let offset = 4
|
|
22
|
-
export let customHeight
|
|
27
|
+
export let customHeight: string | undefined = undefined
|
|
23
28
|
export let animate = true
|
|
24
|
-
export let customZindex
|
|
25
|
-
export let handlePostionUpdate
|
|
29
|
+
export let customZindex: string | undefined = undefined
|
|
30
|
+
export let handlePostionUpdate: UpdateHandler | undefined = undefined
|
|
26
31
|
export let showPopover = true
|
|
27
32
|
export let clickOutsideOverride = false
|
|
28
33
|
export let resizable = true
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
|
|
31
36
|
const animationDuration = 260
|
|
32
37
|
|
|
33
|
-
let timeout
|
|
38
|
+
let timeout: ReturnType<typeof setTimeout>
|
|
34
39
|
let blockPointerEvents = false
|
|
35
40
|
|
|
36
41
|
$: target = portalTarget || getContext(Context.PopoverRoot) || ".spectrum"
|
|
@@ -65,13 +70,13 @@
|
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
const handleOutsideClick = e => {
|
|
73
|
+
const handleOutsideClick = (e: MouseEvent) => {
|
|
69
74
|
if (clickOutsideOverride) {
|
|
70
75
|
return
|
|
71
76
|
}
|
|
72
77
|
if (open) {
|
|
73
78
|
// Stop propagation if the source is the anchor
|
|
74
|
-
let node = e.target
|
|
79
|
+
let node = e.target as Node | null
|
|
75
80
|
let fromAnchor = false
|
|
76
81
|
while (!fromAnchor && node && node.parentNode) {
|
|
77
82
|
fromAnchor = node === anchor
|
|
@@ -86,7 +91,7 @@
|
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
const handleEscape: KeyboardEventHandler<HTMLDivElement> = e => {
|
|
90
95
|
if (!clickOutsideOverride) {
|
|
91
96
|
return
|
|
92
97
|
}
|