@egjs/svelte-infinitegrid 3.2.5 → 4.0.1-beta.1
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/.storybook/main.js +32 -0
- package/.storybook/manager.js +5 -0
- package/.storybook/preview.js +25 -0
- package/README.md +79 -155
- package/dist/infinitegrid.cjs.js +203 -533
- package/dist/infinitegrid.cjs.js.map +1 -1
- package/dist/infinitegrid.esm.js +198 -522
- package/dist/infinitegrid.esm.js.map +1 -1
- package/global.d.ts +8 -0
- package/package.json +41 -50
- package/public/global.css +6 -5
- package/public/index.html +3 -3
- package/rollup.config.js +7 -6
- package/src/InfiniteGrid.js +23 -16
- package/src/InfiniteGrid.svelte +91 -138
- package/src/consts.js +8 -13
- package/src/grids/FrameInfiniteGrid.js +17 -0
- package/src/grids/JustifiedInfiniteGrid.js +17 -0
- package/src/grids/MasonryInfiniteGrid.js +17 -0
- package/src/grids/PackingInfiniteGrid.js +17 -0
- package/src/index.d.ts +14 -27
- package/src/index.js +5 -13
- package/src/index.umd.js +2 -6
- package/src/{demo/main.js → main.ts} +1 -1
- package/stories/1-MasonryInfiniteGrid/0-MasonryInfiniteGrid.stories.ts +4 -0
- package/stories/1-MasonryInfiniteGrid/1-MasonryInfiniteGrid.stories.ts +27 -0
- package/stories/1-MasonryInfiniteGrid/apps/SvelteMasonryInfiniteGridApp.svelte +42 -0
- package/stories/2-JustifiedInfiniteGrid/0-JustifiedInfiniteGrid.stories.ts +5 -0
- package/stories/2-JustifiedInfiniteGrid/1-JustifiedInfiniteGrid.stories.ts +10 -0
- package/stories/2-JustifiedInfiniteGrid/apps/SvelteJustifiedInfiniteGridApp.svelte +43 -0
- package/stories/3-FrameInfiniteGrid/0-FrameInfiniteGrid.stories.ts +5 -0
- package/stories/3-FrameInfiniteGrid/1-FrameInfiniteGrid.stories.ts +10 -0
- package/stories/3-FrameInfiniteGrid/apps/SvelteFrameInfiniteGridApp.svelte +44 -0
- package/stories/4-PackingInfiniteGrid/0-PackingInfiniteGrid.stories.ts +5 -0
- package/stories/4-PackingInfiniteGrid/1-PackingInfiniteGrid.stories.ts +10 -0
- package/stories/4-PackingInfiniteGrid/apps/SveltePackingInfiniteGridApp.svelte +40 -0
- package/stories/5-DataLoading/0-DataLoading.stories.ts +7 -0
- package/stories/5-DataLoading/1-WaitNReady.stories.ts +10 -0
- package/stories/5-DataLoading/2-Placeholder.stories.ts +10 -0
- package/stories/5-DataLoading/3-Loading.stories.ts +10 -0
- package/stories/5-DataLoading/apps/SvelteLoadingApp.svelte +54 -0
- package/stories/5-DataLoading/apps/SveltePlaceholderApp.svelte +54 -0
- package/stories/5-DataLoading/apps/SvelteWaitNReadyApp.svelte +47 -0
- package/tsconfig.json +4 -61
- package/.editorconfig +0 -3
- package/LICENSE +0 -19
- package/babel.config.js +0 -10
- package/jest.config.js +0 -14
- package/rollup_start_dev.js +0 -12
- package/src/LoadingChecker.svelte +0 -9
- package/src/demo/App.svelte +0 -86
- package/src/demo/useFirstRender.svelte +0 -67
- package/src/layouts/FrameLayout.js +0 -9
- package/src/layouts/GridLayout.js +0 -9
- package/src/layouts/JustifiedLayout.js +0 -9
- package/src/layouts/PackingLayout.js +0 -9
- package/src/layouts/SquareLayout.js +0 -9
- package/svelte.config.js +0 -5
- package/test/unit/demo.spec.ts +0 -23
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const autoPreprocess = require('svelte-preprocess');
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
webpackFinal: (config) => {
|
|
6
|
+
const svelteLoader = config.module.rules.find(
|
|
7
|
+
r => r.loader && r.loader.includes('svelte-loader'),
|
|
8
|
+
);
|
|
9
|
+
svelteLoader.options.preprocess = autoPreprocess({
|
|
10
|
+
less: { includePaths: ['src', 'node_modules'] },
|
|
11
|
+
css: { includePaths: ['src', 'node_modules'] },
|
|
12
|
+
typescript: {
|
|
13
|
+
tsconfigFile: './tsconfig.json',
|
|
14
|
+
transpileOnly: true,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
config.resolve.extensions.push('.ts', '.tsx');
|
|
18
|
+
config.resolve.alias["@egjs/infinitegrid"] = path.resolve(__dirname, '../../../dist/infinitegrid.esm.js');
|
|
19
|
+
return config;
|
|
20
|
+
},
|
|
21
|
+
stories: [
|
|
22
|
+
"../stories/**/*.stories.@(js|jsx|ts|tsx)"
|
|
23
|
+
],
|
|
24
|
+
addons: [
|
|
25
|
+
// "@storybook/addon-knobs/register",
|
|
26
|
+
"@storybook/addon-docs/register",
|
|
27
|
+
"@storybook/addon-controls/register",
|
|
28
|
+
"@storybook/addon-viewport/register",
|
|
29
|
+
"storybook-addon-preview/register",
|
|
30
|
+
"storybook-dark-mode/register",
|
|
31
|
+
],
|
|
32
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { themes } from "@storybook/theming";
|
|
2
|
+
import {
|
|
3
|
+
INITIAL_VIEWPORTS,
|
|
4
|
+
// or MINIMAL_VIEWPORTS,
|
|
5
|
+
} from "@storybook/addon-viewport";
|
|
6
|
+
|
|
7
|
+
// or global addParameters
|
|
8
|
+
export const parameters = {
|
|
9
|
+
controls: {
|
|
10
|
+
passArgsFirst: true,
|
|
11
|
+
expanded: true,
|
|
12
|
+
hideNoControlsWarning: true,
|
|
13
|
+
},
|
|
14
|
+
viewport: {
|
|
15
|
+
viewports: {
|
|
16
|
+
...INITIAL_VIEWPORTS,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
darkMode: {
|
|
20
|
+
// Override the default light theme
|
|
21
|
+
light: { ...themes.normal },
|
|
22
|
+
// Override the default dark theme
|
|
23
|
+
dark: { ...themes.dark },
|
|
24
|
+
},
|
|
25
|
+
};
|
package/README.md
CHANGED
|
@@ -1,182 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img width="256" alt="InfiniteGrid Logo" src="https://naver.github.io/egjs-infinitegrid/img/infinitegrid_logo.png"><br/>
|
|
3
|
+
@egjs/svelte-infinitegrid
|
|
4
|
+
</h1>
|
|
5
|
+
|
|
6
|
+
<p align=center>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@egjs/svelte-infinitegrid" target="_blank">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/@egjs/svelte-infinitegrid.svg?style=flat-square&color=42b883&label=version&logo=NPM">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@egjs/svelte-infinitegrid" target="_blank">
|
|
11
|
+
<img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@egjs/svelte-infinitegrid.svg?style=flat-square&label=%F0%9F%92%BE%20gzipped&color=007acc">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/naver/egjs-infinitegrid/graphs/commit-activity">
|
|
14
|
+
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/naver/egjs-infinitegrid.svg?style=flat-square&label=%E2%AC%86%20commits&color=08CE5D">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@egjs/svelte-infinitegrid" target="_blank">
|
|
17
|
+
<img src="https://img.shields.io/npm/dm/@egjs/svelte-infinitegrid.svg?style=flat-square&label=%E2%AC%87%20downloads&color=08CE5D" alt="npm downloads per month">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/naver/egjs-infinitegrid/graphs/contributors" target="_blank">
|
|
20
|
+
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/naver/egjs-infinitegrid.svg?label=%F0%9F%91%A5%20contributors&style=flat-square&color=08CE5D"></a>
|
|
21
|
+
<a href="https://github.com/naver/egjs-infinitegrid/blob/master/LICENSE" target="_blank">
|
|
22
|
+
<img alt="GitHub" src="https://img.shields.io/github/license/naver/egjs-infinitegrid.svg?style=flat-square&label=%F0%9F%93%9C%20license&color=08CE5D">
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
A Svelte component that can arrange items infinitely according to the type of grids
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://naver.github.io/egjs-infinitegrid/">Demo</a> / <a href="https://naver.github.io/egjs-infinitegrid/docs/api/InfiniteGrid">Documentation</a> / <a href="https://naver.github.io/egjs/">Other components</a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
## ⚙️ Installation
|
|
36
|
+
```sh
|
|
37
|
+
npm install --save @egjs/svelte-infinitegrid
|
|
16
38
|
```
|
|
17
39
|
|
|
18
|
-
##
|
|
40
|
+
## ❗ Changes from [@egjs/infinitegrid](https://github.com/naver/egjs-infinitegrid)
|
|
41
|
+
- You can't use methods that manipulates DOM directly
|
|
42
|
+
- e.g., `append()`, `prepend()`, `insert()`, `remove()`
|
|
43
|
+
|
|
44
|
+
## 🏃 Quick Start
|
|
19
45
|
```html
|
|
20
46
|
<script>
|
|
21
|
-
|
|
22
|
-
GridLayout,
|
|
23
|
-
JustifiedLayout,
|
|
24
|
-
SquareLayout,
|
|
25
|
-
FrameLayout,
|
|
26
|
-
PackingLayout
|
|
27
|
-
} from "@egjs/svelte-infinitegrid";
|
|
28
|
-
|
|
29
|
-
let ig;
|
|
30
|
-
let loading;
|
|
31
|
-
let items = [
|
|
32
|
-
{ groupKey: 0, key: 0},
|
|
33
|
-
{ groupKey: 0, key: 1},
|
|
34
|
-
{ groupKey: 0, key: 2},
|
|
35
|
-
];
|
|
36
|
-
function onAppend(e) {
|
|
37
|
-
const nextGroupKey = (parseFloat(groupKey) || 0) + 1;
|
|
38
|
-
const nextKey = items.length;
|
|
39
|
-
|
|
40
|
-
items = [
|
|
41
|
-
...items,
|
|
42
|
-
{ groupKey: nextGroupKey, key: nextKey },
|
|
43
|
-
{ groupKey: nextGroupKey, key: nextKey + 1 },
|
|
44
|
-
{ groupKey: nextGroupKey, key: nextKey + 2 },
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
```
|
|
49
|
-
```jsx
|
|
50
|
-
<GridLayout
|
|
51
|
-
items={items}
|
|
52
|
-
itemBy={item => item.key}
|
|
53
|
-
groupBy={item => item.groupKey}
|
|
54
|
-
useFirstRender={false}
|
|
55
|
-
status={null}
|
|
56
|
-
options={{
|
|
57
|
-
threshold: 100,
|
|
58
|
-
isOverflowScroll: false,
|
|
59
|
-
isEqualSize: false,
|
|
60
|
-
isContantSize: false,
|
|
61
|
-
useFit: false,
|
|
62
|
-
useRecycle: false,
|
|
63
|
-
horizontal: false,
|
|
64
|
-
}}
|
|
65
|
-
layoutOptions={{
|
|
66
|
-
align: "center",
|
|
67
|
-
}}
|
|
68
|
-
onAppend = {({ detail }) => onAppend(detail)}
|
|
69
|
-
onPrepend = {({ detail }) => onPrepend(detail)}
|
|
70
|
-
onLayoutComplete = {({ detail }) => onLayoutComplete(detail)}
|
|
71
|
-
onImageError = {({ detail }) => onImageError(detail)}
|
|
72
|
-
onChange = {({ detail }) => onChange(detail)}
|
|
73
|
-
let:item
|
|
74
|
-
>
|
|
75
|
-
{#each visibleItems as item (item.key)}
|
|
76
|
-
<div class="item">
|
|
77
|
-
{`item ${item.key}`}</div>
|
|
78
|
-
</div>
|
|
79
|
-
{/each}
|
|
80
|
-
<div slot="loading">Loading</div>
|
|
81
|
-
</GridLayout>
|
|
82
|
-
```
|
|
47
|
+
import { MasonryInfiniteGrid } from "@egjs/svelte-infinitegrid";
|
|
83
48
|
|
|
84
|
-
|
|
49
|
+
let items = getItems(0, 10);
|
|
85
50
|
|
|
86
|
-
|
|
51
|
+
function getItems(nextGroupKey, count) {
|
|
52
|
+
const nextItems = [];
|
|
87
53
|
|
|
54
|
+
for (let i = 0; i < count; ++i) {
|
|
55
|
+
const nextKey = nextGroupKey * count + i;
|
|
88
56
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|status|IInfiniteGridStatus|null|State object of the react-infinitegrid module|
|
|
95
|
-
|layoutType|Class|GridLayout|Specifies the Layout class to use.|
|
|
96
|
-
|options|IInfiniteGridOptions|{}|The option object of the eg.InfiniteGrid module|
|
|
97
|
-
|layoutOptions|IInfiniteGridOptions|{}|Options to apply to the Layout.|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Options
|
|
101
|
-
* [InfiniteGrid's options](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.html)
|
|
102
|
-
* [InfiniteGrid's events](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.html#event:append)
|
|
103
|
-
* [GridLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.GridLayout.html)
|
|
104
|
-
* [JustifiedLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.JustifiedLayout.html)
|
|
105
|
-
* [SquareLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.SquareLayout.html)
|
|
106
|
-
* [FrameLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.FrameLayout.html)
|
|
107
|
-
* [PackingLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.PackingLayout.html)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### Restore status
|
|
111
|
-
|
|
112
|
-
If you want to restore the state, use the status prop.
|
|
113
|
-
|
|
114
|
-
* Save Status
|
|
115
|
-
```tsx
|
|
116
|
-
import { GridLayout } from "@egjs/svelte-infinitegrid";
|
|
117
|
-
|
|
118
|
-
// Save Status
|
|
119
|
-
let ig;
|
|
120
|
-
const status = ig.getStatus();
|
|
121
|
-
|
|
122
|
-
<GridLayout
|
|
123
|
-
bind:this={ig}></GridLayout>
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
* Restore Status (First mount)
|
|
127
|
-
```tsx
|
|
128
|
-
import { GridLayout } from "@egjs/svelte-infinitegrid";
|
|
129
|
-
|
|
130
|
-
<GridLayout
|
|
131
|
-
status={status}></GridLayout>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
* Dynamically restore status
|
|
135
|
-
```tsx
|
|
136
|
-
import { GridLayout } from "@egjs/svelte-infinitegrid";
|
|
57
|
+
nextItems.push({ groupKey: nextGroupKey, key: nextKey });
|
|
58
|
+
}
|
|
59
|
+
return nextItems;
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
137
62
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
63
|
+
<MasonryInfiniteGrid
|
|
64
|
+
class="container"
|
|
65
|
+
gap={5}
|
|
66
|
+
{items}
|
|
67
|
+
on:requestAppend={({ detail: e }) => {
|
|
68
|
+
const nextGroupKey = (+e.groupKey || 0) + 1;
|
|
141
69
|
|
|
142
|
-
|
|
143
|
-
|
|
70
|
+
items = [...items, ...getItems(nextGroupKey, 10)];
|
|
71
|
+
}}
|
|
72
|
+
let:visibleItems
|
|
73
|
+
>
|
|
74
|
+
{#each visibleItems as item (item.key)}
|
|
75
|
+
<div class="item">
|
|
76
|
+
...
|
|
77
|
+
</div>
|
|
78
|
+
{/each}
|
|
79
|
+
</MasonryInfiniteGrid>
|
|
144
80
|
```
|
|
145
81
|
|
|
82
|
+
## 🙌 Contributing
|
|
83
|
+
See [CONTRIBUTING.md](https://github.com/naver/egjs-infinitegrid/blob/master/CONTRIBUTING.md)
|
|
146
84
|
|
|
85
|
+
## 📝 Feedback
|
|
86
|
+
Please file an [Issue](https://github.com/naver/egjs-infinitegrid/issues) with label "Svelte".
|
|
147
87
|
|
|
148
|
-
##
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
Runs the app in the development mode.<br>
|
|
152
|
-
Open [http://localhost:5000](http://localhost:5000) to view it in the browser.
|
|
153
|
-
|
|
154
|
-
The page will reload if you make edits.<br>
|
|
155
|
-
You will also see any lint errors in the console.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
## Bug Report
|
|
159
|
-
|
|
160
|
-
If you find a bug, please report it to us using the [Issues](https://github.com/naver/egjs-infinitegrid/issues) page on GitHub.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
## License
|
|
164
|
-
react-infinitegrid is released under the [MIT license](https://github.com/naver/egjs-infinitegrid/blob/master/LICENSE).
|
|
165
|
-
|
|
88
|
+
## 📜 License
|
|
89
|
+
egjs-infinitegrid is released under the [MIT license](http://naver.github.io/egjs/license.txt).
|
|
166
90
|
|
|
167
91
|
```
|
|
168
|
-
Copyright (c)
|
|
169
|
-
|
|
92
|
+
Copyright (c) 2015-present NAVER Corp.
|
|
170
93
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
171
94
|
of this software and associated documentation files (the "Software"), to deal
|
|
172
95
|
in the Software without restriction, including without limitation the rights
|
|
173
96
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
174
97
|
copies of the Software, and to permit persons to whom the Software is
|
|
175
98
|
furnished to do so, subject to the following conditions:
|
|
176
|
-
|
|
177
99
|
The above copyright notice and this permission notice shall be included in
|
|
178
100
|
all copies or substantial portions of the Software.
|
|
179
|
-
|
|
180
101
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
181
102
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
182
103
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
@@ -186,3 +107,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
186
107
|
THE SOFTWARE.
|
|
187
108
|
```
|
|
188
109
|
|
|
110
|
+
<p align=center>
|
|
111
|
+
<a href="https://naver.github.io/egjs/"><img height="50" src="https://naver.github.io/egjs/img/logotype1_black.svg" ></a> <a href="https://github.com/naver"><img height="50" src="https://naver.github.io/OpenSourceGuide/book/assets/naver_logo.png" /></a>
|
|
112
|
+
</p>
|