Skip to content

Releases: woylie/flop_phoenix

0.25.3

31 Jul 08:05
d4f13b6

Choose a tag to compare

Changed

  • Require phoenix_live_view ~> 1.0.6 or ~> 1.1.0.

0.25.2

25 Jun 08:52
66c479e

Choose a tag to compare

Fixed

  • Allow overriding maxlength attribute in filter value field.

0.25.1

05 May 09:20
760a641

Choose a tag to compare

Fixed

  • Function clause error when no pagination parameters are passed and no
    default_pagination_type is set.

0.25.0

04 May 09:54
29988ad

Choose a tag to compare

Added

  • Add guide about load-more buttons and infinite scroll.
  • Add guide about CSS styles.
  • Add guide about page size controls.

Changed

  • Remove opts attribute from Flop.Phoenix.pagination/1 and remove
    configuration of the pagination component via application environment.
  • Remove all default classes from pagination component.
  • Remove wrapper_attrs from pagination component in favor of global
    attributes.
  • Set page link aria label function with page_link_aria_label_fun attribute
    on Flop.Phoenix.pagination/1 component instead of using
    pagination_link_aria_label option.
  • 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_attrs attribute instead of
    pagination_list_attrs option.
  • Set pagination list item attributes with page_list_item_attrs attribute
    instead of pagination_list_item_attrs option.
  • Set pagination link attributes with page_link_attrs attribute
    instead of pagination_link_attrs option.
  • Set current pagination link attributes with current_page_link_attrs
    attribute instead of current_link_attrs option.
  • Set disabled link attributes with disabled_link_attrs attribute instead of
    disabled_attrs option.
  • Remove default classes for pagination root element, pagination list and
    pagination links.
  • Use <button> elements for pagination if no path is set.
  • Remove role attribute from the pagination component. The <nav> element
    already has the implicit ARIA role navigation.
  • Add rel attribute 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/1 to use
    Phoenix.Component.inputs_for/1 with the skip_persistent_id option.
  • 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_opts 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"],
-     elipsis_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.1

03 Feb 04:00
f485dab

Choose a tag to compare

Fixed

  • Determine pagination type when there is only a limit.

0.24.0

01 Feb 09:40
d4ab8ce

Choose a tag to compare

Added

  • Add Flop.Phoenix.Pagination struct to hold information needed to render
    a pagination component.
  • Add Flop.Phoenix.Pagination.new/2 to build a Pagination struct from a
    Flop.Meta struct.
  • Add Flop.Phoenix.pagination_for/1 for building custom pagination components.
    Update the existing Flop.Phoenix.pagination/1 component to it.
  • Add Flop.Phoenix.page_link_range/3 for determining which page links to
    render in a pagination component.

Changed

  • Support cursor pagination in Flop.Phoenix.pagination/1.
  • Remove the page_links option from the pagination_opts. Set this option
    with the new page_links attribute instead.
  • Change the values of the page_links option from
    :all | :hide | {:ellipsis, pos_integer} to :all | :none | pos_integer.
  • Change default value for page_links option of the
    Flop.Phoenix.pagination/1 component from :all to 5.
  • Deprecate configuring the pagination and table components via the
    application environment. Define wrapper components that pass the opts
    attribute 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. Use Flop.Phoenix.pagination/1
    instead.
  • Remove t:Flop.Phoenix.cursor_pagination_option/0.
  • Remove Flop.Phoenix.IncorrectPaginationTypeError.
  • Remove input_type/3 from the Phoenix.HTML.FormData protocol
    implementation for Flop.Meta. The function had been removed from the
    protocol in Phoenix.HTML 4.0.
  • Remove the previously deprecated event attribute from the
    Flop.Phoenix.pagination/1 and Flop.Phoenix.table/1 components. Use
    :on_paginate and :on_sort instead.
  • Remove the previously deprecated hide and show attributes from the
    :col and :action slots of the Flop.Phoenix.table/1 component. Use the
    :if attribute 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

18 Oct 00:18
b2af85d

Choose a tag to compare

Changed

  • Raise an error if a meta struct with the wrong pagination type is passed to the pagination or cursor_pagination component.

Fixed

  • Fix compilation error in Phoenix LiveView 1.0.0-rc.7.
  • Fix type of row_click attribute.

0.23.0

18 Aug 02:44
80dd8c0

Choose a tag to compare

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

18 Aug 02:28
cefb455

Choose a tag to compare

Changed

  • Loosen version requirement for flop to support 0.26.

0.22.9

04 May 04:05
9323c81

Choose a tag to compare

Added

  • Added :pagination_list_item_attrs option to Flop.Phoenix.pagination/1.