mood-ui 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/Chart.cjs +6 -0
- package/dist/components/data-display/Chart.cjs.map +1 -0
- package/dist/components/data-display/Chart.mjs +7 -0
- package/dist/components/data-display/Chart.mjs.map +1 -0
- package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.cjs +48 -0
- package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.mjs +47 -0
- package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/Stat.cjs.map +1 -1
- package/dist/components/data-display/Stat.mjs.map +1 -1
- package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.cjs +88 -75
- package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.mjs +90 -77
- package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/chart/Cartesian.cjs +6 -0
- package/dist/components/data-display/chart/Cartesian.cjs.map +1 -0
- package/dist/components/data-display/chart/Cartesian.mjs +7 -0
- package/dist/components/data-display/chart/Cartesian.mjs.map +1 -0
- package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.cjs +573 -0
- package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.mjs +572 -0
- package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/chart/Heatmap.cjs +6 -0
- package/dist/components/data-display/chart/Heatmap.cjs.map +1 -0
- package/dist/components/data-display/chart/Heatmap.mjs +7 -0
- package/dist/components/data-display/chart/Heatmap.mjs.map +1 -0
- package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.cjs +332 -0
- package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.mjs +331 -0
- package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/chart/Polar.cjs +6 -0
- package/dist/components/data-display/chart/Polar.cjs.map +1 -0
- package/dist/components/data-display/chart/Polar.mjs +7 -0
- package/dist/components/data-display/chart/Polar.mjs.map +1 -0
- package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.cjs +361 -0
- package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.mjs +360 -0
- package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/chart/Radar.cjs +6 -0
- package/dist/components/data-display/chart/Radar.cjs.map +1 -0
- package/dist/components/data-display/chart/Radar.mjs +7 -0
- package/dist/components/data-display/chart/Radar.mjs.map +1 -0
- package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.cjs +347 -0
- package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.mjs +346 -0
- package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/chart/Sparkline.cjs +6 -0
- package/dist/components/data-display/chart/Sparkline.cjs.map +1 -0
- package/dist/components/data-display/chart/Sparkline.mjs +7 -0
- package/dist/components/data-display/chart/Sparkline.mjs.map +1 -0
- package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.cjs +293 -0
- package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.mjs +292 -0
- package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/data-display/chart/useChart.cjs +189 -0
- package/dist/components/data-display/chart/useChart.cjs.map +1 -0
- package/dist/components/data-display/chart/useChart.mjs +182 -0
- package/dist/components/data-display/chart/useChart.mjs.map +1 -0
- package/dist/components/data-display/date-picker/DateRangePicker.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.cjs +1 -7
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +1 -7
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/feedback/Tooltip.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +20 -3
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +20 -3
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Button.cjs +1 -1
- package/dist/components/forms/Button.cjs.map +1 -1
- package/dist/components/forms/Button.mjs +1 -1
- package/dist/components/forms/Button.mjs.map +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs +76 -63
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs +77 -64
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/ButtonGroup.cjs +1 -1
- package/dist/components/forms/ButtonGroup.cjs.map +1 -1
- package/dist/components/forms/ButtonGroup.mjs +1 -1
- package/dist/components/forms/ButtonGroup.mjs.map +1 -1
- package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Checkbox.cjs +1 -1
- package/dist/components/forms/Checkbox.cjs.map +1 -1
- package/dist/components/forms/Checkbox.mjs +1 -1
- package/dist/components/forms/Checkbox.mjs.map +1 -1
- package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.cjs +7 -7
- package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.mjs +7 -7
- package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/ColorPicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/ColorPicker.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/DateField.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/DateField.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/DateRangeField.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/DateRangeField.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/DateTimeField.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/DateTimeField.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/FormField.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/FormField.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/Input.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/Input.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/MenuButton.cjs +6 -0
- package/dist/components/forms/MenuButton.cjs.map +1 -0
- package/dist/components/forms/MenuButton.mjs +7 -0
- package/dist/components/forms/MenuButton.mjs.map +1 -0
- package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.cjs +270 -0
- package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.mjs +269 -0
- package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/NumberInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/NumberInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/OTPInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/OTPInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/PasswordInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/PasswordInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/Radio.cjs +1 -1
- package/dist/components/forms/Radio.cjs.map +1 -1
- package/dist/components/forms/Radio.mjs +1 -1
- package/dist/components/forms/Radio.mjs.map +1 -1
- package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.cjs +6 -6
- package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.mjs +6 -6
- package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/RangeSlider.cjs.map +1 -1
- package/dist/components/forms/RangeSlider.mjs.map +1 -1
- package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.cjs +6 -6
- package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.mjs +6 -6
- package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/SearchInput.cjs.map +1 -1
- package/dist/components/forms/SearchInput.mjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +225 -20
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +227 -22
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Segmented.cjs +1 -1
- package/dist/components/forms/Segmented.cjs.map +1 -1
- package/dist/components/forms/Segmented.mjs +1 -1
- package/dist/components/forms/Segmented.mjs.map +1 -1
- package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.cjs +4 -12
- package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.mjs +4 -12
- package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Select.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/Select.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/Slider.cjs.map +1 -1
- package/dist/components/forms/Slider.mjs.map +1 -1
- package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.cjs +6 -6
- package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.mjs +6 -6
- package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Switch.cjs +1 -1
- package/dist/components/forms/Switch.cjs.map +1 -1
- package/dist/components/forms/Switch.mjs +1 -1
- package/dist/components/forms/Switch.mjs.map +1 -1
- package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.cjs +7 -7
- package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.mjs +7 -7
- package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/layout/AppShell.cjs.map +1 -1
- package/dist/components/layout/AppShell.mjs.map +1 -1
- package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.cjs +8 -8
- package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.mjs +8 -8
- package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/Sidebar.cjs.map +1 -1
- package/dist/components/layout/Sidebar.mjs.map +1 -1
- package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.cjs +36 -21
- package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.mjs +36 -21
- package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/Topbar.cjs.map +1 -1
- package/dist/components/layout/Topbar.mjs.map +1 -1
- package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Switcher.cjs.map +1 -1
- package/dist/components/navigation/Switcher.mjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +4 -4
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Tabs.cjs +1 -1
- package/dist/components/navigation/Tabs.cjs.map +1 -1
- package/dist/components/navigation/Tabs.mjs +1 -1
- package/dist/components/navigation/Tabs.mjs.map +1 -1
- package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.cjs +1 -9
- package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.mjs +1 -9
- package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/composables/useField.cjs +21 -23
- package/dist/composables/useField.cjs.map +1 -1
- package/dist/composables/useField.mjs +21 -24
- package/dist/composables/useField.mjs.map +1 -1
- package/dist/composables/usePopover.cjs +5 -1
- package/dist/composables/usePopover.cjs.map +1 -1
- package/dist/composables/usePopover.mjs +5 -1
- package/dist/composables/usePopover.mjs.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.mjs +4 -2
- package/dist/mood-ui.css +107 -473
- package/dist/types/components/data-display/Chart.vue.d.ts +8 -0
- package/dist/types/components/data-display/Stat.vue.d.ts +12 -2
- package/dist/types/components/data-display/chart/Cartesian.vue.d.ts +17 -0
- package/dist/types/components/data-display/chart/Heatmap.vue.d.ts +10 -0
- package/dist/types/components/data-display/chart/Polar.vue.d.ts +9 -0
- package/dist/types/components/data-display/chart/Radar.vue.d.ts +10 -0
- package/dist/types/components/data-display/chart/Sparkline.vue.d.ts +13 -0
- package/dist/types/components/data-display/chart/useChart.d.ts +49 -0
- package/dist/types/components/feedback/Drawer.vue.d.ts +2 -2
- package/dist/types/components/feedback/Modal.vue.d.ts +2 -2
- package/dist/types/components/feedback/Tooltip.vue.d.ts +1 -1
- package/dist/types/components/forms/Button.vue.d.ts +3 -2
- package/dist/types/components/forms/Combobox.vue.d.ts +3 -3
- package/dist/types/components/forms/DateField.vue.d.ts +3 -3
- package/dist/types/components/forms/DateRangeField.vue.d.ts +3 -3
- package/dist/types/components/forms/DateTimeField.vue.d.ts +3 -3
- package/dist/types/components/forms/MenuButton.vue.d.ts +23 -0
- package/dist/types/components/forms/MultiSelect.vue.d.ts +3 -3
- package/dist/types/components/forms/SearchInput.vue.d.ts +33 -2
- package/dist/types/components/forms/Select.vue.d.ts +2 -2
- package/dist/types/components/layout/AppShell.vue.d.ts +1 -1
- package/dist/types/components/layout/PageHeader.vue.d.ts +1 -1
- package/dist/types/components/layout/Sidebar.vue.d.ts +4 -4
- package/dist/types/components/layout/Stack.vue.d.ts +1 -1
- package/dist/types/components/layout/Topbar.vue.d.ts +1 -1
- package/dist/types/components/navigation/Breadcrumbs.vue.d.ts +1 -1
- package/dist/types/components/navigation/Switcher.vue.d.ts +3 -3
- package/dist/types/composables/useField.d.ts +10 -0
- package/dist/types/composables/usePopover.d.ts +7 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/interfaces/data-display/Chart.interface.d.ts +97 -0
- package/dist/types/interfaces/data-display/Stat.interface.d.ts +17 -6
- package/dist/types/interfaces/feedback/Tooltip.interface.d.ts +11 -0
- package/dist/types/interfaces/forms/MenuButton.interface.d.ts +38 -0
- package/dist/types/interfaces/forms/SearchInput.interface.d.ts +36 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeSlider.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/components/forms/RangeSlider.vue"],"sourcesContent":["<template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <div\n v-if=\"label || showValue\"\n class=\"flex items-center justify-between gap-2\"\n >\n <label\n v-if=\"label\"\n :for=\"fieldId\"\n class=\"text-caption font-medium text-foreground\"\n >\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\"\n >*</span\n >\n </label>\n <span\n v-if=\"showValue\"\n class=\"text-caption tabular-nums text-muted-foreground\"\n >\n {{ displayFrom }} – {{ displayTo }}\n </span>\n </div>\n\n <div\n ref=\"trackEl\"\n :class=\"[\n 'relative w-full select-none touch-none',\n trackHeightClass,\n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @pointerdown=\"onTrackPointerDown\"\n >\n <!-- Track bg -->\n <div\n :class=\"[\n 'absolute inset-x-0 top-1/2 -translate-y-1/2 bg-muted',\n trackRadiusClass,\n trackThicknessClass,\n ]\"\n />\n <!-- Filled segment -->\n <div\n :class=\"[\n 'absolute top-1/2 -translate-y-1/2 transition-colors duration-base ease-standard',\n trackRadiusClass,\n trackThicknessClass,\n fillColorClass,\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n width: `${toPercent - fromPercent}%`,\n }\"\n />\n\n <!-- Marks -->\n <template v-if=\"resolvedMarks.length\">\n <div\n v-for=\"mark in resolvedMarks\"\n :key=\"mark.value\"\n class=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2\"\n :style=\"{ left: `${valueToPercent(mark.value)}%` }\"\n >\n <span\n :class=\"[\n 'block rounded-full',\n markSizeClass,\n mark.value >= fromValue && mark.value <= toValue\n ? fillColorClass\n : 'bg-muted-foreground',\n ]\"\n />\n <span\n v-if=\"mark.label\"\n class=\"absolute left-1/2 -translate-x-1/2 top-full mt-1 text-[11px] text-muted-foreground whitespace-nowrap\"\n >\n {{ mark.label }}\n </span>\n </div>\n </template>\n\n <!-- Thumb FROM -->\n <button\n :id=\"fieldId\"\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' from'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"fromValue\"\n :aria-valuetext=\"displayFrom\"\n :aria-disabled=\"isDisabled || undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n zIndex: activeThumb === 'from' ? 3 : 2,\n }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'from')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'from')\"\n />\n <!-- Thumb TO -->\n <button\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' to'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"toValue\"\n :aria-valuetext=\"displayTo\"\n :aria-disabled=\"isDisabled || undefined\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{ left: `${toPercent}%`, zIndex: activeThumb === 'to' ? 3 : 2 }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'to')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'to')\"\n />\n </div>\n\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\n <Typography\n v-if=\"errorText\"\n :id=\"errorId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"danger\"\n as=\"p\"\n >{{ errorText }}</Typography\n >\n <Typography\n v-else-if=\"helperText\"\n :id=\"helperId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"muted\"\n as=\"p\"\n >{{ helperText }}</Typography\n >\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport type { RangeSlider } from \"../../interfaces/forms/RangeSlider.interface\";\nimport { useFieldState } from \"../../composables/useField\";\nimport {\n useResolvedRadius,\n useResolvedSize,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\nimport Typography from \"../data-display/Typography.vue\";\n\nconst props = withDefaults(defineProps<RangeSlider>(), {\n modelValue: () => [0, 100] as [number, number],\n min: 0,\n max: 100,\n step: 1,\n minDistance: 0,\n showValue: false,\n marks: false,\n orientation: \"horizontal\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n fullWidth: true,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n// Track radius (default pill). Thumbs are always round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? \"full\");\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"medium\":\n return \"rounded-md\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n default:\n return \"rounded-full\";\n }\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: [number, number]];\n change: [value: [number, number]];\n}>();\n\nconst {\n fieldId,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n stateColor,\n} = useFieldState(props, {\n componentName: \"RangeSlider\",\n idPrefix: \"modo-range\",\n});\n\nconst trackEl = ref<HTMLElement | null>(null);\ntype Thumb = \"from\" | \"to\";\nconst activeThumb = ref<Thumb | null>(null);\n\nconst fromValue = computed(() => {\n const v = props.modelValue?.[0] ?? props.min;\n return Math.min(Math.max(v, props.min), props.max);\n});\nconst toValue = computed(() => {\n const v = props.modelValue?.[1] ?? props.max;\n return Math.min(Math.max(v, props.min), props.max);\n});\n\nconst fromPercent = computed(() => valueToPercent(fromValue.value));\nconst toPercent = computed(() => valueToPercent(toValue.value));\n\nfunction valueToPercent(v: number) {\n if (props.max === props.min) return 0;\n return ((v - props.min) / (props.max - props.min)) * 100;\n}\nfunction percentToValue(pct: number) {\n const raw = props.min + (pct / 100) * (props.max - props.min);\n return clampToStep(raw);\n}\nfunction clampToStep(v: number) {\n const steps = Math.round((v - props.min) / props.step);\n const snapped = props.min + steps * props.step;\n const clamped = Math.min(Math.max(snapped, props.min), props.max);\n const precision = String(props.step).includes(\".\")\n ? String(props.step).split(\".\")[1].length\n : 0;\n return Number(clamped.toFixed(precision));\n}\n\nfunction emitValue(next: [number, number]) {\n if (props.readonly || isDisabled.value) return;\n const cur = props.modelValue ?? [props.min, props.max];\n if (cur[0] === next[0] && cur[1] === next[1]) return;\n emit(\"update:modelValue\", next);\n emit(\"change\", next);\n}\n\nfunction setThumb(thumb: Thumb, raw: number) {\n const v = clampToStep(raw);\n if (thumb === \"from\") {\n const maxAllowed = toValue.value - props.minDistance;\n emitValue([Math.min(v, maxAllowed), toValue.value]);\n } else {\n const minAllowed = fromValue.value + props.minDistance;\n emitValue([fromValue.value, Math.max(v, minAllowed)]);\n }\n}\n\n/* ---------- Pointer drag ---------- */\nlet activePointer: number | null = null;\nlet draggingThumb: Thumb | null = null;\n\nfunction onTrackPointerDown(e: PointerEvent) {\n if (isDisabled.value || props.readonly) return;\n if (!trackEl.value) return;\n // Pick nearest thumb\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n const v = percentToValue(pct);\n const thumb: Thumb =\n Math.abs(v - fromValue.value) <= Math.abs(v - toValue.value)\n ? \"from\"\n : \"to\";\n activeThumb.value = thumb;\n startDrag(e, thumb);\n setThumb(thumb, v);\n}\nfunction onThumbPointerDown(e: PointerEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n activeThumb.value = thumb;\n startDrag(e, thumb);\n}\nfunction startDrag(e: PointerEvent, thumb: Thumb) {\n activePointer = e.pointerId;\n draggingThumb = thumb;\n window.addEventListener(\"pointermove\", onPointerMove);\n window.addEventListener(\"pointerup\", onPointerUp);\n window.addEventListener(\"pointercancel\", onPointerUp);\n}\nfunction onPointerMove(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n if (!trackEl.value || !draggingThumb) return;\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n setThumb(draggingThumb, percentToValue(pct));\n}\nfunction onPointerUp(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n activePointer = null;\n draggingThumb = null;\n window.removeEventListener(\"pointermove\", onPointerMove);\n window.removeEventListener(\"pointerup\", onPointerUp);\n window.removeEventListener(\"pointercancel\", onPointerUp);\n}\n\n/* ---------- Keyboard ---------- */\nfunction onThumbKeydown(e: KeyboardEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n const cur = thumb === \"from\" ? fromValue.value : toValue.value;\n const bigStep = props.step * 10;\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n e.preventDefault();\n setThumb(thumb, cur + (e.shiftKey ? bigStep : props.step));\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n e.preventDefault();\n setThumb(thumb, cur - (e.shiftKey ? bigStep : props.step));\n break;\n case \"PageUp\":\n e.preventDefault();\n setThumb(thumb, cur + bigStep);\n break;\n case \"PageDown\":\n e.preventDefault();\n setThumb(thumb, cur - bigStep);\n break;\n case \"Home\":\n e.preventDefault();\n setThumb(thumb, props.min);\n break;\n case \"End\":\n e.preventDefault();\n setThumb(thumb, props.max);\n break;\n }\n activeThumb.value = thumb;\n}\n\n/* ---------- Marks ---------- */\nconst resolvedMarks = computed<{ value: number; label?: string }[]>(() => {\n if (!props.marks) return [];\n if (props.marks === true) {\n const out: { value: number }[] = [];\n for (let v = props.min; v <= props.max; v += props.step)\n out.push({ value: v });\n return out;\n }\n if (Array.isArray(props.marks)) {\n return props.marks.map((m) => (typeof m === \"number\" ? { value: m } : m));\n }\n return [];\n});\n\n/* ---------- Display ---------- */\nconst displayFrom = computed(() =>\n props.formatValue\n ? props.formatValue(fromValue.value)\n : String(fromValue.value),\n);\nconst displayTo = computed(() =>\n props.formatValue ? props.formatValue(toValue.value) : String(toValue.value),\n);\n\n/* ---------- Style maps ---------- */\nconst trackHeightClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-5\";\n case \"large\":\n return \"h-8\";\n default:\n return \"h-6\";\n }\n});\nconst trackThicknessClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-1\";\n case \"large\":\n return \"h-2\";\n default:\n return \"h-1.5\";\n }\n});\nconst thumbSizeClass = computed(() => {\n switch (sz.value.box) {\n case 'h-4 w-4': return 'w-4 h-4'; // xsmall\n case 'h-[18px] w-[18px]': return 'w-[18px] h-[18px]'; // small\n case 'h-6 w-6': return 'w-6 h-6'; // large\n case 'h-5 w-5': // medium (default)\n default: return 'w-5 h-5';\n }\n});\nconst markSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-1 h-1\";\n case \"large\":\n return \"w-2 h-2\";\n default:\n return \"w-1.5 h-1.5\";\n }\n});\n\nconst FILL_BY_COLOR: Record<string, string> = {\n default: \"bg-foreground\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\nconst BORDER_BY_COLOR: Record<string, string> = {\n default: \"border-foreground\",\n primary: \"border-primary\",\n danger: \"border-destructive\",\n success: \"border-success\",\n warning: \"border-warning\",\n};\nconst fillColorClass = computed(\n () =>\n FILL_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"bg-foreground\",\n);\nconst thumbBorderColorClass = computed(\n () =>\n BORDER_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"border-foreground\",\n);\n\nconst THUMB_HALO_BY_COLOR: Record<string, string> = {\n default:\n \"ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-foreground/30\",\n primary:\n \"ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-primary/35\",\n danger:\n \"ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-destructive/35\",\n success:\n \"ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-success/35\",\n warning:\n \"ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-warning/35\",\n};\nconst thumbHaloClass = computed(\n () =>\n THUMB_HALO_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n THUMB_HALO_BY_COLOR.default,\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+KA,MAAM,Q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OAAA,CAAA;MACnD,eAAW,OAAA,OAAA,OAAA,MAAA,GAAA,IAAA,gBAAQ,MAAoB,mBAAmB,GAAC,KAAA,EAAA,CAAA,OAAA,CAAA;MAC3D,WAAO,OAAA,OAAA,OAAA,MAAG,MAAqB,eAAe,GAAC,KAAA;;;IAIzC,QAAA,aAAa,QAAA,eAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAmBlB,OAnBN,YAmBM,CAjBI,QAAA,cAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aAOP,mBAAA,SAAA;;KANE,KAAA,GAAA,IAAA,OAAI,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;qCACa,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGF,QAAA,eAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aAOZ,mBAAA,SAAA;;KANE,KAAA,GAAA,IAAA,OAAI,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;qCACc,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"RangeSlider.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/components/forms/RangeSlider.vue"],"sourcesContent":["<template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <div\n v-if=\"label || showValue\"\n class=\"flex items-center justify-between gap-2\"\n >\n <label\n v-if=\"label\"\n :for=\"fieldId\"\n class=\"text-caption font-medium text-foreground\"\n >\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\"\n >*</span\n >\n </label>\n <span\n v-if=\"showValue\"\n class=\"text-caption tabular-nums text-muted-foreground\"\n >\n {{ displayFrom }} – {{ displayTo }}\n </span>\n </div>\n\n <div\n ref=\"trackEl\"\n :class=\"[\n 'relative w-full select-none touch-none',\n trackHeightClass,\n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @pointerdown=\"onTrackPointerDown\"\n >\n <!-- Track bg -->\n <div\n :class=\"[\n 'absolute inset-x-0 top-1/2 -translate-y-1/2 bg-muted',\n trackRadiusClass,\n trackThicknessClass,\n ]\"\n />\n <!-- Filled segment -->\n <div\n :class=\"[\n 'absolute top-1/2 -translate-y-1/2 transition-colors duration-base ease-standard',\n trackRadiusClass,\n trackThicknessClass,\n fillColorClass,\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n width: `${toPercent - fromPercent}%`,\n }\"\n />\n\n <!-- Marks -->\n <template v-if=\"resolvedMarks.length\">\n <div\n v-for=\"mark in resolvedMarks\"\n :key=\"mark.value\"\n class=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2\"\n :style=\"{ left: `${valueToPercent(mark.value)}%` }\"\n >\n <span\n :class=\"[\n 'block rounded-full',\n markSizeClass,\n mark.value >= fromValue && mark.value <= toValue\n ? fillColorClass\n : 'bg-muted-foreground',\n ]\"\n />\n <span\n v-if=\"mark.label\"\n class=\"absolute left-1/2 -translate-x-1/2 top-full mt-1 text-[11px] text-muted-foreground whitespace-nowrap\"\n >\n {{ mark.label }}\n </span>\n </div>\n </template>\n\n <!-- Thumb FROM -->\n <button\n :id=\"fieldId\"\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' from'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"fromValue\"\n :aria-valuetext=\"displayFrom\"\n :aria-disabled=\"isDisabled || undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n zIndex: activeThumb === 'from' ? 3 : 2,\n }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'from')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'from')\"\n />\n <!-- Thumb TO -->\n <button\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' to'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"toValue\"\n :aria-valuetext=\"displayTo\"\n :aria-disabled=\"isDisabled || undefined\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{ left: `${toPercent}%`, zIndex: activeThumb === 'to' ? 3 : 2 }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'to')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'to')\"\n />\n </div>\n\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\n <Typography\n v-if=\"errorText\"\n :id=\"errorId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"danger\"\n as=\"p\"\n >{{ errorText }}</Typography\n >\n <Typography\n v-else-if=\"helperText\"\n :id=\"helperId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"muted\"\n as=\"p\"\n >{{ helperText }}</Typography\n >\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport type { RangeSlider } from \"../../interfaces/forms/RangeSlider.interface\";\nimport { useFieldState } from \"../../composables/useField\";\nimport {\n useResolvedRadius,\n useResolvedSize,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\nimport Typography from \"../data-display/Typography.vue\";\n\nconst props = withDefaults(defineProps<RangeSlider>(), {\n modelValue: () => [0, 100] as [number, number],\n min: 0,\n max: 100,\n step: 1,\n minDistance: 0,\n showValue: false,\n marks: false,\n orientation: \"horizontal\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n fullWidth: true,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n// Track radius (default pill). Thumbs are always round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? \"full\");\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"medium\":\n return \"rounded-md\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n default:\n return \"rounded-full\";\n }\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: [number, number]];\n change: [value: [number, number]];\n}>();\n\nconst {\n fieldId,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n stateColor,\n} = useFieldState(props, {\n componentName: \"RangeSlider\",\n idPrefix: \"modo-range\",\n});\n\nconst trackEl = ref<HTMLElement | null>(null);\ntype Thumb = \"from\" | \"to\";\nconst activeThumb = ref<Thumb | null>(null);\n\nconst fromValue = computed(() => {\n const v = props.modelValue?.[0] ?? props.min;\n return Math.min(Math.max(v, props.min), props.max);\n});\nconst toValue = computed(() => {\n const v = props.modelValue?.[1] ?? props.max;\n return Math.min(Math.max(v, props.min), props.max);\n});\n\nconst fromPercent = computed(() => valueToPercent(fromValue.value));\nconst toPercent = computed(() => valueToPercent(toValue.value));\n\nfunction valueToPercent(v: number) {\n if (props.max === props.min) return 0;\n return ((v - props.min) / (props.max - props.min)) * 100;\n}\nfunction percentToValue(pct: number) {\n const raw = props.min + (pct / 100) * (props.max - props.min);\n return clampToStep(raw);\n}\nfunction clampToStep(v: number) {\n const steps = Math.round((v - props.min) / props.step);\n const snapped = props.min + steps * props.step;\n const clamped = Math.min(Math.max(snapped, props.min), props.max);\n const precision = String(props.step).includes(\".\")\n ? String(props.step).split(\".\")[1].length\n : 0;\n return Number(clamped.toFixed(precision));\n}\n\nfunction emitValue(next: [number, number]) {\n if (props.readonly || isDisabled.value) return;\n const cur = props.modelValue ?? [props.min, props.max];\n if (cur[0] === next[0] && cur[1] === next[1]) return;\n emit(\"update:modelValue\", next);\n emit(\"change\", next);\n}\n\nfunction setThumb(thumb: Thumb, raw: number) {\n const v = clampToStep(raw);\n if (thumb === \"from\") {\n const maxAllowed = toValue.value - props.minDistance;\n emitValue([Math.min(v, maxAllowed), toValue.value]);\n } else {\n const minAllowed = fromValue.value + props.minDistance;\n emitValue([fromValue.value, Math.max(v, minAllowed)]);\n }\n}\n\n/* ---------- Pointer drag ---------- */\nlet activePointer: number | null = null;\nlet draggingThumb: Thumb | null = null;\n\nfunction onTrackPointerDown(e: PointerEvent) {\n if (isDisabled.value || props.readonly) return;\n if (!trackEl.value) return;\n // Pick nearest thumb\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n const v = percentToValue(pct);\n const thumb: Thumb =\n Math.abs(v - fromValue.value) <= Math.abs(v - toValue.value)\n ? \"from\"\n : \"to\";\n activeThumb.value = thumb;\n startDrag(e, thumb);\n setThumb(thumb, v);\n}\nfunction onThumbPointerDown(e: PointerEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n activeThumb.value = thumb;\n startDrag(e, thumb);\n}\nfunction startDrag(e: PointerEvent, thumb: Thumb) {\n activePointer = e.pointerId;\n draggingThumb = thumb;\n window.addEventListener(\"pointermove\", onPointerMove);\n window.addEventListener(\"pointerup\", onPointerUp);\n window.addEventListener(\"pointercancel\", onPointerUp);\n}\nfunction onPointerMove(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n if (!trackEl.value || !draggingThumb) return;\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n setThumb(draggingThumb, percentToValue(pct));\n}\nfunction onPointerUp(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n activePointer = null;\n draggingThumb = null;\n window.removeEventListener(\"pointermove\", onPointerMove);\n window.removeEventListener(\"pointerup\", onPointerUp);\n window.removeEventListener(\"pointercancel\", onPointerUp);\n}\n\n/* ---------- Keyboard ---------- */\nfunction onThumbKeydown(e: KeyboardEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n const cur = thumb === \"from\" ? fromValue.value : toValue.value;\n const bigStep = props.step * 10;\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n e.preventDefault();\n setThumb(thumb, cur + (e.shiftKey ? bigStep : props.step));\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n e.preventDefault();\n setThumb(thumb, cur - (e.shiftKey ? bigStep : props.step));\n break;\n case \"PageUp\":\n e.preventDefault();\n setThumb(thumb, cur + bigStep);\n break;\n case \"PageDown\":\n e.preventDefault();\n setThumb(thumb, cur - bigStep);\n break;\n case \"Home\":\n e.preventDefault();\n setThumb(thumb, props.min);\n break;\n case \"End\":\n e.preventDefault();\n setThumb(thumb, props.max);\n break;\n }\n activeThumb.value = thumb;\n}\n\n/* ---------- Marks ---------- */\nconst resolvedMarks = computed<{ value: number; label?: string }[]>(() => {\n if (!props.marks) return [];\n if (props.marks === true) {\n const out: { value: number }[] = [];\n for (let v = props.min; v <= props.max; v += props.step)\n out.push({ value: v });\n return out;\n }\n if (Array.isArray(props.marks)) {\n return props.marks.map((m) => (typeof m === \"number\" ? { value: m } : m));\n }\n return [];\n});\n\n/* ---------- Display ---------- */\nconst displayFrom = computed(() =>\n props.formatValue\n ? props.formatValue(fromValue.value)\n : String(fromValue.value),\n);\nconst displayTo = computed(() =>\n props.formatValue ? props.formatValue(toValue.value) : String(toValue.value),\n);\n\n/* ---------- Style maps ---------- */\nconst trackHeightClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-5\";\n case \"large\":\n return \"h-8\";\n default:\n return \"h-6\";\n }\n});\nconst trackThicknessClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-1\";\n case \"large\":\n return \"h-2\";\n default:\n return \"h-1.5\";\n }\n});\nconst thumbSizeClass = computed(() => {\n switch (sz.value.box) {\n case 'h-4 w-4': return 'w-4 h-4'; // xsmall\n case 'h-[18px] w-[18px]': return 'w-[18px] h-[18px]'; // small\n case 'h-6 w-6': return 'w-6 h-6'; // large\n case 'h-5 w-5': // medium (default)\n default: return 'w-5 h-5';\n }\n});\nconst markSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-1 h-1\";\n case \"large\":\n return \"w-2 h-2\";\n default:\n return \"w-1.5 h-1.5\";\n }\n});\n\nconst FILL_BY_COLOR: Record<string, string> = {\n default: \"bg-foreground\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\nconst BORDER_BY_COLOR: Record<string, string> = {\n default: \"border-foreground\",\n primary: \"border-primary\",\n danger: \"border-destructive\",\n success: \"border-success\",\n warning: \"border-warning\",\n};\nconst fillColorClass = computed(\n () =>\n FILL_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"bg-foreground\",\n);\nconst thumbBorderColorClass = computed(\n () =>\n BORDER_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"border-foreground\",\n);\n\nconst THUMB_HALO_BY_COLOR: Record<string, string> = {\n // Idle/hover halo stays tinted per color; focus uses the unified ring.\n default:\n \"ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-ring/60\",\n primary:\n \"ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-ring/60\",\n danger:\n \"ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-ring/60\",\n success:\n \"ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-ring/60\",\n warning:\n \"ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-ring/60\",\n};\nconst thumbHaloClass = computed(\n () =>\n THUMB_HALO_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n THUMB_HALO_BY_COLOR.default,\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+KA,MAAM,QAAQ;EAgBd,MAAM,eAAe,sBAAA,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,sBAAA,oBAAoB,MAAM,KAAK;EAE1C,MAAM,iBAAiB,sBAAA,wBAAwB,MAAM,UAAU,OAAO;EACtE,MAAM,oBAAA,GAAA,IAAA,gBAAkC;GACtC,QAAQ,eAAe,OAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,SACH,OAAO;IACT,KAAK,UACH,OAAO;IACT,KAAK,SACH,OAAO;IAET,SACE,OAAO;;IAEX;EAEF,MAAM,OAAO;EAKb,MAAM,EACJ,SACA,UACA,YACA,SACA,UACA,aACA,eACE,iBAAA,cAAc,OAAO;GACvB,eAAe;GACf,UAAU;GACX,CAAC;EAEF,MAAM,WAAA,GAAA,IAAA,KAAkC,KAAK;EAE7C,MAAM,eAAA,GAAA,IAAA,KAAgC,KAAK;EAE3C,MAAM,aAAA,GAAA,IAAA,gBAA2B;GAC/B,MAAM,IAAI,MAAM,aAAa,MAAM,MAAM;GACzC,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,EAAE,MAAM,IAAI;IAClD;EACF,MAAM,WAAA,GAAA,IAAA,gBAAy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A,WAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useResolvedRadius, useResolvedSize, useSizeTokens } from "../../composables/useModoConfig.mjs";
|
|
2
|
-
import Typography_default from "../data-display/Typography.mjs";
|
|
3
2
|
import { useFieldState } from "../../composables/useField.mjs";
|
|
3
|
+
import Typography_default from "../data-display/Typography.mjs";
|
|
4
4
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, ref, renderList, toDisplayString, unref, withCtx, withModifiers } from "vue";
|
|
5
5
|
//#region src/components/forms/RangeSlider.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
var _hoisted_1 = {
|
|
@@ -284,11 +284,11 @@ var RangeSlider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
284
284
|
const fillColorClass = computed(() => FILL_BY_COLOR[hasError.value ? "danger" : stateColor.value] ?? "bg-foreground");
|
|
285
285
|
const thumbBorderColorClass = computed(() => BORDER_BY_COLOR[hasError.value ? "danger" : stateColor.value] ?? "border-foreground");
|
|
286
286
|
const THUMB_HALO_BY_COLOR = {
|
|
287
|
-
default: "ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-
|
|
288
|
-
primary: "ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-
|
|
289
|
-
danger: "ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-
|
|
290
|
-
success: "ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-
|
|
291
|
-
warning: "ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-
|
|
287
|
+
default: "ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-ring/60",
|
|
288
|
+
primary: "ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-ring/60",
|
|
289
|
+
danger: "ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-ring/60",
|
|
290
|
+
success: "ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-ring/60",
|
|
291
|
+
warning: "ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-ring/60"
|
|
292
292
|
};
|
|
293
293
|
const thumbHaloClass = computed(() => THUMB_HALO_BY_COLOR[hasError.value ? "danger" : stateColor.value] ?? THUMB_HALO_BY_COLOR.default);
|
|
294
294
|
return (_ctx, _cache) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeSlider.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/RangeSlider.vue"],"sourcesContent":["<template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <div\n v-if=\"label || showValue\"\n class=\"flex items-center justify-between gap-2\"\n >\n <label\n v-if=\"label\"\n :for=\"fieldId\"\n class=\"text-caption font-medium text-foreground\"\n >\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\"\n >*</span\n >\n </label>\n <span\n v-if=\"showValue\"\n class=\"text-caption tabular-nums text-muted-foreground\"\n >\n {{ displayFrom }} – {{ displayTo }}\n </span>\n </div>\n\n <div\n ref=\"trackEl\"\n :class=\"[\n 'relative w-full select-none touch-none',\n trackHeightClass,\n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @pointerdown=\"onTrackPointerDown\"\n >\n <!-- Track bg -->\n <div\n :class=\"[\n 'absolute inset-x-0 top-1/2 -translate-y-1/2 bg-muted',\n trackRadiusClass,\n trackThicknessClass,\n ]\"\n />\n <!-- Filled segment -->\n <div\n :class=\"[\n 'absolute top-1/2 -translate-y-1/2 transition-colors duration-base ease-standard',\n trackRadiusClass,\n trackThicknessClass,\n fillColorClass,\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n width: `${toPercent - fromPercent}%`,\n }\"\n />\n\n <!-- Marks -->\n <template v-if=\"resolvedMarks.length\">\n <div\n v-for=\"mark in resolvedMarks\"\n :key=\"mark.value\"\n class=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2\"\n :style=\"{ left: `${valueToPercent(mark.value)}%` }\"\n >\n <span\n :class=\"[\n 'block rounded-full',\n markSizeClass,\n mark.value >= fromValue && mark.value <= toValue\n ? fillColorClass\n : 'bg-muted-foreground',\n ]\"\n />\n <span\n v-if=\"mark.label\"\n class=\"absolute left-1/2 -translate-x-1/2 top-full mt-1 text-[11px] text-muted-foreground whitespace-nowrap\"\n >\n {{ mark.label }}\n </span>\n </div>\n </template>\n\n <!-- Thumb FROM -->\n <button\n :id=\"fieldId\"\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' from'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"fromValue\"\n :aria-valuetext=\"displayFrom\"\n :aria-disabled=\"isDisabled || undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n zIndex: activeThumb === 'from' ? 3 : 2,\n }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'from')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'from')\"\n />\n <!-- Thumb TO -->\n <button\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' to'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"toValue\"\n :aria-valuetext=\"displayTo\"\n :aria-disabled=\"isDisabled || undefined\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{ left: `${toPercent}%`, zIndex: activeThumb === 'to' ? 3 : 2 }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'to')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'to')\"\n />\n </div>\n\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\n <Typography\n v-if=\"errorText\"\n :id=\"errorId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"danger\"\n as=\"p\"\n >{{ errorText }}</Typography\n >\n <Typography\n v-else-if=\"helperText\"\n :id=\"helperId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"muted\"\n as=\"p\"\n >{{ helperText }}</Typography\n >\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport type { RangeSlider } from \"../../interfaces/forms/RangeSlider.interface\";\nimport { useFieldState } from \"../../composables/useField\";\nimport {\n useResolvedRadius,\n useResolvedSize,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\nimport Typography from \"../data-display/Typography.vue\";\n\nconst props = withDefaults(defineProps<RangeSlider>(), {\n modelValue: () => [0, 100] as [number, number],\n min: 0,\n max: 100,\n step: 1,\n minDistance: 0,\n showValue: false,\n marks: false,\n orientation: \"horizontal\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n fullWidth: true,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n// Track radius (default pill). Thumbs are always round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? \"full\");\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"medium\":\n return \"rounded-md\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n default:\n return \"rounded-full\";\n }\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: [number, number]];\n change: [value: [number, number]];\n}>();\n\nconst {\n fieldId,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n stateColor,\n} = useFieldState(props, {\n componentName: \"RangeSlider\",\n idPrefix: \"modo-range\",\n});\n\nconst trackEl = ref<HTMLElement | null>(null);\ntype Thumb = \"from\" | \"to\";\nconst activeThumb = ref<Thumb | null>(null);\n\nconst fromValue = computed(() => {\n const v = props.modelValue?.[0] ?? props.min;\n return Math.min(Math.max(v, props.min), props.max);\n});\nconst toValue = computed(() => {\n const v = props.modelValue?.[1] ?? props.max;\n return Math.min(Math.max(v, props.min), props.max);\n});\n\nconst fromPercent = computed(() => valueToPercent(fromValue.value));\nconst toPercent = computed(() => valueToPercent(toValue.value));\n\nfunction valueToPercent(v: number) {\n if (props.max === props.min) return 0;\n return ((v - props.min) / (props.max - props.min)) * 100;\n}\nfunction percentToValue(pct: number) {\n const raw = props.min + (pct / 100) * (props.max - props.min);\n return clampToStep(raw);\n}\nfunction clampToStep(v: number) {\n const steps = Math.round((v - props.min) / props.step);\n const snapped = props.min + steps * props.step;\n const clamped = Math.min(Math.max(snapped, props.min), props.max);\n const precision = String(props.step).includes(\".\")\n ? String(props.step).split(\".\")[1].length\n : 0;\n return Number(clamped.toFixed(precision));\n}\n\nfunction emitValue(next: [number, number]) {\n if (props.readonly || isDisabled.value) return;\n const cur = props.modelValue ?? [props.min, props.max];\n if (cur[0] === next[0] && cur[1] === next[1]) return;\n emit(\"update:modelValue\", next);\n emit(\"change\", next);\n}\n\nfunction setThumb(thumb: Thumb, raw: number) {\n const v = clampToStep(raw);\n if (thumb === \"from\") {\n const maxAllowed = toValue.value - props.minDistance;\n emitValue([Math.min(v, maxAllowed), toValue.value]);\n } else {\n const minAllowed = fromValue.value + props.minDistance;\n emitValue([fromValue.value, Math.max(v, minAllowed)]);\n }\n}\n\n/* ---------- Pointer drag ---------- */\nlet activePointer: number | null = null;\nlet draggingThumb: Thumb | null = null;\n\nfunction onTrackPointerDown(e: PointerEvent) {\n if (isDisabled.value || props.readonly) return;\n if (!trackEl.value) return;\n // Pick nearest thumb\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n const v = percentToValue(pct);\n const thumb: Thumb =\n Math.abs(v - fromValue.value) <= Math.abs(v - toValue.value)\n ? \"from\"\n : \"to\";\n activeThumb.value = thumb;\n startDrag(e, thumb);\n setThumb(thumb, v);\n}\nfunction onThumbPointerDown(e: PointerEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n activeThumb.value = thumb;\n startDrag(e, thumb);\n}\nfunction startDrag(e: PointerEvent, thumb: Thumb) {\n activePointer = e.pointerId;\n draggingThumb = thumb;\n window.addEventListener(\"pointermove\", onPointerMove);\n window.addEventListener(\"pointerup\", onPointerUp);\n window.addEventListener(\"pointercancel\", onPointerUp);\n}\nfunction onPointerMove(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n if (!trackEl.value || !draggingThumb) return;\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n setThumb(draggingThumb, percentToValue(pct));\n}\nfunction onPointerUp(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n activePointer = null;\n draggingThumb = null;\n window.removeEventListener(\"pointermove\", onPointerMove);\n window.removeEventListener(\"pointerup\", onPointerUp);\n window.removeEventListener(\"pointercancel\", onPointerUp);\n}\n\n/* ---------- Keyboard ---------- */\nfunction onThumbKeydown(e: KeyboardEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n const cur = thumb === \"from\" ? fromValue.value : toValue.value;\n const bigStep = props.step * 10;\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n e.preventDefault();\n setThumb(thumb, cur + (e.shiftKey ? bigStep : props.step));\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n e.preventDefault();\n setThumb(thumb, cur - (e.shiftKey ? bigStep : props.step));\n break;\n case \"PageUp\":\n e.preventDefault();\n setThumb(thumb, cur + bigStep);\n break;\n case \"PageDown\":\n e.preventDefault();\n setThumb(thumb, cur - bigStep);\n break;\n case \"Home\":\n e.preventDefault();\n setThumb(thumb, props.min);\n break;\n case \"End\":\n e.preventDefault();\n setThumb(thumb, props.max);\n break;\n }\n activeThumb.value = thumb;\n}\n\n/* ---------- Marks ---------- */\nconst resolvedMarks = computed<{ value: number; label?: string }[]>(() => {\n if (!props.marks) return [];\n if (props.marks === true) {\n const out: { value: number }[] = [];\n for (let v = props.min; v <= props.max; v += props.step)\n out.push({ value: v });\n return out;\n }\n if (Array.isArray(props.marks)) {\n return props.marks.map((m) => (typeof m === \"number\" ? { value: m } : m));\n }\n return [];\n});\n\n/* ---------- Display ---------- */\nconst displayFrom = computed(() =>\n props.formatValue\n ? props.formatValue(fromValue.value)\n : String(fromValue.value),\n);\nconst displayTo = computed(() =>\n props.formatValue ? props.formatValue(toValue.value) : String(toValue.value),\n);\n\n/* ---------- Style maps ---------- */\nconst trackHeightClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-5\";\n case \"large\":\n return \"h-8\";\n default:\n return \"h-6\";\n }\n});\nconst trackThicknessClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-1\";\n case \"large\":\n return \"h-2\";\n default:\n return \"h-1.5\";\n }\n});\nconst thumbSizeClass = computed(() => {\n switch (sz.value.box) {\n case 'h-4 w-4': return 'w-4 h-4'; // xsmall\n case 'h-[18px] w-[18px]': return 'w-[18px] h-[18px]'; // small\n case 'h-6 w-6': return 'w-6 h-6'; // large\n case 'h-5 w-5': // medium (default)\n default: return 'w-5 h-5';\n }\n});\nconst markSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-1 h-1\";\n case \"large\":\n return \"w-2 h-2\";\n default:\n return \"w-1.5 h-1.5\";\n }\n});\n\nconst FILL_BY_COLOR: Record<string, string> = {\n default: \"bg-foreground\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\nconst BORDER_BY_COLOR: Record<string, string> = {\n default: \"border-foreground\",\n primary: \"border-primary\",\n danger: \"border-destructive\",\n success: \"border-success\",\n warning: \"border-warning\",\n};\nconst fillColorClass = computed(\n () =>\n FILL_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"bg-foreground\",\n);\nconst thumbBorderColorClass = computed(\n () =>\n BORDER_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"border-foreground\",\n);\n\nconst THUMB_HALO_BY_COLOR: Record<string, string> = {\n default:\n \"ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-foreground/30\",\n primary:\n \"ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-primary/35\",\n danger:\n \"ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-destructive/35\",\n success:\n \"ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-success/35\",\n warning:\n \"ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-warning/35\",\n};\nconst thumbHaloClass = computed(\n () =>\n THUMB_HALO_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n THUMB_HALO_BY_COLOR.default,\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+KA,MAAM,QAA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template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <div\n v-if=\"label || showValue\"\n class=\"flex items-center justify-between gap-2\"\n >\n <label\n v-if=\"label\"\n :for=\"fieldId\"\n class=\"text-caption font-medium text-foreground\"\n >\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\"\n >*</span\n >\n </label>\n <span\n v-if=\"showValue\"\n class=\"text-caption tabular-nums text-muted-foreground\"\n >\n {{ displayFrom }} – {{ displayTo }}\n </span>\n </div>\n\n <div\n ref=\"trackEl\"\n :class=\"[\n 'relative w-full select-none touch-none',\n trackHeightClass,\n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @pointerdown=\"onTrackPointerDown\"\n >\n <!-- Track bg -->\n <div\n :class=\"[\n 'absolute inset-x-0 top-1/2 -translate-y-1/2 bg-muted',\n trackRadiusClass,\n trackThicknessClass,\n ]\"\n />\n <!-- Filled segment -->\n <div\n :class=\"[\n 'absolute top-1/2 -translate-y-1/2 transition-colors duration-base ease-standard',\n trackRadiusClass,\n trackThicknessClass,\n fillColorClass,\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n width: `${toPercent - fromPercent}%`,\n }\"\n />\n\n <!-- Marks -->\n <template v-if=\"resolvedMarks.length\">\n <div\n v-for=\"mark in resolvedMarks\"\n :key=\"mark.value\"\n class=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2\"\n :style=\"{ left: `${valueToPercent(mark.value)}%` }\"\n >\n <span\n :class=\"[\n 'block rounded-full',\n markSizeClass,\n mark.value >= fromValue && mark.value <= toValue\n ? fillColorClass\n : 'bg-muted-foreground',\n ]\"\n />\n <span\n v-if=\"mark.label\"\n class=\"absolute left-1/2 -translate-x-1/2 top-full mt-1 text-[11px] text-muted-foreground whitespace-nowrap\"\n >\n {{ mark.label }}\n </span>\n </div>\n </template>\n\n <!-- Thumb FROM -->\n <button\n :id=\"fieldId\"\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' from'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"fromValue\"\n :aria-valuetext=\"displayFrom\"\n :aria-disabled=\"isDisabled || undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{\n left: `${fromPercent}%`,\n zIndex: activeThumb === 'from' ? 3 : 2,\n }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'from')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'from')\"\n />\n <!-- Thumb TO -->\n <button\n type=\"button\"\n role=\"slider\"\n :aria-label=\"(ariaLabel ?? label ?? 'Range') + ' to'\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-valuenow=\"toValue\"\n :aria-valuetext=\"displayTo\"\n :aria-disabled=\"isDisabled || undefined\"\n :disabled=\"isDisabled\"\n :class=\"[\n 'absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-background border-2',\n 'transition-[transform,box-shadow,--tw-ring-color] duration-fast ease-standard',\n thumbSizeClass,\n thumbBorderColorClass,\n thumbHaloClass,\n 'shadow-sm hover:scale-110 focus:outline-none',\n isDisabled\n ? 'cursor-not-allowed'\n : 'cursor-grab active:cursor-grabbing',\n ]\"\n :style=\"{ left: `${toPercent}%`, zIndex: activeThumb === 'to' ? 3 : 2 }\"\n @pointerdown.stop=\"(e: PointerEvent) => onThumbPointerDown(e, 'to')\"\n @keydown=\"(e: KeyboardEvent) => onThumbKeydown(e, 'to')\"\n />\n </div>\n\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\n <Typography\n v-if=\"errorText\"\n :id=\"errorId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"danger\"\n as=\"p\"\n >{{ errorText }}</Typography\n >\n <Typography\n v-else-if=\"helperText\"\n :id=\"helperId\"\n variant=\"caption\"\n size=\"medium\"\n color=\"muted\"\n as=\"p\"\n >{{ helperText }}</Typography\n >\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport type { RangeSlider } from \"../../interfaces/forms/RangeSlider.interface\";\nimport { useFieldState } from \"../../composables/useField\";\nimport {\n useResolvedRadius,\n useResolvedSize,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\nimport Typography from \"../data-display/Typography.vue\";\n\nconst props = withDefaults(defineProps<RangeSlider>(), {\n modelValue: () => [0, 100] as [number, number],\n min: 0,\n max: 100,\n step: 1,\n minDistance: 0,\n showValue: false,\n marks: false,\n orientation: \"horizontal\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n fullWidth: true,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n// Track radius (default pill). Thumbs are always round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? \"full\");\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"medium\":\n return \"rounded-md\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n default:\n return \"rounded-full\";\n }\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: [number, number]];\n change: [value: [number, number]];\n}>();\n\nconst {\n fieldId,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n stateColor,\n} = useFieldState(props, {\n componentName: \"RangeSlider\",\n idPrefix: \"modo-range\",\n});\n\nconst trackEl = ref<HTMLElement | null>(null);\ntype Thumb = \"from\" | \"to\";\nconst activeThumb = ref<Thumb | null>(null);\n\nconst fromValue = computed(() => {\n const v = props.modelValue?.[0] ?? props.min;\n return Math.min(Math.max(v, props.min), props.max);\n});\nconst toValue = computed(() => {\n const v = props.modelValue?.[1] ?? props.max;\n return Math.min(Math.max(v, props.min), props.max);\n});\n\nconst fromPercent = computed(() => valueToPercent(fromValue.value));\nconst toPercent = computed(() => valueToPercent(toValue.value));\n\nfunction valueToPercent(v: number) {\n if (props.max === props.min) return 0;\n return ((v - props.min) / (props.max - props.min)) * 100;\n}\nfunction percentToValue(pct: number) {\n const raw = props.min + (pct / 100) * (props.max - props.min);\n return clampToStep(raw);\n}\nfunction clampToStep(v: number) {\n const steps = Math.round((v - props.min) / props.step);\n const snapped = props.min + steps * props.step;\n const clamped = Math.min(Math.max(snapped, props.min), props.max);\n const precision = String(props.step).includes(\".\")\n ? String(props.step).split(\".\")[1].length\n : 0;\n return Number(clamped.toFixed(precision));\n}\n\nfunction emitValue(next: [number, number]) {\n if (props.readonly || isDisabled.value) return;\n const cur = props.modelValue ?? [props.min, props.max];\n if (cur[0] === next[0] && cur[1] === next[1]) return;\n emit(\"update:modelValue\", next);\n emit(\"change\", next);\n}\n\nfunction setThumb(thumb: Thumb, raw: number) {\n const v = clampToStep(raw);\n if (thumb === \"from\") {\n const maxAllowed = toValue.value - props.minDistance;\n emitValue([Math.min(v, maxAllowed), toValue.value]);\n } else {\n const minAllowed = fromValue.value + props.minDistance;\n emitValue([fromValue.value, Math.max(v, minAllowed)]);\n }\n}\n\n/* ---------- Pointer drag ---------- */\nlet activePointer: number | null = null;\nlet draggingThumb: Thumb | null = null;\n\nfunction onTrackPointerDown(e: PointerEvent) {\n if (isDisabled.value || props.readonly) return;\n if (!trackEl.value) return;\n // Pick nearest thumb\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n const v = percentToValue(pct);\n const thumb: Thumb =\n Math.abs(v - fromValue.value) <= Math.abs(v - toValue.value)\n ? \"from\"\n : \"to\";\n activeThumb.value = thumb;\n startDrag(e, thumb);\n setThumb(thumb, v);\n}\nfunction onThumbPointerDown(e: PointerEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n activeThumb.value = thumb;\n startDrag(e, thumb);\n}\nfunction startDrag(e: PointerEvent, thumb: Thumb) {\n activePointer = e.pointerId;\n draggingThumb = thumb;\n window.addEventListener(\"pointermove\", onPointerMove);\n window.addEventListener(\"pointerup\", onPointerUp);\n window.addEventListener(\"pointercancel\", onPointerUp);\n}\nfunction onPointerMove(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n if (!trackEl.value || !draggingThumb) return;\n const rect = trackEl.value.getBoundingClientRect();\n const pct = Math.min(\n Math.max(((e.clientX - rect.left) / rect.width) * 100, 0),\n 100,\n );\n setThumb(draggingThumb, percentToValue(pct));\n}\nfunction onPointerUp(e: PointerEvent) {\n if (activePointer === null || e.pointerId !== activePointer) return;\n activePointer = null;\n draggingThumb = null;\n window.removeEventListener(\"pointermove\", onPointerMove);\n window.removeEventListener(\"pointerup\", onPointerUp);\n window.removeEventListener(\"pointercancel\", onPointerUp);\n}\n\n/* ---------- Keyboard ---------- */\nfunction onThumbKeydown(e: KeyboardEvent, thumb: Thumb) {\n if (isDisabled.value || props.readonly) return;\n const cur = thumb === \"from\" ? fromValue.value : toValue.value;\n const bigStep = props.step * 10;\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n e.preventDefault();\n setThumb(thumb, cur + (e.shiftKey ? bigStep : props.step));\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n e.preventDefault();\n setThumb(thumb, cur - (e.shiftKey ? bigStep : props.step));\n break;\n case \"PageUp\":\n e.preventDefault();\n setThumb(thumb, cur + bigStep);\n break;\n case \"PageDown\":\n e.preventDefault();\n setThumb(thumb, cur - bigStep);\n break;\n case \"Home\":\n e.preventDefault();\n setThumb(thumb, props.min);\n break;\n case \"End\":\n e.preventDefault();\n setThumb(thumb, props.max);\n break;\n }\n activeThumb.value = thumb;\n}\n\n/* ---------- Marks ---------- */\nconst resolvedMarks = computed<{ value: number; label?: string }[]>(() => {\n if (!props.marks) return [];\n if (props.marks === true) {\n const out: { value: number }[] = [];\n for (let v = props.min; v <= props.max; v += props.step)\n out.push({ value: v });\n return out;\n }\n if (Array.isArray(props.marks)) {\n return props.marks.map((m) => (typeof m === \"number\" ? { value: m } : m));\n }\n return [];\n});\n\n/* ---------- Display ---------- */\nconst displayFrom = computed(() =>\n props.formatValue\n ? props.formatValue(fromValue.value)\n : String(fromValue.value),\n);\nconst displayTo = computed(() =>\n props.formatValue ? props.formatValue(toValue.value) : String(toValue.value),\n);\n\n/* ---------- Style maps ---------- */\nconst trackHeightClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-5\";\n case \"large\":\n return \"h-8\";\n default:\n return \"h-6\";\n }\n});\nconst trackThicknessClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"h-1\";\n case \"large\":\n return \"h-2\";\n default:\n return \"h-1.5\";\n }\n});\nconst thumbSizeClass = computed(() => {\n switch (sz.value.box) {\n case 'h-4 w-4': return 'w-4 h-4'; // xsmall\n case 'h-[18px] w-[18px]': return 'w-[18px] h-[18px]'; // small\n case 'h-6 w-6': return 'w-6 h-6'; // large\n case 'h-5 w-5': // medium (default)\n default: return 'w-5 h-5';\n }\n});\nconst markSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-1 h-1\";\n case \"large\":\n return \"w-2 h-2\";\n default:\n return \"w-1.5 h-1.5\";\n }\n});\n\nconst FILL_BY_COLOR: Record<string, string> = {\n default: \"bg-foreground\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\nconst BORDER_BY_COLOR: Record<string, string> = {\n default: \"border-foreground\",\n primary: \"border-primary\",\n danger: \"border-destructive\",\n success: \"border-success\",\n warning: \"border-warning\",\n};\nconst fillColorClass = computed(\n () =>\n FILL_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"bg-foreground\",\n);\nconst thumbBorderColorClass = computed(\n () =>\n BORDER_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n \"border-foreground\",\n);\n\nconst THUMB_HALO_BY_COLOR: Record<string, string> = {\n // Idle/hover halo stays tinted per color; focus uses the unified ring.\n default:\n \"ring-[3px] ring-foreground/10 hover:ring-foreground/20 focus-visible:ring-ring/60\",\n primary:\n \"ring-[3px] ring-primary/15 hover:ring-primary/25 focus-visible:ring-ring/60\",\n danger:\n \"ring-[3px] ring-destructive/15 hover:ring-destructive/25 focus-visible:ring-ring/60\",\n success:\n \"ring-[3px] ring-success/15 hover:ring-success/25 focus-visible:ring-ring/60\",\n warning:\n \"ring-[3px] ring-warning/15 hover:ring-warning/25 focus-visible:ring-ring/60\",\n};\nconst thumbHaloClass = computed(\n () =>\n THUMB_HALO_BY_COLOR[hasError.value ? \"danger\" : stateColor.value] ??\n THUMB_HALO_BY_COLOR.default,\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+KA,MAAM,QAAQ;EAgBd,MAAM,eAAe,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,oBAAoB,MAAM,KAAK;EAE1C,MAAM,iBAAiB,wBAAwB,MAAM,UAAU,OAAO;EACtE,MAAM,mBAAmB,eAAe;GACtC,QAAQ,eAAe,OAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,SACH,OAAO;IACT,KAAK,UACH,OAAO;IACT,KAAK,SACH,OAAO;IAET,SACE,OAAO;;IAEX;EAEF,MAAM,OAAO;EAKb,MAAM,EACJ,SACA,UACA,YACA,SACA,UACA,aACA,eACE,cAAc,OAAO;GACvB,e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A0B,sBAAA;OAAiC,eAAA;;OAAoF,MAAA,WAAU,GAAA,uBAAA;;MAW3W,OAAK,eAAA;OAAA,MAAA,GAAa,UAAA,MAAS;OAAA,QAAa,YAAA,UAAW,OAAA,IAAA;OAAA,CAAA;MACnD,eAAW,OAAA,OAAA,OAAA,KAAA,eAAQ,MAAoB,mBAAmB,GAAC,KAAA,EAAA,CAAA,OAAA,CAAA;MAC3D,WAAO,OAAA,OAAA,OAAA,MAAG,MAAqB,eAAe,GAAC,KAAA;;;IAIzC,QAAA,aAAa,QAAA,cAAA,WAAA,EAAxB,mBAmBM,OAnBN,YAmBM,CAjBI,QAAA,aAAA,WAAA,EADR,YAQC,oBAAA;;KANE,IAAI,MAAA,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;4BACa,CAAA,gBAAA,gBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGF,QAAA,cAAA,WAAA,EADb,YAQC,oBAAA;;KANE,IAAI,MAAA,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;4BACc,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.cjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2', \n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : '', \n ]\" \n > \n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <kbd \n v-else-if=\"shortcut && !focused\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }} \n </kbd> \n </div> \n \n <div \n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref } from 'vue'; \nimport type { SearchInput } from '../../interfaces/forms/SearchInput.interface'; \nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField'; \nimport Loader from '../feedback/Loader.vue'; \nimport Button from './Button.vue'; \nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Typography from '../data-display/Typography.vue'; \nimport { useModoLocale, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: string]; \n change: [value: string]; \n focus: [event: FocusEvent]; \n blur: [event: FocusEvent]; \n clear: []; \n /** Se emite al presionar Enter o tras el debounce. */ \n search: [value: string]; \n}>(); \n \nconst props = withDefaults(defineProps<SearchInput>(), { \n variant: 'outline', \n color: 'default', \n disabled: false, \n readonly: false, \n required: false, \n loading: false, \n fullWidth: false, \n showCounter: false, \n autofocus: false, \n debounce: 0, \n placeholder: 'Search…', \n}); \n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/* ---------- Debounce ---------- */ \nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) { \n if (e.key === 'Enter') { \n e.preventDefault(); \n cancelDebounce(); \n emit('search', String(props.modelValue ?? '')); \n } else if (e.key === 'Escape' && hasValue.value) { \n e.preventDefault(); \n onClear(); \n } \n} \n \nfunction onFocus(e: FocusEvent) { \n focused.value = true; \n emit('focus', e); \n} \n \nfunction onBlur(e: FocusEvent) { \n focused.value = false; \n emit('blur', e); \n} \n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SearchInput.cjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center gap-2',\n wrapperVariantClasses,\n wrapperSizeClasses,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-expanded=\"hasDropdown ? isOpen : undefined\"\n :aria-controls=\"hasDropdown && isOpen ? `${fieldId}-results` : undefined\"\n :aria-activedescendant=\"isOpen && highlightedIdx >= 0 ? `${fieldId}-opt-${highlightedIdx}` : undefined\"\n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <!-- The shortcut hint stays while the field is empty (focused or not)\n so focusing never removes it and reflows the width. It yields to\n the clear button as soon as there is a value. -->\n <kbd\n v-else-if=\"shortcut\"\n aria-hidden=\"true\"\n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }}\n </kbd>\n </div>\n\n <!-- RESULTS DROPDOWN -->\n <PopoverPanel\n v-if=\"hasDropdown\"\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"resolvedRadius\"\n role=\"presentation\"\n @update:panelRef=\"panelRef = $event\"\n >\n <!-- mousedown.prevent keeps focus in the input while clicking a row -->\n <div class=\"modo-search-results\" @mousedown.prevent>\n <slot\n name=\"results\"\n :items=\"resultItems\"\n :query=\"String(modelValue ?? '')\"\n :highlighted=\"highlightedIdx\"\n :select=\"selectResult\"\n :close=\"closePopover\"\n >\n <div v-if=\"loading\" class=\"px-3 py-6 flex items-center justify-center\">\n <slot name=\"loading\"><Loader size=\"small\" /></slot>\n </div>\n <div\n v-else-if=\"!resultItems.length\"\n class=\"px-3 py-6 text-center text-muted-foreground text-body\"\n >\n <slot name=\"empty\">{{ emptyText }}</slot>\n </div>\n <ul v-else :id=\"`${fieldId}-results`\" role=\"listbox\" class=\"flex flex-col\">\n <template v-for=\"row in renderRows\" :key=\"row.key\">\n <li\n v-if=\"row.kind === 'header'\"\n role=\"presentation\"\n class=\"px-3 pt-2 pb-1 text-caption font-medium text-muted-foreground select-none\"\n >\n {{ row.label }}\n </li>\n <li\n v-else\n :id=\"`${fieldId}-opt-${row.index}`\"\n role=\"option\"\n :aria-selected=\"row.index === highlightedIdx\"\n :aria-disabled=\"row.item.disabled || undefined\"\n >\n <component\n :is=\"row.item.href && !row.item.disabled ? 'a' : 'div'\"\n :href=\"row.item.href && !row.item.disabled ? row.item.href : undefined\"\n :target=\"row.item.external ? '_blank' : undefined\"\n :rel=\"row.item.external ? 'noopener noreferrer' : undefined\"\n class=\"flex items-center gap-2.5 px-3 py-2 text-body transition-colors duration-fast ease-standard\"\n :class=\"[\n row.item.disabled\n ? 'opacity-50 cursor-not-allowed'\n : 'cursor-pointer',\n row.index === highlightedIdx && !row.item.disabled ? 'bg-accent' : '',\n ]\"\n @mouseenter=\"row.item.disabled ? null : (highlightedIdx = row.index)\"\n @click=\"selectResult(row.item)\"\n >\n <slot name=\"item\" :item=\"row.item\" :active=\"row.index === highlightedIdx\">\n <component\n :is=\"row.item.icon\"\n v-if=\"row.item.icon\"\n class=\"size-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate\">{{ row.item.label }}</span>\n <span\n v-if=\"row.item.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >{{ row.item.description }}</span>\n </span>\n <span\n v-if=\"row.item.shortcut\"\n class=\"ml-2 text-caption text-muted-foreground tabular-nums shrink-0\"\n aria-hidden=\"true\"\n >{{ row.item.shortcut }}</span>\n </slot>\n </component>\n </li>\n </template>\n </ul>\n </slot>\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch, nextTick } from 'vue';\nimport type { SearchInput, SearchResultItem } from '../../interfaces/forms/SearchInput.interface';\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField';\nimport Loader from '../feedback/Loader.vue';\nimport Button from './Button.vue';\nimport PopoverPanel from '../layout/PopoverPanel.vue';\nimport { usePopover } from '../../composables/usePopover';\nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline';\nimport Typography from '../data-display/Typography.vue';\nimport { useModoLocale, useResolvedRadius, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n\nconst loc = useModoLocale();\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n clear: [];\n /** Se emite al presionar Enter o tras el debounce. */\n search: [value: string];\n /** A result row was chosen (click / Enter on the highlighted row). */\n select: [item: SearchResultItem];\n /** Results popover open state (for `v-model:open`). */\n 'update:open': [value: boolean];\n}>();\n\nconst props = withDefaults(defineProps<SearchInput>(), {\n variant: 'outline',\n color: 'default',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n showCounter: false,\n autofocus: false,\n debounce: 0,\n placeholder: 'Search…',\n resultsPlacement: 'bottom-start',\n});\n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n\n/* ---------- Results dropdown ---------- */\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\n// The dropdown is active when the host passes `items` (even empty) or a custom\n// `#results` slot. Filtering/async stays with the host — this only renders.\nconst hasDropdown = computed(() => props.items !== undefined || !!slots.results);\nconst resultItems = computed<SearchResultItem[]>(() => props.items ?? []);\n\nconst highlightedIdx = ref(-1);\nconst {\n triggerRef: popoverTrigger,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: () => props.resultsPlacement,\n matchTriggerWidth: true,\n closeOnEscape: false, // handled on the input so focus stays in the field\n closeOnScroll: false, // reposition on scroll; focusing the input can auto-scroll it into view\n onOpen: () => emit('update:open', true),\n onClose: () => { emit('update:open', false); highlightedIdx.value = -1; },\n});\n\nconst wrapperEl = ref<HTMLElement | null>(null);\nwatch(wrapperEl, (el) => { popoverTrigger.value = el; });\n\n// Flat render list with a group header inserted whenever `group` changes.\ntype RenderRow =\n | { kind: 'header'; label: string; key: string }\n | { kind: 'option'; item: SearchResultItem; index: number; key: string };\nconst renderRows = computed<RenderRow[]>(() => {\n const rows: RenderRow[] = [];\n let prevGroup: string | undefined;\n resultItems.value.forEach((item, index) => {\n if (item.group && item.group !== prevGroup) {\n rows.push({ kind: 'header', label: item.group, key: `h-${index}` });\n prevGroup = item.group;\n }\n rows.push({ kind: 'option', item, index, key: `o-${item.id ?? index}` });\n });\n return rows;\n});\n\nconst enabledIndices = computed(() =>\n resultItems.value.map((it, i) => (it.disabled ? -1 : i)).filter((i) => i !== -1),\n);\n\n// Show the popover only while focused and there is something to render.\nconst shouldShowResults = computed(() =>\n hasDropdown.value && focused.value &&\n (resultItems.value.length > 0 || props.loading || !!props.emptyText || !!slots.empty),\n);\n\nfunction syncOpen() {\n if (shouldShowResults.value) { if (!isOpen.value) openPopover(); }\n else if (isOpen.value) closePopover();\n}\nwatch(shouldShowResults, syncOpen);\nwatch(() => resultItems.value.length, () => { if (isOpen.value || shouldShowResults.value) nextTick(syncOpen); });\n\n// Optional external control via `v-model:open`.\nwatch(() => props.open, (v) => {\n if (v === undefined) return;\n if (v && shouldShowResults.value) openPopover();\n else if (!v) closePopover();\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = enabledIndices.value;\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n highlightedIdx.value = cur === -1\n ? (delta > 0 ? order[0] : order[order.length - 1])\n : order[(cur + delta + order.length) % order.length];\n}\n\nfunction selectResult(item: SearchResultItem) {\n if (item.disabled) return;\n emit('select', item);\n closePopover();\n}\n\n/* ---------- Debounce ---------- */\nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) {\n // Arrow keys drive the results dropdown when it is available.\n if (hasDropdown.value && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n if (!isOpen.value && shouldShowResults.value) openPopover();\n moveHighlight(e.key === 'ArrowDown' ? 1 : -1);\n return;\n }\n if (e.key === 'Enter') {\n // Enter picks the highlighted result if the dropdown is open; otherwise\n // it keeps the existing \"submit search\" behaviour.\n if (isOpen.value && highlightedIdx.value >= 0) {\n const item = resultItems.value[highlightedIdx.value];\n if (item && !item.disabled) {\n e.preventDefault();\n selectResult(item);\n return;\n }\n }\n e.preventDefault();\n cancelDebounce();\n emit('search', String(props.modelValue ?? ''));\n return;\n }\n if (e.key === 'Escape') {\n // First Escape closes the dropdown; a second (or when closed) clears.\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n return;\n }\n if (hasValue.value) {\n e.preventDefault();\n onClear();\n }\n }\n}\n \nfunction onFocus(e: FocusEvent) {\n focused.value = true;\n emit('focus', e);\n // Open the results popover on focus if there is anything to show. Done\n // explicitly (not only via the watcher) so it fires on the very first focus.\n if (hasDropdown.value) nextTick(syncOpen);\n}\n \nfunction onBlur(e: FocusEvent) { \n focused.value = false; \n emit('blur', e); \n} \n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.mjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2', \n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : '', \n ]\" \n > \n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <kbd \n v-else-if=\"shortcut && !focused\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }} \n </kbd> \n </div> \n \n <div \n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref } from 'vue'; \nimport type { SearchInput } from '../../interfaces/forms/SearchInput.interface'; \nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField'; \nimport Loader from '../feedback/Loader.vue'; \nimport Button from './Button.vue'; \nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Typography from '../data-display/Typography.vue'; \nimport { useModoLocale, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: string]; \n change: [value: string]; \n focus: [event: FocusEvent]; \n blur: [event: FocusEvent]; \n clear: []; \n /** Se emite al presionar Enter o tras el debounce. */ \n search: [value: string]; \n}>(); \n \nconst props = withDefaults(defineProps<SearchInput>(), { \n variant: 'outline', \n color: 'default', \n disabled: false, \n readonly: false, \n required: false, \n loading: false, \n fullWidth: false, \n showCounter: false, \n autofocus: false, \n debounce: 0, \n placeholder: 'Search…', \n}); \n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/* ---------- Debounce ---------- */ \nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) { \n if (e.key === 'Enter') { \n e.preventDefault(); \n cancelDebounce(); \n emit('search', String(props.modelValue ?? '')); \n } else if (e.key === 'Escape' && hasValue.value) { \n e.preventDefault(); \n onClear(); \n } \n} \n \nfunction onFocus(e: FocusEvent) { \n focused.value = true; \n emit('focus', e); \n} \n \nfunction onBlur(e: FocusEvent) { \n focused.value = false; \n emit('blur', e); \n} \n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SearchInput.mjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center gap-2',\n wrapperVariantClasses,\n wrapperSizeClasses,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-expanded=\"hasDropdown ? isOpen : undefined\"\n :aria-controls=\"hasDropdown && isOpen ? `${fieldId}-results` : undefined\"\n :aria-activedescendant=\"isOpen && highlightedIdx >= 0 ? `${fieldId}-opt-${highlightedIdx}` : undefined\"\n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <!-- The shortcut hint stays while the field is empty (focused or not)\n so focusing never removes it and reflows the width. It yields to\n the clear button as soon as there is a value. -->\n <kbd\n v-else-if=\"shortcut\"\n aria-hidden=\"true\"\n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }}\n </kbd>\n </div>\n\n <!-- RESULTS DROPDOWN -->\n <PopoverPanel\n v-if=\"hasDropdown\"\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"resolvedRadius\"\n role=\"presentation\"\n @update:panelRef=\"panelRef = $event\"\n >\n <!-- mousedown.prevent keeps focus in the input while clicking a row -->\n <div class=\"modo-search-results\" @mousedown.prevent>\n <slot\n name=\"results\"\n :items=\"resultItems\"\n :query=\"String(modelValue ?? '')\"\n :highlighted=\"highlightedIdx\"\n :select=\"selectResult\"\n :close=\"closePopover\"\n >\n <div v-if=\"loading\" class=\"px-3 py-6 flex items-center justify-center\">\n <slot name=\"loading\"><Loader size=\"small\" /></slot>\n </div>\n <div\n v-else-if=\"!resultItems.length\"\n class=\"px-3 py-6 text-center text-muted-foreground text-body\"\n >\n <slot name=\"empty\">{{ emptyText }}</slot>\n </div>\n <ul v-else :id=\"`${fieldId}-results`\" role=\"listbox\" class=\"flex flex-col\">\n <template v-for=\"row in renderRows\" :key=\"row.key\">\n <li\n v-if=\"row.kind === 'header'\"\n role=\"presentation\"\n class=\"px-3 pt-2 pb-1 text-caption font-medium text-muted-foreground select-none\"\n >\n {{ row.label }}\n </li>\n <li\n v-else\n :id=\"`${fieldId}-opt-${row.index}`\"\n role=\"option\"\n :aria-selected=\"row.index === highlightedIdx\"\n :aria-disabled=\"row.item.disabled || undefined\"\n >\n <component\n :is=\"row.item.href && !row.item.disabled ? 'a' : 'div'\"\n :href=\"row.item.href && !row.item.disabled ? row.item.href : undefined\"\n :target=\"row.item.external ? '_blank' : undefined\"\n :rel=\"row.item.external ? 'noopener noreferrer' : undefined\"\n class=\"flex items-center gap-2.5 px-3 py-2 text-body transition-colors duration-fast ease-standard\"\n :class=\"[\n row.item.disabled\n ? 'opacity-50 cursor-not-allowed'\n : 'cursor-pointer',\n row.index === highlightedIdx && !row.item.disabled ? 'bg-accent' : '',\n ]\"\n @mouseenter=\"row.item.disabled ? null : (highlightedIdx = row.index)\"\n @click=\"selectResult(row.item)\"\n >\n <slot name=\"item\" :item=\"row.item\" :active=\"row.index === highlightedIdx\">\n <component\n :is=\"row.item.icon\"\n v-if=\"row.item.icon\"\n class=\"size-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate\">{{ row.item.label }}</span>\n <span\n v-if=\"row.item.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >{{ row.item.description }}</span>\n </span>\n <span\n v-if=\"row.item.shortcut\"\n class=\"ml-2 text-caption text-muted-foreground tabular-nums shrink-0\"\n aria-hidden=\"true\"\n >{{ row.item.shortcut }}</span>\n </slot>\n </component>\n </li>\n </template>\n </ul>\n </slot>\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch, nextTick } from 'vue';\nimport type { SearchInput, SearchResultItem } from '../../interfaces/forms/SearchInput.interface';\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField';\nimport Loader from '../feedback/Loader.vue';\nimport Button from './Button.vue';\nimport PopoverPanel from '../layout/PopoverPanel.vue';\nimport { usePopover } from '../../composables/usePopover';\nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline';\nimport Typography from '../data-display/Typography.vue';\nimport { useModoLocale, useResolvedRadius, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n\nconst loc = useModoLocale();\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n clear: [];\n /** Se emite al presionar Enter o tras el debounce. */\n search: [value: string];\n /** A result row was chosen (click / Enter on the highlighted row). */\n select: [item: SearchResultItem];\n /** Results popover open state (for `v-model:open`). */\n 'update:open': [value: boolean];\n}>();\n\nconst props = withDefaults(defineProps<SearchInput>(), {\n variant: 'outline',\n color: 'default',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n showCounter: false,\n autofocus: false,\n debounce: 0,\n placeholder: 'Search…',\n resultsPlacement: 'bottom-start',\n});\n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n\n/* ---------- Results dropdown ---------- */\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\n// The dropdown is active when the host passes `items` (even empty) or a custom\n// `#results` slot. Filtering/async stays with the host — this only renders.\nconst hasDropdown = computed(() => props.items !== undefined || !!slots.results);\nconst resultItems = computed<SearchResultItem[]>(() => props.items ?? []);\n\nconst highlightedIdx = ref(-1);\nconst {\n triggerRef: popoverTrigger,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: () => props.resultsPlacement,\n matchTriggerWidth: true,\n closeOnEscape: false, // handled on the input so focus stays in the field\n closeOnScroll: false, // reposition on scroll; focusing the input can auto-scroll it into view\n onOpen: () => emit('update:open', true),\n onClose: () => { emit('update:open', false); highlightedIdx.value = -1; },\n});\n\nconst wrapperEl = ref<HTMLElement | null>(null);\nwatch(wrapperEl, (el) => { popoverTrigger.value = el; });\n\n// Flat render list with a group header inserted whenever `group` changes.\ntype RenderRow =\n | { kind: 'header'; label: string; key: string }\n | { kind: 'option'; item: SearchResultItem; index: number; key: string };\nconst renderRows = computed<RenderRow[]>(() => {\n const rows: RenderRow[] = [];\n let prevGroup: string | undefined;\n resultItems.value.forEach((item, index) => {\n if (item.group && item.group !== prevGroup) {\n rows.push({ kind: 'header', label: item.group, key: `h-${index}` });\n prevGroup = item.group;\n }\n rows.push({ kind: 'option', item, index, key: `o-${item.id ?? index}` });\n });\n return rows;\n});\n\nconst enabledIndices = computed(() =>\n resultItems.value.map((it, i) => (it.disabled ? -1 : i)).filter((i) => i !== -1),\n);\n\n// Show the popover only while focused and there is something to render.\nconst shouldShowResults = computed(() =>\n hasDropdown.value && focused.value &&\n (resultItems.value.length > 0 || props.loading || !!props.emptyText || !!slots.empty),\n);\n\nfunction syncOpen() {\n if (shouldShowResults.value) { if (!isOpen.value) openPopover(); }\n else if (isOpen.value) closePopover();\n}\nwatch(shouldShowResults, syncOpen);\nwatch(() => resultItems.value.length, () => { if (isOpen.value || shouldShowResults.value) nextTick(syncOpen); });\n\n// Optional external control via `v-model:open`.\nwatch(() => props.open, (v) => {\n if (v === undefined) return;\n if (v && shouldShowResults.value) openPopover();\n else if (!v) closePopover();\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = enabledIndices.value;\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n highlightedIdx.value = cur === -1\n ? (delta > 0 ? order[0] : order[order.length - 1])\n : order[(cur + delta + order.length) % order.length];\n}\n\nfunction selectResult(item: SearchResultItem) {\n if (item.disabled) return;\n emit('select', item);\n closePopover();\n}\n\n/* ---------- Debounce ---------- */\nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) {\n // Arrow keys drive the results dropdown when it is available.\n if (hasDropdown.value && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n if (!isOpen.value && shouldShowResults.value) openPopover();\n moveHighlight(e.key === 'ArrowDown' ? 1 : -1);\n return;\n }\n if (e.key === 'Enter') {\n // Enter picks the highlighted result if the dropdown is open; otherwise\n // it keeps the existing \"submit search\" behaviour.\n if (isOpen.value && highlightedIdx.value >= 0) {\n const item = resultItems.value[highlightedIdx.value];\n if (item && !item.disabled) {\n e.preventDefault();\n selectResult(item);\n return;\n }\n }\n e.preventDefault();\n cancelDebounce();\n emit('search', String(props.modelValue ?? ''));\n return;\n }\n if (e.key === 'Escape') {\n // First Escape closes the dropdown; a second (or when closed) clears.\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n return;\n }\n if (hasValue.value) {\n e.preventDefault();\n onClear();\n }\n }\n}\n \nfunction onFocus(e: FocusEvent) {\n focused.value = true;\n emit('focus', e);\n // Open the results popover on focus if there is anything to show. Done\n // explicitly (not only via the watcher) so it fires on the very first focus.\n if (hasDropdown.value) nextTick(syncOpen);\n}\n \nfunction onBlur(e: FocusEvent) { \n focused.value = false; \n emit('blur', e); \n} \n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":""}
|