# frozen_string_literal: truerequire"playbook/classnames"require"playbook/spacing"require"playbook/z_index"require"playbook/number_spacing"require"playbook/shadow"require"playbook/line_height"require"playbook/display"require"playbook/cursor"require"playbook/flex_direction"require"playbook/flex_wrap"require"playbook/justify_content"require"playbook/justify_self"require"playbook/align_items"require"playbook/align_content"require"playbook/align_self"require"playbook/flex"require"playbook/flex_grow"require"playbook/flex_shrink"require"playbook/order"require"playbook/position"require"playbook/hover"require"playbook/border_radius"require"playbook/text_align"require"playbook/overflow"require"playbook/truncate"require"playbook/left"require"playbook/top"require"playbook/right"require"playbook/bottom"require"playbook/vertical_align"require"playbook/height"require"playbook/min_height"require"playbook/max_height"modulePlaybookincludeActionView::HelpersclassKitBase<ViewComponent::BaseincludePlaybook::PbKitHelperincludePlaybook::PropsincludePlaybook::ClassnamesincludePlaybook::SpacingincludePlaybook::ZIndexincludePlaybook::NumberSpacingincludePlaybook::ShadowincludePlaybook::LineHeightincludePlaybook::DisplayincludePlaybook::CursorincludePlaybook::FlexDirectionincludePlaybook::FlexWrapincludePlaybook::JustifyContentincludePlaybook::JustifySelfincludePlaybook::AlignItemsincludePlaybook::AlignContentincludePlaybook::AlignSelfincludePlaybook::FlexincludePlaybook::FlexGrowincludePlaybook::FlexShrinkincludePlaybook::OrderincludePlaybook::PositionincludePlaybook::HoverincludePlaybook::BorderRadiusincludePlaybook::TextAlignincludePlaybook::OverflowincludePlaybook::TruncateincludePlaybook::LeftincludePlaybook::TopincludePlaybook::RightincludePlaybook::BottomincludePlaybook::VerticalAlignincludePlaybook::HeightincludePlaybook::MinHeightincludePlaybook::MaxHeightprop:idprop:data,type: Playbook::Props::HashProp,default: {}prop:aria,type: Playbook::Props::HashProp,default: {}prop:html_options,type: Playbook::Props::HashProp,default: {}prop:children,type: Playbook::Props::Procprop:style,type: Playbook::Props::HashProp,default: {}prop:heightprop:min_heightprop:max_heightdefobjectselfend# rubocop:disable Layout/CommentIndentation# pb_content_tag information (potentially to be abstracted into its own dev doc in the future)# The pb_content_tag generates HTML content tags for rails kits with flexible options.# Modify a generated kit.html.erb file accordingly (the default_options listed below no longer need to be explictly outlined in that file, only modifications).# name - the first argument is for HTML tag. The default is :div.# content_or_options_with_block - additional content or options for the tag (i.e., the customizations a dev adds to kit.html.erb).# options - Within combined_options, the empty options hash allows for customizations to# merge with the default_options and combined_html_options.# escape - set to true, this allows for HTML-escape.# block - an optional block for content inside the tag.# The return is a HTML tag that includes any provided customizations. If nothing is specified in kit.html.erb, the default shape is:# :div,# aria: object.aria,# class: object.classname,# data: object.data,# id: object.id,# **combined_html_options# rubocop:enable Layout/CommentIndentation# rubocop:disable Style/OptionalBooleanParameterdefpb_content_tag(name=:div,content_or_options_with_block={},options={},escape=true,&block)combined_options=options.merge(combined_html_options).merge(default_options.merge(content_or_options_with_block))content_tag(name,combined_options,options,escape,&block)end# rubocop:enable Style/OptionalBooleanParameterdefcombined_html_optionsmerged=default_html_options.duphtml_options.eachdo|key,value|ifkey==:style&&value.is_a?(Hash)# Convert style hash to CSS stringmerged[:style]=value.map{|k,v|"#{k.to_s.gsub('_','-')}: #{v}"}.join("; ")elsemerged[key]=valueendendinline_styles=dynamic_inline_propsmerged[:style]=ifinline_styles.present?merged[:style].present??"#{merged[:style]}; #{inline_styles}":inline_stylesendmerged.deep_merge(data_attributes)enddefglobal_inline_props{height: height,min_height: min_height,max_height: max_height,}.compactendprivatedefdefault_optionsoptions={id: id,data: data,class: classname,aria: aria,}inline_styles=dynamic_inline_propsoptions[:style]=inline_stylesifinline_styles.present?&&!html_options.key?(:style)optionsenddefdefault_html_options{}enddefdata_attributes{data: data,aria: aria,}.transform_keys{|key|key.to_s.tr("_","-").to_sym}enddefdynamic_inline_propsstyles=global_inline_props.map{|key,value|"#{key.to_s.gsub('_','-')}: #{value}"ifinline_validator(key,value)}.compactstyles.join("; ").presenceenddefinline_validator(key,value)returnfalseifvalue.nil?returnfalseifheight_values.include?(value)&&key==:heightreturnfalseifmin_height_values.include?(value)&&key==:min_heightreturnfalseifmax_height_values.include?(value)&&key==:max_heighttrueendendend