playbook_ui 14.14.0.pre.alpha.PBNTR907reactfilterpopoverpropswidthbug6557 → 14.14.0.pre.alpha.pbntr500currencykithandlingofnullvalues6275

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 (148) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +3 -143
  3. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +99 -45
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -123
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +299 -153
  6. data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
  7. data/app/pb_kits/playbook/pb_currency/_currency.tsx +2 -1
  8. data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -1
  9. data/app/pb_kits/playbook/pb_currency/currency.rb +2 -14
  10. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +1 -3
  11. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -4
  12. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
  13. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +3 -43
  14. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
  15. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +37 -20
  16. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -20
  17. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
  18. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +0 -1
  19. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -6
  20. data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +12 -20
  21. data/app/pb_kits/playbook/pb_drawer/drawer.rb +1 -49
  22. data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -5
  23. data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
  24. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
  25. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -9
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +0 -4
  27. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +0 -2
  28. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +0 -1
  29. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -7
  30. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +0 -4
  31. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +0 -7
  32. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -13
  33. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -2
  34. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
  35. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -6
  36. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
  37. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
  38. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -3
  39. data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
  40. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +3 -5
  41. data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -16
  42. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
  43. data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
  44. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  45. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +2 -2
  46. data/app/pb_kits/playbook/pb_radio/_radio.tsx +74 -85
  47. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
  48. data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
  49. data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
  50. data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -1
  51. data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
  52. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -3
  53. data/app/pb_kits/playbook/pb_select/select.rb +0 -8
  54. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  55. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  56. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  57. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
  58. data/app/pb_kits/playbook/pb_title/_title.scss +0 -32
  59. data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
  60. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
  61. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  62. data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
  63. data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
  64. data/app/pb_kits/playbook/pb_title/title.rb +1 -10
  65. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
  66. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -25
  67. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -3
  68. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
  69. data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
  70. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
  71. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -36
  72. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
  73. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
  74. data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
  75. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -17
  76. data/app/pb_kits/playbook/utilities/object.ts +1 -29
  77. data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
  78. data/dist/chunks/_weekday_stacked-BhC8Xp9l.js +45 -0
  79. data/dist/chunks/{lib-5OzNgeeu.js → lib-D3us1bGD.js} +2 -2
  80. data/dist/chunks/{pb_form_validation-DGhKbZtO.js → pb_form_validation-BpihMSOQ.js} +1 -1
  81. data/dist/chunks/vendor.js +1 -1
  82. data/dist/menu.yml +3 -3
  83. data/dist/playbook-doc.js +1 -1
  84. data/dist/playbook-rails-react-bindings.js +1 -1
  85. data/dist/playbook-rails.js +1 -1
  86. data/dist/playbook.css +1 -1
  87. data/lib/playbook/version.rb +1 -1
  88. metadata +6 -64
  89. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +0 -127
  90. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +0 -55
  91. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +0 -33
  92. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +0 -275
  93. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +0 -66
  94. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +0 -195
  95. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +0 -73
  96. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +0 -52
  97. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +0 -80
  98. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +0 -50
  99. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +0 -152002
  100. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +0 -1
  101. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +0 -1
  102. data/app/pb_kits/playbook/pb_date_picker/index.ts +0 -38
  103. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +0 -8
  104. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +0 -33
  105. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  106. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +0 -24
  107. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +0 -21
  108. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +0 -1
  109. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +0 -49
  110. data/app/pb_kits/playbook/pb_drawer/index.js +0 -257
  111. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +0 -40
  112. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +0 -50
  113. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +0 -3
  114. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +0 -71
  115. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +0 -17
  116. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +0 -61
  117. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +0 -2
  118. data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +0 -39
  119. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +0 -72
  120. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +0 -91
  121. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
  122. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
  123. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
  124. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
  125. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +0 -11
  126. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +0 -1
  127. data/app/pb_kits/playbook/pb_overlay/index.js +0 -61
  128. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
  129. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
  130. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +0 -58
  131. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +0 -1
  132. data/app/pb_kits/playbook/pb_select/index.js +0 -38
  133. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
  134. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
  135. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
  136. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +0 -39
  137. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +0 -3
  138. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +0 -26
  139. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +0 -69
  140. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +0 -3
  141. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
  142. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
  143. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
  144. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
  145. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
  146. data/app/pb_kits/playbook/utilities/object.test.js +0 -99
  147. data/dist/chunks/_typeahead-F4bG5YsC.js +0 -36
  148. data/dist/chunks/_weekday_stacked-CaWVQMMq.js +0 -45
@@ -1,26 +0,0 @@
1
- <%= pb_rails("flex", props: { gap: "md", wrap: true }) do %>
2
- <%= pb_rails("flex/flex_item") do %>
3
- <%= pb_rails("button", props: { text: "With Interaction", id: "tooltip-interaction"}) %>
4
-
5
- <%= pb_rails("tooltip", props: {
6
- trigger_element_selector: "#tooltip-interaction",
7
- tooltip_id: "tooltip-with-interaction",
8
- position: 'top',
9
- interaction: true
10
- }) do %>
11
- You can copy me
12
- <% end %>
13
- <% end %>
14
-
15
- <%= pb_rails("flex/flex_item") do %>
16
- <%= pb_rails("button", props: { text: "No Interaction", id: "tooltip-no-interaction"}) %>
17
-
18
- <%= pb_rails("tooltip", props: {
19
- trigger_element_selector: "#tooltip-no-interaction",
20
- tooltip_id: "tooltip-without-interaction",
21
- position: 'top',
22
- }) do %>
23
- I'm just a regular tooltip
24
- <% end %>
25
- <% end %>
26
- <% end %>
@@ -1,69 +0,0 @@
1
- import React from 'react'
2
- import { Button, Tooltip, Flex, FlexItem } from 'playbook-ui';
3
-
4
- const TooltipSizing = (props) => {
5
-
6
- return (
7
- <Flex
8
- flexDirection='row'
9
- gap='md'
10
- wrap
11
- >
12
- <FlexItem>
13
- <Tooltip
14
- height='150px'
15
- placement='top'
16
- text="I'm 150px high and 100px wide!"
17
- width='100px'
18
- {...props}
19
- >
20
- <Button text="Height and Width"/>
21
- </Tooltip>
22
- </FlexItem>
23
- <FlexItem>
24
- <Tooltip
25
- maxHeight='100px'
26
- placement='top'
27
- text="I have a maxHeight of 100px! Lorem ipsum dolor sit amet consectetur adipisicing elit."
28
- width='250px'
29
- {...props}
30
- >
31
- <Button text="maxHeight"/>
32
- </Tooltip>
33
- </FlexItem>
34
- <FlexItem>
35
- <Tooltip
36
- maxWidth='150px'
37
- placement='top'
38
- text="I have a maxWidth of 150px! Lorem ipsum dolor sit amet consectetur adipisicing elit."
39
- {...props}
40
- >
41
- <Button text="maxWidth"/>
42
- </Tooltip>
43
- </FlexItem>
44
- <FlexItem>
45
- <Tooltip
46
- minWidth='300px'
47
- placement='top'
48
- text="I have a minWidth of 300px!"
49
- {...props}
50
- >
51
- <Button text="minWidth"/>
52
- </Tooltip>
53
- </FlexItem>
54
- <FlexItem>
55
- <Tooltip
56
- maxWidth='150px'
57
- minHeight='300px'
58
- placement='top'
59
- text="I have a minHeight of 300px!"
60
- {...props}
61
- >
62
- <Button text="minHeight"/>
63
- </Tooltip>
64
- </FlexItem>
65
- </Flex>
66
- )
67
- }
68
-
69
- export default TooltipSizing
@@ -1,3 +0,0 @@
1
- You can customize the `height` and `width` of the tooltip's popover.
2
-
3
- When using `maxHeight`, be sure to set a `width` as well. The text needs to truncate within the `width` prop.
@@ -1,282 +0,0 @@
1
- import PbEnhancedElement from '../pb_enhanced_element'
2
- import { computePosition, offset, flip, shift, arrow, autoUpdate } from '@floating-ui/dom'
3
-
4
- const TOOLTIP_OFFSET = 20
5
- const TOOLTIP_TIMEOUT = 250
6
- const SAFE_ZONE_MARGIN = 1
7
-
8
- export default class PbTooltipFloatingUi extends PbEnhancedElement {
9
- static get selector() {
10
- return '[data-pb-tooltip-kit="true"][data-pb-tooltip-delay-open], [data-pb-tooltip-kit="true"][data-pb-tooltip-delay-close], [data-pb-tooltip-kit="true"][data-pb-tooltip-interaction="true"]'
11
- }
12
-
13
- connect() {
14
- if (this.tooltipInteraction) {
15
- document.addEventListener('mousemove', (e) => {
16
- this.lastMouseX = e.clientX
17
- this.lastMouseY = e.clientY
18
- })
19
- }
20
-
21
- this.triggerElements.forEach((trigger) => {
22
- const method = this.triggerMethod
23
- const interactionEnabled = this.tooltipInteraction
24
-
25
- if (method === 'click') {
26
- trigger.addEventListener('click', () => {
27
- this.showTooltip(trigger)
28
- })
29
- } else {
30
- trigger.addEventListener('mouseenter', () => {
31
- clearSafeZoneListener(this)
32
- clearTimeout(this.mouseleaveTimeout)
33
- this.currentTrigger = trigger
34
- const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
35
- this.mouseenterTimeout = setTimeout(() => {
36
- this.showTooltip(trigger)
37
- if (interactionEnabled) {
38
- this.checkCloseTooltip(trigger)
39
- }
40
- }, delayOpen)
41
- })
42
-
43
- trigger.addEventListener('mouseleave', () => {
44
- clearTimeout(this.mouseenterTimeout)
45
- if (this.delayClose) {
46
- const delayClose = parseInt(this.delayClose)
47
- this.mouseleaveTimeout = setTimeout(() => {
48
- if (interactionEnabled) {
49
- this.attachSafeZoneListener()
50
- } else {
51
- this.hideTooltip()
52
- }
53
- }, delayClose)
54
- } else {
55
- if (interactionEnabled) {
56
- this.attachSafeZoneListener()
57
- } else {
58
- this.hideTooltip()
59
- }
60
- }
61
- })
62
-
63
- if (interactionEnabled) {
64
- this.tooltip.addEventListener('mouseenter', () => {
65
- clearSafeZoneListener(this)
66
- })
67
-
68
- this.tooltip.addEventListener('mouseleave', () => {
69
- this.attachSafeZoneListener()
70
- })
71
- }
72
- }
73
- })
74
- }
75
-
76
- attachSafeZoneListener() {
77
- clearSafeZoneListener(this)
78
- this.safeZoneHandler = (e) => {
79
- if (!this.currentTrigger) return
80
- const triggerRect = this.currentTrigger.getBoundingClientRect()
81
- const tooltipRect = this.tooltip.getBoundingClientRect()
82
- const safeRect = getSafeZone(triggerRect, tooltipRect, this.position, SAFE_ZONE_MARGIN)
83
- if (!isPointInsideRect(e.clientX, e.clientY, safeRect)) {
84
- this.hideTooltip()
85
- clearSafeZoneListener(this)
86
- }
87
- }
88
- document.addEventListener('mousemove', this.safeZoneHandler)
89
- }
90
-
91
- checkCloseTooltip(trigger) {
92
- document.querySelector('body').addEventListener('click', ({ target }) => {
93
- const isTooltip = target.closest(`#${this.tooltipId}`) === this.tooltip
94
- const isTrigger = target.closest(this.triggerElementSelector) === trigger
95
- if (isTrigger || isTooltip) {
96
- this.checkCloseTooltip(trigger)
97
- } else {
98
- this.hideTooltip()
99
- }
100
- }, { once: true })
101
- }
102
-
103
- showTooltip(trigger) {
104
- if (this.shouldShowTooltip === 'false') return
105
-
106
- clearSafeZoneListener(this)
107
-
108
- this.tooltip.style.opacity = '1'
109
- this.tooltip.style.visibility = 'visible'
110
- this.tooltip.style.pointerEvents = 'auto'
111
-
112
- if (this.cleanup) {
113
- this.cleanup()
114
- }
115
-
116
- const arrowElement = document.querySelector(`#${this.tooltipId}-arrow`)
117
-
118
- this.cleanup = autoUpdate(trigger, this.tooltip, () => {
119
- computePosition(trigger, this.tooltip, {
120
- placement: this.position,
121
- strategy: 'fixed',
122
- middleware: [
123
- offset({ mainAxis: TOOLTIP_OFFSET, crossAxis: 0 }),
124
- flip(),
125
- shift(),
126
- arrow({ element: arrowElement })
127
- ],
128
- }).then(({ x, y, placement, middlewareData }) => {
129
- Object.assign(this.tooltip.style, {
130
- left: `${x}px`,
131
- top: `${y}px`,
132
- position: 'fixed'
133
- })
134
- this.tooltip.setAttribute('data-popper-placement', placement)
135
- if (arrowElement && middlewareData.arrow) {
136
- const { x: arrowX, y: arrowY } = middlewareData.arrow
137
- Object.assign(arrowElement.style, {
138
- left: arrowX != null ? `${arrowX}px` : '',
139
- top: arrowY != null ? `${arrowY}px` : '',
140
- position: 'absolute'
141
- })
142
- }
143
- })
144
- })
145
-
146
- this.tooltip.classList.add('show')
147
-
148
- if (this.triggerMethod === 'click') {
149
- clearTimeout(this.autoHideTimeout)
150
- this.autoHideTimeout = setTimeout(() => {
151
- this.hideTooltip()
152
- }, 1000)
153
- }
154
- }
155
-
156
- hideTooltip() {
157
- if (!this.tooltip) return
158
-
159
- this.tooltip.classList.add('fade_out')
160
- setTimeout(() => {
161
- if (this.cleanup) {
162
- this.cleanup()
163
- this.cleanup = null
164
- }
165
- this.tooltip.classList.remove('show')
166
- this.tooltip.classList.remove('fade_out')
167
- this.tooltip.style.opacity = '0'
168
- this.tooltip.style.visibility = 'hidden'
169
- this.tooltip.style.pointerEvents = 'none'
170
- this.tooltip.style.position = ''
171
- this.tooltip.style.top = ''
172
- this.tooltip.style.left = ''
173
- this.tooltip.style.transform = ''
174
- }, TOOLTIP_TIMEOUT)
175
- }
176
-
177
- get triggerElements() {
178
- let triggerEl
179
- if (this.triggerElementId) {
180
- triggerEl = document.querySelector(`#${this.triggerElementId}`)
181
- } else if (this.triggerElementSelector) {
182
- const selectorIsId = this.triggerElementSelector.indexOf('#') > -1
183
- triggerEl = selectorIsId
184
- ? document.querySelector(this.triggerElementSelector)
185
- : document.querySelectorAll(this.triggerElementSelector)
186
- } else {
187
- triggerEl = this.element
188
- }
189
- if (!triggerEl) {
190
- console.error('Tooltip Kit: No valid trigger element found!')
191
- return []
192
- }
193
- if (triggerEl.length === undefined) {
194
- triggerEl = [triggerEl]
195
- }
196
- return triggerEl
197
- }
198
-
199
- get tooltip() {
200
- return (this._tooltip = this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
201
- }
202
-
203
- get position() {
204
- return this.element.dataset.pbTooltipPosition
205
- }
206
-
207
- get triggerElementId() {
208
- return this.element.dataset.pbTooltipTriggerElementId
209
- }
210
-
211
- get tooltipId() {
212
- return this.element.dataset.pbTooltipTooltipId
213
- }
214
-
215
- get triggerElementSelector() {
216
- return this.element.dataset.pbTooltipTriggerElementSelector
217
- }
218
-
219
- get shouldShowTooltip() {
220
- return this.element.dataset.pbTooltipShowTooltip
221
- }
222
-
223
- get triggerMethod() {
224
- return this.element.dataset.pbTooltipTriggerMethod || 'hover'
225
- }
226
-
227
- get tooltipInteraction() {
228
- return this.element.dataset.pbTooltipInteraction === 'true'
229
- }
230
-
231
- get delayOpen() {
232
- return this.element.dataset.pbTooltipDelayOpen
233
- }
234
-
235
- get delayClose() {
236
- return this.element.dataset.pbTooltipDelayClose
237
- }
238
- }
239
-
240
- function clearSafeZoneListener(context) {
241
- if (context.safeZoneHandler) {
242
- document.removeEventListener('mousemove', context.safeZoneHandler)
243
- context.safeZoneHandler = null
244
- }
245
- }
246
-
247
- function getSafeZone(triggerRect, tooltipRect, placement, margin) {
248
- let safeRect = {}
249
- if (placement.startsWith('top')) {
250
- safeRect.left = triggerRect.left - margin
251
- safeRect.right = triggerRect.right + margin
252
- safeRect.top = tooltipRect.bottom - margin
253
- safeRect.bottom = triggerRect.top + margin
254
- } else if (placement.startsWith('bottom')) {
255
- safeRect.left = triggerRect.left - margin
256
- safeRect.right = triggerRect.right + margin
257
- safeRect.top = triggerRect.bottom - margin
258
- safeRect.bottom = tooltipRect.top + margin
259
- } else if (placement.startsWith('left')) {
260
- safeRect.top = triggerRect.top - margin
261
- safeRect.bottom = triggerRect.bottom + margin
262
- safeRect.left = tooltipRect.right - margin
263
- safeRect.right = triggerRect.left + margin
264
- } else if (placement.startsWith('right')) {
265
- safeRect.top = triggerRect.top - margin
266
- safeRect.bottom = triggerRect.bottom + margin
267
- safeRect.left = triggerRect.right - margin
268
- safeRect.right = tooltipRect.left + margin
269
- } else {
270
- safeRect = {
271
- left: triggerRect.left - margin,
272
- right: triggerRect.right + margin,
273
- top: triggerRect.top - margin,
274
- bottom: triggerRect.bottom + margin,
275
- }
276
- }
277
- return safeRect
278
- }
279
-
280
- function isPointInsideRect(x, y, rect) {
281
- return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
282
- }
@@ -1,45 +0,0 @@
1
- <%= pb_rails("select", props: {
2
- id:"color_context_2",
3
- label: "Choose a Color",
4
- name: "color_name",
5
- options: [
6
- { value: "red", value_text: "Red" },
7
- { value: "blue", value_text: "Blue" },
8
- { value: "green", value_text: "Green" }
9
- ],
10
- }) %>
11
-
12
- <%= pb_rails("typeahead", props: {
13
- label: "Pick a Shade",
14
- is_multi: false,
15
- search_context_selector: "color_context_2",
16
- options_by_context: {
17
- "red": [
18
- { label: "Scarlet", value: "scarlet" },
19
- { label: "Mahogany", value: "mahogany" },
20
- { label: "Crimson", value: "crimson" }
21
- ],
22
- "blue": [
23
- { label: "Sky Blue", value: "sky" },
24
- { label: "Cerulean", value: "cerulean" },
25
- { label: "Navy", value: "navy" }
26
- ],
27
- "green": [
28
- { label: "Emerald", value: "emerald" },
29
- { label: "Mint", value: "mint" },
30
- { label: "Olive", value: "olive" }
31
- ]
32
- },
33
- id: "typeahead-dynamic-options",
34
- }) %>
35
-
36
-
37
- <%= javascript_tag defer: "defer" do %>
38
- document.addEventListener("pb-typeahead-kit-typeahead-dynamic-options-result-option-select", function(event) {
39
- console.log('Single Option selected')
40
- console.dir(event.detail)
41
- })
42
- document.addEventListener("pb-typeahead-kit-typeahead-dynamic-options-result-clear", function() {
43
- console.log('All options cleared')
44
- })
45
- <% end %>
@@ -1,5 +0,0 @@
1
- You can also set up a typeahead to render options dynamically based on input from a select. To achieve this:
2
- - The typeahead must have a unique `id`
3
- - Use the `search_context_selector` prop on the typeahead. The value here must match the id of the select so the Typeahead knows where to read the current "context" from.
4
- - Use `options_by_context` to pass in a hash whose keys match the possible values of your “context” select. Each key maps to an array of { label, value } objects. The typeahead automatically displays only the subset of options matching the current context.
5
- - Additionally, the optional `clear_on_context_change` prop controls whether the typeahead clears or not when a change happens in the linked select. This prop is set to true by default so that whenever a selection is made in the select, the Typeahead automatically clears its current input/selection.
@@ -1,33 +0,0 @@
1
- <%= pb_rails("select", props: {
2
- id:"color_context",
3
- label: "Choose a Color",
4
- name: "color_name_2",
5
- options: [
6
- { value: "red", value_text: "Red" },
7
- { value: "blue", value_text: "Blue" },
8
- { value: "green", value_text: "Green" }
9
- ],
10
- }) %>
11
-
12
- <%= pb_rails("typeahead", props: {
13
- label: "Pick a Shade",
14
- search_context_selector: "color_context",
15
- options_by_context: {
16
- "red": [
17
- { label: "Scarlet", value: "scarlet" },
18
- { label: "Mahogany", value: "mahogany" },
19
- { label: "Crimson", value: "crimson" }
20
- ],
21
- "blue": [
22
- { label: "Sky Blue", value: "sky" },
23
- { label: "Cerulean", value: "cerulean" },
24
- { label: "Navy", value: "navy" }
25
- ],
26
- "green": [
27
- { label: "Emerald", value: "emerald" },
28
- { label: "Mint", value: "mint" },
29
- { label: "Olive", value: "olive" }
30
- ]
31
- },
32
- search_term_minimum_length: 0,
33
- }) %>
@@ -1,3 +0,0 @@
1
- The dynamic rendering of options for the typeahead can also be achieved with a pure Rails implementation (not react rendered). For this implementation, use all the props as above with the following additions:
2
-
3
- - `search_term_minimum_length`: this sets the minimum input in the typeahead needed to display the dropdown. This is set to 3 by default. Set it to 0 for the dropdown to always display when the typeahead is interacted with.
@@ -1,99 +0,0 @@
1
- import { isEmpty, get, isString, uniqueId, omitBy } from './object';
2
-
3
- describe('Lodash functions', () => {
4
- describe('isEmpty', () => {
5
- test('returns true for empty objects', () => {
6
- expect(isEmpty({})).toBe(true);
7
- });
8
- test('returns true for empty arrays', () => {
9
- expect(isEmpty([])).toBe(true);
10
- });
11
- test('returns false for non-empty objects', () => {
12
- expect(isEmpty({ a: 1 })).toBe(false);
13
- });
14
- test('returns false for non-empty arrays', () => {
15
- expect(isEmpty([1])).toBe(false);
16
- });
17
- test('returns true for null and undefined', () => {
18
- expect(isEmpty(null)).toBe(true);
19
- expect(isEmpty(undefined)).toBe(true);
20
- });
21
- test('returns false for non-object, non-array values', () => {
22
- expect(isEmpty("hello")).toBe(false);
23
- expect(isEmpty(123)).toBe(false);
24
- });
25
- });
26
-
27
- describe('get', () => {
28
- const obj = { a: { b: { c: 42 } }, arr: [{ x: 1 }, { y: 2 }] };
29
-
30
- test('retrieves nested properties by dot path', () => {
31
- expect(get(obj, 'a.b.c')).toBe(42);
32
- });
33
- test('returns default value if path does not exist', () => {
34
- expect(get(obj, 'a.b.d', 'default')).toBe('default');
35
- });
36
- test('retrieves array values using bracket notation', () => {
37
- expect(get(obj, 'arr[1].y')).toBe(2);
38
- });
39
- test('returns default for non-existent paths', () => {
40
- expect(get(obj, 'non.existent.path', null)).toBe(null);
41
- });
42
- });
43
-
44
- describe('isString', () => {
45
- test('returns true for string literal', () => {
46
- expect(isString('test')).toBe(true);
47
- });
48
- test('returns true for String object', () => {
49
- expect(isString(new String('test'))).toBe(true);
50
- });
51
- test('returns false for non-string values', () => {
52
- expect(isString(123)).toBe(false);
53
- expect(isString(null)).toBe(false);
54
- expect(isString({ a: 1 })).toBe(false);
55
- expect(isString([ 'a','b','c' ])).toBe(false);
56
- });
57
- });
58
-
59
- describe('uniqueId', () => {
60
- test('generates unique ids without prefix', () => {
61
- const id1 = uniqueId();
62
- const id2 = uniqueId();
63
- expect(id1).not.toBe(id2);
64
- expect(Number(id1)).toBeLessThan(Number(id2));
65
- });
66
- test('generates unique ids with prefix', () => {
67
- const id1 = uniqueId('id_');
68
- const id2 = uniqueId('id_');
69
- const id3 = uniqueId('id_');
70
- expect(id1).not.toBe(id2);
71
- expect(id1).not.toBe(id3);
72
- expect(id2).not.toBe(id3);
73
- expect(id1.startsWith('id_')).toBe(true);
74
- expect(id2.startsWith('id_')).toBe(true);
75
- expect(id3.startsWith('id_')).toBe(true);
76
- });
77
- });
78
-
79
- describe('omitBy', () => {
80
- test('omits keys for which predicate returns true', () => {
81
- const obj = { a: 1, b: 2, c: 3 };
82
- const isEven = value => value % 2 === 0;
83
- const noEvenValues = omitBy(obj, isEven);
84
- expect(noEvenValues).toEqual({ a: 1, c: 3 });
85
- });
86
- test('returns empty object for null input', () => {
87
- expect(omitBy(null, () => true)).toEqual({});
88
- });
89
- test('returns empty object for non-object input', () => {
90
- expect(omitBy("string", () => true)).toEqual({});
91
- });
92
- test('returns original object if predicate returns false for all keys', () => {
93
- const obj = { a: 1, b: 2 };
94
- const isBiggerThanFive = value => value >= 4;
95
- const objWithSmallValues = omitBy(obj, isBiggerThanFive);
96
- expect(objWithSmallValues).toEqual(obj);
97
- });
98
- });
99
- });