Class: Ruflet::UI::Controls::RufletComponents::DataTableControl

Inherits:
Control
  • Object
show all
Defined in:
lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb

Constant Summary collapse

TYPE =
"datatable".freeze
WIRE =
"DataTable".freeze

Constants inherited from Control

Control::HOST_EXPANDED_TYPES

Instance Attribute Summary

Attributes inherited from Control

#children, #id, #props, #runtime_page, #type, #wire_id

Instance Method Summary collapse

Methods inherited from Control

#emit, generate_id, #has_handler?, #on, #to_patch

Constructor Details

#initialize(id: nil, align: nil, animate_align: nil, animate_margin: nil, animate_offset: nil, animate_opacity: nil, animate_position: nil, animate_rotation: nil, animate_scale: nil, animate_size: nil, aspect_ratio: nil, badge: nil, bgcolor: nil, border: nil, border_radius: nil, bottom: nil, checkbox_horizontal_margin: nil, clip_behavior: nil, col: nil, column_spacing: nil, columns: nil, data: nil, data_row_color: nil, data_row_max_height: nil, data_row_min_height: nil, data_text_style: nil, disabled: nil, divider_thickness: nil, expand: nil, expand_loose: nil, gradient: nil, heading_row_color: nil, heading_row_height: nil, heading_text_style: nil, height: nil, horizontal_lines: nil, horizontal_margin: nil, key: nil, left: nil, margin: nil, offset: nil, opacity: nil, right: nil, rotate: nil, rows: nil, rtl: nil, scale: nil, show_bottom_border: nil, show_checkbox_column: nil, size_change_interval: nil, sort_ascending: nil, sort_column_index: nil, tooltip: nil, top: nil, vertical_lines: nil, visible: nil, width: nil, on_animation_end: nil, on_select_all: nil, on_size_change: nil) ⇒ DataTableControl

Returns a new instance of DataTableControl.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb', line 11

def initialize(id: nil, align: nil, animate_align: nil, animate_margin: nil, animate_offset: nil, animate_opacity: nil, animate_position: nil, animate_rotation: nil, animate_scale: nil, animate_size: nil, aspect_ratio: nil, badge: nil, bgcolor: nil, border: nil, border_radius: nil, bottom: nil, checkbox_horizontal_margin: nil, clip_behavior: nil, col: nil, column_spacing: nil, columns: nil, data: nil, data_row_color: nil, data_row_max_height: nil, data_row_min_height: nil, data_text_style: nil, disabled: nil, divider_thickness: nil, expand: nil, expand_loose: nil, gradient: nil, heading_row_color: nil, heading_row_height: nil, heading_text_style: nil, height: nil, horizontal_lines: nil, horizontal_margin: nil, key: nil, left: nil, margin: nil, offset: nil, opacity: nil, right: nil, rotate: nil, rows: nil, rtl: nil, scale: nil, show_bottom_border: nil, show_checkbox_column: nil, size_change_interval: nil, sort_ascending: nil, sort_column_index: nil, tooltip: nil, top: nil, vertical_lines: nil, visible: nil, width: nil, on_animation_end: nil, on_select_all: nil, on_size_change: nil)
  visible_columns = visible_controls(columns)
  raise ArgumentError, "data_table requires at least one visible columns control" if visible_columns.empty?

  visible_rows = visible_controls(rows)
  visible_rows.each do |row|
    next unless row.respond_to?(:props)

    unless visible_controls(row.props["cells"]).length == visible_columns.length
      raise ArgumentError, "data_table row cells must match visible columns"
    end
  end

  {
    checkbox_horizontal_margin: checkbox_horizontal_margin,
    column_spacing: column_spacing,
    data_row_max_height: data_row_max_height,
    data_row_min_height: data_row_min_height,
    divider_thickness: divider_thickness,
    heading_row_height: heading_row_height,
    horizontal_margin: horizontal_margin
  }.each do |name, value|
    raise ArgumentError, "data_table #{name} must be greater than or equal to 0" unless value.nil? || value >= 0
  end

  unless data_row_min_height.nil? || data_row_max_height.nil? || data_row_min_height <= data_row_max_height
    raise ArgumentError, "data_table data_row_min_height must be less than or equal to data_row_max_height"
  end

  props = {}
  props[:align] = align unless align.nil?
  props[:animate_align] = animate_align unless animate_align.nil?
  props[:animate_margin] = animate_margin unless animate_margin.nil?
  props[:animate_offset] = animate_offset unless animate_offset.nil?
  props[:animate_opacity] = animate_opacity unless animate_opacity.nil?
  props[:animate_position] = animate_position unless animate_position.nil?
  props[:animate_rotation] = animate_rotation unless animate_rotation.nil?
  props[:animate_scale] = animate_scale unless animate_scale.nil?
  props[:animate_size] = animate_size unless animate_size.nil?
  props[:aspect_ratio] = aspect_ratio unless aspect_ratio.nil?
  props[:badge] = badge unless badge.nil?
  props[:bgcolor] = bgcolor unless bgcolor.nil?
  props[:border] = border unless border.nil?
  props[:border_radius] = border_radius unless border_radius.nil?
  props[:bottom] = bottom unless bottom.nil?
  props[:checkbox_horizontal_margin] = checkbox_horizontal_margin unless checkbox_horizontal_margin.nil?
  props[:clip_behavior] = clip_behavior unless clip_behavior.nil?
  props[:col] = col unless col.nil?
  props[:column_spacing] = column_spacing unless column_spacing.nil?
  props[:columns] = columns unless columns.nil?
  props[:data] = data unless data.nil?
  props[:data_row_color] = data_row_color unless data_row_color.nil?
  props[:data_row_max_height] = data_row_max_height unless data_row_max_height.nil?
  props[:data_row_min_height] = data_row_min_height unless data_row_min_height.nil?
  props[:data_text_style] = data_text_style unless data_text_style.nil?
  props[:disabled] = disabled unless disabled.nil?
  props[:divider_thickness] = divider_thickness unless divider_thickness.nil?
  props[:expand] = expand unless expand.nil?
  props[:expand_loose] = expand_loose unless expand_loose.nil?
  props[:gradient] = gradient unless gradient.nil?
  props[:heading_row_color] = heading_row_color unless heading_row_color.nil?
  props[:heading_row_height] = heading_row_height unless heading_row_height.nil?
  props[:heading_text_style] = heading_text_style unless heading_text_style.nil?
  props[:height] = height unless height.nil?
  props[:horizontal_lines] = horizontal_lines unless horizontal_lines.nil?
  props[:horizontal_margin] = horizontal_margin unless horizontal_margin.nil?
  props[:key] = key unless key.nil?
  props[:left] = left unless left.nil?
  props[:margin] = margin unless margin.nil?
  props[:offset] = offset unless offset.nil?
  props[:opacity] = opacity unless opacity.nil?
  props[:right] = right unless right.nil?
  props[:rotate] = rotate unless rotate.nil?
  props[:rows] = rows unless rows.nil?
  props[:rtl] = rtl unless rtl.nil?
  props[:scale] = scale unless scale.nil?
  props[:show_bottom_border] = show_bottom_border unless show_bottom_border.nil?
  props[:show_checkbox_column] = show_checkbox_column unless show_checkbox_column.nil?
  props[:size_change_interval] = size_change_interval unless size_change_interval.nil?
  props[:sort_ascending] = sort_ascending unless sort_ascending.nil?
  props[:sort_column_index] = sort_column_index unless sort_column_index.nil?
  props[:tooltip] = tooltip unless tooltip.nil?
  props[:top] = top unless top.nil?
  props[:vertical_lines] = vertical_lines unless vertical_lines.nil?
  props[:visible] = visible unless visible.nil?
  props[:width] = width unless width.nil?
  props[:on_animation_end] = on_animation_end unless on_animation_end.nil?
  props[:on_select_all] = on_select_all unless on_select_all.nil?
  props[:on_size_change] = on_size_change unless on_size_change.nil?
  super(type: TYPE, id: id, **props)
end