katalyst-koi 5.0.0.alpha.4 → 5.0.0.beta.2
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/builds/katalyst/koi.esm.js +832 -0
- data/app/assets/builds/katalyst/koi.js +832 -0
- data/app/assets/builds/katalyst/koi.min.js +2 -0
- data/app/assets/builds/katalyst/koi.min.js.map +1 -0
- data/app/assets/config/koi.js +0 -12
- data/app/assets/stylesheets/koi/blocks/modal.css +4 -1
- data/app/assets/stylesheets/koi/blocks/tables/query.css +5 -4
- data/app/assets/stylesheets/koi/blocks/tables/table.css +21 -20
- data/app/assets/stylesheets/koi/forms/combobox.css +81 -0
- data/app/assets/stylesheets/koi/forms/index.css +3 -0
- data/app/assets/stylesheets/koi/forms/input.css +8 -7
- data/app/assets/stylesheets/koi/forms/textarea.css +6 -0
- data/app/assets/stylesheets/koi/forms/trix.css +6 -2
- data/app/components/koi/pagy_nav_component.rb +7 -0
- data/app/controllers/concerns/koi/controller/has_attachments.rb +1 -1
- data/app/controllers/concerns/koi/controller.rb +1 -0
- data/app/helpers/koi/modal_helper.rb +10 -9
- data/app/{assets/javascripts/koi/admin.js → javascript/koi/application.js} +2 -2
- data/app/{assets/javascripts → javascript}/koi/controllers/form_request_submit_controller.js +1 -1
- data/app/javascript/koi/controllers/index.js +89 -0
- data/app/{assets/javascripts/koi/controllers/koi → javascript/koi/controllers}/modal_controller.js +1 -1
- data/app/{assets/javascripts → javascript}/koi/controllers/show_hide_controller.js +1 -1
- data/app/javascript/koi/elements/index.js +1 -0
- data/app/models/admin/user.rb +2 -2
- data/app/models/concerns/koi/model/archivable.rb +3 -3
- data/app/views/layouts/koi/application.html.erb +1 -1
- data/app/views/layouts/koi/login.html.erb +1 -1
- data/config/importmap.rb +1 -3
- data/lib/generators/koi/helpers/attribute_helpers.rb +11 -8
- data/lib/generators/koi/helpers/resource_helpers.rb +9 -1
- data/lib/koi/config.rb +2 -0
- data/lib/koi/engine.rb +10 -8
- data/lib/koi/form_builder.rb +0 -1
- data/lib/koi.rb +0 -7
- metadata +27 -37
- data/app/assets/javascripts/koi/controllers/document_field_controller.js +0 -26
- data/app/assets/javascripts/koi/controllers/file_field_controller.js +0 -152
- data/app/assets/javascripts/koi/controllers/image_field_controller.js +0 -24
- data/app/assets/javascripts/koi/controllers/index.js +0 -15
- data/app/assets/javascripts/koi/elements/index.js +0 -1
- data/app/mailers/koi/application_mailer.rb +0 -8
- data/app/views/katalyst/content/asides/_aside.html+form.erb +0 -6
- data/app/views/katalyst/content/columns/_column.html+form.erb +0 -5
- data/app/views/katalyst/content/contents/_content.html+form.erb +0 -8
- data/app/views/katalyst/content/figures/_figure.html+form.erb +0 -9
- data/app/views/katalyst/content/groups/_group.html+form.erb +0 -5
- data/app/views/katalyst/content/items/_item.html+form.erb +0 -5
- data/app/views/katalyst/content/sections/_section.html+form.erb +0 -5
- data/app/views/katalyst/content/tables/_table.html+form.erb +0 -36
- data/lib/koi/form/elements/document.rb +0 -47
- data/lib/koi/form/elements/file_element.rb +0 -128
- data/lib/koi/form/elements/image.rb +0 -44
- data/lib/koi/form/govuk_extensions.rb +0 -73
- /data/app/{assets/javascripts → javascript}/koi/controllers/application.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/clipboard_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/flash_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/index_actions_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/keyboard_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/navigation_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/navigation_toggle_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/pagy_nav_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/sluggable_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_authentication_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_registration_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/elements/toolbar.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/utils/transition.js +0 -0
- /data/lib/{katalyst/koi.rb → katalyst-koi.rb} +0 -0
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "govuk_design_system_formbuilder"
|
4
|
-
|
5
|
-
module Koi
|
6
|
-
module Form
|
7
|
-
module Elements
|
8
|
-
class Document < GOVUKDesignSystemFormBuilder::Base
|
9
|
-
include FileElement
|
10
|
-
|
11
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:,
|
12
|
-
**kwargs, &)
|
13
|
-
super(builder, object_name, attribute_name, &)
|
14
|
-
|
15
|
-
@mime_types = mime_types
|
16
|
-
@label = label
|
17
|
-
@caption = caption
|
18
|
-
@hint = hint
|
19
|
-
@html_attributes = kwargs.merge(file_input_options)
|
20
|
-
@form_group = form_group
|
21
|
-
end
|
22
|
-
|
23
|
-
def preview
|
24
|
-
options = {}
|
25
|
-
add_option(options, :data, "#{stimulus_controller}_target", "preview")
|
26
|
-
add_option(options, :class, "preview-file")
|
27
|
-
options[:hidden] = "" unless preview?
|
28
|
-
|
29
|
-
tag.div(**options) do
|
30
|
-
filename = @builder.object.send(@attribute_name).filename.to_s
|
31
|
-
tag.p(filename, class: "preview-filename") + destroy_element_trigger
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def stimulus_controller
|
38
|
-
"document-field"
|
39
|
-
end
|
40
|
-
|
41
|
-
def form_group_class
|
42
|
-
"govuk-document-field"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "govuk_design_system_formbuilder"
|
4
|
-
|
5
|
-
module Koi
|
6
|
-
module Form
|
7
|
-
module Elements
|
8
|
-
module FileElement
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
using GOVUKDesignSystemFormBuilder::PrefixableArray
|
12
|
-
|
13
|
-
include GOVUKDesignSystemFormBuilder::Traits::Error
|
14
|
-
include GOVUKDesignSystemFormBuilder::Traits::Hint
|
15
|
-
include GOVUKDesignSystemFormBuilder::Traits::Label
|
16
|
-
include GOVUKDesignSystemFormBuilder::Traits::Supplemental
|
17
|
-
include GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes
|
18
|
-
include GOVUKDesignSystemFormBuilder::Traits::HTMLClasses
|
19
|
-
include ActionDispatch::Routing::RouteSet::MountedHelpers
|
20
|
-
|
21
|
-
def html
|
22
|
-
GOVUKDesignSystemFormBuilder::Containers::FormGroup.new(
|
23
|
-
*bound,
|
24
|
-
**default_form_group_options(**@form_group),
|
25
|
-
).html do
|
26
|
-
safe_join([label_element, preview, hint_element, error_element, file, destroy_element,
|
27
|
-
supplemental_content])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
protected
|
32
|
-
|
33
|
-
def stimulus_controller_actions
|
34
|
-
<<~ACTIONS.gsub(/\s+/, " ").freeze
|
35
|
-
dragover->#{stimulus_controller}#dragover
|
36
|
-
dragenter->#{stimulus_controller}#dragenter
|
37
|
-
dragleave->#{stimulus_controller}#dragleave
|
38
|
-
drop->#{stimulus_controller}#drop
|
39
|
-
ACTIONS
|
40
|
-
end
|
41
|
-
|
42
|
-
def stimulus_controller
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
def file
|
47
|
-
previous_input = @builder.hidden_field(@attribute_name, id: nil, value: value.signed_id) if attached?
|
48
|
-
file_input = @builder.file_field(@attribute_name, attributes(@html_attributes))
|
49
|
-
|
50
|
-
safe_join([previous_input, file_input])
|
51
|
-
end
|
52
|
-
|
53
|
-
def destroy_element
|
54
|
-
return if @html_attributes[:optional].blank?
|
55
|
-
|
56
|
-
@builder.fields_for(:"#{@attribute_name}_attachment") do |form|
|
57
|
-
form.hidden_field :_destroy, value: false, data: { "#{stimulus_controller}_target" => "destroy" }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def destroy_element_trigger
|
62
|
-
return if @html_attributes[:optional].blank?
|
63
|
-
|
64
|
-
content_tag(:button, "", class: "file-destroy", data: { action: "#{stimulus_controller}#setDestroy" })
|
65
|
-
end
|
66
|
-
|
67
|
-
def preview
|
68
|
-
""
|
69
|
-
end
|
70
|
-
|
71
|
-
def preview_url
|
72
|
-
preview? ? main_app.polymorphic_path(value, only_path: true) : ""
|
73
|
-
end
|
74
|
-
|
75
|
-
def preview?
|
76
|
-
attached?
|
77
|
-
end
|
78
|
-
|
79
|
-
def attached?
|
80
|
-
value&.attached? && value.blob.persisted?
|
81
|
-
end
|
82
|
-
|
83
|
-
def value
|
84
|
-
@builder.object.send(@attribute_name)
|
85
|
-
end
|
86
|
-
|
87
|
-
def file_input_options
|
88
|
-
default_file_input_options = options
|
89
|
-
|
90
|
-
add_option(default_file_input_options, :accept, @mime_types.join(","))
|
91
|
-
add_option(default_file_input_options, :data, :action, "change->#{stimulus_controller}#onUpload")
|
92
|
-
|
93
|
-
default_file_input_options
|
94
|
-
end
|
95
|
-
|
96
|
-
def options
|
97
|
-
{
|
98
|
-
id: field_id(link_errors: true),
|
99
|
-
class: classes,
|
100
|
-
aria: { describedby: combine_references(hint_id, error_id, supplemental_id) },
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
def classes
|
105
|
-
build_classes(%(file-upload), %(file-upload--error) => has_errors?).prefix(brand)
|
106
|
-
end
|
107
|
-
|
108
|
-
def default_form_group_options(**form_group_options)
|
109
|
-
add_option(form_group_options, :class, "govuk-form-group #{form_group_class}")
|
110
|
-
add_option(form_group_options, :data, :controller, stimulus_controller)
|
111
|
-
add_option(form_group_options, :data, :action, stimulus_controller_actions)
|
112
|
-
add_option(form_group_options, :data, :"#{stimulus_controller}_mime_types_value",
|
113
|
-
@mime_types.to_json)
|
114
|
-
|
115
|
-
form_group_options
|
116
|
-
end
|
117
|
-
|
118
|
-
def add_option(options, key, *path)
|
119
|
-
if path.length > 1
|
120
|
-
add_option(options[key] ||= {}, *path)
|
121
|
-
else
|
122
|
-
options[key] = [options[key], *path].compact.join(" ")
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Koi
|
4
|
-
module Form
|
5
|
-
module Elements
|
6
|
-
class Image < GOVUKDesignSystemFormBuilder::Base
|
7
|
-
include FileElement
|
8
|
-
|
9
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:,
|
10
|
-
**kwargs, &)
|
11
|
-
super(builder, object_name, attribute_name, &)
|
12
|
-
|
13
|
-
@mime_types = mime_types
|
14
|
-
@label = label
|
15
|
-
@caption = caption
|
16
|
-
@hint = hint
|
17
|
-
@html_attributes = kwargs.merge(file_input_options)
|
18
|
-
@form_group = form_group
|
19
|
-
end
|
20
|
-
|
21
|
-
def preview
|
22
|
-
options = {}
|
23
|
-
add_option(options, :data, "#{stimulus_controller}_target", "preview")
|
24
|
-
add_option(options, :class, "preview-image")
|
25
|
-
options[:hidden] = "" unless preview?
|
26
|
-
|
27
|
-
tag.div(**options) do
|
28
|
-
tag.img(src: preview_url, class: "image-thumbnail") + destroy_element_trigger
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def stimulus_controller
|
35
|
-
"image-field"
|
36
|
-
end
|
37
|
-
|
38
|
-
def form_group_class
|
39
|
-
"govuk-image-field"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Koi
|
4
|
-
module Form
|
5
|
-
module GOVUKExtensions
|
6
|
-
# Generates a +div+ element with an +input+ with +type=file+ with a label, optional hint.
|
7
|
-
#
|
8
|
-
# @example A upload field with label as a proc
|
9
|
-
# = f.govuk_document_field :data, label: -> { tag.h3('Upload your document') }
|
10
|
-
#
|
11
|
-
def govuk_document_field(attribute_name,
|
12
|
-
label: {},
|
13
|
-
caption: {},
|
14
|
-
hint: {},
|
15
|
-
form_group: {},
|
16
|
-
mime_types: Koi.config.document_mime_types,
|
17
|
-
**,
|
18
|
-
&)
|
19
|
-
Elements::Document.new(
|
20
|
-
self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **, &
|
21
|
-
).html
|
22
|
-
end
|
23
|
-
|
24
|
-
# Generates a +div+ element to preview uploaded images and an +input+ with +type=file+ with a label, optional hint
|
25
|
-
#
|
26
|
-
# @param attribute_name [Symbol] The name of the attribute
|
27
|
-
# @param hint [Hash,Proc] The content of the hint. No hint will be added if 'text' is left +nil+. When a +Proc+ is
|
28
|
-
# supplied the hint will be wrapped in a +div+ instead of a +span+
|
29
|
-
# @option hint text [String] the hint text
|
30
|
-
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
31
|
-
# @param label [Hash,Proc] configures or sets the associated label content
|
32
|
-
# @option label text [String] the label text
|
33
|
-
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
34
|
-
# @option label tag [Symbol,String] the label's wrapper tag, intended to allow labels to act as page headings
|
35
|
-
# @option label hidden [Boolean] control the visibility of the label. Hidden labels will still be read by screen
|
36
|
-
# readers
|
37
|
-
# @option label kwargs [Hash] additional arguments are applied as attributes on the +label+ element
|
38
|
-
# @param caption [Hash] configures or sets the caption content which is inserted above the label
|
39
|
-
# @option caption text [String] the caption text
|
40
|
-
# @option caption size [String] the size of the caption, can be +xl+, +l+ or +m+. Defaults to +m+
|
41
|
-
# @option caption kwargs [Hash] additional arguments are applied as attributes on the caption +span+ element
|
42
|
-
# @option kwargs [Hash] kwargs additional arguments are applied as attributes to the +input+ element.
|
43
|
-
# @param form_group [Hash] configures the form group
|
44
|
-
# @option form_group classes [Array,String] sets the form group's classes
|
45
|
-
# @option form_group kwargs [Hash] additional attributes added to the form group
|
46
|
-
# @param & [Block] arbitrary HTML that will be rendered between the hint and the input
|
47
|
-
# @return [ActiveSupport::SafeBuffer] HTML output
|
48
|
-
#
|
49
|
-
# @example An image field with injected content
|
50
|
-
# = f.govuk_image_field :incident_image,
|
51
|
-
# label: { text: 'Attach a picture of the incident' } do
|
52
|
-
#
|
53
|
-
# p.govuk-inset-text
|
54
|
-
# | If you don't know exactly leave this section blank
|
55
|
-
#
|
56
|
-
# @example A image upload field with label as a proc
|
57
|
-
# = f.govuk_image_field :image, label: -> { tag.h3('Upload your image') }
|
58
|
-
#
|
59
|
-
def govuk_image_field(attribute_name,
|
60
|
-
label: {},
|
61
|
-
caption: {},
|
62
|
-
hint: {},
|
63
|
-
form_group: {},
|
64
|
-
mime_types: Koi.config.image_mime_types,
|
65
|
-
**,
|
66
|
-
&)
|
67
|
-
Elements::Image.new(
|
68
|
-
self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **, &
|
69
|
-
).html
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_authentication_controller.js
RENAMED
File without changes
|
/data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_registration_controller.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|