codengage_view_components 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/components/codengage_view_components/date_field_component.css +3 -0
- data/app/components/codengage_view_components/date_field_component.html.haml +5 -0
- data/app/components/codengage_view_components/date_field_component.rb +13 -0
- data/app/components/codengage_view_components/dropdown_component.html.haml +10 -0
- data/app/components/codengage_view_components/dropdown_component.rb +13 -0
- data/app/components/codengage_view_components/flash_component.rb +1 -1
- data/app/components/codengage_view_components/item_component.html.haml +19 -0
- data/app/components/codengage_view_components/item_component.rb +33 -0
- data/app/javascript/controllers/datepicker_controller.js +34 -0
- data/config/importmap.rb +4 -1
- data/lib/codengage_view_components/version.rb +1 -1
- metadata +11 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0ac31396e7187215d096cbe324400e4418e434ff3be16260d590fd9cc8a3fa8
|
|
4
|
+
data.tar.gz: a18cd53126064cb8b3eec55bd98bf3cf5fdf9ac43e93f06264727b482b395ba5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 216aba8d113b9c0fdfd1c0a189c60f3ac1fab13f7754adae9b70c9827126cbac42d5d3f4eee4e038893606babad2828da97224b6b3aa04e7a4ff6983e228ec35
|
|
7
|
+
data.tar.gz: 610f007c96aa00b8765c256303a230531b17eaecb1068f0a2e8ee24563be69bebaa5abfb54306f5a9a44fc455dc54a0649bb60de8dc6fe7d413e230c6d9e0223
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Form
|
|
4
|
+
class DateFieldComponent < ApplicationComponent
|
|
5
|
+
def initialize(form:, classes:, attribute:, placeholder:, **data_options)
|
|
6
|
+
@form = form
|
|
7
|
+
@classes = classes
|
|
8
|
+
@attribute = attribute
|
|
9
|
+
@placeholder = placeholder
|
|
10
|
+
@data_options = data_options
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
%div{id: "#{@id}_button", type: "button", data: { dropdown_toggle: "#{@id}" }}
|
|
2
|
+
|
|
3
|
+
- if trigger.present?
|
|
4
|
+
= trigger
|
|
5
|
+
|
|
6
|
+
.z-10.hidden.bg-neutral-primary-medium.border.border-default-medium.rounded-base.shadow-lg.w-44{id: "#{@id}" }
|
|
7
|
+
%ul.p-2.text-sm.text-body.font-medium{ aria: { labelledby: "#{@id}_button" } }
|
|
8
|
+
- if items.any?
|
|
9
|
+
- items.each do |item|
|
|
10
|
+
= item
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CodengageViewComponents
|
|
4
|
+
class DropdownComponent < ApplicationComponent
|
|
5
|
+
renders_one :trigger
|
|
6
|
+
renders_many :items, "Dropdown::ItemComponent"
|
|
7
|
+
|
|
8
|
+
def initialize(id:, options: {})
|
|
9
|
+
@id = id
|
|
10
|
+
@options = options
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -5,7 +5,7 @@ module CodengageViewComponents
|
|
|
5
5
|
Message = Struct.new(:type, :text, :bg, :stroke, :icon, keyword_init: true)
|
|
6
6
|
|
|
7
7
|
STYLES = {
|
|
8
|
-
"notice" => { bg: "bg-
|
|
8
|
+
"notice" => { bg: "bg-white", stroke: "#48BB78", icon: "check" },
|
|
9
9
|
"alert" => { bg: "bg-red-700", stroke: "#DC3545", icon: "circle-alert" }
|
|
10
10
|
}.freeze
|
|
11
11
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
%li
|
|
2
|
+
- if delete?
|
|
3
|
+
= button_to @url,
|
|
4
|
+
method: :delete,
|
|
5
|
+
onclick: 'event.stopPropagation()',
|
|
6
|
+
form: { data: { turbo_confirm: I18n.t('shared.are_you_sure?'), turbo_frame: '_top' } },
|
|
7
|
+
class: 'inline-flex items-center w-full p-2 hover:bg-neutral-tertiary-medium hover:text-heading rounded cursor-pointer' do
|
|
8
|
+
.flex.items-center.gap-x-2
|
|
9
|
+
- if @icon.present?
|
|
10
|
+
= lucide_icon(@icon, stroke: icon_stroke, size: icon_size)
|
|
11
|
+
%div{ class: text_class }= @value
|
|
12
|
+
- else
|
|
13
|
+
= link_to @url,
|
|
14
|
+
data: data_attributes,
|
|
15
|
+
class: 'inline-flex items-center w-full p-2 hover:bg-neutral-tertiary-medium hover:text-heading rounded' do
|
|
16
|
+
.flex.items-center.gap-x-2
|
|
17
|
+
- if @icon.present?
|
|
18
|
+
= lucide_icon(@icon, stroke: icon_stroke, size: icon_size)
|
|
19
|
+
%div{ class: text_class }= @value
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CodengageViewComponents
|
|
4
|
+
class ItemComponent < ApplicationComponent
|
|
5
|
+
def initialize(value:, url:, method: :get, icon: nil, options: {})
|
|
6
|
+
@value = value
|
|
7
|
+
@url = url
|
|
8
|
+
@method = method
|
|
9
|
+
@icon = icon
|
|
10
|
+
@options = options
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def data_attributes
|
|
14
|
+
@options.fetch(:data, {})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def text_class
|
|
18
|
+
@options.fetch(:text_class, "")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def icon_stroke
|
|
22
|
+
@options.fetch(:icon_stroke, "gray")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def icon_size
|
|
26
|
+
@options.fetch(:icon_size, "")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def delete?
|
|
30
|
+
@method.to_s == "delete"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
import "flowbite-datepicker"
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
async connect() {
|
|
6
|
+
if (!window.Datepicker && typeof Datepicker !== 'undefined') {
|
|
7
|
+
window.Datepicker = Datepicker
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
await import("flowbite-datepicker-pt-BR")
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.warn("Não foi possível carregar a tradução, usando padrão.")
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DP = window.Datepicker
|
|
16
|
+
|
|
17
|
+
if (DP) {
|
|
18
|
+
this.picker = new DP(this.element, {
|
|
19
|
+
format: 'dd/mm/yyyy',
|
|
20
|
+
autohide: true,
|
|
21
|
+
language: 'pt-BR',
|
|
22
|
+
orientation: 'bottom',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
this.element.addEventListener('changeDate', () => {
|
|
26
|
+
this.element.dispatchEvent(new Event('change', { bubbles: true }))
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnect() {
|
|
32
|
+
this.picker?.destroy()
|
|
33
|
+
}
|
|
34
|
+
}
|
data/config/importmap.rb
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
pin_all_from File.expand_path("../app/javascript/controllers", __dir__), under: "controllers"
|
|
1
|
+
pin_all_from File.expand_path("../app/javascript/controllers", __dir__), under: "controllers"
|
|
2
|
+
|
|
3
|
+
pin "flowbite-datepicker", to: "https://cdn.jsdelivr.net/npm/flowbite-datepicker@1.3.0/dist/js/datepicker-full.js"
|
|
4
|
+
pin "flowbite-datepicker-pt-BR", to: "https://cdn.jsdelivr.net/npm/flowbite-datepicker@1.3.0/dist/js/locales/pt-BR.js"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: codengage_view_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriel Karlinski Baldo
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -93,13 +92,21 @@ files:
|
|
|
93
92
|
- Rakefile
|
|
94
93
|
- app/assets/stylesheets/codengage_view_components/application.css
|
|
95
94
|
- app/components/codengage_view_components/application_component.rb
|
|
95
|
+
- app/components/codengage_view_components/date_field_component.css
|
|
96
|
+
- app/components/codengage_view_components/date_field_component.html.haml
|
|
97
|
+
- app/components/codengage_view_components/date_field_component.rb
|
|
98
|
+
- app/components/codengage_view_components/dropdown_component.html.haml
|
|
99
|
+
- app/components/codengage_view_components/dropdown_component.rb
|
|
96
100
|
- app/components/codengage_view_components/flash_component.css
|
|
97
101
|
- app/components/codengage_view_components/flash_component.html.haml
|
|
98
102
|
- app/components/codengage_view_components/flash_component.rb
|
|
103
|
+
- app/components/codengage_view_components/item_component.html.haml
|
|
104
|
+
- app/components/codengage_view_components/item_component.rb
|
|
99
105
|
- app/controllers/codengage_view_components/application_controller.rb
|
|
100
106
|
- app/controllers/codengage_view_components/pages_controller.rb
|
|
101
107
|
- app/helpers/codengage_view_components/application_helper.rb
|
|
102
108
|
- app/helpers/codengage_view_components/pages_helper.rb
|
|
109
|
+
- app/javascript/controllers/datepicker_controller.js
|
|
103
110
|
- app/javascript/controllers/flash_component_controller.js
|
|
104
111
|
- app/javascript/controllers/index.js
|
|
105
112
|
- app/jobs/codengage_view_components/application_job.rb
|
|
@@ -120,7 +127,6 @@ metadata:
|
|
|
120
127
|
homepage_uri: https://github.com/gabriel-baldo/codengage_view_components
|
|
121
128
|
source_code_uri: https://github.com/gabriel-baldo/codengage_view_components
|
|
122
129
|
changelog_uri: https://github.com/gabriel-baldo/codengage_view_components/blob/main/README.md
|
|
123
|
-
post_install_message:
|
|
124
130
|
rdoc_options: []
|
|
125
131
|
require_paths:
|
|
126
132
|
- lib
|
|
@@ -135,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
141
|
- !ruby/object:Gem::Version
|
|
136
142
|
version: '0'
|
|
137
143
|
requirements: []
|
|
138
|
-
rubygems_version: 3.
|
|
139
|
-
signing_key:
|
|
144
|
+
rubygems_version: 3.6.9
|
|
140
145
|
specification_version: 4
|
|
141
146
|
summary: Biblioteca de ViewComponents com Tailwind para projetos Codengage.
|
|
142
147
|
test_files: []
|