hakumi_components 0.1.18.pre → 0.1.19.pre
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/CHANGELOG.md +32 -2
- data/README.md +208 -381
- data/app/assets/javascripts/hakumi_components.js +40 -34
- data/app/assets/stylesheets/hakumi_components.css +1 -1
- data/app/components/hakumi_components/admin_panel/component.rb +19 -9
- data/app/components/hakumi_components/affix/component.rb +54 -30
- data/app/components/hakumi_components/alert/component.html.erb +2 -2
- data/app/components/hakumi_components/alert/component.rb +68 -18
- data/app/components/hakumi_components/anchor/component.rb +35 -27
- data/app/components/hakumi_components/anchor/link/component.html.erb +1 -1
- data/app/components/hakumi_components/anchor/link/component.rb +28 -9
- data/app/components/hakumi_components/autocomplete/component.html.erb +86 -66
- data/app/components/hakumi_components/autocomplete/component.rb +115 -89
- data/app/components/hakumi_components/avatar/component.rb +45 -12
- data/app/components/hakumi_components/badge/component.rb +99 -45
- data/app/components/hakumi_components/base_component.rb +290 -91
- data/app/components/hakumi_components/breadcrumb/component.rb +16 -5
- data/app/components/hakumi_components/breadcrumb/item/component.html.erb +5 -5
- data/app/components/hakumi_components/breadcrumb/item/component.rb +56 -8
- data/app/components/hakumi_components/breadcrumb/item/menu_entry.rb +71 -0
- data/app/components/hakumi_components/button/component.rb +62 -20
- data/app/components/hakumi_components/calendar/component.html.erb +19 -19
- data/app/components/hakumi_components/calendar/component.rb +225 -202
- data/app/components/hakumi_components/calendar/day_cell.rb +62 -0
- data/app/components/hakumi_components/calendar/display_model.rb +237 -0
- data/app/components/hakumi_components/calendar/event_entry.rb +54 -0
- data/app/components/hakumi_components/calendar/locale_pack.rb +28 -0
- data/app/components/hakumi_components/calendar/panel_entry.rb +48 -0
- data/app/components/hakumi_components/calendar/week_row.rb +28 -0
- data/app/components/hakumi_components/card/component.html.erb +2 -2
- data/app/components/hakumi_components/card/component.rb +76 -49
- data/app/components/hakumi_components/card/grid/component.html.erb +1 -1
- data/app/components/hakumi_components/card/grid/component.rb +23 -17
- data/app/components/hakumi_components/card/meta/component.html.erb +8 -8
- data/app/components/hakumi_components/card/meta/component.rb +42 -24
- data/app/components/hakumi_components/carousel/autoplay_config.rb +27 -0
- data/app/components/hakumi_components/carousel/component.rb +85 -67
- data/app/components/hakumi_components/carousel/dots_config.rb +36 -0
- data/app/components/hakumi_components/cascader/component.html.erb +54 -36
- data/app/components/hakumi_components/cascader/component.rb +111 -62
- data/app/components/hakumi_components/checkbox/component.html.erb +5 -5
- data/app/components/hakumi_components/checkbox/component.rb +40 -6
- data/app/components/hakumi_components/checkbox/group/component.html.erb +4 -4
- data/app/components/hakumi_components/checkbox/group/component.rb +40 -13
- data/app/components/hakumi_components/checkbox/group/option.rb +34 -0
- data/app/components/hakumi_components/collapse/component.rb +64 -48
- data/app/components/hakumi_components/collapse/panel/component.rb +64 -21
- data/app/components/hakumi_components/color_picker/component.html.erb +21 -22
- data/app/components/hakumi_components/color_picker/component.rb +159 -49
- data/app/components/hakumi_components/color_picker/preset_group.rb +27 -0
- data/app/components/hakumi_components/concerns/form_field.rb +169 -68
- data/app/components/hakumi_components/concerns/form_field_contract.rb +57 -0
- data/app/components/hakumi_components/concerns/form_field_interface.rb +16 -0
- data/app/components/hakumi_components/concerns/input_control.rb +111 -0
- data/app/components/hakumi_components/concerns/input_control_contract.rb +47 -0
- data/app/components/hakumi_components/concerns/input_control_interface.rb +34 -0
- data/app/components/hakumi_components/concerns/selection_control.rb +122 -0
- data/app/components/hakumi_components/concerns/selection_control_contract.rb +47 -0
- data/app/components/hakumi_components/concerns/selection_control_interface.rb +34 -0
- data/app/components/hakumi_components/container/component.rb +29 -14
- data/app/components/hakumi_components/date_picker/component.html.erb +1 -3
- data/app/components/hakumi_components/date_picker/component.rb +130 -16
- data/app/components/hakumi_components/date_picker/range_picker.rb +159 -28
- data/app/components/hakumi_components/date_picker/shared_rendering.rb +151 -61
- data/app/components/hakumi_components/descriptions/component.html.erb +6 -6
- data/app/components/hakumi_components/descriptions/component.rb +98 -61
- data/app/components/hakumi_components/descriptions/item/component.rb +32 -8
- data/app/components/hakumi_components/divider/component.rb +36 -16
- data/app/components/hakumi_components/drawer/component.html.erb +2 -2
- data/app/components/hakumi_components/drawer/component.rb +112 -29
- data/app/components/hakumi_components/dropdown/component.rb +32 -35
- data/app/components/hakumi_components/dropdown/divider/component.rb +4 -0
- data/app/components/hakumi_components/dropdown/item/component.rb +42 -16
- data/app/components/hakumi_components/empty/component.rb +66 -31
- data/app/components/hakumi_components/flex/component.rb +39 -21
- data/app/components/hakumi_components/float_button/back_top/component.rb +35 -28
- data/app/components/hakumi_components/float_button/component.rb +161 -75
- data/app/components/hakumi_components/float_button/group/component.rb +85 -98
- data/app/components/hakumi_components/float_button/group_cluster/component.rb +46 -54
- data/app/components/hakumi_components/float_button/group_spec.rb +259 -0
- data/app/components/hakumi_components/float_button/item_spec.rb +115 -0
- data/app/components/hakumi_components/float_button/position_config.rb +68 -0
- data/app/components/hakumi_components/form/item/component.rb +34 -27
- data/app/components/hakumi_components/grid/col/component.rb +88 -17
- data/app/components/hakumi_components/grid/row/component.rb +35 -17
- data/app/components/hakumi_components/icon/component.rb +49 -49
- data/app/components/hakumi_components/image/component.html.erb +7 -7
- data/app/components/hakumi_components/image/component.rb +103 -40
- data/app/components/hakumi_components/image/preview_group/component.html.erb +1 -1
- data/app/components/hakumi_components/image/preview_group/component.rb +41 -36
- data/app/components/hakumi_components/image/preview_group/item.rb +48 -0
- data/app/components/hakumi_components/input/component.html.erb +1 -1
- data/app/components/hakumi_components/input/component.rb +142 -66
- data/app/components/hakumi_components/input/password/component.rb +30 -41
- data/app/components/hakumi_components/input/text_area/component.html.erb +2 -2
- data/app/components/hakumi_components/input/text_area/component.rb +89 -42
- data/app/components/hakumi_components/input_number/component.html.erb +5 -5
- data/app/components/hakumi_components/input_number/component.rb +137 -55
- data/app/components/hakumi_components/layout/component.html.erb +1 -1
- data/app/components/hakumi_components/layout/component.rb +23 -16
- data/app/components/hakumi_components/layout/content/component.html.erb +1 -1
- data/app/components/hakumi_components/layout/content/component.rb +24 -14
- data/app/components/hakumi_components/layout/footer/component.html.erb +1 -1
- data/app/components/hakumi_components/layout/footer/component.rb +24 -14
- data/app/components/hakumi_components/layout/header/component.html.erb +1 -1
- data/app/components/hakumi_components/layout/header/component.rb +24 -14
- data/app/components/hakumi_components/layout/sider/component.html.erb +1 -1
- data/app/components/hakumi_components/layout/sider/component.rb +83 -49
- data/app/components/hakumi_components/mentions/coercion.rb +46 -0
- data/app/components/hakumi_components/mentions/component.html.erb +6 -6
- data/app/components/hakumi_components/mentions/component.rb +131 -67
- data/app/components/hakumi_components/mentions/option.rb +30 -0
- data/app/components/hakumi_components/menu/component.rb +50 -59
- data/app/components/hakumi_components/menu/divider/component.rb +4 -0
- data/app/components/hakumi_components/menu/group/component.rb +16 -15
- data/app/components/hakumi_components/menu/item/component.rb +42 -19
- data/app/components/hakumi_components/menu/sub_menu/component.rb +49 -37
- data/app/components/hakumi_components/message/component.rb +62 -27
- data/app/components/hakumi_components/modal/component.html.erb +6 -6
- data/app/components/hakumi_components/modal/component.rb +93 -40
- data/app/components/hakumi_components/modal/confirm/component.html.erb +2 -2
- data/app/components/hakumi_components/modal/confirm/component.rb +49 -8
- data/app/components/hakumi_components/modal/error/component.rb +8 -39
- data/app/components/hakumi_components/modal/info/component.rb +6 -40
- data/app/components/hakumi_components/modal/status_component.rb +150 -0
- data/app/components/hakumi_components/modal/success/component.rb +6 -40
- data/app/components/hakumi_components/modal/warning/component.rb +14 -44
- data/app/components/hakumi_components/notification/component.rb +72 -38
- data/app/components/hakumi_components/pagination/component.html.erb +7 -11
- data/app/components/hakumi_components/pagination/component.rb +105 -72
- data/app/components/hakumi_components/pagination/page_item.rb +49 -0
- data/app/components/hakumi_components/popconfirm/component.rb +67 -19
- data/app/components/hakumi_components/popover/component.html.erb +2 -2
- data/app/components/hakumi_components/popover/component.rb +102 -38
- data/app/components/hakumi_components/progress/attribute_renderer.rb +354 -0
- data/app/components/hakumi_components/progress/circle_geometry.rb +76 -0
- data/app/components/hakumi_components/progress/component.html.erb +18 -17
- data/app/components/hakumi_components/progress/component.rb +230 -402
- data/app/components/hakumi_components/progress/controller_locals_parser.rb +130 -0
- data/app/components/hakumi_components/progress/info_tooltip_policy.rb +39 -0
- data/app/components/hakumi_components/progress/info_value.rb +75 -0
- data/app/components/hakumi_components/progress/status_state.rb +31 -0
- data/app/components/hakumi_components/progress/steps_renderer.rb +149 -0
- data/app/components/hakumi_components/progress/stroke_gradient_value.rb +90 -0
- data/app/components/hakumi_components/qr_code/component.rb +138 -72
- data/app/components/hakumi_components/radio/component.html.erb +3 -3
- data/app/components/hakumi_components/radio/component.rb +42 -9
- data/app/components/hakumi_components/radio/group/component.html.erb +9 -9
- data/app/components/hakumi_components/radio/group/component.rb +76 -27
- data/app/components/hakumi_components/radio/group/option.rb +43 -0
- data/app/components/hakumi_components/rate/component.html.erb +1 -1
- data/app/components/hakumi_components/rate/component.rb +55 -9
- data/app/components/hakumi_components/result/component.rb +87 -37
- data/app/components/hakumi_components/segmented/component.html.erb +1 -1
- data/app/components/hakumi_components/segmented/component.rb +81 -118
- data/app/components/hakumi_components/segmented/option.rb +191 -0
- data/app/components/hakumi_components/select/component.html.erb +19 -19
- data/app/components/hakumi_components/select/component.rb +88 -37
- data/app/components/hakumi_components/selection_control/coercion.rb +161 -0
- data/app/components/hakumi_components/selection_control/entry.rb +22 -0
- data/app/components/hakumi_components/selection_control/option.rb +42 -0
- data/app/components/hakumi_components/selection_control/option_group.rb +34 -0
- data/app/components/hakumi_components/selection_control/tree_node.rb +123 -0
- data/app/components/hakumi_components/skeleton/avatar/component.rb +36 -14
- data/app/components/hakumi_components/skeleton/avatar_config.rb +79 -0
- data/app/components/hakumi_components/skeleton/button/component.rb +32 -14
- data/app/components/hakumi_components/skeleton/component.rb +79 -93
- data/app/components/hakumi_components/skeleton/image/component.rb +46 -22
- data/app/components/hakumi_components/skeleton/input/component.rb +25 -10
- data/app/components/hakumi_components/skeleton/node/component.rb +23 -7
- data/app/components/hakumi_components/skeleton/paragraph_config.rb +92 -0
- data/app/components/hakumi_components/skeleton/title_config.rb +31 -0
- data/app/components/hakumi_components/slider/component.html.erb +11 -11
- data/app/components/hakumi_components/slider/component.rb +172 -53
- data/app/components/hakumi_components/slider/mark.rb +27 -0
- data/app/components/hakumi_components/space/compact/component.html.erb +1 -3
- data/app/components/hakumi_components/space/compact/component.rb +35 -19
- data/app/components/hakumi_components/space/component.html.erb +1 -1
- data/app/components/hakumi_components/space/component.rb +75 -39
- data/app/components/hakumi_components/spin/component.rb +92 -31
- data/app/components/hakumi_components/splitter/component.html.erb +9 -3
- data/app/components/hakumi_components/splitter/component.rb +55 -22
- data/app/components/hakumi_components/splitter/panel/component.html.erb +1 -3
- data/app/components/hakumi_components/splitter/panel/component.rb +64 -39
- data/app/components/hakumi_components/statistic/component.rb +143 -59
- data/app/components/hakumi_components/steps/component.rb +87 -55
- data/app/components/hakumi_components/steps/item/component.rb +59 -20
- data/app/components/hakumi_components/switch/component.html.erb +2 -3
- data/app/components/hakumi_components/switch/component.rb +62 -36
- data/app/components/hakumi_components/table/column/component.rb +80 -23
- data/app/components/hakumi_components/table/column_definition.rb +181 -0
- data/app/components/hakumi_components/table/column_group/component.rb +32 -21
- data/app/components/hakumi_components/table/component.html.erb +22 -31
- data/app/components/hakumi_components/table/component.rb +248 -509
- data/app/components/hakumi_components/table/concerns/attribute_helpers.rb +22 -0
- data/app/components/hakumi_components/table/concerns/cell_rendering.rb +277 -0
- data/app/components/hakumi_components/table/concerns/columns.rb +293 -91
- data/app/components/hakumi_components/table/concerns/editable.rb +36 -89
- data/app/components/hakumi_components/table/concerns/ellipsis.rb +31 -30
- data/app/components/hakumi_components/table/concerns/fixed_columns.rb +26 -19
- data/app/components/hakumi_components/table/concerns/surface_rendering.rb +365 -0
- data/app/components/hakumi_components/table/configs.rb +518 -0
- data/app/components/hakumi_components/table/definition_types.rb +40 -0
- data/app/components/hakumi_components/table/display_rows.rb +56 -0
- data/app/components/hakumi_components/table/ellipsis_config.rb +143 -0
- data/app/components/hakumi_components/table/fixed_offset.rb +36 -0
- data/app/components/hakumi_components/table/header_cell.rb +23 -0
- data/app/components/hakumi_components/table/row_record.rb +60 -0
- data/app/components/hakumi_components/table/row_render_state.rb +85 -0
- data/app/components/hakumi_components/tabs/component.html.erb +8 -8
- data/app/components/hakumi_components/tabs/component.rb +114 -64
- data/app/components/hakumi_components/tabs/indicator_config.rb +34 -0
- data/app/components/hakumi_components/tabs/item/component.rb +73 -13
- data/app/components/hakumi_components/tag/component.rb +142 -47
- data/app/components/hakumi_components/tag/group/component.rb +18 -6
- data/app/components/hakumi_components/time_picker/component.html.erb +8 -8
- data/app/components/hakumi_components/time_picker/component.rb +71 -17
- data/app/components/hakumi_components/timeline/component.html.erb +3 -2
- data/app/components/hakumi_components/timeline/component.rb +188 -55
- data/app/components/hakumi_components/timeline/item/component.html.erb +2 -2
- data/app/components/hakumi_components/timeline/item/component.rb +121 -60
- data/app/components/hakumi_components/tooltip/component.html.erb +1 -1
- data/app/components/hakumi_components/tooltip/component.rb +89 -64
- data/app/components/hakumi_components/tour/component.rb +74 -49
- data/app/components/hakumi_components/tour/step.rb +86 -0
- data/app/components/hakumi_components/transfer/coercion.rb +66 -0
- data/app/components/hakumi_components/transfer/component.html.erb +171 -140
- data/app/components/hakumi_components/transfer/component.rb +232 -82
- data/app/components/hakumi_components/transfer/item.rb +54 -0
- data/app/components/hakumi_components/transfer/operations.rb +31 -0
- data/app/components/hakumi_components/tree/component.rb +219 -400
- data/app/components/hakumi_components/tree/concerns/node_rendering.rb +365 -0
- data/app/components/hakumi_components/tree/node.rb +276 -0
- data/app/components/hakumi_components/tree_select/component.html.erb +23 -9
- data/app/components/hakumi_components/tree_select/component.rb +116 -107
- data/app/components/hakumi_components/typography/base_component.rb +69 -36
- data/app/components/hakumi_components/typography/link/component.rb +63 -6
- data/app/components/hakumi_components/typography/paragraph/component.rb +6 -0
- data/app/components/hakumi_components/typography/text/component.rb +4 -0
- data/app/components/hakumi_components/typography/title/component.rb +61 -6
- data/app/components/hakumi_components/upload/component.html.erb +106 -88
- data/app/components/hakumi_components/upload/component.rb +222 -48
- data/app/components/hakumi_components/upload/file_entry.rb +53 -0
- data/app/controllers/hakumi_components/components_controller.rb +2 -1
- data/app/form_builders/hakumi_components/form_builder/contracts.rb +55 -0
- data/app/form_builders/hakumi_components/form_builder/field_context.rb +43 -0
- data/app/form_builders/hakumi_components/form_builder/model_binding.rb +163 -0
- data/app/form_builders/hakumi_components/form_builder.rb +238 -317
- data/app/helpers/hakumi_components/form_helper.rb +27 -23
- data/app/javascript/hakumi_components/controllers/hakumi/admin_panel_controller.js +5 -7
- data/app/javascript/hakumi_components/controllers/hakumi/back_top_controller.js +1 -1
- data/app/javascript/hakumi_components/controllers/hakumi/button_controller.js +108 -2
- data/app/javascript/hakumi_components/controllers/hakumi/calendar_controller.js +183 -95
- data/app/javascript/hakumi_components/controllers/hakumi/color_picker_controller.js +23 -285
- data/app/javascript/hakumi_components/controllers/hakumi/date_picker_controller.js +274 -262
- data/app/javascript/hakumi_components/controllers/hakumi/float_button_group_controller.js +2 -2
- data/app/javascript/hakumi_components/controllers/hakumi/message_controller.js +4 -2
- data/app/javascript/hakumi_components/controllers/hakumi/modal_controller.js +119 -125
- data/app/javascript/hakumi_components/controllers/hakumi/table/editable.js +291 -0
- data/app/javascript/hakumi_components/controllers/hakumi/table_controller.js +166 -366
- data/app/javascript/hakumi_components/controllers/hakumi/tabs_controller.js +8 -2
- data/app/javascript/hakumi_components/controllers/hakumi/tag_controller.js +27 -25
- data/app/javascript/hakumi_components/controllers/hakumi/tag_group_controller.js +19 -18
- data/app/javascript/hakumi_components/controllers/hakumi/theme_controller.js +116 -117
- data/app/javascript/hakumi_components/controllers/hakumi/transfer_controller.js +17 -1
- data/app/javascript/hakumi_components/controllers/hakumi/tree_controller.js +363 -78
- data/app/javascript/hakumi_components/controllers/hakumi/typography_controller.js +3 -3
- data/app/javascript/hakumi_components/controllers/hakumi/upload_controller.js +320 -204
- data/app/javascript/hakumi_components/core/render_component.js +37 -11
- data/app/javascript/hakumi_components/utils/color_helper.js +262 -0
- data/app/javascript/stylesheets/_base.scss +9 -0
- data/app/javascript/stylesheets/_hakumi_components.scss +1 -0
- data/app/javascript/stylesheets/components/_breadcrumb.scss +2 -2
- data/app/javascript/stylesheets/components/_calendar.scss +13 -13
- data/app/javascript/stylesheets/components/_cascader.scss +5 -5
- data/app/javascript/stylesheets/components/_checkbox.scss +9 -11
- data/app/javascript/stylesheets/components/_color_picker.scss +11 -11
- data/app/javascript/stylesheets/components/_date_picker.scss +4 -4
- data/app/javascript/stylesheets/components/_descriptions.scss +2 -2
- data/app/javascript/stylesheets/components/_drawer.scss +3 -3
- data/app/javascript/stylesheets/components/_dropdown.scss +2 -2
- data/app/javascript/stylesheets/components/_flex.scss +1 -1
- data/app/javascript/stylesheets/components/_float_button.scss +5 -5
- data/app/javascript/stylesheets/components/_form_item.scss +92 -0
- data/app/javascript/stylesheets/components/_image.scss +15 -15
- data/app/javascript/stylesheets/components/_input.scss +23 -113
- data/app/javascript/stylesheets/components/_layout.scss +27 -26
- data/app/javascript/stylesheets/components/_menu.scss +15 -15
- data/app/javascript/stylesheets/components/_modal.scss +13 -13
- data/app/javascript/stylesheets/components/_notification.scss +3 -3
- data/app/javascript/stylesheets/components/_popover.scss +1 -1
- data/app/javascript/stylesheets/components/_segmented.scss +3 -3
- data/app/javascript/stylesheets/components/_select.scss +6 -6
- data/app/javascript/stylesheets/components/_slider.scss +1 -1
- data/app/javascript/stylesheets/components/_spin.scss +2 -2
- data/app/javascript/stylesheets/components/_steps.scss +10 -10
- data/app/javascript/stylesheets/components/_switch.scss +11 -10
- data/app/javascript/stylesheets/components/_table.scss +6 -6
- data/app/javascript/stylesheets/components/_tag.scss +2 -2
- data/app/javascript/stylesheets/components/_tooltip.scss +4 -4
- data/app/javascript/stylesheets/components/_tree_select.scss +3 -3
- data/app/javascript/stylesheets/components/_typography.scss +3 -3
- data/app/javascript/stylesheets/components/_upload.scss +4 -4
- data/app/services/hakumi_components/component_handler.rb +95 -24
- data/app/services/hakumi_components/icon/loader.rb +84 -67
- data/app/services/hakumi_components/illustrations/loader.rb +35 -27
- data/app/views/hakumi/_alert.html.erb +4 -1
- data/app/views/hakumi/_drawer.html.erb +1 -1
- data/app/views/hakumi/_statistic.html.erb +11 -11
- data/lib/generators/hakumi_components/install_generator.rb +14 -1
- data/lib/hakumi_components/documentation/models.rb +290 -0
- data/lib/hakumi_components/documentation/node.rb +73 -0
- data/lib/hakumi_components/documentation.rb +139 -62
- data/lib/hakumi_components/engine.rb +17 -11
- data/lib/hakumi_components/file_size_checker.rb +215 -0
- data/lib/hakumi_components/locales/en.yml +115 -0
- data/lib/hakumi_components/rails/attribute_introspection.rb +39 -107
- data/lib/hakumi_components/rails/model_reflection.rb +154 -0
- data/lib/hakumi_components/rails/validation_introspection.rb +25 -73
- data/lib/hakumi_components/rails/validation_mapper.rb +148 -201
- data/lib/hakumi_components/rails.rb +2 -0
- data/lib/hakumi_components/stylesheet_ownership_checker.rb +191 -0
- data/lib/hakumi_components/types/form_field.rb +24 -0
- data/lib/hakumi_components/types/html.rb +28 -0
- data/lib/hakumi_components/types/rendering.rb +10 -0
- data/lib/hakumi_components/types/stimulus.rb +19 -0
- data/lib/hakumi_components/types/validation.rb +22 -0
- data/lib/hakumi_components/types.rb +13 -0
- data/lib/hakumi_components/version.rb +2 -1
- data/lib/hakumi_components.rb +26 -6
- data/lib/tasks/coverage.rake +1 -0
- metadata +100 -136
- data/sig/action_view/tag_builder.rbs +0 -24
- data/sig/active_support/concern_patch.rbs +0 -7
- data/sig/generators/hakumi_components/install_generator.rbs +0 -11
- data/sig/hakumi_components/admin_panel/component.rbs +0 -28
- data/sig/hakumi_components/affix/component.rbs +0 -44
- data/sig/hakumi_components/alert/component.rbs +0 -64
- data/sig/hakumi_components/anchor/component.rbs +0 -45
- data/sig/hakumi_components/anchor/link/component.rbs +0 -31
- data/sig/hakumi_components/autocomplete/component.rbs +0 -68
- data/sig/hakumi_components/avatar/component.rbs +0 -44
- data/sig/hakumi_components/badge/component.rbs +0 -41
- data/sig/hakumi_components/base_component.rbs +0 -82
- data/sig/hakumi_components/breadcrumb/component.rbs +0 -21
- data/sig/hakumi_components/breadcrumb/item/component.rbs +0 -36
- data/sig/hakumi_components/button/component.rbs +0 -56
- data/sig/hakumi_components/calendar/component.rbs +0 -41
- data/sig/hakumi_components/card/component.rbs +0 -50
- data/sig/hakumi_components/card/grid/component.rbs +0 -21
- data/sig/hakumi_components/card/meta/component.rbs +0 -25
- data/sig/hakumi_components/carousel/component.rbs +0 -88
- data/sig/hakumi_components/cascader/component.rbs +0 -52
- data/sig/hakumi_components/checkbox/component.rbs +0 -46
- data/sig/hakumi_components/checkbox/group/component.rbs +0 -34
- data/sig/hakumi_components/collapse/component.rbs +0 -57
- data/sig/hakumi_components/collapse/panel/component.rbs +0 -47
- data/sig/hakumi_components/color_picker/component.rbs +0 -80
- data/sig/hakumi_components/concerns/form_field.rbs +0 -89
- data/sig/hakumi_components/container/component.rbs +0 -37
- data/sig/hakumi_components/date_picker/component.rbs +0 -72
- data/sig/hakumi_components/date_picker/range_picker.rbs +0 -68
- data/sig/hakumi_components/date_picker/shared_rendering.rbs +0 -41
- data/sig/hakumi_components/descriptions/component.rbs +0 -59
- data/sig/hakumi_components/descriptions/item/component.rbs +0 -31
- data/sig/hakumi_components/divider/component.rbs +0 -39
- data/sig/hakumi_components/drawer/component.rbs +0 -66
- data/sig/hakumi_components/dropdown/component.rbs +0 -45
- data/sig/hakumi_components/dropdown/divider/component.rbs +0 -11
- data/sig/hakumi_components/dropdown/item/component.rbs +0 -45
- data/sig/hakumi_components/empty/component.rbs +0 -40
- data/sig/hakumi_components/flex/component.rbs +0 -47
- data/sig/hakumi_components/float_button/back_top/component.rbs +0 -45
- data/sig/hakumi_components/float_button/component.rbs +0 -80
- data/sig/hakumi_components/float_button/group/component.rbs +0 -95
- data/sig/hakumi_components/float_button/group_cluster/component.rbs +0 -60
- data/sig/hakumi_components/form/item/component.rbs +0 -39
- data/sig/hakumi_components/form_builder.rbs +0 -37
- data/sig/hakumi_components/grid/col/component.rbs +0 -50
- data/sig/hakumi_components/grid/row/component.rbs +0 -46
- data/sig/hakumi_components/icon/component.rbs +0 -56
- data/sig/hakumi_components/image/component.rbs +0 -56
- data/sig/hakumi_components/image/preview_group/component.rbs +0 -28
- data/sig/hakumi_components/input/component.rbs +0 -71
- data/sig/hakumi_components/input/password/component.rbs +0 -27
- data/sig/hakumi_components/input/text_area/component.rbs +0 -42
- data/sig/hakumi_components/input_number/component.rbs +0 -85
- data/sig/hakumi_components/layout/component.rbs +0 -21
- data/sig/hakumi_components/layout/content/component.rbs +0 -19
- data/sig/hakumi_components/layout/footer/component.rbs +0 -19
- data/sig/hakumi_components/layout/header/component.rbs +0 -19
- data/sig/hakumi_components/layout/sider/component.rbs +0 -19
- data/sig/hakumi_components/mentions/component.rbs +0 -75
- data/sig/hakumi_components/menu/component.rbs +0 -52
- data/sig/hakumi_components/menu/divider/component.rbs +0 -11
- data/sig/hakumi_components/menu/group/component.rbs +0 -20
- data/sig/hakumi_components/menu/item/component.rbs +0 -42
- data/sig/hakumi_components/menu/sub_menu/component.rbs +0 -37
- data/sig/hakumi_components/message/component.rbs +0 -50
- data/sig/hakumi_components/modal/component.rbs +0 -76
- data/sig/hakumi_components/modal/confirm/component.rbs +0 -32
- data/sig/hakumi_components/modal/error/component.rbs +0 -27
- data/sig/hakumi_components/modal/info/component.rbs +0 -27
- data/sig/hakumi_components/modal/success/component.rbs +0 -27
- data/sig/hakumi_components/modal/warning/component.rbs +0 -27
- data/sig/hakumi_components/notification/component.rbs +0 -64
- data/sig/hakumi_components/pagination/component.rbs +0 -113
- data/sig/hakumi_components/popconfirm/component.rbs +0 -52
- data/sig/hakumi_components/popover/component.rbs +0 -66
- data/sig/hakumi_components/progress/component.rbs +0 -201
- data/sig/hakumi_components/qr_code/component.rbs +0 -111
- data/sig/hakumi_components/radio/component.rbs +0 -55
- data/sig/hakumi_components/radio/group/component.rbs +0 -71
- data/sig/hakumi_components/rails/attribute_introspection.rbs +0 -16
- data/sig/hakumi_components/rails/validation_introspection.rbs +0 -18
- data/sig/hakumi_components/rails/validation_mapper.rbs +0 -53
- data/sig/hakumi_components/rails.rbs +0 -6
- data/sig/hakumi_components/rate/component.rbs +0 -56
- data/sig/hakumi_components/result/component.rbs +0 -65
- data/sig/hakumi_components/segmented/component.rbs +0 -72
- data/sig/hakumi_components/select/component.rbs +0 -73
- data/sig/hakumi_components/skeleton/avatar/component.rbs +0 -23
- data/sig/hakumi_components/skeleton/button/component.rbs +0 -24
- data/sig/hakumi_components/skeleton/component.rbs +0 -76
- data/sig/hakumi_components/skeleton/image/component.rbs +0 -22
- data/sig/hakumi_components/skeleton/input/component.rbs +0 -23
- data/sig/hakumi_components/skeleton/node/component.rbs +0 -21
- data/sig/hakumi_components/slider/component.rbs +0 -85
- data/sig/hakumi_components/space/compact/component.rbs +0 -21
- data/sig/hakumi_components/space/component.rbs +0 -47
- data/sig/hakumi_components/spin/component.rbs +0 -77
- data/sig/hakumi_components/splitter/component.rbs +0 -27
- data/sig/hakumi_components/splitter/panel/component.rbs +0 -36
- data/sig/hakumi_components/statistic/component.rbs +0 -97
- data/sig/hakumi_components/steps/component.rbs +0 -82
- data/sig/hakumi_components/steps/item/component.rbs +0 -29
- data/sig/hakumi_components/switch/component.rbs +0 -52
- data/sig/hakumi_components/table/column/component.rbs +0 -57
- data/sig/hakumi_components/table/column_group/component.rbs +0 -20
- data/sig/hakumi_components/table/component.rbs +0 -279
- data/sig/hakumi_components/table/concerns/columns.rbs +0 -95
- data/sig/hakumi_components/table/concerns/editable.rbs +0 -40
- data/sig/hakumi_components/table/concerns/ellipsis.rbs +0 -27
- data/sig/hakumi_components/table/concerns/fixed_columns.rbs +0 -33
- data/sig/hakumi_components/tabs/component.rbs +0 -66
- data/sig/hakumi_components/tabs/item/component.rbs +0 -29
- data/sig/hakumi_components/tag/component.rbs +0 -86
- data/sig/hakumi_components/tag/group/component.rbs +0 -24
- data/sig/hakumi_components/time_picker/component.rbs +0 -72
- data/sig/hakumi_components/timeline/component.rbs +0 -61
- data/sig/hakumi_components/timeline/item/component.rbs +0 -70
- data/sig/hakumi_components/tooltip/component.rbs +0 -73
- data/sig/hakumi_components/tour/component.rbs +0 -84
- data/sig/hakumi_components/transfer/component.rbs +0 -75
- data/sig/hakumi_components/tree/component.rbs +0 -126
- data/sig/hakumi_components/tree_select/component.rbs +0 -122
- data/sig/hakumi_components/typography/base_component.rbs +0 -57
- data/sig/hakumi_components/typography/link/component.rbs +0 -28
- data/sig/hakumi_components/typography/paragraph/component.rbs +0 -13
- data/sig/hakumi_components/typography/text/component.rbs +0 -10
- data/sig/hakumi_components/typography/title/component.rbs +0 -28
- data/sig/hakumi_components/upload/component.rbs +0 -78
- data/sig/hakumi_components.rbs +0 -96
- data/sig/rails/active_model/validations/comparison_validator.rbs +0 -6
- data/sig/rails.rbs +0 -18
- data/sig/view_component/base.rbs +0 -28
|
@@ -1,26 +1,66 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Modal
|
|
5
6
|
module Confirm
|
|
6
7
|
class Component < HakumiComponents::BaseComponent
|
|
8
|
+
extend T::Sig
|
|
9
|
+
|
|
10
|
+
Type = T.type_alias { T.any(Symbol, String) }
|
|
11
|
+
TYPES = T.let(%i[confirm info success error warning].freeze, T::Array[Symbol])
|
|
12
|
+
|
|
13
|
+
sig do
|
|
14
|
+
params(
|
|
15
|
+
params: T.any(ActionController::Parameters, HakumiComponents::Types::HtmlAttributes)
|
|
16
|
+
).returns(HakumiComponents::Types::HtmlAttributes)
|
|
17
|
+
end
|
|
18
|
+
def self.extract_controller_locals(params)
|
|
19
|
+
{
|
|
20
|
+
open: boolean_html_param(html_param(params, :open)),
|
|
21
|
+
title: html_primitive_param(html_param(params, :title)),
|
|
22
|
+
type: symbol_html_param(html_param(params, :type))
|
|
23
|
+
}.compact
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
sig do
|
|
27
|
+
params(
|
|
28
|
+
id: String,
|
|
29
|
+
open: T::Boolean,
|
|
30
|
+
title: HakumiComponents::Types::Renderable,
|
|
31
|
+
type: Type,
|
|
32
|
+
html_options: HakumiComponents::Types::HtmlAttributeValue
|
|
33
|
+
).void
|
|
34
|
+
end
|
|
7
35
|
def initialize(
|
|
8
36
|
id:,
|
|
9
37
|
open: false,
|
|
10
|
-
title:
|
|
38
|
+
title: nil,
|
|
11
39
|
type: :confirm,
|
|
12
|
-
**
|
|
40
|
+
**html_options
|
|
13
41
|
)
|
|
14
|
-
@id = id
|
|
15
|
-
@open = open
|
|
16
|
-
@title = title
|
|
17
|
-
@type = type
|
|
18
|
-
@
|
|
19
|
-
|
|
42
|
+
@id = T.let(id, String)
|
|
43
|
+
@open = T.let(cast_boolean(open) ? true : false, T::Boolean)
|
|
44
|
+
@title = T.let(title, HakumiComponents::Types::Renderable)
|
|
45
|
+
@type = T.let(type.to_sym, Symbol)
|
|
46
|
+
@html_options = T.let(html_options, HakumiComponents::Types::HtmlAttributes)
|
|
47
|
+
|
|
48
|
+
validate_props!
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
sig { returns(HakumiComponents::Types::Renderable) }
|
|
52
|
+
def resolved_title
|
|
53
|
+
@title || t_default(:title, default: "Confirm")
|
|
20
54
|
end
|
|
21
55
|
|
|
22
56
|
private
|
|
23
57
|
|
|
58
|
+
sig { void }
|
|
59
|
+
def validate_props!
|
|
60
|
+
validate_inclusion!(:type, TYPES)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
sig { returns(Symbol) }
|
|
24
64
|
def icon_name
|
|
25
65
|
case @type
|
|
26
66
|
when :info then :info_circle
|
|
@@ -31,6 +71,7 @@ module HakumiComponents
|
|
|
31
71
|
end
|
|
32
72
|
end
|
|
33
73
|
|
|
74
|
+
sig { returns(String) }
|
|
34
75
|
def icon_color
|
|
35
76
|
case @type
|
|
36
77
|
when :info then "#1890ff"
|
|
@@ -1,50 +1,19 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Modal
|
|
5
6
|
module Error
|
|
6
|
-
class Component < HakumiComponents::
|
|
7
|
-
|
|
8
|
-
id:,
|
|
9
|
-
title: "Error",
|
|
10
|
-
message: nil,
|
|
11
|
-
open: false,
|
|
12
|
-
ok_text: "OK",
|
|
13
|
-
**html_attributes
|
|
14
|
-
)
|
|
15
|
-
@id = id
|
|
16
|
-
@title = title
|
|
17
|
-
@message = message
|
|
18
|
-
@open = open
|
|
19
|
-
@ok_text = ok_text
|
|
20
|
-
@html_attributes = html_attributes
|
|
21
|
-
super()
|
|
22
|
-
end
|
|
7
|
+
class Component < HakumiComponents::Modal::StatusComponent
|
|
8
|
+
extend T::Sig
|
|
23
9
|
|
|
24
|
-
|
|
25
|
-
render(HakumiComponents::Modal::Component.new(
|
|
26
|
-
id: @id,
|
|
27
|
-
open: @open,
|
|
28
|
-
closable: false,
|
|
29
|
-
mask_closable: false,
|
|
30
|
-
**@html_attributes
|
|
31
|
-
)) do |modal|
|
|
32
|
-
modal.with_header { @title }
|
|
10
|
+
private
|
|
33
11
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
12
|
+
sig { override.returns(Symbol) }
|
|
13
|
+
def status_type = :error
|
|
37
14
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
render(HakumiComponents::Icon::Component.new(name: :close_circle, theme: :filled, color: "#ff4d4f", size: 22)),
|
|
41
|
-
content_tag(:div, class: "hakumi-modal-confirm-content") do
|
|
42
|
-
content_tag(:p, @message || content)
|
|
43
|
-
end
|
|
44
|
-
])
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
15
|
+
sig { override.returns(T::Boolean) }
|
|
16
|
+
def ok_button_danger? = true
|
|
48
17
|
end
|
|
49
18
|
end
|
|
50
19
|
end
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Modal
|
|
5
6
|
module Info
|
|
6
|
-
class Component < HakumiComponents::
|
|
7
|
-
|
|
8
|
-
id:,
|
|
9
|
-
title: "Info",
|
|
10
|
-
message: nil,
|
|
11
|
-
open: false,
|
|
12
|
-
ok_text: "OK",
|
|
13
|
-
**html_attributes
|
|
14
|
-
)
|
|
15
|
-
@id = id
|
|
16
|
-
@title = title
|
|
17
|
-
@message = message
|
|
18
|
-
@open = open
|
|
19
|
-
@ok_text = ok_text
|
|
20
|
-
@html_attributes = html_attributes
|
|
21
|
-
super()
|
|
22
|
-
end
|
|
7
|
+
class Component < HakumiComponents::Modal::StatusComponent
|
|
8
|
+
extend T::Sig
|
|
23
9
|
|
|
24
|
-
|
|
25
|
-
render(HakumiComponents::Modal::Component.new(
|
|
26
|
-
id: @id,
|
|
27
|
-
open: @open,
|
|
28
|
-
closable: false,
|
|
29
|
-
mask_closable: false,
|
|
30
|
-
**@html_attributes
|
|
31
|
-
)) do |modal|
|
|
32
|
-
modal.with_header { @title }
|
|
10
|
+
private
|
|
33
11
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
content_tag(:div, class: "hakumi-modal-confirm-body-wrapper") do
|
|
39
|
-
safe_join([
|
|
40
|
-
render(HakumiComponents::Icon::Component.new(name: :info_circle, theme: :filled, color: "#1890ff", size: 22)),
|
|
41
|
-
content_tag(:div, class: "hakumi-modal-confirm-content") do
|
|
42
|
-
content_tag(:p, @message || content)
|
|
43
|
-
end
|
|
44
|
-
])
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
12
|
+
sig { override.returns(Symbol) }
|
|
13
|
+
def status_type = :info
|
|
48
14
|
end
|
|
49
15
|
end
|
|
50
16
|
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module HakumiComponents
|
|
5
|
+
module Modal
|
|
6
|
+
class StatusComponent < HakumiComponents::BaseComponent
|
|
7
|
+
extend T::Sig
|
|
8
|
+
|
|
9
|
+
IconConfig = T.type_alias { [ Symbol, String ] }
|
|
10
|
+
ICON_CONFIG = T.let({
|
|
11
|
+
info: [ :info_circle, "#1890ff" ],
|
|
12
|
+
success: [ :check_circle, "#52c41a" ],
|
|
13
|
+
error: [ :close_circle, "#ff4d4f" ],
|
|
14
|
+
warning: [ :warning, "#faad14" ]
|
|
15
|
+
}.freeze, T::Hash[Symbol, IconConfig])
|
|
16
|
+
|
|
17
|
+
sig do
|
|
18
|
+
params(
|
|
19
|
+
id: String,
|
|
20
|
+
title: HakumiComponents::Types::Renderable,
|
|
21
|
+
message: HakumiComponents::Types::Renderable,
|
|
22
|
+
open: T::Boolean,
|
|
23
|
+
ok_text: T.nilable(String),
|
|
24
|
+
cancel_text: T.nilable(String),
|
|
25
|
+
html_options: HakumiComponents::Types::HtmlAttributeValue
|
|
26
|
+
).void
|
|
27
|
+
end
|
|
28
|
+
def initialize(
|
|
29
|
+
id:,
|
|
30
|
+
title: nil,
|
|
31
|
+
message: nil,
|
|
32
|
+
open: false,
|
|
33
|
+
ok_text: nil,
|
|
34
|
+
cancel_text: nil,
|
|
35
|
+
**html_options
|
|
36
|
+
)
|
|
37
|
+
@id = T.let(id, String)
|
|
38
|
+
@title = T.let(title, HakumiComponents::Types::Renderable)
|
|
39
|
+
@message = T.let(message, HakumiComponents::Types::Renderable)
|
|
40
|
+
@open = T.let(cast_boolean(open) ? true : false, T::Boolean)
|
|
41
|
+
@ok_text = ok_text
|
|
42
|
+
@cancel_text = cancel_text
|
|
43
|
+
@html_options = T.let(html_options, HakumiComponents::Types::HtmlAttributes)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sig { returns(ActiveSupport::SafeBuffer) }
|
|
47
|
+
def call
|
|
48
|
+
modal = HakumiComponents::Modal::Component.new(
|
|
49
|
+
id: @id,
|
|
50
|
+
title: resolved_title,
|
|
51
|
+
open: @open,
|
|
52
|
+
closable: false,
|
|
53
|
+
mask_closable: false,
|
|
54
|
+
**@html_options
|
|
55
|
+
)
|
|
56
|
+
modal.with_footer { footer_buttons }
|
|
57
|
+
|
|
58
|
+
render(modal) do
|
|
59
|
+
content_tag(:div, class: "hakumi-modal-confirm-body-wrapper") do
|
|
60
|
+
safe_join([
|
|
61
|
+
icon_element,
|
|
62
|
+
content_element
|
|
63
|
+
])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
sig { returns(Symbol) }
|
|
71
|
+
def status_type
|
|
72
|
+
raise NotImplementedError, "subclasses must define status_type"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
sig { returns(IconConfig) }
|
|
76
|
+
def icon_config
|
|
77
|
+
ICON_CONFIG.fetch(status_type)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
sig { returns(HakumiComponents::Types::Renderable) }
|
|
81
|
+
def resolved_title
|
|
82
|
+
@title || t_default(:title, default: status_type.to_s.capitalize)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
sig { returns(String) }
|
|
86
|
+
def resolved_ok_text
|
|
87
|
+
@ok_text || t_default(:ok, default: default_ok_text)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
sig { returns(String) }
|
|
91
|
+
def resolved_cancel_text
|
|
92
|
+
@cancel_text || t_default(:cancel, default: "Cancel")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
sig { returns(String) }
|
|
96
|
+
def default_ok_text
|
|
97
|
+
"OK"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
sig { returns(T::Boolean) }
|
|
101
|
+
def show_cancel?
|
|
102
|
+
false
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
sig { returns(Symbol) }
|
|
106
|
+
def ok_button_type
|
|
107
|
+
:primary
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
sig { returns(T::Boolean) }
|
|
111
|
+
def ok_button_danger?
|
|
112
|
+
false
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
sig { returns(String) }
|
|
116
|
+
def ok_button_action
|
|
117
|
+
"close"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
sig { returns(ActiveSupport::SafeBuffer) }
|
|
121
|
+
def footer_buttons
|
|
122
|
+
buttons = T.let([], T::Array[ActiveSupport::SafeBuffer])
|
|
123
|
+
if show_cancel?
|
|
124
|
+
buttons << render(HakumiComponents::Button::Component.new(data: { "hakumi-action": "cancel" })) { resolved_cancel_text }
|
|
125
|
+
end
|
|
126
|
+
buttons << render(
|
|
127
|
+
HakumiComponents::Button::Component.new(
|
|
128
|
+
type: ok_button_type,
|
|
129
|
+
danger: ok_button_danger?,
|
|
130
|
+
data: { "hakumi-action": ok_button_action }
|
|
131
|
+
)
|
|
132
|
+
) { resolved_ok_text }
|
|
133
|
+
safe_join(buttons)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
sig { returns(ActiveSupport::SafeBuffer) }
|
|
137
|
+
def icon_element
|
|
138
|
+
name, color = icon_config
|
|
139
|
+
render(HakumiComponents::Icon::Component.new(name: name, theme: :filled, color: color, size: 22))
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
sig { returns(ActiveSupport::SafeBuffer) }
|
|
143
|
+
def content_element
|
|
144
|
+
content_tag(:div, class: "hakumi-modal-confirm-content") do
|
|
145
|
+
content_tag(:p, render_value(@message || content))
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Modal
|
|
5
6
|
module Success
|
|
6
|
-
class Component < HakumiComponents::
|
|
7
|
-
|
|
8
|
-
id:,
|
|
9
|
-
title: "Success",
|
|
10
|
-
message: nil,
|
|
11
|
-
open: false,
|
|
12
|
-
ok_text: "OK",
|
|
13
|
-
**html_attributes
|
|
14
|
-
)
|
|
15
|
-
@id = id
|
|
16
|
-
@title = title
|
|
17
|
-
@message = message
|
|
18
|
-
@open = open
|
|
19
|
-
@ok_text = ok_text
|
|
20
|
-
@html_attributes = html_attributes
|
|
21
|
-
super()
|
|
22
|
-
end
|
|
7
|
+
class Component < HakumiComponents::Modal::StatusComponent
|
|
8
|
+
extend T::Sig
|
|
23
9
|
|
|
24
|
-
|
|
25
|
-
render(HakumiComponents::Modal::Component.new(
|
|
26
|
-
id: @id,
|
|
27
|
-
open: @open,
|
|
28
|
-
closable: false,
|
|
29
|
-
mask_closable: false,
|
|
30
|
-
**@html_attributes
|
|
31
|
-
)) do |modal|
|
|
32
|
-
modal.with_header { @title }
|
|
10
|
+
private
|
|
33
11
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
content_tag(:div, class: "hakumi-modal-confirm-body-wrapper") do
|
|
39
|
-
safe_join([
|
|
40
|
-
render(HakumiComponents::Icon::Component.new(name: :check_circle, theme: :filled, color: "#52c41a", size: 22)),
|
|
41
|
-
content_tag(:div, class: "hakumi-modal-confirm-content") do
|
|
42
|
-
content_tag(:p, @message || content)
|
|
43
|
-
end
|
|
44
|
-
])
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
12
|
+
sig { override.returns(Symbol) }
|
|
13
|
+
def status_type = :success
|
|
48
14
|
end
|
|
49
15
|
end
|
|
50
16
|
end
|
|
@@ -1,55 +1,25 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Modal
|
|
5
6
|
module Warning
|
|
6
|
-
class Component < HakumiComponents::
|
|
7
|
-
|
|
8
|
-
id:,
|
|
9
|
-
title: "Warning",
|
|
10
|
-
message: nil,
|
|
11
|
-
open: false,
|
|
12
|
-
ok_text: "Proceed",
|
|
13
|
-
cancel_text: "Cancel",
|
|
14
|
-
**html_attributes
|
|
15
|
-
)
|
|
16
|
-
@id = id
|
|
17
|
-
@title = title
|
|
18
|
-
@message = message
|
|
19
|
-
@open = open
|
|
20
|
-
@ok_text = ok_text
|
|
21
|
-
@cancel_text = cancel_text
|
|
22
|
-
@html_attributes = html_attributes
|
|
23
|
-
super()
|
|
24
|
-
end
|
|
7
|
+
class Component < HakumiComponents::Modal::StatusComponent
|
|
8
|
+
extend T::Sig
|
|
25
9
|
|
|
26
|
-
|
|
27
|
-
render(HakumiComponents::Modal::Component.new(
|
|
28
|
-
id: @id,
|
|
29
|
-
open: @open,
|
|
30
|
-
closable: false,
|
|
31
|
-
mask_closable: false,
|
|
32
|
-
**@html_attributes
|
|
33
|
-
)) do |modal|
|
|
34
|
-
modal.with_header { @title }
|
|
10
|
+
private
|
|
35
11
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
render(HakumiComponents::Button::Component.new(data: { "hakumi-action": "cancel" })) { @cancel_text },
|
|
39
|
-
render(HakumiComponents::Button::Component.new(type: :primary, data: { "hakumi-action": "confirm" })) { @ok_text }
|
|
40
|
-
])
|
|
41
|
-
end
|
|
12
|
+
sig { override.returns(Symbol) }
|
|
13
|
+
def status_type = :warning
|
|
42
14
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
end
|
|
15
|
+
sig { override.returns(String) }
|
|
16
|
+
def default_ok_text = "Proceed"
|
|
17
|
+
|
|
18
|
+
sig { override.returns(T::Boolean) }
|
|
19
|
+
def show_cancel? = true
|
|
20
|
+
|
|
21
|
+
sig { override.returns(String) }
|
|
22
|
+
def ok_button_action = "confirm"
|
|
53
23
|
end
|
|
54
24
|
end
|
|
55
25
|
end
|
|
@@ -1,32 +1,61 @@
|
|
|
1
|
+
# typed: strict
|
|
1
2
|
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module HakumiComponents
|
|
4
5
|
module Notification
|
|
5
6
|
class Component < HakumiComponents::BaseComponent
|
|
6
|
-
|
|
7
|
-
PLACEMENTS = %w[top topLeft topRight bottom bottomLeft bottomRight].freeze
|
|
7
|
+
extend T::Sig
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Type = T.type_alias { T.any(Symbol, String) }
|
|
10
|
+
Placement = T.type_alias { T.any(Symbol, String) }
|
|
11
|
+
TYPES = T.let(%i[success info warning error].freeze, T::Array[Symbol])
|
|
12
|
+
PLACEMENTS = T.let(%i[top topLeft topRight bottom bottomLeft bottomRight].freeze, T::Array[Symbol])
|
|
13
|
+
|
|
14
|
+
sig do
|
|
15
|
+
params(
|
|
16
|
+
params: T.any(ActionController::Parameters, HakumiComponents::Types::HtmlAttributes)
|
|
17
|
+
).returns(HakumiComponents::Types::HtmlAttributes)
|
|
18
|
+
end
|
|
10
19
|
def self.extract_controller_locals(params)
|
|
11
20
|
{
|
|
12
|
-
title: params
|
|
13
|
-
description: params
|
|
14
|
-
type: params
|
|
15
|
-
duration: params
|
|
16
|
-
key: params
|
|
17
|
-
placement: params
|
|
18
|
-
icon: params
|
|
19
|
-
close_icon: params
|
|
20
|
-
btn: params
|
|
21
|
-
max_count: params
|
|
22
|
-
top: params
|
|
23
|
-
bottom: params
|
|
24
|
-
pause_on_hover:
|
|
25
|
-
show_progress:
|
|
26
|
-
stack_threshold: params
|
|
21
|
+
title: html_primitive_param(html_param(params, :title)) || html_primitive_param(html_param(params, :message)),
|
|
22
|
+
description: html_primitive_param(html_param(params, :description)),
|
|
23
|
+
type: symbol_html_param(html_param(params, :type)),
|
|
24
|
+
duration: float_html_param(html_param(params, :duration)),
|
|
25
|
+
key: html_primitive_param(html_param(params, :key)),
|
|
26
|
+
placement: symbol_html_param(html_param(params, :placement)),
|
|
27
|
+
icon: html_primitive_param(html_param(params, :icon)),
|
|
28
|
+
close_icon: html_primitive_param(html_param(params, :close_icon)),
|
|
29
|
+
btn: html_primitive_param(html_param(params, :btn)),
|
|
30
|
+
max_count: integer_html_param(html_param(params, :max_count)),
|
|
31
|
+
top: integer_html_param(html_param(params, :top)),
|
|
32
|
+
bottom: integer_html_param(html_param(params, :bottom)),
|
|
33
|
+
pause_on_hover: boolean_html_param(html_param(params, :pause_on_hover)),
|
|
34
|
+
show_progress: boolean_html_param(html_param(params, :show_progress)),
|
|
35
|
+
stack_threshold: integer_html_param(html_param(params, :stack_threshold))
|
|
27
36
|
}
|
|
28
37
|
end
|
|
29
38
|
|
|
39
|
+
sig do
|
|
40
|
+
params(
|
|
41
|
+
title: HakumiComponents::Types::HtmlPrimitive,
|
|
42
|
+
description: HakumiComponents::Types::HtmlPrimitive,
|
|
43
|
+
type: T.nilable(Type),
|
|
44
|
+
duration: T.nilable(Float),
|
|
45
|
+
key: HakumiComponents::Types::HtmlPrimitive,
|
|
46
|
+
placement: T.nilable(Placement),
|
|
47
|
+
icon: HakumiComponents::Types::HtmlPrimitive,
|
|
48
|
+
close_icon: HakumiComponents::Types::HtmlPrimitive,
|
|
49
|
+
btn: HakumiComponents::Types::HtmlPrimitive,
|
|
50
|
+
max_count: T.nilable(Integer),
|
|
51
|
+
top: T.nilable(Integer),
|
|
52
|
+
bottom: T.nilable(Integer),
|
|
53
|
+
pause_on_hover: T.nilable(T::Boolean),
|
|
54
|
+
show_progress: T.nilable(T::Boolean),
|
|
55
|
+
stack_threshold: T.nilable(Integer),
|
|
56
|
+
html_options: HakumiComponents::Types::HtmlAttributeValue
|
|
57
|
+
).void
|
|
58
|
+
end
|
|
30
59
|
def initialize(
|
|
31
60
|
title: nil,
|
|
32
61
|
description: nil,
|
|
@@ -45,40 +74,42 @@ module HakumiComponents
|
|
|
45
74
|
stack_threshold: nil,
|
|
46
75
|
**html_options
|
|
47
76
|
)
|
|
48
|
-
@title = title
|
|
49
|
-
@description = description
|
|
50
|
-
@type = type
|
|
51
|
-
@duration = duration
|
|
52
|
-
@key = key
|
|
53
|
-
@placement = placement
|
|
54
|
-
@icon = icon
|
|
55
|
-
@close_icon = close_icon
|
|
56
|
-
@btn = btn
|
|
57
|
-
@max_count = max_count
|
|
58
|
-
@top = top
|
|
59
|
-
@bottom = bottom
|
|
60
|
-
@pause_on_hover = pause_on_hover
|
|
61
|
-
@show_progress = show_progress
|
|
62
|
-
@stack_threshold = stack_threshold
|
|
63
|
-
@html_options = html_options
|
|
77
|
+
@title = T.let(title, HakumiComponents::Types::HtmlPrimitive)
|
|
78
|
+
@description = T.let(description, HakumiComponents::Types::HtmlPrimitive)
|
|
79
|
+
@type = T.let(type&.to_sym, T.nilable(Symbol))
|
|
80
|
+
@duration = T.let(duration, T.nilable(Float))
|
|
81
|
+
@key = T.let(key, HakumiComponents::Types::HtmlPrimitive)
|
|
82
|
+
@placement = T.let(placement&.to_sym, T.nilable(Symbol))
|
|
83
|
+
@icon = T.let(icon, HakumiComponents::Types::HtmlPrimitive)
|
|
84
|
+
@close_icon = T.let(close_icon, HakumiComponents::Types::HtmlPrimitive)
|
|
85
|
+
@btn = T.let(btn, HakumiComponents::Types::HtmlPrimitive)
|
|
86
|
+
@max_count = T.let(max_count, T.nilable(Integer))
|
|
87
|
+
@top = T.let(top, T.nilable(Integer))
|
|
88
|
+
@bottom = T.let(bottom, T.nilable(Integer))
|
|
89
|
+
@pause_on_hover = T.let(pause_on_hover, T.nilable(T::Boolean))
|
|
90
|
+
@show_progress = T.let(show_progress, T.nilable(T::Boolean))
|
|
91
|
+
@stack_threshold = T.let(stack_threshold, T.nilable(Integer))
|
|
92
|
+
@html_options = T.let(html_options, HakumiComponents::Types::HtmlAttributes)
|
|
64
93
|
|
|
65
94
|
validate_props!
|
|
66
95
|
end
|
|
67
96
|
|
|
97
|
+
sig { returns(HakumiComponents::Types::HtmlAttributes) }
|
|
68
98
|
def root_attributes
|
|
69
99
|
base_attrs = {
|
|
70
100
|
id: "notification",
|
|
71
|
-
class:
|
|
101
|
+
class: component_classes("notification", {}, @html_options),
|
|
72
102
|
data: data_attributes
|
|
73
103
|
}
|
|
74
104
|
|
|
75
105
|
merge_attributes(base_attrs, @html_options)
|
|
76
106
|
end
|
|
77
107
|
|
|
108
|
+
sig { returns(HakumiComponents::Types::DataAttributes) }
|
|
78
109
|
def data_attributes
|
|
79
|
-
attrs = {
|
|
110
|
+
attrs = T.let({
|
|
80
111
|
controller: "hakumi--notification"
|
|
81
|
-
}
|
|
112
|
+
}, HakumiComponents::Types::DataAttributes)
|
|
82
113
|
|
|
83
114
|
attrs[:hakumi__notification_duration_value] = @duration unless @duration.nil?
|
|
84
115
|
attrs[:hakumi__notification_max_count_value] = @max_count unless @max_count.nil?
|
|
@@ -95,12 +126,14 @@ module HakumiComponents
|
|
|
95
126
|
attrs
|
|
96
127
|
end
|
|
97
128
|
|
|
129
|
+
sig { returns(ActiveSupport::SafeBuffer) }
|
|
98
130
|
def call
|
|
99
|
-
|
|
131
|
+
content_tag(:div, nil, root_attributes)
|
|
100
132
|
end
|
|
101
133
|
|
|
102
134
|
private
|
|
103
135
|
|
|
136
|
+
sig { returns(HakumiComponents::Types::StimulusValues) }
|
|
104
137
|
def initial_payload
|
|
105
138
|
{
|
|
106
139
|
title: @title,
|
|
@@ -117,6 +150,7 @@ module HakumiComponents
|
|
|
117
150
|
}.compact
|
|
118
151
|
end
|
|
119
152
|
|
|
153
|
+
sig { void }
|
|
120
154
|
def validate_props!
|
|
121
155
|
validate_inclusion!(:type, TYPES)
|
|
122
156
|
validate_inclusion!(:placement, PLACEMENTS)
|