✨ Simplify arrow function syntax and remove unnecessary whitespace across composable utilities
This commit is contained in:
@@ -18,14 +18,14 @@ export function useClipboard() {
|
||||
* @param {string} text - Text to copy
|
||||
* @returns {Promise<boolean>} Success status
|
||||
*/
|
||||
const copyToClipboard = async (text) => {
|
||||
const copyToClipboard = async text => {
|
||||
error.value = null;
|
||||
copied.value = false;
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
copied.value = true;
|
||||
|
||||
|
||||
// Reset after 2 seconds
|
||||
setTimeout(() => {
|
||||
copied.value = false;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { onMounted, onUnmounted } from 'vue';
|
||||
* Register keyboard shortcuts
|
||||
* @param {Object} shortcuts - Map of key combinations to handlers
|
||||
* @returns {Object} Control functions
|
||||
*
|
||||
*
|
||||
* Example shortcuts object:
|
||||
* {
|
||||
* 'ctrl+f': () => focusSearch(),
|
||||
@@ -18,7 +18,7 @@ import { onMounted, onUnmounted } from 'vue';
|
||||
* }
|
||||
*/
|
||||
export function useKeyboardShortcuts(shortcuts = {}) {
|
||||
const handleKeyDown = (event) => {
|
||||
const handleKeyDown = event => {
|
||||
const key = event.key.toLowerCase();
|
||||
const ctrl = event.ctrlKey || event.metaKey; // Support both Ctrl and Cmd
|
||||
const shift = event.shiftKey;
|
||||
@@ -36,7 +36,7 @@ export function useKeyboardShortcuts(shortcuts = {}) {
|
||||
|
||||
// Try to find and execute handler
|
||||
const handler = shortcuts[combination] || shortcuts[simpleKey];
|
||||
|
||||
|
||||
if (handler) {
|
||||
event.preventDefault();
|
||||
handler(event);
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useLocalStorage(key, defaultValue) {
|
||||
// Watch for changes and save to localStorage
|
||||
watch(
|
||||
storedValue,
|
||||
(newValue) => {
|
||||
newValue => {
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify(newValue));
|
||||
} catch (error) {
|
||||
@@ -52,7 +52,7 @@ export function useLocalStorage(key, defaultValue) {
|
||||
export function useSearchHistory(key = 'searchHistory', maxItems = 5) {
|
||||
const history = useLocalStorage(key, []);
|
||||
|
||||
const addToHistory = (query) => {
|
||||
const addToHistory = query => {
|
||||
if (!query || query.trim() === '') return;
|
||||
|
||||
// Remove duplicates and add to front
|
||||
@@ -64,7 +64,7 @@ export function useSearchHistory(key = 'searchHistory', maxItems = 5) {
|
||||
history.value = newHistory;
|
||||
};
|
||||
|
||||
const removeFromHistory = (query) => {
|
||||
const removeFromHistory = query => {
|
||||
history.value = history.value.filter(item => item !== query);
|
||||
};
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ export function useUrlState(stateRefs) {
|
||||
*/
|
||||
const updateUrl = () => {
|
||||
const query = {};
|
||||
|
||||
|
||||
Object.entries(stateRefs).forEach(([key, ref]) => {
|
||||
const value = ref.value;
|
||||
|
||||
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
if (Array.isArray(value)) {
|
||||
query[key] = value.join(',');
|
||||
@@ -42,7 +42,7 @@ export function useUrlState(stateRefs) {
|
||||
const loadFromUrl = () => {
|
||||
Object.entries(stateRefs).forEach(([key, ref]) => {
|
||||
const value = route.query[key];
|
||||
|
||||
|
||||
if (value) {
|
||||
if (Array.isArray(ref.value)) {
|
||||
ref.value = value.split(',');
|
||||
|
||||
Reference in New Issue
Block a user