Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions demo/esmodule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Advanced ES Module Demo</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="demo.css" />

<script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>

<style type="text/css">
.grid-stack-item-removing {
opacity: 0.8;
filter: blur(5px);
}
#trash {
background: rgba(255, 0, 0, 0.4);
}
</style>
</head>

<body>
<h1>Advanced ES Module Demo</h1>
<div class="row">
<div class="col-md-2 d-none d-md-block">
<div id="trash" style="padding: 5px; margin-bottom: 15px;" class="text-center">
<div>
<ion-icon name="trash" style="font-size: 300%"></ion-icon>
</div>
<div>
<span>Drop here to remove!</span>
</div>
</div>
<div class="newWidget grid-stack-item">
<div class="grid-stack-item-content" style="padding: 5px;">
<div>
<ion-icon name="add-circle" style="font-size: 300%"></ion-icon>
</div>
<div>
<span>Drag me in the dashboard!</span>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-10">
<div class="grid-stack"></div>
</div>
</div>

<script type="module">
import { GridStack } from '../dist/esm/gridstack.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can you load that ? in Chrome I get:

Access to script at 'file:///C:/depot/gridstack.js/dist/gridstack.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got that too; ended up serving the directory from the root of the repo (i.e. npx http-server . in /gridstack.js)

let grid = GridStack.init({
cellHeight: 70,
acceptWidgets: true,
dragIn: '.newWidget', // class that can be dragged from outside
dragInOptions: { revert: 'invalid', scroll: false, appendTo: 'body', helper: 'clone' }, // clone or can be your function
removable: '#trash', // drag-out delete class
});

let items = [
{x: 0, y: 0, w: 4, h: 2, content: '1'},
{x: 4, y: 0, w: 4, h: 4, noMove: true, noResize: true, locked: true, content: 'I can\'t be moved or dragged!<br><ion-icon name="ios-lock" style="font-size:300%"></ion-icon>'},
{x: 8, y: 0, w: 2, h: 2, minW: 2, noResize: true, content: '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand" style="font-size: 300%"></ion-icon><p class="card-text text-center" style="margin-bottom: 0">...but don\'t resize me!'},
{x: 10, y: 0, w: 2, h: 2, content: '4'},
{x: 0, y: 2, w: 2, h: 2, content: '5'},
{x: 2, y: 2, w: 2, h: 4, content: '6'},
{x: 8, y: 2, w: 4, h: 2, content: '7'},
{x: 0, y: 4, w: 2, h: 2, content: '8'},
{x: 4, y: 4, w: 4, h: 2, content: '9'},
{x: 8, y: 4, w: 2, h: 2, content: '10'},
{x: 10, y: 4, w: 2, h: 2, content: '11'},
];
grid.load(items);

grid.on('added removed change', function(e, items) {
let str = '';
items.forEach(function(item) { str += ' (x,y)=' + item.x + ',' + item.y; });
console.log(e.type + ' ' + items.length + ' items:' + str );
});
</script>
</body>

</html>
57 changes: 0 additions & 57 deletions demo/index.html

This file was deleted.

1 change: 1 addition & 0 deletions es5/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
*/
"rootDir": "../src",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand Down
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
}
],
"scripts": {
"build": "yarn --no-progress && rm -rf dist/* && grunt && yarn build:es6 && yarn build:es5 && yarn doc",
"build": "yarn --no-progress && rimraf dist && grunt && yarn build:es6 && yarn build:es5 && yarn build:esm && yarn doc",
"build:es6": "webpack && tsc --stripInternal",
"build:es5": "webpack --config es5/webpack.config.js && tsc --stripInternal --project es5/tsconfig.json",
"w": "webpack",
"build:esm": "rollup -c rollup.config.js",
"w": "rimraf dist/* && grunt && rollup -c rollup.config.js",
"t": "rm -rf dist/* && grunt && tsc --stripInternal",
"doc": "doctoc ./README.md && doctoc ./doc/README.md && doctoc ./doc/CHANGES.md",
"test": "yarn lint && karma start karma.conf.js",
"lint": "tsc --noEmit && eslint src/*.ts",
"reset": "rm -rf dist node_modules",
"reset": "rimraf dist node_modules",
"prepublishOnly": "yarn build"
},
"keywords": [
Expand All @@ -58,6 +59,10 @@
"homepage": "http://gridstackjs.com/",
"dependencies": {},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.3.2",
"@types/jasmine": "^4.3.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
Expand All @@ -84,9 +89,11 @@
"karma-jasmine": "^5.1.0",
"karma-typescript": "5.5.3",
"protractor": "^7.0.0",
"rollup": "^2.75.6",
"sass": "^1.62.0",
"serve-static": "^1.15.0",
"ts-loader": "^9.4.2",
"tslib": "^2.4.0",
"typescript": "^5.0.4",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1"
Expand Down
35 changes: 35 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';

// rollup.config.js
/**
* @type {import('rollup').RollupOptions[]}
*/
export default [
{
input: {
'gridstack': './src/gridstack.ts'
},
output: {
format: 'esm',
dir: './dist/esm',
sourcemap: true,
globals: {
jquery: '$'
},
preserveModules: true
},
plugins: [
typescript({
tsconfig: './tsconfig.json',
outDir: './dist/esm',
module: "esnext",
declaration: true,
stripInternal: true,
}),
nodeResolve({
browser: true,
})
]
}
]
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/*
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
*/
"rootDir": "src",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand All @@ -16,6 +16,7 @@
"sourceMap": true,
"strict": false,
"target": "ES2020"
"allowSyntheticDefaultImports": true
},
"exclude": [
"./src/**/*.spec.ts",
Expand Down
Loading