├── dist ├── manage.esm.js └── manage.min.js ├── src └── index.js ├── .gitignore ├── scripts └── build.js ├── package.json ├── LICENSE └── README.md /dist/manage.esm.js: -------------------------------------------------------------------------------- 1 | function r(t){t.magic("manage",()=>a=>{let e=document.querySelector(a);if(e)return t.$data(e)})}var u=r;export{u as default}; 2 | -------------------------------------------------------------------------------- /dist/manage.min.js: -------------------------------------------------------------------------------- 1 | (()=>{function t(n){n.magic("manage",()=>a=>{let e=document.querySelector(a);if(e)return n.$data(e)})}document.addEventListener("alpine:init",()=>window.Alpine.plugin(t));})(); 2 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export default function (Alpine) { 2 | Alpine.magic('manage', () => (targetEl) => { 3 | const foundEl = document.querySelector(targetEl) 4 | 5 | if (!foundEl) { 6 | return 7 | } 8 | 9 | return Alpine.$data(foundEl) 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # misc 9 | .DS_Store 10 | *.pem 11 | 12 | # debug 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # local env files 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | # testing 24 | index.html 25 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | buildPlugin({ 2 | entryPoints: ['builds/cdn.js'], 3 | outfile: 'dist/manage.min.js', 4 | }) 5 | 6 | buildPlugin({ 7 | entryPoints: ['builds/module.js'], 8 | outfile: 'dist/manage.esm.js', 9 | platform: 'neutral', 10 | mainFields: ['main', 'module'], 11 | }) 12 | 13 | function buildPlugin(buildOptions) { 14 | return require('esbuild').buildSync({ 15 | ...buildOptions, 16 | minify: true, 17 | bundle: true, 18 | }) 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alpinejs-manage", 3 | "version": "1.0.4", 4 | "description": "Manage another Alpine JS elements `x-data` values 👩✈️", 5 | "keywords": [ 6 | "Alpine", 7 | "Alpine JS", 8 | "Alpine JS Plugin", 9 | "Alpine JS Plugins", 10 | "Alpine JS Manage", 11 | "Alpine JS Data" 12 | ], 13 | "module": "dist/manage.esm.js", 14 | "unpkg": "dist/manage.min.js", 15 | "scripts": { 16 | "build": "node scripts/build.js" 17 | }, 18 | "devDependencies": { 19 | "esbuild": "^0.25.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mark Mead 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alpine JS Manage 2 | 3 | Manage another Alpine JS elements `x-data` values 👩✈️ 4 | 5 | ## Install 6 | 7 | ### With a CDN 8 | 9 | ```html 10 | 14 | 15 | 16 | ``` 17 | 18 | ### With a Package Manager 19 | 20 | ```shell 21 | yarn add -D alpinejs-manage 22 | 23 | npm install -D alpinejs-manage 24 | ``` 25 | 26 | ```js 27 | import Alpine from 'alpinejs' 28 | import manage from 'alpinejs-manage' 29 | 30 | Alpine.plugin(manage) 31 | 32 | Alpine.start() 33 | ``` 34 | 35 | ## Example 36 | 37 | ```html 38 | 41 | 42 |