polaris_view_components 3.0.0 → 3.1.1
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/README.md +12 -0
- data/app/assets/javascripts/polaris_view_components/data_table_controller.js +31 -20
- data/app/assets/javascripts/polaris_view_components/modal_controller.js +4 -0
- data/app/assets/javascripts/polaris_view_components.js +32 -19
- data/app/assets/stylesheets/polaris_view_components/data_table.pcss +10 -3
- data/app/assets/stylesheets/polaris_view_components.css +10 -3
- data/app/components/polaris/action_list/section_component.html.erb +1 -1
- data/app/components/polaris/avatar_component.html.erb +1 -1
- data/app/components/polaris/character_count.rb +3 -3
- data/app/components/polaris/data_table_component.rb +0 -1
- data/app/components/polaris/divider_component.rb +24 -1
- data/app/components/polaris/empty_state_component.html.erb +1 -1
- data/app/components/polaris/index_table_component.html.erb +4 -4
- data/lib/polaris/view_components/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d930e9979e26f2a16e58a86aaf5477360eb518602900671407fbad50476058a
|
|
4
|
+
data.tar.gz: c65e3755b6d86787d6a6582c646ed8e81c17fbb33e6ba95fb6e975f240411840
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b74b88c543352ce30e6db7b6478b61aeba71a7688f578335bab15464aa041e1f806f0200fadbfc8015586c18b99f543d1a8633d250e46eed03f984b3543889e
|
|
7
|
+
data.tar.gz: 04f4ad64a553706075a8fe6a7632707e4334f3a805f717f8dfb40c1e4b47c6db314a05b9684cc923f4dfd2359aafd10b61c53ec0bc47a11b1ee683a6fc54ae24
|
data/README.md
CHANGED
|
@@ -73,6 +73,18 @@ npm run release
|
|
|
73
73
|
|
|
74
74
|
After that make sure to commit changes in package.json.
|
|
75
75
|
|
|
76
|
+
## Deploy
|
|
77
|
+
|
|
78
|
+
Before deploying make sure to:
|
|
79
|
+
|
|
80
|
+
1. Copy `demo/config/master.key` from 1Password
|
|
81
|
+
2. Set `KAMAL_REGISTRY_PASSWORD` in `.env`
|
|
82
|
+
|
|
83
|
+
Then run:
|
|
84
|
+
```bash
|
|
85
|
+
kamal deploy
|
|
86
|
+
```
|
|
87
|
+
|
|
76
88
|
## License
|
|
77
89
|
|
|
78
90
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
import { debounce } from "./utils"
|
|
2
3
|
|
|
3
4
|
export default class extends Controller {
|
|
4
|
-
static targets = ["row"]
|
|
5
|
-
|
|
6
5
|
connect() {
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
this.handleMouseOver = debounce(this.handleMouseOver.bind(this), 50)
|
|
7
|
+
this.handleMouseOut = debounce(this.handleMouseOut.bind(this), 50)
|
|
8
|
+
|
|
9
|
+
this.element.addEventListener("mouseover", this.handleMouseOver)
|
|
10
|
+
this.element.addEventListener("mouseout", this.handleMouseOut)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
disconnect() {
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
this.element.removeEventListener("mouseover", this.handleMouseOver)
|
|
15
|
+
this.element.removeEventListener("mouseout", this.handleMouseOut)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
handleMouseOver(event) {
|
|
19
|
+
const row = event.target.closest(".Polaris-DataTable--hoverable")
|
|
20
|
+
if (row && row !== this.hoveredRow) {
|
|
21
|
+
this.clearHoveredRow()
|
|
22
|
+
this.hoveredRow = row
|
|
23
|
+
row.querySelectorAll(".Polaris-DataTable__Cell").forEach(cell => {
|
|
24
|
+
cell.classList.add("Polaris-DataTable__Cell--hovered")
|
|
25
|
+
})
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
29
|
+
handleMouseOut(event) {
|
|
30
|
+
const row = event.target.closest(".Polaris-DataTable--hoverable")
|
|
31
|
+
if (row && !row.contains(event.relatedTarget)) {
|
|
32
|
+
this.clearHoveredRow()
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
clearHoveredRow() {
|
|
37
|
+
if (this.hoveredRow) {
|
|
38
|
+
this.hoveredRow.querySelectorAll(".Polaris-DataTable__Cell").forEach(cell => {
|
|
39
|
+
cell.classList.remove("Polaris-DataTable__Cell--hovered")
|
|
40
|
+
})
|
|
41
|
+
this.hoveredRow = null
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
44
|
}
|
|
@@ -17,10 +17,14 @@ export default class extends Controller {
|
|
|
17
17
|
const dropElement = `<div class="${this.backdropClass}" data-controller="polaris" data-target="#${this.element.id}" data-action="click->polaris#closeModal"></div>`
|
|
18
18
|
this.element.insertAdjacentHTML('afterend', dropElement)
|
|
19
19
|
this.backdrop = this.element.nextElementSibling
|
|
20
|
+
const event = new CustomEvent("polarisModalOpened");
|
|
21
|
+
window.dispatchEvent(event);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
close() {
|
|
23
25
|
this.element.classList.add(this.hiddenClass)
|
|
24
26
|
this.backdrop.remove()
|
|
27
|
+
const event = new CustomEvent("polarisModalClosed");
|
|
28
|
+
window.dispatchEvent(event);
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -357,30 +357,39 @@ class Collapsible extends Controller {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
class DataTable extends Controller {
|
|
360
|
-
static targets=[ "row" ];
|
|
361
360
|
connect() {
|
|
362
|
-
this.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
this.handleMouseOver = debounce(this.handleMouseOver.bind(this), 50);
|
|
362
|
+
this.handleMouseOut = debounce(this.handleMouseOut.bind(this), 50);
|
|
363
|
+
this.element.addEventListener("mouseover", this.handleMouseOver);
|
|
364
|
+
this.element.addEventListener("mouseout", this.handleMouseOut);
|
|
366
365
|
}
|
|
367
366
|
disconnect() {
|
|
368
|
-
this.
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
367
|
+
this.element.removeEventListener("mouseover", this.handleMouseOver);
|
|
368
|
+
this.element.removeEventListener("mouseout", this.handleMouseOut);
|
|
369
|
+
}
|
|
370
|
+
handleMouseOver(event) {
|
|
371
|
+
const row = event.target.closest(".Polaris-DataTable--hoverable");
|
|
372
|
+
if (row && row !== this.hoveredRow) {
|
|
373
|
+
this.clearHoveredRow();
|
|
374
|
+
this.hoveredRow = row;
|
|
375
|
+
row.querySelectorAll(".Polaris-DataTable__Cell").forEach((cell => {
|
|
376
|
+
cell.classList.add("Polaris-DataTable__Cell--hovered");
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
372
379
|
}
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
380
|
+
handleMouseOut(event) {
|
|
381
|
+
const row = event.target.closest(".Polaris-DataTable--hoverable");
|
|
382
|
+
if (row && !row.contains(event.relatedTarget)) {
|
|
383
|
+
this.clearHoveredRow();
|
|
384
|
+
}
|
|
378
385
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
386
|
+
clearHoveredRow() {
|
|
387
|
+
if (this.hoveredRow) {
|
|
388
|
+
this.hoveredRow.querySelectorAll(".Polaris-DataTable__Cell").forEach((cell => {
|
|
389
|
+
cell.classList.remove("Polaris-DataTable__Cell--hovered");
|
|
390
|
+
}));
|
|
391
|
+
this.hoveredRow = null;
|
|
392
|
+
}
|
|
384
393
|
}
|
|
385
394
|
}
|
|
386
395
|
|
|
@@ -839,10 +848,14 @@ class Modal extends Controller {
|
|
|
839
848
|
const dropElement = `<div class="${this.backdropClass}" data-controller="polaris" data-target="#${this.element.id}" data-action="click->polaris#closeModal"></div>`;
|
|
840
849
|
this.element.insertAdjacentHTML("afterend", dropElement);
|
|
841
850
|
this.backdrop = this.element.nextElementSibling;
|
|
851
|
+
const event = new CustomEvent("polarisModalOpened");
|
|
852
|
+
window.dispatchEvent(event);
|
|
842
853
|
}
|
|
843
854
|
close() {
|
|
844
855
|
this.element.classList.add(this.hiddenClass);
|
|
845
856
|
this.backdrop.remove();
|
|
857
|
+
const event = new CustomEvent("polarisModalClosed");
|
|
858
|
+
window.dispatchEvent(event);
|
|
846
859
|
}
|
|
847
860
|
}
|
|
848
861
|
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable {
|
|
2
|
-
|
|
2
|
+
.Polaris-DataTable__TableRow {
|
|
3
|
+
content-visibility: auto;
|
|
4
|
+
contain-intrinsic-size: auto 250px;
|
|
5
|
+
}
|
|
3
6
|
.Polaris-DataTable__Cell:not(.Polaris-DataTable__Cell--flush):first-child,
|
|
4
|
-
.Polaris-DataTable__Heading:not(
|
|
7
|
+
.Polaris-DataTable__Heading:not(
|
|
8
|
+
.Polaris-DataTable__Heading--flush
|
|
9
|
+
):first-child {
|
|
5
10
|
padding-left: var(--p-space-400);
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
.Polaris-DataTable__Cell:not(.Polaris-DataTable__Cell--flush):last-child,
|
|
9
|
-
.Polaris-DataTable__Heading:not(
|
|
14
|
+
.Polaris-DataTable__Heading:not(
|
|
15
|
+
.Polaris-DataTable__Heading--flush
|
|
16
|
+
):last-child {
|
|
10
17
|
padding-right: var(--p-space-400);
|
|
11
18
|
}
|
|
12
19
|
}
|
|
@@ -537,11 +537,18 @@
|
|
|
537
537
|
width: 100%;
|
|
538
538
|
}/* Select *//* Fix for Safari bug: https://github.com/baoagency/polaris_view_components/issues/454 */select.Polaris-Select__Input {
|
|
539
539
|
font-weight: 400;
|
|
540
|
-
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-
|
|
541
|
-
|
|
540
|
+
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__TableRow {
|
|
541
|
+
content-visibility: auto;
|
|
542
|
+
contain-intrinsic-size: auto 250px;
|
|
543
|
+
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__Cell:not(.Polaris-DataTable__Cell--flush):first-child,
|
|
544
|
+
html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__Heading:not(
|
|
545
|
+
.Polaris-DataTable__Heading--flush
|
|
546
|
+
):first-child {
|
|
542
547
|
padding-left: var(--p-space-400);
|
|
543
548
|
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__Cell:not(.Polaris-DataTable__Cell--flush):last-child,
|
|
544
|
-
html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__Heading:not(
|
|
549
|
+
html[class~="Polaris-Summer-Editions-2023"] .Polaris-DataTable .Polaris-DataTable__Heading:not(
|
|
550
|
+
.Polaris-DataTable__Heading--flush
|
|
551
|
+
):last-child {
|
|
545
552
|
padding-right: var(--p-space-400);
|
|
546
553
|
}html[class~="Polaris-Summer-Editions-2023"] .Polaris-FooterHelp .Polaris-FooterHelp__Text {
|
|
547
554
|
font-size: var(--p-font-size-325);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
|
2
2
|
<% if @source %>
|
|
3
|
-
<img src="<%= @source %>" class="Polaris-Avatar__Image" role="presentation" onerror="this.src=''"
|
|
3
|
+
<img src="<%= @source %>" class="Polaris-Avatar__Image" role="presentation" onerror="this.src=''" alt="">
|
|
4
4
|
<% else %>
|
|
5
5
|
<span class="Polaris-Avatar__Initials">
|
|
6
6
|
<% if @initials %>
|
|
@@ -22,9 +22,9 @@ module Polaris
|
|
|
22
22
|
def label_template
|
|
23
23
|
if max_length?
|
|
24
24
|
"{count} of #{@max_length} characters used"
|
|
25
|
+
else
|
|
26
|
+
"{count} characters"
|
|
25
27
|
end
|
|
26
|
-
|
|
27
|
-
"{count} characters"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def text_template
|
|
@@ -40,7 +40,7 @@ module Polaris
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def normalized_value
|
|
43
|
-
@text_field.value.to_s
|
|
43
|
+
@text_field.value.to_s
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def count
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module Polaris
|
|
4
4
|
class DividerComponent < Polaris::Component
|
|
5
|
+
include ActiveModel::Validations
|
|
6
|
+
|
|
7
|
+
SUPPORTED_DIRECTIONS = %w[inline block].freeze
|
|
8
|
+
|
|
9
|
+
validates :direction, inclusion: {in: SUPPORTED_DIRECTIONS}
|
|
10
|
+
|
|
5
11
|
def initialize(
|
|
6
12
|
border_color: "border-subdued",
|
|
7
13
|
border_width: "1",
|
|
14
|
+
direction: "inline",
|
|
8
15
|
**system_arguments
|
|
9
16
|
)
|
|
10
17
|
@system_arguments = system_arguments.tap do |args|
|
|
@@ -15,7 +22,7 @@ module Polaris
|
|
|
15
22
|
)
|
|
16
23
|
args[:style] = styles_list(
|
|
17
24
|
args[:style],
|
|
18
|
-
|
|
25
|
+
**border_styles(direction, border_color, border_width)
|
|
19
26
|
)
|
|
20
27
|
end
|
|
21
28
|
end
|
|
@@ -31,5 +38,21 @@ module Polaris
|
|
|
31
38
|
return "transparent" if border_color == "transparent"
|
|
32
39
|
"var(--p-color-#{fetch_or_fallback(Tokens::Color::BORDER_ALIAS, border_color)})"
|
|
33
40
|
end
|
|
41
|
+
|
|
42
|
+
def border_styles(direction, border_color, border_width)
|
|
43
|
+
border_direction = fetch_or_fallback(SUPPORTED_DIRECTIONS, direction, "inline")
|
|
44
|
+
|
|
45
|
+
if border_direction == "block"
|
|
46
|
+
{
|
|
47
|
+
"border-inline-start": "var(--p-border-width-#{fetch_or_fallback(Tokens::Border::WIDTH_SCALE, border_width)}) solid #{border_color_value(border_color)}",
|
|
48
|
+
"inline-size": "auto",
|
|
49
|
+
"min-block-size": "100%"
|
|
50
|
+
}
|
|
51
|
+
else
|
|
52
|
+
{
|
|
53
|
+
"border-block-start": "var(--p-border-width-#{fetch_or_fallback(Tokens::Border::WIDTH_SCALE, border_width)}) solid #{border_color_value(border_color)}"
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
34
57
|
end
|
|
35
58
|
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
**@system_arguments
|
|
7
7
|
) do %>
|
|
8
8
|
<%= polaris_vertical_stack(inline_align: :center) do %>
|
|
9
|
-
<img src="<%= @image %>" role="presentation" class="<%= @image_contained_class %>">
|
|
9
|
+
<img src="<%= @image %>" role="presentation" class="<%= @image_contained_class %>" alt="">
|
|
10
10
|
|
|
11
11
|
<%= polaris_box(max_width: @full_width? "100%" : "400px") do %>
|
|
12
12
|
<%= polaris_vertical_stack(inline_align: :center) do %>
|
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: 3.
|
|
4
|
+
version: 3.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Gamble
|
|
@@ -64,14 +64,14 @@ dependencies:
|
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version:
|
|
67
|
+
version: 4.9.0
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version:
|
|
74
|
+
version: 4.9.0
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: minitest
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,14 +120,14 @@ dependencies:
|
|
|
120
120
|
requirements:
|
|
121
121
|
- - "~>"
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: 2.
|
|
123
|
+
version: '2.8'
|
|
124
124
|
type: :development
|
|
125
125
|
prerelease: false
|
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
128
|
- - "~>"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 2.
|
|
130
|
+
version: '2.8'
|
|
131
131
|
- !ruby/object:Gem::Dependency
|
|
132
132
|
name: dotenv
|
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -950,7 +950,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
950
950
|
- !ruby/object:Gem::Version
|
|
951
951
|
version: '0'
|
|
952
952
|
requirements: []
|
|
953
|
-
rubygems_version:
|
|
953
|
+
rubygems_version: 4.0.3
|
|
954
954
|
specification_version: 4
|
|
955
955
|
summary: ViewComponents for Polaris Design System
|
|
956
956
|
test_files: []
|