@milaboratories/uikit 2.15.37 → 2.15.38
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/.turbo/turbo-build.log +173 -173
- package/.turbo/turbo-formatter$colon$check.log +2 -2
- package/.turbo/turbo-linter$colon$check.log +2 -2
- package/.turbo/turbo-types$colon$check.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/__tests__/default-testid.test.d.ts +2 -0
- package/dist/__tests__/default-testid.test.d.ts.map +1 -0
- package/dist/base/BtnBase.js.map +1 -1
- package/dist/base/BtnBase.vue.d.ts.map +1 -1
- package/dist/base/BtnBase.vue2.js +6 -1
- package/dist/base/BtnBase.vue2.js.map +1 -1
- package/dist/components/DropdownListItem.js.map +1 -1
- package/dist/components/DropdownListItem.vue.d.ts.map +1 -1
- package/dist/components/DropdownListItem.vue2.js +13 -4
- package/dist/components/DropdownListItem.vue2.js.map +1 -1
- package/dist/components/InputRange.js.map +1 -1
- package/dist/components/InputRange.vue.d.ts.map +1 -1
- package/dist/components/InputRange.vue2.js +10 -2
- package/dist/components/InputRange.vue2.js.map +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.js.map +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.style.js.map +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.vue.d.ts.map +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.vue2.js +7 -1
- package/dist/components/PlAccordion/PlAccordionSection.vue2.js.map +1 -1
- package/dist/components/PlAlert/PlAlert.js.map +1 -1
- package/dist/components/PlAlert/PlAlert.vue.d.ts.map +1 -1
- package/dist/components/PlAlert/PlAlert.vue2.js +10 -1
- package/dist/components/PlAlert/PlAlert.vue2.js.map +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.js.map +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.vue.d.ts.map +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.vue2.js +29 -11
- package/dist/components/PlAutocomplete/PlAutocomplete.vue2.js.map +1 -1
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.js.map +1 -1
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue.d.ts.map +1 -1
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue2.js +30 -9
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue2.js.map +1 -1
- package/dist/components/PlBtnAccent/PlBtnAccent.js.map +1 -1
- package/dist/components/PlBtnAccent/PlBtnAccent.vue.d.ts.map +1 -1
- package/dist/components/PlBtnAccent/PlBtnAccent.vue2.js +4 -1
- package/dist/components/PlBtnAccent/PlBtnAccent.vue2.js.map +1 -1
- package/dist/components/PlBtnDanger/PlBtnDanger.js.map +1 -1
- package/dist/components/PlBtnDanger/PlBtnDanger.vue.d.ts.map +1 -1
- package/dist/components/PlBtnDanger/PlBtnDanger.vue2.js +4 -1
- package/dist/components/PlBtnDanger/PlBtnDanger.vue2.js.map +1 -1
- package/dist/components/PlBtnGhost/PlBtnGhost.js.map +1 -1
- package/dist/components/PlBtnGhost/PlBtnGhost.vue.d.ts.map +1 -1
- package/dist/components/PlBtnGhost/PlBtnGhost.vue2.js +7 -1
- package/dist/components/PlBtnGhost/PlBtnGhost.vue2.js.map +1 -1
- package/dist/components/PlBtnGroup/PlBtnGroup.js.map +1 -1
- package/dist/components/PlBtnGroup/PlBtnGroup.vue.d.ts.map +1 -1
- package/dist/components/PlBtnGroup/PlBtnGroup.vue2.js +19 -6
- package/dist/components/PlBtnGroup/PlBtnGroup.vue2.js.map +1 -1
- package/dist/components/PlBtnLink/PlBtnLink.js.map +1 -1
- package/dist/components/PlBtnLink/PlBtnLink.vue.d.ts.map +1 -1
- package/dist/components/PlBtnLink/PlBtnLink.vue2.js +2 -0
- package/dist/components/PlBtnLink/PlBtnLink.vue2.js.map +1 -1
- package/dist/components/PlBtnPrimary/PlBtnPrimary.js.map +1 -1
- package/dist/components/PlBtnPrimary/PlBtnPrimary.vue.d.ts.map +1 -1
- package/dist/components/PlBtnPrimary/PlBtnPrimary.vue2.js +4 -1
- package/dist/components/PlBtnPrimary/PlBtnPrimary.vue2.js.map +1 -1
- package/dist/components/PlBtnSecondary/PlBtnSecondary.js.map +1 -1
- package/dist/components/PlBtnSecondary/PlBtnSecondary.vue.d.ts.map +1 -1
- package/dist/components/PlBtnSecondary/PlBtnSecondary.vue2.js +1 -1
- package/dist/components/PlBtnSecondary/PlBtnSecondary.vue2.js.map +1 -1
- package/dist/components/PlBtnSplit/PlBtnSplit.js.map +1 -1
- package/dist/components/PlBtnSplit/PlBtnSplit.vue.d.ts.map +1 -1
- package/dist/components/PlBtnSplit/PlBtnSplit.vue2.js +6 -0
- package/dist/components/PlBtnSplit/PlBtnSplit.vue2.js.map +1 -1
- package/dist/components/PlChartHistogram/PlChartHistogram.js.map +1 -1
- package/dist/components/PlChartHistogram/PlChartHistogram.style.js.map +1 -1
- package/dist/components/PlChartHistogram/PlChartHistogram.vue.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/PlChartHistogram.vue2.js +7 -2
- package/dist/components/PlChartHistogram/PlChartHistogram.vue2.js.map +1 -1
- package/dist/components/PlChartHistogram/createGridlines.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/createGridlines.js +1 -1
- package/dist/components/PlChartHistogram/createGridlines.js.map +1 -1
- package/dist/components/PlChartHistogram/createLabels.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/createLabels.js +1 -1
- package/dist/components/PlChartHistogram/createLabels.js.map +1 -1
- package/dist/components/PlChartHistogram/createSvgContainer.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/createSvgContainer.js +1 -1
- package/dist/components/PlChartHistogram/createSvgContainer.js.map +1 -1
- package/dist/components/PlChartHistogram/drawBins.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/drawBins.js +2 -2
- package/dist/components/PlChartHistogram/drawBins.js.map +1 -1
- package/dist/components/PlChartHistogram/drawThreshold.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/drawThreshold.js +1 -1
- package/dist/components/PlChartHistogram/drawThreshold.js.map +1 -1
- package/dist/components/PlChartHistogram/histogram.d.ts.map +1 -1
- package/dist/components/PlChartHistogram/histogram.js +1 -1
- package/dist/components/PlChartHistogram/histogram.js.map +1 -1
- package/dist/components/PlChartStackedBar/Legends.js.map +1 -1
- package/dist/components/PlChartStackedBar/Legends.style.js.map +1 -1
- package/dist/components/PlChartStackedBar/Legends.vue.d.ts.map +1 -1
- package/dist/components/PlChartStackedBar/Legends.vue2.js +7 -1
- package/dist/components/PlChartStackedBar/Legends.vue2.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBar.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBar.style.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBar.vue.d.ts.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBar.vue2.js +5 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBar.vue2.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBarCompact.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBarCompact.style.js.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBarCompact.vue.d.ts.map +1 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBarCompact.vue2.js +4 -1
- package/dist/components/PlChartStackedBar/PlChartStackedBarCompact.vue2.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRow.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRow.style.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRow.vue.d.ts.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRow.vue2.js +13 -3
- package/dist/components/PlChartStackedBar/StackedRow.vue2.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRowCompact.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRowCompact.style.js.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRowCompact.vue.d.ts.map +1 -1
- package/dist/components/PlChartStackedBar/StackedRowCompact.vue2.js +8 -2
- package/dist/components/PlChartStackedBar/StackedRowCompact.vue2.js.map +1 -1
- package/dist/components/PlCheckbox/PlCheckbox.js.map +1 -1
- package/dist/components/PlCheckbox/PlCheckbox.vue.d.ts.map +1 -1
- package/dist/components/PlCheckbox/PlCheckbox.vue2.js +9 -2
- package/dist/components/PlCheckbox/PlCheckbox.vue2.js.map +1 -1
- package/dist/components/PlCheckbox/PlCheckboxBase.js.map +1 -1
- package/dist/components/PlCheckbox/PlCheckboxBase.vue.d.ts.map +1 -1
- package/dist/components/PlCheckbox/PlCheckboxBase.vue2.js +1 -0
- package/dist/components/PlCheckbox/PlCheckboxBase.vue2.js.map +1 -1
- package/dist/components/PlCheckboxGroup/PlCheckboxGroup.js.map +1 -1
- package/dist/components/PlCheckboxGroup/PlCheckboxGroup.vue.d.ts.map +1 -1
- package/dist/components/PlCheckboxGroup/PlCheckboxGroup.vue2.js +19 -5
- package/dist/components/PlCheckboxGroup/PlCheckboxGroup.vue2.js.map +1 -1
- package/dist/components/PlChip/PlChip.js.map +1 -1
- package/dist/components/PlChip/PlChip.vue.d.ts.map +1 -1
- package/dist/components/PlChip/PlChip.vue2.js +7 -1
- package/dist/components/PlChip/PlChip.vue2.js.map +1 -1
- package/dist/components/PlClipboard/PlClipboard.js.map +1 -1
- package/dist/components/PlClipboard/PlClipboard.style.js.map +1 -1
- package/dist/components/PlClipboard/PlClipboard.vue.d.ts.map +1 -1
- package/dist/components/PlClipboard/PlClipboard.vue2.js +1 -0
- package/dist/components/PlClipboard/PlClipboard.vue2.js.map +1 -1
- package/dist/components/PlConfirmDialog.js.map +1 -1
- package/dist/components/PlConfirmDialog.vue.d.ts.map +1 -1
- package/dist/components/PlConfirmDialog.vue2.js +9 -2
- package/dist/components/PlConfirmDialog.vue2.js.map +1 -1
- package/dist/components/PlDialogModal/PlDialogModal.js.map +1 -1
- package/dist/components/PlDialogModal/PlDialogModal.vue.d.ts.map +1 -1
- package/dist/components/PlDialogModal/PlDialogModal.vue2.js +12 -5
- package/dist/components/PlDialogModal/PlDialogModal.vue2.js.map +1 -1
- package/dist/components/PlDropdown/OptionList.js.map +1 -1
- package/dist/components/PlDropdown/OptionList.vue.d.ts.map +1 -1
- package/dist/components/PlDropdown/OptionList.vue2.js +11 -5
- package/dist/components/PlDropdown/OptionList.vue2.js.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.js.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue.d.ts.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue2.js +26 -10
- package/dist/components/PlDropdown/PlDropdown.vue2.js.map +1 -1
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.js.map +1 -1
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue2.js +32 -10
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue2.js.map +1 -1
- package/dist/components/PlDropdownLine/PlDropdownLine.js.map +1 -1
- package/dist/components/PlDropdownLine/PlDropdownLine.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownLine/PlDropdownLine.vue2.js +17 -3
- package/dist/components/PlDropdownLine/PlDropdownLine.vue2.js.map +1 -1
- package/dist/components/PlDropdownLine/ResizableInput.js.map +1 -1
- package/dist/components/PlDropdownLine/ResizableInput.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownLine/ResizableInput.vue2.js +5 -2
- package/dist/components/PlDropdownLine/ResizableInput.vue2.js.map +1 -1
- package/dist/components/PlDropdownMulti/PlDropdownMulti.js.map +1 -1
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue2.js +31 -10
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue2.js.map +1 -1
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.js.map +1 -1
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.vue2.js +1 -1
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.vue2.js.map +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.js.map +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.vue2.js +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.vue2.js.map +1 -1
- package/dist/components/PlEditableTitle/PlEditableTitle.js.map +1 -1
- package/dist/components/PlEditableTitle/PlEditableTitle.vue.d.ts.map +1 -1
- package/dist/components/PlEditableTitle/PlEditableTitle.vue2.js +9 -3
- package/dist/components/PlEditableTitle/PlEditableTitle.vue2.js.map +1 -1
- package/dist/components/PlElementList/PlElementList.js.map +1 -1
- package/dist/components/PlElementList/PlElementList.style.js.map +1 -1
- package/dist/components/PlElementList/PlElementList.vue.d.ts.map +1 -1
- package/dist/components/PlElementList/PlElementList.vue2.js +6 -1
- package/dist/components/PlElementList/PlElementList.vue2.js.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.js.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.style.js.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue.d.ts.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue2.js +34 -13
- package/dist/components/PlElementList/PlElementListItem.vue2.js.map +1 -1
- package/dist/components/PlErrorAlert/PlErrorAlert.js.map +1 -1
- package/dist/components/PlErrorAlert/PlErrorAlert.style.js.map +1 -1
- package/dist/components/PlErrorAlert/PlErrorAlert.vue.d.ts.map +1 -1
- package/dist/components/PlErrorAlert/PlErrorAlert.vue2.js +15 -3
- package/dist/components/PlErrorAlert/PlErrorAlert.vue2.js.map +1 -1
- package/dist/components/PlErrorBoundary/PlErrorBoundary.js.map +1 -1
- package/dist/components/PlErrorBoundary/PlErrorBoundary.vue.d.ts.map +1 -1
- package/dist/components/PlErrorBoundary/PlErrorBoundary.vue2.js +1 -0
- package/dist/components/PlErrorBoundary/PlErrorBoundary.vue2.js.map +1 -1
- package/dist/components/PlFileDialog/Local.js.map +1 -1
- package/dist/components/PlFileDialog/Local.vue.d.ts.map +1 -1
- package/dist/components/PlFileDialog/Local.vue2.js +23 -20
- package/dist/components/PlFileDialog/Local.vue2.js.map +1 -1
- package/dist/components/PlFileDialog/PlFileDialog.js.map +1 -1
- package/dist/components/PlFileDialog/PlFileDialog.vue.d.ts.map +1 -1
- package/dist/components/PlFileDialog/PlFileDialog.vue2.js +5 -1
- package/dist/components/PlFileDialog/PlFileDialog.vue2.js.map +1 -1
- package/dist/components/PlFileDialog/Remote.js.map +1 -1
- package/dist/components/PlFileDialog/Remote.vue.d.ts.map +1 -1
- package/dist/components/PlFileDialog/Remote.vue2.js +108 -94
- package/dist/components/PlFileDialog/Remote.vue2.js.map +1 -1
- package/dist/components/PlFileDialog/Shortcuts.js.map +1 -1
- package/dist/components/PlFileDialog/Shortcuts.style.js.map +1 -1
- package/dist/components/PlFileDialog/Shortcuts.vue.d.ts.map +1 -1
- package/dist/components/PlFileDialog/Shortcuts.vue2.js +2 -1
- package/dist/components/PlFileDialog/Shortcuts.vue2.js.map +1 -1
- package/dist/components/PlFileInput/PlFileInput.js.map +1 -1
- package/dist/components/PlFileInput/PlFileInput.vue.d.ts.map +1 -1
- package/dist/components/PlFileInput/PlFileInput.vue2.js +92 -71
- package/dist/components/PlFileInput/PlFileInput.vue2.js.map +1 -1
- package/dist/components/PlLoaderCircular/PlLoaderCircular.js.map +1 -1
- package/dist/components/PlLoaderCircular/PlLoaderCircular.vue.d.ts.map +1 -1
- package/dist/components/PlLoaderCircular/PlLoaderCircular.vue2.js +4 -1
- package/dist/components/PlLoaderCircular/PlLoaderCircular.vue2.js.map +1 -1
- package/dist/components/PlLoaderLogo.js.map +1 -1
- package/dist/components/PlLoaderLogo.style.js.map +1 -1
- package/dist/components/PlLoaderLogo.vue.css +1 -1
- package/dist/components/PlLoaderLogo.vue.d.ts.map +1 -1
- package/dist/components/PlLoaderLogo.vue2.js +4 -3
- package/dist/components/PlLoaderLogo.vue2.js.map +1 -1
- package/dist/components/PlLogView/PlLogView.js.map +1 -1
- package/dist/components/PlLogView/PlLogView.vue.d.ts.map +1 -1
- package/dist/components/PlLogView/PlLogView.vue2.js +13 -1
- package/dist/components/PlLogView/PlLogView.vue2.js.map +1 -1
- package/dist/components/PlNotificationAlert/PlNotificationAlert.js.map +1 -1
- package/dist/components/PlNotificationAlert/PlNotificationAlert.vue.d.ts.map +1 -1
- package/dist/components/PlNotificationAlert/PlNotificationAlert.vue2.js +8 -2
- package/dist/components/PlNotificationAlert/PlNotificationAlert.vue2.js.map +1 -1
- package/dist/components/PlNumberField/PlNumberField.js.map +1 -1
- package/dist/components/PlNumberField/PlNumberField.vue.d.ts.map +1 -1
- package/dist/components/PlNumberField/PlNumberField.vue2.js +12 -3
- package/dist/components/PlNumberField/PlNumberField.vue2.js.map +1 -1
- package/dist/components/PlProgressBar/PlProgressBar.js.map +1 -1
- package/dist/components/PlProgressBar/PlProgressBar.vue.d.ts.map +1 -1
- package/dist/components/PlProgressBar/PlProgressBar.vue2.js +9 -1
- package/dist/components/PlProgressBar/PlProgressBar.vue2.js.map +1 -1
- package/dist/components/PlProgressCell/PlProgressCell.js.map +1 -1
- package/dist/components/PlProgressCell/PlProgressCell.vue.d.ts.map +1 -1
- package/dist/components/PlProgressCell/PlProgressCell.vue2.js +19 -7
- package/dist/components/PlProgressCell/PlProgressCell.vue2.js.map +1 -1
- package/dist/components/PlRadio/PlRadio.js.map +1 -1
- package/dist/components/PlRadio/PlRadio.style.js.map +1 -1
- package/dist/components/PlRadio/PlRadio.vue.d.ts.map +1 -1
- package/dist/components/PlRadio/PlRadio.vue2.js +10 -3
- package/dist/components/PlRadio/PlRadio.vue2.js.map +1 -1
- package/dist/components/PlRadio/PlRadioGroup.js.map +1 -1
- package/dist/components/PlRadio/PlRadioGroup.style.js.map +1 -1
- package/dist/components/PlRadio/PlRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/PlRadio/PlRadioGroup.vue2.js +10 -3
- package/dist/components/PlRadio/PlRadioGroup.vue2.js.map +1 -1
- package/dist/components/PlSearchField/PlSearchField.js.map +1 -1
- package/dist/components/PlSearchField/PlSearchField.style.js.map +1 -1
- package/dist/components/PlSearchField/PlSearchField.vue.d.ts.map +1 -1
- package/dist/components/PlSearchField/PlSearchField.vue2.js +11 -4
- package/dist/components/PlSearchField/PlSearchField.vue2.js.map +1 -1
- package/dist/components/PlSectionSeparator/PlSectionSeparator.js.map +1 -1
- package/dist/components/PlSectionSeparator/PlSectionSeparator.style.js.map +1 -1
- package/dist/components/PlSectionSeparator/PlSectionSeparator.vue.d.ts.map +1 -1
- package/dist/components/PlSectionSeparator/PlSectionSeparator.vue2.js +7 -1
- package/dist/components/PlSectionSeparator/PlSectionSeparator.vue2.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarGroup.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarGroup.style.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarGroup.vue.d.ts.map +1 -1
- package/dist/components/PlSidebar/PlSidebarGroup.vue2.js +5 -1
- package/dist/components/PlSidebar/PlSidebarGroup.vue2.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarItem.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarItem.style.js.map +1 -1
- package/dist/components/PlSidebar/PlSidebarItem.vue.d.ts.map +1 -1
- package/dist/components/PlSidebar/PlSidebarItem.vue2.js +7 -1
- package/dist/components/PlSidebar/PlSidebarItem.vue2.js.map +1 -1
- package/dist/components/PlSlideModal/PlPureSlideModal.js.map +1 -1
- package/dist/components/PlSlideModal/PlPureSlideModal.vue.d.ts.map +1 -1
- package/dist/components/PlSlideModal/PlPureSlideModal.vue2.js +4 -1
- package/dist/components/PlSlideModal/PlPureSlideModal.vue2.js.map +1 -1
- package/dist/components/PlSlideModal/PlSlideModal.js.map +1 -1
- package/dist/components/PlSlideModal/PlSlideModal.style.js.map +1 -1
- package/dist/components/PlSlideModal/PlSlideModal.vue.d.ts.map +1 -1
- package/dist/components/PlSlideModal/PlSlideModal.vue2.js +7 -2
- package/dist/components/PlSlideModal/PlSlideModal.vue2.js.map +1 -1
- package/dist/components/PlSpacer/PlSpacer.vue.d.ts.map +1 -1
- package/dist/components/PlSplash/PlSplash.js.map +1 -1
- package/dist/components/PlSplash/PlSplash.vue.d.ts.map +1 -1
- package/dist/components/PlSplash/PlSplash.vue2.js +13 -5
- package/dist/components/PlSplash/PlSplash.vue2.js.map +1 -1
- package/dist/components/PlStatusTag/PlStatusTag.js.map +1 -1
- package/dist/components/PlStatusTag/PlStatusTag.vue.d.ts.map +1 -1
- package/dist/components/PlStatusTag/PlStatusTag.vue2.js +4 -1
- package/dist/components/PlStatusTag/PlStatusTag.vue2.js.map +1 -1
- package/dist/components/PlTabs/PlTabs.js.map +1 -1
- package/dist/components/PlTabs/PlTabs.vue.d.ts.map +1 -1
- package/dist/components/PlTabs/PlTabs.vue2.js +16 -11
- package/dist/components/PlTabs/PlTabs.vue2.js.map +1 -1
- package/dist/components/PlTextArea/PlTextArea.js.map +1 -1
- package/dist/components/PlTextArea/PlTextArea.vue.d.ts.map +1 -1
- package/dist/components/PlTextArea/PlTextArea.vue2.js +21 -8
- package/dist/components/PlTextArea/PlTextArea.vue2.js.map +1 -1
- package/dist/components/PlTextField/PlTextField.js.map +1 -1
- package/dist/components/PlTextField/PlTextField.vue.d.ts.map +1 -1
- package/dist/components/PlTextField/PlTextField.vue2.js +23 -9
- package/dist/components/PlTextField/PlTextField.vue2.js.map +1 -1
- package/dist/components/PlToggleSwitch/PlToggleSwitch.js.map +1 -1
- package/dist/components/PlToggleSwitch/PlToggleSwitch.vue.d.ts.map +1 -1
- package/dist/components/PlToggleSwitch/PlToggleSwitch.vue2.js +10 -2
- package/dist/components/PlToggleSwitch/PlToggleSwitch.vue2.js.map +1 -1
- package/dist/components/PlTooltip/PlTooltip.js.map +1 -1
- package/dist/components/PlTooltip/PlTooltip.style.js.map +1 -1
- package/dist/components/PlTooltip/PlTooltip.vue.css +1 -1
- package/dist/components/PlTooltip/PlTooltip.vue.d.ts.map +1 -1
- package/dist/components/PlTooltip/PlTooltip.vue2.js +7 -2
- package/dist/components/PlTooltip/PlTooltip.vue2.js.map +1 -1
- package/dist/components/Slider.js.map +1 -1
- package/dist/components/Slider.vue.d.ts.map +1 -1
- package/dist/components/Slider.vue2.js +13 -1
- package/dist/components/Slider.vue2.js.map +1 -1
- package/dist/components/SliderRange.js.map +1 -1
- package/dist/components/SliderRange.vue.d.ts.map +1 -1
- package/dist/components/SliderRange.vue2.js +14 -1
- package/dist/components/SliderRange.vue2.js.map +1 -1
- package/dist/components/SliderRangeTriple.js.map +1 -1
- package/dist/components/SliderRangeTriple.vue.d.ts.map +1 -1
- package/dist/components/SliderRangeTriple.vue2.js +13 -1
- package/dist/components/SliderRangeTriple.vue2.js.map +1 -1
- package/dist/components/TabItem.js.map +1 -1
- package/dist/components/TabItem.vue.d.ts.map +1 -1
- package/dist/components/TabItem.vue2.js +8 -2
- package/dist/components/TabItem.vue2.js.map +1 -1
- package/dist/components/contextMenu/Menu.js +1 -1
- package/dist/components/contextMenu/Menu.js.map +1 -1
- package/dist/components/contextMenu/Menu.style.css +1 -1
- package/dist/components/contextMenu/Menu.vue.d.ts.map +1 -1
- package/dist/components/contextMenu/Menu.vue2.js +12 -8
- package/dist/components/contextMenu/Menu.vue2.js.map +1 -1
- package/dist/layout/PlBlockPage/PlBlockPage.js.map +1 -1
- package/dist/layout/PlBlockPage/PlBlockPage.style.js.map +1 -1
- package/dist/layout/PlBlockPage/PlBlockPage.vue.d.ts.map +1 -1
- package/dist/layout/PlBlockPage/PlBlockPage.vue2.js +45 -25
- package/dist/layout/PlBlockPage/PlBlockPage.vue2.js.map +1 -1
- package/dist/layout/PlContainer/PlContainer.js.map +1 -1
- package/dist/layout/PlContainer/PlContainer.vue.d.ts.map +1 -1
- package/dist/layout/PlContainer/PlContainer.vue2.js +1 -0
- package/dist/layout/PlContainer/PlContainer.vue2.js.map +1 -1
- package/dist/layout/PlGrid/PlGrid.js.map +1 -1
- package/dist/layout/PlGrid/PlGrid.vue.d.ts.map +1 -1
- package/dist/layout/PlGrid/PlGrid.vue2.js +1 -0
- package/dist/layout/PlGrid/PlGrid.vue2.js.map +1 -1
- package/dist/layout/PlPlaceholder/PlPlaceholder.js.map +1 -1
- package/dist/layout/PlPlaceholder/PlPlaceholder.style.js.map +1 -1
- package/dist/layout/PlPlaceholder/PlPlaceholder.vue.d.ts.map +1 -1
- package/dist/layout/PlPlaceholder/PlPlaceholder.vue2.js +25 -6
- package/dist/layout/PlPlaceholder/PlPlaceholder.vue2.js.map +1 -1
- package/dist/layout/PlRow/PlRow.js.map +1 -1
- package/dist/layout/PlRow/PlRow.vue.d.ts.map +1 -1
- package/dist/layout/PlRow/PlRow.vue2.js +7 -4
- package/dist/layout/PlRow/PlRow.vue2.js.map +1 -1
- package/dist/layout/PlSpacer/PlSpacer.js.map +1 -1
- package/dist/layout/PlSpacer/PlSpacer.vue.d.ts.map +1 -1
- package/dist/layout/PlSpacer/PlSpacer.vue2.js +1 -0
- package/dist/layout/PlSpacer/PlSpacer.vue2.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/default-testid.test.ts +95 -0
- package/src/base/BtnBase.vue +3 -3
- package/src/components/DropdownListItem.vue +14 -4
- package/src/components/InputRange.vue +6 -2
- package/src/components/PlAccordion/PlAccordionSection.vue +13 -4
- package/src/components/PlAlert/PlAlert.vue +5 -3
- package/src/components/PlAutocomplete/PlAutocomplete.vue +47 -11
- package/src/components/PlAutocompleteMulti/PlAutocompleteMulti.vue +53 -11
- package/src/components/PlBtnAccent/PlBtnAccent.vue +1 -1
- package/src/components/PlBtnDanger/PlBtnDanger.vue +1 -1
- package/src/components/PlBtnGhost/PlBtnGhost.vue +4 -3
- package/src/components/PlBtnGroup/PlBtnGroup.vue +16 -6
- package/src/components/PlBtnLink/PlBtnLink.vue +2 -1
- package/src/components/PlBtnPrimary/PlBtnPrimary.vue +1 -1
- package/src/components/PlBtnSecondary/PlBtnSecondary.vue +1 -1
- package/src/components/PlBtnSplit/PlBtnSplit.vue +12 -2
- package/src/components/PlChartHistogram/PlChartHistogram.vue +9 -3
- package/src/components/PlChartHistogram/createGridlines.ts +2 -0
- package/src/components/PlChartHistogram/createLabels.ts +2 -0
- package/src/components/PlChartHistogram/createSvgContainer.ts +2 -0
- package/src/components/PlChartHistogram/drawBins.ts +2 -0
- package/src/components/PlChartHistogram/drawThreshold.ts +1 -0
- package/src/components/PlChartHistogram/histogram.ts +6 -1
- package/src/components/PlChartStackedBar/Legends.vue +18 -4
- package/src/components/PlChartStackedBar/PlChartStackedBar.vue +4 -2
- package/src/components/PlChartStackedBar/PlChartStackedBarCompact.vue +1 -1
- package/src/components/PlChartStackedBar/StackedRow.vue +12 -4
- package/src/components/PlChartStackedBar/StackedRowCompact.vue +10 -3
- package/src/components/PlCheckbox/PlCheckbox.vue +15 -4
- package/src/components/PlCheckbox/PlCheckboxBase.vue +1 -0
- package/src/components/PlCheckboxGroup/PlCheckboxGroup.vue +15 -4
- package/src/components/PlChip/PlChip.vue +4 -3
- package/src/components/PlClipboard/PlClipboard.vue +7 -1
- package/src/components/PlConfirmDialog.vue +8 -3
- package/src/components/PlDialogModal/PlDialogModal.vue +15 -2
- package/src/components/PlDropdown/OptionList.vue +13 -3
- package/src/components/PlDropdown/PlDropdown.vue +35 -11
- package/src/components/PlDropdownLegacy/PlDropdownLegacy.vue +51 -12
- package/src/components/PlDropdownLine/PlDropdownLine.vue +29 -5
- package/src/components/PlDropdownLine/ResizableInput.vue +2 -1
- package/src/components/PlDropdownMulti/PlDropdownMulti.vue +47 -11
- package/src/components/PlDropdownMultiRef/PlDropdownMultiRef.vue +1 -0
- package/src/components/PlDropdownRef/PlDropdownRef.vue +1 -0
- package/src/components/PlEditableTitle/PlEditableTitle.vue +11 -3
- package/src/components/PlElementList/PlElementList.vue +8 -3
- package/src/components/PlElementList/PlElementListItem.vue +16 -5
- package/src/components/PlErrorAlert/PlErrorAlert.vue +8 -6
- package/src/components/PlErrorBoundary/PlErrorBoundary.vue +7 -1
- package/src/components/PlFileDialog/Local.vue +12 -4
- package/src/components/PlFileDialog/PlFileDialog.vue +13 -3
- package/src/components/PlFileDialog/Remote.vue +39 -11
- package/src/components/PlFileDialog/Shortcuts.vue +7 -1
- package/src/components/PlFileInput/PlFileInput.vue +44 -19
- package/src/components/PlLoaderCircular/PlLoaderCircular.vue +1 -1
- package/src/components/PlLoaderLogo.vue +6 -1
- package/src/components/PlLogView/PlLogView.vue +30 -8
- package/src/components/PlNotificationAlert/PlNotificationAlert.vue +15 -3
- package/src/components/PlNumberField/PlNumberField.vue +14 -3
- package/src/components/PlProgressBar/PlProgressBar.vue +12 -4
- package/src/components/PlProgressCell/PlProgressCell.vue +13 -4
- package/src/components/PlRadio/PlRadio.vue +10 -3
- package/src/components/PlRadio/PlRadioGroup.vue +3 -2
- package/src/components/PlSearchField/PlSearchField.vue +5 -3
- package/src/components/PlSectionSeparator/PlSectionSeparator.vue +6 -2
- package/src/components/PlSidebar/PlSidebarGroup.vue +2 -2
- package/src/components/PlSidebar/PlSidebarItem.vue +12 -4
- package/src/components/PlSlideModal/PlPureSlideModal.vue +7 -1
- package/src/components/PlSlideModal/PlSlideModal.vue +4 -3
- package/src/components/PlSpacer/PlSpacer.vue +1 -1
- package/src/components/PlSplash/PlSplash.vue +6 -3
- package/src/components/PlStatusTag/PlStatusTag.vue +1 -0
- package/src/components/PlTabs/PlTabs.vue +6 -2
- package/src/components/PlTextArea/PlTextArea.vue +21 -8
- package/src/components/PlTextField/PlTextField.vue +23 -8
- package/src/components/PlToggleSwitch/PlToggleSwitch.vue +4 -3
- package/src/components/PlTooltip/PlTooltip.vue +3 -0
- package/src/components/Slider.vue +27 -7
- package/src/components/SliderRange.vue +28 -7
- package/src/components/SliderRangeTriple.vue +19 -5
- package/src/components/TabItem.vue +2 -2
- package/src/components/contextMenu/Menu.vue +8 -3
- package/src/layout/PlBlockPage/PlBlockPage.vue +40 -11
- package/src/layout/PlContainer/PlContainer.vue +1 -0
- package/src/layout/PlGrid/PlGrid.vue +1 -1
- package/src/layout/PlPlaceholder/PlPlaceholder.vue +20 -8
- package/src/layout/PlRow/PlRow.vue +5 -1
- package/src/layout/PlSpacer/PlSpacer.vue +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlTooltip.vue_vue_type_script_setup_true_lang.js","names":["$style","$attrs","$slots"],"sources":["../../../src/components/PlTooltip/PlTooltip.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Simple tooltip on mouseover */\nexport default {\n name: \"PlTooltip\",\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport { uniqueId } from \"@milaboratories/helpers\";\nimport { onUnmounted, reactive, ref, watch } from \"vue\";\nimport { tMap } from \"./global\";\nimport * as utils from \"../../helpers/utils\";\nimport { useClickOutside } from \"../../composition/useClickOutside\";\n\nconst emit = defineEmits([\"tooltip:close\"]);\n\nconst tKey = Symbol();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * delay in milliseconds before the tooltip opens\n */\n openDelay?: number;\n /**\n * delay in milliseconds before the tooltip disappears\n */\n closeDelay?: number;\n /**\n * Tooltip position\n */\n position?: \"top\" | \"left\" | \"bottom\" | \"right\" | \"top-left\";\n /**\n * external prop to hide tooltips\n */\n hide?: boolean;\n /**\n * The gap in pixels between the tooltip and the target element\n */\n gap?: number;\n\n /**\n * The minimum offset in pixels from the edge of the screen to the tooltip\n */\n offsetToTheEdge?: number;\n /**\n * base html element for tooltip\n */\n element?: \"div\" | \"span\" | \"a\" | \"p\" | \"h1\" | \"h2\" | \"h3\";\n /**\n * Max width (css value) of the tooltip container (default is 300px)\n */\n maxWidth?: string;\n /**\n * The container to insert the tooltip to (body by default)\n */\n container?: \"body\" | HTMLElement;\n /**\n * Whether the tooltip is shown on hover (default is true); otherwise, it is shown when hide is set to false\n */\n hoverable?: boolean;\n }>(),\n {\n openDelay: 100,\n closeDelay: 1000,\n gap: 8,\n offsetToTheEdge: 8,\n position: \"top\",\n element: \"div\",\n maxWidth: \"300px\",\n container: \"body\",\n hoverable: true,\n },\n);\n\nconst data = reactive({\n open: false,\n over: false,\n tooltipOpen: false,\n key: Symbol(),\n});\n\ntMap.set(tKey, () => closeTooltip());\n\n// Hook to avoid the need to immediately teleport into the body (better performance)\nwatch(\n () => data.open,\n (v) => {\n requestAnimationFrame(() => {\n data.tooltipOpen = v;\n });\n },\n);\n\nlet clearTimeout = () => {};\n\nconst showTooltip = () => {\n data.open = true;\n\n for (const [k, f] of tMap.entries()) {\n if (k !== tKey) {\n f();\n }\n }\n};\n\nconst closeTooltip = () => {\n data.open = false;\n emit(\"tooltip:close\");\n};\n\nconst onOver = async () => {\n if (props.hide || !props.hoverable) {\n return;\n }\n\n data.over = true;\n\n clearTimeout();\n\n await utils.delay(props.openDelay ?? 100);\n\n if (data.over) {\n showTooltip();\n }\n};\n\nconst onLeave = () => {\n if (!props.hoverable) {\n return;\n }\n\n data.over = false;\n clearTimeout = utils.timeout(() => {\n if (!data.over) {\n closeTooltip();\n }\n }, props.closeDelay);\n};\n\nwatch(\n () => props.hide,\n (hide) => {\n if (hide) {\n closeTooltip();\n } else if (!props.hoverable) {\n showTooltip();\n }\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst tooltip = ref<HTMLElement | undefined>();\n\nuseClickOutside([rootRef, tooltip], () => closeTooltip());\n\nonUnmounted(() => {\n tMap.delete(tKey);\n});\nconst anchorName = `--anchor-${uniqueId()}`;\n</script>\n\n<template>\n <component\n :class=\"$style.plTooltipAnchorWrapper\"\n :is=\"element\"\n v-bind=\"$attrs\"\n ref=\"rootRef\"\n @click=\"onOver\"\n @mouseover=\"onOver\"\n @mouseleave=\"onLeave\"\n >\n <!-- anchor element here -->\n <slot />\n <Transition name=\"pl-tooltip-fade\">\n <Teleport v-if=\"$slots['tooltip'] && data.tooltipOpen\" :to=\"container\">\n <div\n :class=\"[\n $style.plTooltipContainer,\n {\n [$style.top]: props.position === 'top',\n [$style.bottom]: props.position === 'bottom',\n [$style.left]: props.position === 'left',\n [$style.right]: props.position === 'right',\n [$style.topLeft]: props.position === 'top-left',\n },\n ]\"\n :style=\"{\n '--anchorName': anchorName,\n '--gap': gap + 'px',\n '--offsetToTheEdge': offsetToTheEdge + 'px',\n '--plTooltipMaxWidth': maxWidth,\n }\"\n >\n <div :class=\"$style.plTooltipBox\" @click.stop>\n <div\n ref=\"tooltip\"\n :class=\"[$style.plTooltipContent, position]\"\n @mouseover=\"onOver\"\n @mouseleave=\"onLeave\"\n >\n <!-- should be one line -->\n <div><slot name=\"tooltip\" /></div>\n </div>\n </div>\n <div :class=\"$style.plTooltipBeak\" />\n </div>\n </Teleport>\n </Transition>\n </component>\n</template>\n\n<style module>\n.plTooltipAnchorWrapper {\n display: inline-block;\n}\n/* just to set anchor-name for the anchor */\n.plTooltipAnchorWrapper > :first-child {\n --anchorName: v-bind(\"anchorName\");\n anchor-name: var(--anchorName);\n}\n\n.plTooltipAnchorWrapper:global(.info) {\n --anchorName: v-bind(\"anchorName\");\n anchor-name: var(--anchorName);\n}\n\n.plTooltipContainer {\n --plTooltipMaxWidth: 300px;\n --gap: 8px;\n --tailWidth: 8px;\n --tailHeight: calc(var(--gap) + 2px);\n\n --tailClipTop: polygon(\n 0 0,\n 100% 0,\n 100% calc(100% - var(--gap)),\n 50% calc(100% - 3px),\n 0 calc(100% - var(--gap))\n );\n --tailClipBottom: polygon(0 100%, 100% 100%, 100% var(--gap), 50% 3px, 0 var(--gap));\n --tailClipLeft: polygon(0 0, 0 100%, 2px 100%, calc(100% - 3px) 50%, 2px 0);\n --tailClipRight: polygon(100% 0, 100% 100%, calc(100% - 2px) 100%, 3px 50%, calc(100% - 2px) 0);\n\n z-index: var(--z-tooltip);\n}\n\n.plTooltipContent {\n display: inline-block;\n padding: 8px 12px 9px 12px;\n background: var(--tooltip-bg);\n border-radius: 6px;\n width: max-content;\n word-break: normal;\n max-width: var(--plTooltipMaxWidth);\n color: #fff;\n}\n\n.plTooltipBox {\n position: absolute;\n position-anchor: var(--anchorName);\n z-index: 1;\n}\n\n.plTooltipBeak {\n position: absolute;\n position-anchor: var(--anchorName);\n z-index: 0;\n background: var(--tooltip-bg);\n width: var(--tailWidth);\n height: var(--tailHeight);\n}\n\n/* top */\n.plTooltipContainer.top .plTooltipBox {\n position-area: top;\n bottom: var(--gap);\n left: var(--offsetToTheEdge);\n right: var(--offsetToTheEdge);\n}\n.plTooltipContainer.top .plTooltipBeak {\n position-area: top;\n bottom: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipTop);\n}\n\n/* bottom */\n.plTooltipContainer.bottom .plTooltipBox {\n position-area: bottom;\n top: var(--gap);\n left: var(--offsetToTheEdge);\n right: var(--offsetToTheEdge);\n}\n.plTooltipContainer.bottom .plTooltipBeak {\n position-area: bottom;\n top: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipBottom);\n}\n\n/* left */\n.plTooltipContainer.left .plTooltipBox {\n position-area: left;\n right: var(--gap);\n top: var(--offsetToTheEdge);\n bottom: var(--offsetToTheEdge);\n}\n\n.plTooltipContainer.left .plTooltipBeak {\n position-area: left;\n right: 0;\n top: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n width: var(--tailHeight);\n height: var(--tailWidth);\n clip-path: var(--tailClipLeft);\n}\n\n/* right */\n.plTooltipContainer.right .plTooltipBox {\n position-area: right;\n left: var(--gap);\n top: var(--offsetToTheEdge);\n bottom: var(--offsetToTheEdge);\n}\n\n.plTooltipContainer.right .plTooltipBeak {\n position-area: right;\n left: 0;\n top: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n width: var(--tailHeight);\n height: var(--tailWidth);\n clip-path: var(--tailClipRight);\n}\n\n/* top left */\n.plTooltipContainer.topLeft .plTooltipBox {\n position-area: top;\n bottom: var(--gap);\n left: anchor(var(--anchorName) left);\n}\n.plTooltipContainer.topLeft .plTooltipBeak {\n position-area: top;\n bottom: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipTop);\n}\n\n:global(.pl-tooltip-fade-leave-active),\n:global(.pl-tooltip-fade-enter-active) {\n z-index: var(--z-tooltip);\n transition: opacity 0.2s ease-in-out;\n}\n:global(.pl-tooltip-fade-enter-from),\n:global(.pl-tooltip-fade-leave-to) {\n opacity: 0;\n}\n\n.plTooltipContent a {\n color: var(--tooltip-link-color);\n}\n\n.plTooltipContent p {\n margin-bottom: 8px;\n}\n\n.plTooltipContent ul,\n.plTooltipContent li {\n margin-left: 6px;\n padding-left: 6px;\n}\n\n.plTooltipContent li {\n margin-bottom: 4px;\n}\n</style>\n"],"mappings":";;;;;;CAGE,MAAM;;;;;;;;;;;;;;;;;;;EAWR,IAAM,IAAO,GAEP,IAAO,QAAQ,EAEf,IAAQ,GAyDR,IAAO,EAAS;GACpB,MAAM;GACN,MAAM;GACN,aAAa;GACb,KAAK,QAAQ;GACd,CAAC;AAKF,EAHA,EAAK,IAAI,SAAY,GAAc,CAAC,EAGpC,QACQ,EAAK,OACV,MAAM;AACL,+BAA4B;AAC1B,MAAK,cAAc;KACnB;IAEL;EAED,IAAI,UAAqB,IAEnB,UAAoB;AACxB,KAAK,OAAO;AAEZ,QAAK,IAAM,CAAC,GAAG,MAAM,EAAK,SAAS,CACjC,CAAI,MAAM,KACR,GAAG;KAKH,UAAqB;AAEzB,GADA,EAAK,OAAO,IACZ,EAAK,gBAAgB;KAGjB,IAAS,YAAY;AACrB,KAAM,QAAQ,CAAC,EAAM,cAIzB,EAAK,OAAO,IAEZ,GAAc,EAEd,MAAM,EAAY,EAAM,aAAa,IAAI,EAErC,EAAK,QACP,GAAa;KAIX,UAAgB;AACf,KAAM,cAIX,EAAK,OAAO,IACZ,IAAe,QAAoB;AACjC,IAAK,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AY;QAGb,EAAkC,OAAA,MAAA,CAA7B,EAAuB,EAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,GAAA,CAAA,EAAA,EAAA,EAGhC,EAAqC,OAAA,EAA/B,OAAK,EAAEA,EAAAA,OAAO,cAAa,EAAA,EAAA,MAAA,EAAA,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,CAAA,KAAA,CAAA,IAAA,EAAA,IAAA,GAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"PlTooltip.vue_vue_type_script_setup_true_lang.js","names":["$style","$attrs","$slots"],"sources":["../../../src/components/PlTooltip/PlTooltip.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Simple tooltip on mouseover */\nexport default {\n name: \"PlTooltip\",\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport { uniqueId } from \"@milaboratories/helpers\";\nimport { onUnmounted, reactive, ref, watch } from \"vue\";\nimport { tMap } from \"./global\";\nimport * as utils from \"../../helpers/utils\";\nimport { useClickOutside } from \"../../composition/useClickOutside\";\n\nconst emit = defineEmits([\"tooltip:close\"]);\n\nconst tKey = Symbol();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * delay in milliseconds before the tooltip opens\n */\n openDelay?: number;\n /**\n * delay in milliseconds before the tooltip disappears\n */\n closeDelay?: number;\n /**\n * Tooltip position\n */\n position?: \"top\" | \"left\" | \"bottom\" | \"right\" | \"top-left\";\n /**\n * external prop to hide tooltips\n */\n hide?: boolean;\n /**\n * The gap in pixels between the tooltip and the target element\n */\n gap?: number;\n\n /**\n * The minimum offset in pixels from the edge of the screen to the tooltip\n */\n offsetToTheEdge?: number;\n /**\n * base html element for tooltip\n */\n element?: \"div\" | \"span\" | \"a\" | \"p\" | \"h1\" | \"h2\" | \"h3\";\n /**\n * Max width (css value) of the tooltip container (default is 300px)\n */\n maxWidth?: string;\n /**\n * The container to insert the tooltip to (body by default)\n */\n container?: \"body\" | HTMLElement;\n /**\n * Whether the tooltip is shown on hover (default is true); otherwise, it is shown when hide is set to false\n */\n hoverable?: boolean;\n }>(),\n {\n openDelay: 100,\n closeDelay: 1000,\n gap: 8,\n offsetToTheEdge: 8,\n position: \"top\",\n element: \"div\",\n maxWidth: \"300px\",\n container: \"body\",\n hoverable: true,\n },\n);\n\nconst data = reactive({\n open: false,\n over: false,\n tooltipOpen: false,\n key: Symbol(),\n});\n\ntMap.set(tKey, () => closeTooltip());\n\n// Hook to avoid the need to immediately teleport into the body (better performance)\nwatch(\n () => data.open,\n (v) => {\n requestAnimationFrame(() => {\n data.tooltipOpen = v;\n });\n },\n);\n\nlet clearTimeout = () => {};\n\nconst showTooltip = () => {\n data.open = true;\n\n for (const [k, f] of tMap.entries()) {\n if (k !== tKey) {\n f();\n }\n }\n};\n\nconst closeTooltip = () => {\n data.open = false;\n emit(\"tooltip:close\");\n};\n\nconst onOver = async () => {\n if (props.hide || !props.hoverable) {\n return;\n }\n\n data.over = true;\n\n clearTimeout();\n\n await utils.delay(props.openDelay ?? 100);\n\n if (data.over) {\n showTooltip();\n }\n};\n\nconst onLeave = () => {\n if (!props.hoverable) {\n return;\n }\n\n data.over = false;\n clearTimeout = utils.timeout(() => {\n if (!data.over) {\n closeTooltip();\n }\n }, props.closeDelay);\n};\n\nwatch(\n () => props.hide,\n (hide) => {\n if (hide) {\n closeTooltip();\n } else if (!props.hoverable) {\n showTooltip();\n }\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst tooltip = ref<HTMLElement | undefined>();\n\nuseClickOutside([rootRef, tooltip], () => closeTooltip());\n\nonUnmounted(() => {\n tMap.delete(tKey);\n});\nconst anchorName = `--anchor-${uniqueId()}`;\n</script>\n\n<template>\n <component\n :class=\"$style.plTooltipAnchorWrapper\"\n :is=\"element\"\n data-testid=\"pl-tooltip\"\n v-bind=\"$attrs\"\n ref=\"rootRef\"\n @click=\"onOver\"\n @mouseover=\"onOver\"\n @mouseleave=\"onLeave\"\n >\n <!-- anchor element here -->\n <slot />\n <Transition name=\"pl-tooltip-fade\">\n <Teleport v-if=\"$slots['tooltip'] && data.tooltipOpen\" :to=\"container\">\n <div\n data-testid=\"pl-tooltip-popup\"\n :class=\"[\n $style.plTooltipContainer,\n {\n [$style.top]: props.position === 'top',\n [$style.bottom]: props.position === 'bottom',\n [$style.left]: props.position === 'left',\n [$style.right]: props.position === 'right',\n [$style.topLeft]: props.position === 'top-left',\n },\n ]\"\n :style=\"{\n '--anchorName': anchorName,\n '--gap': gap + 'px',\n '--offsetToTheEdge': offsetToTheEdge + 'px',\n '--plTooltipMaxWidth': maxWidth,\n }\"\n >\n <div :class=\"$style.plTooltipBox\" @click.stop>\n <div\n ref=\"tooltip\"\n data-testid=\"pl-tooltip-content\"\n :class=\"[$style.plTooltipContent, position]\"\n @mouseover=\"onOver\"\n @mouseleave=\"onLeave\"\n >\n <!-- should be one line -->\n <div><slot name=\"tooltip\" /></div>\n </div>\n </div>\n <div :class=\"$style.plTooltipBeak\" />\n </div>\n </Teleport>\n </Transition>\n </component>\n</template>\n\n<style module>\n.plTooltipAnchorWrapper {\n display: inline-block;\n}\n/* just to set anchor-name for the anchor */\n.plTooltipAnchorWrapper > :first-child {\n --anchorName: v-bind(\"anchorName\");\n anchor-name: var(--anchorName);\n}\n\n.plTooltipAnchorWrapper:global(.info) {\n --anchorName: v-bind(\"anchorName\");\n anchor-name: var(--anchorName);\n}\n\n.plTooltipContainer {\n --plTooltipMaxWidth: 300px;\n --gap: 8px;\n --tailWidth: 8px;\n --tailHeight: calc(var(--gap) + 2px);\n\n --tailClipTop: polygon(\n 0 0,\n 100% 0,\n 100% calc(100% - var(--gap)),\n 50% calc(100% - 3px),\n 0 calc(100% - var(--gap))\n );\n --tailClipBottom: polygon(0 100%, 100% 100%, 100% var(--gap), 50% 3px, 0 var(--gap));\n --tailClipLeft: polygon(0 0, 0 100%, 2px 100%, calc(100% - 3px) 50%, 2px 0);\n --tailClipRight: polygon(100% 0, 100% 100%, calc(100% - 2px) 100%, 3px 50%, calc(100% - 2px) 0);\n\n z-index: var(--z-tooltip);\n}\n\n.plTooltipContent {\n display: inline-block;\n padding: 8px 12px 9px 12px;\n background: var(--tooltip-bg);\n border-radius: 6px;\n width: max-content;\n word-break: normal;\n max-width: var(--plTooltipMaxWidth);\n color: #fff;\n}\n\n.plTooltipBox {\n position: absolute;\n position-anchor: var(--anchorName);\n z-index: 1;\n}\n\n.plTooltipBeak {\n position: absolute;\n position-anchor: var(--anchorName);\n z-index: 0;\n background: var(--tooltip-bg);\n width: var(--tailWidth);\n height: var(--tailHeight);\n}\n\n/* top */\n.plTooltipContainer.top .plTooltipBox {\n position-area: top;\n bottom: var(--gap);\n left: var(--offsetToTheEdge);\n right: var(--offsetToTheEdge);\n}\n.plTooltipContainer.top .plTooltipBeak {\n position-area: top;\n bottom: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipTop);\n}\n\n/* bottom */\n.plTooltipContainer.bottom .plTooltipBox {\n position-area: bottom;\n top: var(--gap);\n left: var(--offsetToTheEdge);\n right: var(--offsetToTheEdge);\n}\n.plTooltipContainer.bottom .plTooltipBeak {\n position-area: bottom;\n top: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipBottom);\n}\n\n/* left */\n.plTooltipContainer.left .plTooltipBox {\n position-area: left;\n right: var(--gap);\n top: var(--offsetToTheEdge);\n bottom: var(--offsetToTheEdge);\n}\n\n.plTooltipContainer.left .plTooltipBeak {\n position-area: left;\n right: 0;\n top: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n width: var(--tailHeight);\n height: var(--tailWidth);\n clip-path: var(--tailClipLeft);\n}\n\n/* right */\n.plTooltipContainer.right .plTooltipBox {\n position-area: right;\n left: var(--gap);\n top: var(--offsetToTheEdge);\n bottom: var(--offsetToTheEdge);\n}\n\n.plTooltipContainer.right .plTooltipBeak {\n position-area: right;\n left: 0;\n top: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n width: var(--tailHeight);\n height: var(--tailWidth);\n clip-path: var(--tailClipRight);\n}\n\n/* top left */\n.plTooltipContainer.topLeft .plTooltipBox {\n position-area: top;\n bottom: var(--gap);\n left: anchor(var(--anchorName) left);\n}\n.plTooltipContainer.topLeft .plTooltipBeak {\n position-area: top;\n bottom: 0;\n left: calc(anchor(var(--anchorName) center) - var(--tailWidth) / 2);\n clip-path: var(--tailClipTop);\n}\n\n:global(.pl-tooltip-fade-leave-active),\n:global(.pl-tooltip-fade-enter-active) {\n z-index: var(--z-tooltip);\n transition: opacity 0.2s ease-in-out;\n}\n:global(.pl-tooltip-fade-enter-from),\n:global(.pl-tooltip-fade-leave-to) {\n opacity: 0;\n}\n\n.plTooltipContent a {\n color: var(--tooltip-link-color);\n}\n\n.plTooltipContent p {\n margin-bottom: 8px;\n}\n\n.plTooltipContent ul,\n.plTooltipContent li {\n margin-left: 6px;\n padding-left: 6px;\n}\n\n.plTooltipContent li {\n margin-bottom: 4px;\n}\n</style>\n"],"mappings":";;;;;;CAGE,MAAM;;;;;;;;;;;;;;;;;;;EAWR,IAAM,IAAO,GAEP,IAAO,QAAQ,EAEf,IAAQ,GAyDR,IAAO,EAAS;GACpB,MAAM;GACN,MAAM;GACN,aAAa;GACb,KAAK,QAAQ;GACd,CAAC;AAKF,EAHA,EAAK,IAAI,SAAY,GAAc,CAAC,EAGpC,QACQ,EAAK,OACV,MAAM;AACL,+BAA4B;AAC1B,MAAK,cAAc;KACnB;IAEL;EAED,IAAI,UAAqB,IAEnB,UAAoB;AACxB,KAAK,OAAO;AAEZ,QAAK,IAAM,CAAC,GAAG,MAAM,EAAK,SAAS,CACjC,CAAI,MAAM,KACR,GAAG;KAKH,UAAqB;AAEzB,GADA,EAAK,OAAO,IACZ,EAAK,gBAAgB;KAGjB,IAAS,YAAY;AACrB,KAAM,QAAQ,CAAC,EAAM,cAIzB,EAAK,OAAO,IAEZ,GAAc,EAEd,MAAM,EAAY,EAAM,aAAa,IAAI,EAErC,EAAK,QACP,G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KAAI;KACJ,eAAY;KACX,OAAK,EAAA,CAAGA,EAAAA,OAAO,kBAAkB,EAAA,SAAQ,CAAA;KACzC,aAAW;KACX,cAAY;QAGb,EAAkC,OAAA,MAAA,CAA7B,EAAuB,EAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,GAAA,CAAA,EAAA,EAAA,EAGhC,EAAqC,OAAA,EAA/B,OAAK,EAAEA,EAAAA,OAAO,cAAa,EAAA,EAAA,MAAA,EAAA,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,CAAA,KAAA,CAAA,IAAA,EAAA,IAAA,GAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","names":[],"sources":["../../src/components/Slider.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: number;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue: 0,\n});\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue = computed(() => {\n return clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max);\n});\n\nconst realtimeVal = ref(props.modelValue);\n\nconst error = computed(() => {\n const v = props.modelValue;\n\n if (!Number.isFinite(v)) {\n return \"Not a number\";\n }\n\n if (v < props.min) {\n return `Min value: ${props.min}`;\n }\n\n if (v > props.max) {\n return `Max value: ${props.max}`;\n }\n\n return getErrorMessage(props.error);\n});\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst position = computed(() => {\n return (localValue.value - props.min) / range.value;\n});\n\nconst progressStyle = computed(() => ({\n right: Math.ceil((1 - position.value) * 100) + \"%\",\n}));\n\nconst thumbStyle = computed(() => {\n const value = Math.ceil((1 - position.value) * 100);\n return {\n right: `calc(${value}%) `,\n };\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef = ref<HTMLElement>();\n\nwatch(\n () => props.modelValue,\n (val) => {\n realtimeVal.value = val;\n },\n);\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nuseMouseCapture(thumbRef, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue = (dx / rect.width) * range.value;\n\n realtimeVal.value = round(\n clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max),\n );\n\n if (ev.stop) {\n emit(\"update:modelValue\", round(localValue.value));\n data.deltaValue = 0;\n }\n });\n});\n\nfunction setModelValue(value: number) {\n emit(\"update:modelValue\", round(value));\n}\n\nfunction updateModelValue(event: Event) {\n setModelValue(+(event.target as HTMLInputElement).value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n setModelValue(props.modelValue + nextStep);\n}\n</script>\n\n<template>\n <div
|
|
1
|
+
{"version":3,"file":"Slider.js","names":[],"sources":["../../src/components/Slider.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: number;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue: 0,\n});\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue = computed(() => {\n return clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max);\n});\n\nconst realtimeVal = ref(props.modelValue);\n\nconst error = computed(() => {\n const v = props.modelValue;\n\n if (!Number.isFinite(v)) {\n return \"Not a number\";\n }\n\n if (v < props.min) {\n return `Min value: ${props.min}`;\n }\n\n if (v > props.max) {\n return `Max value: ${props.max}`;\n }\n\n return getErrorMessage(props.error);\n});\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst position = computed(() => {\n return (localValue.value - props.min) / range.value;\n});\n\nconst progressStyle = computed(() => ({\n right: Math.ceil((1 - position.value) * 100) + \"%\",\n}));\n\nconst thumbStyle = computed(() => {\n const value = Math.ceil((1 - position.value) * 100);\n return {\n right: `calc(${value}%) `,\n };\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef = ref<HTMLElement>();\n\nwatch(\n () => props.modelValue,\n (val) => {\n realtimeVal.value = val;\n },\n);\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nuseMouseCapture(thumbRef, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue = (dx / rect.width) * range.value;\n\n realtimeVal.value = round(\n clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max),\n );\n\n if (ev.stop) {\n emit(\"update:modelValue\", round(localValue.value));\n data.deltaValue = 0;\n }\n });\n});\n\nfunction setModelValue(value: number) {\n emit(\"update:modelValue\", round(value));\n}\n\nfunction updateModelValue(event: Event) {\n setModelValue(+(event.target as HTMLInputElement).value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n setModelValue(props.modelValue + nextStep);\n}\n</script>\n\n<template>\n <div\n data-testid=\"pl-slider\"\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" data-testid=\"pl-slider-label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"slots.tooltip\"\n data-testid=\"pl-slider-tooltip\"\n class=\"info\"\n position=\"top\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div\n v-if=\"props.mode === 'text'\"\n data-testid=\"pl-slider-value\"\n class=\"ui-slider__value-static text-s\"\n >\n {{ realtimeVal }}{{ measure }}\n </div>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" data-testid=\"pl-slider-bar\" class=\"ui-slider__bar\">\n <div\n data-testid=\"pl-slider-progress\"\n class=\"ui-slider__progress\"\n :style=\"progressStyle\"\n />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n data-testid=\"pl-slider-step\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef\"\n data-testid=\"pl-slider-thumb\"\n tabindex=\"0\"\n class=\"ui-slider__thumb ui-slider__thumb-active\"\n :style=\"thumbStyle\"\n @keydown=\"handleKeyPress\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <input\n v-if=\"props.mode === 'input'\"\n data-testid=\"pl-slider-input\"\n :value=\"realtimeVal\"\n class=\"ui-slider__value text-s\"\n @change=\"updateModelValue($event)\"\n />\n </div>\n </div>\n <!-- <div v-if=\"props.helper\" class=\"ui-slider__helper\">\n {{ props.helper }}\n </div> -->\n <div v-if=\"error\" data-testid=\"pl-slider-error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.vue.d.ts","sourceRoot":"","sources":["../../src/components/Slider.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Slider.vue.d.ts","sourceRoot":"","sources":["../../src/components/Slider.vue"],"names":[],"mappings":"AA6OA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAQ3C,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAmTJ,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAQ/C,QAAA,MAAM,UAAU;;;;;WApUJ,MAAM;;UAGP,UAAU;cAGN,OAAO;SATZ,MAAM;UAEL,MAAM;YAEJ,MAAM;aAGL,MAAM;iBACF,OAAO;6EAmUvB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -9,12 +9,15 @@ import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l
|
|
|
9
9
|
//#region src/components/Slider.vue?vue&type=script&setup=true&lang.ts
|
|
10
10
|
var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section" }, D = {
|
|
11
11
|
key: 0,
|
|
12
|
+
"data-testid": "pl-slider-label",
|
|
12
13
|
class: "text-s"
|
|
13
14
|
}, O = {
|
|
14
15
|
key: 1,
|
|
16
|
+
"data-testid": "pl-slider-value",
|
|
15
17
|
class: "ui-slider__value-static text-s"
|
|
16
18
|
}, k = { class: "ui-slider__base" }, A = { class: "ui-slider__container" }, j = { class: "ui-slider__container ui-slider__container-thumb" }, M = { class: "ui-slider__input-wrapper d-flex" }, N = ["value"], P = {
|
|
17
19
|
key: 0,
|
|
20
|
+
"data-testid": "pl-slider-error",
|
|
18
21
|
class: "ui-slider__error"
|
|
19
22
|
}, F = /* @__PURE__ */ f({
|
|
20
23
|
__name: "Slider",
|
|
@@ -73,8 +76,12 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
73
76
|
let t = e.code === "ArrowUp" || e.code === "ArrowRight" ? R.step * 1 : e.code === "ArrowDown" || e.code === "ArrowLeft" ? R.step * -1 : 0;
|
|
74
77
|
Z(R.modelValue + t);
|
|
75
78
|
}
|
|
76
|
-
return (e, t) => (h(), u("div", {
|
|
79
|
+
return (e, t) => (h(), u("div", {
|
|
80
|
+
"data-testid": "pl-slider",
|
|
81
|
+
class: p([R.disabled ? "ui-slider__disabled" : void 0, "ui-slider__envelope"])
|
|
82
|
+
}, [d("div", { class: p([`ui-slider__mode-${R.mode}`, "ui-slider"]) }, [d("div", T, [d("div", E, [f.label ? (h(), u("label", D, [d("span", null, b(f.label), 1), x(I).tooltip ? (h(), c(x(r), {
|
|
77
83
|
key: 0,
|
|
84
|
+
"data-testid": "pl-slider-tooltip",
|
|
78
85
|
class: "info",
|
|
79
86
|
position: "top"
|
|
80
87
|
}, {
|
|
@@ -83,23 +90,28 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
83
90
|
})) : l("", !0)])) : l("", !0), R.mode === "text" ? (h(), u("div", O, b(H.value) + b(f.measure), 1)) : l("", !0)]), d("div", k, [d("div", A, [d("div", {
|
|
84
91
|
ref_key: "barRef",
|
|
85
92
|
ref: J,
|
|
93
|
+
"data-testid": "pl-slider-bar",
|
|
86
94
|
class: "ui-slider__bar"
|
|
87
95
|
}, [d("div", {
|
|
96
|
+
"data-testid": "pl-slider-progress",
|
|
88
97
|
class: "ui-slider__progress",
|
|
89
98
|
style: m(K.value)
|
|
90
99
|
}, null, 4)], 512)]), d("div", j, [R.breakpoints ? (h(!0), u(o, { key: 0 }, v(x(W), (e, t) => (h(), u("div", {
|
|
91
100
|
key: t,
|
|
101
|
+
"data-testid": "pl-slider-step",
|
|
92
102
|
style: m({ right: `${e}%` }),
|
|
93
103
|
class: "ui-slider__thumb-step"
|
|
94
104
|
}, null, 4))), 128)) : l("", !0), d("div", {
|
|
95
105
|
ref_key: "thumbRef",
|
|
96
106
|
ref: Y,
|
|
107
|
+
"data-testid": "pl-slider-thumb",
|
|
97
108
|
tabindex: "0",
|
|
98
109
|
class: "ui-slider__thumb ui-slider__thumb-active",
|
|
99
110
|
style: m(q.value),
|
|
100
111
|
onKeydown: $
|
|
101
112
|
}, [...t[1] ||= [d("div", { class: "ui-slider__thumb-focused-contour" }, null, -1)]], 36)])])]), d("div", M, [R.mode === "input" ? (h(), u("input", {
|
|
102
113
|
key: 0,
|
|
114
|
+
"data-testid": "pl-slider-input",
|
|
103
115
|
value: H.value,
|
|
104
116
|
class: "ui-slider__value text-s",
|
|
105
117
|
onChange: t[0] ||= (e) => Q(e)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/Slider.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: number;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue: 0,\n});\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue = computed(() => {\n return clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max);\n});\n\nconst realtimeVal = ref(props.modelValue);\n\nconst error = computed(() => {\n const v = props.modelValue;\n\n if (!Number.isFinite(v)) {\n return \"Not a number\";\n }\n\n if (v < props.min) {\n return `Min value: ${props.min}`;\n }\n\n if (v > props.max) {\n return `Max value: ${props.max}`;\n }\n\n return getErrorMessage(props.error);\n});\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst position = computed(() => {\n return (localValue.value - props.min) / range.value;\n});\n\nconst progressStyle = computed(() => ({\n right: Math.ceil((1 - position.value) * 100) + \"%\",\n}));\n\nconst thumbStyle = computed(() => {\n const value = Math.ceil((1 - position.value) * 100);\n return {\n right: `calc(${value}%) `,\n };\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef = ref<HTMLElement>();\n\nwatch(\n () => props.modelValue,\n (val) => {\n realtimeVal.value = val;\n },\n);\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nuseMouseCapture(thumbRef, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue = (dx / rect.width) * range.value;\n\n realtimeVal.value = round(\n clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max),\n );\n\n if (ev.stop) {\n emit(\"update:modelValue\", round(localValue.value));\n data.deltaValue = 0;\n }\n });\n});\n\nfunction setModelValue(value: number) {\n emit(\"update:modelValue\", round(value));\n}\n\nfunction updateModelValue(event: Event) {\n setModelValue(+(event.target as HTMLInputElement).value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n setModelValue(props.modelValue + nextStep);\n}\n</script>\n\n<template>\n <div
|
|
1
|
+
{"version":3,"file":"Slider.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/Slider.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: number;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue: 0,\n});\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue = computed(() => {\n return clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max);\n});\n\nconst realtimeVal = ref(props.modelValue);\n\nconst error = computed(() => {\n const v = props.modelValue;\n\n if (!Number.isFinite(v)) {\n return \"Not a number\";\n }\n\n if (v < props.min) {\n return `Min value: ${props.min}`;\n }\n\n if (v > props.max) {\n return `Max value: ${props.max}`;\n }\n\n return getErrorMessage(props.error);\n});\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst position = computed(() => {\n return (localValue.value - props.min) / range.value;\n});\n\nconst progressStyle = computed(() => ({\n right: Math.ceil((1 - position.value) * 100) + \"%\",\n}));\n\nconst thumbStyle = computed(() => {\n const value = Math.ceil((1 - position.value) * 100);\n return {\n right: `calc(${value}%) `,\n };\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef = ref<HTMLElement>();\n\nwatch(\n () => props.modelValue,\n (val) => {\n realtimeVal.value = val;\n },\n);\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nuseMouseCapture(thumbRef, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue = (dx / rect.width) * range.value;\n\n realtimeVal.value = round(\n clamp((props.modelValue ?? 0) + data.deltaValue, props.min, props.max),\n );\n\n if (ev.stop) {\n emit(\"update:modelValue\", round(localValue.value));\n data.deltaValue = 0;\n }\n });\n});\n\nfunction setModelValue(value: number) {\n emit(\"update:modelValue\", round(value));\n}\n\nfunction updateModelValue(event: Event) {\n setModelValue(+(event.target as HTMLInputElement).value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n setModelValue(props.modelValue + nextStep);\n}\n</script>\n\n<template>\n <div\n data-testid=\"pl-slider\"\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" data-testid=\"pl-slider-label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"slots.tooltip\"\n data-testid=\"pl-slider-tooltip\"\n class=\"info\"\n position=\"top\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div\n v-if=\"props.mode === 'text'\"\n data-testid=\"pl-slider-value\"\n class=\"ui-slider__value-static text-s\"\n >\n {{ realtimeVal }}{{ measure }}\n </div>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" data-testid=\"pl-slider-bar\" class=\"ui-slider__bar\">\n <div\n data-testid=\"pl-slider-progress\"\n class=\"ui-slider__progress\"\n :style=\"progressStyle\"\n />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n data-testid=\"pl-slider-step\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef\"\n data-testid=\"pl-slider-thumb\"\n tabindex=\"0\"\n class=\"ui-slider__thumb ui-slider__thumb-active\"\n :style=\"thumbStyle\"\n @keydown=\"handleKeyPress\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <input\n v-if=\"props.mode === 'input'\"\n data-testid=\"pl-slider-input\"\n :value=\"realtimeVal\"\n class=\"ui-slider__value text-s\"\n @change=\"updateModelValue($event)\"\n />\n </div>\n </div>\n <!-- <div v-if=\"props.helper\" class=\"ui-slider__helper\">\n {{ props.helper }}\n </div> -->\n <div v-if=\"error\" data-testid=\"pl-slider-error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUA,IAAM,IAAQ,GAAU,EAElB,IAAO,GAEP,IAAQ,GA2BR,IAAO,EAAS,EACpB,YAAY,GACb,CAAC,EAEI,IAAQ,QAAe,EAAM,MAAM,EAAM,IAAI,EAE7C,IAAa,QACV,GAAO,EAAM,cAAc,KAAK,EAAK,YAAY,EAAM,KAAK,EAAM,IAAI,CAC7E,EAEI,IAAc,EAAI,EAAM,WAAW,EAEnC,IAAQ,QAAe;GAC3B,IAAM,IAAI,EAAM;AAchB,UAZK,OAAO,SAAS,EAAE,GAInB,IAAI,EAAM,MACL,cAAc,EAAM,QAGzB,IAAI,EAAM,MACL,cAAc,EAAM,QAGtB,EAAgB,EAAM,MAAM,GAX1B;IAYT,EAII,IAAiB,EAFN,QAAe,EAAM,CAEe,EAE/C,IAAW,SACP,EAAW,QAAQ,EAAM,OAAO,EAAM,MAC9C,EAEI,IAAgB,SAAgB,EACpC,OAAO,KAAK,MAAM,IAAI,EAAS,SAAS,IAAI,GAAG,KAChD,EAAE,EAEG,IAAa,SAEV,EACL,OAAO,QAFK,KAAK,MAAM,IAAI,EAAS,SAAS,IAAI,CAE5B,MACtB,EACD,EAEI,IAAS,GAAkB,EAC3B,IAAW,GAAkB;AAEnC,UACQ,EAAM,aACX,MAAQ;AACP,KAAY,QAAQ;IAEvB;EAED,SAAS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AA,EAAA,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderRange.js","names":[],"sources":["../../src/components/SliderRange.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport InputRange from \"./InputRange.vue\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: [number, number];\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst inputRange = ref<[number, number]>(props.modelValue);\nconst leftDelta = ref(props.modelValue[0]);\nconst rightDelta = ref(props.modelValue[1]);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst textModelValue = computed(() =>\n [leftDelta.value, rightDelta.value].sort((a, b) => a - b).join(\"-\"),\n);\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue1 = computed(() => {\n return clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max);\n});\n\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 2 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number]\";\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[1] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nwatch(\n () => props.modelValue,\n (value: [number, number]) => {\n inputRange.value = value;\n leftDelta.value = +value[0];\n rightDelta.value = +value[1];\n },\n { immediate: true },\n);\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n leftDelta.value = round(\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n rightDelta.value = round(\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n return [point1, point2].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: [number, number]) {\n emit(\"update:modelValue\", value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: [number, number] = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n}\n</script>\n\n<template>\n <!-- {{ leftDelta }} {{ rightDelta }} -->\n <div
|
|
1
|
+
{"version":3,"file":"SliderRange.js","names":[],"sources":["../../src/components/SliderRange.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport InputRange from \"./InputRange.vue\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: [number, number];\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst inputRange = ref<[number, number]>(props.modelValue);\nconst leftDelta = ref(props.modelValue[0]);\nconst rightDelta = ref(props.modelValue[1]);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst textModelValue = computed(() =>\n [leftDelta.value, rightDelta.value].sort((a, b) => a - b).join(\"-\"),\n);\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue1 = computed(() => {\n return clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max);\n});\n\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 2 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number]\";\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[1] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nwatch(\n () => props.modelValue,\n (value: [number, number]) => {\n inputRange.value = value;\n leftDelta.value = +value[0];\n rightDelta.value = +value[1];\n },\n { immediate: true },\n);\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n leftDelta.value = round(\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n rightDelta.value = round(\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n return [point1, point2].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: [number, number]) {\n emit(\"update:modelValue\", value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: [number, number] = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n}\n</script>\n\n<template>\n <!-- {{ leftDelta }} {{ rightDelta }} -->\n <div\n data-testid=\"pl-slider-range\"\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" data-testid=\"pl-slider-range-label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"slots.tooltip\"\n data-testid=\"pl-slider-range-tooltip\"\n class=\"info\"\n position=\"top\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div\n v-if=\"props.mode === 'text'\"\n data-testid=\"pl-slider-range-value\"\n class=\"ui-slider__value-static text-s\"\n >\n {{ textModelValue }}\n </div>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" data-testid=\"pl-slider-range-bar\" class=\"ui-slider__bar\">\n <div\n data-testid=\"pl-slider-range-progress\"\n class=\"ui-slider__progress\"\n :style=\"progressStyle\"\n />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n data-testid=\"pl-slider-range-step\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef1\"\n data-testid=\"pl-slider-range-thumb\"\n :style=\"thumbStyle1\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 0)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef2\"\n data-testid=\"pl-slider-range-thumb\"\n :style=\"thumbStyle2\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 1)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <InputRange\n v-if=\"props.mode === 'input'\"\n v-model=\"inputRange\"\n data-testid=\"pl-slider-range-input\"\n class=\"ui-focused-border\"\n @change=\"setModelValue\"\n />\n </div>\n </div>\n <!-- <div v-if=\"helper\" class=\"ui-slider__helper\">\n {{ helper }}\n </div> -->\n <div v-if=\"error\" data-testid=\"pl-slider-range-error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderRange.vue.d.ts","sourceRoot":"","sources":["../../src/components/SliderRange.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SliderRange.vue.d.ts","sourceRoot":"","sources":["../../src/components/SliderRange.vue"],"names":[],"mappings":"AAsSA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAS3C,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA8XJ,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAS/C,QAAA,MAAM,UAAU;;;;;WAhZJ,MAAM;;UAGP,UAAU;cAGN,OAAO;SATZ,MAAM;UAEL,MAAM;YAEJ,MAAM;aAGL,MAAM;iBACF,OAAO;6EA+YvB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -10,12 +10,15 @@ import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u
|
|
|
10
10
|
//#region src/components/SliderRange.vue?vue&type=script&setup=true&lang.ts
|
|
11
11
|
var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section" }, D = {
|
|
12
12
|
key: 0,
|
|
13
|
+
"data-testid": "pl-slider-range-label",
|
|
13
14
|
class: "text-s"
|
|
14
15
|
}, O = {
|
|
15
16
|
key: 1,
|
|
17
|
+
"data-testid": "pl-slider-range-value",
|
|
16
18
|
class: "ui-slider__value-static text-s"
|
|
17
19
|
}, k = { class: "ui-slider__base" }, A = { class: "ui-slider__container" }, j = { class: "ui-slider__container ui-slider__container-thumb" }, M = { class: "ui-slider__input-wrapper d-flex" }, te = {
|
|
18
20
|
key: 0,
|
|
21
|
+
"data-testid": "pl-slider-range-error",
|
|
19
22
|
class: "ui-slider__error"
|
|
20
23
|
}, N = /* @__PURE__ */ p({
|
|
21
24
|
__name: "SliderRange",
|
|
@@ -84,8 +87,12 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
84
87
|
let r = e.code === "ArrowUp" || e.code === "ArrowRight" ? P.step * 1 : e.code === "ArrowDown" || e.code === "ArrowLeft" ? P.step * -1 : 0, i = [...P.modelValue];
|
|
85
88
|
i[t] = n(i[t] + r, P.min, P.max), Q(i);
|
|
86
89
|
}
|
|
87
|
-
return (e, t) => (g(), d("div", {
|
|
90
|
+
return (e, t) => (g(), d("div", {
|
|
91
|
+
"data-testid": "pl-slider-range",
|
|
92
|
+
class: m([P.disabled ? "ui-slider__disabled" : void 0, "ui-slider__envelope"])
|
|
93
|
+
}, [f("div", { class: m([`ui-slider__mode-${P.mode}`, "ui-slider"]) }, [f("div", T, [f("div", E, [p.label ? (g(), d("label", D, [f("span", null, x(p.label), 1), S(ne).tooltip ? (g(), l(S(r), {
|
|
88
94
|
key: 0,
|
|
95
|
+
"data-testid": "pl-slider-range-tooltip",
|
|
89
96
|
class: "info",
|
|
90
97
|
position: "top"
|
|
91
98
|
}, {
|
|
@@ -94,19 +101,23 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
94
101
|
})) : u("", !0)])) : u("", !0), P.mode === "text" ? (g(), d("div", O, x(U.value), 1)) : u("", !0)]), f("div", k, [f("div", A, [f("div", {
|
|
95
102
|
ref_key: "barRef",
|
|
96
103
|
ref: I,
|
|
104
|
+
"data-testid": "pl-slider-range-bar",
|
|
97
105
|
class: "ui-slider__bar"
|
|
98
106
|
}, [f("div", {
|
|
107
|
+
"data-testid": "pl-slider-range-progress",
|
|
99
108
|
class: "ui-slider__progress",
|
|
100
109
|
style: h(ie.value)
|
|
101
110
|
}, null, 4)], 512)]), f("div", j, [
|
|
102
111
|
P.breakpoints ? (g(!0), d(s, { key: 0 }, y(S(H), (e, t) => (g(), d("div", {
|
|
103
112
|
key: t,
|
|
113
|
+
"data-testid": "pl-slider-range-step",
|
|
104
114
|
style: h({ right: `${e}%` }),
|
|
105
115
|
class: "ui-slider__thumb-step"
|
|
106
116
|
}, null, 4))), 128)) : u("", !0),
|
|
107
117
|
f("div", {
|
|
108
118
|
ref_key: "thumbRef1",
|
|
109
119
|
ref: L,
|
|
120
|
+
"data-testid": "pl-slider-range-thumb",
|
|
110
121
|
style: h(ae.value),
|
|
111
122
|
class: "ui-slider__thumb",
|
|
112
123
|
tabindex: "0",
|
|
@@ -115,6 +126,7 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
115
126
|
f("div", {
|
|
116
127
|
ref_key: "thumbRef2",
|
|
117
128
|
ref: R,
|
|
129
|
+
"data-testid": "pl-slider-range-thumb",
|
|
118
130
|
style: h(oe.value),
|
|
119
131
|
class: "ui-slider__thumb",
|
|
120
132
|
tabindex: "0",
|
|
@@ -124,6 +136,7 @@ var T = { class: "ui-slider__wrapper" }, E = { class: "ui-slider__label-section"
|
|
|
124
136
|
key: 0,
|
|
125
137
|
modelValue: z.value,
|
|
126
138
|
"onUpdate:modelValue": t[2] ||= (e) => z.value = e,
|
|
139
|
+
"data-testid": "pl-slider-range-input",
|
|
127
140
|
class: "ui-focused-border",
|
|
128
141
|
onChange: Q
|
|
129
142
|
}, null, 8, ["modelValue"])) : u("", !0)])], 2), q.value ? (g(), d("div", te, x(q.value), 1)) : u("", !0)], 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderRange.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/SliderRange.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport InputRange from \"./InputRange.vue\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: [number, number];\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst inputRange = ref<[number, number]>(props.modelValue);\nconst leftDelta = ref(props.modelValue[0]);\nconst rightDelta = ref(props.modelValue[1]);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst textModelValue = computed(() =>\n [leftDelta.value, rightDelta.value].sort((a, b) => a - b).join(\"-\"),\n);\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue1 = computed(() => {\n return clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max);\n});\n\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 2 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number]\";\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[1] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nwatch(\n () => props.modelValue,\n (value: [number, number]) => {\n inputRange.value = value;\n leftDelta.value = +value[0];\n rightDelta.value = +value[1];\n },\n { immediate: true },\n);\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n leftDelta.value = round(\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n rightDelta.value = round(\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n return [point1, point2].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: [number, number]) {\n emit(\"update:modelValue\", value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: [number, number] = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n}\n</script>\n\n<template>\n <!-- {{ leftDelta }} {{ rightDelta }} -->\n <div :class=\"props.disabled ? 'ui-slider__disabled' : undefined\" class=\"ui-slider__envelope\">\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div v-if=\"props.mode === 'text'\" class=\"ui-slider__value-static text-s\">\n {{ textModelValue }}\n </div>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" class=\"ui-slider__bar\">\n <div class=\"ui-slider__progress\" :style=\"progressStyle\" />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef1\"\n :style=\"thumbStyle1\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 0)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef2\"\n :style=\"thumbStyle2\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 1)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <InputRange\n v-if=\"props.mode === 'input'\"\n v-model=\"inputRange\"\n class=\"ui-focused-border\"\n @change=\"setModelValue\"\n />\n </div>\n </div>\n <!-- <div v-if=\"helper\" class=\"ui-slider__helper\">\n {{ helper }}\n </div> -->\n <div v-if=\"error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA,IAAM,KAAQ,GAAU,EAElB,KAAO,GAEP,IAAQ,GA2BR,IAAO,EAAS;GACpB,aAAa;GACb,aAAa;GACd,CAAC,EAEI,IAAS,GAAkB,EAC3B,IAAY,GAAkB,EAC9B,IAAY,GAAkB,EAC9B,IAAa,EAAsB,EAAM,WAAW,EACpD,IAAY,EAAI,EAAM,WAAW,GAAG,EACpC,IAAa,EAAI,EAAM,WAAW,GAAG,EAIrC,IAAiB,EAFN,QAAe,EAAM,CAEe,EAE/C,IAAiB,QACrB,CAAC,EAAU,OAAO,EAAW,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC,KAAK,IAAI,CACpE,EAEK,IAAQ,QAAe,EAAM,MAAM,EAAM,IAAI,EAE7C,IAAc,QACX,GAAO,EAAM,WAAW,MAAM,KAAK,EAAK,aAAa,EAAM,KAAK,EAAM,IAAI,CACjF,EAEI,IAAc,QAClB,GAAO,EAAM,WAAW,MAAM,KAAK,EAAK,aAAa,EAAM,KAAK,EAAM,IAAI,CAC3E,EAEK,IAAQ,QAAe;GAC3B,IAAM,IAAI,EAAM;AAQhB,UANqB,MAAM,QAAQ,EAAE,IAAI,EAAE,WAAW,KAAK,EAAE,OAAO,MAAO,OAAO,SAAS,EAAG,CAAC,GAMxF,EAAgB,EAAM,MAAM,GAH1B;IAIT,EAEI,IAAY,SACR,EAAY,QAAQ,EAAM,OAAO,EAAM,MAC/C,EAEI,IAAY,SACR,EAAY,QAAQ,EAAM,OAAO,EAAM,MAC/C,EAEI,IAAY,QAAe,IAAiB,CAAC,EAE7C,KAAgB,SAAgB;GACpC,OAAO,EAAU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,EADD,EAAA,MAAK,EAAA,EAAA,IAAA,EAAA,IAAA,GAAA,CAAA,EAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"SliderRange.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/components/SliderRange.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, reactive, ref, unref, useSlots, watch } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport InputRange from \"./InputRange.vue\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: [number, number];\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst inputRange = ref<[number, number]>(props.modelValue);\nconst leftDelta = ref(props.modelValue[0]);\nconst rightDelta = ref(props.modelValue[1]);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst textModelValue = computed(() =>\n [leftDelta.value, rightDelta.value].sort((a, b) => a - b).join(\"-\"),\n);\n\nconst range = computed(() => props.max - props.min);\n\nconst localValue1 = computed(() => {\n return clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max);\n});\n\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 2 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number]\";\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[1] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nwatch(\n () => props.modelValue,\n (value: [number, number]) => {\n inputRange.value = value;\n leftDelta.value = +value[0];\n rightDelta.value = +value[1];\n },\n { immediate: true },\n);\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n leftDelta.value = round(\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n rightDelta.value = round(\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n );\n\n inputRange.value = ([leftDelta.value, rightDelta.value] as [number, number]).sort(\n (a, b) => a - b,\n );\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n return [point1, point2].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: [number, number]) {\n emit(\"update:modelValue\", value);\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: [number, number] = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n}\n</script>\n\n<template>\n <!-- {{ leftDelta }} {{ rightDelta }} -->\n <div\n data-testid=\"pl-slider-range\"\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" data-testid=\"pl-slider-range-label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"slots.tooltip\"\n data-testid=\"pl-slider-range-tooltip\"\n class=\"info\"\n position=\"top\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <div\n v-if=\"props.mode === 'text'\"\n data-testid=\"pl-slider-range-value\"\n class=\"ui-slider__value-static text-s\"\n >\n {{ textModelValue }}\n </div>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" data-testid=\"pl-slider-range-bar\" class=\"ui-slider__bar\">\n <div\n data-testid=\"pl-slider-range-progress\"\n class=\"ui-slider__progress\"\n :style=\"progressStyle\"\n />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n data-testid=\"pl-slider-range-step\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef1\"\n data-testid=\"pl-slider-range-thumb\"\n :style=\"thumbStyle1\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 0)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef2\"\n data-testid=\"pl-slider-range-thumb\"\n :style=\"thumbStyle2\"\n class=\"ui-slider__thumb\"\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 1)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <InputRange\n v-if=\"props.mode === 'input'\"\n v-model=\"inputRange\"\n data-testid=\"pl-slider-range-input\"\n class=\"ui-focused-border\"\n @change=\"setModelValue\"\n />\n </div>\n </div>\n <!-- <div v-if=\"helper\" class=\"ui-slider__helper\">\n {{ helper }}\n </div> -->\n <div v-if=\"error\" data-testid=\"pl-slider-range-error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA,IAAM,KAAQ,GAAU,EAElB,KAAO,GAEP,IAAQ,GA2BR,IAAO,EAAS;GACpB,aAAa;GACb,aAAa;GACd,CAAC,EAEI,IAAS,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,OAAA;GAHA,eAAY;GACZ,OAAM;GACL,OAAK,EAAE,GAAA,MAAa;wBAI3B,EA8BM,OA9BN,GA8BM;GA7BY,EAAM,eAAA,EAAA,GAAA,EACpB,EAME,GAAA,EAAA,KAAA,GAAA,EAAA,EALwB,EAAA,EAAc,GAA9B,GAAM,YADhB,EAME,OAAA;IAJC,KAAK;IACN,eAAY;IACX,OAAK,EAAA,EAAA,OAAA,GAAc,EAAI,IAAA,CAAA;IACxB,OAAM;;GAGV,EASM,OAAA;aARA;IAAJ,KAAI;IACJ,eAAY;IACX,OAAK,EAAE,GAAA,MAAW;IACnB,OAAM;IACN,UAAS;IACR,WAAO,AAAA,EAAA,QAAA,MAAE,EAAe,GAAM,EAAA;oBAE/B,EAAgD,OAAA,EAA3C,OAAM,oCAAkC,EAAA,MAAA,GAAA,CAAA,CAAA,EAAA,GAAA;GAE/C,EASM,OAAA;aARA;IAAJ,KAAI;IACJ,eAAY;IACX,OAAK,EAAE,GAAA,MAAW;IACnB,OAAM;IACN,UAAS;IACR,WAAO,AAAA,EAAA,QAAA,MAAE,EAAe,GAAM,EAAA;oBAE/B,EAAgD,OAAA,EAA3C,OAAM,oCAAkC,EAAA,MAAA,GAAA,CAAA,CAAA,EAAA,GAAA;UAMrD,EAQM,OARN,GAQM,CANI,EAAM,SAAI,WAAA,GAAA,EADlB,EAME,GAAA;;eAJS,EAAA;4CAAU,QAAA;GACnB,eAAY;GACZ,OAAM;GACL,UAAQ;mDAOJ,EAAA,SAAA,GAAA,EAAX,EAEM,OAFN,IAEM,EADD,EAAA,MAAK,EAAA,EAAA,IAAA,EAAA,IAAA,GAAA,CAAA,EAAA,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderRangeTriple.js","names":[],"sources":["../../src/components/SliderRangeTriple.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, onMounted, reactive, ref, unref, useSlots } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\ntype ModelType = [number, number, number];\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: ModelType;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"%\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n deltaValue3: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst thumbRef3 = ref<HTMLElement>();\n\nconst range = computed(() => props.max - props.min);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst localValue1 = computed(() =>\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n);\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\nconst localValue3 = computed(() =>\n clamp((props.modelValue[2] ?? 0) + data.deltaValue3, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 3 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number, number]\";\n }\n\n const errors: string[] = [];\n\n [...props.modelValue].forEach((v) => {\n if (v > props.max) {\n errors.push(`Max model value must be lower than max props ${props.max}.`);\n }\n if (v < props.min) {\n errors.push(\"Min model value must be greater than max props.\");\n }\n });\n\n if (errors.length > 0) {\n return errors.join(\" \");\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst position3 = computed(() => {\n return (localValue3.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[2] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nconst thumbStyle3 = computed(() => ({\n right: Math.ceil((1 - position3.value) * 100) + \"%\",\n}));\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n if (thumbRef1.value) {\n updateDatasetForThumb(thumbRef1.value, props.modelValue[0], data.deltaValue1);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n if (thumbRef2.value) {\n updateDatasetForThumb(thumbRef2.value, props.modelValue[1], data.deltaValue2);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef3, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue3 = (dx / rect.width) * range.value;\n\n if (thumbRef3.value) {\n updateDatasetForThumb(thumbRef3.value, props.modelValue[2], data.deltaValue3);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue3 = 0;\n }\n });\n});\n\nfunction updateDatasetForThumb(thumb: HTMLElement, modelVal: number, delta: number) {\n const value = round(clamp((modelVal ?? 0) + delta, props.min, props.max));\n thumb.dataset.percent = `${value}${props.measure}`;\n getHint();\n}\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n const point3 = Math.ceil((1 - position3.value) * 100);\n return [point1, point2, point3].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: ModelType) {\n emit(\"update:modelValue\", value);\n}\n\nfunction getHint() {\n const right1 = Number(thumbStyle1.value.right.substring(0, thumbStyle1.value.right.length - 1));\n const right2 = Number(thumbStyle2.value.right.substring(0, thumbStyle2.value.right.length - 1));\n const right3 = Number(thumbStyle3.value.right.substring(0, thumbStyle3.value.right.length - 1));\n\n const arr = [\n { r: right1, th: thumbRef1 },\n { r: right2, th: thumbRef2 },\n { r: right3, th: thumbRef3 },\n ].sort((a, b) => a.r - b.r);\n\n if (arr[0].th.value) {\n arr[0].th.value.dataset.hint = \"high\";\n }\n if (arr[1].th.value) {\n arr[1].th.value.dataset.hint = \"mid\";\n }\n\n if (arr[2].th.value) {\n arr[2].th.value.dataset.hint = \"low\";\n }\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: ModelType = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n getHint();\n}\n\nonMounted(() => {\n getHint();\n});\n</script>\n\n<template>\n <div\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope ui-slider__triple\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" class=\"ui-slider__bar\">\n <div class=\"ui-slider__progress\" :style=\"progressStyle\" />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef1\"\n :style=\"thumbStyle1\"\n :data-percent=\"props.modelValue[0] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r1\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 0)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef2\"\n :style=\"thumbStyle2\"\n :data-percent=\"props.modelValue[1] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r2\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 1)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef3\"\n :style=\"thumbStyle3\"\n :data-percent=\"props.modelValue[2] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r3\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 2)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <!-- {{ props.modelValue }} -->\n <!-- <InputRange v-if=\"props.mode === 'input'\" v-model=\"inputRange\" class=\"ui-focused-border\" /> -->\n </div>\n </div>\n <!-- <div v-if=\"helper\" class=\"ui-slider__helper\">\n {{ helper }}\n </div> -->\n <div v-if=\"error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n\n<style></style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SliderRangeTriple.js","names":[],"sources":["../../src/components/SliderRangeTriple.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, onMounted, reactive, ref, unref, useSlots } from \"vue\";\nimport { useMouseCapture } from \"../composition/useMouseCapture\";\nimport { tapIf } from \"../helpers/functions\";\nimport { clamp } from \"../helpers/math\";\nimport { PlTooltip } from \"./PlTooltip\";\nimport type { SliderMode } from \"../types\";\nimport { useSliderBreakpoints } from \"../composition/useSliderBreakpoints\";\nimport { getErrorMessage } from \"../helpers/error.ts\";\n\ntype ModelType = [number, number, number];\nconst slots = useSlots();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst props = withDefaults(\n defineProps<{\n modelValue: ModelType;\n min?: number;\n max: number;\n step?: number;\n label?: string;\n helper?: string;\n error?: unknown;\n mode?: SliderMode;\n measure?: string;\n breakpoints?: boolean;\n disabled?: boolean;\n }>(),\n {\n label: undefined,\n helper: undefined,\n error: undefined,\n min: 0,\n step: 1,\n mode: \"text\",\n measure: \"%\",\n breakpoints: false,\n disabled: false,\n },\n);\n\nconst data = reactive({\n deltaValue1: 0,\n deltaValue2: 0,\n deltaValue3: 0,\n});\n\nconst barRef = ref<HTMLElement>();\nconst thumbRef1 = ref<HTMLElement>();\nconst thumbRef2 = ref<HTMLElement>();\nconst thumbRef3 = ref<HTMLElement>();\n\nconst range = computed(() => props.max - props.min);\n\nconst propsRef = computed(() => props);\n\nconst breakpointsRef = useSliderBreakpoints(propsRef);\n\nconst localValue1 = computed(() =>\n clamp((props.modelValue[0] ?? 0) + data.deltaValue1, props.min, props.max),\n);\nconst localValue2 = computed(() =>\n clamp((props.modelValue[1] ?? 0) + data.deltaValue2, props.min, props.max),\n);\nconst localValue3 = computed(() =>\n clamp((props.modelValue[2] ?? 0) + data.deltaValue3, props.min, props.max),\n);\n\nconst error = computed(() => {\n const v = props.modelValue as unknown;\n\n const isValidModel = Array.isArray(v) && v.length === 3 && v.every((it) => Number.isFinite(it));\n\n if (!isValidModel) {\n return \"Expected model [number, number, number]\";\n }\n\n const errors: string[] = [];\n\n [...props.modelValue].forEach((v) => {\n if (v > props.max) {\n errors.push(`Max model value must be lower than max props ${props.max}.`);\n }\n if (v < props.min) {\n errors.push(\"Min model value must be greater than max props.\");\n }\n });\n\n if (errors.length > 0) {\n return errors.join(\" \");\n }\n\n return getErrorMessage(props.error);\n});\n\nconst position1 = computed(() => {\n return (localValue1.value - props.min) / range.value;\n});\n\nconst position2 = computed(() => {\n return (localValue2.value - props.min) / range.value;\n});\n\nconst position3 = computed(() => {\n return (localValue3.value - props.min) / range.value;\n});\n\nconst leftRight = computed(() => getLeftAndRight());\n\nconst progressStyle = computed(() => ({\n right: leftRight.value[0] + \"%\",\n left: 100 - leftRight.value[2] + \"%\",\n}));\n\nconst thumbStyle1 = computed(() => ({\n right: Math.ceil((1 - position1.value) * 100) + \"%\",\n}));\n\nconst thumbStyle2 = computed(() => ({\n right: Math.ceil((1 - position2.value) * 100) + \"%\",\n}));\n\nconst thumbStyle3 = computed(() => ({\n right: Math.ceil((1 - position3.value) * 100) + \"%\",\n}));\n\nuseMouseCapture(thumbRef1, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue1 = (dx / rect.width) * range.value;\n\n if (thumbRef1.value) {\n updateDatasetForThumb(thumbRef1.value, props.modelValue[0], data.deltaValue1);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue1 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef2, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue2 = (dx / rect.width) * range.value;\n\n if (thumbRef2.value) {\n updateDatasetForThumb(thumbRef2.value, props.modelValue[1], data.deltaValue2);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue2 = 0;\n }\n });\n});\n\nuseMouseCapture(thumbRef3, (ev) => {\n tapIf(unref(barRef)?.getBoundingClientRect(), (rect) => {\n const { dx } = ev;\n data.deltaValue3 = (dx / rect.width) * range.value;\n\n if (thumbRef3.value) {\n updateDatasetForThumb(thumbRef3.value, props.modelValue[2], data.deltaValue3);\n }\n\n if (ev.stop) {\n setModelValue([round(localValue1.value), round(localValue2.value), round(localValue3.value)]);\n data.deltaValue3 = 0;\n }\n });\n});\n\nfunction updateDatasetForThumb(thumb: HTMLElement, modelVal: number, delta: number) {\n const value = round(clamp((modelVal ?? 0) + delta, props.min, props.max));\n thumb.dataset.percent = `${value}${props.measure}`;\n getHint();\n}\n\nfunction getLeftAndRight() {\n const point1 = Math.ceil((1 - position1.value) * 100);\n const point2 = Math.ceil((1 - position2.value) * 100);\n const point3 = Math.ceil((1 - position3.value) * 100);\n return [point1, point2, point3].sort((a, b) => a - b);\n}\n\nfunction round(value: number) {\n const v = clamp(value, props.min, props.max);\n // This is the same as Math.round(v / props.step) * props.step but here we need this magic to avoid numbers like 3.00000000000000000004\n return Math.round((v + Number.EPSILON) * (1 / props.step)) / (1 / props.step);\n}\n\nfunction setModelValue(value: ModelType) {\n emit(\"update:modelValue\", value);\n}\n\nfunction getHint() {\n const right1 = Number(thumbStyle1.value.right.substring(0, thumbStyle1.value.right.length - 1));\n const right2 = Number(thumbStyle2.value.right.substring(0, thumbStyle2.value.right.length - 1));\n const right3 = Number(thumbStyle3.value.right.substring(0, thumbStyle3.value.right.length - 1));\n\n const arr = [\n { r: right1, th: thumbRef1 },\n { r: right2, th: thumbRef2 },\n { r: right3, th: thumbRef3 },\n ].sort((a, b) => a.r - b.r);\n\n if (arr[0].th.value) {\n arr[0].th.value.dataset.hint = \"high\";\n }\n if (arr[1].th.value) {\n arr[1].th.value.dataset.hint = \"mid\";\n }\n\n if (arr[2].th.value) {\n arr[2].th.value.dataset.hint = \"low\";\n }\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }, index: number) {\n if ([\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\", \"Enter\"].includes(e.code)) {\n e.preventDefault();\n }\n\n const nextStep =\n e.code === \"ArrowUp\" || e.code === \"ArrowRight\"\n ? props.step * 1\n : e.code === \"ArrowDown\" || e.code === \"ArrowLeft\"\n ? props.step * -1\n : 0;\n\n const arr: ModelType = [...props.modelValue];\n arr[index] = clamp(arr[index] + nextStep, props.min, props.max);\n setModelValue(arr);\n getHint();\n}\n\nonMounted(() => {\n getHint();\n});\n</script>\n\n<template>\n <div\n data-testid=\"pl-slider-range-triple\"\n :class=\"props.disabled ? 'ui-slider__disabled' : undefined\"\n class=\"ui-slider__envelope ui-slider__triple\"\n >\n <div :class=\"`ui-slider__mode-${props.mode}`\" class=\"ui-slider\">\n <div class=\"ui-slider__wrapper\">\n <div class=\"ui-slider__label-section\">\n <label v-if=\"label\" data-testid=\"pl-slider-range-triple-label\" class=\"text-s\">\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"slots.tooltip\"\n data-testid=\"pl-slider-range-triple-tooltip\"\n class=\"info\"\n position=\"top\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n </div>\n <div class=\"ui-slider__base\">\n <div class=\"ui-slider__container\">\n <div ref=\"barRef\" data-testid=\"pl-slider-range-triple-bar\" class=\"ui-slider__bar\">\n <div\n data-testid=\"pl-slider-range-triple-progress\"\n class=\"ui-slider__progress\"\n :style=\"progressStyle\"\n />\n </div>\n </div>\n <div class=\"ui-slider__container ui-slider__container-thumb\">\n <template v-if=\"props.breakpoints\">\n <div\n v-for=\"(item, index) in breakpointsRef\"\n :key=\"index\"\n data-testid=\"pl-slider-range-triple-step\"\n :style=\"{ right: `${item}%` }\"\n class=\"ui-slider__thumb-step\"\n />\n </template>\n <div\n ref=\"thumbRef1\"\n data-testid=\"pl-slider-range-triple-thumb\"\n :style=\"thumbStyle1\"\n :data-percent=\"props.modelValue[0] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r1\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 0)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef2\"\n data-testid=\"pl-slider-range-triple-thumb\"\n :style=\"thumbStyle2\"\n :data-percent=\"props.modelValue[1] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r2\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 1)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n <div\n ref=\"thumbRef3\"\n data-testid=\"pl-slider-range-triple-thumb\"\n :style=\"thumbStyle3\"\n :data-percent=\"props.modelValue[2] + '%'\"\n class=\"ui-slider__thumb ui-slider__triple-thumb\"\n r3\n tabindex=\"0\"\n @keydown=\"handleKeyPress($event, 2)\"\n >\n <div class=\"ui-slider__thumb-focused-contour\" />\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"ui-slider__input-wrapper d-flex\">\n <!-- {{ props.modelValue }} -->\n <!-- <InputRange v-if=\"props.mode === 'input'\" v-model=\"inputRange\" class=\"ui-focused-border\" /> -->\n </div>\n </div>\n <!-- <div v-if=\"helper\" class=\"ui-slider__helper\">\n {{ helper }}\n </div> -->\n <div v-if=\"error\" data-testid=\"pl-slider-range-triple-error\" class=\"ui-slider__error\">\n {{ error }}\n </div>\n </div>\n</template>\n\n<style></style>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderRangeTriple.vue.d.ts","sourceRoot":"","sources":["../../src/components/SliderRangeTriple.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SliderRangeTriple.vue.d.ts","sourceRoot":"","sources":["../../src/components/SliderRangeTriple.vue"],"names":[],"mappings":"AA8VA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAK1C,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,SAAS,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAyaJ,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAU/C,QAAA,MAAM,UAAU;;;;;WA5bJ,MAAM;;UAGP,UAAU;cAGN,OAAO;SATZ,MAAM;UAEL,MAAM;YAEJ,MAAM;aAGL,MAAM;iBACF,OAAO;6EA2bvB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -9,9 +9,11 @@ import { Fragment as a, computed as o, createBlock as te, createCommentVNode as
|
|
|
9
9
|
//#region src/components/SliderRangeTriple.vue?vue&type=script&setup=true&lang.ts
|
|
10
10
|
var ae = { class: "ui-slider__wrapper" }, oe = { class: "ui-slider__label-section" }, b = {
|
|
11
11
|
key: 0,
|
|
12
|
+
"data-testid": "pl-slider-range-triple-label",
|
|
12
13
|
class: "text-s"
|
|
13
14
|
}, x = { class: "ui-slider__base" }, S = { class: "ui-slider__container" }, C = { class: "ui-slider__container ui-slider__container-thumb" }, w = ["data-percent"], T = ["data-percent"], E = ["data-percent"], D = {
|
|
14
15
|
key: 0,
|
|
16
|
+
"data-testid": "pl-slider-range-triple-error",
|
|
15
17
|
class: "ui-slider__error"
|
|
16
18
|
}, O = /* @__PURE__ */ u({
|
|
17
19
|
__name: "SliderRangeTriple",
|
|
@@ -127,8 +129,12 @@ var ae = { class: "ui-slider__wrapper" }, oe = { class: "ui-slider__label-sectio
|
|
|
127
129
|
}
|
|
128
130
|
return ne(() => {
|
|
129
131
|
Q();
|
|
130
|
-
}), (e, t) => (p(), c("div", {
|
|
132
|
+
}), (e, t) => (p(), c("div", {
|
|
133
|
+
"data-testid": "pl-slider-range-triple",
|
|
134
|
+
class: d([A.disabled ? "ui-slider__disabled" : void 0, "ui-slider__envelope ui-slider__triple"])
|
|
135
|
+
}, [l("div", { class: d([`ui-slider__mode-${A.mode}`, "ui-slider"]) }, [l("div", ae, [l("div", oe, [u.label ? (p(), c("label", b, [l("span", null, _(u.label), 1), v(k).tooltip ? (p(), te(v(r), {
|
|
131
136
|
key: 0,
|
|
137
|
+
"data-testid": "pl-slider-range-triple-tooltip",
|
|
132
138
|
class: "info",
|
|
133
139
|
position: "top"
|
|
134
140
|
}, {
|
|
@@ -137,19 +143,23 @@ var ae = { class: "ui-slider__wrapper" }, oe = { class: "ui-slider__label-sectio
|
|
|
137
143
|
})) : s("", !0)])) : s("", !0)]), l("div", x, [l("div", S, [l("div", {
|
|
138
144
|
ref_key: "barRef",
|
|
139
145
|
ref: M,
|
|
146
|
+
"data-testid": "pl-slider-range-triple-bar",
|
|
140
147
|
class: "ui-slider__bar"
|
|
141
148
|
}, [l("div", {
|
|
149
|
+
"data-testid": "pl-slider-range-triple-progress",
|
|
142
150
|
class: "ui-slider__progress",
|
|
143
151
|
style: f(ce.value)
|
|
144
152
|
}, null, 4)], 512)]), l("div", C, [
|
|
145
153
|
A.breakpoints ? (p(!0), c(a, { key: 0 }, h(v(L), (e, t) => (p(), c("div", {
|
|
146
154
|
key: t,
|
|
155
|
+
"data-testid": "pl-slider-range-triple-step",
|
|
147
156
|
style: f({ right: `${e}%` }),
|
|
148
157
|
class: "ui-slider__thumb-step"
|
|
149
158
|
}, null, 4))), 128)) : s("", !0),
|
|
150
159
|
l("div", {
|
|
151
160
|
ref_key: "thumbRef1",
|
|
152
161
|
ref: N,
|
|
162
|
+
"data-testid": "pl-slider-range-triple-thumb",
|
|
153
163
|
style: f(K.value),
|
|
154
164
|
"data-percent": A.modelValue[0] + "%",
|
|
155
165
|
class: "ui-slider__thumb ui-slider__triple-thumb",
|
|
@@ -160,6 +170,7 @@ var ae = { class: "ui-slider__wrapper" }, oe = { class: "ui-slider__label-sectio
|
|
|
160
170
|
l("div", {
|
|
161
171
|
ref_key: "thumbRef2",
|
|
162
172
|
ref: P,
|
|
173
|
+
"data-testid": "pl-slider-range-triple-thumb",
|
|
163
174
|
style: f(q.value),
|
|
164
175
|
"data-percent": A.modelValue[1] + "%",
|
|
165
176
|
class: "ui-slider__thumb ui-slider__triple-thumb",
|
|
@@ -170,6 +181,7 @@ var ae = { class: "ui-slider__wrapper" }, oe = { class: "ui-slider__label-sectio
|
|
|
170
181
|
l("div", {
|
|
171
182
|
ref_key: "thumbRef3",
|
|
172
183
|
ref: F,
|
|
184
|
+
"data-testid": "pl-slider-range-triple-thumb",
|
|
173
185
|
style: f(J.value),
|
|
174
186
|
"data-percent": A.modelValue[2] + "%",
|
|
175
187
|
class: "ui-slider__thumb ui-slider__triple-thumb",
|