### Global Setup of Fluid DnD Composables in Vue Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/vue/introduction/introduction.mdx Demonstrates setting up the 'useDragAndDrop' composable from Fluid DnD globally in a Vue application using Vue's provide/inject mechanism. This allows the composable to be accessed throughout the entire application. It requires Vue to be installed. ```javascript import { createApp } from "vue"; import App from './App.vue'; import { useDragAndDrop } from "fluid-dnd/vue"; const app = createApp(App); app.provide('useDragAndDrop', useDragAndDrop); app.mount('#app'); ``` -------------------------------- ### Integrate React-specific ESLint Plugins (JavaScript) Source: https://github.com/carlosjorger/fluid-dnd/blob/main/tests-frameworks/react/README.md This configuration adds `eslint-plugin-react-x` and `eslint-plugin-react-dom` to your ESLint setup. It enables recommended TypeScript rules from `react-x` and recommended rules from `react-dom`, enhancing React-specific linting. Ensure these plugins are installed as dev dependencies. ```javascript // eslint.config.js import reactX from 'eslint-plugin-react-x' import reactDom from 'eslint-plugin-react-dom' export default tseslint.config({ plugins: { // Add the react-x and react-dom plugins 'react-x': reactX, 'react-dom': reactDom, }, rules: { // other rules... // Enable its recommended typescript rules ...reactX.configs['recommended-typescript'].rules, ...reactDom.configs.recommended.rules, }, }) ``` -------------------------------- ### Essential npm Commands for Astro Projects Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/README.md These commands are essential for managing an Astro project. They cover dependency installation, starting a local development server, building the production site, and previewing the build. These commands are executed from the project's root directory in a terminal. ```bash npm install ``` ```bash npm run dev ``` ```bash npm run build ``` ```bash npm run preview ``` ```bash npm run astro ... ``` ```bash npm run astro -- --help ``` -------------------------------- ### Start Svelte Development Server with npm Source: https://github.com/carlosjorger/fluid-dnd/blob/main/tests-frameworks/svelte/README.md This snippet shows how to start the development server for a Svelte project using npm. It includes an option to automatically open the application in a new browser tab. Assumes project dependencies have been installed via 'npm install' or equivalent. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### React Composition API Usage Example Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/react/introduction/introduction.mdx Demonstrates how to import and use the `useDragAndDrop` composable from the 'fluid-dnd/react' package within a React application using TypeScript. This is a fundamental part of integrating Fluid DnD's drag and drop capabilities. ```tsx import { useDragAndDrop } from 'fluid-dnd/react'; // ... ``` -------------------------------- ### Import useDragAndDrop Composable in Svelte Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/svelte/introduction/introduction.mdx Demonstrates how to import the `useDragAndDrop` composable function from the 'fluid-dnd/svelte' module in a Svelte component. This is the first step in utilizing Fluid DnD's drag-and-drop functionality within a Svelte application. ```svelte ``` -------------------------------- ### Install fluid-dnd using npm, yarn, or pnpm Source: https://github.com/carlosjorger/fluid-dnd/blob/main/README.md These commands show how to install the fluid-dnd library using different package managers. Ensure you have Node.js and your chosen package manager installed. ```bash # with npm: npm i fluid-dnd # with yarn: yarn add fluid-dnd # with pnpm: pnpm i fluid-dnd ``` -------------------------------- ### Create Astro + Starlight Project Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/README.md This command initializes a new Astro project using the Starlight template. It requires Node.js and npm to be installed. The command will prompt for project details and set up the basic file structure. ```bash npm create astro@latest -- --template starlight ``` -------------------------------- ### Local Import of Fluid DnD Composables in Vue Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/vue/introduction/introduction.mdx Shows how to import the 'useDragAndDrop' composable from Fluid DnD for local usage within a Vue component's script section. This is useful when the composable is only needed in a specific part of the application. ```vue ``` -------------------------------- ### Expand ESLint with Type-Checked Rules (TypeScript) Source: https://github.com/carlosjorger/fluid-dnd/blob/main/tests-frameworks/react/README.md This snippet shows how to configure ESLint to include type-aware lint rules for TypeScript projects. It extends the default ESLint configuration with recommended, strict, and stylistic type-checked rules. Ensure that `tsconfig.node.json` and `tsconfig.app.json` are correctly configured. ```javascript export default tseslint.config({ extends: [ // Remove ...tseslint.configs.recommended and replace with this ...tseslint.configs.recommendedTypeChecked, // Alternatively, use this for stricter rules ...tseslint.configs.strictTypeChecked, // Optionally, add this for stylistic rules ...tseslint.configs.stylisticTypeChecked, ], languageOptions: { // other options... parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, }, }) ``` -------------------------------- ### Build Svelte Project for Production with npm Source: https://github.com/carlosjorger/fluid-dnd/blob/main/tests-frameworks/svelte/README.md This snippet outlines the command to generate a production-ready build of a Svelte application using npm. The resulting build is typically placed in a 'dist' or 'build' folder. Further deployment may require installing a Svelte adapter. ```bash npm run build ``` -------------------------------- ### TechArticle Schema (JSON-LD) Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/STRUCTURED_DATA.md Implements the 'TechArticle' schema for guide pages, including headline, description, author, and related topics. This schema helps search engines categorize technical content effectively. ```json { "@type": "TechArticle", "headline": "Page Title", "description": "Page description", "author": { "@type": "Person", "name": "Carlos Jorge" }, "about": [ {"@type": "Thing", "name": "Drag and Drop"}, {"@type": "Thing", "name": "Vue.js"}, {"@type": "Thing", "name": "React"}, {"@type": "Thing", "name": "Svelte"} ] } ``` -------------------------------- ### Vue Drag and Drop Setup for a List Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/svelte/guides/verticallist.mdx This snippet shows the basic setup for using the `useDragAndDrop` hook from `fluid-dnd/vue` to manage a list of numbers. It initializes a reactive list and applies the drag-and-drop functionality to it. Ensure you have Vue 3 and `fluid-dnd` installed. ```vue ``` -------------------------------- ### Setup List for Horizontal Drag and Drop (Vue) Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/vue/guides/horizontallist.mdx This snippet shows the setup for a horizontal list using Fluid DnD in Vue.js. It initializes a list of numbers and configures the drag-and-drop instance with the 'horizontal' direction. It requires Vue.js and the useDragAndDrop composable from Fluid DnD. ```vue import { ref } from "vue"; import { useDragAndDrop } from "@/composables/useDragAndDrop"; const list = ref([1, 2, 3, 4, 5]); const [ parent ] = useDragAndDrop(list, { direction: "horizontal" }); ``` -------------------------------- ### Initialize Editable List with Fluid DnD in React Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/es/react/guides/listinputs.mdx This snippet initializes a list of people using the `useDragAndDrop` hook from Fluid DnD. It sets up the initial state for each person object, including properties for identification and editability. This forms the basis for an editable list where users can reorder items. ```tsx import {SingleVerticalPersonList} from "@/components/react/SingleVerticalPersonList.tsx"; import { Code } from "@astrojs/starlight/components"; export const listOfPeople = ` export const SingleVerticalPersonList: React.FC = () => { const [ parent, listValue, setList ] = useDragAndDrop([ { number: 1, name: "Carlos", edit: false }, { number: 2, name: "Jorge", edit: false }, { number: 3, name: "Ivis", edit: false }, ]); `; ``` -------------------------------- ### Vue: Setup Horizontal List with Fluid DnD Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/es/vue/guides/horizontallist.mdx This snippet demonstrates the initial setup for a horizontal list using Fluid DnD in Vue. It imports necessary components and defines a reactive list of numbers. The `useDragAndDrop` hook is configured with `direction: 'horizontal'` to enable horizontal dragging behavior. No external dependencies are required beyond Vue and Fluid DnD. ```vue ``` -------------------------------- ### Configure Lists for Multiple Groups (Svelte) Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/svelte/guides/listgroup.mdx This example demonstrates how a list can belong to multiple droppable groups ('group1' and 'group2'). Drag and drop is only possible between lists that share at least one common group. This snippet modifies the previous example to include 'group2' for `list2`. ```svelte ``` -------------------------------- ### Vue.js: List with Drag Handler Setup Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/vue/guides/styles/listhandler.mdx Sets up a Vue.js component to use Fluid DnD with a specified drag handler selector. It imports necessary functions from 'fluid-dnd/vue' and defines the list data and handler selector. The `useDragAndDrop` hook is utilized to enable drag-and-drop functionality. ```vue import { ref } from "vue"; import { useDragAndDrop } from "fluid-dnd/vue"; import Handler from "./icons/handler.vue"; const list = ref([1, 2, 3, 4, 5]); const handlerSelector = ".handler"; const [ parent ] = useDragAndDrop(list, { handlerSelector }); ``` -------------------------------- ### Vue Template for Displaying Vertical List Items Source: https://github.com/carlosjorger/fluid-dnd/blob/main/docs/src/content/docs/vue/guides/verticallist.mdx This HTML template displays items from a Vue list within an unordered list (`