polaris_view_components 0.8.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/icons/polaris/AnalyticsMinor.svg +1 -0
- data/app/assets/icons/polaris/AppsMinor.svg +1 -0
- data/app/assets/icons/polaris/BlockMinor.svg +1 -0
- data/app/assets/icons/polaris/ButtonMinor.svg +1 -0
- data/app/assets/icons/polaris/CaretDownMinor.svg +1 -1
- data/app/assets/icons/polaris/CaretUpMinor.svg +1 -1
- data/app/assets/icons/polaris/CircleTickMinor.svg +1 -0
- data/app/assets/icons/polaris/Columns3Minor.svg +1 -0
- data/app/assets/icons/polaris/CustomersMinor.svg +1 -1
- data/app/assets/icons/polaris/DiscountsMinor.svg +1 -0
- data/app/assets/icons/polaris/DropdownMinor.svg +1 -1
- data/app/assets/icons/polaris/FinancesMajor.svg +1 -0
- data/app/assets/icons/polaris/FinancesMinor.svg +1 -0
- data/app/assets/icons/polaris/HomeMinor.svg +1 -0
- data/app/assets/icons/polaris/MarketingMinor.svg +1 -0
- data/app/assets/icons/polaris/OnlineStoreMinor.svg +1 -0
- data/app/assets/icons/polaris/OrdersMinor.svg +1 -0
- data/app/assets/icons/polaris/ProductsMinor.svg +1 -0
- data/app/assets/icons/polaris/QuestionMarkInverseMajor.svg +1 -0
- data/app/assets/icons/polaris/QuestionMarkInverseMinor.svg +1 -0
- data/app/assets/icons/polaris/SelectMinor.svg +1 -1
- data/app/assets/icons/polaris/TitleMinor.svg +1 -0
- data/app/assets/icons/polaris/WandMinor.svg +1 -0
- data/app/assets/javascripts/polaris_view_components/collapsible_controller.js +19 -0
- data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +15 -3
- data/app/assets/javascripts/polaris_view_components/frame_controller.js +1 -1
- data/app/assets/javascripts/polaris_view_components/index.js +2 -0
- data/app/assets/javascripts/polaris_view_components/polaris_controller.js +4 -0
- data/app/assets/javascripts/polaris_view_components/text_field_controller.js +5 -0
- data/app/assets/javascripts/polaris_view_components/toast_controller.js +13 -2
- data/app/assets/javascripts/polaris_view_components/{utils.js → utils/index.js} +3 -1
- data/app/assets/javascripts/polaris_view_components/utils/use-transition.js +162 -0
- data/app/assets/javascripts/polaris_view_components.js +201 -162
- data/app/assets/stylesheets/polaris_view_components/custom.css +37 -0
- data/app/assets/stylesheets/polaris_view_components.css +68 -33
- data/app/components/polaris/action_list/item_component.rb +2 -1
- data/app/components/polaris/button_component.html.erb +2 -2
- data/app/components/polaris/collapsible_component.rb +37 -0
- data/app/components/polaris/dropzone_component.html.erb +9 -6
- data/app/components/polaris/filters_component.rb +3 -1
- data/app/components/polaris/headless_button.html.erb +2 -2
- data/app/components/polaris/headless_button.rb +3 -1
- data/app/components/polaris/keyboard_key_component.rb +20 -0
- data/app/components/polaris/page_component.html.erb +81 -10
- data/app/components/polaris/page_component.rb +85 -28
- data/app/components/polaris/resource_item_component.rb +7 -2
- data/app/components/polaris/skeleton_display_text_component.rb +32 -0
- data/app/components/polaris/skeleton_thumbnail_component.rb +31 -0
- data/app/components/polaris/text_field_component.html.erb +1 -1
- data/app/components/polaris/text_field_component.rb +1 -1
- data/app/components/polaris/visually_hidden_component.rb +0 -3
- data/app/helpers/polaris/form_builder.rb +1 -1
- data/app/helpers/polaris/view_helper.rb +4 -0
- data/lib/polaris/view_components/version.rb +1 -1
- metadata +111 -15
@@ -2,6 +2,163 @@ import { Controller } from "@hotwired/stimulus";
|
|
2
2
|
|
3
3
|
import { get } from "@rails/request.js";
|
4
4
|
|
5
|
+
const alpineNames = {
|
6
|
+
enterFromClass: "enter",
|
7
|
+
enterActiveClass: "enterStart",
|
8
|
+
enterToClass: "enterEnd",
|
9
|
+
leaveFromClass: "leave",
|
10
|
+
leaveActiveClass: "leaveStart",
|
11
|
+
leaveToClass: "leaveEnd"
|
12
|
+
};
|
13
|
+
|
14
|
+
const defaultOptions = {
|
15
|
+
transitioned: false,
|
16
|
+
hiddenClass: "hidden",
|
17
|
+
preserveOriginalClass: true,
|
18
|
+
removeToClasses: true
|
19
|
+
};
|
20
|
+
|
21
|
+
const useTransition = (controller, options = {}) => {
|
22
|
+
var _a, _b, _c;
|
23
|
+
const targetName = controller.element.dataset.transitionTarget;
|
24
|
+
let targetFromAttribute;
|
25
|
+
if (targetName) {
|
26
|
+
targetFromAttribute = controller[`${targetName}Target`];
|
27
|
+
}
|
28
|
+
const targetElement = (options === null || options === void 0 ? void 0 : options.element) || targetFromAttribute || controller.element;
|
29
|
+
if (!(targetElement instanceof HTMLElement || targetElement instanceof SVGElement)) return;
|
30
|
+
const dataset = targetElement.dataset;
|
31
|
+
const leaveAfter = parseInt(dataset.leaveAfter || "") || options.leaveAfter || 0;
|
32
|
+
const {transitioned: transitioned, hiddenClass: hiddenClass, preserveOriginalClass: preserveOriginalClass, removeToClasses: removeToClasses} = Object.assign(defaultOptions, options);
|
33
|
+
const controllerEnter = (_a = controller.enter) === null || _a === void 0 ? void 0 : _a.bind(controller);
|
34
|
+
const controllerLeave = (_b = controller.leave) === null || _b === void 0 ? void 0 : _b.bind(controller);
|
35
|
+
const controllerToggleTransition = (_c = controller.toggleTransition) === null || _c === void 0 ? void 0 : _c.bind(controller);
|
36
|
+
async function enter(event) {
|
37
|
+
if (controller.transitioned) return;
|
38
|
+
controller.transitioned = true;
|
39
|
+
controllerEnter && controllerEnter(event);
|
40
|
+
const enterFromClasses = getAttribute("enterFrom", options, dataset);
|
41
|
+
const enterActiveClasses = getAttribute("enterActive", options, dataset);
|
42
|
+
const enterToClasses = getAttribute("enterTo", options, dataset);
|
43
|
+
const leaveToClasses = getAttribute("leaveTo", options, dataset);
|
44
|
+
if (!!hiddenClass) {
|
45
|
+
targetElement.classList.remove(hiddenClass);
|
46
|
+
}
|
47
|
+
if (!removeToClasses) {
|
48
|
+
removeClasses(targetElement, leaveToClasses);
|
49
|
+
}
|
50
|
+
await transition(targetElement, enterFromClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
|
51
|
+
if (leaveAfter > 0) {
|
52
|
+
setTimeout((() => {
|
53
|
+
leave(event);
|
54
|
+
}), leaveAfter);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
async function leave(event) {
|
58
|
+
if (!controller.transitioned) return;
|
59
|
+
controller.transitioned = false;
|
60
|
+
controllerLeave && controllerLeave(event);
|
61
|
+
const leaveFromClasses = getAttribute("leaveFrom", options, dataset);
|
62
|
+
const leaveActiveClasses = getAttribute("leaveActive", options, dataset);
|
63
|
+
const leaveToClasses = getAttribute("leaveTo", options, dataset);
|
64
|
+
const enterToClasses = getAttribute("enterTo", options, dataset);
|
65
|
+
if (!removeToClasses) {
|
66
|
+
removeClasses(targetElement, enterToClasses);
|
67
|
+
}
|
68
|
+
await transition(targetElement, leaveFromClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
|
69
|
+
if (!!hiddenClass) {
|
70
|
+
targetElement.classList.add(hiddenClass);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
function toggleTransition(event) {
|
74
|
+
controllerToggleTransition && controllerToggleTransition(event);
|
75
|
+
if (controller.transitioned) {
|
76
|
+
leave();
|
77
|
+
} else {
|
78
|
+
enter();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
async function transition(element, initialClasses, activeClasses, endClasses, hiddenClass, preserveOriginalClass, removeEndClasses) {
|
82
|
+
const stashedClasses = [];
|
83
|
+
if (preserveOriginalClass) {
|
84
|
+
initialClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
85
|
+
activeClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
86
|
+
endClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
87
|
+
}
|
88
|
+
addClasses(element, initialClasses);
|
89
|
+
removeClasses(element, stashedClasses);
|
90
|
+
addClasses(element, activeClasses);
|
91
|
+
await nextAnimationFrame();
|
92
|
+
removeClasses(element, initialClasses);
|
93
|
+
addClasses(element, endClasses);
|
94
|
+
await afterTransition(element);
|
95
|
+
removeClasses(element, activeClasses);
|
96
|
+
if (removeEndClasses) {
|
97
|
+
removeClasses(element, endClasses);
|
98
|
+
}
|
99
|
+
addClasses(element, stashedClasses);
|
100
|
+
}
|
101
|
+
function initialState() {
|
102
|
+
controller.transitioned = transitioned;
|
103
|
+
if (transitioned) {
|
104
|
+
if (!!hiddenClass) {
|
105
|
+
targetElement.classList.remove(hiddenClass);
|
106
|
+
}
|
107
|
+
enter();
|
108
|
+
} else {
|
109
|
+
if (!!hiddenClass) {
|
110
|
+
targetElement.classList.add(hiddenClass);
|
111
|
+
}
|
112
|
+
leave();
|
113
|
+
}
|
114
|
+
}
|
115
|
+
function addClasses(element, classes) {
|
116
|
+
if (classes.length > 0) {
|
117
|
+
element.classList.add(...classes);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
function removeClasses(element, classes) {
|
121
|
+
if (classes.length > 0) {
|
122
|
+
element.classList.remove(...classes);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
initialState();
|
126
|
+
Object.assign(controller, {
|
127
|
+
enter: enter,
|
128
|
+
leave: leave,
|
129
|
+
toggleTransition: toggleTransition
|
130
|
+
});
|
131
|
+
return [ enter, leave, toggleTransition ];
|
132
|
+
};
|
133
|
+
|
134
|
+
function getAttribute(name, options, dataset) {
|
135
|
+
const datasetName = `transition${name[0].toUpperCase()}${name.substr(1)}`;
|
136
|
+
const datasetAlpineName = alpineNames[name];
|
137
|
+
const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || " ";
|
138
|
+
return isEmpty(classes) ? [] : classes.split(" ");
|
139
|
+
}
|
140
|
+
|
141
|
+
async function afterTransition(element) {
|
142
|
+
return new Promise((resolve => {
|
143
|
+
const duration = Number(getComputedStyle(element).transitionDuration.split(",")[0].replace("s", "")) * 1e3;
|
144
|
+
setTimeout((() => {
|
145
|
+
resolve(duration);
|
146
|
+
}), duration);
|
147
|
+
}));
|
148
|
+
}
|
149
|
+
|
150
|
+
async function nextAnimationFrame() {
|
151
|
+
return new Promise((resolve => {
|
152
|
+
requestAnimationFrame((() => {
|
153
|
+
requestAnimationFrame(resolve);
|
154
|
+
}));
|
155
|
+
}));
|
156
|
+
}
|
157
|
+
|
158
|
+
function isEmpty(str) {
|
159
|
+
return str.length === 0 || !str.trim();
|
160
|
+
}
|
161
|
+
|
5
162
|
function debounce$1(fn, wait) {
|
6
163
|
let timeoutId;
|
7
164
|
return (...args) => {
|
@@ -165,6 +322,23 @@ class Button extends Controller {
|
|
165
322
|
}
|
166
323
|
}
|
167
324
|
|
325
|
+
class Collapsible extends Controller {
|
326
|
+
toggle() {
|
327
|
+
if (this.isClosed) {
|
328
|
+
this.element.style.maxHeight = "none";
|
329
|
+
this.element.style.overflow = "visible";
|
330
|
+
this.element.classList.remove("Polaris-Collapsible--isFullyClosed");
|
331
|
+
} else {
|
332
|
+
this.element.style.maxHeight = "0px";
|
333
|
+
this.element.style.overflow = "hidden";
|
334
|
+
this.element.classList.add("Polaris-Collapsible--isFullyClosed");
|
335
|
+
}
|
336
|
+
}
|
337
|
+
get isClosed() {
|
338
|
+
return this.element.classList.contains("Polaris-Collapsible--isFullyClosed");
|
339
|
+
}
|
340
|
+
}
|
341
|
+
|
168
342
|
const dragEvents = [ "dragover", "dragenter", "drop" ];
|
169
343
|
|
170
344
|
const SIZES = {
|
@@ -285,6 +459,7 @@ class Dropzone extends Controller {
|
|
285
459
|
onDirectUploadsEnd=() => {
|
286
460
|
this.enable();
|
287
461
|
this.clearFiles();
|
462
|
+
if (this.acceptedFiles.length === 0) return;
|
288
463
|
this.loaderTarget.classList.remove("Polaris--hidden");
|
289
464
|
};
|
290
465
|
onDirectUploadInitialize=event => {
|
@@ -292,9 +467,15 @@ class Dropzone extends Controller {
|
|
292
467
|
const {id: id, file: file} = detail;
|
293
468
|
const dropzone = target.closest(".Polaris-DropZone");
|
294
469
|
if (!dropzone) return;
|
295
|
-
|
296
|
-
|
297
|
-
|
470
|
+
if (this.acceptedFiles.length === 0) return;
|
471
|
+
if (this.sizeValue == "small") {
|
472
|
+
this.clearFiles();
|
473
|
+
this.loaderTarget.classList.remove("Polaris--hidden");
|
474
|
+
} else {
|
475
|
+
const content = dropzone.querySelector(`[data-file-name="${file.name}"]`);
|
476
|
+
const progressBar = content.parentElement.querySelector('[data-target="progress-bar"]');
|
477
|
+
progressBar.id = `direct-upload-${id}`;
|
478
|
+
}
|
298
479
|
};
|
299
480
|
onDirectUploadStart=event => {
|
300
481
|
const {id: id} = event.detail;
|
@@ -364,6 +545,7 @@ class Dropzone extends Controller {
|
|
364
545
|
this.toggleFileUpload(false);
|
365
546
|
this.toggleErrorOverlay(true);
|
366
547
|
const dropRejectedEvent = new CustomEvent("polaris-dropzone:drop-rejected", {
|
548
|
+
bubbles: true,
|
367
549
|
detail: {
|
368
550
|
rejectedFiles: this.rejectedFiles
|
369
551
|
}
|
@@ -376,6 +558,7 @@ class Dropzone extends Controller {
|
|
376
558
|
}
|
377
559
|
this.toggleErrorOverlay(false);
|
378
560
|
const dropAcceptedEvent = new CustomEvent("polaris-dropzone:drop-accepted", {
|
561
|
+
bubbles: true,
|
379
562
|
detail: {
|
380
563
|
acceptedFiles: this.acceptedFiles
|
381
564
|
}
|
@@ -383,6 +566,7 @@ class Dropzone extends Controller {
|
|
383
566
|
this.element.dispatchEvent(dropAcceptedEvent);
|
384
567
|
}
|
385
568
|
const dropEvent = new CustomEvent("polaris-dropzone:drop", {
|
569
|
+
bubbles: true,
|
386
570
|
detail: {
|
387
571
|
files: this.files,
|
388
572
|
acceptedFiles: this.acceptedFiles,
|
@@ -547,163 +731,6 @@ function isChangeEvent(event) {
|
|
547
731
|
return event.type === "change";
|
548
732
|
}
|
549
733
|
|
550
|
-
const alpineNames = {
|
551
|
-
enterFromClass: "enter",
|
552
|
-
enterActiveClass: "enterStart",
|
553
|
-
enterToClass: "enterEnd",
|
554
|
-
leaveFromClass: "leave",
|
555
|
-
leaveActiveClass: "leaveStart",
|
556
|
-
leaveToClass: "leaveEnd"
|
557
|
-
};
|
558
|
-
|
559
|
-
const defaultOptions = {
|
560
|
-
transitioned: false,
|
561
|
-
hiddenClass: "hidden",
|
562
|
-
preserveOriginalClass: true,
|
563
|
-
removeToClasses: true
|
564
|
-
};
|
565
|
-
|
566
|
-
const useTransition = (controller, options = {}) => {
|
567
|
-
var _a, _b, _c;
|
568
|
-
const targetName = controller.element.dataset.transitionTarget;
|
569
|
-
let targetFromAttribute;
|
570
|
-
if (targetName) {
|
571
|
-
targetFromAttribute = controller[`${targetName}Target`];
|
572
|
-
}
|
573
|
-
const targetElement = (options === null || options === void 0 ? void 0 : options.element) || targetFromAttribute || controller.element;
|
574
|
-
if (!(targetElement instanceof HTMLElement || targetElement instanceof SVGElement)) return;
|
575
|
-
const dataset = targetElement.dataset;
|
576
|
-
const leaveAfter = parseInt(dataset.leaveAfter || "") || options.leaveAfter || 0;
|
577
|
-
const {transitioned: transitioned, hiddenClass: hiddenClass, preserveOriginalClass: preserveOriginalClass, removeToClasses: removeToClasses} = Object.assign(defaultOptions, options);
|
578
|
-
const controllerEnter = (_a = controller.enter) === null || _a === void 0 ? void 0 : _a.bind(controller);
|
579
|
-
const controllerLeave = (_b = controller.leave) === null || _b === void 0 ? void 0 : _b.bind(controller);
|
580
|
-
const controllerToggleTransition = (_c = controller.toggleTransition) === null || _c === void 0 ? void 0 : _c.bind(controller);
|
581
|
-
async function enter(event) {
|
582
|
-
if (controller.transitioned) return;
|
583
|
-
controller.transitioned = true;
|
584
|
-
controllerEnter && controllerEnter(event);
|
585
|
-
const enterFromClasses = getAttribute("enterFrom", options, dataset);
|
586
|
-
const enterActiveClasses = getAttribute("enterActive", options, dataset);
|
587
|
-
const enterToClasses = getAttribute("enterTo", options, dataset);
|
588
|
-
const leaveToClasses = getAttribute("leaveTo", options, dataset);
|
589
|
-
if (!!hiddenClass) {
|
590
|
-
targetElement.classList.remove(hiddenClass);
|
591
|
-
}
|
592
|
-
if (!removeToClasses) {
|
593
|
-
removeClasses(targetElement, leaveToClasses);
|
594
|
-
}
|
595
|
-
await transition(targetElement, enterFromClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
|
596
|
-
if (leaveAfter > 0) {
|
597
|
-
setTimeout((() => {
|
598
|
-
leave(event);
|
599
|
-
}), leaveAfter);
|
600
|
-
}
|
601
|
-
}
|
602
|
-
async function leave(event) {
|
603
|
-
if (!controller.transitioned) return;
|
604
|
-
controller.transitioned = false;
|
605
|
-
controllerLeave && controllerLeave(event);
|
606
|
-
const leaveFromClasses = getAttribute("leaveFrom", options, dataset);
|
607
|
-
const leaveActiveClasses = getAttribute("leaveActive", options, dataset);
|
608
|
-
const leaveToClasses = getAttribute("leaveTo", options, dataset);
|
609
|
-
const enterToClasses = getAttribute("enterTo", options, dataset);
|
610
|
-
if (!removeToClasses) {
|
611
|
-
removeClasses(targetElement, enterToClasses);
|
612
|
-
}
|
613
|
-
await transition(targetElement, leaveFromClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
|
614
|
-
if (!!hiddenClass) {
|
615
|
-
targetElement.classList.add(hiddenClass);
|
616
|
-
}
|
617
|
-
}
|
618
|
-
function toggleTransition(event) {
|
619
|
-
controllerToggleTransition && controllerToggleTransition(event);
|
620
|
-
if (controller.transitioned) {
|
621
|
-
leave();
|
622
|
-
} else {
|
623
|
-
enter();
|
624
|
-
}
|
625
|
-
}
|
626
|
-
async function transition(element, initialClasses, activeClasses, endClasses, hiddenClass, preserveOriginalClass, removeEndClasses) {
|
627
|
-
const stashedClasses = [];
|
628
|
-
if (preserveOriginalClass) {
|
629
|
-
initialClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
630
|
-
activeClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
631
|
-
endClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
|
632
|
-
}
|
633
|
-
addClasses(element, initialClasses);
|
634
|
-
removeClasses(element, stashedClasses);
|
635
|
-
addClasses(element, activeClasses);
|
636
|
-
await nextAnimationFrame();
|
637
|
-
removeClasses(element, initialClasses);
|
638
|
-
addClasses(element, endClasses);
|
639
|
-
await afterTransition(element);
|
640
|
-
removeClasses(element, activeClasses);
|
641
|
-
if (removeEndClasses) {
|
642
|
-
removeClasses(element, endClasses);
|
643
|
-
}
|
644
|
-
addClasses(element, stashedClasses);
|
645
|
-
}
|
646
|
-
function initialState() {
|
647
|
-
controller.transitioned = transitioned;
|
648
|
-
if (transitioned) {
|
649
|
-
if (!!hiddenClass) {
|
650
|
-
targetElement.classList.remove(hiddenClass);
|
651
|
-
}
|
652
|
-
enter();
|
653
|
-
} else {
|
654
|
-
if (!!hiddenClass) {
|
655
|
-
targetElement.classList.add(hiddenClass);
|
656
|
-
}
|
657
|
-
leave();
|
658
|
-
}
|
659
|
-
}
|
660
|
-
function addClasses(element, classes) {
|
661
|
-
if (classes.length > 0) {
|
662
|
-
element.classList.add(...classes);
|
663
|
-
}
|
664
|
-
}
|
665
|
-
function removeClasses(element, classes) {
|
666
|
-
if (classes.length > 0) {
|
667
|
-
element.classList.remove(...classes);
|
668
|
-
}
|
669
|
-
}
|
670
|
-
initialState();
|
671
|
-
Object.assign(controller, {
|
672
|
-
enter: enter,
|
673
|
-
leave: leave,
|
674
|
-
toggleTransition: toggleTransition
|
675
|
-
});
|
676
|
-
return [ enter, leave, toggleTransition ];
|
677
|
-
};
|
678
|
-
|
679
|
-
function getAttribute(name, options, dataset) {
|
680
|
-
const datasetName = `transition${name[0].toUpperCase()}${name.substr(1)}`;
|
681
|
-
const datasetAlpineName = alpineNames[name];
|
682
|
-
const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || " ";
|
683
|
-
return isEmpty(classes) ? [] : classes.split(" ");
|
684
|
-
}
|
685
|
-
|
686
|
-
async function afterTransition(element) {
|
687
|
-
return new Promise((resolve => {
|
688
|
-
const duration = Number(getComputedStyle(element).transitionDuration.split(",")[0].replace("s", "")) * 1e3;
|
689
|
-
setTimeout((() => {
|
690
|
-
resolve(duration);
|
691
|
-
}), duration);
|
692
|
-
}));
|
693
|
-
}
|
694
|
-
|
695
|
-
async function nextAnimationFrame() {
|
696
|
-
return new Promise((resolve => {
|
697
|
-
requestAnimationFrame((() => {
|
698
|
-
requestAnimationFrame(resolve);
|
699
|
-
}));
|
700
|
-
}));
|
701
|
-
}
|
702
|
-
|
703
|
-
function isEmpty(str) {
|
704
|
-
return str.length === 0 || !str.trim();
|
705
|
-
}
|
706
|
-
|
707
734
|
class Frame extends Controller {
|
708
735
|
static targets=[ "navigationOverlay", "navigation", "saveBar" ];
|
709
736
|
connect() {
|
@@ -803,6 +830,9 @@ class Polaris extends Controller {
|
|
803
830
|
showToast() {
|
804
831
|
this.findElement("toast").show();
|
805
832
|
}
|
833
|
+
toggleCollapsible() {
|
834
|
+
this.findElement("collapsible").toggle();
|
835
|
+
}
|
806
836
|
findElement(type) {
|
807
837
|
const targetId = this.element.dataset.target.replace("#", "");
|
808
838
|
const target = document.getElementById(targetId);
|
@@ -2372,7 +2402,11 @@ class TextField extends Controller {
|
|
2372
2402
|
this.valueValue = this.inputTarget.value;
|
2373
2403
|
}
|
2374
2404
|
clear() {
|
2405
|
+
const oldValue = this.value;
|
2375
2406
|
this.value = null;
|
2407
|
+
if (this.value != oldValue) {
|
2408
|
+
this.inputTarget.dispatchEvent(new Event("change"));
|
2409
|
+
}
|
2376
2410
|
}
|
2377
2411
|
increase() {
|
2378
2412
|
this.changeNumber(1);
|
@@ -2465,8 +2499,9 @@ class Toast extends Controller {
|
|
2465
2499
|
this.element.removeEventListener("transitionend", this.updatePositions, false);
|
2466
2500
|
};
|
2467
2501
|
getStyle(position) {
|
2468
|
-
const
|
2469
|
-
const
|
2502
|
+
const height = this.element.offsetHeight + this.heightOffset;
|
2503
|
+
const translateIn = height * -1;
|
2504
|
+
const translateOut = 150 - height;
|
2470
2505
|
return `--toast-translate-y-in: ${translateIn}px; --toast-translate-y-out: ${translateOut}px;`;
|
2471
2506
|
}
|
2472
2507
|
get timeoutDuration() {
|
@@ -2487,11 +2522,15 @@ class Toast extends Controller {
|
|
2487
2522
|
get position() {
|
2488
2523
|
return this.visibleToasts.filter((el => !this.element.isEqualNode(el))).length + 1;
|
2489
2524
|
}
|
2525
|
+
get heightOffset() {
|
2526
|
+
return this.visibleToasts.filter((el => !this.element.isEqualNode(el) && this.element.dataset.position > el.dataset.position)).map((el => el.offsetHeight)).reduce(((a, b) => a + b), 0);
|
2527
|
+
}
|
2490
2528
|
}
|
2491
2529
|
|
2492
2530
|
function registerPolarisControllers(application) {
|
2493
2531
|
application.register("polaris-autocomplete", Autocomplete);
|
2494
2532
|
application.register("polaris-button", Button);
|
2533
|
+
application.register("polaris-collapsible", Collapsible);
|
2495
2534
|
application.register("polaris-dropzone", Dropzone);
|
2496
2535
|
application.register("polaris-frame", Frame);
|
2497
2536
|
application.register("polaris-modal", Modal);
|
@@ -116,6 +116,15 @@ a.Polaris-Tag__Button {
|
|
116
116
|
justify-content: center;
|
117
117
|
}
|
118
118
|
|
119
|
+
&--sizeMedium {
|
120
|
+
justify-content: center;
|
121
|
+
text-align: center;
|
122
|
+
|
123
|
+
.Polaris-Stack.Polaris-Stack--alignmentCenter {
|
124
|
+
justify-content: center;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
119
128
|
&--sizeSmall {
|
120
129
|
padding: 0;
|
121
130
|
justify-content: center;
|
@@ -137,5 +146,33 @@ a.Polaris-Tag__Button {
|
|
137
146
|
align-items: center;
|
138
147
|
text-align: center;
|
139
148
|
justify-content: center;
|
149
|
+
|
150
|
+
.Polaris-Spinner--sizeSmall {
|
151
|
+
height: 20px;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
/* ActionMenu */
|
157
|
+
.Polaris-ActionMenu {
|
158
|
+
&--mobile {
|
159
|
+
@media (min-width: 768px){
|
160
|
+
display: none;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
&--desktop {
|
165
|
+
display: none;
|
166
|
+
|
167
|
+
@media (min-width: 768px){
|
168
|
+
display: block;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
/* Page Pagination */
|
174
|
+
@media (max-width: 768px){
|
175
|
+
.Polaris-Page-Header__PaginationWrapper {
|
176
|
+
display: none;
|
140
177
|
}
|
141
178
|
}
|