polaris_view_components 2.2.5 → 2.3.0
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +54 -39
- data/app/assets/javascripts/polaris_view_components.js +8 -1
- data/app/assets/stylesheets/polaris_view_components/pagination.pcss +6 -5
- data/app/assets/stylesheets/polaris_view_components.css +5 -6
- data/app/components/polaris/data_table_component.rb +1 -1
- data/app/components/polaris/navigation/item_component.html.erb +4 -4
- data/app/components/polaris/navigation/item_component.rb +1 -0
- data/app/components/polaris/new_tabs/tab_component.html.erb +14 -0
- data/app/components/polaris/new_tabs/tab_component.rb +34 -0
- data/app/components/polaris/new_tabs_component.html.erb +14 -0
- data/app/components/polaris/new_tabs_component.rb +37 -0
- data/app/components/polaris/thumbnail_component.rb +3 -0
- data/app/helpers/polaris/view_helper.rb +1 -0
- data/lib/polaris/view_components/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b3c0fda53d1a7abb6931059e6879a873ddcbd6b7b0f4afdb9c0001fd141e700
|
4
|
+
data.tar.gz: a35bb46578dd1cecef4d27038595cfa24499284529e77ac88eb8967c9a9d6e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cfbdd729290bc21c197289371bc2fc769d78648d7c4f10f30532f04cac6298994cb2c97a5fcb7f2398432d49130e3806e702e13132c62b3561eba04880945b5
|
7
|
+
data.tar.gz: 5f6f201da44a38a6ff915fa70cd661b8173e5ee644ebccd34cf03c9ba4c7b00d80118003bd5de7953f171208da8bb1f474e5601851fbd6b1a8c21283983b8dd1
|
@@ -1,103 +1,118 @@
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
2
|
-
import {
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
2
|
+
import {
|
3
|
+
computePosition,
|
4
|
+
autoUpdate,
|
5
|
+
offset,
|
6
|
+
flip,
|
7
|
+
shift,
|
8
|
+
} from "@floating-ui/dom";
|
3
9
|
|
4
10
|
export default class extends Controller {
|
5
|
-
static targets = ["activator", "popover", "template"]
|
6
|
-
static classes = ["open", "closed"]
|
11
|
+
static targets = ["activator", "popover", "template"];
|
12
|
+
static classes = ["open", "closed"];
|
7
13
|
static values = {
|
8
14
|
appendToBody: Boolean,
|
9
15
|
placement: String,
|
10
16
|
active: Boolean,
|
11
|
-
textFieldActivator: Boolean
|
12
|
-
}
|
17
|
+
textFieldActivator: Boolean,
|
18
|
+
};
|
13
19
|
|
14
20
|
connect() {
|
15
21
|
if (this.appendToBodyValue) {
|
16
|
-
const clonedTemplate = this.templateTarget.content.cloneNode(true)
|
17
|
-
this.target = clonedTemplate.firstElementChild
|
18
|
-
document.body.appendChild(clonedTemplate)
|
22
|
+
const clonedTemplate = this.templateTarget.content.cloneNode(true);
|
23
|
+
this.target = clonedTemplate.firstElementChild;
|
24
|
+
document.body.appendChild(clonedTemplate);
|
19
25
|
}
|
20
26
|
|
21
|
-
this.target.style.display =
|
27
|
+
this.target.style.display = "none";
|
22
28
|
|
23
29
|
if (this.activeValue) {
|
24
|
-
this.show()
|
30
|
+
this.show();
|
25
31
|
}
|
26
32
|
}
|
27
33
|
|
28
34
|
disconnect() {
|
29
35
|
if (this.cleanup) {
|
30
|
-
this.cleanup()
|
36
|
+
this.cleanup();
|
37
|
+
}
|
38
|
+
if (this.target && this.appendToBodyValue) {
|
39
|
+
this.target.remove();
|
31
40
|
}
|
41
|
+
this._target = null;
|
32
42
|
}
|
33
|
-
|
34
43
|
updatePosition() {
|
35
44
|
if (this.cleanup) {
|
36
|
-
this.cleanup()
|
45
|
+
this.cleanup();
|
37
46
|
}
|
38
47
|
this.cleanup = autoUpdate(this.activator, this.target, () => {
|
39
48
|
computePosition(this.activator, this.target, {
|
40
49
|
placement: this.placementValue,
|
41
50
|
middleware: [
|
42
51
|
offset(5),
|
43
|
-
flip
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
// Only flip to opposite side if there's not enough space
|
53
|
+
flip({
|
54
|
+
fallbackPlacements: [this.placementValue],
|
55
|
+
fallbackStrategy: "bestFit",
|
56
|
+
}),
|
57
|
+
shift({ padding: 5 }),
|
58
|
+
],
|
59
|
+
}).then(({ x, y }) => {
|
47
60
|
Object.assign(this.target.style, {
|
48
61
|
left: `${x}px`,
|
49
62
|
top: `${y}px`,
|
50
|
-
})
|
51
|
-
})
|
52
|
-
})
|
63
|
+
});
|
64
|
+
});
|
65
|
+
});
|
53
66
|
}
|
54
67
|
|
55
68
|
toggle() {
|
56
69
|
if (this.target.classList.contains(this.openClass)) {
|
57
|
-
this.forceHide()
|
70
|
+
this.forceHide();
|
58
71
|
} else {
|
59
|
-
this.show()
|
72
|
+
this.show();
|
60
73
|
}
|
61
74
|
}
|
62
75
|
|
63
76
|
show() {
|
64
|
-
this.target.style.display =
|
65
|
-
this.target.classList.remove(this.closedClass)
|
66
|
-
this.target.classList.add(this.openClass)
|
67
|
-
this.updatePosition()
|
77
|
+
this.target.style.display = "block";
|
78
|
+
this.target.classList.remove(this.closedClass);
|
79
|
+
this.target.classList.add(this.openClass);
|
80
|
+
this.updatePosition();
|
68
81
|
}
|
69
82
|
|
70
83
|
hide(event) {
|
71
|
-
if (this.element.contains(event.target)) return
|
72
|
-
if (this.target.classList.contains(this.closedClass)) return
|
73
|
-
if (this.appendToBodyValue && this.target.contains(event.target)) return
|
84
|
+
if (this.element.contains(event.target)) return;
|
85
|
+
if (this.target.classList.contains(this.closedClass)) return;
|
86
|
+
if (this.appendToBodyValue && this.target.contains(event.target)) return;
|
74
87
|
|
75
|
-
this.forceHide()
|
88
|
+
this.forceHide();
|
76
89
|
}
|
77
90
|
|
78
91
|
forceHide() {
|
79
|
-
this.target.style.display =
|
80
|
-
this.target.classList.remove(this.openClass)
|
81
|
-
this.target.classList.add(this.closedClass)
|
92
|
+
this.target.style.display = "none";
|
93
|
+
this.target.classList.remove(this.openClass);
|
94
|
+
this.target.classList.add(this.closedClass);
|
82
95
|
}
|
83
96
|
|
84
97
|
get activator() {
|
85
98
|
if (this.textFieldActivatorValue) {
|
86
|
-
return this.activatorTarget.querySelector(
|
99
|
+
return this.activatorTarget.querySelector(
|
100
|
+
'[data-controller="polaris-text-field"]'
|
101
|
+
);
|
87
102
|
} else {
|
88
|
-
return this.activatorTarget
|
103
|
+
return this.activatorTarget;
|
89
104
|
}
|
90
105
|
}
|
91
106
|
|
92
107
|
get target() {
|
93
108
|
if (this.hasPopoverTarget) {
|
94
|
-
return this.popoverTarget
|
109
|
+
return this.popoverTarget;
|
95
110
|
} else {
|
96
|
-
return this._target
|
111
|
+
return this._target;
|
97
112
|
}
|
98
113
|
}
|
99
114
|
|
100
115
|
set target(value) {
|
101
|
-
this._target = value
|
116
|
+
this._target = value;
|
102
117
|
}
|
103
118
|
}
|
@@ -2134,6 +2134,10 @@ class Popover extends Controller {
|
|
2134
2134
|
if (this.cleanup) {
|
2135
2135
|
this.cleanup();
|
2136
2136
|
}
|
2137
|
+
if (this.target && this.appendToBodyValue) {
|
2138
|
+
this.target.remove();
|
2139
|
+
}
|
2140
|
+
this._target = null;
|
2137
2141
|
}
|
2138
2142
|
updatePosition() {
|
2139
2143
|
if (this.cleanup) {
|
@@ -2142,7 +2146,10 @@ class Popover extends Controller {
|
|
2142
2146
|
this.cleanup = autoUpdate(this.activator, this.target, (() => {
|
2143
2147
|
computePosition(this.activator, this.target, {
|
2144
2148
|
placement: this.placementValue,
|
2145
|
-
middleware: [ offset(5), flip(
|
2149
|
+
middleware: [ offset(5), flip({
|
2150
|
+
fallbackPlacements: [ this.placementValue ],
|
2151
|
+
fallbackStrategy: "bestFit"
|
2152
|
+
}), shift({
|
2146
2153
|
padding: 5
|
2147
2154
|
}) ]
|
2148
2155
|
}).then((({x: x, y: y}) => {
|
@@ -1,13 +1,14 @@
|
|
1
1
|
html[class~="Polaris-Summer-Editions-2023"] [aria-label='Pagination'] {
|
2
2
|
.Polaris-Button {
|
3
|
-
background-color: var(--p-color-bg-fill-tertiary);
|
4
3
|
border: none !important;
|
5
4
|
box-shadow: none;
|
6
5
|
|
7
|
-
&:
|
8
|
-
background-color: var(--p-color-bg-fill-tertiary
|
9
|
-
|
10
|
-
|
6
|
+
&:not([disabled]) {
|
7
|
+
background-color: var(--p-color-bg-fill-tertiary);
|
8
|
+
|
9
|
+
&:hover {
|
10
|
+
background-color: var(--p-color-bg-fill-tertiary-hover);
|
11
|
+
}
|
11
12
|
}
|
12
13
|
}
|
13
14
|
}
|
@@ -595,14 +595,13 @@
|
|
595
595
|
font-size: var(--p-font-size-500);
|
596
596
|
line-height: var(--p-font-line-height-600);
|
597
597
|
}html[class~="Polaris-Summer-Editions-2023"] [aria-label='Pagination'] .Polaris-Button {
|
598
|
-
background-color: var(--p-color-bg-fill-tertiary);
|
599
598
|
border: none !important;
|
600
599
|
box-shadow: none;
|
601
|
-
}html[class~="Polaris-Summer-Editions-2023"] [aria-label='Pagination'] .Polaris-Button:
|
602
|
-
background-color: var(--p-color-bg-fill-tertiary
|
603
|
-
|
604
|
-
|
605
|
-
|
600
|
+
}html[class~="Polaris-Summer-Editions-2023"] [aria-label='Pagination'] .Polaris-Button:not([disabled]) {
|
601
|
+
background-color: var(--p-color-bg-fill-tertiary);
|
602
|
+
}html[class~="Polaris-Summer-Editions-2023"] [aria-label='Pagination'] .Polaris-Button:not([disabled]):hover {
|
603
|
+
background-color: var(--p-color-bg-fill-tertiary-hover);
|
604
|
+
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-Popover .Polaris-Popover__Content .Polaris-Popover__Pane:first-child > .Polaris-Popover__Section > .Polaris-Box {
|
606
605
|
padding: var(--p-space-300) var(--p-space-400) var(--p-space-100);
|
607
606
|
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-Popover .Polaris-Popover__Content .Polaris-Popover__Pane:last-child > .Polaris-Popover__Section > .Polaris-Box {
|
608
607
|
padding: var(--p-space-300) var(--p-space-300);
|
@@ -11,9 +11,9 @@
|
|
11
11
|
<span class="Polaris-Navigation__Text">
|
12
12
|
<%= @label %>
|
13
13
|
</span>
|
14
|
-
<% if @badge.present? %>
|
14
|
+
<% if badge? || @badge.present? %>
|
15
15
|
<div class="Polaris-Navigation__Badge">
|
16
|
-
<%= polaris_badge { @badge } %>
|
16
|
+
<%= badge? ? badge : (polaris_badge { @badge }) %>
|
17
17
|
</div>
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
@@ -27,9 +27,9 @@
|
|
27
27
|
<span class="Polaris-Navigation__Text">
|
28
28
|
<%= @label %>
|
29
29
|
</span>
|
30
|
-
<% if @badge.present? %>
|
30
|
+
<% if badge? || @badge.present? %>
|
31
31
|
<div class="Polaris-Navigation__Badge">
|
32
|
-
<%= polaris_badge { @badge } %>
|
32
|
+
<%= badge? ? badge : (polaris_badge { @badge }) %>
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
35
|
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<li class="Polaris-Tabs__TabContainer" role="presentation">
|
2
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
3
|
+
<%= polaris_stack(alignment: :center, distribution: :center, spacing: :tight) do |stack| %>
|
4
|
+
<% stack.with_item do %>
|
5
|
+
<%= polaris_text(variant: :bodySm, as: :span, font_weight: :medium) { @title } %>
|
6
|
+
<% end %>
|
7
|
+
<% if badge.present? %>
|
8
|
+
<% stack.with_item do %>
|
9
|
+
<%= badge %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
</li>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Polaris::NewTabs::TabComponent < Polaris::Component
|
2
|
+
renders_one :badge, Polaris::BadgeComponent
|
3
|
+
|
4
|
+
def initialize(
|
5
|
+
title:,
|
6
|
+
url: nil,
|
7
|
+
active: false,
|
8
|
+
**system_arguments
|
9
|
+
)
|
10
|
+
@title = title
|
11
|
+
@url = url
|
12
|
+
@active = active
|
13
|
+
@system_arguments = system_arguments
|
14
|
+
end
|
15
|
+
|
16
|
+
def system_arguments
|
17
|
+
@system_arguments.tap do |opts|
|
18
|
+
opts[:rol] = "tab"
|
19
|
+
opts[:tabindex] = "0"
|
20
|
+
if @url.present?
|
21
|
+
opts[:tag] = "a"
|
22
|
+
opts[:href] = @url
|
23
|
+
else
|
24
|
+
opts[:tag] = "button"
|
25
|
+
opts[:type] = "button"
|
26
|
+
end
|
27
|
+
opts[:classes] = class_names(
|
28
|
+
@system_arguments[:classes],
|
29
|
+
"Polaris-Tabs__Tab",
|
30
|
+
"Polaris-Tabs__Tab--active": @active
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= polaris_box(
|
2
|
+
padding_block_start: {xs: "0", sm: "0", md: "2"},
|
3
|
+
padding_block_end: {xs: "0", sm: "0", md: "2"},
|
4
|
+
padding_inline_start: {xs: "0", md: "1"},
|
5
|
+
padding_inline_end: {xs: "0", md: "1"}
|
6
|
+
) do %>
|
7
|
+
<%= render(Polaris::BaseComponent.new(**wrapper_arguments)) do %>
|
8
|
+
<%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
|
9
|
+
<% tabs.each do |tab| %>
|
10
|
+
<%= tab %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Polaris
|
2
|
+
class NewTabsComponent < Polaris::Component
|
3
|
+
renders_many :tabs, Polaris::NewTabs::TabComponent
|
4
|
+
|
5
|
+
def initialize(fitted: false, wrapper_arguments: {}, **system_arguments)
|
6
|
+
@fitted = fitted
|
7
|
+
@wrapper_arguments = wrapper_arguments
|
8
|
+
@system_arguments = system_arguments
|
9
|
+
end
|
10
|
+
|
11
|
+
def wrapper_arguments
|
12
|
+
@wrapper_arguments.tap do |opts|
|
13
|
+
opts[:tag] = "div"
|
14
|
+
opts[:classes] = class_names(
|
15
|
+
@wrapper_arguments[:classes],
|
16
|
+
"Polaris-Tabs__Wrapper"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def system_arguments
|
22
|
+
@system_arguments.tap do |opts|
|
23
|
+
opts[:tag] = "ul"
|
24
|
+
opts[:role] = "tablist"
|
25
|
+
opts[:classes] = class_names(
|
26
|
+
@system_arguments[:classes],
|
27
|
+
"Polaris-Tabs",
|
28
|
+
"Polaris-Tabs--fitted": @fitted
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def renders?
|
34
|
+
tabs.present?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -8,6 +8,7 @@ module Polaris
|
|
8
8
|
|
9
9
|
SIZE_DEFAULT = :medium
|
10
10
|
SIZE_MAPPINGS = {
|
11
|
+
extra_small: "Polaris-Thumbnail--sizeExtraSmall",
|
11
12
|
small: "Polaris-Thumbnail--sizeSmall",
|
12
13
|
medium: "Polaris-Thumbnail--sizeMedium",
|
13
14
|
large: "Polaris-Thumbnail--sizeLarge"
|
@@ -30,6 +31,8 @@ module Polaris
|
|
30
31
|
@source = source
|
31
32
|
@transparent = transparent
|
32
33
|
|
34
|
+
@size = :extra_small if [:xsmall, :x_small, :xs].include?(@size)
|
35
|
+
|
33
36
|
@system_arguments = system_arguments
|
34
37
|
end
|
35
38
|
|
@@ -74,6 +74,7 @@ module Polaris
|
|
74
74
|
skeleton_thumbnail: "Polaris::SkeletonThumbnailComponent",
|
75
75
|
spacer: "Polaris::SpacerComponent",
|
76
76
|
tabs: "Polaris::TabsComponent",
|
77
|
+
new_tabs: "Polaris::NewTabsComponent",
|
77
78
|
tag: "Polaris::TagComponent",
|
78
79
|
text: "Polaris::TextComponent",
|
79
80
|
text_container: "Polaris::TextContainerComponent",
|
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: 2.
|
4
|
+
version: 2.3.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:
|
12
|
+
date: 2025-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -834,6 +834,10 @@ files:
|
|
834
834
|
- app/components/polaris/navigation_component.rb
|
835
835
|
- app/components/polaris/navigation_list_component.html.erb
|
836
836
|
- app/components/polaris/navigation_list_component.rb
|
837
|
+
- app/components/polaris/new_tabs/tab_component.html.erb
|
838
|
+
- app/components/polaris/new_tabs/tab_component.rb
|
839
|
+
- app/components/polaris/new_tabs_component.html.erb
|
840
|
+
- app/components/polaris/new_tabs_component.rb
|
837
841
|
- app/components/polaris/option_list/checkbox_component.html.erb
|
838
842
|
- app/components/polaris/option_list/checkbox_component.rb
|
839
843
|
- app/components/polaris/option_list/option_component.rb
|