igniteui-webcomponents 7.3.1 → 7.4.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/CHANGELOG.md +72 -1
- package/animations/easings.d.ts +21 -31
- package/animations/easings.js +21 -34
- package/animations/easings.js.map +1 -1
- package/animations/player.d.ts +8 -16
- package/animations/player.js +5 -8
- package/animations/player.js.map +1 -1
- package/animations/view-transition.d.ts +10 -10
- package/animations/view-transition.js +26 -37
- package/animations/view-transition.js.map +1 -1
- package/components/avatar/themes/avatar.base.css.js +1 -1
- package/components/avatar/themes/avatar.base.css.js.map +1 -1
- package/components/badge/themes/badge.base.css.js +1 -1
- package/components/badge/themes/badge.base.css.js.map +1 -1
- package/components/banner/themes/banner.base.css.js +1 -1
- package/components/banner/themes/banner.base.css.js.map +1 -1
- package/components/banner/themes/shared/banner.indigo.css.js +1 -1
- package/components/banner/themes/shared/banner.indigo.css.js.map +1 -1
- package/components/breadcrumb/breadcrumb.d.ts +74 -0
- package/components/breadcrumb/breadcrumb.js +107 -0
- package/components/breadcrumb/breadcrumb.js.map +1 -0
- package/components/breadcrumb/breadcrumbs.d.ts +60 -0
- package/components/breadcrumb/breadcrumbs.js +50 -0
- package/components/breadcrumb/breadcrumbs.js.map +1 -0
- package/components/breadcrumb/themes/breadcrumb.base.css.d.ts +1 -0
- package/components/breadcrumb/themes/breadcrumb.base.css.js +3 -0
- package/components/breadcrumb/themes/breadcrumb.base.css.js.map +1 -0
- package/components/breadcrumb/themes/breadcrumbs.base.css.d.ts +1 -0
- package/components/breadcrumb/themes/breadcrumbs.base.css.js +3 -0
- package/components/breadcrumb/themes/breadcrumbs.base.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/themes.d.ts +2 -0
- package/components/breadcrumb/themes/themes.js +50 -0
- package/components/breadcrumb/themes/themes.js.map +1 -0
- package/components/button/button.d.ts +0 -2
- package/components/button/button.js.map +1 -1
- package/components/button-group/button-group.d.ts +42 -12
- package/components/button-group/button-group.js +82 -34
- package/components/button-group/button-group.js.map +1 -1
- package/components/button-group/toggle-button.d.ts +6 -1
- package/components/button-group/toggle-button.js +28 -2
- package/components/button-group/toggle-button.js.map +1 -1
- package/components/calendar/base.d.ts +7 -2
- package/components/calendar/base.js +10 -4
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +6 -3
- package/components/calendar/calendar.js +41 -14
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +5 -8
- package/components/calendar/days-view/days-view.js +7 -16
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/helpers.d.ts +13 -0
- package/components/calendar/helpers.js +15 -0
- package/components/calendar/helpers.js.map +1 -1
- package/components/calendar/themes/calendar.base.css.js +1 -1
- package/components/calendar/themes/calendar.base.css.js.map +1 -1
- package/components/calendar/themes/days-view.base.css.js +1 -1
- package/components/calendar/themes/days-view.base.css.js.map +1 -1
- package/components/calendar/themes/shared/bootstrap/calendar.bootstrap.css.js +1 -1
- package/components/calendar/themes/shared/bootstrap/calendar.bootstrap.css.js.map +1 -1
- package/components/calendar/themes/shared/bootstrap/days-view.bootstrap.css.js +1 -1
- package/components/calendar/themes/shared/bootstrap/days-view.bootstrap.css.js.map +1 -1
- package/components/calendar/themes/shared/fluent/days-view.fluent.css.js +1 -1
- package/components/calendar/themes/shared/fluent/days-view.fluent.css.js.map +1 -1
- package/components/calendar/themes/shared/indigo/calendar.indigo.css.js +1 -1
- package/components/calendar/themes/shared/indigo/calendar.indigo.css.js.map +1 -1
- package/components/calendar/themes/shared/indigo/days-view.indigo.css.js +1 -1
- package/components/calendar/themes/shared/indigo/days-view.indigo.css.js.map +1 -1
- package/components/calendar/themes/shared/material/days-view.material.css.js +1 -1
- package/components/calendar/themes/shared/material/days-view.material.css.js.map +1 -1
- package/components/calendar/themes/year-month-view.base.css.js +1 -1
- package/components/calendar/themes/year-month-view.base.css.js.map +1 -1
- package/components/card/themes/container.base.css.js +1 -1
- package/components/card/themes/container.base.css.js.map +1 -1
- package/components/carousel/carousel-indicator.js +1 -0
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.d.ts +1 -1
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.d.ts +3 -3
- package/components/carousel/carousel.js.map +1 -1
- package/components/carousel/themes/carousel.base.css.js +1 -1
- package/components/carousel/themes/carousel.base.css.js.map +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js.map +1 -1
- package/components/chat/chat-input.d.ts +1 -2
- package/components/chat/chat-input.js +1 -1
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-state.d.ts +8 -9
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +1 -3
- package/components/chat/chat.js +2 -2
- package/components/chat/chat.js.map +1 -1
- package/components/chat/message-attachments.d.ts +6 -15
- package/components/chat/message-attachments.js.map +1 -1
- package/components/chat/themes/chat.base.css.js +1 -1
- package/components/chat/themes/chat.base.css.js.map +1 -1
- package/components/chat/themes/message.base.css.js +1 -1
- package/components/chat/themes/message.base.css.js.map +1 -1
- package/components/chat/utils.d.ts +0 -1
- package/components/chat/utils.js +1 -1
- package/components/chat/utils.js.map +1 -1
- package/components/checkbox/checkbox-base.d.ts +1 -1
- package/components/checkbox/checkbox.js +1 -1
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/themes/checkbox.base.css.js +1 -1
- package/components/checkbox/themes/checkbox.base.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.fluent.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.fluent.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.indigo.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.indigo.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.material.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.material.css.js.map +1 -1
- package/components/checkbox/themes/switch.base.css.js +1 -1
- package/components/checkbox/themes/switch.base.css.js.map +1 -1
- package/components/chip/chip.d.ts +2 -2
- package/components/chip/chip.js.map +1 -1
- package/components/color-picker/color-picker.d.ts +35 -34
- package/components/color-picker/color-picker.js +9 -4
- package/components/color-picker/color-picker.js.map +1 -1
- package/components/color-picker/common.d.ts +0 -2
- package/components/color-picker/common.js +2 -2
- package/components/color-picker/common.js.map +1 -1
- package/components/color-picker/converters.js.map +1 -1
- package/components/color-picker/picker-canvas.js.map +1 -1
- package/components/color-picker/themes/color-picker.base.css.js +1 -1
- package/components/color-picker/themes/color-picker.base.css.js.map +1 -1
- package/components/combo/combo.d.ts +18 -20
- package/components/combo/combo.js +8 -2
- package/components/combo/combo.js.map +1 -1
- package/components/combo/controllers/data.d.ts +7 -10
- package/components/combo/controllers/data.js.map +1 -1
- package/components/combo/themes/combo-item.base.css.js +1 -1
- package/components/combo/themes/combo-item.base.css.js.map +1 -1
- package/components/combo/themes/combo.base.css.js +1 -1
- package/components/combo/themes/combo.base.css.js.map +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js.map +1 -1
- package/components/date-picker/date-picker.base.d.ts +33 -29
- package/components/date-picker/date-picker.base.js +15 -4
- package/components/date-picker/date-picker.base.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +1 -1
- package/components/date-picker/date-picker.js +5 -3
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-picker/themes/date-picker.base.css.js +1 -1
- package/components/date-picker/themes/date-picker.base.css.js.map +1 -1
- package/components/date-range-picker/date-range-input.d.ts +0 -2
- package/components/date-range-picker/date-range-input.js +0 -6
- package/components/date-range-picker/date-range-input.js.map +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +22 -31
- package/components/date-range-picker/date-range-picker.js +7 -7
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/i18n.d.ts +21 -0
- package/components/date-range-picker/i18n.js +10 -0
- package/components/date-range-picker/i18n.js.map +1 -0
- package/components/date-range-picker/predefined-ranges-area.base.css.js +1 -1
- package/components/date-range-picker/predefined-ranges-area.base.css.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.d.ts +3 -3
- package/components/date-range-picker/predefined-ranges-area.js +2 -5
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-range-picker/validators.d.ts +0 -4
- package/components/date-range-picker/validators.js +4 -4
- package/components/date-range-picker/validators.js.map +1 -1
- package/components/date-time-input/date-time-input.base.d.ts +39 -37
- package/components/date-time-input/date-time-input.base.js +6 -0
- package/components/date-time-input/date-time-input.base.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +1 -11
- package/components/date-time-input/date-time-input.js +0 -6
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/datetime-mask-parser.d.ts +0 -10
- package/components/date-time-input/datetime-mask-parser.js +1 -1
- package/components/date-time-input/datetime-mask-parser.js.map +1 -1
- package/components/dialog/dialog.js.map +1 -1
- package/components/divider/themes/divider.base.css.js +1 -1
- package/components/divider/themes/divider.base.css.js.map +1 -1
- package/components/dropdown/dropdown-group.d.ts +2 -10
- package/components/dropdown/dropdown-group.js +2 -27
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/dropdown/dropdown.d.ts +17 -23
- package/components/dropdown/dropdown.js +5 -17
- package/components/dropdown/dropdown.js.map +1 -1
- package/components/dropdown/themes/dropdown-item.base.css.js +1 -1
- package/components/dropdown/themes/dropdown-item.base.css.js.map +1 -1
- package/components/dropdown/themes/dropdown.base.css.js +1 -1
- package/components/dropdown/themes/dropdown.base.css.js.map +1 -1
- package/components/file-input/file-input.d.ts +2 -2
- package/components/file-input/file-input.js.map +1 -1
- package/components/file-input/themes/file-input.base.css.js +1 -1
- package/components/file-input/themes/file-input.base.css.js.map +1 -1
- package/components/file-input/themes/shared/file-input.bootstrap.css.js +1 -1
- package/components/file-input/themes/shared/file-input.bootstrap.css.js.map +1 -1
- package/components/icon/icon.d.ts +1 -1
- package/components/icon/icon.registry.d.ts +6 -6
- package/components/icon/icon.registry.js.map +1 -1
- package/components/input/input.d.ts +3 -3
- package/components/input/input.js.map +1 -1
- package/components/input/themes/shared/input.indigo.css.js +1 -1
- package/components/input/themes/shared/input.indigo.css.js.map +1 -1
- package/components/input/themes/shared/input.material.css.js +1 -1
- package/components/input/themes/shared/input.material.css.js.map +1 -1
- package/components/list/themes/item.base.css.js +1 -1
- package/components/list/themes/item.base.css.js.map +1 -1
- package/components/mask-input/mask-history.d.ts +22 -18
- package/components/mask-input/mask-history.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +1 -1
- package/components/mask-input/mask-parser.d.ts +11 -13
- package/components/mask-input/mask-parser.js.map +1 -1
- package/components/nav-drawer/themes/item.base.css.js +1 -1
- package/components/nav-drawer/themes/item.base.css.js.map +1 -1
- package/components/popover/popover.d.ts +45 -34
- package/components/popover/popover.js +54 -122
- package/components/popover/popover.js.map +1 -1
- package/components/popover/position/arrow.d.ts +19 -0
- package/components/popover/position/arrow.js +33 -0
- package/components/popover/position/arrow.js.map +1 -0
- package/components/popover/position/floating.d.ts +40 -0
- package/components/popover/position/floating.js +146 -0
- package/components/popover/position/floating.js.map +1 -0
- package/components/popover/position/native.d.ts +45 -0
- package/components/popover/position/native.js +158 -0
- package/components/popover/position/native.js.map +1 -0
- package/components/popover/position/strategy.d.ts +37 -0
- package/components/popover/position/strategy.js +21 -0
- package/components/popover/position/strategy.js.map +1 -0
- package/components/popover/position/types.d.ts +26 -0
- package/components/popover/position/types.js +15 -0
- package/components/popover/position/types.js.map +1 -0
- package/components/popover/themes/light/popover.base.css.js +1 -1
- package/components/popover/themes/light/popover.base.css.js.map +1 -1
- package/components/progress/circular-progress.d.ts +0 -5
- package/components/progress/circular-progress.js.map +1 -1
- package/components/progress/themes/linear/linear.progress.base.css.js +1 -1
- package/components/progress/themes/linear/linear.progress.base.css.js.map +1 -1
- package/components/progress/themes/linear/shared/linear.progress.bootstrap.css.d.ts +1 -0
- package/components/progress/themes/linear/shared/linear.progress.bootstrap.css.js +3 -0
- package/components/progress/themes/linear/shared/linear.progress.bootstrap.css.js.map +1 -0
- package/components/progress/themes/linear/themes.js +3 -2
- package/components/progress/themes/linear/themes.js.map +1 -1
- package/components/qr-code/qr-code.d.ts +29 -2
- package/components/qr-code/qr-code.js +56 -13
- package/components/qr-code/qr-code.js.map +1 -1
- package/components/qr-code/renderer/export.d.ts +28 -0
- package/components/qr-code/renderer/export.js +120 -0
- package/components/qr-code/renderer/export.js.map +1 -0
- package/components/qr-code/types.d.ts +26 -0
- package/components/qr-code/types.js.map +1 -1
- package/components/radio/radio.d.ts +4 -4
- package/components/radio/radio.js +17 -14
- package/components/radio/radio.js.map +1 -1
- package/components/radio/themes/radio.base.css.js +1 -1
- package/components/radio/themes/radio.base.css.js.map +1 -1
- package/components/radio/themes/shared/radio.bootstrap.css.js +1 -1
- package/components/radio/themes/shared/radio.bootstrap.css.js.map +1 -1
- package/components/radio/themes/shared/radio.indigo.css.js +1 -1
- package/components/radio/themes/shared/radio.indigo.css.js.map +1 -1
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating.d.ts +6 -6
- package/components/rating/rating.js.map +1 -1
- package/components/select/select-group.d.ts +5 -10
- package/components/select/select-group.js +10 -34
- package/components/select/select-group.js.map +1 -1
- package/components/select/select.d.ts +12 -20
- package/components/select/select.js +4 -14
- package/components/select/select.js.map +1 -1
- package/components/select/themes/select.base.css.js +1 -1
- package/components/select/themes/select.base.css.js.map +1 -1
- package/components/select/themes/shared/select.bootstrap.css.js +1 -1
- package/components/select/themes/shared/select.bootstrap.css.js.map +1 -1
- package/components/slider/themes/shared/slider.material.css.js +1 -1
- package/components/slider/themes/shared/slider.material.css.js.map +1 -1
- package/components/slider/themes/slider.base.css.js +1 -1
- package/components/slider/themes/slider.base.css.js.map +1 -1
- package/components/snackbar/themes/snackbar.base.css.js +1 -1
- package/components/snackbar/themes/snackbar.base.css.js.map +1 -1
- package/components/splitter/splitter.d.ts +6 -6
- package/components/splitter/splitter.js.map +1 -1
- package/components/splitter/themes/splitter.base.css.js +1 -1
- package/components/splitter/themes/splitter.base.css.js.map +1 -1
- package/components/stepper/themes/step/step.base.css.js +1 -1
- package/components/stepper/themes/step/step.base.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.bootstrap.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.bootstrap.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.fluent.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.fluent.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.indigo.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.indigo.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.material.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.material.css.js.map +1 -1
- package/components/tabs/themes/shared/tabs/tabs.fluent.css.js +1 -1
- package/components/tabs/themes/shared/tabs/tabs.fluent.css.js.map +1 -1
- package/components/tabs/themes/shared/tabs/tabs.indigo.css.js +1 -1
- package/components/tabs/themes/shared/tabs/tabs.indigo.css.js.map +1 -1
- package/components/tabs/themes/shared/tabs/tabs.material.css.js +1 -1
- package/components/tabs/themes/shared/tabs/tabs.material.css.js.map +1 -1
- package/components/tabs/themes/tab.base.css.js +1 -1
- package/components/tabs/themes/tab.base.css.js.map +1 -1
- package/components/textarea/textarea.d.ts +1 -1
- package/components/textarea/textarea.js.map +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.common.css.js +1 -1
- package/components/textarea/themes/shared/textarea.common.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
- package/components/tile-manager/themes/tile.base.css.js +1 -1
- package/components/tile-manager/themes/tile.base.css.js.map +1 -1
- package/components/tile-manager/tile-manager.d.ts +6 -7
- package/components/tile-manager/tile-manager.js.map +1 -1
- package/components/tile-manager/tile.d.ts +3 -3
- package/components/tile-manager/tile.js.map +1 -1
- package/components/toast/themes/toast.base.css.js +1 -1
- package/components/toast/themes/toast.base.css.js.map +1 -1
- package/components/toast/toast.d.ts +0 -2
- package/components/toast/toast.js.map +1 -1
- package/components/tooltip/controller.js.map +1 -1
- package/components/tooltip/service.js +4 -5
- package/components/tooltip/service.js.map +1 -1
- package/components/tooltip/themes/tooltip.base.css.js +1 -1
- package/components/tooltip/themes/tooltip.base.css.js.map +1 -1
- package/components/tooltip/tooltip.d.ts +34 -13
- package/components/tooltip/tooltip.js +8 -4
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/themes/item.base.css.js +1 -1
- package/components/tree/themes/item.base.css.js.map +1 -1
- package/components/tree/tree-item.d.ts +6 -6
- package/components/tree/tree-item.js.map +1 -1
- package/components/tree/tree.navigation.d.ts +5 -6
- package/components/tree/tree.navigation.js.map +1 -1
- package/components/tree/tree.selection.js.map +1 -1
- package/components/types.d.ts +1 -1
- package/components/types.js.map +1 -1
- package/components/validation-container/themes/validator.base.css.js +1 -1
- package/components/validation-container/themes/validator.base.css.js.map +1 -1
- package/components/validation-container/validation-container.d.ts +10 -12
- package/components/validation-container/validation-container.js +14 -17
- package/components/validation-container/validation-container.js.map +1 -1
- package/components/virtualization/engine.d.ts +5 -5
- package/components/virtualization/engine.js.map +1 -1
- package/components/virtualization/virtualization.d.ts +61 -63
- package/components/virtualization/virtualization.js +6 -5
- package/components/virtualization/virtualization.js.map +1 -1
- package/custom-elements.json +16769 -19698
- package/igniteui-webcomponents.css-data.json +2 -2
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internals/abort-handler.d.ts +13 -25
- package/internals/abort-handler.js +4 -6
- package/internals/abort-handler.js.map +1 -1
- package/internals/context.d.ts +13 -7
- package/internals/context.js +2 -1
- package/internals/context.js.map +1 -1
- package/internals/controllers/adopt-styles.d.ts +19 -20
- package/internals/controllers/adopt-styles.js +3 -8
- package/internals/controllers/adopt-styles.js.map +1 -1
- package/internals/controllers/aria-projection.d.ts +56 -55
- package/internals/controllers/aria-projection.js +14 -15
- package/internals/controllers/aria-projection.js.map +1 -1
- package/internals/controllers/async-consumer.js.map +1 -1
- package/internals/controllers/command.d.ts +15 -30
- package/internals/controllers/command.js +2 -7
- package/internals/controllers/command.js.map +1 -1
- package/internals/controllers/context-provider.d.ts +7 -13
- package/internals/controllers/context-provider.js.map +1 -1
- package/internals/controllers/focus-ring.d.ts +10 -30
- package/internals/controllers/focus-ring.js +6 -12
- package/internals/controllers/focus-ring.js.map +1 -1
- package/internals/controllers/fullscreen.d.ts +7 -23
- package/internals/controllers/fullscreen.js +3 -9
- package/internals/controllers/fullscreen.js.map +1 -1
- package/internals/controllers/gestures.d.ts +10 -29
- package/internals/controllers/gestures.js +1 -3
- package/internals/controllers/gestures.js.map +1 -1
- package/internals/controllers/group.d.ts +13 -30
- package/internals/controllers/group.js.map +1 -1
- package/internals/controllers/host-listeners.d.ts +28 -0
- package/internals/controllers/host-listeners.js +27 -0
- package/internals/controllers/host-listeners.js.map +1 -0
- package/internals/controllers/id-resolver.d.ts +8 -9
- package/internals/controllers/id-resolver.js +6 -14
- package/internals/controllers/id-resolver.js.map +1 -1
- package/internals/controllers/internals.d.ts +53 -104
- package/internals/controllers/internals.js +40 -13
- package/internals/controllers/internals.js.map +1 -1
- package/internals/controllers/key-bindings.d.ts +61 -158
- package/internals/controllers/key-bindings.js +68 -67
- package/internals/controllers/key-bindings.js.map +1 -1
- package/internals/controllers/keys.d.ts +32 -0
- package/internals/controllers/keys.js +20 -0
- package/internals/controllers/keys.js.map +1 -0
- package/internals/controllers/mutation-observer.d.ts +14 -37
- package/internals/controllers/mutation-observer.js +1 -1
- package/internals/controllers/mutation-observer.js.map +1 -1
- package/internals/controllers/resize-observer.d.ts +9 -19
- package/internals/controllers/resize-observer.js.map +1 -1
- package/internals/controllers/root-click.d.ts +11 -42
- package/internals/controllers/root-click.js +4 -6
- package/internals/controllers/root-click.js.map +1 -1
- package/internals/controllers/roving-focus.d.ts +16 -35
- package/internals/controllers/roving-focus.js.map +1 -1
- package/internals/controllers/slot.d.ts +25 -54
- package/internals/controllers/slot.js +6 -6
- package/internals/controllers/slot.js.map +1 -1
- package/internals/controllers/toggle.d.ts +44 -48
- package/internals/controllers/toggle.js.map +1 -1
- package/internals/date/compare.js.map +1 -1
- package/internals/date/converters.d.ts +10 -7
- package/internals/date/converters.js.map +1 -1
- package/internals/date/model.d.ts +9 -16
- package/internals/date/model.js +22 -25
- package/internals/date/model.js.map +1 -1
- package/internals/decorators/blazorAdditionalDependencies.d.ts +4 -2
- package/internals/decorators/blazorAdditionalDependencies.js.map +1 -1
- package/internals/decorators/blazorDeepImport.d.ts +1 -3
- package/internals/decorators/blazorDeepImport.js.map +1 -1
- package/internals/decorators/blazorInclude.d.ts +3 -2
- package/internals/decorators/blazorInclude.js.map +1 -1
- package/internals/decorators/blazorIndirectRender.d.ts +1 -3
- package/internals/decorators/blazorIndirectRender.js.map +1 -1
- package/internals/decorators/blazorSuppressComponent.d.ts +1 -3
- package/internals/decorators/blazorSuppressComponent.js.map +1 -1
- package/internals/decorators/coerced-property.d.ts +14 -20
- package/internals/decorators/coerced-property.js.map +1 -1
- package/internals/decorators/shadow-options.d.ts +2 -5
- package/internals/decorators/shadow-options.js.map +1 -1
- package/internals/definitions/defineAllComponents.js +6 -0
- package/internals/definitions/defineAllComponents.js.map +1 -1
- package/internals/directives/drag.d.ts +51 -81
- package/internals/directives/drag.js +27 -89
- package/internals/directives/drag.js.map +1 -1
- package/internals/directives/pointer-operation.d.ts +75 -0
- package/internals/directives/pointer-operation.js +92 -0
- package/internals/directives/pointer-operation.js.map +1 -0
- package/internals/directives/resize.d.ts +36 -64
- package/internals/directives/resize.js +18 -85
- package/internals/directives/resize.js.map +1 -1
- package/internals/i18n/EN/calendar.resources.d.ts +8 -2
- package/internals/i18n/EN/calendar.resources.js +2 -2
- package/internals/i18n/EN/calendar.resources.js.map +1 -1
- package/internals/i18n/EN/chat.resources.d.ts +8 -2
- package/internals/i18n/EN/chat.resources.js +3 -10
- package/internals/i18n/EN/chat.resources.js.map +1 -1
- package/internals/i18n/EN/date-picker.resources.d.ts +6 -4
- package/internals/i18n/EN/date-picker.resources.js +1 -7
- package/internals/i18n/EN/date-picker.resources.js.map +1 -1
- package/internals/i18n/EN/date-range-picker.resources.d.ts +9 -2
- package/internals/i18n/EN/date-range-picker.resources.js +2 -2
- package/internals/i18n/EN/date-range-picker.resources.js.map +1 -1
- package/internals/i18n/i18n-controller.d.ts +44 -46
- package/internals/i18n/i18n-controller.js +46 -33
- package/internals/i18n/i18n-controller.js.map +1 -1
- package/internals/i18n/utils.d.ts +9 -4
- package/internals/i18n/utils.js +4 -27
- package/internals/i18n/utils.js.map +1 -1
- package/internals/mixins/alert.d.ts +10 -25
- package/internals/mixins/alert.js.map +1 -1
- package/internals/mixins/combo-box.d.ts +21 -11
- package/internals/mixins/combo-box.js +16 -22
- package/internals/mixins/combo-box.js.map +1 -1
- package/internals/mixins/event-emitter.js +9 -11
- package/internals/mixins/event-emitter.js.map +1 -1
- package/internals/mixins/forms/associated-required.d.ts +4 -4
- package/internals/mixins/forms/associated-required.js.map +1 -1
- package/internals/mixins/forms/associated.d.ts +4 -2
- package/internals/mixins/forms/associated.js +8 -19
- package/internals/mixins/forms/associated.js.map +1 -1
- package/internals/mixins/forms/form-transformers.js.map +1 -1
- package/internals/mixins/forms/types.d.ts +24 -80
- package/internals/mixins/forms/types.js.map +1 -1
- package/internals/mixins/group.d.ts +18 -0
- package/internals/mixins/group.js +37 -0
- package/internals/mixins/group.js.map +1 -0
- package/internals/mixins/i18n.d.ts +10 -16
- package/internals/mixins/i18n.js.map +1 -1
- package/internals/mixins/mask-behavior.d.ts +8 -22
- package/internals/mixins/mask-behavior.js +1 -2
- package/internals/mixins/mask-behavior.js.map +1 -1
- package/internals/mixins/option.d.ts +1 -2
- package/internals/mixins/option.js +2 -1
- package/internals/mixins/option.js.map +1 -1
- package/internals/part-map.d.ts +4 -2
- package/internals/part-map.js +1 -1
- package/internals/part-map.js.map +1 -1
- package/internals/templates/input-shell.d.ts +8 -17
- package/internals/templates/input-shell.js +4 -1
- package/internals/templates/input-shell.js.map +1 -1
- package/internals/templates/masked-input.d.ts +7 -8
- package/internals/templates/masked-input.js.map +1 -1
- package/internals/templates/slotted-icon.d.ts +7 -12
- package/internals/templates/slotted-icon.js.map +1 -1
- package/internals/templates/toggle-shell.d.ts +6 -7
- package/internals/templates/toggle-shell.js.map +1 -1
- package/internals/timing.d.ts +5 -14
- package/internals/timing.js.map +1 -1
- package/internals/utils/arrays.d.ts +21 -21
- package/internals/utils/arrays.js +14 -0
- package/internals/utils/arrays.js.map +1 -1
- package/internals/utils/dom.d.ts +51 -39
- package/internals/utils/dom.js +1 -2
- package/internals/utils/dom.js.map +1 -1
- package/internals/utils/events.d.ts +29 -16
- package/internals/utils/events.js +9 -1
- package/internals/utils/events.js.map +1 -1
- package/internals/utils/lit.d.ts +5 -2
- package/internals/utils/lit.js.map +1 -1
- package/internals/utils/math.d.ts +8 -6
- package/internals/utils/math.js.map +1 -1
- package/internals/utils/objects.d.ts +3 -20
- package/internals/utils/objects.js +1 -39
- package/internals/utils/objects.js.map +1 -1
- package/internals/utils/strings.d.ts +9 -11
- package/internals/utils/strings.js.map +1 -1
- package/internals/utils/types.d.ts +16 -3
- package/internals/utils/types.js +3 -0
- package/internals/utils/types.js.map +1 -1
- package/internals/validators.d.ts +9 -8
- package/internals/validators.js +12 -6
- package/internals/validators.js.map +1 -1
- package/package.json +1 -1
- package/skills/README.md +3 -0
- package/skills/igniteui-wc-figma-to-app/SKILL.md +907 -0
- package/skills/igniteui-wc-figma-to-app/references/asset-extraction.md +363 -0
- package/skills/igniteui-wc-figma-to-app/references/design-token-bridge.md +407 -0
- package/skills/igniteui-wc-figma-to-app/references/figma-component-map.md +325 -0
- package/skills/igniteui-wc-figma-to-app/references/mcp-setup.md +409 -0
- package/skills/igniteui-wc-figma-to-app/references/validation-patterns.md +376 -0
- package/skills/igniteui-wc-generate-from-image-design/references/gotchas.md +21 -0
- package/skills/igniteui-wc-integrate-with-framework/SKILL.md +4 -3
- package/skills/igniteui-wc-integrate-with-framework/references/vanilla-js.md +14 -0
- package/skills/igniteui-wc-migrate-grid-lite-to-premium/SKILL.md +12 -2
- package/theming/config.d.ts +14 -5
- package/theming/config.js +38 -18
- package/theming/config.js.map +1 -1
- package/theming/context.d.ts +1 -23
- package/theming/context.js.map +1 -1
- package/theming/theming-controller.d.ts +2 -32
- package/theming/theming-controller.js +15 -21
- package/theming/theming-controller.js.map +1 -1
- package/theming/theming-event.d.ts +0 -7
- package/theming/theming-event.js +0 -13
- package/theming/theming-event.js.map +1 -1
- package/theming/types.d.ts +1 -8
- package/theming/types.js.map +1 -1
- package/web-types.json +3 -3
- package/animations/presets/slide/index.d.ts +0 -3
- package/animations/presets/slide/index.js +0 -16
- package/animations/presets/slide/index.js.map +0 -1
- package/internals/controllers/root-scroll.d.ts +0 -31
- package/internals/controllers/root-scroll.js +0 -71
- package/internals/controllers/root-scroll.js.map +0 -1
- package/theming/utils.d.ts +0 -11
- package/theming/utils.js +0 -20
- package/theming/utils.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type PartInfo } from 'lit/async-directive.js';
|
|
2
|
+
import { PointerOperationDirective, type PointerOperationOptions, type PointerOperationState } from './pointer-operation.js';
|
|
3
3
|
export type DragPointerDirection = 'start' | 'end' | 'top' | 'bottom';
|
|
4
|
-
export type DragGhostFactory = (initial: DOMRect) => HTMLElement;
|
|
5
4
|
export type DragCallback = (params: DragCallbackParams) => unknown;
|
|
6
5
|
export type DragCancelCallback = (state: DragState) => unknown;
|
|
7
6
|
type Point = {
|
|
@@ -9,15 +8,16 @@ type Point = {
|
|
|
9
8
|
y: number;
|
|
10
9
|
};
|
|
11
10
|
export type DragState = {
|
|
12
|
-
/** The bounding rectangle of the
|
|
11
|
+
/** The bounding rectangle of the target at the start of the operation. */
|
|
13
12
|
initial: DOMRect;
|
|
14
|
-
/** The current bounding rectangle of the drag target. */
|
|
15
13
|
current: DOMRect;
|
|
16
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The position of the moved element: relative to the layer in deferred
|
|
16
|
+
* mode, and to the initial rectangle of the target in immediate mode.
|
|
17
|
+
*/
|
|
17
18
|
position: Point;
|
|
18
|
-
/**
|
|
19
|
+
/** The distance from the target origin to the pointer at the start. */
|
|
19
20
|
offset: Point;
|
|
20
|
-
/** Pointer positions and movement direction for the current operation. */
|
|
21
21
|
pointerState: {
|
|
22
22
|
previous: Point;
|
|
23
23
|
current: Point;
|
|
@@ -25,93 +25,71 @@ export type DragState = {
|
|
|
25
25
|
};
|
|
26
26
|
/** The ghost element when in deferred mode. */
|
|
27
27
|
ghost: HTMLElement | null;
|
|
28
|
-
/** The
|
|
28
|
+
/** The element that the `matchTarget` callback matches, or `null`. */
|
|
29
29
|
element: Element | null;
|
|
30
30
|
};
|
|
31
31
|
export type DragCallbackParams = {
|
|
32
32
|
event: PointerEvent;
|
|
33
33
|
state: DragState;
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* In `immediate` mode the target element is moved in place as the pointer moves.
|
|
43
|
-
* In `deferred` mode a ghost element is created and moved instead, keeping the
|
|
44
|
-
* target element at its place until the operation completes.
|
|
45
|
-
*
|
|
46
|
-
* Defaults to `deferred`.
|
|
47
|
-
*/
|
|
48
|
-
mode?: DragMode;
|
|
49
|
-
/** Whether the dragged element's top left corner snaps to the cursor position at the start of the operation. */
|
|
35
|
+
/**
|
|
36
|
+
* Options for the draggable directive. See {@link PointerOperationOptions}
|
|
37
|
+
* for the shared ones. The mode defaults to `deferred`, which moves a ghost
|
|
38
|
+
* element and leaves the target in place.
|
|
39
|
+
*/
|
|
40
|
+
export interface DraggableOptions extends PointerOperationOptions {
|
|
41
|
+
/** Whether the dragged element snaps its top left corner to the pointer. */
|
|
50
42
|
snapToCursor?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* The element being dragged. It captures the pointer events for the operation.
|
|
53
|
-
* Defaults to the element the directive is applied to.
|
|
54
|
-
*
|
|
55
|
-
* Accepts either an element or a function returning one, resolved when
|
|
56
|
-
* the directive options are applied.
|
|
57
|
-
*/
|
|
58
|
-
target?: HTMLElement | (() => HTMLElement | null | undefined);
|
|
59
|
-
/**
|
|
60
|
-
* When provided, a drag operation only starts if the returned element is in the
|
|
61
|
-
* composed path of the initiating pointer event.
|
|
62
|
-
*/
|
|
43
|
+
/** Returns the element whose presence in the event path starts a drag. */
|
|
63
44
|
trigger?: () => HTMLElement | null | undefined;
|
|
64
|
-
/**
|
|
45
|
+
/** Runs with the initiating pointer event. A `true` return skips the drag. */
|
|
65
46
|
skip?: (event: PointerEvent) => boolean;
|
|
66
47
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `enter`, `leave` and `over` callbacks.
|
|
48
|
+
* A predicate for the elements under the pointer. The first match becomes
|
|
49
|
+
* `state.element`, and drives `enter`, `leave` and `over`.
|
|
70
50
|
*/
|
|
71
51
|
matchTarget?: (element: Element) => boolean;
|
|
72
|
-
/**
|
|
73
|
-
ghostFactory?: DragGhostFactory;
|
|
74
|
-
/** The container in which the deferred ghost element is rendered. Defaults to the document body. */
|
|
75
|
-
layer?: () => HTMLElement;
|
|
76
|
-
/** Called when a drag operation starts. Return `false` to abort the operation. */
|
|
52
|
+
/** Runs when a drag starts. A `false` return aborts the operation. */
|
|
77
53
|
start?: DragCallback;
|
|
78
|
-
/**
|
|
54
|
+
/** Runs on each pointer move of a drag operation. */
|
|
79
55
|
move?: DragCallback;
|
|
80
|
-
/**
|
|
56
|
+
/** Runs when the pointer enters a matched element. */
|
|
81
57
|
enter?: DragCallback;
|
|
82
|
-
/**
|
|
58
|
+
/** Runs when the pointer leaves the matched element. */
|
|
83
59
|
leave?: DragCallback;
|
|
84
|
-
/**
|
|
60
|
+
/** Runs while the pointer moves over the matched element. */
|
|
85
61
|
over?: DragCallback;
|
|
86
|
-
/**
|
|
62
|
+
/** Runs when a drag operation completes. */
|
|
87
63
|
end?: DragCallback;
|
|
88
|
-
/**
|
|
64
|
+
/** Runs when the Escape key cancels a drag operation. */
|
|
89
65
|
cancel?: DragCancelCallback;
|
|
90
66
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
type DragOperation = PointerOperationState & {
|
|
68
|
+
target: HTMLElement;
|
|
69
|
+
initial: DOMRect;
|
|
70
|
+
current: DOMRect;
|
|
71
|
+
position: Point;
|
|
72
|
+
offset: Point;
|
|
73
|
+
pointerState: DragState['pointerState'];
|
|
74
|
+
matchedElement: Element | null;
|
|
75
|
+
/** The inline transform of the target, restored on an immediate cancel. */
|
|
76
|
+
targetTransform: string;
|
|
77
|
+
};
|
|
78
|
+
declare class DraggableDirective extends PointerOperationDirective<DraggableOptions, DragOperation> {
|
|
96
79
|
private _target;
|
|
97
|
-
private _operation;
|
|
98
80
|
constructor(partInfo: PartInfo);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
protected _cancelOperation(): void;
|
|
82
|
+
/** Restores the styles that the operation changed, then disposes. */
|
|
83
|
+
protected _dispose(): void;
|
|
84
|
+
protected disconnected(): void;
|
|
85
|
+
/** The ghost element in deferred mode, the drag target in immediate mode. */
|
|
102
86
|
private get _dragItem();
|
|
103
87
|
private readonly _handlePointerDown;
|
|
104
88
|
private readonly _handlePointerMove;
|
|
105
89
|
private readonly _handlePointerEnd;
|
|
106
|
-
|
|
107
|
-
/** Prevents native drag and touch interactions from interfering with an enabled directive. */
|
|
108
|
-
private readonly _preventNativeBehavior;
|
|
109
|
-
private _attachTriggerListeners;
|
|
90
|
+
protected _attachTriggerListeners(): void;
|
|
110
91
|
private _startOperation;
|
|
111
|
-
private _resolveTarget;
|
|
112
|
-
private _resolveLayer;
|
|
113
92
|
private _shouldSkip;
|
|
114
|
-
private _createGhost;
|
|
115
93
|
private _createState;
|
|
116
94
|
private _createParams;
|
|
117
95
|
private _updatePosition;
|
|
@@ -119,26 +97,18 @@ declare class DraggableDirective extends AsyncDirective {
|
|
|
119
97
|
private _updateMatcher;
|
|
120
98
|
private _assignPosition;
|
|
121
99
|
/**
|
|
122
|
-
* Toggles touch action
|
|
100
|
+
* Toggles the touch action and the text selection for a drag operation.
|
|
123
101
|
*
|
|
124
102
|
* @remarks
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* the
|
|
128
|
-
* across the page for the active drag and is reverted once the operation completes.
|
|
103
|
+
* The `user-select` style on the dragged element is not enough. Browsers,
|
|
104
|
+
* Safari in particular, still select text in the elements under the
|
|
105
|
+
* pointer, so the style also goes on the body of the owner document.
|
|
129
106
|
*/
|
|
130
107
|
private _setDragStyles;
|
|
131
|
-
/** Stops the current drag operation, cleaning up the ghost element and event listeners. */
|
|
132
|
-
private _dispose;
|
|
133
|
-
protected reconnected(): void;
|
|
134
|
-
protected disconnected(): void;
|
|
135
|
-
update(part: ElementPart, [options]: DirectiveParameters<this>): symbol;
|
|
136
|
-
render(_options?: DraggableOptions): symbol;
|
|
137
108
|
}
|
|
138
109
|
/**
|
|
139
|
-
* A directive that makes an element draggable,
|
|
140
|
-
*
|
|
141
|
-
* while dragging.
|
|
110
|
+
* A directive that makes an element draggable, in place or through a
|
|
111
|
+
* deferred ghost element, with an optional hit test of other elements.
|
|
142
112
|
*/
|
|
143
113
|
export declare const draggable: (_options?: DraggableOptions | undefined) => import("lit-html/directive.js").DirectiveResult<typeof DraggableDirective>;
|
|
144
114
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getDefaultLayer, getRoot, isLTR, roundByDPR, setStyles, } from '../utils/dom.js';
|
|
6
|
-
import { getElementFromPath, preventDefault } from '../utils/events.js';
|
|
1
|
+
import { directive } from 'lit/async-directive.js';
|
|
2
|
+
import { getRoot, isLTR, roundByDPR, setStyles } from '../utils/dom.js';
|
|
3
|
+
import { getElementFromPath } from '../utils/events.js';
|
|
4
|
+
import { PointerOperationDirective, } from './pointer-operation.js';
|
|
7
5
|
function createDefaultGhost({ width, height }) {
|
|
8
6
|
const element = document.createElement('div');
|
|
9
7
|
setStyles(element, {
|
|
@@ -17,14 +15,15 @@ function createDefaultGhost({ width, height }) {
|
|
|
17
15
|
});
|
|
18
16
|
return element;
|
|
19
17
|
}
|
|
20
|
-
class DraggableDirective extends
|
|
18
|
+
class DraggableDirective extends PointerOperationDirective {
|
|
21
19
|
constructor(partInfo) {
|
|
22
|
-
super(partInfo
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
super(partInfo, {
|
|
21
|
+
name: 'draggable',
|
|
22
|
+
ghostAttribute: 'data-drag-ghost',
|
|
23
|
+
defaultMode: 'deferred',
|
|
24
|
+
defaultGhost: createDefaultGhost,
|
|
25
|
+
});
|
|
26
26
|
this._target = null;
|
|
27
|
-
this._operation = null;
|
|
28
27
|
this._handlePointerDown = (event) => {
|
|
29
28
|
if (!this._enabled ||
|
|
30
29
|
event.button !== 0 ||
|
|
@@ -39,7 +38,7 @@ class DraggableDirective extends AsyncDirective {
|
|
|
39
38
|
pointerId,
|
|
40
39
|
target,
|
|
41
40
|
initial,
|
|
42
|
-
current:
|
|
41
|
+
current: DOMRect.fromRect(initial),
|
|
43
42
|
position: { x: initial.x, y: initial.y },
|
|
44
43
|
offset: { x: initial.x - clientX, y: initial.y - clientY },
|
|
45
44
|
pointerState: {
|
|
@@ -76,30 +75,23 @@ class DraggableDirective extends AsyncDirective {
|
|
|
76
75
|
this._options.end?.(this._createParams(event));
|
|
77
76
|
this._dispose();
|
|
78
77
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.
|
|
84
|
-
|
|
85
|
-
this._operation.target.style.transform = this._operation.targetTransform;
|
|
86
|
-
}
|
|
87
|
-
this._dispose();
|
|
88
|
-
};
|
|
89
|
-
this._preventNativeBehavior = (event) => {
|
|
90
|
-
if (this._enabled) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
if (partInfo.type !== PartType.ELEMENT) {
|
|
95
|
-
throw new Error('The `draggable` directive can only be used on elements.');
|
|
78
|
+
}
|
|
79
|
+
_cancelOperation() {
|
|
80
|
+
this._options.cancel?.(this._createState());
|
|
81
|
+
if (!this._isDeferred) {
|
|
82
|
+
this._operation.target.style.transform =
|
|
83
|
+
this._operation.targetTransform;
|
|
96
84
|
}
|
|
97
85
|
}
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
_dispose() {
|
|
87
|
+
if (this._operation) {
|
|
88
|
+
this._setDragStyles(false);
|
|
89
|
+
}
|
|
90
|
+
super._dispose();
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
disconnected() {
|
|
93
|
+
super.disconnected();
|
|
94
|
+
this._target = null;
|
|
103
95
|
}
|
|
104
96
|
get _dragItem() {
|
|
105
97
|
return this._isDeferred ? this._operation.ghost : this._operation.target;
|
|
@@ -126,25 +118,8 @@ class DraggableDirective extends AsyncDirective {
|
|
|
126
118
|
});
|
|
127
119
|
}
|
|
128
120
|
_startOperation({ pointerId }) {
|
|
129
|
-
const { target } = this._operation;
|
|
130
|
-
const { signal } = this._dragAbort;
|
|
131
121
|
this._setDragStyles(true);
|
|
132
|
-
|
|
133
|
-
target.addEventListener('pointermove', this._handlePointerMove, {
|
|
134
|
-
signal,
|
|
135
|
-
});
|
|
136
|
-
target.addEventListener('lostpointercapture', this._handlePointerEnd, {
|
|
137
|
-
signal,
|
|
138
|
-
});
|
|
139
|
-
target.addEventListener('contextmenu', preventDefault, { signal });
|
|
140
|
-
globalThis.addEventListener('keydown', this._handleKeydown, { signal });
|
|
141
|
-
}
|
|
142
|
-
_resolveTarget() {
|
|
143
|
-
const { target } = this._options;
|
|
144
|
-
return ((typeof target === 'function' ? target() : target) ?? this._host ?? null);
|
|
145
|
-
}
|
|
146
|
-
_resolveLayer() {
|
|
147
|
-
return this._options.layer?.() ?? getDefaultLayer();
|
|
122
|
+
this._startOperationListeners(this._operation.target, pointerId, this._handlePointerMove, this._handlePointerEnd);
|
|
148
123
|
}
|
|
149
124
|
_shouldSkip(event) {
|
|
150
125
|
if (this._options.skip?.(event)) {
|
|
@@ -153,12 +128,6 @@ class DraggableDirective extends AsyncDirective {
|
|
|
153
128
|
const trigger = this._options.trigger?.();
|
|
154
129
|
return trigger ? !getElementFromPath((e) => e === trigger, event) : false;
|
|
155
130
|
}
|
|
156
|
-
_createGhost(initial) {
|
|
157
|
-
const ghost = this._options.ghostFactory?.(initial) ?? createDefaultGhost(initial);
|
|
158
|
-
ghost.setAttribute('data-drag-ghost', '');
|
|
159
|
-
this._resolveLayer().append(ghost);
|
|
160
|
-
return ghost;
|
|
161
|
-
}
|
|
162
131
|
_createState() {
|
|
163
132
|
const { initial, current, position, offset, pointerState, ghost, matchedElement, } = this._operation;
|
|
164
133
|
return {
|
|
@@ -242,37 +211,6 @@ class DraggableDirective extends AsyncDirective {
|
|
|
242
211
|
doc.getSelection()?.removeAllRanges();
|
|
243
212
|
}
|
|
244
213
|
}
|
|
245
|
-
_dispose() {
|
|
246
|
-
this._dragAbort.abort();
|
|
247
|
-
if (this._operation) {
|
|
248
|
-
const { pointerId, target, ghost } = this._operation;
|
|
249
|
-
this._setDragStyles(false);
|
|
250
|
-
if (target.hasPointerCapture(pointerId)) {
|
|
251
|
-
target.releasePointerCapture(pointerId);
|
|
252
|
-
}
|
|
253
|
-
ghost?.remove();
|
|
254
|
-
this._operation = null;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
reconnected() {
|
|
258
|
-
this._attachTriggerListeners();
|
|
259
|
-
}
|
|
260
|
-
disconnected() {
|
|
261
|
-
this._dispose();
|
|
262
|
-
this._triggerAbort.abort();
|
|
263
|
-
this._target = null;
|
|
264
|
-
}
|
|
265
|
-
update(part, [options]) {
|
|
266
|
-
if (this.isConnected) {
|
|
267
|
-
this._host = part.element;
|
|
268
|
-
this._options = options ?? {};
|
|
269
|
-
this._attachTriggerListeners();
|
|
270
|
-
}
|
|
271
|
-
return noChange;
|
|
272
|
-
}
|
|
273
|
-
render(_options) {
|
|
274
|
-
return noChange;
|
|
275
|
-
}
|
|
276
214
|
}
|
|
277
215
|
export const draggable = directive(DraggableDirective);
|
|
278
216
|
//# sourceMappingURL=drag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag.js","sourceRoot":"","sources":["../../../src/internals/directives/drag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,SAAS,EAIT,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,eAAe,EACf,OAAO,EACP,KAAK,EACL,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA2GxE,SAAS,kBAAkB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAW;IACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAG9C,SAAS,CAAC,OAAO,EAAE;QACjB,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,GAAG;QACT,GAAG,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AC,kBAAkB,CAAC,CAAC","sourcesContent":["import { noChange } from 'lit';\nimport {\n AsyncDirective,\n directive,\n type DirectiveParameters,\n type ElementPart,\n type PartInfo,\n PartType,\n} from 'lit/async-directive.js';\nimport { createAbortHandle } from '../abort-handler.js';\nimport { escapeKey, isKey } from '../controllers/key-bindings.js';\nimport {\n getDefaultLayer,\n getRoot,\n isLTR,\n roundByDPR,\n setStyles,\n} from '../utils/dom.js';\nimport { getElementFromPath, preventDefault } from '../utils/events.js';\n\nexport type DragMode = 'immediate' | 'deferred';\nexport type DragPointerDirection = 'start' | 'end' | 'top' | 'bottom';\nexport type DragGhostFactory = (initial: DOMRect) => HTMLElement;\nexport type DragCallback = (params: DragCallbackParams) => unknown;\nexport type DragCancelCallback = (state: DragState) => unknown;\n\ntype Point = { x: number; y: number };\n\nexport type DragState = {\n /** The bounding rectangle of the drag target at the start of the operation. */\n initial: DOMRect;\n /** The current bounding rectangle of the drag target. */\n current: DOMRect;\n /** The current position of the dragged element relative to its containing layer. */\n position: Point;\n /** Offset between the drag target origin and the pointer position at the start of the operation. */\n offset: Point;\n /** Pointer positions and movement direction for the current operation. */\n pointerState: {\n previous: Point;\n current: Point;\n direction: DragPointerDirection;\n };\n /** The ghost element when in deferred mode. */\n ghost: HTMLElement | null;\n /** The current element matched through the `matchTarget` callback, if any. */\n element: Element | null;\n};\n\nexport type DragCallbackParams = {\n event: PointerEvent;\n state: DragState;\n};\n\n/** Options for the draggable directive. */\nexport interface DraggableOptions {\n /** Whether the directive will listen for and initiate drag operations. Defaults to `true`. */\n enabled?: boolean;\n /**\n * The mode of the drag operation.\n *\n * In `immediate` mode the target element is moved in place as the pointer moves.\n * In `deferred` mode a ghost element is created and moved instead, keeping the\n * target element at its place until the operation completes.\n *\n * Defaults to `deferred`.\n */\n mode?: DragMode;\n /** Whether the dragged element's top left corner snaps to the cursor position at the start of the operation. */\n snapToCursor?: boolean;\n /**\n * The element being dragged. It captures the pointer events for the operation.\n * Defaults to the element the directive is applied to.\n *\n * Accepts either an element or a function returning one, resolved when\n * the directive options are applied.\n */\n target?: HTMLElement | (() => HTMLElement | null | undefined);\n /**\n * When provided, a drag operation only starts if the returned element is in the\n * composed path of the initiating pointer event.\n */\n trigger?: () => HTMLElement | null | undefined;\n /** Guard invoked on the initiating pointer event. Returning `true` skips the drag operation. */\n skip?: (event: PointerEvent) => boolean;\n /**\n * Predicate invoked with the elements under the pointer while dragging.\n * The first matching element is exposed as `state.element` and drives the\n * `enter`, `leave` and `over` callbacks.\n */\n matchTarget?: (element: Element) => boolean;\n /** Factory function for the ghost element in deferred mode. */\n ghostFactory?: DragGhostFactory;\n /** The container in which the deferred ghost element is rendered. Defaults to the document body. */\n layer?: () => HTMLElement;\n /** Called when a drag operation starts. Return `false` to abort the operation. */\n start?: DragCallback;\n /** Called on each pointer move during a drag operation. */\n move?: DragCallback;\n /** Called when the pointer enters an element matched through `matchTarget`. */\n enter?: DragCallback;\n /** Called when the pointer leaves the currently matched element. */\n leave?: DragCallback;\n /** Called while the pointer moves over the currently matched element. */\n over?: DragCallback;\n /** Called when a drag operation completes. */\n end?: DragCallback;\n /** Called when a drag operation is cancelled with the Escape key. */\n cancel?: DragCancelCallback;\n}\n\ntype DragOperation = {\n pointerId: number;\n target: HTMLElement;\n initial: DOMRect;\n current: DOMRect;\n position: Point;\n offset: Point;\n pointerState: DragState['pointerState'];\n ghost: HTMLElement | null;\n matchedElement: Element | null;\n /** Inline transform of the target before the operation, restored on cancel. */\n targetTransform: string;\n};\n\nfunction createDefaultGhost({ width, height }: DOMRect): HTMLElement {\n const element = document.createElement('div');\n\n // Anchored at the layer origin; the directive positions it via `translate3d`.\n setStyles(element, {\n position: 'absolute',\n left: '0',\n top: '0',\n width: `${width}px`,\n height: `${height}px`,\n zIndex: '1000',\n background: 'gold',\n });\n\n return element;\n}\n\nclass DraggableDirective extends AsyncDirective {\n private readonly _triggerAbort = createAbortHandle();\n private readonly _dragAbort = createAbortHandle();\n\n private _options: DraggableOptions = {};\n private _host?: HTMLElement;\n private _target: HTMLElement | null = null;\n private _operation: DragOperation | null = null;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n\n if (partInfo.type !== PartType.ELEMENT) {\n throw new Error(\n 'The `draggable` directive can only be used on elements.'\n );\n }\n }\n\n private get _enabled(): boolean {\n return this._options.enabled ?? true;\n }\n\n private get _isDeferred(): boolean {\n return (this._options.mode ?? 'deferred') === 'deferred';\n }\n\n /** The element being moved around - the ghost in deferred mode, otherwise the drag target. */\n private get _dragItem(): HTMLElement {\n return this._isDeferred ? this._operation!.ghost! : this._operation!.target;\n }\n\n // #region Event handlers\n\n private readonly _handlePointerDown = (event: PointerEvent): void => {\n if (\n !this._enabled ||\n event.button !== 0 ||\n this._operation ||\n this._shouldSkip(event)\n ) {\n return;\n }\n\n const target = this._target!;\n const initial = target.getBoundingClientRect();\n const { pointerId, clientX, clientY } = event;\n\n this._operation = {\n pointerId,\n target,\n initial,\n current: structuredClone(initial),\n position: { x: initial.x, y: initial.y },\n offset: { x: initial.x - clientX, y: initial.y - clientY },\n pointerState: {\n previous: { x: clientX, y: clientY },\n current: { x: clientX, y: clientY },\n direction: 'end',\n },\n ghost: this._isDeferred ? this._createGhost(initial) : null,\n matchedElement: null,\n targetTransform: target.style.transform,\n };\n\n this._updatePosition(event);\n\n if (this._options.start?.(this._createParams(event)) === false) {\n this._dispose();\n return;\n }\n\n this._assignPosition(this._dragItem);\n this._startOperation(event);\n };\n\n private readonly _handlePointerMove = (event: PointerEvent): void => {\n if (!this._operation) {\n return;\n }\n\n this._updatePosition(event);\n this._updatePointerState(event);\n this._updateMatcher(event);\n\n this._options.move?.(this._createParams(event));\n\n this._assignPosition(this._dragItem);\n };\n\n private readonly _handlePointerEnd = (event: PointerEvent): void => {\n if (!this._operation) {\n return;\n }\n\n this._options.end?.(this._createParams(event));\n this._dispose();\n };\n\n private readonly _handleKeydown = (event: KeyboardEvent): void => {\n if (!this._operation || !isKey(event, escapeKey)) {\n return;\n }\n\n this._options.cancel?.(this._createState());\n\n if (!this._isDeferred) {\n this._operation.target.style.transform = this._operation.targetTransform;\n }\n\n this._dispose();\n };\n\n /** Prevents native drag and touch interactions from interfering with an enabled directive. */\n private readonly _preventNativeBehavior = (event: Event): void => {\n if (this._enabled) {\n event.preventDefault();\n }\n };\n\n // #endregion\n\n // #region Internal API\n\n private _attachTriggerListeners(): void {\n const target = this._resolveTarget();\n if (!target) {\n return;\n }\n\n if (target !== this._target) {\n this._triggerAbort.abort();\n this._target = target;\n }\n\n const { signal } = this._triggerAbort;\n\n target.addEventListener('pointerdown', this._handlePointerDown, {\n signal,\n });\n target.addEventListener('dragstart', this._preventNativeBehavior, {\n signal,\n });\n target.addEventListener('touchstart', this._preventNativeBehavior, {\n passive: false,\n signal,\n });\n }\n\n private _startOperation({ pointerId }: PointerEvent): void {\n const { target } = this._operation!;\n const { signal } = this._dragAbort;\n\n this._setDragStyles(true);\n\n target.setPointerCapture(pointerId);\n target.addEventListener('pointermove', this._handlePointerMove, {\n signal,\n });\n target.addEventListener('lostpointercapture', this._handlePointerEnd, {\n signal,\n });\n target.addEventListener('contextmenu', preventDefault, { signal });\n globalThis.addEventListener('keydown', this._handleKeydown, { signal });\n }\n\n private _resolveTarget(): HTMLElement | null {\n const { target } = this._options;\n return (\n (typeof target === 'function' ? target() : target) ?? this._host ?? null\n );\n }\n\n private _resolveLayer(): HTMLElement {\n return this._options.layer?.() ?? getDefaultLayer();\n }\n\n private _shouldSkip(event: PointerEvent): boolean {\n if (this._options.skip?.(event)) {\n return true;\n }\n\n const trigger = this._options.trigger?.();\n return trigger ? !getElementFromPath((e) => e === trigger, event) : false;\n }\n\n private _createGhost(initial: DOMRect): HTMLElement {\n const ghost =\n this._options.ghostFactory?.(initial) ?? createDefaultGhost(initial);\n\n ghost.setAttribute('data-drag-ghost', '');\n this._resolveLayer().append(ghost);\n return ghost;\n }\n\n private _createState(): DragState {\n const {\n initial,\n current,\n position,\n offset,\n pointerState,\n ghost,\n matchedElement,\n } = this._operation!;\n\n return {\n initial,\n current,\n position,\n offset,\n pointerState,\n ghost,\n element: matchedElement,\n };\n }\n\n private _createParams(event: PointerEvent): DragCallbackParams {\n return { event, state: this._createState() };\n }\n\n private _updatePosition({ clientX, clientY }: PointerEvent): void {\n const operation = this._operation!;\n const { x: layerX, y: layerY } = this._isDeferred\n ? this._resolveLayer().getBoundingClientRect()\n : operation.initial;\n const { x, y } = this._options.snapToCursor\n ? { x: 0, y: 0 }\n : operation.offset;\n\n operation.position = {\n x: clientX - layerX + x,\n y: clientY - layerY + y,\n };\n }\n\n private _updatePointerState({ clientX, clientY }: PointerEvent): void {\n const state = this._operation!.pointerState;\n\n state.previous = { ...state.current };\n state.current = { x: clientX, y: clientY };\n\n const dx = state.current.x - state.previous.x;\n const dy = state.current.y - state.previous.y;\n\n if (Math.abs(dx) >= Math.abs(dy)) {\n const swapHorizontal = isLTR(this._operation!.target) ? dx >= 0 : dx <= 0;\n state.direction = swapHorizontal ? 'end' : 'start';\n } else {\n state.direction = dy >= 0 ? 'bottom' : 'top';\n }\n }\n\n private _updateMatcher(event: PointerEvent): void {\n const { matchTarget } = this._options;\n if (!matchTarget) {\n return;\n }\n\n const operation = this._operation!;\n const match = getRoot(operation.target)\n .elementsFromPoint(event.clientX, event.clientY)\n .find((element) => matchTarget(element));\n\n if (match && !operation.matchedElement) {\n operation.matchedElement = match;\n this._options.enter?.(this._createParams(event));\n return;\n }\n\n if (!match && operation.matchedElement) {\n this._options.leave?.(this._createParams(event));\n operation.matchedElement = null;\n return;\n }\n\n if (match && match === operation.matchedElement) {\n this._options.over?.(this._createParams(event));\n }\n }\n\n private _assignPosition(element: HTMLElement): void {\n const { x, y } = this._operation!.position;\n element.style.transform = `translate3d(${roundByDPR(x)}px,${roundByDPR(y)}px,0)`;\n }\n\n /**\n * Toggles touch action, user and text selection for the duration of a drag operation.\n *\n * @remarks\n * Disabling `user-select` only on the dragged element is not enough, since browsers\n * (notably Safari) will still create a text selection in whatever elements sit under\n * the pointer while dragging. Applying it to the owner document's body prevents that\n * across the page for the active drag and is reverted once the operation completes.\n */\n private _setDragStyles(active: boolean): void {\n const value = active ? 'none' : '';\n const { target } = this._operation!;\n const doc = target.ownerDocument;\n\n setStyles(target, {\n touchAction: value,\n userSelect: value,\n webkitUserSelect: value,\n });\n setStyles(doc.body, { userSelect: value, webkitUserSelect: value });\n\n if (active) {\n doc.getSelection()?.removeAllRanges();\n }\n }\n\n /** Stops the current drag operation, cleaning up the ghost element and event listeners. */\n private _dispose(): void {\n this._dragAbort.abort();\n\n if (this._operation) {\n const { pointerId, target, ghost } = this._operation;\n\n this._setDragStyles(false);\n\n if (target.hasPointerCapture(pointerId)) {\n target.releasePointerCapture(pointerId);\n }\n\n ghost?.remove();\n this._operation = null;\n }\n }\n\n // #endregion\n\n protected override reconnected(): void {\n this._attachTriggerListeners();\n }\n\n protected override disconnected(): void {\n this._dispose();\n this._triggerAbort.abort();\n this._target = null;\n }\n\n public override update(\n part: ElementPart,\n [options]: DirectiveParameters<this>\n ) {\n if (this.isConnected) {\n this._host = part.element as HTMLElement;\n this._options = options ?? {};\n this._attachTriggerListeners();\n }\n return noChange;\n }\n\n public render(_options?: DraggableOptions) {\n return noChange;\n }\n}\n\n/**\n * A directive that makes an element draggable, either in place or through\n * a deferred ghost element, with optional hit-testing against other elements\n * while dragging.\n */\nexport const draggable = directive(DraggableDirective);\n"]}
|
|
1
|
+
{"version":3,"file":"drag.js","sourceRoot":"","sources":["../../../src/internals/directives/drag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,yBAAyB,GAG1B,MAAM,wBAAwB,CAAC;AAgFhC,SAAS,kBAAkB,CAAC,EAAE,KAAK,EAAE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eAAe,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;CAGF;AAMD,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { directive, type PartInfo } from 'lit/async-directive.js';\nimport { getRoot, isLTR, roundByDPR, setStyles } from '../utils/dom.js';\nimport { getElementFromPath } from '../utils/events.js';\nimport {\n PointerOperationDirective,\n type PointerOperationOptions,\n type PointerOperationState,\n} from './pointer-operation.js';\n\nexport type DragPointerDirection = 'start' | 'end' | 'top' | 'bottom';\nexport type DragCallback = (params: DragCallbackParams) => unknown;\nexport type DragCancelCallback = (state: DragState) => unknown;\n\ntype Point = { x: number; y: number };\n\nexport type DragState = {\n /** The bounding rectangle of the target at the start of the operation. */\n initial: DOMRect;\n current: DOMRect;\n /**\n * The position of the moved element: relative to the layer in deferred\n * mode, and to the initial rectangle of the target in immediate mode.\n */\n position: Point;\n /** The distance from the target origin to the pointer at the start. */\n offset: Point;\n pointerState: {\n previous: Point;\n current: Point;\n direction: DragPointerDirection;\n };\n /** The ghost element when in deferred mode. */\n ghost: HTMLElement | null;\n /** The element that the `matchTarget` callback matches, or `null`. */\n element: Element | null;\n};\n\nexport type DragCallbackParams = {\n event: PointerEvent;\n state: DragState;\n};\n\n/**\n * Options for the draggable directive. See {@link PointerOperationOptions}\n * for the shared ones. The mode defaults to `deferred`, which moves a ghost\n * element and leaves the target in place.\n */\nexport interface DraggableOptions extends PointerOperationOptions {\n /** Whether the dragged element snaps its top left corner to the pointer. */\n snapToCursor?: boolean;\n /** Returns the element whose presence in the event path starts a drag. */\n trigger?: () => HTMLElement | null | undefined;\n /** Runs with the initiating pointer event. A `true` return skips the drag. */\n skip?: (event: PointerEvent) => boolean;\n /**\n * A predicate for the elements under the pointer. The first match becomes\n * `state.element`, and drives `enter`, `leave` and `over`.\n */\n matchTarget?: (element: Element) => boolean;\n /** Runs when a drag starts. A `false` return aborts the operation. */\n start?: DragCallback;\n /** Runs on each pointer move of a drag operation. */\n move?: DragCallback;\n /** Runs when the pointer enters a matched element. */\n enter?: DragCallback;\n /** Runs when the pointer leaves the matched element. */\n leave?: DragCallback;\n /** Runs while the pointer moves over the matched element. */\n over?: DragCallback;\n /** Runs when a drag operation completes. */\n end?: DragCallback;\n /** Runs when the Escape key cancels a drag operation. */\n cancel?: DragCancelCallback;\n}\n\ntype DragOperation = PointerOperationState & {\n target: HTMLElement;\n initial: DOMRect;\n current: DOMRect;\n position: Point;\n offset: Point;\n pointerState: DragState['pointerState'];\n matchedElement: Element | null;\n /** The inline transform of the target, restored on an immediate cancel. */\n targetTransform: string;\n};\n\nfunction createDefaultGhost({ width, height }: DOMRect): HTMLElement {\n const element = document.createElement('div');\n\n // The element sits at the layer origin and moves with `translate3d`.\n setStyles(element, {\n position: 'absolute',\n left: '0',\n top: '0',\n width: `${width}px`,\n height: `${height}px`,\n zIndex: '1000',\n background: 'gold',\n });\n\n return element;\n}\n\nclass DraggableDirective extends PointerOperationDirective<\n DraggableOptions,\n DragOperation\n> {\n private _target: HTMLElement | null = null;\n\n constructor(partInfo: PartInfo) {\n super(partInfo, {\n name: 'draggable',\n ghostAttribute: 'data-drag-ghost',\n defaultMode: 'deferred',\n defaultGhost: createDefaultGhost,\n });\n }\n\n protected override _cancelOperation(): void {\n this._options.cancel?.(this._createState());\n\n if (!this._isDeferred) {\n this._operation!.target.style.transform =\n this._operation!.targetTransform;\n }\n }\n\n /** Restores the styles that the operation changed, then disposes. */\n protected override _dispose(): void {\n if (this._operation) {\n this._setDragStyles(false);\n }\n\n super._dispose();\n }\n\n protected override disconnected(): void {\n super.disconnected();\n this._target = null;\n }\n\n /** The ghost element in deferred mode, the drag target in immediate mode. */\n private get _dragItem(): HTMLElement {\n return this._isDeferred ? this._operation!.ghost! : this._operation!.target;\n }\n\n // #region Event handlers\n\n private readonly _handlePointerDown = (event: PointerEvent): void => {\n if (\n !this._enabled ||\n event.button !== 0 ||\n this._operation ||\n this._shouldSkip(event)\n ) {\n return;\n }\n\n const target = this._target!;\n const initial = target.getBoundingClientRect();\n const { pointerId, clientX, clientY } = event;\n\n this._operation = {\n pointerId,\n target,\n initial,\n current: DOMRect.fromRect(initial),\n position: { x: initial.x, y: initial.y },\n offset: { x: initial.x - clientX, y: initial.y - clientY },\n pointerState: {\n previous: { x: clientX, y: clientY },\n current: { x: clientX, y: clientY },\n direction: 'end',\n },\n ghost: this._isDeferred ? this._createGhost(initial) : null,\n matchedElement: null,\n targetTransform: target.style.transform,\n };\n\n this._updatePosition(event);\n\n if (this._options.start?.(this._createParams(event)) === false) {\n this._dispose();\n return;\n }\n\n this._assignPosition(this._dragItem);\n this._startOperation(event);\n };\n\n private readonly _handlePointerMove = (event: PointerEvent): void => {\n if (!this._operation) {\n return;\n }\n\n this._updatePosition(event);\n this._updatePointerState(event);\n this._updateMatcher(event);\n\n this._options.move?.(this._createParams(event));\n\n this._assignPosition(this._dragItem);\n };\n\n private readonly _handlePointerEnd = (event: PointerEvent): void => {\n if (!this._operation) {\n return;\n }\n\n this._options.end?.(this._createParams(event));\n this._dispose();\n };\n\n // #endregion\n\n // #region Internal API\n\n protected override _attachTriggerListeners(): void {\n const target = this._resolveTarget();\n if (!target) {\n return;\n }\n\n if (target !== this._target) {\n this._triggerAbort.abort();\n this._target = target;\n }\n\n const { signal } = this._triggerAbort;\n\n target.addEventListener('pointerdown', this._handlePointerDown, {\n signal,\n });\n target.addEventListener('dragstart', this._preventNativeBehavior, {\n signal,\n });\n target.addEventListener('touchstart', this._preventNativeBehavior, {\n passive: false,\n signal,\n });\n }\n\n private _startOperation({ pointerId }: PointerEvent): void {\n this._setDragStyles(true);\n\n this._startOperationListeners(\n this._operation!.target,\n pointerId,\n this._handlePointerMove,\n this._handlePointerEnd\n );\n }\n\n private _shouldSkip(event: PointerEvent): boolean {\n if (this._options.skip?.(event)) {\n return true;\n }\n\n const trigger = this._options.trigger?.();\n return trigger ? !getElementFromPath((e) => e === trigger, event) : false;\n }\n\n private _createState(): DragState {\n const {\n initial,\n current,\n position,\n offset,\n pointerState,\n ghost,\n matchedElement,\n } = this._operation!;\n\n return {\n initial,\n current,\n position,\n offset,\n pointerState,\n ghost,\n element: matchedElement,\n };\n }\n\n private _createParams(event: PointerEvent): DragCallbackParams {\n return { event, state: this._createState() };\n }\n\n private _updatePosition({ clientX, clientY }: PointerEvent): void {\n const operation = this._operation!;\n const { x: layerX, y: layerY } = this._isDeferred\n ? this._resolveLayer().getBoundingClientRect()\n : operation.initial;\n const { x, y } = this._options.snapToCursor\n ? { x: 0, y: 0 }\n : operation.offset;\n\n operation.position = {\n x: clientX - layerX + x,\n y: clientY - layerY + y,\n };\n }\n\n private _updatePointerState({ clientX, clientY }: PointerEvent): void {\n const state = this._operation!.pointerState;\n\n state.previous = { ...state.current };\n state.current = { x: clientX, y: clientY };\n\n const dx = state.current.x - state.previous.x;\n const dy = state.current.y - state.previous.y;\n\n if (Math.abs(dx) >= Math.abs(dy)) {\n const swapHorizontal = isLTR(this._operation!.target) ? dx >= 0 : dx <= 0;\n state.direction = swapHorizontal ? 'end' : 'start';\n } else {\n state.direction = dy >= 0 ? 'bottom' : 'top';\n }\n }\n\n private _updateMatcher(event: PointerEvent): void {\n const { matchTarget } = this._options;\n if (!matchTarget) {\n return;\n }\n\n const operation = this._operation!;\n const match = getRoot(operation.target)\n .elementsFromPoint(event.clientX, event.clientY)\n .find((element) => matchTarget(element));\n\n if (match && !operation.matchedElement) {\n operation.matchedElement = match;\n this._options.enter?.(this._createParams(event));\n return;\n }\n\n if (!match && operation.matchedElement) {\n this._options.leave?.(this._createParams(event));\n operation.matchedElement = null;\n return;\n }\n\n if (match && match === operation.matchedElement) {\n this._options.over?.(this._createParams(event));\n }\n }\n\n private _assignPosition(element: HTMLElement): void {\n const { x, y } = this._operation!.position;\n element.style.transform = `translate3d(${roundByDPR(x)}px,${roundByDPR(y)}px,0)`;\n }\n\n /**\n * Toggles the touch action and the text selection for a drag operation.\n *\n * @remarks\n * The `user-select` style on the dragged element is not enough. Browsers,\n * Safari in particular, still select text in the elements under the\n * pointer, so the style also goes on the body of the owner document.\n */\n private _setDragStyles(active: boolean): void {\n const value = active ? 'none' : '';\n const { target } = this._operation!;\n const doc = target.ownerDocument;\n\n setStyles(target, {\n touchAction: value,\n userSelect: value,\n webkitUserSelect: value,\n });\n setStyles(doc.body, { userSelect: value, webkitUserSelect: value });\n\n if (active) {\n doc.getSelection()?.removeAllRanges();\n }\n }\n\n // #endregion\n}\n\n/**\n * A directive that makes an element draggable, in place or through a\n * deferred ghost element, with an optional hit test of other elements.\n */\nexport const draggable = directive(DraggableDirective);\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AsyncDirective, type DirectiveParameters, type ElementPart, type PartInfo } from 'lit/async-directive.js';
|
|
2
|
+
/**
|
|
3
|
+
* How an operation applies its result. `immediate` changes the target while
|
|
4
|
+
* the pointer moves. `deferred` changes a ghost, and the target keeps its
|
|
5
|
+
* state until the operation ends.
|
|
6
|
+
*/
|
|
7
|
+
export type PointerOperationMode = 'immediate' | 'deferred';
|
|
8
|
+
/** Builds the ghost element from the initial rectangle. */
|
|
9
|
+
export type GhostFactory = (initial: DOMRect) => HTMLElement;
|
|
10
|
+
/** The options that the pointer directives have in common. */
|
|
11
|
+
export interface PointerOperationOptions {
|
|
12
|
+
/** Whether the directive starts operations. Defaults to `true`. */
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
/** The mode of the operation. Each directive has its own default. */
|
|
15
|
+
mode?: PointerOperationMode;
|
|
16
|
+
/** The operation target. Defaults to the element with the directive. */
|
|
17
|
+
target?: HTMLElement | (() => HTMLElement | null | undefined);
|
|
18
|
+
ghostFactory?: GhostFactory;
|
|
19
|
+
/** The ghost container. Defaults to the document body. */
|
|
20
|
+
layer?: () => HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
/** The traits that a directive fixes, and that its options cannot change. */
|
|
23
|
+
export type PointerOperationConfig = {
|
|
24
|
+
/** The name of the directive, used in the wrong-part-type error. */
|
|
25
|
+
name: string;
|
|
26
|
+
ghostAttribute: string;
|
|
27
|
+
defaultMode: PointerOperationMode;
|
|
28
|
+
/** The ghost that the directive builds without a factory. */
|
|
29
|
+
defaultGhost: GhostFactory;
|
|
30
|
+
};
|
|
31
|
+
/** The state that each operation keeps, whatever the directive. */
|
|
32
|
+
export type PointerOperationState = {
|
|
33
|
+
pointerId: number;
|
|
34
|
+
/** The ghost element in deferred mode. */
|
|
35
|
+
ghost: HTMLElement | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The parts that the drag and the resize directives share.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* The base class keeps the abort handles, the ghost, the pointer capture and
|
|
42
|
+
* the life-cycle. A subclass adds its own geometry and start events.
|
|
43
|
+
*/
|
|
44
|
+
export declare abstract class PointerOperationDirective<TOptions extends PointerOperationOptions, TState extends PointerOperationState> extends AsyncDirective {
|
|
45
|
+
/** Aborts the listeners that wait for an operation to start. */
|
|
46
|
+
protected readonly _triggerAbort: import("../abort-handler.js").AbortHandle;
|
|
47
|
+
/** Aborts the listeners that run for the duration of an operation. */
|
|
48
|
+
protected readonly _operationAbort: import("../abort-handler.js").AbortHandle;
|
|
49
|
+
protected readonly _config: PointerOperationConfig;
|
|
50
|
+
protected _options: TOptions;
|
|
51
|
+
protected _host?: HTMLElement;
|
|
52
|
+
protected _operation: TState | null;
|
|
53
|
+
/** The element that holds the pointer capture of the running operation. */
|
|
54
|
+
private _captureElement?;
|
|
55
|
+
constructor(partInfo: PartInfo, config: PointerOperationConfig);
|
|
56
|
+
protected get _enabled(): boolean;
|
|
57
|
+
protected get _isDeferred(): boolean;
|
|
58
|
+
protected abstract _attachTriggerListeners(): void;
|
|
59
|
+
/** Reports the cancellation and restores the target element. */
|
|
60
|
+
protected abstract _cancelOperation(): void;
|
|
61
|
+
/** Prevents the native interactions that would compete with the directive. */
|
|
62
|
+
protected readonly _preventNativeBehavior: (event: Event) => void;
|
|
63
|
+
protected readonly _handleKeydown: (event: KeyboardEvent) => void;
|
|
64
|
+
protected _resolveTarget(): HTMLElement | null;
|
|
65
|
+
protected _resolveLayer(): HTMLElement;
|
|
66
|
+
protected _createGhost(initial: DOMRect): HTMLElement;
|
|
67
|
+
/** Captures the pointer on `element` and adds the operation listeners. */
|
|
68
|
+
protected _startOperationListeners(element: HTMLElement, pointerId: number, onMove: (event: PointerEvent) => void, onEnd: (event: PointerEvent) => void): void;
|
|
69
|
+
/** Stops the operation and removes the ghost and the listeners. */
|
|
70
|
+
protected _dispose(): void;
|
|
71
|
+
protected reconnected(): void;
|
|
72
|
+
protected disconnected(): void;
|
|
73
|
+
update(part: ElementPart, [options]: DirectiveParameters<this>): symbol;
|
|
74
|
+
render(_options?: TOptions): symbol;
|
|
75
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { noChange } from 'lit';
|
|
2
|
+
import { AsyncDirective, PartType, } from 'lit/async-directive.js';
|
|
3
|
+
import { createAbortHandle } from '../abort-handler.js';
|
|
4
|
+
import { escapeKey, isKey } from '../controllers/keys.js';
|
|
5
|
+
import { getDefaultLayer } from '../utils/dom.js';
|
|
6
|
+
import { preventDefault } from '../utils/events.js';
|
|
7
|
+
import { resolveValue } from '../utils/types.js';
|
|
8
|
+
export class PointerOperationDirective extends AsyncDirective {
|
|
9
|
+
constructor(partInfo, config) {
|
|
10
|
+
super(partInfo);
|
|
11
|
+
this._triggerAbort = createAbortHandle();
|
|
12
|
+
this._operationAbort = createAbortHandle();
|
|
13
|
+
this._options = {};
|
|
14
|
+
this._operation = null;
|
|
15
|
+
this._preventNativeBehavior = (event) => {
|
|
16
|
+
if (this._enabled) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
this._handleKeydown = (event) => {
|
|
21
|
+
if (!this._operation || !isKey(event, escapeKey)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this._cancelOperation();
|
|
25
|
+
this._dispose();
|
|
26
|
+
};
|
|
27
|
+
if (partInfo.type !== PartType.ELEMENT) {
|
|
28
|
+
throw new Error(`The \`${config.name}\` directive can only be used on elements.`);
|
|
29
|
+
}
|
|
30
|
+
this._config = config;
|
|
31
|
+
}
|
|
32
|
+
get _enabled() {
|
|
33
|
+
return this._options.enabled ?? true;
|
|
34
|
+
}
|
|
35
|
+
get _isDeferred() {
|
|
36
|
+
return (this._options.mode ?? this._config.defaultMode) === 'deferred';
|
|
37
|
+
}
|
|
38
|
+
_resolveTarget() {
|
|
39
|
+
return resolveValue(this._options.target) ?? this._host ?? null;
|
|
40
|
+
}
|
|
41
|
+
_resolveLayer() {
|
|
42
|
+
return this._options.layer?.() ?? getDefaultLayer();
|
|
43
|
+
}
|
|
44
|
+
_createGhost(initial) {
|
|
45
|
+
const ghost = (this._options.ghostFactory ?? this._config.defaultGhost)(initial);
|
|
46
|
+
ghost.setAttribute(this._config.ghostAttribute, '');
|
|
47
|
+
this._resolveLayer().append(ghost);
|
|
48
|
+
return ghost;
|
|
49
|
+
}
|
|
50
|
+
_startOperationListeners(element, pointerId, onMove, onEnd) {
|
|
51
|
+
const { signal } = this._operationAbort;
|
|
52
|
+
this._captureElement = element;
|
|
53
|
+
element.setPointerCapture(pointerId);
|
|
54
|
+
element.addEventListener('pointermove', onMove, { signal });
|
|
55
|
+
element.addEventListener('lostpointercapture', onEnd, { signal });
|
|
56
|
+
element.addEventListener('contextmenu', preventDefault, { signal });
|
|
57
|
+
globalThis.addEventListener('keydown', this._handleKeydown, { signal });
|
|
58
|
+
}
|
|
59
|
+
_dispose() {
|
|
60
|
+
this._operationAbort.abort();
|
|
61
|
+
if (!this._operation) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { pointerId, ghost } = this._operation;
|
|
65
|
+
const element = this._captureElement;
|
|
66
|
+
if (element?.hasPointerCapture(pointerId)) {
|
|
67
|
+
element.releasePointerCapture(pointerId);
|
|
68
|
+
}
|
|
69
|
+
ghost?.remove();
|
|
70
|
+
this._captureElement = undefined;
|
|
71
|
+
this._operation = null;
|
|
72
|
+
}
|
|
73
|
+
reconnected() {
|
|
74
|
+
this._attachTriggerListeners();
|
|
75
|
+
}
|
|
76
|
+
disconnected() {
|
|
77
|
+
this._dispose();
|
|
78
|
+
this._triggerAbort.abort();
|
|
79
|
+
}
|
|
80
|
+
update(part, [options]) {
|
|
81
|
+
if (this.isConnected) {
|
|
82
|
+
this._host = part.element;
|
|
83
|
+
this._options = (options ?? {});
|
|
84
|
+
this._attachTriggerListeners();
|
|
85
|
+
}
|
|
86
|
+
return noChange;
|
|
87
|
+
}
|
|
88
|
+
render(_options) {
|
|
89
|
+
return noChange;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=pointer-operation.js.map
|