@stackoverflow/stacks 1.6.2 → 1.6.4
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/README.md +22 -0
- package/dist/controllers/index.d.ts +7 -7
- package/dist/controllers/s-expandable-control.d.ts +1 -1
- package/dist/css/stacks.css +17 -28
- package/dist/css/stacks.min.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/js/stacks.js +174 -112
- package/dist/js/stacks.min.js +1 -1
- package/dist/stacks.d.ts +1 -1
- package/lib/css/atomic/gap.less +1 -1
- package/lib/css/components/buttons.less +3 -1
- package/lib/css/components/cards.less +1 -1
- package/lib/css/components/expandable.less +1 -1
- package/lib/css/components/inputs.less +4 -18
- package/lib/css/components/labels.less +6 -1
- package/lib/css/components/pagination.less +1 -1
- package/lib/css/components/popovers.less +6 -7
- package/lib/ts/controllers/index.ts +14 -7
- package/lib/ts/controllers/s-expandable-control.ts +79 -34
- package/lib/ts/controllers/s-modal.ts +116 -58
- package/lib/ts/controllers/s-navigation-tablist.ts +30 -20
- package/lib/ts/controllers/s-popover.ts +149 -73
- package/lib/ts/controllers/s-table.ts +69 -28
- package/lib/ts/controllers/s-tooltip.ts +87 -29
- package/lib/ts/controllers/s-uploader.ts +58 -39
- package/lib/ts/index.ts +11 -3
- package/lib/ts/stacks.ts +40 -19
- package/lib/tsconfig.json +1 -1
- package/package.json +8 -6
package/dist/js/stacks.js
CHANGED
|
@@ -4485,10 +4485,13 @@ var Stacks = __webpack_require__(36);
|
|
|
4485
4485
|
var RADIO_OFF_EVENT = "s-expandable-control:radio-off";
|
|
4486
4486
|
function globalChangeListener(e) {
|
|
4487
4487
|
var target = e.target;
|
|
4488
|
-
if (!(target instanceof HTMLInputElement) ||
|
|
4488
|
+
if (!(target instanceof HTMLInputElement) ||
|
|
4489
|
+
target.nodeName !== "INPUT" ||
|
|
4490
|
+
target.type !== "radio") {
|
|
4489
4491
|
return;
|
|
4490
4492
|
}
|
|
4491
|
-
document
|
|
4493
|
+
document
|
|
4494
|
+
.querySelectorAll('input[type="radio"][name="' + target.name + '"]')
|
|
4492
4495
|
.forEach(function (other) {
|
|
4493
4496
|
if (other === e.target) {
|
|
4494
4497
|
return;
|
|
@@ -4528,7 +4531,8 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4528
4531
|
return _this;
|
|
4529
4532
|
}
|
|
4530
4533
|
ExpandableController.prototype.initialize = function () {
|
|
4531
|
-
if (this.element.nodeName === "INPUT" &&
|
|
4534
|
+
if (this.element.nodeName === "INPUT" &&
|
|
4535
|
+
["radio", "checkbox"].indexOf(this.element.type) >= 0) {
|
|
4532
4536
|
this.isCollapsed = this._isCollapsedForCheckable.bind(this);
|
|
4533
4537
|
this.events = ["change", RADIO_OFF_EVENT];
|
|
4534
4538
|
this.isCheckable = true;
|
|
@@ -4540,27 +4544,27 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4540
4544
|
}
|
|
4541
4545
|
this.listener = this.listener.bind(this);
|
|
4542
4546
|
};
|
|
4543
|
-
;
|
|
4544
4547
|
// for non-checkable elements, the initial source of truth is the collapsed/expanded
|
|
4545
4548
|
// state of the controlled element (unless the element doesn't exist)
|
|
4546
4549
|
ExpandableController.prototype._isCollapsedForClickable = function () {
|
|
4547
4550
|
var cc = this.controlledExpandables;
|
|
4548
4551
|
// the element is considered collapsed if *any* target element is collapsed
|
|
4549
|
-
return cc.length > 0
|
|
4552
|
+
return cc.length > 0
|
|
4553
|
+
? !cc.every(function (element) { return element.classList.contains("is-expanded"); })
|
|
4554
|
+
: this.element.getAttribute("aria-expanded") === "false";
|
|
4550
4555
|
};
|
|
4551
|
-
;
|
|
4552
4556
|
// for checkable elements, the initial source of truth is the checked state
|
|
4553
4557
|
ExpandableController.prototype._isCollapsedForCheckable = function () {
|
|
4554
4558
|
return !this.element.checked;
|
|
4555
4559
|
};
|
|
4556
|
-
;
|
|
4557
4560
|
Object.defineProperty(ExpandableController.prototype, "controlledExpandables", {
|
|
4558
4561
|
get: function () {
|
|
4559
4562
|
var attr = this.element.getAttribute("aria-controls");
|
|
4560
4563
|
if (!attr) {
|
|
4561
4564
|
throw "[aria-controls=\"targetId1 ... targetIdN\"] attribute required";
|
|
4562
4565
|
}
|
|
4563
|
-
var result = attr
|
|
4566
|
+
var result = attr
|
|
4567
|
+
.split(/\s+/g)
|
|
4564
4568
|
.map(function (s) { return document.getElementById(s); })
|
|
4565
4569
|
.filter(function (e) { return !!e; });
|
|
4566
4570
|
if (!result.length) {
|
|
@@ -4571,11 +4575,9 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4571
4575
|
enumerable: false,
|
|
4572
4576
|
configurable: true
|
|
4573
4577
|
});
|
|
4574
|
-
;
|
|
4575
4578
|
ExpandableController.prototype._dispatchShowHideEvent = function (isShow) {
|
|
4576
4579
|
this.triggerEvent(isShow ? "show" : "hide");
|
|
4577
4580
|
};
|
|
4578
|
-
;
|
|
4579
4581
|
ExpandableController.prototype._toggleClass = function (doAdd) {
|
|
4580
4582
|
if (!this.data.has("toggle-class")) {
|
|
4581
4583
|
return;
|
|
@@ -4589,17 +4591,20 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4589
4591
|
cl.toggle(cls, !!doAdd);
|
|
4590
4592
|
});
|
|
4591
4593
|
};
|
|
4592
|
-
;
|
|
4593
4594
|
ExpandableController.prototype.listener = function (e) {
|
|
4594
4595
|
var newCollapsed;
|
|
4595
4596
|
if (this.isCheckable) {
|
|
4596
4597
|
newCollapsed = !this.element.checked;
|
|
4597
4598
|
}
|
|
4598
4599
|
else {
|
|
4599
|
-
if (e.type == "keydown" &&
|
|
4600
|
+
if (e.type == "keydown" &&
|
|
4601
|
+
e instanceof KeyboardEvent &&
|
|
4602
|
+
e.keyCode != 13 &&
|
|
4603
|
+
e.keyCode != 32) {
|
|
4600
4604
|
return;
|
|
4601
4605
|
}
|
|
4602
|
-
if (e.target !== e.currentTarget &&
|
|
4606
|
+
if (e.target !== e.currentTarget &&
|
|
4607
|
+
["A", "BUTTON"].indexOf(e.target.nodeName) >= 0) {
|
|
4603
4608
|
return;
|
|
4604
4609
|
}
|
|
4605
4610
|
e.preventDefault();
|
|
@@ -4609,10 +4614,12 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4609
4614
|
if (e.type == "keydown") {
|
|
4610
4615
|
this.lastKeydownClickTimestamp = Date.now();
|
|
4611
4616
|
}
|
|
4612
|
-
else if (e.type == "click" &&
|
|
4617
|
+
else if (e.type == "click" &&
|
|
4618
|
+
Date.now() - this.lastKeydownClickTimestamp < 300) {
|
|
4613
4619
|
return;
|
|
4614
4620
|
}
|
|
4615
|
-
newCollapsed =
|
|
4621
|
+
newCollapsed =
|
|
4622
|
+
this.element.getAttribute("aria-expanded") === "true";
|
|
4616
4623
|
if (e.type === "click") {
|
|
4617
4624
|
this.element.blur();
|
|
4618
4625
|
}
|
|
@@ -4625,7 +4632,6 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4625
4632
|
this._dispatchShowHideEvent(!newCollapsed);
|
|
4626
4633
|
this._toggleClass(!newCollapsed);
|
|
4627
4634
|
};
|
|
4628
|
-
;
|
|
4629
4635
|
ExpandableController.prototype.connect = function () {
|
|
4630
4636
|
var _this = this;
|
|
4631
4637
|
this.events.forEach(function (e) {
|
|
@@ -4646,8 +4652,12 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4646
4652
|
if (cc.length) {
|
|
4647
4653
|
var expected_1 = !this.isCollapsed();
|
|
4648
4654
|
// if any element does not match the expected state, set them all to the expected state
|
|
4649
|
-
if (cc.some(function (element) {
|
|
4650
|
-
|
|
4655
|
+
if (cc.some(function (element) {
|
|
4656
|
+
return element.classList.contains("is-expanded") !==
|
|
4657
|
+
expected_1;
|
|
4658
|
+
})) {
|
|
4659
|
+
for (var _i = 0, _a = this
|
|
4660
|
+
.controlledExpandables; _i < _a.length; _i++) {
|
|
4651
4661
|
var controlledElement = _a[_i];
|
|
4652
4662
|
controlledElement.classList.toggle("is-expanded", expected_1);
|
|
4653
4663
|
}
|
|
@@ -4657,7 +4667,6 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4657
4667
|
}
|
|
4658
4668
|
}
|
|
4659
4669
|
};
|
|
4660
|
-
;
|
|
4661
4670
|
ExpandableController.prototype.disconnect = function () {
|
|
4662
4671
|
var _this = this;
|
|
4663
4672
|
this.events.forEach(function (e) {
|
|
@@ -4667,7 +4676,6 @@ var ExpandableController = /** @class */ (function (_super) {
|
|
|
4667
4676
|
globalChangeListenerRequired(false);
|
|
4668
4677
|
}
|
|
4669
4678
|
};
|
|
4670
|
-
;
|
|
4671
4679
|
return ExpandableController;
|
|
4672
4680
|
}(Stacks.StacksController));
|
|
4673
4681
|
exports.ExpandableController = ExpandableController;
|
|
@@ -4720,7 +4728,6 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4720
4728
|
ModalController.prototype.disconnect = function () {
|
|
4721
4729
|
this.unbindDocumentEvents();
|
|
4722
4730
|
};
|
|
4723
|
-
;
|
|
4724
4731
|
/**
|
|
4725
4732
|
* Toggles the visibility of the modal
|
|
4726
4733
|
*/
|
|
@@ -4749,9 +4756,10 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4749
4756
|
// check for returnElement support
|
|
4750
4757
|
var returnElementSelector = this.data.get("return-element");
|
|
4751
4758
|
if (returnElementSelector) {
|
|
4752
|
-
this.returnElement = document.querySelector(returnElementSelector);
|
|
4759
|
+
this.returnElement = (document.querySelector(returnElementSelector));
|
|
4753
4760
|
if (!this.returnElement) {
|
|
4754
|
-
throw "Unable to find element by return-element selector: " +
|
|
4761
|
+
throw ("Unable to find element by return-element selector: " +
|
|
4762
|
+
returnElementSelector);
|
|
4755
4763
|
}
|
|
4756
4764
|
}
|
|
4757
4765
|
};
|
|
@@ -4776,7 +4784,7 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4776
4784
|
// show/hide events trigger before toggling the class
|
|
4777
4785
|
var triggeredEvent = this.triggerEvent(toShow ? "show" : "hide", {
|
|
4778
4786
|
returnElement: this.returnElement,
|
|
4779
|
-
dispatcher: this.getDispatcher(dispatchingElement)
|
|
4787
|
+
dispatcher: this.getDispatcher(dispatchingElement),
|
|
4780
4788
|
}, this.modalTarget);
|
|
4781
4789
|
// if this pre-show/hide event was prevented, don't attempt to continue changing the modal state
|
|
4782
4790
|
if (triggeredEvent.defaultPrevented) {
|
|
@@ -4794,20 +4802,20 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4794
4802
|
this.removeModalOnHide();
|
|
4795
4803
|
}
|
|
4796
4804
|
// check for transitionend support
|
|
4797
|
-
var supportsTransitionEnd =
|
|
4805
|
+
var supportsTransitionEnd = this.modalTarget.ontransitionend !== undefined;
|
|
4798
4806
|
// shown/hidden events trigger after toggling the class
|
|
4799
4807
|
if (supportsTransitionEnd) {
|
|
4800
4808
|
// wait until after the modal finishes transitioning to fire the event
|
|
4801
4809
|
this.modalTarget.addEventListener("transitionend", function () {
|
|
4802
4810
|
//TODO this is firing waaay to soon?
|
|
4803
4811
|
_this.triggerEvent(toShow ? "shown" : "hidden", {
|
|
4804
|
-
dispatcher: dispatchingElement
|
|
4812
|
+
dispatcher: dispatchingElement,
|
|
4805
4813
|
}, _this.modalTarget);
|
|
4806
4814
|
}, { once: true });
|
|
4807
4815
|
}
|
|
4808
4816
|
else {
|
|
4809
4817
|
this.triggerEvent(toShow ? "shown" : "hidden", {
|
|
4810
|
-
dispatcher: dispatchingElement
|
|
4818
|
+
dispatcher: dispatchingElement,
|
|
4811
4819
|
}, this.modalTarget);
|
|
4812
4820
|
}
|
|
4813
4821
|
};
|
|
@@ -4821,7 +4829,8 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4821
4829
|
}
|
|
4822
4830
|
this.modalTarget.addEventListener("s-modal:hidden", function () {
|
|
4823
4831
|
// double check the element still exists when the event is called
|
|
4824
|
-
if (_this.returnElement &&
|
|
4832
|
+
if (_this.returnElement &&
|
|
4833
|
+
document.body.contains(_this.returnElement)) {
|
|
4825
4834
|
_this.returnElement.focus();
|
|
4826
4835
|
}
|
|
4827
4836
|
}, { once: true });
|
|
@@ -4842,8 +4851,9 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4842
4851
|
* Gets all elements within the modal that could receive keyboard focus.
|
|
4843
4852
|
*/
|
|
4844
4853
|
ModalController.prototype.getAllTabbables = function () {
|
|
4845
|
-
return Array.from(this.modalTarget.querySelectorAll("[href], input, select, textarea, button, [tabindex]"))
|
|
4846
|
-
|
|
4854
|
+
return Array.from(this.modalTarget.querySelectorAll("[href], input, select, textarea, button, [tabindex]")).filter(function (el) {
|
|
4855
|
+
return el.matches(":not([disabled]):not([tabindex='-1'])");
|
|
4856
|
+
});
|
|
4847
4857
|
};
|
|
4848
4858
|
/**
|
|
4849
4859
|
* Returns the first visible element in an array or `undefined` if no elements are visible.
|
|
@@ -4910,9 +4920,12 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4910
4920
|
*/
|
|
4911
4921
|
ModalController.prototype.bindDocumentEvents = function () {
|
|
4912
4922
|
// in order for removeEventListener to remove the right event, this bound function needs a constant reference
|
|
4913
|
-
this._boundClickFn =
|
|
4914
|
-
|
|
4915
|
-
this.
|
|
4923
|
+
this._boundClickFn =
|
|
4924
|
+
this._boundClickFn || this.hideOnOutsideClick.bind(this);
|
|
4925
|
+
this._boundKeypressFn =
|
|
4926
|
+
this._boundKeypressFn || this.hideOnEscapePress.bind(this);
|
|
4927
|
+
this._boundTabTrap =
|
|
4928
|
+
this._boundTabTrap || this.keepFocusWithinModal.bind(this);
|
|
4916
4929
|
document.addEventListener("mousedown", this._boundClickFn);
|
|
4917
4930
|
document.addEventListener("keyup", this._boundKeypressFn);
|
|
4918
4931
|
document.addEventListener("keydown", this._boundTabTrap);
|
|
@@ -4929,10 +4942,13 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4929
4942
|
* Forces the popover to hide if a user clicks outside of it or its reference element
|
|
4930
4943
|
*/
|
|
4931
4944
|
ModalController.prototype.hideOnOutsideClick = function (e) {
|
|
4945
|
+
var _a;
|
|
4932
4946
|
var target = e.target;
|
|
4933
4947
|
// check if the document was clicked inside either the toggle element or the modal itself
|
|
4934
4948
|
// note: .contains also returns true if the node itself matches the target element
|
|
4935
|
-
if (!
|
|
4949
|
+
if (!((_a = this.modalTarget
|
|
4950
|
+
.querySelector(".s-modal--dialog")) === null || _a === void 0 ? void 0 : _a.contains(target)) &&
|
|
4951
|
+
document.body.contains(target)) {
|
|
4936
4952
|
this._toggle(false, e);
|
|
4937
4953
|
}
|
|
4938
4954
|
};
|
|
@@ -4941,7 +4957,8 @@ var ModalController = /** @class */ (function (_super) {
|
|
|
4941
4957
|
*/
|
|
4942
4958
|
ModalController.prototype.hideOnEscapePress = function (e) {
|
|
4943
4959
|
// if the ESC key (27) wasn't pressed or if no popovers are showing, return
|
|
4944
|
-
if (e.which !== 27 ||
|
|
4960
|
+
if (e.which !== 27 ||
|
|
4961
|
+
this.modalTarget.getAttribute("aria-hidden") === "true") {
|
|
4945
4962
|
return;
|
|
4946
4963
|
}
|
|
4947
4964
|
this._toggle(false, e);
|
|
@@ -5109,7 +5126,7 @@ var TabListController = /** @class */ (function (_super) {
|
|
|
5109
5126
|
* Returns the currently selected tab or null if no tabs are selected.
|
|
5110
5127
|
*/
|
|
5111
5128
|
get: function () {
|
|
5112
|
-
return this.tabTargets.find(function (e) { return e.getAttribute("aria-selected") === "true"; }) || null;
|
|
5129
|
+
return (this.tabTargets.find(function (e) { return e.getAttribute("aria-selected") === "true"; }) || null);
|
|
5113
5130
|
},
|
|
5114
5131
|
/**
|
|
5115
5132
|
* Switches the tablist to the provided tab, updating the tabs and panels
|
|
@@ -5120,19 +5137,19 @@ var TabListController = /** @class */ (function (_super) {
|
|
|
5120
5137
|
set: function (selectedTab) {
|
|
5121
5138
|
for (var _i = 0, _a = this.tabTargets; _i < _a.length; _i++) {
|
|
5122
5139
|
var tab = _a[_i];
|
|
5123
|
-
var panelId = tab.getAttribute(
|
|
5140
|
+
var panelId = tab.getAttribute("aria-controls");
|
|
5124
5141
|
var panel = panelId ? document.getElementById(panelId) : null;
|
|
5125
5142
|
if (tab === selectedTab) {
|
|
5126
|
-
tab.classList.add(
|
|
5127
|
-
tab.setAttribute(
|
|
5128
|
-
tab.removeAttribute(
|
|
5129
|
-
panel === null || panel === void 0 ? void 0 : panel.classList.remove(
|
|
5143
|
+
tab.classList.add("is-selected");
|
|
5144
|
+
tab.setAttribute("aria-selected", "true");
|
|
5145
|
+
tab.removeAttribute("tabindex");
|
|
5146
|
+
panel === null || panel === void 0 ? void 0 : panel.classList.remove("d-none");
|
|
5130
5147
|
}
|
|
5131
5148
|
else {
|
|
5132
|
-
tab.classList.remove(
|
|
5133
|
-
tab.setAttribute(
|
|
5134
|
-
tab.setAttribute(
|
|
5135
|
-
panel === null || panel === void 0 ? void 0 : panel.classList.add(
|
|
5149
|
+
tab.classList.remove("is-selected");
|
|
5150
|
+
tab.setAttribute("aria-selected", "false");
|
|
5151
|
+
tab.setAttribute("tabindex", "-1");
|
|
5152
|
+
panel === null || panel === void 0 ? void 0 : panel.classList.add("d-none");
|
|
5136
5153
|
}
|
|
5137
5154
|
}
|
|
5138
5155
|
},
|
|
@@ -5180,7 +5197,9 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5180
5197
|
*/
|
|
5181
5198
|
get: function () {
|
|
5182
5199
|
var popoverElement = this.popoverElement;
|
|
5183
|
-
return popoverElement
|
|
5200
|
+
return popoverElement
|
|
5201
|
+
? popoverElement.classList.contains("is-visible")
|
|
5202
|
+
: false;
|
|
5184
5203
|
},
|
|
5185
5204
|
enumerable: false,
|
|
5186
5205
|
configurable: true
|
|
@@ -5199,14 +5218,17 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5199
5218
|
var rect = element.getBoundingClientRect();
|
|
5200
5219
|
var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
|
|
5201
5220
|
var viewWidth = Math.max(document.documentElement.clientWidth, window.innerWidth);
|
|
5202
|
-
return rect.bottom > 0 &&
|
|
5221
|
+
return (rect.bottom > 0 &&
|
|
5222
|
+
rect.top < viewHeight &&
|
|
5223
|
+
rect.right > 0 &&
|
|
5224
|
+
rect.left < viewWidth);
|
|
5203
5225
|
},
|
|
5204
5226
|
enumerable: false,
|
|
5205
5227
|
configurable: true
|
|
5206
5228
|
});
|
|
5207
5229
|
Object.defineProperty(BasePopoverController.prototype, "shouldHideOnOutsideClick", {
|
|
5208
5230
|
get: function () {
|
|
5209
|
-
var hideBehavior = this.data.get("hide-on-outside-click");
|
|
5231
|
+
var hideBehavior = (this.data.get("hide-on-outside-click"));
|
|
5210
5232
|
switch (hideBehavior) {
|
|
5211
5233
|
case "after-dismissal":
|
|
5212
5234
|
case "never":
|
|
@@ -5265,7 +5287,7 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5265
5287
|
}
|
|
5266
5288
|
var dispatcherElement = this.getDispatcher(dispatcher);
|
|
5267
5289
|
if (this.triggerEvent("show", {
|
|
5268
|
-
dispatcher: dispatcherElement
|
|
5290
|
+
dispatcher: dispatcherElement,
|
|
5269
5291
|
}).defaultPrevented) {
|
|
5270
5292
|
return;
|
|
5271
5293
|
}
|
|
@@ -5287,7 +5309,7 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5287
5309
|
}
|
|
5288
5310
|
var dispatcherElement = this.getDispatcher(dispatcher);
|
|
5289
5311
|
if (this.triggerEvent("hide", {
|
|
5290
|
-
dispatcher: dispatcherElement
|
|
5312
|
+
dispatcher: dispatcherElement,
|
|
5291
5313
|
}).defaultPrevented) {
|
|
5292
5314
|
return;
|
|
5293
5315
|
}
|
|
@@ -5300,7 +5322,8 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5300
5322
|
delete this.popper;
|
|
5301
5323
|
}
|
|
5302
5324
|
// on first interaction, hide-on-outside-click with value "after-dismissal" reverts to the default behavior
|
|
5303
|
-
if (this.data.get("hide-on-outside-click") ===
|
|
5325
|
+
if (this.data.get("hide-on-outside-click") ===
|
|
5326
|
+
"after-dismissal") {
|
|
5304
5327
|
this.data.delete("hide-on-outside-click");
|
|
5305
5328
|
}
|
|
5306
5329
|
this.hidden(dispatcherElement);
|
|
@@ -5312,7 +5335,7 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5312
5335
|
if (dispatcher === void 0) { dispatcher = null; }
|
|
5313
5336
|
this.bindDocumentEvents();
|
|
5314
5337
|
this.triggerEvent("shown", {
|
|
5315
|
-
dispatcher: dispatcher
|
|
5338
|
+
dispatcher: dispatcher,
|
|
5316
5339
|
});
|
|
5317
5340
|
};
|
|
5318
5341
|
/**
|
|
@@ -5322,7 +5345,7 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5322
5345
|
if (dispatcher === void 0) { dispatcher = null; }
|
|
5323
5346
|
this.unbindDocumentEvents();
|
|
5324
5347
|
this.triggerEvent("hidden", {
|
|
5325
|
-
dispatcher: dispatcher
|
|
5348
|
+
dispatcher: dispatcher,
|
|
5326
5349
|
});
|
|
5327
5350
|
};
|
|
5328
5351
|
/**
|
|
@@ -5342,15 +5365,15 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5342
5365
|
name: "offset",
|
|
5343
5366
|
options: {
|
|
5344
5367
|
offset: [0, 10], // The entire popover should be 10px away from the element
|
|
5345
|
-
}
|
|
5368
|
+
},
|
|
5346
5369
|
},
|
|
5347
5370
|
{
|
|
5348
5371
|
name: "arrow",
|
|
5349
5372
|
options: {
|
|
5350
|
-
element: ".s-popover--arrow"
|
|
5373
|
+
element: ".s-popover--arrow",
|
|
5351
5374
|
},
|
|
5352
5375
|
},
|
|
5353
|
-
]
|
|
5376
|
+
],
|
|
5354
5377
|
});
|
|
5355
5378
|
};
|
|
5356
5379
|
/**
|
|
@@ -5361,9 +5384,10 @@ var BasePopoverController = /** @class */ (function (_super) {
|
|
|
5361
5384
|
this.referenceElement = this.element;
|
|
5362
5385
|
// if there is an alternative reference selector and that element exists, use it (and throw if it isn't found)
|
|
5363
5386
|
if (referenceSelector) {
|
|
5364
|
-
this.referenceElement = this.element.querySelector(referenceSelector);
|
|
5387
|
+
this.referenceElement = (this.element.querySelector(referenceSelector));
|
|
5365
5388
|
if (!this.referenceElement) {
|
|
5366
|
-
throw "Unable to find element by reference selector: " +
|
|
5389
|
+
throw ("Unable to find element by reference selector: " +
|
|
5390
|
+
referenceSelector);
|
|
5367
5391
|
}
|
|
5368
5392
|
}
|
|
5369
5393
|
var popoverId = this.referenceElement.getAttribute(this.popoverSelectorAttribute);
|
|
@@ -5447,8 +5471,10 @@ var PopoverController = /** @class */ (function (_super) {
|
|
|
5447
5471
|
* Binds global events to the document for hiding popovers on user interaction
|
|
5448
5472
|
*/
|
|
5449
5473
|
PopoverController.prototype.bindDocumentEvents = function () {
|
|
5450
|
-
this.boundHideOnOutsideClick =
|
|
5451
|
-
|
|
5474
|
+
this.boundHideOnOutsideClick =
|
|
5475
|
+
this.boundHideOnOutsideClick || this.hideOnOutsideClick.bind(this);
|
|
5476
|
+
this.boundHideOnEscapePress =
|
|
5477
|
+
this.boundHideOnEscapePress || this.hideOnEscapePress.bind(this);
|
|
5452
5478
|
document.addEventListener("mousedown", this.boundHideOnOutsideClick);
|
|
5453
5479
|
document.addEventListener("keyup", this.boundHideOnEscapePress);
|
|
5454
5480
|
};
|
|
@@ -5467,11 +5493,13 @@ var PopoverController = /** @class */ (function (_super) {
|
|
|
5467
5493
|
var target = e.target;
|
|
5468
5494
|
// check if the document was clicked inside either the reference element or the popover itself
|
|
5469
5495
|
// note: .contains also returns true if the node itself matches the target element
|
|
5470
|
-
if (this.shouldHideOnOutsideClick &&
|
|
5496
|
+
if (this.shouldHideOnOutsideClick &&
|
|
5497
|
+
!this.referenceElement.contains(target) &&
|
|
5498
|
+
!this.popoverElement.contains(target) &&
|
|
5499
|
+
document.body.contains(target)) {
|
|
5471
5500
|
this.hide(e);
|
|
5472
5501
|
}
|
|
5473
5502
|
};
|
|
5474
|
-
;
|
|
5475
5503
|
/**
|
|
5476
5504
|
* Forces the popover to hide if the user presses escape while it, one of its childen, or the reference element are focused
|
|
5477
5505
|
* @param {Event} e - The document keyup event
|
|
@@ -5488,7 +5516,6 @@ var PopoverController = /** @class */ (function (_super) {
|
|
|
5488
5516
|
}
|
|
5489
5517
|
this.hide(e);
|
|
5490
5518
|
};
|
|
5491
|
-
;
|
|
5492
5519
|
/**
|
|
5493
5520
|
* Toggles all classes on the originating element based on the `class-toggle` data
|
|
5494
5521
|
* @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide.
|
|
@@ -5568,9 +5595,11 @@ function attachPopover(element, popover, options) {
|
|
|
5568
5595
|
if (!referenceElement) {
|
|
5569
5596
|
throw "element has invalid data-s-popover-reference-selector attribute";
|
|
5570
5597
|
}
|
|
5571
|
-
if (typeof popover ===
|
|
5598
|
+
if (typeof popover === "string") {
|
|
5572
5599
|
// eslint-disable-next-line no-unsanitized/method
|
|
5573
|
-
var elements = document
|
|
5600
|
+
var elements = document
|
|
5601
|
+
.createRange()
|
|
5602
|
+
.createContextualFragment(popover).children;
|
|
5574
5603
|
if (elements.length !== 1) {
|
|
5575
5604
|
throw "popover should contain a single element";
|
|
5576
5605
|
}
|
|
@@ -5578,14 +5607,15 @@ function attachPopover(element, popover, options) {
|
|
|
5578
5607
|
}
|
|
5579
5608
|
var existingId = referenceElement.getAttribute("aria-controls");
|
|
5580
5609
|
var popoverId = popover.id;
|
|
5581
|
-
if (!popover.classList.contains(
|
|
5610
|
+
if (!popover.classList.contains("s-popover")) {
|
|
5582
5611
|
throw "popover should have the \"s-popover\" class but had class=\"".concat(popover.className, "\"");
|
|
5583
5612
|
}
|
|
5584
5613
|
if (existingId && existingId !== popoverId) {
|
|
5585
5614
|
throw "element has aria-controls=\"".concat(existingId, "\" but popover has id=\"").concat(popoverId, "\"");
|
|
5586
5615
|
}
|
|
5587
5616
|
if (!popoverId) {
|
|
5588
|
-
popoverId =
|
|
5617
|
+
popoverId =
|
|
5618
|
+
"--stacks-s-popover-" + Math.random().toString(36).substring(2, 10);
|
|
5589
5619
|
popover.id = popoverId;
|
|
5590
5620
|
}
|
|
5591
5621
|
if (!existingId) {
|
|
@@ -5639,8 +5669,12 @@ function getPopover(element) {
|
|
|
5639
5669
|
var isPopover = ((_a = element.getAttribute("data-controller")) === null || _a === void 0 ? void 0 : _a.includes("s-popover")) || false;
|
|
5640
5670
|
var controller = Stacks.application.getControllerForElementAndIdentifier(element, "s-popover");
|
|
5641
5671
|
var referenceSelector = element.getAttribute("data-s-popover-reference-selector");
|
|
5642
|
-
var referenceElement = referenceSelector
|
|
5643
|
-
|
|
5672
|
+
var referenceElement = referenceSelector
|
|
5673
|
+
? element.querySelector(referenceSelector)
|
|
5674
|
+
: element;
|
|
5675
|
+
var popoverId = referenceElement
|
|
5676
|
+
? referenceElement.getAttribute("aria-controls")
|
|
5677
|
+
: null;
|
|
5644
5678
|
var popover = popoverId ? document.getElementById(popoverId) : null;
|
|
5645
5679
|
return { isPopover: isPopover, controller: controller, referenceElement: referenceElement, popover: popover };
|
|
5646
5680
|
}
|
|
@@ -5652,14 +5686,14 @@ function getPopover(element) {
|
|
|
5652
5686
|
*/
|
|
5653
5687
|
function toggleController(el, controllerName, include) {
|
|
5654
5688
|
var _a;
|
|
5655
|
-
var controllers = new Set((_a = el.getAttribute(
|
|
5689
|
+
var controllers = new Set((_a = el.getAttribute("data-controller")) === null || _a === void 0 ? void 0 : _a.split(/\s+/));
|
|
5656
5690
|
if (include) {
|
|
5657
5691
|
controllers.add(controllerName);
|
|
5658
5692
|
}
|
|
5659
5693
|
else {
|
|
5660
5694
|
controllers.delete(controllerName);
|
|
5661
5695
|
}
|
|
5662
|
-
el.setAttribute(
|
|
5696
|
+
el.setAttribute("data-controller", Array.from(controllers).join(" "));
|
|
5663
5697
|
}
|
|
5664
5698
|
|
|
5665
5699
|
|
|
@@ -5701,7 +5735,9 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5701
5735
|
this.columnTargets.forEach(function (target) {
|
|
5702
5736
|
var isCurrrent = target === headElem;
|
|
5703
5737
|
target.classList.toggle("is-sorted", isCurrrent && direction !== "none");
|
|
5704
|
-
target
|
|
5738
|
+
target
|
|
5739
|
+
.querySelectorAll(".js-sorting-indicator")
|
|
5740
|
+
.forEach(function (icon) {
|
|
5705
5741
|
var visible = isCurrrent ? direction : "none";
|
|
5706
5742
|
icon.classList.toggle("d-none", !icon.classList.contains("js-sorting-indicator-" + visible));
|
|
5707
5743
|
});
|
|
@@ -5713,7 +5749,6 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5713
5749
|
}
|
|
5714
5750
|
});
|
|
5715
5751
|
};
|
|
5716
|
-
;
|
|
5717
5752
|
TableController.prototype.sort = function (evt) {
|
|
5718
5753
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
5719
5754
|
var controller = this;
|
|
@@ -5725,7 +5760,8 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5725
5760
|
var tbody = table.tBodies[0];
|
|
5726
5761
|
// the column slot number of the clicked header
|
|
5727
5762
|
var colno = getCellSlot(colHead);
|
|
5728
|
-
if (colno < 0) {
|
|
5763
|
+
if (colno < 0) {
|
|
5764
|
+
// this shouldn't happen if the clicked element is actually a column head
|
|
5729
5765
|
return;
|
|
5730
5766
|
}
|
|
5731
5767
|
// an index of the <tbody>, so we can find out for each row which <td> element is
|
|
@@ -5742,6 +5778,7 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5742
5778
|
var data = [];
|
|
5743
5779
|
var firstBottomRow;
|
|
5744
5780
|
rows.forEach(function (row, index) {
|
|
5781
|
+
var _a, _b;
|
|
5745
5782
|
var force = controller.getElementData(row, "sort-to");
|
|
5746
5783
|
if (force === "top") {
|
|
5747
5784
|
return; // rows not added to the list will automatically end up at the top
|
|
@@ -5760,8 +5797,10 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5760
5797
|
// unless the to-be-sorted-by value is explicitly provided on the element via this attribute,
|
|
5761
5798
|
// the value we're using is the cell's text, trimmed of any whitespace
|
|
5762
5799
|
var explicit = controller.getElementData(cell, "sort-val");
|
|
5763
|
-
var d = typeof explicit === "string"
|
|
5764
|
-
|
|
5800
|
+
var d = typeof explicit === "string"
|
|
5801
|
+
? explicit
|
|
5802
|
+
: (_b = (_a = cell.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
|
|
5803
|
+
if (d !== "" && "".concat(parseInt(d, 10)) !== d) {
|
|
5765
5804
|
anyNonInt = true;
|
|
5766
5805
|
}
|
|
5767
5806
|
data.push([d, index]);
|
|
@@ -5770,7 +5809,10 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5770
5809
|
// having the lowest possible value (i.e. sorted to the top if ascending, bottom if descending)
|
|
5771
5810
|
if (!anyNonInt) {
|
|
5772
5811
|
data.forEach(function (tuple) {
|
|
5773
|
-
tuple[0] =
|
|
5812
|
+
tuple[0] =
|
|
5813
|
+
tuple[0] === ""
|
|
5814
|
+
? Number.MIN_VALUE
|
|
5815
|
+
: parseInt(tuple[0], 10);
|
|
5774
5816
|
});
|
|
5775
5817
|
}
|
|
5776
5818
|
// We don't sort an array of <tr>, but instead an arrays of row *numbers*, because this way we
|
|
@@ -5792,8 +5834,9 @@ var TableController = /** @class */ (function (_super) {
|
|
|
5792
5834
|
});
|
|
5793
5835
|
// this is the actual reordering of the table rows
|
|
5794
5836
|
data.forEach(function (tup) {
|
|
5837
|
+
var _a;
|
|
5795
5838
|
var row = rows[tup[1]];
|
|
5796
|
-
row.parentElement.removeChild(row);
|
|
5839
|
+
(_a = row.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(row);
|
|
5797
5840
|
if (firstBottomRow) {
|
|
5798
5841
|
tbody.insertBefore(row, firstBottomRow);
|
|
5799
5842
|
}
|
|
@@ -5817,7 +5860,8 @@ function buildIndex(section) {
|
|
|
5817
5860
|
return result;
|
|
5818
5861
|
}
|
|
5819
5862
|
function getCellSlot(cell) {
|
|
5820
|
-
if (!(cell.parentElement &&
|
|
5863
|
+
if (!(cell.parentElement &&
|
|
5864
|
+
cell.parentElement.parentElement instanceof HTMLTableSectionElement)) {
|
|
5821
5865
|
throw "invalid table";
|
|
5822
5866
|
}
|
|
5823
5867
|
var result = buildIndexOrGetCellSlot(cell.parentElement.parentElement, cell);
|
|
@@ -5850,7 +5894,10 @@ function buildIndexOrGetCellSlot(section, findCell) {
|
|
|
5850
5894
|
var growing = [];
|
|
5851
5895
|
var growingRowsLeft = [];
|
|
5852
5896
|
// continue while we have actual <tr>'s left *or* we still have rowspan'ed elements that aren't done
|
|
5853
|
-
while (curRow ||
|
|
5897
|
+
while (curRow ||
|
|
5898
|
+
growingRowsLeft.some(function (e) {
|
|
5899
|
+
return e !== 0;
|
|
5900
|
+
})) {
|
|
5854
5901
|
var curIndexRow = [];
|
|
5855
5902
|
index.push(curIndexRow);
|
|
5856
5903
|
var curSlot = 0;
|
|
@@ -5890,7 +5937,9 @@ function buildIndexOrGetCellSlot(section, findCell) {
|
|
|
5890
5937
|
curRow = curRow.nextElementSibling;
|
|
5891
5938
|
}
|
|
5892
5939
|
}
|
|
5893
|
-
return findCell
|
|
5940
|
+
return findCell
|
|
5941
|
+
? -1
|
|
5942
|
+
: index; /* if findCell was given but we end up here, that means it isn't in this section */
|
|
5894
5943
|
}
|
|
5895
5944
|
|
|
5896
5945
|
|
|
@@ -5993,7 +6042,9 @@ var TooltipController = /** @class */ (function (_super) {
|
|
|
5993
6042
|
var htmlTitle = this.data.get("html-title");
|
|
5994
6043
|
if (htmlTitle) {
|
|
5995
6044
|
// eslint-disable-next-line no-unsanitized/method
|
|
5996
|
-
content = document
|
|
6045
|
+
content = document
|
|
6046
|
+
.createRange()
|
|
6047
|
+
.createContextualFragment(htmlTitle);
|
|
5997
6048
|
}
|
|
5998
6049
|
else {
|
|
5999
6050
|
var plainTitle = this.element.getAttribute("title");
|
|
@@ -6045,7 +6096,8 @@ var TooltipController = /** @class */ (function (_super) {
|
|
|
6045
6096
|
* the page.
|
|
6046
6097
|
*/
|
|
6047
6098
|
TooltipController.prototype.bindDocumentEvents = function () {
|
|
6048
|
-
this.boundHideIfWithin =
|
|
6099
|
+
this.boundHideIfWithin =
|
|
6100
|
+
this.boundHideIfWithin || this.hideIfWithin.bind(this);
|
|
6049
6101
|
document.addEventListener("s-popover:shown", this.boundHideIfWithin);
|
|
6050
6102
|
};
|
|
6051
6103
|
/**
|
|
@@ -6079,9 +6131,12 @@ var TooltipController = /** @class */ (function (_super) {
|
|
|
6079
6131
|
* Binds mouse events to show/hide on reference element hover
|
|
6080
6132
|
*/
|
|
6081
6133
|
TooltipController.prototype.bindKeyboardEvents = function () {
|
|
6082
|
-
this.boundScheduleShow =
|
|
6134
|
+
this.boundScheduleShow =
|
|
6135
|
+
this.boundScheduleShow || this.scheduleShow.bind(this);
|
|
6083
6136
|
this.boundHide = this.boundHide || this.scheduleHide.bind(this);
|
|
6084
|
-
this.boundHideOnEscapeKeyEvent =
|
|
6137
|
+
this.boundHideOnEscapeKeyEvent =
|
|
6138
|
+
this.boundHideOnEscapeKeyEvent ||
|
|
6139
|
+
this.hideOnEscapeKeyEvent.bind(this);
|
|
6085
6140
|
this.referenceElement.addEventListener("focus", this.boundScheduleShow);
|
|
6086
6141
|
this.referenceElement.addEventListener("blur", this.boundHide);
|
|
6087
6142
|
document.addEventListener("keyup", this.boundHideOnEscapeKeyEvent);
|
|
@@ -6098,9 +6153,11 @@ var TooltipController = /** @class */ (function (_super) {
|
|
|
6098
6153
|
* Binds mouse events to show/hide on reference element hover
|
|
6099
6154
|
*/
|
|
6100
6155
|
TooltipController.prototype.bindMouseEvents = function () {
|
|
6101
|
-
this.boundScheduleShow =
|
|
6156
|
+
this.boundScheduleShow =
|
|
6157
|
+
this.boundScheduleShow || this.scheduleShow.bind(this);
|
|
6102
6158
|
this.boundHide = this.boundHide || this.scheduleHide.bind(this);
|
|
6103
|
-
this.boundClearActiveTimeout =
|
|
6159
|
+
this.boundClearActiveTimeout =
|
|
6160
|
+
this.boundClearActiveTimeout || this.clearActiveTimeout.bind(this);
|
|
6104
6161
|
this.referenceElement.addEventListener("mouseover", this.boundScheduleShow);
|
|
6105
6162
|
this.referenceElement.addEventListener("mouseout", this.boundHide);
|
|
6106
6163
|
this.popoverElement.addEventListener("mouseover", this.boundClearActiveTimeout);
|
|
@@ -6122,7 +6179,7 @@ var TooltipController = /** @class */ (function (_super) {
|
|
|
6122
6179
|
*/
|
|
6123
6180
|
TooltipController.generateId = function () {
|
|
6124
6181
|
// generate a random number, then convert to a well formatted string
|
|
6125
|
-
return "--stacks-s-tooltip-" + Math.random().toString(36).substring(2, 10);
|
|
6182
|
+
return ("--stacks-s-tooltip-" + Math.random().toString(36).substring(2, 10));
|
|
6126
6183
|
};
|
|
6127
6184
|
TooltipController.targets = [];
|
|
6128
6185
|
return TooltipController;
|
|
@@ -6161,7 +6218,7 @@ function applyOptionsAndTitleAttributes(element, options) {
|
|
|
6161
6218
|
if (options && options.placement) {
|
|
6162
6219
|
element.setAttribute("data-s-tooltip-placement", options.placement);
|
|
6163
6220
|
}
|
|
6164
|
-
var controller = Stacks.application.getControllerForElementAndIdentifier(element, "s-tooltip");
|
|
6221
|
+
var controller = (Stacks.application.getControllerForElementAndIdentifier(element, "s-tooltip"));
|
|
6165
6222
|
if (controller) {
|
|
6166
6223
|
controller.applyTitleAttributes();
|
|
6167
6224
|
}
|
|
@@ -6196,7 +6253,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
6196
6253
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6197
6254
|
exports.UploaderController = void 0;
|
|
6198
6255
|
var Stacks = __webpack_require__(36);
|
|
6199
|
-
;
|
|
6200
6256
|
var UploaderController = /** @class */ (function (_super) {
|
|
6201
6257
|
__extends(UploaderController, _super);
|
|
6202
6258
|
function UploaderController() {
|
|
@@ -6231,8 +6287,10 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6231
6287
|
if (hasMultipleFiles) {
|
|
6232
6288
|
var headingElement = document.createElement("div");
|
|
6233
6289
|
headingElement.classList.add("s-uploader--previews-heading");
|
|
6234
|
-
headingElement.innerText =
|
|
6235
|
-
|
|
6290
|
+
headingElement.innerText =
|
|
6291
|
+
res.length < count
|
|
6292
|
+
? "Showing ".concat(res.length, " of ").concat(count, " files")
|
|
6293
|
+
: "".concat(count, " items");
|
|
6236
6294
|
_this.previewsTarget.appendChild(headingElement);
|
|
6237
6295
|
_this.previewsTarget.classList.add("has-multiple");
|
|
6238
6296
|
}
|
|
@@ -6249,7 +6307,7 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6249
6307
|
* Resets the Uploader to initial state
|
|
6250
6308
|
*/
|
|
6251
6309
|
UploaderController.prototype.reset = function () {
|
|
6252
|
-
this.inputTarget.value =
|
|
6310
|
+
this.inputTarget.value = "";
|
|
6253
6311
|
this.previewsTarget.innerHTML = "";
|
|
6254
6312
|
this.handleVisible(false);
|
|
6255
6313
|
};
|
|
@@ -6259,9 +6317,9 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6259
6317
|
*/
|
|
6260
6318
|
UploaderController.prototype.handleVisible = function (shouldPreview) {
|
|
6261
6319
|
var scope = this.targets.scope;
|
|
6262
|
-
var hideElements = scope.findAllElements(
|
|
6263
|
-
var showElements = scope.findAllElements(
|
|
6264
|
-
var enableElements = scope.findAllElements(
|
|
6320
|
+
var hideElements = scope.findAllElements("[data-s-uploader-hide-on-input]");
|
|
6321
|
+
var showElements = scope.findAllElements("[data-s-uploader-show-on-input]");
|
|
6322
|
+
var enableElements = scope.findAllElements("[data-s-uploader-enable-on-input]");
|
|
6265
6323
|
if (shouldPreview) {
|
|
6266
6324
|
hideElements.forEach(function (el) {
|
|
6267
6325
|
el.classList.add("d-none");
|
|
@@ -6296,7 +6354,7 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6296
6354
|
}
|
|
6297
6355
|
var previewElement = document.createElement("div");
|
|
6298
6356
|
var thumbElement;
|
|
6299
|
-
if (file.type.match(
|
|
6357
|
+
if (file.type.match("image/*") && file.data) {
|
|
6300
6358
|
thumbElement = document.createElement("img");
|
|
6301
6359
|
thumbElement.src = file.data.toString();
|
|
6302
6360
|
thumbElement.alt = file.name;
|
|
@@ -6308,7 +6366,7 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6308
6366
|
thumbElement.classList.add("s-uploader--preview-thumbnail");
|
|
6309
6367
|
previewElement.appendChild(thumbElement);
|
|
6310
6368
|
previewElement.classList.add("s-uploader--preview");
|
|
6311
|
-
previewElement.setAttribute(
|
|
6369
|
+
previewElement.setAttribute("data-filename", file.name);
|
|
6312
6370
|
this.previewsTarget.appendChild(previewElement);
|
|
6313
6371
|
};
|
|
6314
6372
|
/**
|
|
@@ -6326,7 +6384,8 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6326
6384
|
UploaderController.prototype.fileToDataURL = function (file) {
|
|
6327
6385
|
var reader = new FileReader();
|
|
6328
6386
|
var name = file.name, size = file.size, type = file.type;
|
|
6329
|
-
if (size < UploaderController.MAX_FILE_SIZE &&
|
|
6387
|
+
if (size < UploaderController.MAX_FILE_SIZE &&
|
|
6388
|
+
type.indexOf("image") > -1) {
|
|
6330
6389
|
return new Promise(function (resolve, reject) {
|
|
6331
6390
|
reader.onload = function (evt) {
|
|
6332
6391
|
var _a;
|
|
@@ -6363,7 +6422,6 @@ var UploaderController = /** @class */ (function (_super) {
|
|
|
6363
6422
|
return UploaderController;
|
|
6364
6423
|
}(Stacks.StacksController));
|
|
6365
6424
|
exports.UploaderController = UploaderController;
|
|
6366
|
-
;
|
|
6367
6425
|
|
|
6368
6426
|
|
|
6369
6427
|
/***/ }),
|
|
@@ -6454,10 +6512,10 @@ var StacksApplication = /** @class */ (function (_super) {
|
|
|
6454
6512
|
var definition = definitions_1[_a];
|
|
6455
6513
|
var hasPrefix = /^s-/.test(definition.identifier);
|
|
6456
6514
|
if (StacksApplication._initializing && !hasPrefix) {
|
|
6457
|
-
throw
|
|
6515
|
+
throw 'Stacks-created Stimulus controller names must start with "s-".';
|
|
6458
6516
|
}
|
|
6459
6517
|
if (!StacksApplication._initializing && hasPrefix) {
|
|
6460
|
-
throw
|
|
6518
|
+
throw 'The "s-" prefix on Stimulus controller names is reserved for Stacks-created controllers.';
|
|
6461
6519
|
}
|
|
6462
6520
|
}
|
|
6463
6521
|
_super.prototype.load.call(this, definitions);
|
|
@@ -6484,20 +6542,21 @@ var StacksController = /** @class */ (function (_super) {
|
|
|
6484
6542
|
StacksController.prototype.getElementData = function (element, key) {
|
|
6485
6543
|
return element.getAttribute("data-" + this.identifier + "-" + key);
|
|
6486
6544
|
};
|
|
6487
|
-
;
|
|
6488
6545
|
StacksController.prototype.setElementData = function (element, key, value) {
|
|
6489
6546
|
element.setAttribute("data-" + this.identifier + "-" + key, value);
|
|
6490
6547
|
};
|
|
6491
|
-
;
|
|
6492
6548
|
StacksController.prototype.removeElementData = function (element, key) {
|
|
6493
6549
|
element.removeAttribute("data-" + this.identifier + "-" + key);
|
|
6494
6550
|
};
|
|
6495
|
-
;
|
|
6496
6551
|
StacksController.prototype.triggerEvent = function (eventName, detail, optionalElement) {
|
|
6497
6552
|
var namespacedName = this.identifier + ":" + eventName;
|
|
6498
6553
|
var event;
|
|
6499
6554
|
try {
|
|
6500
|
-
event = new CustomEvent(namespacedName, {
|
|
6555
|
+
event = new CustomEvent(namespacedName, {
|
|
6556
|
+
bubbles: true,
|
|
6557
|
+
cancelable: true,
|
|
6558
|
+
detail: detail,
|
|
6559
|
+
});
|
|
6501
6560
|
}
|
|
6502
6561
|
catch (ex) {
|
|
6503
6562
|
// Internet Explorer
|
|
@@ -6508,23 +6567,23 @@ var StacksController = /** @class */ (function (_super) {
|
|
|
6508
6567
|
(optionalElement || this.element).dispatchEvent(event);
|
|
6509
6568
|
return event;
|
|
6510
6569
|
};
|
|
6511
|
-
;
|
|
6512
6570
|
return StacksController;
|
|
6513
6571
|
}(Stimulus.Controller));
|
|
6514
6572
|
exports.StacksController = StacksController;
|
|
6515
6573
|
function createController(controllerDefinition) {
|
|
6516
6574
|
var _a;
|
|
6575
|
+
var _b;
|
|
6517
6576
|
// eslint-disable-next-line no-prototype-builtins
|
|
6518
6577
|
var Controller = controllerDefinition.hasOwnProperty("targets")
|
|
6519
|
-
? (
|
|
6578
|
+
? (_b = /** @class */ (function (_super) {
|
|
6520
6579
|
__extends(Controller, _super);
|
|
6521
6580
|
function Controller() {
|
|
6522
6581
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6523
6582
|
}
|
|
6524
6583
|
return Controller;
|
|
6525
6584
|
}(StacksController)),
|
|
6526
|
-
|
|
6527
|
-
|
|
6585
|
+
_b.targets = (_a = controllerDefinition.targets) !== null && _a !== void 0 ? _a : [],
|
|
6586
|
+
_b) : /** @class */ (function (_super) {
|
|
6528
6587
|
__extends(Controller, _super);
|
|
6529
6588
|
function Controller() {
|
|
6530
6589
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -6532,9 +6591,12 @@ function createController(controllerDefinition) {
|
|
|
6532
6591
|
return Controller;
|
|
6533
6592
|
}(StacksController));
|
|
6534
6593
|
for (var prop in controllerDefinition) {
|
|
6594
|
+
var ownPropDescriptor =
|
|
6535
6595
|
// eslint-disable-next-line no-prototype-builtins
|
|
6536
|
-
|
|
6537
|
-
Object.
|
|
6596
|
+
controllerDefinition.hasOwnProperty(prop) &&
|
|
6597
|
+
Object.getOwnPropertyDescriptor(controllerDefinition, prop);
|
|
6598
|
+
if (prop !== "targets" && ownPropDescriptor) {
|
|
6599
|
+
Object.defineProperty(Controller.prototype, prop, ownPropDescriptor);
|
|
6538
6600
|
}
|
|
6539
6601
|
}
|
|
6540
6602
|
return Controller;
|