playbook_ui 16.5.0.pre.rc.2 → 16.5.0.pre.rc.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98207b8b5cdcfbfb88cfdb2a778ca623f572afc5e5817ce9d3cd0f1117b336b0
4
- data.tar.gz: e603e243afe259f96d162f5bbdef58cb7efdb2ca05fabf942a0ae8f6452dc629
3
+ metadata.gz: 50ca8e58f947f8dbec4fc7f659410b09588f9b11d0404c18824a67866c5773e7
4
+ data.tar.gz: d3e1e785a1f9b4f24910a199890f6c8342a5a479f7a3ec948d0f9bed0d88fed4
5
5
  SHA512:
6
- metadata.gz: 97ced981390eabf50717b0270dd0db9ba7798c0edcdfa0ef2eac929fa3aba2fa8a09492f4e76d26f077a0c37f58a479494d2c5ee2e36e2cedc4ada8158633711
7
- data.tar.gz: 39b0df5624e178851b72acd00d548e346c0ab0526ac23f42f4bbb6718db73ccd6e6104edb780885eb7b45954a1368e6b1d6972105d2f93659451ccc66d1ed878
6
+ metadata.gz: cb09d5d1204fb4929189c91eab464aec3e55257119016aacf4c307a93a7b5626026a633e69905b17ea8c1f9f81e391e8311919fae5bab6f9a2ff6e53f83ff454
7
+ data.tar.gz: 1a84b06d8c5943f8466234897a3218b27ff344ed65bdc0a96b67a0aa74d6337040ebff422ebcfae70d1cf4fb20b3e5a64ca5975e97d9f70a3878b6248bc0f246
@@ -55,6 +55,7 @@ sections:
55
55
  - table_with_clickable_rows
56
56
  - table_with_selectable_rows
57
57
  - table_with_filter_variant
58
+ - table_with_filter_variant_external_filter_rails
58
59
  - table_with_filter_variant_with_pagination
59
60
  - table_disable_hover
60
61
 
@@ -0,0 +1,45 @@
1
+ <%# External filter: capture any filter markup and pass it via the filter prop.
2
+ Use your own helper (e.g. a search/filter form) or pb_rails("filter") as shown here. %>
3
+ <% users = [
4
+ { name: "Alex", role: "Engineer" },
5
+ { name: "Sam", role: "Designer" },
6
+ { name: "Jordan", role: "Manager" },
7
+ ] %>
8
+
9
+ <% filter_output = capture do %>
10
+ <%= pb_rails("filter", props: {
11
+ id: "external-filter-demo",
12
+ template: "single",
13
+ results: 3,
14
+ background: false,
15
+ sort_menu: [
16
+ { item: "Name", link: "#", active: true, direction: "asc" },
17
+ { item: "Role", link: "#", active: false },
18
+ ],
19
+ }) do %>
20
+ <%= pb_rails("text_input", props: { label: "Name", placeholder: "Search by name" }) %>
21
+ <%= pb_rails("text_input", props: { label: "Role", placeholder: "e.g. Engineer, Designer" }) %>
22
+ <%= pb_rails("button", props: { text: "Apply" }) %>
23
+ <% end %>
24
+ <% end %>
25
+
26
+ <%= pb_rails("table", props: {
27
+ variant: "with_filter",
28
+ title: "Table with External Filter",
29
+ filter: filter_output,
30
+ }) do %>
31
+ <%= pb_rails("table/table_head") do %>
32
+ <%= pb_rails("table/table_row") do %>
33
+ <%= pb_rails("table/table_header", props: { text: "Name" }) %>
34
+ <%= pb_rails("table/table_header", props: { text: "Role" }) %>
35
+ <% end %>
36
+ <% end %>
37
+ <%= pb_rails("table/table_body") do %>
38
+ <% users.each do |user| %>
39
+ <%= pb_rails("table/table_row") do %>
40
+ <%= pb_rails("table/table_cell") { user[:name] } %>
41
+ <%= pb_rails("table/table_cell") { user[:role] } %>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+ <% end %>
@@ -0,0 +1,39 @@
1
+ Use the **"with_filter"** variant with an **external filter** (Option B): pass pre-rendered filter markup via the `filter` prop. Same layout as Variant with Filter (card, title, separator, flex); only the filter slot is supplied by you. Use this when you need:
2
+
3
+ - **Manual filter submission** – Apply / Filter button instead of automatic application
4
+ - **Full control** – Over filter props, template, sort menu, and submission
5
+ - **Custom or app-specific filter helpers** – Any helper that returns filter markup (e.g. search/filter forms)
6
+
7
+ #### Required props
8
+
9
+ - `variant: "with_filter"`
10
+ - `filter` – Pre-rendered filter HTML (e.g. from `capture { ... }`)
11
+
12
+ When `filter` is present, `filter_content` and `filter_props` are ignored.
13
+
14
+ #### How to do it
15
+
16
+ 1. **Render your filter** (e.g. `pb_rails("filter", ...)` or any helper that returns filter markup).
17
+ 2. **Capture the output** with `capture do ... end`.
18
+ 3. **Pass it to the Table** as the `filter` prop.
19
+
20
+ **Example (generic pattern):**
21
+
22
+ ```erb
23
+ <% filter_output = capture do %>
24
+ <%= pb_rails("filter", props: { template: "single", results: 10, background: false }) do %>
25
+ <%= pb_rails("text_input", props: { label: "Name", placeholder: "Search by name" }) %>
26
+ <%= pb_rails("button", props: { text: "Apply" }) %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <%= pb_rails("table", props: {
31
+ variant: "with_filter",
32
+ title: "My Table",
33
+ filter: filter_output,
34
+ }) do %>
35
+ <%# table_head / table_body ... %>
36
+ <% end %>
37
+ ```
38
+
39
+ For Nitro apps that use a shared search/filter pattern, reference the example on Alpha for implementation details.
@@ -26,8 +26,9 @@ The Table kit automatically sets these Filter defaults (which you can override v
26
26
  - `min_width: "xs"`
27
27
  - `popover_props: { width: "350px" }`
28
28
 
29
+ Alternatively, you can pass pre-rendered filter markup via the `filter` prop (e.g. for manual submission or custom filter helpers)—scroll down for that approach.
29
30
 
30
31
  **IMPORTANT NOTE**:
31
32
  The purpose of this variant is to provide an easy way to set up a Table with a Filter with Design standards applied by default.
32
33
 
33
- If you are looking for more customization than this embedded variant provides, you may be better served by using the individual kits as demonstrating in our Table Filter Card Building Block as seen [here](https://playbook.powerapp.cloud/building_blocks/table_filter_card/rails).
34
+ If you are looking for more customization than this embedded variant provides, you may be better served by using the individual kits as demonstrated in our Table Filter Card Building Block as seen [here](https://playbook.powerapp.cloud/building_blocks/table_filter_card/rails).
@@ -41,6 +41,7 @@ examples:
41
41
  - table_with_header_style_borderless: Header Style Borderless
42
42
  - table_with_header_style_floating: Header Style Floating
43
43
  - table_with_filter_variant_rails: Variant with Filter
44
+ - table_with_filter_variant_external_filter_rails: Variant with Filter (External Filter)
44
45
  - table_with_filter_variant_with_pagination_rails: Variant with Filter and Pagination
45
46
  - table_with_filter_with_card_title_props_rails: Variant with Filter (with Card and Title Props)
46
47
 
@@ -16,7 +16,10 @@
16
16
  flex_direction: "column",
17
17
  gap: "none"
18
18
  }) do %>
19
- <% if object.filter_content.present? %>
19
+ <% has_filter = object.filter.present? || object.filter_content.present? %>
20
+ <% if object.filter.present? %>
21
+ <%= object.filter %>
22
+ <% elsif object.filter_content.present? %>
20
23
  <%
21
24
  default_filter_props = {
22
25
  background: false,
@@ -31,7 +34,7 @@
31
34
  <%= object.filter_content %>
32
35
  <% end %>
33
36
  <% end %>
34
- <%= pb_rails("section_separator") if object.filter_content.present? %>
37
+ <%= pb_rails("section_separator") if has_filter %>
35
38
  <% if object.pagination.present? %>
36
39
  <%= object.pagination %>
37
40
  <%= pb_rails("section_separator") %>
@@ -46,6 +46,10 @@ module Playbook
46
46
  prop :filter_props, type: Playbook::Props::HashProp,
47
47
  default: {}
48
48
  prop :filter_content
49
+ # Pre-rendered filter slot (e.g. output of capture { your_filter_helper }).
50
+ # When present, this is rendered as-is; filter_content and filter_props are ignored.
51
+ # Use this for manual filter submission or app-specific filter helpers.
52
+ prop :filter
49
53
  prop :pagination
50
54
  prop :title, type: Playbook::Props::String,
51
55
  default: nil
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/no-danger */
2
1
  /* eslint-disable react/no-multi-comp */
3
2
 
4
3
  import React, { useState } from 'react'
@@ -38,14 +37,26 @@ const TypeaheadWithHighlight = (props) => {
38
37
  const [selectedUser, setSelectedUser] = useState()
39
38
 
40
39
  const formatOptionLabel = ({name, territory, title}, {inputValue}) => {
40
+ const escapeRegExp = (value = "") => (
41
+ value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
42
+ )
41
43
 
42
- const highlighted = (text) => {
44
+ const highlighted = (text = "") => {
43
45
  if (!inputValue.length) return text
44
- return text.replace(
45
- new RegExp(inputValue, 'gi'),
46
- (highlighted) => `<mark>${highlighted}</mark>`
47
- )
46
+
47
+ const escapedInputValue = escapeRegExp(inputValue)
48
+ const regex = new RegExp(`(${escapedInputValue})`, 'gi')
49
+ const parts = text.split(regex)
50
+
51
+ return parts.map((part, index) => {
52
+ if (part.toLowerCase() === inputValue.toLowerCase()) {
53
+ return <mark key={`${part}-${index}`}>{part}</mark>
54
+ }
55
+
56
+ return <React.Fragment key={`${part}-${index}`}>{part}</React.Fragment>
57
+ })
48
58
  }
59
+
49
60
  return (
50
61
  <Flex>
51
62
  <FlexItem>
@@ -61,11 +72,12 @@ const TypeaheadWithHighlight = (props) => {
61
72
  size={4}
62
73
  {...props}
63
74
  >
64
- <span dangerouslySetInnerHTML={{ __html: highlighted(name) }} /></Title>
75
+ {highlighted(name)}
76
+ </Title>
65
77
  <Body color="light"
66
78
  {...props}
67
79
  >
68
- <span dangerouslySetInnerHTML={{ __html: highlighted(title) }} />{" • "}
80
+ {highlighted(title)}{" • "}
69
81
  {territory}
70
82
  </Body>
71
83
  </FlexItem>
@@ -0,0 +1,3 @@
1
+ Use `formatOptionLabel` to customize each option row and highlight text that matches the current search input. Split each field (for example, `name` and `title`) by the typed value, then render matching parts inside `<mark>` so users can quickly see why a result matched.
2
+
3
+ See the code snippet below for more details.
@@ -21,7 +21,8 @@
21
21
  }
22
22
 
23
23
  @mixin hover-underline {
24
- .hover_underline:hover {
24
+ .hover_underline:hover,
25
+ .group_hover:hover .group_hover.hover_underline {
25
26
  text-decoration: underline;
26
27
  transition: text-decoration $transition-speed ease;
27
28
  }
@@ -29,11 +30,13 @@
29
30
 
30
31
  @mixin hover-color-classes($colors-list) {
31
32
  @each $name, $color in $colors-list {
32
- .hover_background-#{"" + $name}:hover {
33
+ .hover_background-#{"" + $name}:hover,
34
+ .group_hover:hover .group_hover.hover_background-#{"" + $name} {
33
35
  background-color: $color !important;
34
36
  transition: background-color $transition-speed ease;
35
37
  }
36
- .hover_color-#{"" + $name}:hover {
38
+ .hover_color-#{"" + $name}:hover,
39
+ .group_hover:hover .group_hover.hover_color-#{"" + $name} {
37
40
  color: $color !important;
38
41
  transition: color $transition-speed ease;
39
42
  }