coveragebook_components 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/build/coco/app.css +28 -28
- data/app/assets/build/coco/app.js +8113 -974
- data/app/assets/build/coco/book.css +3 -0
- data/app/assets/build/coco/book.js +37 -4
- data/app/assets/js/base/polyfills/request-submit.js +39 -0
- data/app/assets/js/base/setup.js +2 -0
- data/app/assets/js/helpers/path.js +9 -1
- data/app/assets/js/helpers/screenshot.js +20 -4
- data/app/components/coco/app/blocks/slide_editor/slide_editor.css +8 -11
- data/app/components/coco/app/blocks/slide_editor/slide_editor.html.erb +155 -196
- data/app/components/coco/app/blocks/slide_editor/slide_editor.js +92 -70
- data/app/components/coco/app/blocks/slide_editor/slide_editor.rb +36 -85
- data/app/components/coco/app/elements/alert/alert.css +1 -1
- data/app/components/coco/app/elements/button/button.css +11 -11
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.html.erb +17 -16
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.js +0 -8
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.rb +2 -15
- data/app/components/coco/app/elements/image_picker/image_picker.html.erb +4 -4
- data/app/components/coco/app/elements/image_picker/image_picker.js +18 -6
- data/app/components/coco/app/elements/image_picker/image_picker.rb +2 -11
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.html.erb +9 -8
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.js +10 -23
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.rb +19 -35
- data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.html.erb +7 -4
- data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.js +9 -3
- data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.rb +5 -20
- data/app/components/coco/base/button/button.css +3 -3
- data/app/components/coco/base/button/button.js +1 -3
- data/app/components/coco/base/image_uploader/image_uploader.html.erb +3 -2
- data/app/components/coco/base/image_uploader/image_uploader.rb +2 -12
- data/app/components/coco/book/blocks/slides/media_slide/media_slide.css +1 -1
- data/app/components/coco/component.rb +1 -0
- data/app/components/coco/concerns/has_name.rb +1 -1
- data/app/components/coco/concerns/translatable.rb +18 -0
- data/config/credentials/production.key +1 -0
- data/config/credentials/production.yml.enc +1 -0
- data/config/icons.json +886 -0
- data/config/locales/coco.en.yml +22 -0
- data/config/tailwind.app.config.cjs +21 -0
- data/config/tailwind.base.config.cjs +79 -0
- data/config/tailwind.book.config.cjs +20 -0
- data/config/tokens.cjs +229 -0
- data/config/utils.cjs +16 -0
- data/lib/coco.rb +1 -1
- metadata +13 -6
- data/app/assets/build/coco/app.dev.css +0 -3427
- data/app/assets/build/coco/app.dev.js +0 -24891
- data/app/assets/build/coco/book.dev.css +0 -992
- data/app/assets/build/coco/book.dev.js +0 -19840
@@ -15,18 +15,9 @@ module Coco
|
|
15
15
|
|
16
16
|
attr_reader :uploader_args, :src
|
17
17
|
|
18
|
-
def initialize(
|
18
|
+
def initialize(src: nil, accept: "image/*", **kwargs)
|
19
19
|
@src = src
|
20
|
-
@uploader_args = {
|
21
|
-
end
|
22
|
-
|
23
|
-
def alpine_props
|
24
|
-
{
|
25
|
-
image: {
|
26
|
-
name: (src.present? && File.basename(src)),
|
27
|
-
data: src
|
28
|
-
}
|
29
|
-
}
|
20
|
+
@uploader_args = {accept: accept}
|
30
21
|
end
|
31
22
|
end
|
32
23
|
end
|
@@ -1,20 +1,21 @@
|
|
1
1
|
<%= render component_tag(x: {
|
2
|
-
data: x_data("appImagePickerButton",
|
3
|
-
"@dropdown:mount": "onDropdownMount"
|
4
|
-
|
5
|
-
|
2
|
+
data: x_data("appImagePickerButton", {src: src}),
|
3
|
+
"@dropdown:mount": "onDropdownMount",
|
4
|
+
effect: "$dispatch('image-picker:change', {image: selectedImage})"
|
5
|
+
}) do %>
|
6
6
|
<%= render button do |btn| %>
|
7
|
-
|
7
|
+
|
8
|
+
<% btn.with_dropdown do %>
|
8
9
|
<div
|
9
|
-
@image-picker:select="setSelectedImage($event.detail.image)"
|
10
|
-
@image-picker:clear="clearSelectedImage"
|
10
|
+
@image-picker:select="$parent.setSelectedImage($event.detail.image)"
|
11
|
+
@image-picker:clear="$parent.clearSelectedImage"
|
11
12
|
x-cloak>
|
12
13
|
<div data-role="image-picker">
|
13
14
|
<%= picker %>
|
14
15
|
</div>
|
15
16
|
</div>
|
16
17
|
<% end %>
|
17
|
-
|
18
|
+
|
18
19
|
<%= button_text %>
|
19
20
|
<% end %>
|
20
21
|
<% end %>
|
@@ -1,24 +1,13 @@
|
|
1
1
|
import { CocoComponent } from "@js/coco";
|
2
2
|
import { getData } from "@helpers/alpine";
|
3
|
+
import { basename } from "@helpers/path";
|
3
4
|
|
4
|
-
export default CocoComponent("appImagePickerButton", ({
|
5
|
+
export default CocoComponent("appImagePickerButton", ({ src }) => {
|
5
6
|
return {
|
6
|
-
selectedImage:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
init() {
|
11
|
-
this.$watch("selectedImage", (file) => {
|
12
|
-
const dataTransfer = new DataTransfer();
|
13
|
-
if (file && file.file instanceof File) {
|
14
|
-
dataTransfer.items.add(file.file);
|
15
|
-
}
|
16
|
-
this.$refs.fileInput.files = dataTransfer.files;
|
17
|
-
|
18
|
-
if (this.dropdown) {
|
19
|
-
this.dropdown.hide();
|
20
|
-
}
|
21
|
-
});
|
7
|
+
selectedImage: {
|
8
|
+
name: basename(src),
|
9
|
+
file: null,
|
10
|
+
data: src,
|
22
11
|
},
|
23
12
|
|
24
13
|
getPicker() {
|
@@ -37,21 +26,19 @@ export default CocoComponent("appImagePickerButton", ({ image }) => {
|
|
37
26
|
reader.addEventListener("load", () => {
|
38
27
|
this.selectedImage = {
|
39
28
|
name: file.name,
|
40
|
-
file
|
29
|
+
file,
|
41
30
|
data: reader.result,
|
42
31
|
};
|
43
|
-
});
|
44
32
|
|
45
|
-
|
46
|
-
|
47
|
-
// });
|
33
|
+
this.dropdown.hide();
|
34
|
+
});
|
48
35
|
|
49
36
|
reader.readAsDataURL(file);
|
50
37
|
},
|
51
38
|
|
52
39
|
clearSelectedImage() {
|
53
40
|
this.dropdown.hide();
|
54
|
-
this.selectedImage = null;
|
41
|
+
this.selectedImage = { name: null, data: null, file: null };
|
55
42
|
},
|
56
43
|
|
57
44
|
setSelectedImage(image) {
|
@@ -29,13 +29,10 @@ module Coco
|
|
29
29
|
with_picker(src: @src) unless picker?
|
30
30
|
end
|
31
31
|
|
32
|
-
attr_reader :src
|
32
|
+
attr_reader :src
|
33
33
|
|
34
|
-
def initialize(src: nil,
|
34
|
+
def initialize(src: nil, **kwargs)
|
35
35
|
@src = src
|
36
|
-
@form_builder = form_builder
|
37
|
-
@input_name = input_name
|
38
|
-
@direct_upload = direct_upload
|
39
36
|
|
40
37
|
@size = kwargs.fetch(:size, :default)&.to_sym
|
41
38
|
if @size.in?(Coco::App::Elements::Button::SIZE_ALIASES.keys) && !kwargs.key?(:resize)
|
@@ -43,38 +40,25 @@ module Coco
|
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
name: (src.present? && File.basename(src)),
|
54
|
-
data: src
|
55
|
-
}
|
56
|
-
}
|
57
|
-
end
|
43
|
+
# def input
|
44
|
+
# if input_name
|
45
|
+
# kwargs = {
|
46
|
+
# class: "picker-file-input",
|
47
|
+
# "x-ref": "fileInput",
|
48
|
+
# direct_upload: @direct_upload
|
49
|
+
# }
|
58
50
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
class: "picker-file-input",
|
63
|
-
"x-ref": "fileInput",
|
64
|
-
direct_upload: @direct_upload
|
65
|
-
}
|
51
|
+
# if direct_upload? && !helpers.respond_to?(:rails_direct_uploads_url)
|
52
|
+
# kwargs[:data] = {direct_upload_url: @direct_upload}
|
53
|
+
# end
|
66
54
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
file_field_tag(input_name, **kwargs)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
55
|
+
# if @form_builder
|
56
|
+
# @form_builder.file_field(input_name, **kwargs)
|
57
|
+
# else
|
58
|
+
# file_field_tag(input_name, **kwargs)
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
# end
|
78
62
|
|
79
63
|
def button_text
|
80
64
|
text || content
|
@@ -1,12 +1,15 @@
|
|
1
|
-
<%= render component_tag(x: {data: "appSeamlessTextarea"}) do %>
|
2
|
-
<%=
|
1
|
+
<%= render component_tag(x: {data: "appSeamlessTextarea", options: "options"}) do %>
|
2
|
+
<%= text_area_tag(nil, value,
|
3
|
+
id: nil,
|
4
|
+
placeholder: placeholder,
|
3
5
|
spellcheck: false,
|
4
6
|
rows: 1,
|
5
7
|
**x_attrs({
|
6
8
|
"@keydown.enter.prevent": (true unless multiline?),
|
7
9
|
"@input": "onResize",
|
8
10
|
ref: "textarea",
|
9
|
-
"model.debounce": "value"
|
10
|
-
})
|
11
|
+
"model.fill.debounce": "value"
|
12
|
+
}),
|
13
|
+
**@textarea_args
|
11
14
|
) %>
|
12
15
|
<% end %>
|
@@ -9,12 +9,18 @@ export default CocoComponent("appSeamlessTextarea", () => {
|
|
9
9
|
observer: null,
|
10
10
|
value: null,
|
11
11
|
|
12
|
-
|
13
|
-
return this.assertData("multiline", "false");
|
14
|
-
},
|
12
|
+
options: ["multiline", "focus"],
|
15
13
|
|
16
14
|
init() {
|
17
15
|
this.value = this.$refs.textarea.value;
|
16
|
+
this.$nextTick(() => {
|
17
|
+
this.onResize();
|
18
|
+
|
19
|
+
if (this.$options.focus) {
|
20
|
+
this.$refs.textarea.focus();
|
21
|
+
this.$refs.textarea.selectionStart = this.$refs.textarea.value.length;
|
22
|
+
}
|
23
|
+
});
|
18
24
|
},
|
19
25
|
|
20
26
|
onResize() {
|
@@ -3,22 +3,17 @@ module Coco
|
|
3
3
|
module Elements
|
4
4
|
class SeamlessTextarea < Coco::Component
|
5
5
|
include TagHelper
|
6
|
-
include Concerns::WrapsComponent
|
7
6
|
include Concerns::AcceptsOptions
|
8
7
|
|
9
|
-
wraps_component :textarea
|
10
|
-
|
11
8
|
accepts_option :multiline, from: [true, false]
|
9
|
+
accepts_option :focus, from: [true, false]
|
12
10
|
|
13
|
-
attr_reader :
|
11
|
+
attr_reader :placeholder
|
14
12
|
|
15
|
-
def initialize(
|
16
|
-
@name = name
|
17
|
-
@value = value
|
18
|
-
@form_builder = form_builder
|
13
|
+
def initialize(textarea: nil, value: nil, placeholder: nil, **kwargs)
|
19
14
|
@textarea_args = textarea.to_h
|
20
|
-
@
|
21
|
-
@
|
15
|
+
@value = value
|
16
|
+
@placeholder = placeholder
|
22
17
|
end
|
23
18
|
|
24
19
|
def multiline?
|
@@ -28,16 +23,6 @@ module Coco
|
|
28
23
|
def value
|
29
24
|
(@value.presence || content.presence || "").strip_heredoc.strip
|
30
25
|
end
|
31
|
-
|
32
|
-
def text_area(**html_args)
|
33
|
-
args = @textarea_args.merge(html_args.compact)
|
34
|
-
|
35
|
-
if @form_builder
|
36
|
-
@form_builder.text_area(name, value: value, **args)
|
37
|
-
else
|
38
|
-
text_area_tag(name, value, **args)
|
39
|
-
end
|
40
|
-
end
|
41
26
|
end
|
42
27
|
end
|
43
28
|
end
|
@@ -41,7 +41,7 @@
|
|
41
41
|
|
42
42
|
/* loading */
|
43
43
|
|
44
|
-
&[data-state="loading"] .button-icon {
|
44
|
+
&[data-state="loading"] > .button-element .button-icon {
|
45
45
|
@apply animate-spin;
|
46
46
|
}
|
47
47
|
|
@@ -53,7 +53,7 @@
|
|
53
53
|
|
54
54
|
/* Icons */
|
55
55
|
|
56
|
-
&[data-icon-position="end"] {
|
56
|
+
&[data-icon-position="end"] > .button-element {
|
57
57
|
.button-content {
|
58
58
|
@apply order-1;
|
59
59
|
}
|
@@ -67,7 +67,7 @@
|
|
67
67
|
}
|
68
68
|
}
|
69
69
|
|
70
|
-
&.with-icon[data-collapsed="true"] {
|
70
|
+
&.with-icon[data-collapsed="true"] > .button-element {
|
71
71
|
.button-content {
|
72
72
|
display: none;
|
73
73
|
}
|
@@ -31,11 +31,8 @@ export default CocoComponent("button", (data = {}) => {
|
|
31
31
|
return;
|
32
32
|
}
|
33
33
|
|
34
|
-
this.setTooltipText();
|
35
34
|
this.$root.setAttribute("data-collapsed", collapsed ? "true" : "false");
|
36
35
|
});
|
37
|
-
|
38
|
-
this.$watch("$options.state", () => this.setTooltipText());
|
39
36
|
},
|
40
37
|
|
41
38
|
setTooltipText() {
|
@@ -178,6 +175,7 @@ export default CocoComponent("button", (data = {}) => {
|
|
178
175
|
root: {
|
179
176
|
"x-options": "options",
|
180
177
|
"x-tooltip": "tooltipText",
|
178
|
+
"x-effect": "setTooltipText",
|
181
179
|
"@confirmation:confirm": "approveAndRun",
|
182
180
|
"@confirmation:cancel": "cancelConfirmation",
|
183
181
|
"@dropdown:show": "setState('active')",
|
@@ -7,11 +7,12 @@
|
|
7
7
|
"@drop.stop.prevent": "active = false; handleDrop($event)",
|
8
8
|
":data-active": "active && droppable"
|
9
9
|
}) do %>
|
10
|
-
<%=
|
10
|
+
<%= file_field_tag(nil,
|
11
|
+
accept: accept,
|
11
12
|
class: "uploader-input",
|
12
13
|
"x-ref": "input",
|
13
14
|
"@click.stop": "",
|
14
|
-
"@change": "handleFiles($el.files)" %>
|
15
|
+
"@change": "handleFiles($el.files)") %>
|
15
16
|
<%= content %>
|
16
17
|
<% end %>
|
17
18
|
|
@@ -5,20 +5,10 @@ module Coco
|
|
5
5
|
accepts_option :click, from: [true, false], default: true
|
6
6
|
accepts_option :drop, from: [true, false], default: true
|
7
7
|
|
8
|
-
attr_reader :name, :accept
|
8
|
+
attr_reader :name, :accept
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@name = name || random_id
|
10
|
+
def initialize(accept: "image/*", **kwargs)
|
12
11
|
@accept = accept
|
13
|
-
@form_builder = form_builder
|
14
|
-
end
|
15
|
-
|
16
|
-
def file_field(**kwargs)
|
17
|
-
if form_builder
|
18
|
-
form_builder.file_field(@name, **kwargs)
|
19
|
-
else
|
20
|
-
file_field_tag(@name, **kwargs)
|
21
|
-
end
|
22
12
|
end
|
23
13
|
|
24
14
|
def clickable?
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Coco
|
2
|
+
module Concerns
|
3
|
+
module Translatable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def tt(key)
|
7
|
+
t("coco.#{self.class.i18n_path}.#{key}")
|
8
|
+
end
|
9
|
+
|
10
|
+
class_methods do
|
11
|
+
def i18n_path(path = nil)
|
12
|
+
@_i18n_path = path unless path.nil?
|
13
|
+
@_i18n_path ||= component_path.underscore.tr("/", ".")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
265f649a303f0c2cbbfc9cfece75a181
|
@@ -0,0 +1 @@
|
|
1
|
+
j8VyKMx4mwRZArG1zS/oqUw1F6/UD0hQQ5sujzeTTBlNAuCTkLiuoiyAXnJV9FtR90T765ll/50wFbw0MFtk8nAzPJg=--TOqZsXP2UCs2CSMx--xYL00fHdXoCd+/xpGro01g==
|