polaris_view_components 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +9 -3
- data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +10 -4
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +39 -13
- data/app/assets/javascripts/polaris_view_components.js +101 -53
- data/app/components/polaris/autocomplete_component.html.erb +3 -0
- data/app/components/polaris/autocomplete_component.rb +3 -0
- data/app/components/polaris/button_component.html.erb +2 -0
- data/app/components/polaris/card/header_component.html.erb +4 -2
- data/app/components/polaris/data_table_component.html.erb +5 -2
- data/app/components/polaris/data_table_component.rb +10 -0
- data/app/components/polaris/dropzone_component.html.erb +33 -29
- data/app/components/polaris/dropzone_component.rb +4 -1
- data/app/components/polaris/empty_search_results_component.html.erb +6 -3
- data/app/components/polaris/empty_search_results_component.rb +3 -1
- data/app/components/polaris/headless_button.html.erb +2 -0
- data/app/components/polaris/headless_button.rb +1 -1
- data/app/components/polaris/popover_component.html.erb +26 -16
- data/app/components/polaris/popover_component.rb +6 -1
- data/app/components/polaris/resource_item/shortcut_actions_component.html.erb +21 -0
- data/app/components/polaris/resource_item/shortcut_actions_component.rb +88 -0
- data/app/components/polaris/resource_item_component.html.erb +3 -0
- data/app/components/polaris/resource_item_component.rb +11 -1
- data/app/components/polaris/skeleton_page_component.html.erb +23 -0
- data/app/components/polaris/skeleton_page_component.rb +22 -0
- data/app/helpers/polaris/view_helper.rb +1 -0
- data/lib/polaris/view_components/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6ac82b9541cc182ed79f45d4850e23a0afe6255e3b94d0071c2cc9716dc81e8
|
4
|
+
data.tar.gz: 48de38d93d9d972eb4becc326242ea894ea56532f68e0527339ac0647ee662f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20b0f280d097398cf7793b35ddf77d8dfcdafea0039dd5114e1261fafa62d7bad528b1e3b83ac0015dce4af3619459f711b16bbeb85429f428d5766b1457b82d
|
7
|
+
data.tar.gz: 5d187b4045398761dc1dfd1052965220ee80888a5ef17a3cef8eba19e6632ecf633497275f0833bd36c1e8ff0e0cb22d1fd11a8f0639ff0d2ba4a70a9881da88
|
data/README.md
CHANGED
@@ -42,10 +42,17 @@ bin/rails polaris_view_components:install
|
|
42
42
|
To get started:
|
43
43
|
|
44
44
|
1. Run: `bundle install`
|
45
|
-
|
45
|
+
1. Run: `yarn install`
|
46
|
+
1. Run: `bin/dev`
|
46
47
|
|
47
48
|
It will open demo app with component previews on `localhost:4000`. You can change components and they will be updated on page reload. Component previews located in `demo/test/components/previews`.
|
48
49
|
|
50
|
+
To run tests:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
rake
|
54
|
+
```
|
55
|
+
|
49
56
|
## Releases
|
50
57
|
|
51
58
|
The library follows [semantic versioning](https://semver.org/). To draft a new release you need to run `script/release` with a new version number:
|
@@ -3,8 +3,8 @@ import { get } from '@rails/request.js'
|
|
3
3
|
import { debounce } from './utils'
|
4
4
|
|
5
5
|
export default class extends Controller {
|
6
|
-
static targets = ['popover', 'input', 'results', 'option', 'emptyState']
|
7
|
-
static values = { url: String, selected: Array }
|
6
|
+
static targets = ['popover', 'input', 'hiddenInput', 'results', 'option', 'emptyState']
|
7
|
+
static values = { multiple: Boolean, url: String, selected: Array }
|
8
8
|
|
9
9
|
connect() {
|
10
10
|
this.inputTarget.addEventListener("input", this.onInputChange)
|
@@ -32,6 +32,12 @@ export default class extends Controller {
|
|
32
32
|
})
|
33
33
|
|
34
34
|
this.element.dispatchEvent(changeEvent)
|
35
|
+
|
36
|
+
if (!this.multipleValue) {
|
37
|
+
this.popoverController.forceHide()
|
38
|
+
this.inputTarget.value = label
|
39
|
+
this.hiddenInputTarget.value = input.value
|
40
|
+
}
|
35
41
|
}
|
36
42
|
|
37
43
|
onInputChange = debounce(() => {
|
@@ -65,7 +71,7 @@ export default class extends Controller {
|
|
65
71
|
}
|
66
72
|
|
67
73
|
get visibleOptions() {
|
68
|
-
return this.optionTargets.filter(option => {
|
74
|
+
return [...this.optionTargets].filter(option => {
|
69
75
|
return !option.classList.contains('Polaris--hidden')
|
70
76
|
})
|
71
77
|
}
|
@@ -30,7 +30,8 @@ export default class extends Controller {
|
|
30
30
|
dropOnPage: Boolean,
|
31
31
|
focused: Boolean,
|
32
32
|
renderPreview: Boolean,
|
33
|
-
size: String
|
33
|
+
size: String,
|
34
|
+
removePreviewsAfterUpload: Boolean
|
34
35
|
}
|
35
36
|
|
36
37
|
files = []
|
@@ -164,7 +165,7 @@ export default class extends Controller {
|
|
164
165
|
|
165
166
|
onDirectUploadsEnd = () => {
|
166
167
|
this.enable()
|
167
|
-
this.clearFiles()
|
168
|
+
this.clearFiles(this.removePreviewsAfterUploadValue)
|
168
169
|
|
169
170
|
if (this.acceptedFiles.length === 0) return
|
170
171
|
|
@@ -180,7 +181,7 @@ export default class extends Controller {
|
|
180
181
|
if (this.acceptedFiles.length === 0) return
|
181
182
|
|
182
183
|
if (this.sizeValue == 'small') {
|
183
|
-
this.
|
184
|
+
this.removePreview()
|
184
185
|
if (this.hasLoaderTarget)
|
185
186
|
this.loaderTarget.classList.remove("Polaris--hidden")
|
186
187
|
} else {
|
@@ -358,13 +359,18 @@ export default class extends Controller {
|
|
358
359
|
return clone
|
359
360
|
}
|
360
361
|
|
361
|
-
clearFiles () {
|
362
|
+
clearFiles (removePreview = true) {
|
362
363
|
if (!this.previewRendered) return
|
363
364
|
|
364
365
|
this.acceptedFiles = []
|
365
366
|
this.files = []
|
366
367
|
this.rejectedFiles = []
|
367
368
|
|
369
|
+
if (removePreview)
|
370
|
+
this.removePreview()
|
371
|
+
}
|
372
|
+
|
373
|
+
removePreview () {
|
368
374
|
if (!this.hasPreviewTarget) return
|
369
375
|
|
370
376
|
this.previewTarget.remove()
|
@@ -2,15 +2,16 @@ import { Controller } from "@hotwired/stimulus"
|
|
2
2
|
import { createPopper } from "@popperjs/core/dist/esm"
|
3
3
|
|
4
4
|
export default class extends Controller {
|
5
|
-
static targets = ["activator", "popover"]
|
5
|
+
static targets = ["activator", "popover", "template"]
|
6
6
|
static classes = ["open", "closed"]
|
7
7
|
static values = {
|
8
|
+
appendToBody: Boolean,
|
8
9
|
placement: String,
|
9
10
|
active: Boolean
|
10
11
|
}
|
11
12
|
|
12
13
|
connect() {
|
13
|
-
|
14
|
+
const popperOptions = {
|
14
15
|
placement: this.placementValue,
|
15
16
|
modifiers: [
|
16
17
|
{
|
@@ -26,31 +27,56 @@ export default class extends Controller {
|
|
26
27
|
},
|
27
28
|
}
|
28
29
|
]
|
29
|
-
}
|
30
|
+
}
|
31
|
+
|
32
|
+
if (this.appendToBodyValue) {
|
33
|
+
const clonedTemplate = this.templateTarget.content.cloneNode(true)
|
34
|
+
this.target = clonedTemplate.firstElementChild
|
35
|
+
popperOptions['strategy'] = 'fixed'
|
36
|
+
|
37
|
+
document.body.appendChild(clonedTemplate)
|
38
|
+
}
|
39
|
+
|
40
|
+
this.popper = createPopper(this.activatorTarget, this.target, popperOptions)
|
30
41
|
if (this.activeValue) {
|
31
42
|
this.show()
|
32
43
|
}
|
33
44
|
}
|
34
45
|
|
35
|
-
toggle() {
|
36
|
-
this.
|
37
|
-
this.
|
46
|
+
async toggle() {
|
47
|
+
this.target.classList.toggle(this.closedClass)
|
48
|
+
this.target.classList.toggle(this.openClass)
|
49
|
+
await this.popper.update()
|
38
50
|
}
|
39
51
|
|
40
52
|
async show() {
|
41
|
-
this.
|
42
|
-
this.
|
53
|
+
this.target.classList.remove(this.closedClass)
|
54
|
+
this.target.classList.add(this.openClass)
|
43
55
|
await this.popper.update()
|
44
56
|
}
|
45
57
|
|
46
58
|
hide(event) {
|
47
|
-
if (
|
48
|
-
|
49
|
-
|
59
|
+
if (this.element.contains(event.target)) return
|
60
|
+
if (this.target.classList.contains(this.closedClass)) return
|
61
|
+
if (this.appendToBodyValue && this.target.contains(event.target)) return
|
62
|
+
|
63
|
+
this.forceHide()
|
50
64
|
}
|
51
65
|
|
52
66
|
forceHide() {
|
53
|
-
this.
|
54
|
-
this.
|
67
|
+
this.target.classList.remove(this.openClass)
|
68
|
+
this.target.classList.add(this.closedClass)
|
69
|
+
}
|
70
|
+
|
71
|
+
get target() {
|
72
|
+
if (this.hasPopoverTarget) {
|
73
|
+
return this.popoverTarget
|
74
|
+
} else {
|
75
|
+
return this._target
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
set target(value) {
|
80
|
+
this._target = value
|
55
81
|
}
|
56
82
|
}
|
@@ -174,8 +174,9 @@ function formatBytes(bytes, decimals) {
|
|
174
174
|
}
|
175
175
|
|
176
176
|
class Autocomplete extends Controller {
|
177
|
-
static targets=[ "popover", "input", "results", "option", "emptyState" ];
|
177
|
+
static targets=[ "popover", "input", "hiddenInput", "results", "option", "emptyState" ];
|
178
178
|
static values={
|
179
|
+
multiple: Boolean,
|
179
180
|
url: String,
|
180
181
|
selected: Array
|
181
182
|
};
|
@@ -203,6 +204,11 @@ class Autocomplete extends Controller {
|
|
203
204
|
}
|
204
205
|
});
|
205
206
|
this.element.dispatchEvent(changeEvent);
|
207
|
+
if (!this.multipleValue) {
|
208
|
+
this.popoverController.forceHide();
|
209
|
+
this.inputTarget.value = label;
|
210
|
+
this.hiddenInputTarget.value = input.value;
|
211
|
+
}
|
206
212
|
}
|
207
213
|
onInputChange=debounce$1((() => {
|
208
214
|
if (this.isRemote) {
|
@@ -228,7 +234,7 @@ class Autocomplete extends Controller {
|
|
228
234
|
return this.inputTarget.value;
|
229
235
|
}
|
230
236
|
get visibleOptions() {
|
231
|
-
return this.optionTargets.filter((option => !option.classList.contains("Polaris--hidden")));
|
237
|
+
return [ ...this.optionTargets ].filter((option => !option.classList.contains("Polaris--hidden")));
|
232
238
|
}
|
233
239
|
handleResults() {
|
234
240
|
if (this.visibleOptions.length > 0) {
|
@@ -358,7 +364,8 @@ class Dropzone extends Controller {
|
|
358
364
|
dropOnPage: Boolean,
|
359
365
|
focused: Boolean,
|
360
366
|
renderPreview: Boolean,
|
361
|
-
size: String
|
367
|
+
size: String,
|
368
|
+
removePreviewsAfterUpload: Boolean
|
362
369
|
};
|
363
370
|
files=[];
|
364
371
|
rejectedFiles=[];
|
@@ -458,7 +465,7 @@ class Dropzone extends Controller {
|
|
458
465
|
};
|
459
466
|
onDirectUploadsEnd=() => {
|
460
467
|
this.enable();
|
461
|
-
this.clearFiles();
|
468
|
+
this.clearFiles(this.removePreviewsAfterUploadValue);
|
462
469
|
if (this.acceptedFiles.length === 0) return;
|
463
470
|
if (this.hasLoaderTarget) this.loaderTarget.classList.remove("Polaris--hidden");
|
464
471
|
};
|
@@ -469,7 +476,7 @@ class Dropzone extends Controller {
|
|
469
476
|
if (!dropzone) return;
|
470
477
|
if (this.acceptedFiles.length === 0) return;
|
471
478
|
if (this.sizeValue == "small") {
|
472
|
-
this.
|
479
|
+
this.removePreview();
|
473
480
|
if (this.hasLoaderTarget) this.loaderTarget.classList.remove("Polaris--hidden");
|
474
481
|
} else {
|
475
482
|
const content = dropzone.querySelector(`[data-file-name="${file.name}"]`);
|
@@ -614,11 +621,14 @@ class Dropzone extends Controller {
|
|
614
621
|
}
|
615
622
|
return clone;
|
616
623
|
}
|
617
|
-
clearFiles() {
|
624
|
+
clearFiles(removePreview = true) {
|
618
625
|
if (!this.previewRendered) return;
|
619
626
|
this.acceptedFiles = [];
|
620
627
|
this.files = [];
|
621
628
|
this.rejectedFiles = [];
|
629
|
+
if (removePreview) this.removePreview();
|
630
|
+
}
|
631
|
+
removePreview() {
|
622
632
|
if (!this.hasPreviewTarget) return;
|
623
633
|
this.previewTarget.remove();
|
624
634
|
this.previewRendered = false;
|
@@ -1016,32 +1026,49 @@ var min = Math.min;
|
|
1016
1026
|
|
1017
1027
|
var round = Math.round;
|
1018
1028
|
|
1019
|
-
function
|
1029
|
+
function getUAString() {
|
1030
|
+
var uaData = navigator.userAgentData;
|
1031
|
+
if (uaData != null && uaData.brands) {
|
1032
|
+
return uaData.brands.map((function(item) {
|
1033
|
+
return item.brand + "/" + item.version;
|
1034
|
+
})).join(" ");
|
1035
|
+
}
|
1036
|
+
return navigator.userAgent;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
function isLayoutViewport() {
|
1040
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
1020
1044
|
if (includeScale === void 0) {
|
1021
1045
|
includeScale = false;
|
1022
1046
|
}
|
1023
|
-
|
1047
|
+
if (isFixedStrategy === void 0) {
|
1048
|
+
isFixedStrategy = false;
|
1049
|
+
}
|
1050
|
+
var clientRect = element.getBoundingClientRect();
|
1024
1051
|
var scaleX = 1;
|
1025
1052
|
var scaleY = 1;
|
1026
|
-
if (isHTMLElement(element)
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1053
|
+
if (includeScale && isHTMLElement(element)) {
|
1054
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
1055
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
1056
|
+
}
|
1057
|
+
var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
1058
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
1059
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
1060
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
1061
|
+
var width = clientRect.width / scaleX;
|
1062
|
+
var height = clientRect.height / scaleY;
|
1036
1063
|
return {
|
1037
|
-
width:
|
1038
|
-
height:
|
1039
|
-
top:
|
1040
|
-
right:
|
1041
|
-
bottom:
|
1042
|
-
left:
|
1043
|
-
x:
|
1044
|
-
y:
|
1064
|
+
width: width,
|
1065
|
+
height: height,
|
1066
|
+
top: y,
|
1067
|
+
right: x + width,
|
1068
|
+
bottom: y + height,
|
1069
|
+
left: x,
|
1070
|
+
x: x,
|
1071
|
+
y: y
|
1045
1072
|
};
|
1046
1073
|
}
|
1047
1074
|
|
@@ -1106,8 +1133,8 @@ function getTrueOffsetParent(element) {
|
|
1106
1133
|
}
|
1107
1134
|
|
1108
1135
|
function getContainingBlock(element) {
|
1109
|
-
var isFirefox =
|
1110
|
-
var isIE =
|
1136
|
+
var isFirefox = /firefox/i.test(getUAString());
|
1137
|
+
var isIE = /Trident/i.test(getUAString());
|
1111
1138
|
if (isIE && isHTMLElement(element)) {
|
1112
1139
|
var elementCss = getComputedStyle$1(element);
|
1113
1140
|
if (elementCss.position === "fixed") {
|
@@ -1441,7 +1468,7 @@ function getWindowScrollBarX(element) {
|
|
1441
1468
|
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
1442
1469
|
}
|
1443
1470
|
|
1444
|
-
function getViewportRect(element) {
|
1471
|
+
function getViewportRect(element, strategy) {
|
1445
1472
|
var win = getWindow(element);
|
1446
1473
|
var html = getDocumentElement(element);
|
1447
1474
|
var visualViewport = win.visualViewport;
|
@@ -1452,7 +1479,8 @@ function getViewportRect(element) {
|
|
1452
1479
|
if (visualViewport) {
|
1453
1480
|
width = visualViewport.width;
|
1454
1481
|
height = visualViewport.height;
|
1455
|
-
|
1482
|
+
var layoutViewport = isLayoutViewport();
|
1483
|
+
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
1456
1484
|
x = visualViewport.offsetLeft;
|
1457
1485
|
y = visualViewport.offsetTop;
|
1458
1486
|
}
|
@@ -1522,8 +1550,8 @@ function rectToClientRect(rect) {
|
|
1522
1550
|
});
|
1523
1551
|
}
|
1524
1552
|
|
1525
|
-
function getInnerBoundingClientRect(element) {
|
1526
|
-
var rect = getBoundingClientRect(element);
|
1553
|
+
function getInnerBoundingClientRect(element, strategy) {
|
1554
|
+
var rect = getBoundingClientRect(element, false, strategy === "fixed");
|
1527
1555
|
rect.top = rect.top + element.clientTop;
|
1528
1556
|
rect.left = rect.left + element.clientLeft;
|
1529
1557
|
rect.bottom = rect.top + element.clientHeight;
|
@@ -1535,8 +1563,8 @@ function getInnerBoundingClientRect(element) {
|
|
1535
1563
|
return rect;
|
1536
1564
|
}
|
1537
1565
|
|
1538
|
-
function getClientRectFromMixedType(element, clippingParent) {
|
1539
|
-
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
1566
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
1567
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
1540
1568
|
}
|
1541
1569
|
|
1542
1570
|
function getClippingParents(element) {
|
@@ -1551,18 +1579,18 @@ function getClippingParents(element) {
|
|
1551
1579
|
}));
|
1552
1580
|
}
|
1553
1581
|
|
1554
|
-
function getClippingRect(element, boundary, rootBoundary) {
|
1582
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
1555
1583
|
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
|
1556
1584
|
var clippingParents = [].concat(mainClippingParents, [ rootBoundary ]);
|
1557
1585
|
var firstClippingParent = clippingParents[0];
|
1558
1586
|
var clippingRect = clippingParents.reduce((function(accRect, clippingParent) {
|
1559
|
-
var rect = getClientRectFromMixedType(element, clippingParent);
|
1587
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
1560
1588
|
accRect.top = max(rect.top, accRect.top);
|
1561
1589
|
accRect.right = min(rect.right, accRect.right);
|
1562
1590
|
accRect.bottom = min(rect.bottom, accRect.bottom);
|
1563
1591
|
accRect.left = max(rect.left, accRect.left);
|
1564
1592
|
return accRect;
|
1565
|
-
}), getClientRectFromMixedType(element, firstClippingParent));
|
1593
|
+
}), getClientRectFromMixedType(element, firstClippingParent, strategy));
|
1566
1594
|
clippingRect.width = clippingRect.right - clippingRect.left;
|
1567
1595
|
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
1568
1596
|
clippingRect.x = clippingRect.left;
|
@@ -1632,12 +1660,12 @@ function detectOverflow(state, options) {
|
|
1632
1660
|
if (options === void 0) {
|
1633
1661
|
options = {};
|
1634
1662
|
}
|
1635
|
-
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
1663
|
+
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
1636
1664
|
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
1637
1665
|
var altContext = elementContext === popper ? reference : popper;
|
1638
1666
|
var popperRect = state.rects.popper;
|
1639
1667
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
1640
|
-
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
1668
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
1641
1669
|
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
1642
1670
|
var popperOffsets = computeOffsets({
|
1643
1671
|
reference: referenceClientRect,
|
@@ -2040,7 +2068,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
2040
2068
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
2041
2069
|
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
2042
2070
|
var documentElement = getDocumentElement(offsetParent);
|
2043
|
-
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
|
2071
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
2044
2072
|
var scroll = {
|
2045
2073
|
scrollLeft: 0,
|
2046
2074
|
scrollTop: 0
|
@@ -2275,14 +2303,15 @@ var createPopper = popperGenerator({
|
|
2275
2303
|
});
|
2276
2304
|
|
2277
2305
|
class Popover extends Controller {
|
2278
|
-
static targets=[ "activator", "popover" ];
|
2306
|
+
static targets=[ "activator", "popover", "template" ];
|
2279
2307
|
static classes=[ "open", "closed" ];
|
2280
2308
|
static values={
|
2309
|
+
appendToBody: Boolean,
|
2281
2310
|
placement: String,
|
2282
2311
|
active: Boolean
|
2283
2312
|
};
|
2284
2313
|
connect() {
|
2285
|
-
|
2314
|
+
const popperOptions = {
|
2286
2315
|
placement: this.placementValue,
|
2287
2316
|
modifiers: [ {
|
2288
2317
|
name: "offset",
|
@@ -2295,28 +2324,47 @@ class Popover extends Controller {
|
|
2295
2324
|
allowedAutoPlacements: [ "top-start", "bottom-start", "top-end", "bottom-end" ]
|
2296
2325
|
}
|
2297
2326
|
} ]
|
2298
|
-
}
|
2327
|
+
};
|
2328
|
+
if (this.appendToBodyValue) {
|
2329
|
+
const clonedTemplate = this.templateTarget.content.cloneNode(true);
|
2330
|
+
this.target = clonedTemplate.firstElementChild;
|
2331
|
+
popperOptions["strategy"] = "fixed";
|
2332
|
+
document.body.appendChild(clonedTemplate);
|
2333
|
+
}
|
2334
|
+
this.popper = createPopper(this.activatorTarget, this.target, popperOptions);
|
2299
2335
|
if (this.activeValue) {
|
2300
2336
|
this.show();
|
2301
2337
|
}
|
2302
2338
|
}
|
2303
|
-
toggle() {
|
2304
|
-
this.
|
2305
|
-
this.
|
2339
|
+
async toggle() {
|
2340
|
+
this.target.classList.toggle(this.closedClass);
|
2341
|
+
this.target.classList.toggle(this.openClass);
|
2342
|
+
await this.popper.update();
|
2306
2343
|
}
|
2307
2344
|
async show() {
|
2308
|
-
this.
|
2309
|
-
this.
|
2345
|
+
this.target.classList.remove(this.closedClass);
|
2346
|
+
this.target.classList.add(this.openClass);
|
2310
2347
|
await this.popper.update();
|
2311
2348
|
}
|
2312
2349
|
hide(event) {
|
2313
|
-
if (
|
2314
|
-
|
2315
|
-
|
2350
|
+
if (this.element.contains(event.target)) return;
|
2351
|
+
if (this.target.classList.contains(this.closedClass)) return;
|
2352
|
+
if (this.appendToBodyValue && this.target.contains(event.target)) return;
|
2353
|
+
this.forceHide();
|
2316
2354
|
}
|
2317
2355
|
forceHide() {
|
2318
|
-
this.
|
2319
|
-
this.
|
2356
|
+
this.target.classList.remove(this.openClass);
|
2357
|
+
this.target.classList.add(this.closedClass);
|
2358
|
+
}
|
2359
|
+
get target() {
|
2360
|
+
if (this.hasPopoverTarget) {
|
2361
|
+
return this.popoverTarget;
|
2362
|
+
} else {
|
2363
|
+
return this._target;
|
2364
|
+
}
|
2365
|
+
}
|
2366
|
+
set target(value) {
|
2367
|
+
this._target = value;
|
2320
2368
|
}
|
2321
2369
|
}
|
2322
2370
|
|
@@ -2,6 +2,9 @@
|
|
2
2
|
<%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
|
3
3
|
<% popover.activator do %>
|
4
4
|
<%= text_field %>
|
5
|
+
<% if @name.present? %>
|
6
|
+
<%= hidden_field_tag @name, nil, data: {polaris_autocomplete_target: "hiddenInput"} %>
|
7
|
+
<% end %>
|
5
8
|
<% end %>
|
6
9
|
|
7
10
|
<% if empty_state.present? %>
|
@@ -24,11 +24,13 @@ module Polaris
|
|
24
24
|
def initialize(
|
25
25
|
multiple: false,
|
26
26
|
url: nil,
|
27
|
+
name: nil,
|
27
28
|
selected: [],
|
28
29
|
**system_arguments
|
29
30
|
)
|
30
31
|
@multiple = multiple
|
31
32
|
@url = url
|
33
|
+
@name = name
|
32
34
|
@selected = selected
|
33
35
|
@system_arguments = system_arguments
|
34
36
|
end
|
@@ -42,6 +44,7 @@ module Polaris
|
|
42
44
|
opts[:data][:polaris_autocomplete_url_value] = @url
|
43
45
|
end
|
44
46
|
opts[:data][:polaris_autocomplete_selected_value] = @selected
|
47
|
+
opts[:data][:polaris_autocomplete_multiple_value] = @multiple if @multiple.present?
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|
@@ -12,6 +12,7 @@
|
|
12
12
|
header: true,
|
13
13
|
sort_url: column.sort_url,
|
14
14
|
sorted: column.sorted,
|
15
|
+
**column.system_arguments
|
15
16
|
) do %>
|
16
17
|
<%= column.title %>
|
17
18
|
<% end %>
|
@@ -36,18 +37,19 @@
|
|
36
37
|
</thead>
|
37
38
|
<tbody>
|
38
39
|
<% @data.each do |row| %>
|
39
|
-
|
40
|
+
<%= render Polaris::BaseComponent.new(**row_arguments(row)) do %>
|
40
41
|
<% columns.each_with_index do |column, index| %>
|
41
42
|
<%= render_cell(
|
42
43
|
first: index.zero?,
|
43
44
|
numeric: column.numeric,
|
44
45
|
tag: (index.zero? ? "th" : "td"),
|
45
46
|
scope: ("row" if index.zero?),
|
47
|
+
**column.system_arguments
|
46
48
|
) do %>
|
47
49
|
<%= column.call(row) %>
|
48
50
|
<% end %>
|
49
51
|
<% end %>
|
50
|
-
|
52
|
+
<% end %>
|
51
53
|
<% end %>
|
52
54
|
</tbody>
|
53
55
|
<% if @totals_in_footer %>
|
@@ -61,6 +63,7 @@
|
|
61
63
|
scope: ("row" if index.zero?),
|
62
64
|
total: true,
|
63
65
|
total_footer: true,
|
66
|
+
**column.system_arguments
|
64
67
|
) do %>
|
65
68
|
<%= column.total %>
|
66
69
|
<% end %>
|
@@ -35,6 +35,16 @@ module Polaris
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def row_arguments(row)
|
39
|
+
{tag: "tr"}.tap do |args|
|
40
|
+
args[:classes] = class_names(
|
41
|
+
"Polaris-DataTable__TableRow",
|
42
|
+
"Polaris-DataTable--hoverable": @hoverable
|
43
|
+
)
|
44
|
+
args[:id] = dom_id(row) if row.respond_to?(:to_key)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
38
48
|
def render_cell(**arguments, &block)
|
39
49
|
render(DataTable::CellComponent.new(vertical_alignment: @vertical_alignment, **arguments), &block)
|
40
50
|
end
|
@@ -30,39 +30,43 @@
|
|
30
30
|
|
31
31
|
<div class="Polaris-DropZone__Container" data-polaris-dropzone-target="container">
|
32
32
|
<%= render Polaris::BaseComponent.new(**file_upload_arguments) do %>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
<% if content.present? %>
|
34
|
+
<%= content %>
|
35
|
+
<% else %>
|
36
|
+
<%= render Polaris::StackComponent.new(vertical: true, spacing: :tight) do |stack| %>
|
37
|
+
<% unless @size == :medium %>
|
38
|
+
<% stack.item do %>
|
39
|
+
<img width="<%= @size == :small ? 20 : 40 %>" src="data:image/svg+xml,%3csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M20 10a10 10 0 11-20 0 10 10 0 0120 0zM5.3 8.3l4-4a1 1 0 011.4 0l4 4a1 1 0 01-1.4 1.4L11 7.4V15a1 1 0 11-2 0V7.4L6.7 9.7a1 1 0 01-1.4-1.4z' fill='%235C5F62'/%3e%3c/svg%3e" alt="">
|
40
|
+
<% end %>
|
37
41
|
<% end %>
|
38
|
-
<% end %>
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
<% unless @size == :small %>
|
44
|
+
<% stack.item do %>
|
45
|
+
<% if @size == :medium %>
|
46
|
+
<div class="Polaris-DropZone-FileUpload__ActionTitle">
|
47
|
+
<%= @file_upload_button %>
|
48
|
+
</div>
|
49
|
+
<% else %>
|
50
|
+
<div class="Polaris-DropZone-FileUpload__Button">
|
51
|
+
<%= @file_upload_button %>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
50
54
|
<% end %>
|
51
55
|
<% end %>
|
52
|
-
<% end %>
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
<% unless @size == :small %>
|
58
|
+
<% stack.item do %>
|
59
|
+
<% help_text = capture do %>
|
60
|
+
<%= render Polaris::TextStyleComponent.new(variation: :subdued) do %>
|
61
|
+
<%= @file_upload_help %>
|
62
|
+
<% end %>
|
59
63
|
<% end %>
|
60
|
-
<% end %>
|
61
64
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
<% if @size == :medium %>
|
66
|
+
<%= polaris_caption { help_text } %>
|
67
|
+
<% else %>
|
68
|
+
<%= help_text %>
|
69
|
+
<% end %>
|
66
70
|
<% end %>
|
67
71
|
<% end %>
|
68
72
|
<% end %>
|
@@ -87,12 +91,12 @@
|
|
87
91
|
<template data-polaris-dropzone-target="previewTemplate">
|
88
92
|
<%= tag.div(
|
89
93
|
data: { polaris_dropzone_target: "preview" },
|
90
|
-
class:
|
91
|
-
"Polaris-DropZone__Preview",
|
94
|
+
class: {
|
95
|
+
"Polaris-DropZone__Preview": true,
|
92
96
|
"Polaris-DropZone__Preview--singleFile": !@multiple,
|
93
97
|
"Polaris-DropZone__Preview--sizeMedium": @size == :medium,
|
94
98
|
"Polaris-DropZone__Preview--sizeSmall": @size == :small,
|
95
|
-
|
99
|
+
}
|
96
100
|
) do %>
|
97
101
|
<% if @size.in?(%i[small]) %>
|
98
102
|
<span class="target"></span>
|
@@ -37,6 +37,7 @@ module Polaris
|
|
37
37
|
label_action: nil,
|
38
38
|
disabled: false,
|
39
39
|
error: false,
|
40
|
+
remove_previews_after_upload: true,
|
40
41
|
file_upload_button: nil,
|
41
42
|
file_upload_help: "or drop files to upload",
|
42
43
|
file_upload_arguments: {},
|
@@ -62,6 +63,7 @@ module Polaris
|
|
62
63
|
@label_action = label_action
|
63
64
|
@disabled = disabled
|
64
65
|
@error = error
|
66
|
+
@remove_previews_after_upload = remove_previews_after_upload
|
65
67
|
@file_upload_button = file_upload_button
|
66
68
|
@file_upload_button ||= "Add #{multiple ? "files" : "file"}"
|
67
69
|
@file_upload_help = file_upload_help
|
@@ -82,7 +84,8 @@ module Polaris
|
|
82
84
|
polaris_dropzone_focused_value: "false",
|
83
85
|
polaris_dropzone_drop_on_page_value: @drop_on_page,
|
84
86
|
polaris_dropzone_render_preview_value: @preview,
|
85
|
-
polaris_dropzone_size_value: @size
|
87
|
+
polaris_dropzone_size_value: @size,
|
88
|
+
polaris_dropzone_remove_previews_after_upload_value: @remove_previews_after_upload
|
86
89
|
}
|
87
90
|
}.deep_merge(@system_arguments).tap do |opts|
|
88
91
|
prepend_option(opts[:data], :controller, "polaris-dropzone")
|
@@ -1,12 +1,15 @@
|
|
1
1
|
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
2
|
<div class="Polaris-EmptySearchResults__Content">
|
3
3
|
<%= polaris_text_container do %>
|
4
|
+
<% if image.present? %>
|
5
|
+
<div><%= image %></div>
|
6
|
+
<% end %>
|
4
7
|
<%= polaris_display_text(size: :small) do %>
|
5
8
|
<%= @title %>
|
6
9
|
<% end %>
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
<% if @description.present? %>
|
11
|
+
<div><%= polaris_text_subdued { @description } %></div>
|
12
|
+
<% end %>
|
10
13
|
<% end %>
|
11
14
|
</div>
|
12
15
|
<% end %>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Polaris
|
2
2
|
class EmptySearchResultsComponent < Polaris::Component
|
3
|
-
|
3
|
+
renders_one :image
|
4
|
+
|
5
|
+
def initialize(title:, description: nil, **system_arguments)
|
4
6
|
@title = title
|
5
7
|
@description = description
|
6
8
|
@system_arguments = system_arguments
|
@@ -20,7 +20,7 @@ module Polaris
|
|
20
20
|
TEXT_ALIGN_OPTIONS = TEXT_ALIGN_MAPPINGS.keys
|
21
21
|
|
22
22
|
DISCLOSURE_DEFAULT = false
|
23
|
-
DISCLOSURE_OPTIONS = [true, false, :down, :up, :select]
|
23
|
+
DISCLOSURE_OPTIONS = [true, false, :down, :up, :select, :horizontal_dots]
|
24
24
|
|
25
25
|
renders_one :icon, IconComponent
|
26
26
|
|
@@ -7,25 +7,35 @@
|
|
7
7
|
<% end %>
|
8
8
|
</div>
|
9
9
|
|
10
|
-
|
11
|
-
<%= render Polaris::BaseComponent.new(**
|
12
|
-
|
13
|
-
|
14
|
-
<div
|
15
|
-
|
16
|
-
|
17
|
-
<% panes.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<%=
|
10
|
+
<% popover = capture do %>
|
11
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
12
|
+
<%= render Polaris::BaseComponent.new(**popover_arguments) do %>
|
13
|
+
<div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
|
14
|
+
<div style="">
|
15
|
+
<div class="Polaris-Popover__Wrapper">
|
16
|
+
<%= render Polaris::BaseComponent.new(**content_arguments) do %>
|
17
|
+
<% if panes.present? %>
|
18
|
+
<% panes.each do |pane| %>
|
19
|
+
<%= pane %>
|
20
|
+
<% end %>
|
21
|
+
<% else %>
|
22
|
+
<%= render Polaris::Popover::PaneComponent.new(sectioned: @sectioned) do %>
|
23
|
+
<%= content %>
|
24
|
+
<% end %>
|
23
25
|
<% end %>
|
24
26
|
<% end %>
|
25
|
-
|
27
|
+
</div>
|
26
28
|
</div>
|
27
|
-
|
28
|
-
|
29
|
+
<div class="Polaris-Popover__FocusTracker" tabindex="0"></div>
|
30
|
+
<% end %>
|
29
31
|
<% end %>
|
30
32
|
<% end %>
|
33
|
+
|
34
|
+
<% if @append_to_body %>
|
35
|
+
<template data-polaris-popover-target="template">
|
36
|
+
<%= popover %>
|
37
|
+
</template>
|
38
|
+
<% else %>
|
39
|
+
<%= popover %>
|
40
|
+
<% end %>
|
31
41
|
<% end %>
|
@@ -24,6 +24,7 @@ module Polaris
|
|
24
24
|
sectioned: false,
|
25
25
|
alignment: ALIGNMENT_DEFAULT,
|
26
26
|
position: POSITION_DEFAULT,
|
27
|
+
append_to_body: false,
|
27
28
|
wrapper_arguments: {},
|
28
29
|
**system_arguments
|
29
30
|
)
|
@@ -36,6 +37,7 @@ module Polaris
|
|
36
37
|
@sectioned = sectioned
|
37
38
|
@alignment = fetch_or_fallback(ALIGNMENT_OPTIONS, alignment, ALIGNMENT_DEFAULT)
|
38
39
|
@position = fetch_or_fallback(POSITION_OPTIONS, position, POSITION_DEFAULT)
|
40
|
+
@append_to_body = append_to_body
|
39
41
|
@wrapper_arguments = wrapper_arguments
|
40
42
|
@system_arguments = system_arguments
|
41
43
|
@popover_arguments = {}
|
@@ -47,6 +49,7 @@ module Polaris
|
|
47
49
|
opts[:tag] = "div"
|
48
50
|
opts[:data] ||= {}
|
49
51
|
prepend_option(opts[:data], :controller, "polaris-popover")
|
52
|
+
opts[:data][:polaris_popover_append_to_body_value] = @append_to_body
|
50
53
|
opts[:data][:polaris_popover_active_value] = @active
|
51
54
|
opts[:data][:polaris_popover_placement_value] = popperjs_placement
|
52
55
|
opts[:data][:polaris_popover_open_class] = "Polaris-Popover__PopoverOverlay--open"
|
@@ -61,7 +64,9 @@ module Polaris
|
|
61
64
|
@system_arguments.tap do |opts|
|
62
65
|
opts[:tag] = "div"
|
63
66
|
opts[:data] ||= {}
|
64
|
-
|
67
|
+
unless @append_to_body
|
68
|
+
opts[:data]["polaris_popover_target"] = "popover"
|
69
|
+
end
|
65
70
|
opts[:classes] = class_names(
|
66
71
|
@system_arguments[:classes],
|
67
72
|
"Polaris-PositionedOverlay",
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %>
|
2
|
+
<%= render(Polaris::ButtonGroupComponent.new(**system_arguments)) do |group| %>
|
3
|
+
<% buttons.each do |button| %>
|
4
|
+
<% group.button(**button.system_arguments) { button.content } %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if @persist_actions %>
|
10
|
+
<%= render(Polaris::BaseComponent.new(**disclosure_arguments)) do %>
|
11
|
+
<%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
|
12
|
+
<% popover.button(disclosure: :horizontal_dots, plain: true) %>
|
13
|
+
|
14
|
+
<%= render(Polaris::ActionListComponent.new) do |action_list| %>
|
15
|
+
<% buttons.each do |button| %>
|
16
|
+
<% action_list.item(**button.action_list_item_arguments) { button.content } %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class Polaris::ResourceItem::ShortcutActionsComponent < Polaris::Component
|
2
|
+
renders_many :buttons, ->(**system_arguments) do
|
3
|
+
ShortcutActionsButtonComponent.new(
|
4
|
+
persist_actions: @persist_actions,
|
5
|
+
**system_arguments
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(
|
10
|
+
persist_actions: false,
|
11
|
+
wrapper_arguments: {},
|
12
|
+
disclosure_arguments: {},
|
13
|
+
popover_arguments: {},
|
14
|
+
**system_arguments
|
15
|
+
)
|
16
|
+
@persist_actions = persist_actions
|
17
|
+
@wrapper_arguments = wrapper_arguments
|
18
|
+
@disclosure_arguments = disclosure_arguments
|
19
|
+
@popover_arguments = popover_arguments
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
end
|
22
|
+
|
23
|
+
def wrapper_arguments
|
24
|
+
@wrapper_arguments.tap do |opts|
|
25
|
+
opts[:tag] = "div"
|
26
|
+
opts[:classes] = class_names(
|
27
|
+
@wrapper_arguments[:classes],
|
28
|
+
"Polaris-ResourceItem__Actions"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def disclosure_arguments
|
34
|
+
@disclosure_arguments.tap do |opts|
|
35
|
+
opts[:tag] = "div"
|
36
|
+
opts[:classes] = class_names(
|
37
|
+
@disclosure_arguments[:classes],
|
38
|
+
"Polaris-ResourceItem__Disclosure"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def popover_arguments
|
44
|
+
{
|
45
|
+
alignment: :right,
|
46
|
+
position: :below,
|
47
|
+
append_to_body: true
|
48
|
+
}.deep_merge(@popover_arguments)
|
49
|
+
end
|
50
|
+
|
51
|
+
def system_arguments
|
52
|
+
@system_arguments.tap do |opts|
|
53
|
+
opts[:segmented] = !@persist_actions
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class ShortcutActionsButtonComponent < Polaris::Component
|
58
|
+
attr_reader :content
|
59
|
+
|
60
|
+
def initialize(
|
61
|
+
url:,
|
62
|
+
content:,
|
63
|
+
persist_actions:,
|
64
|
+
action_list_item_arguments: {},
|
65
|
+
**system_arguments
|
66
|
+
)
|
67
|
+
@url = url
|
68
|
+
@content = content
|
69
|
+
@persist_actions = persist_actions
|
70
|
+
@action_list_item_arguments = action_list_item_arguments
|
71
|
+
@system_arguments = system_arguments
|
72
|
+
end
|
73
|
+
|
74
|
+
def system_arguments
|
75
|
+
@system_arguments.tap do |opts|
|
76
|
+
opts[:url] = @url
|
77
|
+
opts[:size] = :slim unless @persist_actions
|
78
|
+
opts[:plain] = true if @persist_actions
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def action_list_item_arguments
|
83
|
+
@action_list_item_arguments.tap do |opts|
|
84
|
+
opts[:url] = @url
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -26,12 +26,20 @@ module Polaris
|
|
26
26
|
end
|
27
27
|
renders_one :media
|
28
28
|
|
29
|
+
renders_one :shortcut_actions, ->(**system_arguments) do
|
30
|
+
Polaris::ResourceItem::ShortcutActionsComponent.new(
|
31
|
+
persist_actions: @persist_actions,
|
32
|
+
**system_arguments
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
29
36
|
def initialize(
|
30
37
|
url: nil,
|
31
38
|
vertical_alignment: ALIGNMENT_DEFAULT,
|
32
39
|
cursor: CURSOR_DEFAULT,
|
33
40
|
selectable: false,
|
34
41
|
selected: false,
|
42
|
+
persist_actions: false,
|
35
43
|
offset: false,
|
36
44
|
wrapper_arguments: {},
|
37
45
|
container_arguments: {},
|
@@ -42,6 +50,7 @@ module Polaris
|
|
42
50
|
@cursor = fetch_or_fallback(CURSOR_OPTIONS, cursor, CURSOR_DEFAULT)
|
43
51
|
@selectable = selectable
|
44
52
|
@selected = selected
|
53
|
+
@persist_actions = persist_actions
|
45
54
|
@offset = offset
|
46
55
|
@wrapper_arguments = wrapper_arguments
|
47
56
|
@container_arguments = container_arguments
|
@@ -82,7 +91,8 @@ module Polaris
|
|
82
91
|
args[:classes],
|
83
92
|
"Polaris-ResourceItem",
|
84
93
|
"Polaris-ResourceItem--selectable": @selectable,
|
85
|
-
"Polaris-ResourceItem--selected": @selected
|
94
|
+
"Polaris-ResourceItem--selected": @selected,
|
95
|
+
"Polaris-ResourceItem--persistActions": @persist_actions
|
86
96
|
)
|
87
97
|
prepend_option(args, :style, "cursor: #{@cursor};")
|
88
98
|
prepend_option(args[:data], :action, "click->polaris-resource-item#open")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
|
+
<div class="Polaris-SkeletonPage__Header">
|
3
|
+
<div class="Polaris-SkeletonPage__TitleAndPrimaryAction">
|
4
|
+
<div class="Polaris-SkeletonPage__TitleWrapper">
|
5
|
+
<% if @title.present? %>
|
6
|
+
<h1 class="Polaris-SkeletonPage__Title">
|
7
|
+
<%= @title %>
|
8
|
+
</h1>
|
9
|
+
<% else %>
|
10
|
+
<div class="Polaris-SkeletonPage__SkeletonTitle"></div>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<% if @primary_action %>
|
14
|
+
<div class="Polaris-SkeletonPage__PrimaryAction">
|
15
|
+
<%= polaris_skeleton_display_text(size: :large) %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<div class="Polaris-SkeletonPage__Content">
|
21
|
+
<%= content %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Polaris
|
4
|
+
class SkeletonPageComponent < Polaris::Component
|
5
|
+
def initialize(title: nil, primary_action: false, **system_arguments)
|
6
|
+
@title = title
|
7
|
+
@primary_action = primary_action
|
8
|
+
@system_arguments = system_arguments
|
9
|
+
end
|
10
|
+
|
11
|
+
def system_arguments
|
12
|
+
@system_arguments.tap do |opts|
|
13
|
+
opts[:tag] = "div"
|
14
|
+
opts[:role] = "status"
|
15
|
+
opts[:classes] = class_names(
|
16
|
+
@system_arguments[:classes],
|
17
|
+
"Polaris-SkeletonPage__Page"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -60,6 +60,7 @@ module Polaris
|
|
60
60
|
spinner: "Polaris::SpinnerComponent",
|
61
61
|
skeleton_body_text: "Polaris::SkeletonBodyTextComponent",
|
62
62
|
skeleton_display_text: "Polaris::SkeletonDisplayTextComponent",
|
63
|
+
skeleton_page: "Polaris::SkeletonPageComponent",
|
63
64
|
skeleton_thumbnail: "Polaris::SkeletonThumbnailComponent",
|
64
65
|
spacer: "Polaris::SpacerComponent",
|
65
66
|
tabs: "Polaris::TabsComponent",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polaris_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Gamble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -695,6 +695,8 @@ files:
|
|
695
695
|
- app/components/polaris/progress_bar_component.rb
|
696
696
|
- app/components/polaris/radio_button_component.html.erb
|
697
697
|
- app/components/polaris/radio_button_component.rb
|
698
|
+
- app/components/polaris/resource_item/shortcut_actions_component.html.erb
|
699
|
+
- app/components/polaris/resource_item/shortcut_actions_component.rb
|
698
700
|
- app/components/polaris/resource_item_component.html.erb
|
699
701
|
- app/components/polaris/resource_item_component.rb
|
700
702
|
- app/components/polaris/resource_list_component.html.erb
|
@@ -710,6 +712,8 @@ files:
|
|
710
712
|
- app/components/polaris/skeleton_body_text_component.html.erb
|
711
713
|
- app/components/polaris/skeleton_body_text_component.rb
|
712
714
|
- app/components/polaris/skeleton_display_text_component.rb
|
715
|
+
- app/components/polaris/skeleton_page_component.html.erb
|
716
|
+
- app/components/polaris/skeleton_page_component.rb
|
713
717
|
- app/components/polaris/skeleton_thumbnail_component.rb
|
714
718
|
- app/components/polaris/spacer_component.rb
|
715
719
|
- app/components/polaris/spinner_component.html.erb
|
@@ -769,7 +773,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
769
773
|
- !ruby/object:Gem::Version
|
770
774
|
version: '0'
|
771
775
|
requirements: []
|
772
|
-
rubygems_version: 3.3.
|
776
|
+
rubygems_version: 3.3.7
|
773
777
|
signing_key:
|
774
778
|
specification_version: 4
|
775
779
|
summary: ViewComponents for Polaris Design System
|