@contributte/datagrid 0.0.0-20250531-d4580b9
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/LICENSE +22 -0
- package/README.md +84 -0
- package/assets/ajax/index.ts +1 -0
- package/assets/ajax/naja.ts +154 -0
- package/assets/css/datagrid-all.css +6 -0
- package/assets/css/datagrid-full.css +7 -0
- package/assets/css/datagrid.css +651 -0
- package/assets/css/happy.css +463 -0
- package/assets/datagrid-all.ts +1 -0
- package/assets/datagrid-full.ts +53 -0
- package/assets/datagrid.ts +228 -0
- package/assets/index.ts +4 -0
- package/assets/integrations/happy.ts +217 -0
- package/assets/integrations/index.ts +4 -0
- package/assets/integrations/sortable-js.ts +58 -0
- package/assets/integrations/tom-select.ts +30 -0
- package/assets/integrations/vanilla-datepicker.ts +25 -0
- package/assets/plugins/features/autosubmit.ts +87 -0
- package/assets/plugins/features/checkboxes.ts +92 -0
- package/assets/plugins/features/confirm.ts +28 -0
- package/assets/plugins/features/editable.ts +118 -0
- package/assets/plugins/features/inline.ts +89 -0
- package/assets/plugins/features/item-detail.ts +48 -0
- package/assets/plugins/features/treeView.ts +44 -0
- package/assets/plugins/index.ts +13 -0
- package/assets/plugins/integrations/datepicker.ts +25 -0
- package/assets/plugins/integrations/happy.ts +19 -0
- package/assets/plugins/integrations/nette-forms.ts +18 -0
- package/assets/plugins/integrations/selectpicker.ts +25 -0
- package/assets/plugins/integrations/sortable.ts +61 -0
- package/assets/types/ajax.d.ts +143 -0
- package/assets/types/datagrid.d.ts +31 -0
- package/assets/types/index.d.ts +41 -0
- package/assets/types/integrations.d.ts +15 -0
- package/assets/utils.ts +179 -0
- package/dist/datagrid-full.css +1 -0
- package/dist/datagrid-full.js +20 -0
- package/dist/datagrid-full.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015
|
|
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
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align=center>
|
|
4
|
+
<a href="https://github.com/contributte/datagrid/actions"><img src="https://badgen.net/github/checks/contributte/datagrid/master"></a>
|
|
5
|
+
<a href="https://coveralls.io/r/contributte/datagrid"><img src="https://badgen.net/coveralls/c/github/contributte/datagrid"></a>
|
|
6
|
+
<a href="https://packagist.org/packages/ublaboo/datagrid"><img src="https://badgen.net/packagist/dm/ublaboo/datagrid"></a>
|
|
7
|
+
<a href="https://packagist.org/packages/ublaboo/datagrid"><img src="https://badgen.net/packagist/v/ublaboo/datagrid"></a>
|
|
8
|
+
</p>
|
|
9
|
+
<p align=center>
|
|
10
|
+
<a href="https://packagist.org/packages/contributte/datagrid"><img src="https://badgen.net/packagist/php/ublaboo/datagrid"></a>
|
|
11
|
+
<a href="https://github.com/contributte/datagrid"><img src="https://badgen.net/github/license/contributte/datagrid"></a>
|
|
12
|
+
<a href="https://bit.ly/ctteg"><img src="https://badgen.net/badge/support/gitter/cyan"></a>
|
|
13
|
+
<a href="https://bit.ly/cttfo"><img src="https://badgen.net/badge/support/forum/yellow"></a>
|
|
14
|
+
<a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align=center>
|
|
18
|
+
Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact 👨🏻💻 <a href="https://paveljanda.com">paveljanda.com</a>, <a href="https://f3l1x.io">f3l1x.io</a> | Twitter 🐦 <a href="https://twitter.com/contributte">@contributte</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align=center>
|
|
22
|
+
<img src="https://github.com/contributte/datagrid/blob/master/.docs/assets/datagrid.gif">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
To install latest version of `contributte/datagrid` use [Composer](https://getcomposer.org).
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
composer require ublaboo/datagrid
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
For details on how to use this package, check out our [documentation](.docs).
|
|
36
|
+
|
|
37
|
+
**Shortly**
|
|
38
|
+
|
|
39
|
+
You are looking at first class datagrid for Nette Framework. Supported features: filtering, sorting, pagination, tree view, table view, translator and many others.
|
|
40
|
+
Give us a star, it makes us so happy. Thanks ⭐.️
|
|
41
|
+
|
|
42
|
+
| What | Where |
|
|
43
|
+
|-|-|
|
|
44
|
+
| **Documentation** | [contributte.org/packages/contributte/datagrid/](https://contributte.org/packages/contributte/datagrid/) |
|
|
45
|
+
| **Demo** | [https://examples.contributte.org/datagrid-skeleton/](https://examples.contributte.org/datagrid-skeleton/) |
|
|
46
|
+
| **Example project** | [github.com/contributte/playground/tree/master/contributte-datagrid](https://github.com/contributte/playground/tree/master/contributte-datagrid) |
|
|
47
|
+
| **Forum (EN)** | will be updated |
|
|
48
|
+
| **Forum (CZ)** | [forum.nette.org/cs/25444](https://forum.nette.org/cs/25444-ublaboo-datagrid-mocny-rychly-rozsiritelny-hezky-anglicky-dokumentovany-datagrid) |
|
|
49
|
+
|
|
50
|
+
## Versions
|
|
51
|
+
|
|
52
|
+
| State | Version | Branch | Nette | PHP |
|
|
53
|
+
|-------------|-----------|----------|--------|---------|
|
|
54
|
+
| dev | `^7.0.0` | `master` | `3.0+` | `>=8.1` |
|
|
55
|
+
| stable | `^6.7.0` | `master` | `3.0+` | `>=7.2` |
|
|
56
|
+
| stable | `^6.6.0` | `master` | `3.0+` | `>=7.2` |
|
|
57
|
+
| stable | `^5.7.1` | `v5.x` | `2.3` | `^5.6` |
|
|
58
|
+
| stable | `^4.4.22` | `v5.x` | `2.3` | `^5.6` |
|
|
59
|
+
| stable | `^3.3.1` | `v5.x` | `2.3` | `^5.3` |
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
See [how to contribute](https://contributte.org) to this package. This package is currently maintained by these authors.
|
|
65
|
+
|
|
66
|
+
<a href="https://github.com/paveljanda">
|
|
67
|
+
<img width="80" height="80" src="https://avatars2.githubusercontent.com/u/1488874?v=3&s=80">
|
|
68
|
+
</a>
|
|
69
|
+
|
|
70
|
+
<a href="https://github.com/f3l1x">
|
|
71
|
+
<img width="80" height="80" src="https://avatars0.githubusercontent.com/u/538058?v=3&s=80">
|
|
72
|
+
</a>
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Future development
|
|
76
|
+
|
|
77
|
+
1. At the moment, we have limited time to maintain contributte datagrid for free. But you can create some maintenance time by sponsoring us. Ask us in email for available tarifs (email visible on https://github.com/paveljanda). At the moment, we have 1 little sponsor that gives us 1 hour of maintenance per month.
|
|
78
|
+
|
|
79
|
+
2. Sometimes, when there is a new issue opened (either with a new feature request or a bug report), we may assign a label with a dollar sign (**$**) and an amount of dollars to the issue. This is an opportunity for you to support datagrid vendor creators and resolve particular issue.
|
|
80
|
+
|
|
81
|
+
-----
|
|
82
|
+
|
|
83
|
+
Consider to [support](https://contributte.org/partners) **contributte** development team.
|
|
84
|
+
Also thank you for using this package.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./naja";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { Naja } from "naja";
|
|
2
|
+
import type {
|
|
3
|
+
Ajax,
|
|
4
|
+
AjaxEventMap as BaseAjaxEventMap,
|
|
5
|
+
BaseRequestParams as AjaxBaseRequestParams,
|
|
6
|
+
BeforeEventDetail as BaseBeforeEventDetail,
|
|
7
|
+
DatagridPayload,
|
|
8
|
+
ErrorEventDetail as BaseErrorEventDetail,
|
|
9
|
+
EventDetail,
|
|
10
|
+
EventListener,
|
|
11
|
+
InteractEventDetail as BaseInteractEventDetail,
|
|
12
|
+
Payload,
|
|
13
|
+
RequestParams,
|
|
14
|
+
Response as AjaxResponse,
|
|
15
|
+
SuccessEventDetail as BaseSuccessEventDetail,
|
|
16
|
+
} from "../types";
|
|
17
|
+
import { Datagrid } from "../datagrid";
|
|
18
|
+
import { BeforeEvent, ErrorEvent, Payload as NajaPayload, SuccessEvent } from "naja/dist/Naja";
|
|
19
|
+
import { InteractionEvent } from "naja/dist/core/UIHandler";
|
|
20
|
+
|
|
21
|
+
export interface BaseRequestParams extends AjaxBaseRequestParams, Request {
|
|
22
|
+
url: string;
|
|
23
|
+
method: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface BeforeEventDetail<D = {}> extends BaseBeforeEventDetail<D> {
|
|
27
|
+
params: EventDetail<BeforeEvent> & RequestParams<D>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface InteractEventDetail<
|
|
31
|
+
E extends HTMLElement = HTMLElement
|
|
32
|
+
> extends BaseInteractEventDetail<E>, EventDetail<InteractionEvent> {
|
|
33
|
+
element: E;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SuccessEventDetail<
|
|
37
|
+
P = DatagridPayload
|
|
38
|
+
> extends BaseSuccessEventDetail<P, Response>, EventDetail<SuccessEvent> {
|
|
39
|
+
params: BaseRequestParams;
|
|
40
|
+
payload: Payload<P> & NajaPayload;
|
|
41
|
+
response: AjaxResponse & Response;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ErrorEventDetail<
|
|
45
|
+
E extends Error = Error,
|
|
46
|
+
> extends BaseErrorEventDetail<E, Response>, EventDetail<ErrorEvent> {
|
|
47
|
+
params: BaseRequestParams;
|
|
48
|
+
response: (AjaxResponse & Response) | undefined;
|
|
49
|
+
error: E;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface AjaxEventMap extends BaseAjaxEventMap {
|
|
53
|
+
before: CustomEvent<BeforeEventDetail>;
|
|
54
|
+
interact: CustomEvent<InteractEventDetail>;
|
|
55
|
+
snippetUpdate: CustomEvent<InteractEventDetail>;
|
|
56
|
+
success: CustomEvent<SuccessEventDetail>;
|
|
57
|
+
error: CustomEvent<ErrorEventDetail>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class NajaAjax<C extends Naja = Naja, G extends Datagrid = Datagrid> extends EventTarget implements Ajax<C, G> {
|
|
61
|
+
constructor(public client: C) {
|
|
62
|
+
if (!client.VERSION || client.VERSION < 2) {
|
|
63
|
+
throw new Error("NajaAjax supports Naja 2 and higher" + (client.VERSION ? `(version ${client.VERSION} provided)` : ''))
|
|
64
|
+
}
|
|
65
|
+
super();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onInit() {
|
|
69
|
+
this.client.addEventListener('before', (e) => {
|
|
70
|
+
return this.dispatch('before', {
|
|
71
|
+
params: e.detail
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
this.client.uiHandler.addEventListener('interaction', (e) => {
|
|
76
|
+
if (!(e.detail.element instanceof HTMLElement)) {
|
|
77
|
+
throw new Error("Element is not an instanceof HTMLElement");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const dispatchResult = this.dispatch('interact', {
|
|
81
|
+
...e.detail,
|
|
82
|
+
element: e.detail.element as HTMLElement // Naja's event has a type of HTMLElement
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (!dispatchResult) {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return dispatchResult;
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
this.client.addEventListener('success', (e) => {
|
|
95
|
+
return this.dispatch('success', {
|
|
96
|
+
...e.detail,
|
|
97
|
+
params: e.detail.request,
|
|
98
|
+
payload: e.detail.payload as Payload
|
|
99
|
+
});
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
this.client.addEventListener('error', (e) => {
|
|
103
|
+
return this.dispatch('error', {
|
|
104
|
+
...e.detail,
|
|
105
|
+
params: e.detail.request,
|
|
106
|
+
response: e.detail.response,
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
this.client.addEventListener('complete', (e) => {
|
|
111
|
+
return this.dispatch('complete', {
|
|
112
|
+
...e.detail,
|
|
113
|
+
params: e.detail.request,
|
|
114
|
+
response: e.detail.response,
|
|
115
|
+
});
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async request<D = {}, P = DatagridPayload>(args: RequestParams<D>): Promise<P> {
|
|
122
|
+
return await this.client.makeRequest(args.method, args.url, args.data) as P;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async submitForm<E extends HTMLFormElement = HTMLFormElement, P = Payload>(element: E): Promise<P> {
|
|
126
|
+
return await this.client.uiHandler.submitForm(element) as P;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
dispatch<
|
|
130
|
+
K extends string, M extends BaseAjaxEventMap = AjaxEventMap
|
|
131
|
+
>(type: K, detail: K extends keyof M ? EventDetail<M[K]> : any, options?: boolean): boolean {
|
|
132
|
+
return this.dispatchEvent(new CustomEvent(type, {
|
|
133
|
+
detail: detail,
|
|
134
|
+
cancelable: true,
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare addEventListener: <K extends keyof M, M extends BaseAjaxEventMap = AjaxEventMap>(
|
|
140
|
+
type: K,
|
|
141
|
+
listener: EventListener<this, M[K]>,
|
|
142
|
+
options?: boolean | AddEventListenerOptions
|
|
143
|
+
) => void;
|
|
144
|
+
|
|
145
|
+
declare removeEventListener: <K extends keyof M, M extends BaseAjaxEventMap = AjaxEventMap>(
|
|
146
|
+
type: K,
|
|
147
|
+
listener: EventListener<this, M[K]>,
|
|
148
|
+
options?: boolean | AddEventListenerOptions
|
|
149
|
+
) => void;
|
|
150
|
+
|
|
151
|
+
declare dispatchEvent: <K extends string, M extends BaseAjaxEventMap = AjaxEventMap>(
|
|
152
|
+
event: K extends keyof M ? M[K] : CustomEvent
|
|
153
|
+
) => boolean;
|
|
154
|
+
}
|