ariadne_view_components 0.0.59 → 0.0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/LICENSE.txt +661 -49
- data/README.md +52 -4
- data/app/assets/javascripts/ariadne_view_components.js +98 -7
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css +1 -7
- data/app/components/ariadne/base_component.rb +79 -27
- data/app/components/ariadne/behaviors/tooltipable.rb +120 -0
- data/app/components/ariadne/conditional_wrapper.rb +21 -0
- data/app/components/ariadne/form/base_component.rb +74 -0
- data/app/components/ariadne/form/base_input_component.rb +60 -0
- data/app/components/ariadne/form/caption/component.html.erb +10 -0
- data/app/components/ariadne/form/caption/component.rb +29 -0
- data/app/components/ariadne/form/form_control/component.html.erb +19 -0
- data/app/components/ariadne/form/form_control/component.rb +27 -0
- data/app/components/ariadne/form/form_reference/component.html.erb +1 -0
- data/app/components/ariadne/form/form_reference/component.rb +18 -0
- data/app/components/ariadne/form/group/component.html.erb +5 -0
- data/app/components/ariadne/form/group/component.rb +27 -0
- data/app/components/ariadne/form/hidden_field/component.html.erb +1 -0
- data/app/components/ariadne/form/hidden_field/component.rb +15 -0
- data/app/components/ariadne/form/separator/component.html.erb +1 -0
- data/app/components/ariadne/form/separator/component.rb +8 -0
- data/app/components/ariadne/form/spacing_wrapper/component.html.erb +3 -0
- data/app/components/ariadne/form/spacing_wrapper/component.rb +8 -0
- data/app/components/ariadne/form/text_field/component.html.erb +25 -0
- data/app/components/ariadne/form/text_field/component.rb +132 -0
- data/app/components/ariadne/form/validation_message/component.html.erb +5 -0
- data/app/components/ariadne/form/validation_message/component.rb +14 -0
- data/app/components/ariadne/layout/narrow/component.html.erb +10 -0
- data/app/components/ariadne/layout/narrow/component.rb +24 -0
- data/app/components/ariadne/layout/nav_bar/component.css +0 -0
- data/app/components/ariadne/layout/nav_bar/component.html.erb +123 -0
- data/app/components/ariadne/layout/nav_bar/component.rb +77 -0
- data/app/components/ariadne/ui/button/component.html.erb +5 -0
- data/app/components/ariadne/ui/button/component.rb +184 -0
- data/app/components/ariadne/ui/clipboard_copy/component.html.erb +8 -0
- data/app/components/ariadne/ui/clipboard_copy/component.rb +102 -0
- data/app/components/ariadne/ui/clipboard_copy/component.ts +54 -0
- data/app/components/ariadne/ui/combobox/component.html.erb +32 -0
- data/app/components/ariadne/ui/combobox/component.rb +83 -0
- data/app/components/ariadne/ui/combobox/component.ts +119 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.html.erb +9 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.rb +53 -0
- data/app/components/ariadne/ui/combobox/option/component.html.erb +11 -0
- data/app/components/ariadne/ui/combobox/option/component.rb +45 -0
- data/app/components/ariadne/ui/heroicon/component.html.erb +3 -0
- data/app/components/ariadne/ui/heroicon/component.rb +141 -0
- data/app/components/ariadne/ui/image/component.rb +69 -0
- data/app/components/ariadne/ui/link/component.html.erb +3 -0
- data/app/components/ariadne/ui/link/component.rb +56 -0
- data/app/components/ariadne/ui/typography/component.html.erb +3 -0
- data/app/components/ariadne/ui/typography/component.rb +41 -0
- data/app/lib/ariadne/attributes_helper.rb +119 -0
- data/app/lib/ariadne/fetch_or_fallback_helper.rb +1 -1
- data/app/lib/ariadne/form.rb +16 -0
- data/app/lib/ariadne/view_helper.rb +2 -5
- data/app/lib/view_components_contrib/html_attrs.rb +64 -0
- data/app/lib/view_components_contrib/style_variants.rb +14 -0
- data/lib/ariadne/forms/acts_as_component.rb +125 -0
- data/lib/ariadne/forms/base.html.erb +8 -0
- data/lib/ariadne/forms/base.rb +132 -0
- data/lib/ariadne/forms/buffer_rewriter.rb +51 -0
- data/lib/ariadne/forms/builder.rb +88 -0
- data/lib/ariadne/forms/dsl/button_input.rb +33 -0
- data/lib/ariadne/forms/dsl/form_object.rb +26 -0
- data/lib/ariadne/forms/dsl/input.rb +322 -0
- data/lib/ariadne/forms/dsl/input_group.rb +34 -0
- data/lib/ariadne/forms/dsl/input_methods.rb +157 -0
- data/lib/ariadne/forms/dsl/submit_button_input.rb +36 -0
- data/lib/ariadne/forms/dsl/text_field_input.rb +73 -0
- data/lib/ariadne/forms/utils.rb +34 -0
- data/lib/ariadne/generate.rb +11 -0
- data/lib/ariadne/view_components/engine.rb +24 -7
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/ariadne/view_components.rb +1 -1
- data/lib/ariadne/yard/backend.rb +24 -0
- data/lib/ariadne/yard/component_manifest.rb +148 -0
- data/lib/ariadne/yard/component_ref.rb +49 -0
- data/lib/ariadne/yard/docs_helper.rb +98 -0
- data/lib/ariadne/yard/info_arch_docs_helper.rb +31 -0
- data/lib/ariadne/yard/lookbook_docs_helper.rb +32 -0
- data/lib/ariadne/yard/lookbook_pages_backend.rb +235 -0
- data/lib/ariadne/yard/registry.rb +136 -0
- data/lib/ariadne/yard/renders_many_handler.rb +23 -0
- data/lib/ariadne/yard/renders_one_handler.rb +23 -0
- data/lib/ariadne/yard.rb +19 -0
- data/static/arguments.yml +141 -48
- data/static/audited_at.json +0 -9
- data/static/classes.yml +210 -209
- data/static/constants.json +2 -209
- data/static/statuses.json +0 -9
- metadata +125 -210
- data/app/assets/builds/ariadne_view_components.css +0 -2202
- data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne.d.ts +0 -2
- data/app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/assets/stylesheets/dropdown.css +0 -46
- data/app/assets/stylesheets/prosemirror.css +0 -323
- data/app/assets/stylesheets/tooltip-component.css +0 -37
- data/app/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/components/ariadne/accumulator_controller/accumulator_controller.js +0 -39
- data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +0 -48
- data/app/components/ariadne/action_card_component.html.erb +0 -13
- data/app/components/ariadne/action_card_component.rb +0 -88
- data/app/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/components/ariadne/ariadne-form.js +0 -85
- data/app/components/ariadne/ariadne.d.ts +0 -2
- data/app/components/ariadne/ariadne.js +0 -24
- data/app/components/ariadne/ariadne.ts +0 -29
- data/app/components/ariadne/avatar_component.rb +0 -81
- data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
- data/app/components/ariadne/avatar_stack_component.rb +0 -75
- data/app/components/ariadne/base_button.rb +0 -70
- data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
- data/app/components/ariadne/blankslate_component.rb +0 -148
- data/app/components/ariadne/body_component.rb +0 -30
- data/app/components/ariadne/bottom_tab_component.html.erb +0 -4
- data/app/components/ariadne/bottom_tab_component.rb +0 -44
- data/app/components/ariadne/bottom_tab_nav_component.html.erb +0 -5
- data/app/components/ariadne/bottom_tab_nav_component.rb +0 -33
- data/app/components/ariadne/breadcrumbs_component.html.erb +0 -13
- data/app/components/ariadne/breadcrumbs_component.rb +0 -31
- data/app/components/ariadne/button_component/button_component.html.erb +0 -4
- data/app/components/ariadne/button_component.rb +0 -165
- data/app/components/ariadne/checkbox_component.html.erb +0 -5
- data/app/components/ariadne/checkbox_component.rb +0 -43
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js +0 -18
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
- data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
- data/app/components/ariadne/clipboard_copy_component.rb +0 -90
- data/app/components/ariadne/close_button_component.html.erb +0 -4
- data/app/components/ariadne/close_button_component.rb +0 -33
- data/app/components/ariadne/combobox_component.html.erb +0 -14
- data/app/components/ariadne/combobox_component.rb +0 -76
- data/app/components/ariadne/component.rb +0 -127
- data/app/components/ariadne/container_component/container_component.html.erb +0 -3
- data/app/components/ariadne/container_component.rb +0 -25
- data/app/components/ariadne/content.rb +0 -12
- data/app/components/ariadne/counter_component.rb +0 -100
- data/app/components/ariadne/details_component/details_component.html.erb +0 -4
- data/app/components/ariadne/details_component.rb +0 -81
- data/app/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
- data/app/components/ariadne/dropdown/menu_component.js +0 -1
- data/app/components/ariadne/dropdown/menu_component.rb +0 -101
- data/app/components/ariadne/dropdown/menu_component.ts +0 -1
- data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
- data/app/components/ariadne/dropdown_component.rb +0 -172
- data/app/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/components/ariadne/events_controller/events_controller.js +0 -6
- data/app/components/ariadne/events_controller/events_controller.ts +0 -7
- data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
- data/app/components/ariadne/flash_component.rb +0 -128
- data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
- data/app/components/ariadne/flex_component.rb +0 -56
- data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
- data/app/components/ariadne/footer_component.rb +0 -23
- data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
- data/app/components/ariadne/grid_component.rb +0 -67
- data/app/components/ariadne/header_component/header_component.html.erb +0 -29
- data/app/components/ariadne/header_component.rb +0 -111
- data/app/components/ariadne/heading_component.rb +0 -49
- data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
- data/app/components/ariadne/heroicon_component.rb +0 -166
- data/app/components/ariadne/image_component.rb +0 -53
- data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
- data/app/components/ariadne/inline_flex_component.rb +0 -72
- data/app/components/ariadne/layout_component.html.erb +0 -21
- data/app/components/ariadne/layout_component.rb +0 -69
- data/app/components/ariadne/link_component.rb +0 -65
- data/app/components/ariadne/list_component/list_component.html.erb +0 -3
- data/app/components/ariadne/list_component.rb +0 -70
- data/app/components/ariadne/modal_component.html.erb +0 -11
- data/app/components/ariadne/modal_component.rb +0 -88
- data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
- data/app/components/ariadne/narrow_container_component.rb +0 -30
- data/app/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/components/ariadne/options_controller/options_controller.js +0 -89
- data/app/components/ariadne/options_controller/options_controller.ts +0 -122
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.js +0 -237
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.ts +0 -278
- data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
- data/app/components/ariadne/panel_bar_component.rb +0 -80
- data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
- data/app/components/ariadne/pill_component.rb +0 -44
- data/app/components/ariadne/popover_component.html.erb +0 -10
- data/app/components/ariadne/popover_component.rb +0 -81
- data/app/components/ariadne/progress_bar_component.html.erb +0 -5
- data/app/components/ariadne/progress_bar_component.rb +0 -63
- data/app/components/ariadne/relative_time_component.html.erb +0 -3
- data/app/components/ariadne/relative_time_component.rb +0 -61
- data/app/components/ariadne/show_more_button_component.html.erb +0 -11
- data/app/components/ariadne/show_more_button_component.rb +0 -47
- data/app/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/components/ariadne/slideover_component/slideover-component.js +0 -11
- data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
- data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
- data/app/components/ariadne/slideover_component.rb +0 -66
- data/app/components/ariadne/spinner_component.html.erb +0 -16
- data/app/components/ariadne/spinner_component.rb +0 -45
- data/app/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/components/ariadne/string_match_controller/string_match_controller.js +0 -51
- data/app/components/ariadne/string_match_controller/string_match_controller.ts +0 -65
- data/app/components/ariadne/subheader_component.html.erb +0 -11
- data/app/components/ariadne/subheader_component.rb +0 -65
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.js +0 -207
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.ts +0 -256
- data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
- data/app/components/ariadne/tab_component.rb +0 -98
- data/app/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/components/ariadne/tab_container_component/tab-container-component.js +0 -23
- data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
- data/app/components/ariadne/tab_container_component.erb +0 -10
- data/app/components/ariadne/tab_container_component.rb +0 -68
- data/app/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/components/ariadne/tab_nav_component/tab-nav-component.js +0 -33
- data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
- data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
- data/app/components/ariadne/tab_nav_component.rb +0 -72
- data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
- data/app/components/ariadne/table_nav_component.rb +0 -338
- data/app/components/ariadne/text.rb +0 -25
- data/app/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.js +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
- data/app/components/ariadne/time_ago_component.rb +0 -56
- data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
- data/app/components/ariadne/timeline_component.rb +0 -34
- data/app/components/ariadne/toggle_component/toggle_component.html.erb +0 -15
- data/app/components/ariadne/toggle_component.rb +0 -95
- data/app/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/components/ariadne/toggleable_controller/toggleable_controller.js +0 -54
- data/app/components/ariadne/toggleable_controller/toggleable_controller.ts +0 -77
- data/app/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/components/ariadne/tooltip_component/tooltip-component.js +0 -43
- data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
- data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
- data/app/components/ariadne/tooltip_component.rb +0 -108
- data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
- data/app/lib/ariadne/audited/dsl.rb +0 -32
- data/app/lib/ariadne/form_builder.rb +0 -80
- data/app/lib/ariadne/status/dsl.rb +0 -41
- data/config/importmap.rb +0 -3
- data/exe/tailwindcss +0 -21
- data/lib/rubocop/cop/ariadne/base_cop.rb +0 -26
- data/tailwind.config.js +0 -70
@@ -1,23 +0,0 @@
|
|
1
|
-
import '@github/tab-container-element';
|
2
|
-
// keep in sync with tab_container_component.rb
|
3
|
-
const DEFAULT_SELECTED_CLASSES = ['ariadne-border-slate-500', 'ariadne-text-slate-600'];
|
4
|
-
const DEFAULT_UNSELECTED_CLASSES = [
|
5
|
-
'ariadne-text-gray-500',
|
6
|
-
'hover:ariadne-text-gray-700',
|
7
|
-
'hover:ariadne-border-gray-300',
|
8
|
-
];
|
9
|
-
for (const tabContainer of document.getElementsByTagName('tab-container')) {
|
10
|
-
tabContainer.addEventListener('tab-container-change', function (event) {
|
11
|
-
var _a;
|
12
|
-
const newPanel = event.detail.relatedTarget;
|
13
|
-
const tabContainer = newPanel.closest('tab-container');
|
14
|
-
const tabList = tabContainer.firstElementChild;
|
15
|
-
const currentTab = tabList.querySelector('[aria-selected="true"]');
|
16
|
-
const tabId = (_a = newPanel.getAttribute('id')) === null || _a === void 0 ? void 0 : _a.split('-').slice(1).join('-');
|
17
|
-
const newTab = tabList.querySelector(`#${tabId}`);
|
18
|
-
currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES);
|
19
|
-
currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES);
|
20
|
-
newTab.classList.add(...DEFAULT_SELECTED_CLASSES);
|
21
|
-
newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES);
|
22
|
-
});
|
23
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import '@github/tab-container-element'
|
2
|
-
|
3
|
-
// keep in sync with tab_container_component.rb
|
4
|
-
const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-slate-500', 'ariadne-text-slate-600']
|
5
|
-
const DEFAULT_UNSELECTED_CLASSES: string[] = [
|
6
|
-
'ariadne-text-gray-500',
|
7
|
-
'hover:ariadne-text-gray-700',
|
8
|
-
'hover:ariadne-border-gray-300',
|
9
|
-
]
|
10
|
-
|
11
|
-
for (const tabContainer of document.getElementsByTagName('tab-container')) {
|
12
|
-
tabContainer.addEventListener('tab-container-change', function (event: Event) {
|
13
|
-
const newPanel = (event as CustomEvent).detail.relatedTarget as HTMLElement
|
14
|
-
const tabContainer = newPanel.closest('tab-container') as HTMLElement
|
15
|
-
const tabList = tabContainer.firstElementChild as HTMLElement
|
16
|
-
const currentTab = tabList.querySelector('[aria-selected="true"]') as HTMLElement
|
17
|
-
const tabId = newPanel.getAttribute('id')?.split('-').slice(1).join('-')
|
18
|
-
const newTab = tabList.querySelector(`#${tabId}`) as HTMLElement
|
19
|
-
currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES)
|
20
|
-
currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES)
|
21
|
-
newTab.classList.add(...DEFAULT_SELECTED_CLASSES)
|
22
|
-
newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES)
|
23
|
-
})
|
24
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do |component| %>
|
2
|
-
<div role="tablist">
|
3
|
-
<% tabs.each do |tab| %>
|
4
|
-
<%= tab %>
|
5
|
-
<% end %>
|
6
|
-
</div>
|
7
|
-
<% tabs.each do |tab| %>
|
8
|
-
<%= tab.panel %>
|
9
|
-
<% end %>
|
10
|
-
<% end %>
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ariadne
|
4
|
-
# A container for a row of tags. Keyboard support is provided.
|
5
|
-
# @accessibility This component requires you to pass in a `sr_label`
|
6
|
-
# attribute, which will be used to label the tabs for screen readers.
|
7
|
-
class TabContainerComponent < Ariadne::Component
|
8
|
-
DEFAULT_TAG = :"tab-container"
|
9
|
-
|
10
|
-
DEFAULT_CLASSES = ""
|
11
|
-
|
12
|
-
DEFAULT_SELECTED_CLASSES = "ariadne-border-slate-500 ariadne-text-slate-600"
|
13
|
-
DEFAULT_UNSELECTED_CLASSES = "ariadne-text-gray-500 hover:ariadne-text-gray-700 hover:ariadne-border-gray-300"
|
14
|
-
|
15
|
-
# Tabs and panels to be rendered.
|
16
|
-
#
|
17
|
-
# @param id [String] The unique ID of the tab.
|
18
|
-
# @param selected [Boolean] Whether the tab is selected.
|
19
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
20
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
21
|
-
renders_many :tabs, lambda { |id: "", selected: false, classes: "", attributes: {}|
|
22
|
-
actual_classes = merge_class_names(selected ? DEFAULT_SELECTED_CLASSES : DEFAULT_UNSELECTED_CLASSES, classes)
|
23
|
-
|
24
|
-
Ariadne::TabComponent.new(
|
25
|
-
id: id,
|
26
|
-
selected: selected,
|
27
|
-
with_panel: true,
|
28
|
-
|
29
|
-
classes: actual_classes,
|
30
|
-
attributes: attributes,
|
31
|
-
)
|
32
|
-
}
|
33
|
-
|
34
|
-
# @example Default
|
35
|
-
#
|
36
|
-
# <%= render(Ariadne::TabContainerComponent.new(sr_label: "Comments")) do |tab_container| %>
|
37
|
-
# <%= render(Ariadne::TabComponent.new(id: "pub-comment")) do |tab| %>
|
38
|
-
# <% tab.with_text { "Tab 1" } %>
|
39
|
-
# <% tab.with_panel { "Panel 1" } %>
|
40
|
-
# <% end %>
|
41
|
-
# <%= render(Ariadne::TabComponent.new(id: "pub-comment")) do |tab| %>
|
42
|
-
# <% tab.with_text { "Tab 2" } %>
|
43
|
-
# <% tab.with_panel { "Panel 2" } %>
|
44
|
-
# <% end %>
|
45
|
-
# <% end %>
|
46
|
-
#
|
47
|
-
# %>
|
48
|
-
#
|
49
|
-
# @param sr_label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the tabs.
|
50
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
51
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
52
|
-
def initialize(sr_label:, classes: "", attributes: {})
|
53
|
-
@tag = DEFAULT_TAG
|
54
|
-
@classes = merge_class_names(
|
55
|
-
DEFAULT_CLASSES,
|
56
|
-
classes,
|
57
|
-
)
|
58
|
-
|
59
|
-
@attributes = attributes
|
60
|
-
@attributes[:"aria-label"] = sr_label
|
61
|
-
@attributes[:role] = :presentation
|
62
|
-
end
|
63
|
-
|
64
|
-
def render?
|
65
|
-
tabs?
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Controller } from '@hotwired/stimulus';
|
2
|
-
export default class TabNavComponent extends Controller {
|
3
|
-
static targets: string[];
|
4
|
-
readonly tabTargets: [HTMLAnchorElement];
|
5
|
-
SELECTED_CLASSES: string[];
|
6
|
-
UNSELECTED_CLASSES: string[];
|
7
|
-
connect(): void;
|
8
|
-
toggle(event: Event): void;
|
9
|
-
}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { Controller } from '@hotwired/stimulus';
|
2
|
-
class TabNavComponent extends Controller {
|
3
|
-
constructor() {
|
4
|
-
super(...arguments);
|
5
|
-
// keep in synch with tab_nav_component
|
6
|
-
this.SELECTED_CLASSES = ['ariadne-border-slate-500', 'ariadne-text-slate-600'];
|
7
|
-
this.UNSELECTED_CLASSES = ['ariadne-text-gray-500', 'hover:ariadne-text-gray-700', 'hover:ariadne-border-gray-300'];
|
8
|
-
}
|
9
|
-
connect() {
|
10
|
-
for (const tab of this.tabTargets) {
|
11
|
-
if (tab.hasAttribute('aria-current')) {
|
12
|
-
tab.classList.add(...this.SELECTED_CLASSES);
|
13
|
-
tab.classList.remove(...this.UNSELECTED_CLASSES);
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
toggle(event) {
|
18
|
-
for (const tab of this.tabTargets) {
|
19
|
-
if (tab === event.target) {
|
20
|
-
tab.setAttribute('aria-current', 'page');
|
21
|
-
tab.classList.add(...this.SELECTED_CLASSES);
|
22
|
-
tab.classList.remove(...this.UNSELECTED_CLASSES);
|
23
|
-
}
|
24
|
-
else if (tab.hasAttribute('aria-current')) {
|
25
|
-
tab.removeAttribute('aria-current');
|
26
|
-
tab.classList.add(...this.UNSELECTED_CLASSES);
|
27
|
-
tab.classList.remove(...this.SELECTED_CLASSES);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
TabNavComponent.targets = ['tab'];
|
33
|
-
export default TabNavComponent;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import {Controller} from '@hotwired/stimulus'
|
2
|
-
|
3
|
-
export default class TabNavComponent extends Controller {
|
4
|
-
static targets = ['tab']
|
5
|
-
|
6
|
-
declare readonly tabTargets: [HTMLAnchorElement]
|
7
|
-
|
8
|
-
// keep in synch with tab_nav_component
|
9
|
-
SELECTED_CLASSES = ['ariadne-border-slate-500', 'ariadne-text-slate-600']
|
10
|
-
UNSELECTED_CLASSES = ['ariadne-text-gray-500', 'hover:ariadne-text-gray-700', 'hover:ariadne-border-gray-300']
|
11
|
-
|
12
|
-
connect() {
|
13
|
-
for (const tab of this.tabTargets) {
|
14
|
-
if (tab.hasAttribute('aria-current')) {
|
15
|
-
tab.classList.add(...this.SELECTED_CLASSES)
|
16
|
-
tab.classList.remove(...this.UNSELECTED_CLASSES)
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
toggle(event: Event) {
|
22
|
-
for (const tab of this.tabTargets) {
|
23
|
-
if (tab === event.target) {
|
24
|
-
tab.setAttribute('aria-current', 'page')
|
25
|
-
tab.classList.add(...this.SELECTED_CLASSES)
|
26
|
-
tab.classList.remove(...this.UNSELECTED_CLASSES)
|
27
|
-
} else if (tab.hasAttribute('aria-current')) {
|
28
|
-
tab.removeAttribute('aria-current')
|
29
|
-
tab.classList.add(...this.UNSELECTED_CLASSES)
|
30
|
-
tab.classList.remove(...this.SELECTED_CLASSES)
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ariadne
|
4
|
-
# Use `TabNavComponent` to style navigation links, typically placed at the top
|
5
|
-
# of the page.
|
6
|
-
#
|
7
|
-
# For panel navigation, use <%= link_to_component(Ariadne::TabContainerComponent) %> instead.
|
8
|
-
#
|
9
|
-
# @accessibility
|
10
|
-
# - By default, `TabNavComponent` renders links within a `<nav>` element. `<nav>` has an
|
11
|
-
# implicit landmark role of `navigation` which should be reserved for main links.
|
12
|
-
# For all other set of links, set tag to `:div`.
|
13
|
-
# - See <%= link_to_component(Ariadne::TabComponent) %> for additional
|
14
|
-
# accessibility considerations.
|
15
|
-
class TabNavComponent < Ariadne::Component
|
16
|
-
DEFAULT_TAG = :nav
|
17
|
-
TAG_OPTIONS = [DEFAULT_TAG, :div].freeze
|
18
|
-
|
19
|
-
BODY_TAG_DEFAULT = :ul
|
20
|
-
|
21
|
-
# keep this consistent with tab-container-component.ts
|
22
|
-
SELECTED_CLASSES = "ariadne-border-slate-600 ariadne-text-slate-700"
|
23
|
-
UNSELECTED_CLASSES = "ariadne-text-slate-500 hover:ariadne-text-slate-700 hover:ariadne-border-slate-700"
|
24
|
-
|
25
|
-
DEFAULT_CLASSES = ""
|
26
|
-
|
27
|
-
# Tabs to be rendered. Use the tabs to list page links.
|
28
|
-
#
|
29
|
-
# @param selected [Boolean] Whether the tab is selected.
|
30
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
31
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
32
|
-
renders_many :tabs, lambda { |selected: false, href: nil, classes: "", attributes: {}|
|
33
|
-
attributes[:href] = href
|
34
|
-
attributes[:"data-tab-nav-component-target"] = "tab"
|
35
|
-
attributes[:"data-action"] = "click->tab-nav-component#toggle"
|
36
|
-
|
37
|
-
actual_classes = merge_class_names(selected ? SELECTED_CLASSES : UNSELECTED_CLASSES, classes)
|
38
|
-
Ariadne::TabComponent.new(
|
39
|
-
selected: selected,
|
40
|
-
|
41
|
-
classes: actual_classes,
|
42
|
-
attributes: attributes,
|
43
|
-
)
|
44
|
-
}
|
45
|
-
|
46
|
-
# @example Default with `<nav>`
|
47
|
-
# @description
|
48
|
-
# `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
|
49
|
-
# @code
|
50
|
-
# <%= render(Ariadne::TabNavComponent.new(label: "Nav")) do |c| %>
|
51
|
-
# <% c.with_tab(selected: true, href: "#") { "Tab 1" } %>
|
52
|
-
# <% c.with_tab(href: "#") { "Tab 2" } %>
|
53
|
-
# <% c.with_tab(href: "#") { "Tab 3" } %>
|
54
|
-
# <% end %>
|
55
|
-
#
|
56
|
-
# @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the links, and distinguish it from similar elements.
|
57
|
-
# @param tag [Symbol, String] The rendered tag name.
|
58
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
59
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
60
|
-
def initialize(label:, tag: DEFAULT_TAG, classes: "", attributes: {})
|
61
|
-
@tag = check_incoming_tag(DEFAULT_TAG, tag)
|
62
|
-
@classes = merge_class_names(
|
63
|
-
DEFAULT_CLASSES,
|
64
|
-
classes,
|
65
|
-
)
|
66
|
-
|
67
|
-
@attributes = attributes
|
68
|
-
@attributes[:"aria-label"] = label
|
69
|
-
@attributes[:"data-controller"] = "tab-nav-component"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
<div class="ariadne-inline-block ariadne-min-w-full ariadne-align-middle md:ariadne-px-6 lg:ariadne-px-8">
|
2
|
-
<div class="ariadne-overflow-hidden ariadne-shadow ariadne-ring-1 ariadne-ring-black ariadne-ring-opacity-5 md:ariadne-rounded-lg">
|
3
|
-
<%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do |table| %>
|
4
|
-
<% if has_header_row? %>
|
5
|
-
<thead>
|
6
|
-
<%= render(Ariadne::BaseComponent.new(tag: :tr, classes: header_row.classes, attributes: header_row.attributes)) do %>
|
7
|
-
<%= header_row.selection_cell %>
|
8
|
-
<%= header_row.main_cell %>
|
9
|
-
<% header_row.action_cells.each_with_index do |action_cell, idx| %>
|
10
|
-
<% if idx.zero? %>
|
11
|
-
<%= action_cell %>
|
12
|
-
<% elsif idx == header_row.action_cells.size - 1 %>
|
13
|
-
<%= action_cell %>
|
14
|
-
<% else %>
|
15
|
-
<%= action_cell %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
</thead>
|
20
|
-
<% end %>
|
21
|
-
<tbody>
|
22
|
-
<% rows.each do |row| %>
|
23
|
-
<%= render(Ariadne::BaseComponent.new(tag: :tr, classes: row.classes, attributes: row.attributes)) do %>
|
24
|
-
<%= row.selection_cell %>
|
25
|
-
<%= row.main_cell %>
|
26
|
-
<% row.metadata_cells.each_with_index do |metadata_cell, idx| %>
|
27
|
-
<% if idx.zero? %>
|
28
|
-
<%= metadata_cell %>
|
29
|
-
<% elsif idx == row.metadata_cells.size - 1 %>
|
30
|
-
<%= metadata_cell %>
|
31
|
-
<% else %>
|
32
|
-
<%= metadata_cell %>
|
33
|
-
<% end %>
|
34
|
-
<% end %>
|
35
|
-
<% end %>
|
36
|
-
<% end %>
|
37
|
-
</tbody>
|
38
|
-
<% end %>
|
39
|
-
</div>
|
40
|
-
<% if has_footer? %>
|
41
|
-
<%= render(Ariadne::BaseComponent.new(tag: :div, classes: footer.classes, attributes: footer.attributes)) do %>
|
42
|
-
<%= footer.records_info %>
|
43
|
-
<%= render(Ariadne::BaseComponent.new(tag: :nav, classes: footer.pagination_bar.classes, attributes: footer.pagination_bar.attributes)) do %>
|
44
|
-
<%= footer.pagination_bar.prev_page %>
|
45
|
-
<% footer.pagination_bar.items.each do |item| %>
|
46
|
-
<%= item %>
|
47
|
-
<% end %>
|
48
|
-
<%= footer.pagination_bar.next_page %>
|
49
|
-
<% end %>
|
50
|
-
<% end %>
|
51
|
-
<% end %>
|
52
|
-
</div>
|
@@ -1,338 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ariadne
|
4
|
-
# The `TableNavComponent` is used to render a table navigation.
|
5
|
-
class TableNavComponent < Ariadne::Component
|
6
|
-
DEFAULT_CLASSES = "ariadne-min-w-full ariadne-divide-y ariadne-divide-gray-300"
|
7
|
-
|
8
|
-
renders_one :header_row, "BaseRowItem::HeaderRowItem"
|
9
|
-
|
10
|
-
renders_many :rows, "BaseRowItem::RowItem"
|
11
|
-
|
12
|
-
renders_one :footer, "FooterItem"
|
13
|
-
|
14
|
-
DEFAULT_TAG = :table
|
15
|
-
|
16
|
-
# @example Default
|
17
|
-
#
|
18
|
-
# <%= render(Ariadne::TableNavComponent.new) do |table| %>
|
19
|
-
# <%= table.with_header_row do |header_row| %>
|
20
|
-
# <% header_row.with_selection_cell do %>
|
21
|
-
# Status
|
22
|
-
# <% end %>
|
23
|
-
# <% header_row.with_main_cell do %>
|
24
|
-
# State
|
25
|
-
# <% end %>
|
26
|
-
# <% header_row.with_action_cell do %>
|
27
|
-
# Labels
|
28
|
-
# <% end %>
|
29
|
-
# <% end %>
|
30
|
-
# <%= table.with_row do |row| %>
|
31
|
-
# <% row.with_selection_cell do %>
|
32
|
-
# "G"
|
33
|
-
# <% end %>
|
34
|
-
# <% row.with_main_cell do %>
|
35
|
-
# "California"
|
36
|
-
# <% end %>
|
37
|
-
# <% row.with_metadata_cell do %>
|
38
|
-
# "Labels"
|
39
|
-
# <% end %>
|
40
|
-
# <% end %>
|
41
|
-
# <%= table.with_row do |row| %>
|
42
|
-
# <% row.with_selection_cell do %>
|
43
|
-
# "V"
|
44
|
-
# <% end %>
|
45
|
-
# <% row.with_main_cell do %>
|
46
|
-
# "New York"
|
47
|
-
# <% end %>
|
48
|
-
# <% row.with_metadata_cell do %>
|
49
|
-
# "Labels"
|
50
|
-
# <% end %>
|
51
|
-
# <% end %>
|
52
|
-
# <%= table.with_row do |row| %>
|
53
|
-
# <% row.with_cell do %>
|
54
|
-
# "D"
|
55
|
-
# <% end %>
|
56
|
-
# <% row.with_selection_cell do %>
|
57
|
-
# "Texas"
|
58
|
-
# <% end %>
|
59
|
-
# <% row.with_metadata_cell do %>
|
60
|
-
# "Labels"
|
61
|
-
# <% end %>
|
62
|
-
# <% end %>
|
63
|
-
# <% end %>
|
64
|
-
#
|
65
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
66
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
67
|
-
def initialize(classes: "", attributes: {})
|
68
|
-
@tag = DEFAULT_TAG
|
69
|
-
@classes = merge_class_names(
|
70
|
-
DEFAULT_CLASSES,
|
71
|
-
classes,
|
72
|
-
)
|
73
|
-
|
74
|
-
@attributes = attributes
|
75
|
-
end
|
76
|
-
|
77
|
-
def has_header_row?
|
78
|
-
header_row.present?
|
79
|
-
end
|
80
|
-
|
81
|
-
def has_footer?
|
82
|
-
footer.present?
|
83
|
-
end
|
84
|
-
|
85
|
-
# This component is part of `TableNavComponent` and should not be
|
86
|
-
# used as a standalone component.
|
87
|
-
class BaseRowItem < Ariadne::TableNavComponent
|
88
|
-
BASE_ROW_CLASSES = ""
|
89
|
-
|
90
|
-
DEFAULT_TAG = :tr
|
91
|
-
|
92
|
-
BASE_SELECTION_CLASSES = ""
|
93
|
-
renders_one :selection_cell, lambda { |classes: "", attributes: {}|
|
94
|
-
actual_classes = merge_class_names(BASE_SELECTION_CLASSES, classes)
|
95
|
-
if header?
|
96
|
-
Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: actual_classes, attributes: attributes)
|
97
|
-
else
|
98
|
-
Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
|
99
|
-
end
|
100
|
-
}
|
101
|
-
|
102
|
-
BASE_MAIN_CLASSES = "ariadne-pr-5"
|
103
|
-
renders_one :main_cell, lambda { |classes: "", attributes: {}|
|
104
|
-
actual_classes = merge_class_names(BASE_MAIN_CLASSES, classes)
|
105
|
-
if header?
|
106
|
-
Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: actual_classes, attributes: attributes)
|
107
|
-
else
|
108
|
-
Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
|
109
|
-
end
|
110
|
-
}
|
111
|
-
|
112
|
-
attr_reader :classes, :attributes
|
113
|
-
|
114
|
-
def initialize(classes: "", attributes: {})
|
115
|
-
@tag = DEFAULT_TAG
|
116
|
-
@classes = merge_class_names(BASE_ROW_CLASSES, classes)
|
117
|
-
|
118
|
-
@attributes = attributes
|
119
|
-
end
|
120
|
-
|
121
|
-
private def linked?
|
122
|
-
@href.present?
|
123
|
-
end
|
124
|
-
|
125
|
-
private def header?
|
126
|
-
@header.present?
|
127
|
-
end
|
128
|
-
|
129
|
-
def call
|
130
|
-
Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)
|
131
|
-
end
|
132
|
-
|
133
|
-
# This component is part of `TableNavComponent` and should not be
|
134
|
-
# used as a standalone component.
|
135
|
-
class RowItem < Ariadne::TableNavComponent::BaseRowItem
|
136
|
-
DEFAULT_ROW_CLASSES = "ariadne-bg-white"
|
137
|
-
DEFAULT_METADATA_CLASSES = ""
|
138
|
-
renders_many :metadata_cells, lambda { |classes: "", attributes: {}|
|
139
|
-
actual_classes = merge_class_names(DEFAULT_METADATA_CLASSES, classes)
|
140
|
-
Ariadne::TableNavComponent::BaseCellItem::CellItem.new(classes: actual_classes, attributes: attributes)
|
141
|
-
}
|
142
|
-
|
143
|
-
attr_reader :href
|
144
|
-
|
145
|
-
def initialize(classes: "", attributes: {})
|
146
|
-
@header = false
|
147
|
-
|
148
|
-
actual_classes = merge_class_names(DEFAULT_ROW_CLASSES, classes)
|
149
|
-
|
150
|
-
super(classes: actual_classes, attributes: attributes)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# This component is part of `TableNavComponent` and should not be
|
155
|
-
# used as a standalone component.
|
156
|
-
class HeaderRowItem < Ariadne::TableNavComponent::BaseRowItem
|
157
|
-
DEFAULT_HEADER_ROW_CLASSES = "ariadne-bg-gray-50 ariadne-text-left"
|
158
|
-
|
159
|
-
renders_many :action_cells, lambda { |classes: "", attributes: {}|
|
160
|
-
Ariadne::TableNavComponent::BaseCellItem::HeaderCellItem.new(classes: classes, attributes: attributes)
|
161
|
-
}
|
162
|
-
|
163
|
-
def initialize(classes: "", attributes: {})
|
164
|
-
@header = true
|
165
|
-
|
166
|
-
actual_classes = merge_class_names(
|
167
|
-
DEFAULT_HEADER_ROW_CLASSES,
|
168
|
-
classes,
|
169
|
-
)
|
170
|
-
|
171
|
-
super(classes: actual_classes, attributes: attributes)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# This component is part of `TableNavComponent` and should not be
|
177
|
-
# used as a standalone component.
|
178
|
-
class BaseCellItem < Ariadne::TableNavComponent
|
179
|
-
DEFAULT_CELL_CLASSES = "ariadne-py-3.5 ariadne-pl-4 ariadne-pr-3 ariadne-text-left ariadne-text-sm ariadne-text-gray-900"
|
180
|
-
|
181
|
-
attr_writer :first, :last
|
182
|
-
|
183
|
-
def initialize(classes: "", attributes: {})
|
184
|
-
@classes = merge_class_names(
|
185
|
-
DEFAULT_CELL_CLASSES,
|
186
|
-
classes,
|
187
|
-
)
|
188
|
-
|
189
|
-
@attributes = attributes
|
190
|
-
end
|
191
|
-
|
192
|
-
def call
|
193
|
-
render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do
|
194
|
-
content
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
# This component is part of `TableNavComponent` and should not be
|
199
|
-
# used as a standalone component.
|
200
|
-
class HeaderCellItem < Ariadne::TableNavComponent::BaseCellItem
|
201
|
-
DEFAULT_HEADER_CELL_CLASSES = "ariadne-py-3.5 ariadne-pl-4 ariadne-pr-3 ariadne-text-left ariadne-text-sm ariadne-font-semibold ariadne-text-gray-900 sm:ariadne-pl-6 md:ariadne-pl-0"
|
202
|
-
|
203
|
-
DEFAULT_TAG = :th
|
204
|
-
|
205
|
-
WIDTH_CLASSES = {
|
206
|
-
none: "ariadne-flex-none ariadne-w-14 ariadne-px-4",
|
207
|
-
default: "ariadne-flex-initial",
|
208
|
-
narrow: "ariadne-flex-initial ariadne-w-1/5 ariadne-text-right",
|
209
|
-
wide: "ariadne-flex-grow ariadne-w-3/5 sm:ariadne-pl-6",
|
210
|
-
}
|
211
|
-
|
212
|
-
# TODO: add one_of check for width
|
213
|
-
def initialize(classes: "", attributes: {})
|
214
|
-
@tag = DEFAULT_TAG
|
215
|
-
actual_classes = merge_class_names(DEFAULT_HEADER_CELL_CLASSES, classes)
|
216
|
-
attributes["scope"] = "col"
|
217
|
-
super(classes: actual_classes, attributes: attributes)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
# This component is part of `TableNavComponent` and should not be
|
222
|
-
# used as a standalone component.
|
223
|
-
class CellItem < Ariadne::TableNavComponent::BaseCellItem
|
224
|
-
DEFAULT_CELL_CLASSES = ""
|
225
|
-
|
226
|
-
DEFAULT_TAG = :td
|
227
|
-
|
228
|
-
# TODO: add one_of check for width
|
229
|
-
def initialize(classes: "", attributes: {})
|
230
|
-
@tag = DEFAULT_TAG
|
231
|
-
actual_classes = merge_class_names(DEFAULT_CELL_CLASSES, classes)
|
232
|
-
super(classes: actual_classes, attributes: attributes)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
# This component is part of `TableNavComponent` and should not be
|
238
|
-
# used as a standalone component.
|
239
|
-
class FooterItem < Ariadne::TableNavComponent
|
240
|
-
DEFAULT_FOOTER_CLASSES = "ariadne-border-none ariadne-flex ariadne-items-center ariadne-justify-between ariadne-px-4 ariadne-py-3 sm:ariadne-px-6"
|
241
|
-
|
242
|
-
DEFAULT_RESULT_CLASSES = "ariadne-text-sm ariadne-text-gray-700"
|
243
|
-
renders_one :records_info, lambda { |classes: "", attributes: {}|
|
244
|
-
actual_classes = merge_class_names(DEFAULT_RESULT_CLASSES, classes)
|
245
|
-
Ariadne::BaseComponent.new(tag: :p, classes: actual_classes, attributes: attributes)
|
246
|
-
}
|
247
|
-
|
248
|
-
renders_one :pagination_bar, "Ariadne::TableNavComponent::PaginationBarItem"
|
249
|
-
|
250
|
-
attr_reader :classes, :attributes
|
251
|
-
|
252
|
-
def initialize(classes: "", attributes: {})
|
253
|
-
@classes = merge_class_names(
|
254
|
-
DEFAULT_FOOTER_CLASSES,
|
255
|
-
classes,
|
256
|
-
)
|
257
|
-
|
258
|
-
@attributes = attributes
|
259
|
-
end
|
260
|
-
|
261
|
-
def call
|
262
|
-
render(Ariadne::BaseComponent.new(tag: :div, classes: @classes, attributes: @attributes)) do
|
263
|
-
records_info.to_s + pagination_bar.to_s
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
# This component is part of `TableNavComponent` and should not be
|
269
|
-
# used as a standalone component.
|
270
|
-
class PaginationBarItem < Ariadne::FooterComponent
|
271
|
-
DEFAULT_PREV_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-rounded-l-md ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-2 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
|
272
|
-
renders_one :prev_page, lambda { |disabled: false, href:, classes: "", attributes: {}|
|
273
|
-
if disabled
|
274
|
-
actual_classes = merge_class_names(DEFAULT_PREV_PAGE_CLASSES, "ariadne-bg-gray-50", classes)
|
275
|
-
|
276
|
-
render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) do
|
277
|
-
render(Ariadne::HeroiconComponent.new(icon: "chevron-left", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
|
278
|
-
end
|
279
|
-
else
|
280
|
-
actual_classes = merge_class_names(DEFAULT_PREV_PAGE_CLASSES, "hover:ariadne-bg-gray-50", classes)
|
281
|
-
attributes[:"aria-label"] = "previous"
|
282
|
-
|
283
|
-
render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
|
284
|
-
render(Ariadne::HeroiconComponent.new(icon: "chevron-left", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
|
285
|
-
end
|
286
|
-
end
|
287
|
-
}
|
288
|
-
|
289
|
-
DEFAULT_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
|
290
|
-
DEFAULT_CURRENT_PAGE_CLASSES = "ariadne-relative ariadne-z-10 ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-slate-500 ariadne-bg-slate-50 ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-slate-600 focus:ariadne-z-20"
|
291
|
-
DEFAULT_GAP_CLASSES = " ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-700"
|
292
|
-
renders_many :items, lambda { |link:, classes: "", attributes: {}|
|
293
|
-
page, href = link
|
294
|
-
if page.is_a?(Integer)
|
295
|
-
actual_classes = merge_class_names(DEFAULT_PAGE_CLASSES, classes)
|
296
|
-
render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) { page.to_s }
|
297
|
-
elsif page.is_a?(String)
|
298
|
-
actual_classes = merge_class_names(DEFAULT_CURRENT_PAGE_CLASSES, classes)
|
299
|
-
render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) { page.to_s }
|
300
|
-
elsif page == :gap
|
301
|
-
actual_classes = merge_class_names(DEFAULT_GAP_CLASSES, classes)
|
302
|
-
render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) { h(href.to_s) }
|
303
|
-
end
|
304
|
-
}
|
305
|
-
|
306
|
-
DEFAULT_NEXT_PAGE_CLASSES = "ariadne-relative ariadne-inline-flex ariadne-items-center ariadne-rounded-r-md ariadne-border ariadne-border-gray-300 ariadne-bg-white ariadne-px-2 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-500 hover:ariadne-bg-gray-50 focus:ariadne-z-20"
|
307
|
-
renders_one :next_page, lambda { |disabled: false, href:, classes: "", attributes: {}|
|
308
|
-
if disabled
|
309
|
-
actual_classes = merge_class_names(DEFAULT_NEXT_PAGE_CLASSES, "ariadne-bg-gray-50", classes)
|
310
|
-
|
311
|
-
render(Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes)) do
|
312
|
-
render(Ariadne::HeroiconComponent.new(icon: "chevron-right", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
|
313
|
-
end
|
314
|
-
else
|
315
|
-
actual_classes = merge_class_names(DEFAULT_NEXT_PAGE_CLASSES, "hover:ariadne-bg-gray-50", classes)
|
316
|
-
attributes[:"aria-label"] = "next"
|
317
|
-
|
318
|
-
render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
|
319
|
-
render(Ariadne::HeroiconComponent.new(icon: "chevron-right", size: :sm, variant: :mini, text_attributes: { "aria-hidden": true }, text_classes: "ariadne-sr-only"))
|
320
|
-
end
|
321
|
-
end
|
322
|
-
}
|
323
|
-
|
324
|
-
attr_reader :classes, :attributes
|
325
|
-
|
326
|
-
DEFAULT_PAGINATOR_CLASSES = "ariadne-flex ariadne-items-center ariadne-justify-between ariadne-m-10"
|
327
|
-
def initialize(classes: "", attributes: {})
|
328
|
-
@classes = merge_class_names(
|
329
|
-
DEFAULT_PAGINATOR_CLASSES,
|
330
|
-
classes,
|
331
|
-
)
|
332
|
-
|
333
|
-
@attributes = attributes
|
334
|
-
@attributes[:"aria-label"] ||= "paginator"
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|
338
|
-
end
|