playbook_ui 14.16.0 → 14.17.0.pre.alpha.PBNTR920emojipickerpoc7130
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 +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +104 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +168 -85
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +10 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +20 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.jsx +90 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +39 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +19 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +38 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +49 -37
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +39 -0
- data/app/pb_kits/playbook/pb_button/_button.scss +5 -5
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +14 -7
- data/app/pb_kits/playbook/pb_contact/contact.test.js +7 -7
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +34 -34
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +0 -11
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +0 -7
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_inline_styles.scss +28 -24
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +2 -2
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.test.js +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +58 -17
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +3 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +8 -8
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +3 -3
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +3 -4
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +2 -3
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +1 -1
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +22 -0
- data/app/pb_kits/playbook/pb_icon/icon.test.js +9 -9
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_icon_value/icon_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_label_value/label_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_layout/_layout.scss +58 -0
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +20 -7
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx +190 -0
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.md +5 -0
- data/app/pb_kits/playbook/pb_layout/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_layout/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_layout/layout.test.js +4 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx +90 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx +57 -0
- data/app/pb_kits/playbook/pb_lightbox/hooks/useVisibility.js +1 -1
- data/app/pb_kits/playbook/pb_link/link.test.jsx +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +2 -1
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +5 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +29 -11
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +4 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +2 -0
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.md +1 -0
- data/app/pb_kits/playbook/pb_stat_change/stat_change.test.js +8 -4
- data/app/pb_kits/playbook/pb_table/_table.tsx +4 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +50 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +59 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +76 -0
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +3 -3
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -0
- data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_picker.jsx +371 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +183 -56
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +2 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +4 -4
- data/app/pb_kits/playbook/pb_typeahead/index.ts +2 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
- data/app/pb_kits/playbook/pb_user/user.html.erb +1 -6
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +1 -6
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
- data/app/pb_kits/playbook/utilities/object.test.js +149 -1
- data/app/pb_kits/playbook/utilities/object.ts +124 -42
- data/dist/chunks/_typeahead-7W5Ha5Td.js +22 -0
- data/dist/chunks/_weekday_stacked-DSKatW3m.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/lib-BGzBzFZX.js +29 -0
- data/dist/chunks/{pb_form_validation-DMajaRt3.js → pb_form_validation-BvNy9Bd6.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/kit_base.rb +4 -4
- data/lib/playbook/version.rb +2 -2
- metadata +25 -10
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
- data/dist/chunks/_typeahead-BuTZG1Jn.js +0 -22
- data/dist/chunks/_weekday_stacked-oT22q75-.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- data/dist/chunks/lib-Co5y3V4K.js +0 -29
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.md → _advanced_table_selectable_rows_no_subrows_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.md → _advanced_table_selectable_rows_react.md} +0 -0
data/lib/playbook/kit_base.rb
CHANGED
@@ -91,11 +91,11 @@ module Playbook
|
|
91
91
|
# rubocop:disable Layout/CommentIndentation
|
92
92
|
# pb_content_tag information (potentially to be abstracted into its own dev doc in the future)
|
93
93
|
# The pb_content_tag generates HTML content tags for rails kits with flexible options.
|
94
|
-
# Modify a generated kit.html.erb file accordingly (the
|
94
|
+
# Modify a generated kit.html.erb file accordingly (the kit_base_default_options listed below no longer need to be explictly outlined in that file, only modifications).
|
95
95
|
# name - the first argument is for HTML tag. The default is :div.
|
96
96
|
# content_or_options_with_block - additional content or options for the tag (i.e., the customizations a dev adds to kit.html.erb).
|
97
97
|
# options - Within combined_options, the empty options hash allows for customizations to
|
98
|
-
# merge with the
|
98
|
+
# merge with the kit_base_default_options and combined_html_options.
|
99
99
|
# escape - set to true, this allows for HTML-escape.
|
100
100
|
# block - an optional block for content inside the tag.
|
101
101
|
# The return is a HTML tag that includes any provided customizations. If nothing is specified in kit.html.erb, the default shape is:
|
@@ -111,7 +111,7 @@ module Playbook
|
|
111
111
|
def pb_content_tag(name = :div, content_or_options_with_block = {}, options = {}, escape = true, &block)
|
112
112
|
combined_options = options
|
113
113
|
.merge(combined_html_options)
|
114
|
-
.merge(
|
114
|
+
.merge(kit_base_default_options.merge(content_or_options_with_block))
|
115
115
|
content_tag(name, combined_options, options, escape, &block)
|
116
116
|
end
|
117
117
|
# rubocop:enable Style/OptionalBooleanParameter
|
@@ -146,7 +146,7 @@ module Playbook
|
|
146
146
|
|
147
147
|
private
|
148
148
|
|
149
|
-
def
|
149
|
+
def kit_base_default_options
|
150
150
|
options = {
|
151
151
|
id: id,
|
152
152
|
data: data,
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.
|
4
|
+
version: 14.17.0.pre.alpha.PBNTR920emojipickerpoc7130
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -309,6 +309,8 @@ files:
|
|
309
309
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md
|
310
310
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx
|
311
311
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md
|
312
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.jsx
|
313
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.md
|
312
314
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx
|
313
315
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx
|
314
316
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md
|
@@ -326,14 +328,18 @@ files:
|
|
326
328
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb
|
327
329
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.jsx
|
328
330
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.md
|
331
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb
|
329
332
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.jsx
|
330
|
-
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.md
|
331
333
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx
|
332
334
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.md
|
333
335
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.jsx
|
334
336
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.md
|
337
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb
|
335
338
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.jsx
|
336
|
-
- app/pb_kits/playbook/pb_advanced_table/docs/
|
339
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md
|
340
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_react.md
|
341
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md
|
342
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_react.md
|
337
343
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx
|
338
344
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md
|
339
345
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx
|
@@ -1791,6 +1797,8 @@ files:
|
|
1791
1797
|
- app/pb_kits/playbook/pb_layout/body.html.erb
|
1792
1798
|
- app/pb_kits/playbook/pb_layout/body.rb
|
1793
1799
|
- app/pb_kits/playbook/pb_layout/docs/_description.md
|
1800
|
+
- app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx
|
1801
|
+
- app/pb_kits/playbook/pb_layout/docs/_layout_bracket.md
|
1794
1802
|
- app/pb_kits/playbook/pb_layout/docs/_layout_collection.html.erb
|
1795
1803
|
- app/pb_kits/playbook/pb_layout/docs/_layout_collection.jsx
|
1796
1804
|
- app/pb_kits/playbook/pb_layout/docs/_layout_collection.md
|
@@ -1824,6 +1832,8 @@ files:
|
|
1824
1832
|
- app/pb_kits/playbook/pb_layout/layout.test.js
|
1825
1833
|
- app/pb_kits/playbook/pb_layout/sidebar.html.erb
|
1826
1834
|
- app/pb_kits/playbook/pb_layout/sidebar.rb
|
1835
|
+
- app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx
|
1836
|
+
- app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx
|
1827
1837
|
- app/pb_kits/playbook/pb_legend/_legend.scss
|
1828
1838
|
- app/pb_kits/playbook/pb_legend/_legend.tsx
|
1829
1839
|
- app/pb_kits/playbook/pb_legend/docs/_description.md
|
@@ -2521,6 +2531,7 @@ files:
|
|
2521
2531
|
- app/pb_kits/playbook/pb_section_separator/docs/_section_separator_text_swift.md
|
2522
2532
|
- app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.html.erb
|
2523
2533
|
- app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.jsx
|
2534
|
+
- app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.md
|
2524
2535
|
- app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical_swift.md
|
2525
2536
|
- app/pb_kits/playbook/pb_section_separator/docs/example.yml
|
2526
2537
|
- app/pb_kits/playbook/pb_section_separator/docs/index.js
|
@@ -2856,6 +2867,10 @@ files:
|
|
2856
2867
|
- app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md
|
2857
2868
|
- app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.html.erb
|
2858
2869
|
- app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md
|
2870
|
+
- app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx
|
2871
|
+
- app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md
|
2872
|
+
- app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx
|
2873
|
+
- app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md
|
2859
2874
|
- app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb
|
2860
2875
|
- app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx
|
2861
2876
|
- app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md
|
@@ -2930,6 +2945,7 @@ files:
|
|
2930
2945
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_disabled.html.erb
|
2931
2946
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_disabled.jsx
|
2932
2947
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_disabled_swift.md
|
2948
|
+
- app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_picker.jsx
|
2933
2949
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_error.html.erb
|
2934
2950
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_error.jsx
|
2935
2951
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md
|
@@ -3187,7 +3203,6 @@ files:
|
|
3187
3203
|
- app/pb_kits/playbook/pb_tooltip/docs/_tooltip_with_icon_circle.html.erb
|
3188
3204
|
- app/pb_kits/playbook/pb_tooltip/docs/example.yml
|
3189
3205
|
- app/pb_kits/playbook/pb_tooltip/docs/index.js
|
3190
|
-
- app/pb_kits/playbook/pb_tooltip/floating_ui.js
|
3191
3206
|
- app/pb_kits/playbook/pb_tooltip/index.js
|
3192
3207
|
- app/pb_kits/playbook/pb_tooltip/tooltip.html.erb
|
3193
3208
|
- app/pb_kits/playbook/pb_tooltip/tooltip.rb
|
@@ -3453,11 +3468,11 @@ files:
|
|
3453
3468
|
- app/pb_kits/playbook/utilities/test/globalProps/truncate.test.js
|
3454
3469
|
- app/pb_kits/playbook/utilities/text.ts
|
3455
3470
|
- app/pb_kits/playbook/utilities/validEmojiChecker.ts
|
3456
|
-
- dist/chunks/_typeahead-
|
3457
|
-
- dist/chunks/_weekday_stacked-
|
3458
|
-
- dist/chunks/lazysizes-
|
3459
|
-
- dist/chunks/lib-
|
3460
|
-
- dist/chunks/pb_form_validation-
|
3471
|
+
- dist/chunks/_typeahead-7W5Ha5Td.js
|
3472
|
+
- dist/chunks/_weekday_stacked-DSKatW3m.js
|
3473
|
+
- dist/chunks/lazysizes-B7xYodB-.js
|
3474
|
+
- dist/chunks/lib-BGzBzFZX.js
|
3475
|
+
- dist/chunks/pb_form_validation-BvNy9Bd6.js
|
3461
3476
|
- dist/chunks/vendor.js
|
3462
3477
|
- dist/menu.yml
|
3463
3478
|
- dist/playbook-doc.js
|
@@ -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
|
-
}
|