playbook_ui 13.30.0.pre.alpha.20240515remotebuildkitconversion3150 → 13.31.0.pre.alpha.PLAY882formpillprimaryandneutral3201

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_background/background.html.erb +2 -11
  3. data/app/pb_kits/playbook/pb_body/body.html.erb +1 -6
  4. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +1 -6
  5. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +1 -6
  6. data/app/pb_kits/playbook/pb_caption/caption.html.erb +1 -6
  7. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -7
  8. data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.jsx +4 -1
  9. data/app/pb_kits/playbook/pb_detail/detail.html.erb +1 -6
  10. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -6
  11. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +1 -6
  12. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +2 -5
  13. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -6
  14. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +15 -1
  15. data/app/pb_kits/playbook/pb_draggable/context/types.ts +5 -0
  16. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +14 -19
  17. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +5 -3
  18. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +7 -3
  19. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +3 -5
  20. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +3 -5
  21. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +3 -1
  22. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +2 -0
  23. data/app/pb_kits/playbook/pb_dropdown/index.js +33 -4
  24. data/app/pb_kits/playbook/pb_flex/flex.html.erb +1 -5
  25. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +9 -0
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +108 -5
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +53 -0
  28. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +11 -2
  29. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  30. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +5 -1
  31. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -6
  32. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +1 -5
  33. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +1 -5
  34. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.html.erb +1 -6
  35. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.jsx +3 -20
  36. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -23
  37. data/dist/menu.yml +566 -472
  38. data/dist/playbook-rails.js +6 -6
  39. data/lib/playbook/version.rb +2 -2
  40. metadata +3 -3
  41. data/app/pb_kits/playbook/pb_icon/types.d.ts +0 -1
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { render, screen } from '../utilities/test-utils';
3
+ import FormPill from './_form_pill';
4
+
5
+ const testId = 'formpill';
6
+
7
+ test('should render classname', () => {
8
+ render(
9
+ <FormPill
10
+ data={{ testid: testId }}
11
+ text="test"
12
+ />
13
+ )
14
+
15
+ const kit = screen.getByTestId(testId)
16
+ expect(kit).toHaveClass('pb_form_pill_kit_primary none')
17
+ });
18
+
19
+ test('displays text content', () => {
20
+ render(
21
+ <FormPill
22
+ data={{ testid: testId }}
23
+ text="test"
24
+ />
25
+ )
26
+
27
+ const text = screen.getByText("test")
28
+ expect(text).toBeInTheDocument()
29
+ });
30
+
31
+ test('displays color variant', () => {
32
+ render(
33
+ <FormPill
34
+ color={"neutral"}
35
+ data={{ testid: testId }}
36
+ text={"test"}
37
+ />
38
+ )
39
+ const kit = screen.getByTestId(testId)
40
+ expect(kit).toHaveClass(`pb_form_pill_kit_neutral none`)
41
+ });
42
+
43
+ test('displays size variant', () => {
44
+ render(
45
+ <FormPill
46
+ data={{ testid: testId }}
47
+ size={"small"}
48
+ text={"test"}
49
+ />
50
+ )
51
+ const kit = screen.getByTestId('formpill')
52
+ expect(kit).toHaveClass(`pb_form_pill_kit_primary small none`)
53
+ });
@@ -5,7 +5,7 @@ import Title from '../pb_title/_title'
5
5
  import Icon from '../pb_icon/_icon'
6
6
  import Avatar from '../pb_avatar/_avatar'
7
7
  import { globalProps, GlobalProps } from '../utilities/globalProps'
8
- import { buildHtmlProps } from '../utilities/props'
8
+ import { buildDataProps, buildHtmlProps } from '../utilities/props'
9
9
 
10
10
  type FormPillProps = {
11
11
  className?: string,
@@ -18,6 +18,9 @@ type FormPillProps = {
18
18
  avatarUrl?: string,
19
19
  size?: string,
20
20
  textTransform?: 'none' | 'lowercase',
21
+ color?: "primary" | "neutral",
22
+ data?: {[key: string]: string},
23
+ tabIndex?: number,
21
24
  closeProps?: {
22
25
  onClick?: React.MouseEventHandler<HTMLSpanElement>,
23
26
  onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
@@ -36,20 +39,26 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
36
39
  closeProps = {},
37
40
  size = '',
38
41
  textTransform = 'none',
42
+ color = "primary",
43
+ data = {},
44
+ tabIndex,
39
45
  } = props
40
46
  const css = classnames(
41
- `pb_form_pill_kit_${'primary'}`,
47
+ `pb_form_pill_kit_${color}`,
42
48
  globalProps(props),
43
49
  className,
44
50
  size === 'small' ? 'small' : null,
45
51
  textTransform,
46
52
  )
47
53
 
54
+ const dataProps = buildDataProps(data)
48
55
  const htmlProps = buildHtmlProps(htmlOptions)
49
56
 
50
57
  return (
51
58
  <div className={css}
52
59
  id={id}
60
+ tabIndex={tabIndex}
61
+ {...dataProps}
53
62
  {...htmlProps}
54
63
  >
55
64
  {name &&
@@ -1,4 +1,4 @@
1
- <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) do %>
1
+ <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
4
4
  <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
@@ -11,9 +11,13 @@ module Playbook
11
11
  prop :text_transform, type: Playbook::Props::Enum,
12
12
  values: %w[none lowercase],
13
13
  default: "none"
14
+ prop :color, type: Playbook::Props::Enum,
15
+ values: %w[primary neutral],
16
+ default: "primary"
17
+ prop :tabindex
14
18
 
15
19
  def classname
16
- generate_classname("pb_form_pill_kit", "primary", name, text, text_transform)
20
+ generate_classname("pb_form_pill_kit", color, name, text, text_transform)
17
21
  end
18
22
 
19
23
  def display_text
@@ -1,9 +1,4 @@
1
- <%= content_tag(:span,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:span) do %>
7
2
  <%= link_to object.url, target: object.link_option do %>
8
3
  <%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
9
4
  <% end %>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:span,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:span) do %>
6
2
  <mark>
7
3
  <%= content.presence || object.text %>
8
4
  </mark>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
6
2
  <%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
7
3
  <% end %>
8
4
 
@@ -1,6 +1 @@
1
- <%= pb_rails("icon", props: { icon: "angles-down", fixed_width: true }) %>
2
- <%= pb_rails("icon", props: { icon: "circle-arrow-right", fixed_width: true }) %>
3
- <%= pb_rails("icon", props: { icon: "arrow-circle-right", fixed_width: true }) %>
4
-
5
- <%= pb_rails("caption", props: { text: "Font Awesome (no alias & not in our Playbook-icons lib)", margin_y: "md" }) %>
6
- <%= pb_rails("icon", props: { icon: "elephant", fixed_width: true }) %>
1
+ <%= pb_rails("icon", props: { icon: "user", fixed_width: true }) %>
@@ -1,29 +1,12 @@
1
1
  import React from "react"
2
-
3
2
  import Icon from "../_icon"
4
- import {Caption} from "../.."
5
3
 
6
4
  const IconDefault = (props) => {
7
5
  return (
8
6
  <div>
9
- <Icon fixedWidth
10
- icon='angles-down'
11
- {...props}
12
- />
13
- <Icon fixedWidth
14
- icon='circle-arrow-right'
15
- {...props}
16
- />
17
- <Icon fixedWidth
18
- icon='arrow-circle-right'
19
- {...props}
20
- />
21
- <Caption
22
- marginY='md'
23
- text='Font Awesome (no alias & not in our Playbook-icons lib)'
24
- />
25
- <Icon fixedWidth
26
- icon='elephant'
7
+ <Icon
8
+ fixedWidth
9
+ icon="user"
27
10
  {...props}
28
11
  />
29
12
  </div>
@@ -86,33 +86,18 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
86
86
  const toolbarElement = element.parentElement.querySelector('trix-toolbar') as HTMLElement,
87
87
  blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
88
88
 
89
+ // replace default trix "block code" button with "inline code" button
89
90
  let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]') as HTMLElement
90
- if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
91
-
92
- // set button attributes
93
- inlineCodeButton.dataset.trixAttribute = 'inlineCode'
94
- blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
91
+ if (!inlineCodeButton) {
92
+ inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
93
+ blockCodeButton.hidden = true
94
+ // set button attributes
95
+ inlineCodeButton.dataset.trixAttribute = 'inlineCode'
96
+ blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
97
+ }
95
98
 
96
99
  if (toolbarBottom) editor.element.after(toolbarElement)
97
100
 
98
- const getCodeFormattingType = (): string => {
99
- if (editor.attributeIsActive('code')) return 'block'
100
- if (editor.attributeIsActive('inlineCode')) return 'inline'
101
-
102
- const range = editor.getSelectedRange()
103
- if (range[0] == range[1]) return 'block'
104
-
105
- const text = editor.getSelectedDocument().toString().trim()
106
- return /\n/.test(text) ? 'block' : 'inline'
107
- }
108
-
109
- // DOM event listeners
110
- element.addEventListener('trix-selection-change', () => {
111
- const type = getCodeFormattingType()
112
- blockCodeButton.hidden = type == 'inline'
113
- inlineCodeButton.hidden = type == 'block'
114
- })
115
-
116
101
  focus
117
102
  ? (document.addEventListener('trix-focus', useFocus),
118
103
  document.addEventListener('trix-blur', useFocus),