Changelog
View SourceUnreleased
[0.25.3] - 2025-07-31
Changed
- Require
phoenix_live_view~> 1.0.6 or ~> 1.1.0.
[0.25.2] - 2025-06-25
Fixed
- Allow overriding
maxlengthattribute in filter value field.
[0.25.1] - 2025-05-05
Fixed
- Function clause error when no pagination parameters are passed and no
default_pagination_typeis set.
[0.25.0] - 2025-05-04
Added
- Add guide about load-more buttons and infinite scroll.
- Add guide about CSS styles.
- Add guide about page size controls.
Changed
- Remove
optsattribute fromFlop.Phoenix.pagination/1and remove configuration of the pagination component via application environment. - Remove all default classes from pagination component.
- Remove
wrapper_attrsfrom pagination component in favor of global attributes. - Set page link aria label function with
page_link_aria_label_funattribute onFlop.Phoenix.pagination/1component instead of usingpagination_link_aria_labeloption. - Set previous and next link attributes and content with slots instead of options.
- Set ellipsis content with slot instead of option.
- Set pagination list attributes with
page_list_attrsattribute instead ofpagination_list_attrsoption. - Set pagination list item attributes with
page_list_item_attrsattribute instead ofpagination_list_item_attrsoption. - Set pagination link attributes with
page_link_attrsattribute instead ofpagination_link_attrsoption. - Set current pagination link attributes with
current_page_link_attrsattribute instead ofcurrent_link_attrsoption. - Set disabled link attributes with
disabled_link_attrsattribute instead ofdisabled_attrsoption. - Remove default classes for pagination root element, pagination list and pagination links.
- Use
<button>elements for pagination if nopathis set. - Remove
roleattribute from the pagination component. The<nav>element already has the implicit ARIA rolenavigation. - Add
relattribute to previous/next links. - Mark up disabled previous/next links of the pagination component as
<a role="link" aria-disabled="true">instead of<span>. - Update documentation for
hidden_inputs_for_filter/1to usePhoenix.Component.inputs_for/1with theskip_persistent_idoption. - Require Phoenix >= 1.6.0 and < 1.9.0.
How to upgrade
The configuration via pagination_opts is deprecated. Instead of referencing a
function that returns the pagination opts, it is recommended to define a
component that wraps the Flop.Phoenix.pagination/1 component and sets the
necessary attributes.
Follow the upgrade guide of version 0.24.0 to update the pagination component configuration, including the removal of the application configuration, if you haven't done so already.
Remove the wrapper_attrs from your pagination options and pass them directly
as attributes instead.
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- wrapper_attrs: [
- class: "pagination",
- aria: [label: "Quppernerit"]
- ]
]}
+ class="pagination"
+ aria-label="Quppernerit"
/>Replace the :previous_link_attrs, :previous_link_content, next_link_attrs,
and next_link_content attributes with the previous and next slots.
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- previous_link_attrs: [class: "previous"],
- previous_link_content: Phoenix.HTML.raw(~s(<i class="fas fa-chevron-left" />)),
- next_link_attrs: [class: "next"],
- next_link_content: Phoenix.HTML.raw(~s(<i class="fas fa-chevron-right" />))
]}
- />
+ >
+ <:previous attrs={[class: "previous"]}>
+ <i class="fas fa-chevron-left" />
+ </:previous>
+ <:next attrs={[class: "next"]}>
+ <i class="fas fa-chevron-right" />
+ </:next>
+ </Flop.Phoenix.pagination>Replace the :ellipsis_attrs and :ellipsis_content attributes with the
ellipsis slot.
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- ellipsis_attrs: [class: "ellipsis", aria-hidden: "true"],
- ellipsis_content: "‥"
]}
- />
+ >
+ <:ellipsis>
+ <span class="ellipsis" aria-hidden="true">‥</span>
+ </:ellipsis>
+ </Flop.Phoenix.pagination>Remove the :disabled_attrs option. Note that the disabled and
aria-disabled attributes are set automatically and do not need to be passed
here.
To style disabled links/buttons without a CSS class, use the CSS selector
[disabled], [aria-disabled="true"].
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- disabled_attrs: [class: "is-disabled"]
]}
+ disabled_link_attrs={[class: "is-disabled"]}
>Remove the :pagination_link_aria_label option and set the
page_link_aria_label_fun attribute instead.
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- pagination_link_aria_label: &"#{&1}ページ目へ"
]}
+ page_link_aria_label_fun={&"#{&1}ページ目へ"}
>Remove the :pagination_list_attrs, :pagination_list_item_attrs,
:pagination_link_attrs, and :current_link_attrs options and set the
page_list_attrs, page_list_item_attrs, page_link_attrs, and
current_page_link_attrs attributes instead. If you relied on the default page
list class and page link classes, set them explicitly. Note that the
aria-current attribute is set automatically and does not need to be set here.
To style the current page link without a CSS class, use the CSS selector
[aria-current="page"].
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
opts={[
- pagination_list_attrs: [class: "pagination-list"]
- pagination_list_item_attrs: [class: "pagination-list-item"]
- pagination_link_attrs: [class: "pagination-link"]
- current_link_attrs: [
- class: "pagination-link is-current",
- aria: [current: "page"]
- ]
]}
+ page_list_attrs={[class: "pagination-list"]}
+ page_list_item_attrs={[class: "pagination-list-item"]}
+ page_link_attrs={[class: "pagination-link"]}
+ current_page_link_attrs={[class: "pagination-link is-current"]}
>Ensure that your CSS styles work with both <a> elements (used when a path is
set) and <button> elements (used when no path is set). Check the appearance
of the pagination component carefully.
[0.24.0] - 2025-02-01
Added
- Add
Flop.Phoenix.Paginationstruct to hold information needed to render a pagination component. - Add
Flop.Phoenix.Pagination.new/2to build aPaginationstruct from aFlop.Metastruct. - Add
Flop.Phoenix.pagination_for/1for building custom pagination components. Update the existingFlop.Phoenix.pagination/1component to use it. - Add
Flop.Phoenix.page_link_range/3for determining which page links to render in a pagination component.
Changed
- Support cursor pagination in
Flop.Phoenix.pagination/1. - Remove the
page_linksoption from thepagination_opts. Set this option with the newpage_linksattribute instead. - Change the values of the
page_linksoption from:all | :hide | {:ellipsis, pos_integer}to:all | :none | pos_integer. - Change default value for
page_linksoption of theFlop.Phoenix.pagination/1component from:allto5. - Deprecate configuring the
paginationandtablecomponents via the application environment. Define wrapper components that pass theoptsattribute to the Flop.Phoenix components instead. - Remove dependency on PhoenixHTMLHelpers.
- Require Phoenix LiveView ~> 1.0.0.
- Require Elixir ~> 1.14.
Removed
- Remove
Flop.Phoenix.cursor_pagination/1. UseFlop.Phoenix.pagination/1instead. - Remove
t:Flop.Phoenix.cursor_pagination_option/0. - Remove
Flop.Phoenix.IncorrectPaginationTypeError. - Remove
input_type/3from thePhoenix.HTML.FormDataprotocol implementation forFlop.Meta. The function had been removed from the protocol in Phoenix.HTML 4.0. - Remove the previously deprecated
eventattribute from theFlop.Phoenix.pagination/1andFlop.Phoenix.table/1components. Use:on_paginateand:on_sortinstead. - Remove the previously deprecated
hideandshowattributes from the:coland:actionslots of theFlop.Phoenix.table/1component. Use the:ifattribute instead.
Fixed
- Fix a warning about ranges in Elixir 1.18.
How to upgrade
Replace Flop.Phoenix.cursor_pagination/1 with Flop.Phoenix.pagination/1.
- <Flop.Phoenix.cursor_pagination meta={@meta} path={~p"/pets"} />
+ <Flop.Phoenix.pagination meta={@meta} path={~p"/pets"} />Update the format of the page_links option for the pagination component.
- page_links: {:ellipsis, 7},
+ page_links: 7,
- page_links: :hide,
+ page_links: :none,Remove page_links from your pagination_opts function and add it as an
attribute instead.
def pagination_opts do
[
ellipsis_attrs: [class: "ellipsis"],
ellipsis_content: "‥",
next_link_attrs: [class: "next"],
next_link_content: next_icon(),
- page_links: 7,
pagination_link_aria_label: &"#{&1}ページ目へ",
previous_link_attrs: [class: "prev"],
previous_link_content: previous_icon()
]
end
<Flop.Phoenix.pagination
meta={@meta}
path={~p"/pets"}
+ page_links={7}
/>Replace the :show and :hide attribute in the :col slot of the table
component with :if.
<:col
:let={pet}
- show={@admin?}
+ :if={@admin?}
label="Name"
field={:name}
>
<%= pet.name %>
</:col>
<:col
:let={pet}
- hide={!@admin?}
+ :if={@admin?}
label="Name"
field={:name}
>
<%= pet.name %>
</:col>Replace the event attribute of the pagination table components with
on_paginate and on_sort.
<Flop.Phoenix.pagination
meta={@meta}
- event="paginate"
+ on_paginate={JS.push("paginate")}
/>
<Flop.Phoenix.table
items={@pets}
meta={@meta}
- event="sort"
+ on_sort={JS.push("sort")}
>Remove the configuration for the pagination component from config/config.exs
and define a wrapper component in your CoreComponents module instead. This
is optional, but will make future version updates easier.
For the pagination component:
# config/config.exs
config :flop_phoenix,
- pagination: [opts: {MyAppWeb.CoreComponents, :pagination_opts}],
table: [opts: {MyAppWeb.CoreComponents, :table_opts}]
# MyAppWeb.CoreComponents
- def pagination_opts do
- [
- # ...
- ]
- end
+ attr :meta, Flop.Meta, required: true
+ attr :path, :any, default: nil
+ attr :on_paginate, JS, default: nil
+ attr :target, :string, default: nil
+
+ def pagination(assigns) do
+ ~H\"""
+ <Flop.Phoenix.pagination
+ meta={@meta}
+ path={@path}
+ on_paginate={@on_paginate}
+ target={@target}
+ opts={[
+ # ...
+ ]}
+ />
+ \"""
+ end[0.23.1] - 2024-10-17
Changed
- Raise an error if a meta struct with the wrong pagination type is passed to
the
paginationorcursor_paginationcomponent.
Fixed
- Fix compilation error in Phoenix LiveView 1.0.0-rc.7.
- Fix type of
row_clickattribute.
[0.23.0] - 2024-08-18
Changed
- Support and require
live_view ~> 1.0.0-rc.0. - Allow to pass options directly in config file instead of referencing function.
Fixed
- Fixed a deprecation warning in Elixir 1.17.
[0.22.10] - 2024-08-18
Changed
- Loosen version requirement for
flopto support 0.26.
[0.22.9] - 2024-05-04
Added
- Added
:pagination_list_item_attrsoption toFlop.Phoenix.pagination/1.
[0.22.8] - 2024-03-23
Added
- Support
:col_classattr on:coland:actionslots in addition to:col_style.
Changed
- Don't render empty
styleattributes oncolelements incolgroup.
Fixed
- The page range calculation in the
Flop.Phoenix.pagination/1was incorrect towards the last pages.
[0.22.7] - 2024-03-02
Changed
- Loosen version requirement for
phoenix_html.
Fixed
- Warning when wrapping table component and passing on
:colslot as attribute.
[0.22.6] - 2024-01-14
Changed
- Support Flop 0.25.0.
- Update documentation examples for filter forms.
[0.22.5] - 2023-12-24
Changed
- Requires
phoenix_html ~> 4.0.
[0.22.4] - 2023-11-18
Fixed
- Don't render
lielement if a pagination link is not rendered.
[0.22.3] - 2023-11-14
Changed
- Support Flop ~> 0.24.0.
[0.22.2] - 2023-10-19
Fixed
- Numbered pagination links were not wrapped in
lielements.
[0.22.1] - 2023-09-28
Changed
- Allow to use
Phoenix.HTML.safe/0as a label attribute in table headers.
[0.22.0] - 2023-09-26
Added
- Added
directionsattribute to thecolslot of the table component. This allows you to override the default sort directions, e.g. to specify nulls-first or nulls-last. - Added
thead_th_attrsandth_wrapper_attrsattributes to thecolslot of the table component. - Added
thead_th_attrsattribute to theactionslot of the table component.
Changed
- Renamed
attrsattribute on thecolandactionslots of the table component totbody_td_attrsin order to match the naming of the global table options.
How to upgrade
Rename the attrs attribute to tbody_td_attrs in both the col slot and the
action slot:
<Flop.Phoenix.table items={@pets} meta={@meta} path={~p"/pets"}>
- <:col :let={p} attrs={[class="my-class"]}><%= p.id %></:col>
- <:action :let={p} attrs={[class="my-class"]}>button</:col>
+ <:col :let={p} tbody_td_attrs={[class="my-class"]}><%= p.id %></:col>
+ <:action :let={p} tbody_td_attrs={[class="my-class"]}>button</:col>
</Flop.Phoenix.table>[0.21.2] - 2023-09-26
Changed
- Support
phoenix_liveview ~> 0.20.
[0.21.1] - 2023-08-05
Added
- Allow passing a function to the
attrsoption of table component's:actionslot. Before, this was only supported in the:colslot.
Changed
- Improve some error messages and documentation examples.
Fixed
- In the
:coland:actionslots of the table component, theattrsoption did not properly override the attributes set with the:tbody_td_attrsoption.
[0.21.0] - 2023-07-17
Changed
- Depend on flop ~> 0.22.0.
[0.20.0] - 2023-07-09
Added
- Added an
on_paginateattribute to thepaginationandcursor_paginationcomponents. This attribute takes aPhoenix.LiveView.JScommand as a value. The attribute can be combined with thepathattribute, in which case the URL will be patched and the the given JS command is executed. - Similarly, an
on_sortattribute was added to thetablecomponent. - Allow setting
tbody_tr_attrsto a function that takes the current row item as an argument and returns a list of attributes. - Allow setting the
attrsattribute of the:colslot of the table component to a function that takes the current row item as an argument and returns a list of attributes.
Changed
- The table ID falls back to
"sortable-table"if no schema module is used. - The tbody ID was changed to
{id}-tbody. - The table container ID is set to
{id}-containernow. - The table ID is set to
{id}now.
Deprecated
- The
showandhideattributes of the:colslot of the table component are now deprecated in favor of the:ifattribute. - The
eventattribute of the pagination, cursor pagination and table components has been deprecated in favor ofon_paginationandon_sort.
[0.19.1] - 2023-06-30
Changed
- The table component only renders an ascending/descending order indicator in the column header for the first order field, instead rendering one in the column headers for all ordered fields.
- Support Flop 0.22.
[0.19.0] - 2023-05-30
Changed
- Necessary updates for
phoenix_live_view ~> 0.19.0. - Requires
phoenix_live_view ~> 0.19.0. - Remove previously deprecated
Flop.Phoenix.pop_filter/2. UseFlop.Filter.pop/3instead.
[0.18.2] - 2023-05-08
Changed
- Added
hiddenattribute to hidden inputs rendered byfilter_fieldscomponent in order to solve CSS spacing issues.
[0.18.1] - 2023-03-18
Changed
- Added support for LiveView streams to the table component. To this end,
row_id,row_itemandidattributes were added to the component, following the example of Phoenix 1.7. Theidattribute is added to thetbody. If noidis explicitly set, a default value will be used depending on the schema name.
[0.18.0] - 2023-02-25
Changed
- Added dependency on
Phoenix.HTML~> 3.3.0. - The
filter_fieldscomponent now passes thePhoenix.HTML.FormFieldstruct introduced inPhoenix.HTML3.3.0 to the inner block. - Support
:asoption for filter inputs withPhoenix.HTML.FormData/4(inputs_for). Phoenix.HTML.FormData.input_type/2now considers the Ecto type for join, custom and compound fields.- Remove support for
path_helperassigns, previously deprecated in 0.15. - Deprecate
Flop.Phoenix.pop_filter/2.
How to upgrade
If your input component already knows how to handle the
Phoenix.HTML.FormField struct, you can update the inner block for
filter_fields like this:
<.filter_fields :let={i} form={f} fields={[:email, :name]}>
<.input
- field={{i.form, i.field}}
+ field={i.field}
type={i.type}
label={i.label}
- id={i.id}
- name={i.name}
- value={i.value}
{i.rest}
/>
</.filter_fields>If your input component still expects the individual assigns, you can update
the inner block like this:
<.filter_fields :let={i} form={f} fields={[:email, :name]}>
<.input
- field={{i.form, i.field}}
+ field={{i.field.form, i.field.field}}
type={i.type}
label={i.label}
- id={i.id}
- name={i.name}
- value={i.value}
+ id={i.field.id}
+ name={i.field.name}
+ value={i.field.value}
{i.rest}
/>
</.filter_fields>For an upgrade example for the path_helper assign, see the changelog entry for
version 0.15.0.
[0.17.2] - 2023-01-15
Changed
- Support Flop 0.19.
[0.17.1] - 2022-11-15
Added
- Allow passing an
offsetwhen generating filter inputs withPhoenix.HTML.Form.inputs_for/3.
[0.17.0] - 2022-10-27
Added
- New option
tbody_attrsfor table component. - New attribute
row_clickand slotactionfor table component.
Changed
- To pass additional attributes to a column, you will now have to use the
attrsattribute. This was necessary because defining aglobalattribute on a slot causes a compile-time error inphoenix_live_view0.18.3.
<Flop.Phoenix.table items={@pets} meta={@meta} path={~p"/pets"}>
- <:col :let={p} class="my-class"><%= p.id %></:col>
+ <:col :let={p} attrs={[class="my-class"]}><%= p.id %></:col>
</Flop.Phoenix.table>[0.16.0] - 2022-10-10
Added
- New Phoenix component
Flop.Phoenix.hidden_inputs_for_filter/1.
Changed
- Major refactoring of
Flop.Phoenix.filter_fields/1. Instead of giving you the rendered<label>and<input>elements, the component now only passes the necessary arguments to the inner block. You will have to pass these arguments to your owninputcomponent (or whatever you name it). The field option format has also been updated. These changes were made to fix warnings emitted by live view 0.18.1, and also accompany current changes in Phoenix that thin outPhoenix.HTML/Phoenix.HTML.Formin favor of Phoenix components for inputs. - Require
flop >= 0.17.1 and < 0.19.0.
Removed
- Removed
Flop.Phoenix.filter_hidden_inputs_for/1. This function is not used internally anymore. You can either usePhoenix.HTML.Form.hidden_inputs_for/1(Phoenix.HTML ~> 3.2), or useFlop.Phoenix.hidden_inputs_for_filter/1, which does the same, but as a Phoenix component. - Removed
Flop.Phoenix.filter_label/1andFlop.Phoenix.filter_input/1. With the changes toFlop.Phoenix.filter_fields/1and the move away from the input rendering functions ofPhoenix.HTML.Form, these functions don't have any value anymore. Read the documentation ofFlop.Phoenix.hidden_inputs_for_filter/1for an example on how to easily render the fields of individual filters.
Fixed
- Fixed warnings about tainted variables in live view 0.18.1.
- Fixed an issue where default parameters set in the backend module were not removed from the query parameters.
- Fixed URLs ending with
?when no query parameters are necessary if the path is passed as a string.
How to upgrade
Filter fields component
Previously, you would render a filter form like this:
<.form :let={f} for={@meta}>
<Flop.Phoenix.filter_fields :let={entry} form={f} fields={[:name, :email]}>
<div class="field">
<%= entry.label %>
<%= entry.input %>
</div>
</Flop.Phoenix.filter_fields>
</.form>In this example, entry.label and entry.input are complete <label> and
<input> elements with all attributes set. You will need to change this to:
<.form :let={f} for={@meta}>
<.filter_fields :let={i} form={f} fields={[:name, :email]}>
<.input
id={i.id}
name={i.name}
label={i.label}
type={i.type}
value={i.value}
field={{i.form, i.field}}
{i.rest}
/>
</.filter_fields>
</.form>You will have to define an input component in your project. You can take a
hint from the input component that is generated as part of the Components
module by Phoenix 1.7.
Field options
Remove input_opts and label_opts and pass them directly to your input
component, or add them directly to the input component. If you passed an id
to filter_fields, set in on the form instead.
<.filter_fields
:let={i}
form={f}
fields={[:name]}
- id="some-id"
- input_opts={[class: "input", phx_debounce: 100]}
- label_opts={[class: "label"]}
>
<.input
...
+ class="input"
+ phx-debounce={100}
/>
</.filter_fields>Use strings instead of atoms to set the type, and use the types that your
input component understands.
<.filter_fields
:let={i}
form={f}
fields={[
- name: [type: :text_input],
+ name: [type: "text"],
- age: [type: :number_input],
+ age: [type: "number"],
- phone: [type: :telephone_input],
+ phone: [type: "tel"]
]}
>If you passed additional input function options in a tuple, take them out of the tuple and add them to the keyword list instead.
<.filter_fields
:let={i}
form={f}
fields={[
- role: [type: {:select, ["author", "editor"], class: "select"}]
+ role: [type: "select", options: ["author", "editor"], class: "select"]
]}
>The default option is not handled for you anymore. You can still set it, but
it will just be passed on as part of the rest options, so your input
component will need to handle it.
Filter label and input components
If you used Flop.Phoenix.filter_label/1 or Flop.Phoenix.filter_input/1
before, follow the example in the documentation of
Flop.hidden_inputs_for_filter/1 to render the inputs of individual filters
without the removed components.
[0.15.2] - 2022-10-10
Changed
- Change version requirement for Flop to
>= 0.15.0 and < 0.19.0.
[0.15.1] - 2022-09-30
Fixed
- Typespec of
Flop.Phoenix.build_path/3.
[0.15.0] - 2022-09-22
Added
This release adds support for passing URI strings instead of MFA or FA tuples to
components and helper functions. This allows you to use the library with the
verified routes introduced in Phoenix 1.7. Alternatively, you can now also
choose to pass a 1-ary path builder function. See Flop.Phoenix.build_path/3
for examples. Passing tuples pointing to route helpers is still supported.
- Added an example for a custom filter form component to the readme.
- Support passing a URI string as a path to the
table,paginationandcursor_paginationcomponents and tobuild_path/3. - Support passing a 1-ary path builder function to the
table,paginationandcursor_paginationcomponents and tobuild_path/3. - New function
Flop.Phoenix.pop_filter/2.
Changed
- Require
live_view ~> 0.18.0. - Deprecate
path_helperassign in favor ofpath. - Use declarative assigns and replace
Phoenix.LiveView.Helpers.live_patch/1withPhoenix.Component.link/1. Flop.Phoenix.filter_input/1requires additional options for the input function to be passed in theinput_optsassign, instead of passing them directly to the component. This was necessary because the global attributes you can define with declarative assigns in LiveView 0.18 are meant for HTML attributes, while the input options may contain any additional attributes necessary (e.g. a list of select options that are rendered as option elements).
Fixed
- Apply
showandhideattribute for columns tocolgroupas well. - Correctly handle multiple inputs for the same field in
Flop.filter_fields/1.
How to upgrade
Rename the path_helper assigns of table, pagination and
cursor_pagination components to path.
- <.pagination meta={@meta} path_helper={{Routes, :pet_path, [@socket, :index]}} />
+ <.pagination meta={@meta} path={{Routes, :pet_path, [@socket, :index]}} />Wrap additional options passed to Flop.Phoenix.filter_input/1 into a single
input_opts assign.
- <.filter_input form={ff} class="select" options={[:some, :options]} />
+ <.filter_input form={ff} input_opts={[class: "select", options: [:some, :options]]} />[0.14.2] - 2022-08-26
Changed
- Support Flop
~> 0.17.0.
[0.14.1] - 2022-03-22
Changed
- Support Flop
~> 0.16.0.
[0.14.0] - 2022-02-22
Added
symbol_unsortedoption for thetablecomponent.captionassign for thetablecomponent.col_styleassign for the:colslot of thetablecomponent.
Changed
- Additional attributes passed to the
<:col>slot will now be added as attributes to the<td>tags.
[0.13.0] - 2021-11-14
Added
- Add
cursor_pagination/1component.
Changed
- The pagination component adds the
disabledclass to thespanthat is displayed when the previous or next link is disabled now. Previously, thedisabledattribute was set on thespan. The class can be customized with the:disabled_classoption.
[0.12.0] - 2021-11-08
Added
- Implement the
Phoenix.HTML.FormDataprotocol forFlop.Meta. This means you can pass the meta struct as:foroption to the Phoenixform_forfunctions now. - Add the functions
filter_fields/1,filter_input/1andfilter_label/1.
Changed
- Remove
:foroption. The schema module is now automatically derived from the meta struct.
[0.11.1] - 2021-10-31
Added
- Adds
hideandshowoptions to table:col.
Changed
- Passing a
labelto a table:colis now optional.
[0.11.0] - 2021-10-30
Changed
- The
path_helper_argsassign has been removed in favor of passing mfa tuples aspath_helper. - In the same vein,
Flop.Phoenix.build_path/4has been replaced withFlop.Phoenix.build_path/3, which also takes a tuple as the first argument. - The table component has been changed to use slots. The
headers,footer,row_funcandrow_optsassigns have been removed. Also, thetfoot_td_attrsandtfoot_th_attrsoptions have been removed. - The
live_viewversion requirement has been changed to~> 0.17.0. - Better error messages for invalid assigns have been added.
How to upgrade
Update the path_helper and path_helper_args assigns set for the table
and pagination component:
- path_helper={&Routes.pet_path/3}
- path_helper_args={[@socket, :index]}
+ path_helper={{Routes, :pet_path, [@socket, :index]}}If you prefer, you can pass a function instead.
+ path_helper={{&Routes.pet_path/3, [@socket, :index]}}Update any calls to Flop.Phoenix.build_path/4:
- Flop.Phoenix.build_path(&Routes.pet_path/3, [@socket, :index], meta)
+ Flop.Phoenix.build_path({Routes, :pet_path, [@socket, :index]}, meta)If you prefer, you can use a 2-tuple here as well:
+ Flop.Phoenix.build_path({&Routes.pet_path/3, [@socket, :index]}, meta)Finally, update the tables in your templates:
<Flop.Phoenix.table
for={MyApp.Pet}
items={@pets}
meta={@meta}
- path_helper={&Routes.pet_path/3}
- path_helper_args={[@socket, :index]}
+ path_helper={{Routes, :pet_path, [@socket, :index]}}
- headers={[{"Name", :name}, {"Age", :age}]}
- row_func={fn pet, \_opts -> [pet.name, pet.age] end}
- footer={["", @average_age]}
- />
+ >
+ <:col let={pet} label="Name" field={:name}><%= pet.name %></:col>
+ <:col let={pet} label="Age" field={:age}><%= pet.age %></:col>
+ <:foot>
+ <tr>
+ <td></td>
+ <td><%= @average_age %></td>
+ </tr>
+ </:foot>
+ </Flop.Phoenix.table>Also, you can remove tfoot_td_attrs and tfoot_th_attrs from the opts
assign (or opts provider function).
[0.10.0] - 2021-10-24
Added
- It is now possible to set global options for the components in your config.
config :flop_phoenix,
pagination: [opts: {MyApp.ViewHelpers, :pagination_opts}],
table: [opts: {MyApp.ViewHelpers, :table_opts}]Changed
- The
for,eventandtargetoptions moved from theoptsassign to the root. Theoptsassign is now exclusively used for customization options that modify the appearance, which are usually set globally for a project and are not related to the specific data or view. - The
row_func/2function passed to thetablecomponent receives the newrow_optsassign now instead of theoptsassign. - The pagination and table components only pass the
foroption to the query builder, instead of allopts. - The
path_helperandpath_helper_argsassigns are now optional if aneventis passed. A descriptive error is raised if neither of them are passed. - The
optsassign for the pagination and table components is now optional. - Aria labels were added to the links to the first and last page.
- The
aria-sortattribute was added to the table headers.
How to upgrade
- Remove the
for,eventandtargetfrom theoptsassign and add them as regular assigns at the root level. - Move any key/value pairs that are needed by your
row_funcfromoptstorow_opts.
For example, if your row_func looks like this:
def table_row(%Pet{id: id, name: name}, opts) do
socket = Keyword.fetch!(opts, :socket)
[name, link("show", to: Routes.pet_path(socket, :show, id))]
endUpdate your template like this:
<Flop.Phoenix.sortable_table
row_func={&table_row/2}
- opts={[
- container: true,
- for: Pet,
- event: "sort-table",
- target: @myself,
- socket: @socket
- ]}
+ row_opts={[socket: @socket]}
+ for={Pet}
+ event="sort-table"
+ target={@myself}
+ opts={[container: true]}
/>
<Flop.Phoenix.pagination
- opts={[
- for: Pet,
- event: "paginate",
- target: @myself,
- page_links: {:ellipsis, 7}
- ]}
+ for={Pet}
+ event="paginate"
+ target={@myself}
+ opts={[page_links: {:ellipsis, 7}]}
/>[0.9.1] - 2021-10-22
Changed
- Change
live_viewversion requirement to~> 0.16.0 or ~> 0.17.0.
[0.9.0] - 2021-10-04
Added
- Add table foot option for sortable table.
[0.8.1] - 2021-08-11
Changed
- Loosen version requirement for Flop.
[0.8.0] - 2021-08-11
Added
- New options
eventandtargetfor the pagination and sortable table component, which allow to emit pagination and sorting events in LiveView without patching the URL.
Changed
- Use
HEExtemplates for both the pagination and the sortable table component. Refer to the Readme for usage examples. - Require
live_view ~> 0.16.0. - Support safe HTML tuples in unsortable table headers.
- Improve documentation with examples for LiveView, HEEx templates and EEx templates.
[0.7.0] - 2021-06-13
Added
- Add wrapper around sortable table header link and order direction indicator.
- Add option
current_link_attrsto pagination builder. - Add options
thead_tr_attrs,thead_th_attrs,tbody_tr_attrsandtbody_td_attrsto table generator. - Add option
no_results_contentto table generator, which sets the content that is going to be displayed instead of the table if the item list is empty. A default option is applied, so make sure to set the option and/or remove your own no results messages from your templates when making the upgrade.
Changed
- The table options
table_class,th_wrapper_class,symbol_classandcontainer_classwere replaced in favour oftable_attrs,th_wrapper_attrs,symbol_attrsandcontainer_attrsfor more flexibility and consistency with the pagination generator. To update, rename the options in your code and wrap the values in keyword lists with aclasskey (e.g.container_class: "table-container"=>container_attrs: [class: "table-container"]). - The
pagination_link_attrsis not applied to current links anymore. Usecurrent_link_attrsto set the attributes for the current link. - Omit
page=1andoffset=0when building query parameters. - Omit default values for order and limit/page size parameters when building query parameters.
- Requires Flop
~> 0.11.0.
Fixed
- Order direction indicator was wrapped twice.
- A Flop struct with an offset was resulting in invalid pagination links.
[0.6.1] - 2021-05-05
Fixed
- Pagination helper generated invalid links when using
default_limitoption.
[0.6.0] - 2021-05-04
Added
- Add
Flop.Phoenix.table/1for rendering sortable tables. - Add function
Flop.Phoenix.to_query/1, which converts a Flop struct into a keyword list for query parameters. - Add function
Flop.Phoenix.build_path/3, which applies Flop parameters to a Phoenix path helper function.
Removed
- Remove
Flop.Phoenix.Live.PaginationComponentin favor of makingFlop.Phoenix.pagination/4work in both.eexand.leextemplates.
[0.5.1] - 2021-04-14
Fixed
- Merge pagination query parameters into existing query parameters, if present.
[0.5.0] - 2021-03-23
Changed
- Rename
FlopPhoenixtoFlop.Phoenix. - Add
Flop.Phoenix.Live.PaginationComponentfor use withPhoenix.LiveView. - Change pagination to always display links to the first and last page.
[0.4.0] - 2020-09-04
Changed
- Allow usage with newer versions of Flop.
[0.3.0] - 2020-06-17
Added
- New option to hide the number of page links.
- New option to limit the number of page links.
Changed
- Add order and filter parameters to pagination links.
[0.2.0] - 2020-06-15
Added
- Improve documentation.
Changed
previous_link/3,next_link/3andpage_links/3are private functions now.
[0.1.0] - 2020-06-15
Initial release