@pega/cosmos-react-core 7.0.0-build.1.0 → 7.0.0-build.10.0
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.
- package/lib/components/AppShell/AppHeader.styles.js +2 -2
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +2 -2
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/style-utils.js +2 -2
- package/lib/components/AppShell/style-utils.js.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts.map +1 -1
- package/lib/components/Avatar/Avatar.js +2 -1
- package/lib/components/Avatar/Avatar.js.map +1 -1
- package/lib/components/Badges/Keyboard.d.ts.map +1 -1
- package/lib/components/Badges/Keyboard.js +9 -8
- package/lib/components/Badges/Keyboard.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +2 -1
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Button/Button.d.ts.map +1 -1
- package/lib/components/Button/Button.js +70 -10
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +3 -6
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +3 -5
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +2 -2
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Input/utils.d.ts +1 -0
- package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Input/utils.js +4 -0
- package/lib/components/DateTime/Input/utils.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +5 -4
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.js +2 -1
- package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +31 -6
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/utils.d.ts +4 -0
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +8 -0
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.d.ts +1 -0
- package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +2 -2
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/File/FileDisplay.d.ts +1 -1
- package/lib/components/File/FileDisplay.d.ts.map +1 -1
- package/lib/components/File/FileDisplay.js +2 -2
- package/lib/components/File/FileDisplay.js.map +1 -1
- package/lib/components/File/FileDisplayList.d.ts +8 -0
- package/lib/components/File/FileDisplayList.d.ts.map +1 -0
- package/lib/components/File/FileDisplayList.js +8 -0
- package/lib/components/File/FileDisplayList.js.map +1 -0
- package/lib/components/File/FileInput.d.ts +7 -2
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +44 -28
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileItem.d.ts +19 -7
- package/lib/components/File/FileItem.d.ts.map +1 -1
- package/lib/components/File/FileItem.js +107 -32
- package/lib/components/File/FileItem.js.map +1 -1
- package/lib/components/File/FileList.d.ts +14 -0
- package/lib/components/File/FileList.d.ts.map +1 -0
- package/lib/components/File/FileList.js +22 -0
- package/lib/components/File/FileList.js.map +1 -0
- package/lib/components/File/index.d.ts +4 -0
- package/lib/components/File/index.d.ts.map +1 -1
- package/lib/components/File/index.js +2 -0
- package/lib/components/File/index.js.map +1 -1
- package/lib/components/FormField/FormField.js +2 -2
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/HTML/HTML.js +2 -2
- package/lib/components/HTML/HTML.js.map +1 -1
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/Icon.js +1 -1
- package/lib/components/Icon/Icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-down.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-down.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-down.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-left.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-left.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-left.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-down.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-down.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-left.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-left.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-right.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-right.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-up.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-micro-up.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-right.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-right.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-right.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-up.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/arrow-up.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/arrow-up.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-down.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-down.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/caret-down.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-left.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-left.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/caret-left.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-right.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-right.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/caret-right.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-up.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/caret-up.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/caret-up.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/case-solid.icon.d.ts +1 -1
- package/lib/components/Icon/streamline-icons/case-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/case-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/case-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/clipboard-pencil-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/clipboard-pencil-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/clipboard-pencil-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/clock-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/clock-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/clock-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/disc-stack-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/disc-stack-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/disc-stack-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/drag.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/drag.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/information-solid.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/information-solid.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/information-solid.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/information-solid.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-down.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-down.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-down.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-down.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-left.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-left.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-left.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-left.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-right.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-right.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-right.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-right.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-up.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-up.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-up.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/micro-arrow-up.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/minus.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/minus.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/minus.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/open.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/open.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/open.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/plus.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/plus.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/plus.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/rule-library-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/rule-library-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/rule-library-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/search-analytics-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/search-analytics-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/search-analytics-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/times.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/times.icon.js +1 -1
- package/lib/components/Icon/streamline-icons/times.icon.js.map +1 -1
- package/lib/components/Icon/streamline-icons/warn-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/streamline-icons/warn-solid.icon.js +2 -2
- package/lib/components/Icon/streamline-icons/warn-solid.icon.js.map +1 -1
- package/lib/components/Icon/streamlineIconNames.d.ts +1 -1
- package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
- package/lib/components/Icon/streamlineIconNames.js +5 -0
- package/lib/components/Icon/streamlineIconNames.js.map +1 -1
- package/lib/components/Label/Label.js +2 -2
- package/lib/components/Label/Label.js.map +1 -1
- package/lib/components/Lightbox/Lightbox.d.ts.map +1 -1
- package/lib/components/Lightbox/Lightbox.js +8 -6
- package/lib/components/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/Link/Link.d.ts.map +1 -1
- package/lib/components/Link/Link.js +13 -6
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +1 -1
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.js +1 -4
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
- package/lib/components/Location/CurrentLocationButton.d.ts +12 -6
- package/lib/components/Location/CurrentLocationButton.d.ts.map +1 -1
- package/lib/components/Location/CurrentLocationButton.js +3 -1
- package/lib/components/Location/CurrentLocationButton.js.map +1 -1
- package/lib/components/Location/LocationInput.d.ts +5 -0
- package/lib/components/Location/LocationInput.d.ts.map +1 -1
- package/lib/components/Location/LocationInput.js +138 -39
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Location/LocationView.d.ts +1 -3
- package/lib/components/Location/LocationView.d.ts.map +1 -1
- package/lib/components/Location/LocationView.js +38 -21
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Location/index.d.ts +1 -0
- package/lib/components/Location/index.d.ts.map +1 -1
- package/lib/components/Location/index.js +1 -0
- package/lib/components/Location/index.js.map +1 -1
- package/lib/components/Location/types.d.ts +7 -0
- package/lib/components/Location/types.d.ts.map +1 -1
- package/lib/components/Location/types.js.map +1 -1
- package/lib/components/Location/utils.d.ts +28 -9
- package/lib/components/Location/utils.d.ts.map +1 -1
- package/lib/components/Location/utils.js +157 -1
- package/lib/components/Location/utils.js.map +1 -1
- package/lib/components/Menu/FlyoutMenuList.d.ts.map +1 -1
- package/lib/components/Menu/FlyoutMenuList.js +1 -1
- package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
- package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
- package/lib/components/Menu/Menu.styles.js +3 -3
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Modal/Modal.styles.d.ts.map +1 -1
- package/lib/components/Modal/Modal.styles.js +24 -3
- package/lib/components/Modal/Modal.styles.js.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/PageTemplates/CategorySubPage.styles.d.ts.map +1 -1
- package/lib/components/PageTemplates/CategorySubPage.styles.js +1 -2
- package/lib/components/PageTemplates/CategorySubPage.styles.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +1 -1
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.js +8 -3
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/Progress/Progress.styles.js +2 -2
- package/lib/components/Progress/Progress.styles.js.map +1 -1
- package/lib/components/RadioCheck/RadioCheck.js +2 -2
- package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
- package/lib/components/Switch/Switch.js +2 -2
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
- package/lib/hooks/useActiveDescendant.js +2 -2
- package/lib/hooks/useActiveDescendant.js.map +1 -1
- package/lib/hooks/useArrows.d.ts.map +1 -1
- package/lib/hooks/useArrows.js +3 -11
- package/lib/hooks/useArrows.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +8 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useScrollStick.d.ts +3 -3
- package/lib/hooks/useScrollStick.d.ts.map +1 -1
- package/lib/hooks/useScrollStick.js +6 -5
- package/lib/hooks/useScrollStick.js.map +1 -1
- package/lib/i18n/default.d.ts +8 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +10 -2
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +8 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/mixins.d.ts +2 -0
- package/lib/styles/mixins.d.ts.map +1 -0
- package/lib/styles/mixins.js +8 -0
- package/lib/styles/mixins.js.map +1 -0
- package/lib/styles/utils.d.ts +11 -5
- package/lib/styles/utils.d.ts.map +1 -1
- package/lib/styles/utils.js +28 -12
- package/lib/styles/utils.js.map +1 -1
- package/lib/utils/getFocusables.d.ts +1 -0
- package/lib/utils/getFocusables.d.ts.map +1 -1
- package/lib/utils/getFocusables.js +2 -1
- package/lib/utils/getFocusables.js.map +1 -1
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -2
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/lib/utils/sameOrigin.d.ts +0 -7
- package/lib/utils/sameOrigin.d.ts.map +0 -1
- package/lib/utils/sameOrigin.js +0 -25
- package/lib/utils/sameOrigin.js.map +0 -1
package/lib/hooks/useI18n.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
24
24
|
new: string;
|
|
25
25
|
info: string;
|
|
26
26
|
shortcuts: string;
|
|
27
|
+
label: string;
|
|
28
|
+
default_input: string;
|
|
29
|
+
default_input_value: string;
|
|
30
|
+
default_input_property: string;
|
|
27
31
|
remove: string;
|
|
28
32
|
follow: string;
|
|
29
33
|
unfollow: string;
|
|
@@ -236,10 +240,12 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
236
240
|
file_upload_text_one: string;
|
|
237
241
|
file_upload_text_multiple: string;
|
|
238
242
|
download_file: string;
|
|
243
|
+
preview_file: string;
|
|
239
244
|
open_file_in_new_tab: string;
|
|
240
245
|
my_current_location_button_a11y: string;
|
|
241
246
|
location_input_placeholder: string;
|
|
242
247
|
location_not_found_text: string;
|
|
248
|
+
exact_location: string;
|
|
243
249
|
allow_location_permissions_text: string;
|
|
244
250
|
advanced_search: string;
|
|
245
251
|
select_search_filter: string;
|
|
@@ -574,6 +580,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
574
580
|
call_panel_send_dtmf_menu_item: string;
|
|
575
581
|
call_panel_conference_call_menu_item: string;
|
|
576
582
|
call_panel_hangup_call_menu_item: string;
|
|
583
|
+
call_panel_disconnect_participant: string;
|
|
577
584
|
call_panel_contacts_add_to_favorites: string;
|
|
578
585
|
call_panel_contacts_remove_from_favorites: string;
|
|
579
586
|
call_panel_contacts_call_button_label: string;
|
|
@@ -655,6 +662,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
655
662
|
follow_up_tasks: string;
|
|
656
663
|
add_follow_up_task: string;
|
|
657
664
|
agents_utterance: string;
|
|
665
|
+
detected_entities: string;
|
|
658
666
|
due_on: string;
|
|
659
667
|
sentiment_positive: string;
|
|
660
668
|
sentiment_negative: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ScrollStickOptions {
|
|
2
|
-
elements: string | HTMLElement[]
|
|
2
|
+
elements: string | HTMLElement[] | Set<HTMLElement>;
|
|
3
3
|
scrollContainer?: Stickers['scrollContainer'];
|
|
4
4
|
offset?: number;
|
|
5
5
|
}
|
|
@@ -11,13 +11,13 @@ interface Sticker {
|
|
|
11
11
|
isStuck: boolean;
|
|
12
12
|
priorStickHeight: number;
|
|
13
13
|
}
|
|
14
|
-
type ElementsOption =
|
|
14
|
+
type ElementsOption = ScrollStickOptions['elements'];
|
|
15
15
|
declare class Stickers {
|
|
16
16
|
#private;
|
|
17
17
|
scrollContainer: HTMLElement | Window;
|
|
18
18
|
offset: number;
|
|
19
19
|
constructor({ elements, scrollContainer, offset }: ScrollStickOptions);
|
|
20
|
-
setStickers(elements: ElementsOption): Sticker
|
|
20
|
+
setStickers(elements: ElementsOption): Set<Sticker>;
|
|
21
21
|
addHandlers(): void;
|
|
22
22
|
rmHandlers(): void;
|
|
23
23
|
snapshotItemRects(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollStick.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollStick.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"useScrollStick.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollStick.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,OAAO;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,KAAK,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAMrD,cAAM,QAAQ;;IACZ,eAAe,EAAE,WAAW,GAAG,MAAM,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;gBAiBH,EAAE,QAAQ,EAAE,eAAwB,EAAE,MAAU,EAAE,EAAE,kBAAkB;IAgClF,WAAW,CAAC,QAAQ,EAAE,cAAc;IAkBpC,WAAW;IAUX,UAAU;IAMV,iBAAiB;IASjB,QAAQ;IAoDR,QAAQ;IAUR,UAAU;IAMV,iBAAiB;IASjB,oBAAoB;IAgBpB,gBAAgB,CAAC,OAAO,EAAE,OAAO;IAQjC,YAAY;IA0BZ,QAAQ,CAAC,OAAO,EAAE,OAAO;IASzB,WAAW,CAAC,OAAO,EAAE,OAAO;IAQ5B,WAAW,CAAC,OAAO,EAAE,OAAO;IAW5B,OAAO;CAIR;AAED;;;;GAIG;AACH,QAAA,MAAM,cAAc,aAAc,kBAAkB,KAAG,IAatD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -43,18 +43,19 @@ class Stickers {
|
|
|
43
43
|
this.#stickers = this.setStickers(elements);
|
|
44
44
|
this.snapshotItemRects();
|
|
45
45
|
this.addHandlers();
|
|
46
|
+
this.testForStick();
|
|
46
47
|
}
|
|
47
48
|
setStickers(elements) {
|
|
48
|
-
this.#stickers = (typeof elements === 'string'
|
|
49
|
-
?
|
|
50
|
-
: elements).map(element => ({
|
|
49
|
+
this.#stickers = new Set((typeof elements === 'string'
|
|
50
|
+
? [...document.querySelectorAll(elements)]
|
|
51
|
+
: [...elements]).map(element => ({
|
|
51
52
|
element,
|
|
52
53
|
isStuck: false,
|
|
53
54
|
top: NaN,
|
|
54
55
|
bottom: NaN,
|
|
55
56
|
height: NaN,
|
|
56
57
|
priorStickHeight: NaN
|
|
57
|
-
}));
|
|
58
|
+
})));
|
|
58
59
|
return this.#stickers;
|
|
59
60
|
}
|
|
60
61
|
addHandlers() {
|
|
@@ -222,7 +223,7 @@ const useScrollStick = (options) => {
|
|
|
222
223
|
instance.current?.cleanup();
|
|
223
224
|
instance.current = undefined;
|
|
224
225
|
};
|
|
225
|
-
}, [options]);
|
|
226
|
+
}, [options?.scrollContainer, options?.offset, ...(options?.elements ?? [])]);
|
|
226
227
|
};
|
|
227
228
|
export default useScrollStick;
|
|
228
229
|
//# sourceMappingURL=useScrollStick.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollStick.js","sourceRoot":"","sources":["../../src/hooks/useScrollStick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAmBhD,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,QAAQ;IACZ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C,GAAG,GAAG,EAAE,CAAC;QAC/B,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,OAAgB;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC7C,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAEzB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE;YAC3C,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;SAC7C;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,OAA4B,EAAQ,EAAE;IAC5D,MAAM,QAAQ,GAAG,MAAM,EAAY,CAAC;IAEpC,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,OAAO,EAAE,QAAQ,EAAE;YACrB,QAAQ,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;SAC1C;QAED,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAC5B,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useRef, useLayoutEffect } from 'react';\n\nexport interface ScrollStickOptions {\n elements: string | HTMLElement[];\n scrollContainer?: Stickers['scrollContainer'];\n offset?: number;\n}\n\ninterface Sticker {\n element: HTMLElement;\n top: number;\n bottom: number;\n height: number;\n isStuck: boolean;\n priorStickHeight: number;\n}\n\ntype ElementsOption = string | HTMLElement[];\n\nconst onBeforeunload = () => {\n window.scrollTo(0, 0);\n};\n\nclass Stickers {\n scrollContainer: HTMLElement | Window;\n offset: number;\n #scrollDebounce: number;\n #resizeDebounce: number;\n #isWindowScroll: boolean;\n #scrollIntervalStart: number;\n #scrollIntervalChange: number;\n #scrollDirection: number;\n #priorScrollY: number;\n #resizeTimeout: number;\n #scrollEndTimeout: number;\n #isScrolling: boolean;\n #vpHeightSnapshot: number;\n #sfHeightSnapshot: number;\n #stickers: Sticker[];\n #scrollHandler: () => void;\n #resizeHandler: () => void;\n\n constructor({ elements, scrollContainer = window, offset = 0 }: ScrollStickOptions) {\n this.scrollContainer = scrollContainer;\n this.offset = offset;\n\n this.#scrollDebounce = 100;\n this.#resizeDebounce = 300;\n this.#resizeTimeout = NaN;\n this.#scrollEndTimeout = NaN;\n this.#priorScrollY = NaN;\n this.#isScrolling = false;\n this.#vpHeightSnapshot = NaN;\n this.#sfHeightSnapshot = NaN;\n this.#scrollHandler = () => {};\n this.#resizeHandler = () => {};\n\n this.#isWindowScroll = this.scrollContainer === window;\n\n // Only gets reset after scroll stop timeout fires\n this.#scrollIntervalStart = this.getScrollY();\n\n // Used to determine scroll change within debounced scroll handler\n this.#scrollIntervalChange = 0;\n\n // Used to determine scroll direction by +1(page down) -1(page up)\n this.#scrollDirection = 0;\n\n this.#stickers = this.setStickers(elements);\n this.snapshotItemRects();\n this.addHandlers();\n }\n\n setStickers(elements: ElementsOption) {\n this.#stickers = (\n typeof elements === 'string'\n ? Array.from(document.querySelectorAll<HTMLElement>(elements))\n : elements\n ).map(element => ({\n element,\n isStuck: false,\n top: NaN,\n bottom: NaN,\n height: NaN,\n priorStickHeight: NaN\n }));\n\n return this.#stickers;\n }\n\n addHandlers() {\n this.rmHandlers();\n this.#scrollHandler = this.onScroll.bind(this);\n this.#resizeHandler = this.onResize.bind(this);\n this.scrollContainer.addEventListener('scroll', this.#scrollHandler);\n window.addEventListener('resize', this.#resizeHandler);\n // Not sure we need this. Maybe when DOM was persisted...\n window.addEventListener('beforeunload', onBeforeunload);\n }\n\n rmHandlers() {\n this.scrollContainer.removeEventListener('scroll', this.#scrollHandler);\n window.removeEventListener('resize', this.#resizeHandler);\n window.removeEventListener('beforeunload', onBeforeunload);\n }\n\n snapshotItemRects() {\n this.#stickers.forEach(sticker => {\n const rect = sticker.element.getBoundingClientRect();\n sticker.top = rect.top;\n sticker.bottom = rect.bottom;\n sticker.height = rect.height;\n });\n }\n\n onScroll() {\n clearTimeout(this.#scrollEndTimeout);\n\n const currentScrollY = this.getScrollY();\n\n this.#priorScrollY = !Number.isNaN(this.#priorScrollY)\n ? this.#priorScrollY\n : this.#scrollIntervalStart;\n\n // Diff between priorScrollY and new currentScrollY to determine direction\n this.#scrollDirection = currentScrollY - this.#priorScrollY > 0 ? 1 : -1;\n\n // How much scroll changed + or - within the debounce interval\n this.#scrollIntervalChange = currentScrollY - this.#scrollIntervalStart;\n\n // Update old to new for next scroll event\n this.#priorScrollY = currentScrollY;\n\n // When scrolling has stopped\n this.#scrollEndTimeout = window.setTimeout(() => {\n // Reset for next scroll starting point\n this.#scrollIntervalStart = this.#priorScrollY;\n\n // Reset until next scroll\n this.#vpHeightSnapshot = NaN;\n this.#sfHeightSnapshot = NaN;\n\n this.#isScrolling = false;\n }, this.#scrollDebounce);\n\n // Additional scroll calls always have to test for stick state change\n if (this.#isScrolling) {\n this.testForStick();\n return;\n }\n\n // Only reaches here on first call and we note as in a scrolling state\n this.#isScrolling = true;\n\n // grab the current rect points for stickers to test against while scrolling\n this.snapshotItemRects();\n\n /**\n * Get once and cache until scroll settles\n * Unlikely to change and avoids additional reflows on scroll\n */\n this.#vpHeightSnapshot = this.getViewportHeight();\n this.#sfHeightSnapshot = this.getScrollFrameHeight();\n\n this.testForStick();\n }\n\n onResize() {\n clearTimeout(this.#resizeTimeout);\n this.#resizeTimeout = window.setTimeout(() => {\n this.snapshotItemRects();\n this.#stickers.forEach(sticker => {\n if (sticker.isStuck) this.addStick(sticker);\n });\n }, this.#resizeDebounce);\n }\n\n getScrollY() {\n return this.#isWindowScroll\n ? (this.scrollContainer as Window).scrollY\n : (this.scrollContainer as HTMLElement).scrollTop;\n }\n\n getViewportHeight() {\n // If we have a height snapshot use it since this has likely been called on scroll\n if (!Number.isNaN(this.#vpHeightSnapshot)) {\n return this.#vpHeightSnapshot;\n }\n\n return Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n }\n\n getScrollFrameHeight() {\n // If we have a height snapshot use it since this has likely been called on scroll\n if (!Number.isNaN(this.#sfHeightSnapshot)) {\n return this.#sfHeightSnapshot;\n }\n\n const viewportHeight = this.getViewportHeight();\n let sfh = viewportHeight;\n\n if (!this.#isWindowScroll) {\n sfh = viewportHeight - (this.scrollContainer as HTMLElement).getBoundingClientRect().top;\n }\n\n return sfh;\n }\n\n testBottomInView(sticker: Sticker) {\n const vph = this.getViewportHeight();\n const sfh = this.getScrollFrameHeight();\n const sic = this.#scrollIntervalChange;\n\n return sfh + sic + (vph - sfh) >= sticker.bottom + this.offset;\n }\n\n testForStick() {\n // Don't do anything if scrolling up\n if (this.#scrollDirection === -1) return;\n\n this.#stickers.forEach(sticker => {\n const bottomIsInView = this.testBottomInView(sticker);\n const hasHeightChange =\n !Number.isNaN(sticker.priorStickHeight) && sticker.height !== sticker.priorStickHeight;\n\n if (bottomIsInView) {\n if (!sticker.isStuck || hasHeightChange) {\n window.requestAnimationFrame(() => this.addStick(sticker));\n }\n } else if (sticker.isStuck && hasHeightChange) {\n const marginTop = this.getScrollY() + sticker.top - this.offset;\n\n window.requestAnimationFrame(() => {\n this.removeStick(sticker);\n sticker.element.style.marginTop = `${marginTop}px`;\n });\n }\n });\n\n return this;\n }\n\n addStick(sticker: Sticker) {\n sticker.element.style.position = 'sticky';\n sticker.element.style.marginTop = '';\n sticker.element.style.top = `${this.getStickTop(sticker)}px`;\n sticker.priorStickHeight = sticker.height;\n sticker.isStuck = true;\n return this;\n }\n\n removeStick(sticker: Sticker) {\n sticker.element.style.position = '';\n sticker.element.style.marginTop = '';\n sticker.element.style.top = '';\n sticker.isStuck = false;\n return this;\n }\n\n getStickTop(sticker: Sticker) {\n const spHeight = this.getScrollFrameHeight();\n let offset = this.offset;\n\n if (sticker.height + this.offset > spHeight) {\n offset = spHeight - sticker.height - offset;\n }\n\n return offset;\n }\n\n cleanup() {\n this.rmHandlers();\n this.#stickers.forEach(this.removeStick);\n }\n}\n\n/**\n * @example useScrollStick({ elements: [myColumnElements] | '.my-columns', offset: 20 });\n * @param options An object to set the sticky elements, the scroll container and an stuck offset in pixels.\n * @returns void.\n */\nconst useScrollStick = (options?: ScrollStickOptions): void => {\n const instance = useRef<Stickers>();\n\n useLayoutEffect(() => {\n if (options?.elements) {\n instance.current = new Stickers(options);\n }\n\n return () => {\n instance.current?.cleanup();\n instance.current = undefined;\n };\n }, [options]);\n};\n\nexport default useScrollStick;\n"]}
|
|
1
|
+
{"version":3,"file":"useScrollStick.js","sourceRoot":"","sources":["../../src/hooks/useScrollStick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAmBhD,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,QAAQ;IACZ,eAAe,CAAuB;IACtC,MAAM,CAAS;IACf,eAAe,CAAS;IACxB,eAAe,CAAS;IACxB,eAAe,CAAU;IACzB,oBAAoB,CAAS;IAC7B,qBAAqB,CAAS;IAC9B,gBAAgB,CAAS;IACzB,aAAa,CAAS;IACtB,cAAc,CAAS;IACvB,iBAAiB,CAAS;IAC1B,YAAY,CAAU;IACtB,iBAAiB,CAAS;IAC1B,iBAAiB,CAAS;IAC1B,SAAS,CAAe;IACxB,cAAc,CAAa;IAC3B,cAAc,CAAa;IAE3B,YAAY,EAAE,QAAQ,EAAE,eAAe,GAAG,MAAM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AAE;YAC3C,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;SAC7C;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,OAA4B,EAAQ,EAAE;IAC5D,MAAM,QAAQ,GAAG,MAAM,EAAY,CAAC;IAEpC,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,OAAO,EAAE,QAAQ,EAAE;YACrB,QAAQ,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;SAC1C;QAED,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAC5B,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useRef, useLayoutEffect } from 'react';\n\nexport interface ScrollStickOptions {\n elements: string | HTMLElement[] | Set<HTMLElement>;\n scrollContainer?: Stickers['scrollContainer'];\n offset?: number;\n}\n\ninterface Sticker {\n element: HTMLElement;\n top: number;\n bottom: number;\n height: number;\n isStuck: boolean;\n priorStickHeight: number;\n}\n\ntype ElementsOption = ScrollStickOptions['elements'];\n\nconst onBeforeunload = () => {\n window.scrollTo(0, 0);\n};\n\nclass Stickers {\n scrollContainer: HTMLElement | Window;\n offset: number;\n #scrollDebounce: number;\n #resizeDebounce: number;\n #isWindowScroll: boolean;\n #scrollIntervalStart: number;\n #scrollIntervalChange: number;\n #scrollDirection: number;\n #priorScrollY: number;\n #resizeTimeout: number;\n #scrollEndTimeout: number;\n #isScrolling: boolean;\n #vpHeightSnapshot: number;\n #sfHeightSnapshot: number;\n #stickers: Set<Sticker>;\n #scrollHandler: () => void;\n #resizeHandler: () => void;\n\n constructor({ elements, scrollContainer = window, offset = 0 }: ScrollStickOptions) {\n this.scrollContainer = scrollContainer;\n this.offset = offset;\n\n this.#scrollDebounce = 100;\n this.#resizeDebounce = 300;\n this.#resizeTimeout = NaN;\n this.#scrollEndTimeout = NaN;\n this.#priorScrollY = NaN;\n this.#isScrolling = false;\n this.#vpHeightSnapshot = NaN;\n this.#sfHeightSnapshot = NaN;\n this.#scrollHandler = () => {};\n this.#resizeHandler = () => {};\n\n this.#isWindowScroll = this.scrollContainer === window;\n\n // Only gets reset after scroll stop timeout fires\n this.#scrollIntervalStart = this.getScrollY();\n\n // Used to determine scroll change within debounced scroll handler\n this.#scrollIntervalChange = 0;\n\n // Used to determine scroll direction by +1(page down) -1(page up)\n this.#scrollDirection = 0;\n\n this.#stickers = this.setStickers(elements);\n this.snapshotItemRects();\n this.addHandlers();\n this.testForStick();\n }\n\n setStickers(elements: ElementsOption) {\n this.#stickers = new Set(\n (typeof elements === 'string'\n ? [...document.querySelectorAll<HTMLElement>(elements)]\n : [...elements]\n ).map(element => ({\n element,\n isStuck: false,\n top: NaN,\n bottom: NaN,\n height: NaN,\n priorStickHeight: NaN\n }))\n );\n\n return this.#stickers;\n }\n\n addHandlers() {\n this.rmHandlers();\n this.#scrollHandler = this.onScroll.bind(this);\n this.#resizeHandler = this.onResize.bind(this);\n this.scrollContainer.addEventListener('scroll', this.#scrollHandler);\n window.addEventListener('resize', this.#resizeHandler);\n // Not sure we need this. Maybe when DOM was persisted...\n window.addEventListener('beforeunload', onBeforeunload);\n }\n\n rmHandlers() {\n this.scrollContainer.removeEventListener('scroll', this.#scrollHandler);\n window.removeEventListener('resize', this.#resizeHandler);\n window.removeEventListener('beforeunload', onBeforeunload);\n }\n\n snapshotItemRects() {\n this.#stickers.forEach(sticker => {\n const rect = sticker.element.getBoundingClientRect();\n sticker.top = rect.top;\n sticker.bottom = rect.bottom;\n sticker.height = rect.height;\n });\n }\n\n onScroll() {\n clearTimeout(this.#scrollEndTimeout);\n\n const currentScrollY = this.getScrollY();\n\n this.#priorScrollY = !Number.isNaN(this.#priorScrollY)\n ? this.#priorScrollY\n : this.#scrollIntervalStart;\n\n // Diff between priorScrollY and new currentScrollY to determine direction\n this.#scrollDirection = currentScrollY - this.#priorScrollY > 0 ? 1 : -1;\n\n // How much scroll changed + or - within the debounce interval\n this.#scrollIntervalChange = currentScrollY - this.#scrollIntervalStart;\n\n // Update old to new for next scroll event\n this.#priorScrollY = currentScrollY;\n\n // When scrolling has stopped\n this.#scrollEndTimeout = window.setTimeout(() => {\n // Reset for next scroll starting point\n this.#scrollIntervalStart = this.#priorScrollY;\n\n // Reset until next scroll\n this.#vpHeightSnapshot = NaN;\n this.#sfHeightSnapshot = NaN;\n\n this.#isScrolling = false;\n }, this.#scrollDebounce);\n\n // Additional scroll calls always have to test for stick state change\n if (this.#isScrolling) {\n this.testForStick();\n return;\n }\n\n // Only reaches here on first call and we note as in a scrolling state\n this.#isScrolling = true;\n\n // grab the current rect points for stickers to test against while scrolling\n this.snapshotItemRects();\n\n /**\n * Get once and cache until scroll settles\n * Unlikely to change and avoids additional reflows on scroll\n */\n this.#vpHeightSnapshot = this.getViewportHeight();\n this.#sfHeightSnapshot = this.getScrollFrameHeight();\n\n this.testForStick();\n }\n\n onResize() {\n clearTimeout(this.#resizeTimeout);\n this.#resizeTimeout = window.setTimeout(() => {\n this.snapshotItemRects();\n this.#stickers.forEach(sticker => {\n if (sticker.isStuck) this.addStick(sticker);\n });\n }, this.#resizeDebounce);\n }\n\n getScrollY() {\n return this.#isWindowScroll\n ? (this.scrollContainer as Window).scrollY\n : (this.scrollContainer as HTMLElement).scrollTop;\n }\n\n getViewportHeight() {\n // If we have a height snapshot use it since this has likely been called on scroll\n if (!Number.isNaN(this.#vpHeightSnapshot)) {\n return this.#vpHeightSnapshot;\n }\n\n return Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n }\n\n getScrollFrameHeight() {\n // If we have a height snapshot use it since this has likely been called on scroll\n if (!Number.isNaN(this.#sfHeightSnapshot)) {\n return this.#sfHeightSnapshot;\n }\n\n const viewportHeight = this.getViewportHeight();\n let sfh = viewportHeight;\n\n if (!this.#isWindowScroll) {\n sfh = viewportHeight - (this.scrollContainer as HTMLElement).getBoundingClientRect().top;\n }\n\n return sfh;\n }\n\n testBottomInView(sticker: Sticker) {\n const vph = this.getViewportHeight();\n const sfh = this.getScrollFrameHeight();\n const sic = this.#scrollIntervalChange;\n\n return sfh + sic + (vph - sfh) >= sticker.bottom + this.offset;\n }\n\n testForStick() {\n // Don't do anything if scrolling up\n if (this.#scrollDirection === -1) return;\n\n this.#stickers.forEach(sticker => {\n const bottomIsInView = this.testBottomInView(sticker);\n const hasHeightChange =\n !Number.isNaN(sticker.priorStickHeight) && sticker.height !== sticker.priorStickHeight;\n\n if (bottomIsInView) {\n if (!sticker.isStuck || hasHeightChange) {\n window.requestAnimationFrame(() => this.addStick(sticker));\n }\n } else if (sticker.isStuck && hasHeightChange) {\n const marginTop = this.getScrollY() + sticker.top - this.offset;\n\n window.requestAnimationFrame(() => {\n this.removeStick(sticker);\n sticker.element.style.marginTop = `${marginTop}px`;\n });\n }\n });\n\n return this;\n }\n\n addStick(sticker: Sticker) {\n sticker.element.style.position = 'sticky';\n sticker.element.style.marginTop = '';\n sticker.element.style.top = `${this.getStickTop(sticker)}px`;\n sticker.priorStickHeight = sticker.height;\n sticker.isStuck = true;\n return this;\n }\n\n removeStick(sticker: Sticker) {\n sticker.element.style.position = '';\n sticker.element.style.marginTop = '';\n sticker.element.style.top = '';\n sticker.isStuck = false;\n return this;\n }\n\n getStickTop(sticker: Sticker) {\n const spHeight = this.getScrollFrameHeight();\n let offset = this.offset;\n\n if (sticker.height + this.offset > spHeight) {\n offset = spHeight - sticker.height - offset;\n }\n\n return offset;\n }\n\n cleanup() {\n this.rmHandlers();\n this.#stickers.forEach(this.removeStick);\n }\n}\n\n/**\n * @example useScrollStick({ elements: [myColumnElements] | '.my-columns', offset: 20 });\n * @param options An object to set the sticky elements, the scroll container and an stuck offset in pixels.\n * @returns void.\n */\nconst useScrollStick = (options?: ScrollStickOptions): void => {\n const instance = useRef<Stickers>();\n\n useLayoutEffect(() => {\n if (options?.elements) {\n instance.current = new Stickers(options);\n }\n\n return () => {\n instance.current?.cleanup();\n instance.current = undefined;\n };\n }, [options?.scrollContainer, options?.offset, ...(options?.elements ?? [])]);\n};\n\nexport default useScrollStick;\n"]}
|
package/lib/i18n/default.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ declare const _default: {
|
|
|
20
20
|
new: string;
|
|
21
21
|
info: string;
|
|
22
22
|
shortcuts: string;
|
|
23
|
+
label: string;
|
|
24
|
+
default_input: string;
|
|
25
|
+
default_input_value: string;
|
|
26
|
+
default_input_property: string;
|
|
23
27
|
remove: string;
|
|
24
28
|
follow: string;
|
|
25
29
|
unfollow: string;
|
|
@@ -232,10 +236,12 @@ declare const _default: {
|
|
|
232
236
|
file_upload_text_one: string;
|
|
233
237
|
file_upload_text_multiple: string;
|
|
234
238
|
download_file: string;
|
|
239
|
+
preview_file: string;
|
|
235
240
|
open_file_in_new_tab: string;
|
|
236
241
|
my_current_location_button_a11y: string;
|
|
237
242
|
location_input_placeholder: string;
|
|
238
243
|
location_not_found_text: string;
|
|
244
|
+
exact_location: string;
|
|
239
245
|
allow_location_permissions_text: string;
|
|
240
246
|
advanced_search: string;
|
|
241
247
|
select_search_filter: string;
|
|
@@ -570,6 +576,7 @@ declare const _default: {
|
|
|
570
576
|
call_panel_send_dtmf_menu_item: string;
|
|
571
577
|
call_panel_conference_call_menu_item: string;
|
|
572
578
|
call_panel_hangup_call_menu_item: string;
|
|
579
|
+
call_panel_disconnect_participant: string;
|
|
573
580
|
call_panel_contacts_add_to_favorites: string;
|
|
574
581
|
call_panel_contacts_remove_from_favorites: string;
|
|
575
582
|
call_panel_contacts_call_button_label: string;
|
|
@@ -651,6 +658,7 @@ declare const _default: {
|
|
|
651
658
|
follow_up_tasks: string;
|
|
652
659
|
add_follow_up_task: string;
|
|
653
660
|
agents_utterance: string;
|
|
661
|
+
detected_entities: string;
|
|
654
662
|
due_on: string;
|
|
655
663
|
sentiment_positive: string;
|
|
656
664
|
sentiment_negative: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAsqCE"}
|
package/lib/i18n/default.js
CHANGED
|
@@ -24,6 +24,10 @@ export default {
|
|
|
24
24
|
new: 'New',
|
|
25
25
|
info: 'info',
|
|
26
26
|
shortcuts: 'Shortcuts',
|
|
27
|
+
label: 'Label',
|
|
28
|
+
default_input: 'Default input',
|
|
29
|
+
default_input_value: 'Default input value',
|
|
30
|
+
default_input_property: 'Default input property',
|
|
27
31
|
/* Verbs */
|
|
28
32
|
remove: 'Remove',
|
|
29
33
|
follow: 'Follow',
|
|
@@ -261,11 +265,13 @@ export default {
|
|
|
261
265
|
file_upload_text_one: 'choose a file',
|
|
262
266
|
file_upload_text_multiple: 'choose files',
|
|
263
267
|
download_file: 'Download {0}',
|
|
268
|
+
preview_file: 'Preview {0}',
|
|
264
269
|
open_file_in_new_tab: 'Open {0} in new tab',
|
|
265
270
|
/* core:Location */
|
|
266
271
|
my_current_location_button_a11y: 'Use my current location',
|
|
267
272
|
location_input_placeholder: 'Enter a location',
|
|
268
273
|
location_not_found_text: 'Location not found',
|
|
274
|
+
exact_location: 'Exact location',
|
|
269
275
|
allow_location_permissions_text: 'To get current location, allow location permissions for this app',
|
|
270
276
|
/* core:SearchInput */
|
|
271
277
|
advanced_search: 'Advanced search',
|
|
@@ -298,7 +304,7 @@ export default {
|
|
|
298
304
|
/* core:Tabs */
|
|
299
305
|
tab_error_tooltip: '{0} has errors',
|
|
300
306
|
/* core:LightBox */
|
|
301
|
-
non_previewable: "{0} file can't be previewed
|
|
307
|
+
non_previewable: "{0} file can't be previewed",
|
|
302
308
|
content_load_error: 'Error loading content',
|
|
303
309
|
/* work:Assignments */
|
|
304
310
|
assignments: 'Assignments',
|
|
@@ -424,7 +430,7 @@ export default {
|
|
|
424
430
|
rte_unindent: 'Unindent',
|
|
425
431
|
rte_table: 'Table',
|
|
426
432
|
rte_link: 'Link',
|
|
427
|
-
rte_image: '
|
|
433
|
+
rte_image: 'Insert image',
|
|
428
434
|
rte_invalid_html: 'Invalid HTML',
|
|
429
435
|
rte_insert_field: 'Insert field',
|
|
430
436
|
rte_invalid_url: 'Invalid URL',
|
|
@@ -628,6 +634,7 @@ export default {
|
|
|
628
634
|
call_panel_send_dtmf_menu_item: 'Send DTMF',
|
|
629
635
|
call_panel_conference_call_menu_item: 'Conference',
|
|
630
636
|
call_panel_hangup_call_menu_item: 'Hang up',
|
|
637
|
+
call_panel_disconnect_participant: 'Disconnect participant',
|
|
631
638
|
call_panel_contacts_add_to_favorites: 'Add to favorites',
|
|
632
639
|
call_panel_contacts_remove_from_favorites: 'Remove from favorites',
|
|
633
640
|
call_panel_contacts_call_button_label: 'Call',
|
|
@@ -711,6 +718,7 @@ export default {
|
|
|
711
718
|
follow_up_tasks: 'Follow-up tasks',
|
|
712
719
|
add_follow_up_task: 'Add follow-up task',
|
|
713
720
|
agents_utterance: "Agent's commitment in context",
|
|
721
|
+
detected_entities: 'Detected entities',
|
|
714
722
|
/* cs:FollowUpTask */
|
|
715
723
|
due_on: 'Due on {0}',
|
|
716
724
|
/* cs:Sentiment */
|