@contributte/datagrid 7.0.0 → 7.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contributte/datagrid",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Assets for contributte/datagrid",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@fortawesome/fontawesome-free": "^6.7.2",
26
26
  "bootstrap": "^5.3.6",
27
- "naja": "^2.6.1",
27
+ "naja": "^3.2.1",
28
28
  "nette-forms": "^3.5.3",
29
29
  "sortablejs": "^1.15.6",
30
30
  "tom-select": "^2.4.3",
@@ -1,6 +0,0 @@
1
- @import "@fortawesome/fontawesome-free/css/all.css";
2
- @import 'bootstrap/dist/css/bootstrap.css';
3
- @import 'vanillajs-datepicker/css/datepicker-bs5.css';
4
- @import "tom-select/dist/css/tom-select.css";
5
- @import './happy.css';
6
- @import './datagrid.css';
@@ -1,463 +0,0 @@
1
- /**
2
- * From happy-inputs by paveljanda:
3
- * https://github.com/paveljanda/happy/blob/94357b7146b5f3029cc565859a588c5832dd374a/src/happy.css
4
- */
5
-
6
- .happy-color,
7
- .happy-checkbox,
8
- .happy-radio {
9
- color: #333333;
10
- }
11
-
12
- .happy-color>b,
13
- .happy-checkbox>b,
14
- .happy-radio>b {
15
- background-color: #333333;
16
- }
17
-
18
- .happy-color.active,
19
- .active.happy-checkbox,
20
- .active.happy-radio {
21
- color: #333333;
22
- }
23
-
24
- .happy-color.active>b,
25
- .active.happy-checkbox>b,
26
- .active.happy-radio>b {
27
- background-color: #333333;
28
- }
29
-
30
- .happy-color.primary,
31
- .primary.happy-checkbox,
32
- .primary.happy-radio {
33
- color: #333333;
34
- }
35
-
36
- .happy-color.primary>b,
37
- .primary.happy-checkbox>b,
38
- .primary.happy-radio>b {
39
- background-color: #333333;
40
- }
41
-
42
- .happy-color.primary.active,
43
- .primary.active.happy-checkbox,
44
- .primary.active.happy-radio {
45
- color: #4c86bb;
46
- }
47
-
48
- .happy-color.primary.active>b,
49
- .primary.active.happy-checkbox>b,
50
- .primary.active.happy-radio>b {
51
- background-color: #4c86bb;
52
- }
53
-
54
- .happy-color.success,
55
- .success.happy-checkbox,
56
- .success.happy-radio {
57
- color: #333333;
58
- }
59
-
60
- .happy-color.success>b,
61
- .success.happy-checkbox>b,
62
- .success.happy-radio>b {
63
- background-color: #333333;
64
- }
65
-
66
- .happy-color.success.active,
67
- .success.active.happy-checkbox,
68
- .success.active.happy-radio {
69
- color: #72b889;
70
- }
71
-
72
- .happy-color.success.active>b,
73
- .success.active.happy-checkbox>b,
74
- .success.active.happy-radio>b {
75
- background-color: #72b889;
76
- }
77
-
78
- .happy-color.info,
79
- .info.happy-checkbox,
80
- .info.happy-radio {
81
- color: #333333;
82
- }
83
-
84
- .happy-color.info>b,
85
- .info.happy-checkbox>b,
86
- .info.happy-radio>b {
87
- background-color: #333333;
88
- }
89
-
90
- .happy-color.info.active,
91
- .info.active.happy-checkbox,
92
- .info.active.happy-radio {
93
- color: #5bc0de;
94
- }
95
-
96
- .happy-color.info.active>b,
97
- .info.active.happy-checkbox>b,
98
- .info.active.happy-radio>b {
99
- background-color: #5bc0de;
100
- }
101
-
102
- .happy-color.warning,
103
- .warning.happy-checkbox,
104
- .warning.happy-radio {
105
- color: #333333;
106
- }
107
-
108
- .happy-color.warning>b,
109
- .warning.happy-checkbox>b,
110
- .warning.happy-radio>b {
111
- background-color: #333333;
112
- }
113
-
114
- .happy-color.warning.active,
115
- .warning.active.happy-checkbox,
116
- .warning.active.happy-radio {
117
- color: #f0bb65;
118
- }
119
-
120
- .happy-color.warning.active>b,
121
- .warning.active.happy-checkbox>b,
122
- .warning.active.happy-radio>b {
123
- background-color: #f0bb65;
124
- }
125
-
126
- .happy-color.danger,
127
- .danger.happy-checkbox,
128
- .danger.happy-radio {
129
- color: #333333;
130
- }
131
-
132
- .happy-color.danger>b,
133
- .danger.happy-checkbox>b,
134
- .danger.happy-radio>b {
135
- background-color: #333333;
136
- }
137
-
138
- .happy-color.danger.active,
139
- .danger.active.happy-checkbox,
140
- .danger.active.happy-radio {
141
- color: #ed6b6b;
142
- }
143
-
144
- .happy-color.danger.active>b,
145
- .danger.active.happy-checkbox>b,
146
- .danger.active.happy-radio>b {
147
- background-color: #ed6b6b;
148
- }
149
-
150
- .happy-color.white,
151
- .white.happy-checkbox,
152
- .white.happy-radio {
153
- color: #333333;
154
- }
155
-
156
- .happy-color.white>b,
157
- .white.happy-checkbox>b,
158
- .white.happy-radio>b {
159
- background-color: #333333;
160
- }
161
-
162
- .happy-color.white.active,
163
- .white.active.happy-checkbox,
164
- .white.active.happy-radio {
165
- color: #ffffff;
166
- }
167
-
168
- .happy-color.white.active>b,
169
- .white.active.happy-checkbox>b,
170
- .white.active.happy-radio>b {
171
- background-color: #ffffff;
172
- }
173
-
174
- .happy-border-color,
175
- .happy-radio {
176
- border-color: rgba(51, 51, 51, 0.8);
177
- }
178
-
179
- .happy-border-color.active,
180
- .active.happy-radio {
181
- border-color: #333333;
182
- }
183
-
184
- .happy-border-color.primary,
185
- .primary.happy-radio {
186
- border-color: rgba(51, 51, 51, 0.8);
187
- }
188
-
189
- .happy-border-color.primary.active,
190
- .primary.active.happy-radio {
191
- border-color: #4c86bb;
192
- }
193
-
194
- .happy-border-color.success,
195
- .success.happy-radio {
196
- border-color: rgba(51, 51, 51, 0.8);
197
- }
198
-
199
- .happy-border-color.success.active,
200
- .success.active.happy-radio {
201
- border-color: #72b889;
202
- }
203
-
204
- .happy-border-color.info,
205
- .info.happy-radio {
206
- border-color: rgba(51, 51, 51, 0.8);
207
- }
208
-
209
- .happy-border-color.info.active,
210
- .info.active.happy-radio {
211
- border-color: #5bc0de;
212
- }
213
-
214
- .happy-border-color.warning,
215
- .warning.happy-radio {
216
- border-color: rgba(51, 51, 51, 0.8);
217
- }
218
-
219
- .happy-border-color.warning.active,
220
- .warning.active.happy-radio {
221
- border-color: #f0bb65;
222
- }
223
-
224
- .happy-border-color.danger,
225
- .danger.happy-radio {
226
- border-color: rgba(51, 51, 51, 0.8);
227
- }
228
-
229
- .happy-border-color.danger.active,
230
- .danger.active.happy-radio {
231
- border-color: #ed6b6b;
232
- }
233
-
234
- .happy-border-color.white,
235
- .white.happy-radio {
236
- border-color: rgba(51, 51, 51, 0.8);
237
- }
238
-
239
- .happy-border-color.white.active,
240
- .white.active.happy-radio {
241
- border-color: #ffffff;
242
- }
243
-
244
- /**
245
- * Common
246
- */
247
-
248
- input[type="radio"].happy,
249
- input[type="checkbox"].happy {
250
- position: absolute;
251
- top: -50%;
252
- left: -50%;
253
- opacity: 0;
254
- }
255
-
256
- label:not(.selectable),
257
- .noselect {
258
- -webkit-touch-callout: none;
259
- -webkit-user-select: none;
260
- -khtml-user-select: none;
261
- -moz-user-select: none;
262
- -ms-user-select: none;
263
- user-select: none;
264
- }
265
-
266
- label {
267
- cursor: pointer;
268
- position: relative;
269
- }
270
-
271
- /**
272
- * Checkbox
273
- */
274
-
275
- .happy-checkbox {
276
- border-color: #333333;
277
- margin-right: 0.2em;
278
- position: relative;
279
- display: inline-block;
280
- line-height: 20px;
281
- vertical-align: middle;
282
- width: 16px;
283
- height: 16px;
284
- border-width: 2px;
285
- border-style: solid;
286
- cursor: pointer;
287
- box-sizing: border-box;
288
- top: -2px;
289
- -webkit-border-radius: 2.66667px;
290
- -moz-border-radius: 2.66667px;
291
- border-radius: 2.66667px;
292
- }
293
-
294
- .happy-checkbox svg {
295
- position: absolute;
296
- display: block;
297
- top: -2px;
298
- left: -2px;
299
- height: 16px;
300
- width: 16px;
301
- opacity: 0;
302
- -webkit-border-radius: 2.66667px;
303
- -moz-border-radius: 2.66667px;
304
- border-radius: 2.66667px;
305
- background-color: #333333;
306
- -ms-transform: scale(0.4);
307
- -webkit-transform: scale(0.4);
308
- transform: scale(0.4);
309
- -ms-transition: all 180ms;
310
- -webkit-transition: all 180ms;
311
- transition: all 180ms;
312
- }
313
-
314
- .happy-checkbox svg rect {
315
- fill: white;
316
- }
317
-
318
- .happy-checkbox svg rect:first-child {
319
- -ms-transform: rotate(45deg);
320
- -webkit-transform: rotate(45deg);
321
- transform: rotate(45deg);
322
- }
323
-
324
- .happy-checkbox svg rect:nth-child(2) {
325
- -ms-transform: rotate(-45deg);
326
- -webkit-transform: rotate(-45deg);
327
- transform: rotate(-45deg);
328
- /* fill: yellow; */
329
- }
330
-
331
- .happy-checkbox.thin {
332
- border-width: 1px;
333
- }
334
-
335
- .happy-checkbox.thin svg {
336
- top: -1px;
337
- left: -1px;
338
- }
339
-
340
- .happy-checkbox.white {
341
- border-color: #ffffff;
342
- }
343
-
344
- .happy-checkbox.gray-border {
345
- border-color: #858585;
346
- }
347
-
348
- .happy-checkbox.primary-border {
349
- border-color: #4c86bb;
350
- }
351
-
352
- .happy-checkbox.success-border {
353
- border-color: #72b889;
354
- }
355
-
356
- .happy-checkbox.info-border {
357
- border-color: #5bc0de;
358
- }
359
-
360
- .happy-checkbox.warning-border {
361
- border-color: #f0bb65;
362
- }
363
-
364
- .happy-checkbox.danger-border {
365
- border-color: #ed6b6b;
366
- }
367
-
368
- .happy-checkbox.primary svg {
369
- background-color: #4c86bb;
370
- }
371
-
372
- .happy-checkbox.success svg {
373
- background-color: #72b889;
374
- }
375
-
376
- .happy-checkbox.info svg {
377
- background-color: #5bc0de;
378
- }
379
-
380
- .happy-checkbox.warning svg {
381
- background-color: #f0bb65;
382
- }
383
-
384
- .happy-checkbox.danger svg {
385
- background-color: #ed6b6b;
386
- }
387
-
388
- .happy-checkbox.white svg {
389
- background-color: #ffffff;
390
- }
391
-
392
- .happy-checkbox.white svg rect {
393
- fill: #333333;
394
- }
395
-
396
- .happy-checkbox.active {
397
- border-color: transparent;
398
- }
399
-
400
- .happy-checkbox.active svg {
401
- opacity: 1;
402
- -ms-transform: scale(1);
403
- -webkit-transform: scale(1);
404
- transform: scale(1);
405
- }
406
-
407
- /**
408
- * Radio
409
- */
410
-
411
- .happy-radio {
412
- position: relative;
413
- display: inline-block;
414
- line-height: 20px;
415
- vertical-align: middle;
416
- width: 16px;
417
- height: 16px;
418
- border-width: 2px;
419
- border-style: solid;
420
- cursor: pointer;
421
- box-sizing: border-box;
422
- top: -2px;
423
- -webkit-border-radius: 16px;
424
- -moz-border-radius: 16px;
425
- border-radius: 16px;
426
- }
427
-
428
- .happy-radio.thin {
429
- border-width: 1.66667px;
430
- }
431
-
432
- .happy-radio b {
433
- position: absolute;
434
- display: block;
435
- top: 2px;
436
- left: 2px;
437
- bottom: 2px;
438
- right: 2px;
439
- opacity: 0;
440
- -webkit-border-radius: 10.66667px;
441
- -moz-border-radius: 10.66667px;
442
- border-radius: 10.66667px;
443
- -ms-transform: scale(0.4);
444
- -webkit-transform: scale(0.4);
445
- transform: scale(0.4);
446
- -ms-transition: all 180ms;
447
- -webkit-transition: all 180ms;
448
- transition: all 180ms;
449
- }
450
-
451
- .happy-radio.active b {
452
- opacity: 1;
453
- -ms-transform: scale(1);
454
- -webkit-transform: scale(1);
455
- transform: scale(1);
456
- }
457
-
458
- .happy-radio.focus {
459
- outline: none;
460
- -webkit-box-shadow: 0px 0px 5px 0px rgba(50, 50, 50, 0.75);
461
- -moz-box-shadow: 0px 0px 5px 0px rgba(50, 50, 50, 0.75);
462
- box-shadow: 0px 0px 5px 0px rgba(50, 50, 50, 0.75);
463
- }
@@ -1 +0,0 @@
1
- export * from "./datagrid-full";
@@ -1,217 +0,0 @@
1
- /**
2
- * Slightly cleaned up & typed version of happy-inputs by paveljanda.
3
- */
4
- export class Happy {
5
- private colors: string[] = ["primary", "success", "info", "warning", "danger", "white", "gray"];
6
-
7
- private templates = {
8
- radio: '<div class="happy-radio"><b></b></div>',
9
- checkbox:
10
- '<div class="happy-checkbox"><svg viewBox="0 0 30 30"><rect class="mark-storke" x="15" y="3" rx="1" ry="1" width="10" height="4"/><rect class="mark-storke" x="-7" y="21" rx="1" ry="1" width="19" height="4"/></svg></div>',
11
- text: "",
12
- textarea: "",
13
- };
14
-
15
- init() {
16
- this.removeBySelector(".happy-radio");
17
- this.removeBySelector(".happy-checkbox");
18
-
19
- this.initRadio();
20
- this.initCheckbox();
21
- }
22
-
23
- /**
24
- * @deprecated
25
- */
26
- reset() {
27
- this.init();
28
- }
29
-
30
- addColorToInput(input: HTMLElement, happyInput: HTMLElement, classString: string) {
31
- if (input.classList.contains(classString)) {
32
- happyInput.classList.add(classString);
33
- }
34
-
35
- classString = `${classString}-border`;
36
-
37
- if (input.classList.contains(classString)) {
38
- happyInput.classList.add(classString);
39
- }
40
- }
41
-
42
- // i... you know what, no, let "thinkess" be "thinkess"
43
- addThinkessToInput(input: HTMLElement, happyInput: HTMLElement) {
44
- if (input.classList.contains("thin")) {
45
- happyInput.classList.add("thin");
46
- }
47
- }
48
-
49
- setNames(input: HTMLElement, happyInput: HTMLElement) {
50
- happyInput.setAttribute("data-name", input.getAttribute("name") ?? "");
51
-
52
- var value = input.getAttribute("value");
53
-
54
- if (value !== "undefined" && value !== null) {
55
- happyInput.setAttribute("data-value", input.getAttribute("value") ?? "");
56
- }
57
- }
58
-
59
- removeBySelector(selector: string) {
60
- document.querySelectorAll(selector).forEach(el => el.parentNode?.removeChild(el));
61
- }
62
-
63
- initRadio() {
64
- document.querySelectorAll<HTMLInputElement>("input[type=radio].happy").forEach(input => {
65
- /**
66
- * Paste happy component into html
67
- */
68
- input.insertAdjacentHTML("afterend", this.templates.radio);
69
-
70
- const happyInput = input.nextElementSibling;
71
-
72
- if (happyInput instanceof HTMLElement) {
73
- /**
74
- * Add optional colors
75
- */
76
- this.colors.forEach(color => {
77
- this.addColorToInput(input, happyInput, color);
78
- this.setNames(input, happyInput);
79
- });
80
-
81
- this.addThinkessToInput(input, happyInput);
82
- }
83
-
84
- /**
85
- * Init state
86
- */
87
- this.checkRadioState(input);
88
-
89
- /**
90
- * Set aciton functionality for native change
91
- */
92
- document.addEventListener("change", this.radioOnChange.bind(this));
93
- });
94
- }
95
-
96
- initCheckbox() {
97
- document.querySelectorAll<HTMLInputElement>("input[type=checkbox].happy").forEach(input => {
98
- /**
99
- * Paste happy component into html
100
- */
101
- input.insertAdjacentHTML("afterend", this.templates.checkbox);
102
-
103
- const happyInput = input.nextElementSibling;
104
-
105
- /**
106
- * Add optional colors
107
- */
108
- if (happyInput instanceof HTMLElement) {
109
- this.colors.forEach(color => {
110
- this.addColorToInput(input, happyInput, color);
111
- this.setNames(input, happyInput);
112
- });
113
-
114
- this.addThinkessToInput(input, happyInput);
115
- }
116
-
117
- /**
118
- * Init state
119
- */
120
- this.checkCheckboxState(input);
121
-
122
- /**
123
- * Set action functionality for click || native change
124
- */
125
- document.addEventListener("click", this.checkCheckboxStateOnClick.bind(this));
126
- document.addEventListener("change", this.checkCheckboxStateOnChange.bind(this));
127
- });
128
- }
129
-
130
- checkCheckboxStateOnClick(event: Event) {
131
- const target = event.target;
132
-
133
- // When target is SVGSVGElement (<svg>), return parentNode,
134
- // When target is a SVGGraphicsElement (<rect>,...), find <svg> and return it's parent node
135
- // otherwise return target itself.
136
- const happyInput =
137
- target instanceof SVGSVGElement
138
- ? target.parentNode
139
- : target instanceof SVGGraphicsElement
140
- ? target.closest("svg")?.parentNode
141
- : target;
142
-
143
- if (!(happyInput instanceof HTMLElement) || !happyInput.classList.contains("happy-checkbox")) {
144
- return;
145
- }
146
-
147
- event.preventDefault();
148
-
149
- const name = happyInput.getAttribute("data-name");
150
- const value = happyInput.getAttribute("data-value");
151
-
152
- const input = document.querySelector(
153
- `.happy-checkbox[data-name="${name}"]` + (!!value ? `[value="${value}"]` : "")
154
- );
155
- if (!(input instanceof HTMLInputElement)) return;
156
-
157
- const checked = happyInput.classList.contains("active");
158
-
159
- input.checked = !checked;
160
- checked ? happyInput.classList.remove("active") : happyInput.classList.add("active");
161
- }
162
-
163
- checkCheckboxStateOnChange({target}: Event) {
164
- if (!(target instanceof HTMLInputElement)) return;
165
-
166
- if (target.classList.contains("happy")) {
167
- this.checkCheckboxState(target);
168
- }
169
- }
170
-
171
- checkRadioState(input: HTMLInputElement) {
172
- if (!input.checked || !input.hasAttribute("name")) return;
173
-
174
- const name = input.getAttribute("name");
175
- const value = input.getAttribute("value");
176
-
177
- const element = document.querySelector(
178
- `.happy-checkbox[data-name="${name}"]` + (!!value ? `[data-value="${value}"]` : "")
179
- );
180
-
181
- if (element) {
182
- element.classList.add("active");
183
- }
184
- }
185
-
186
- checkCheckboxState(input: HTMLInputElement) {
187
- const name = input.getAttribute("name");
188
- if (!name) return;
189
-
190
- const value = input.getAttribute("value");
191
- const element = document.querySelector(
192
- `.happy-checkbox[data-name="${name}"]` + (!!value ? `[data-value="${value}"]` : "")
193
- );
194
-
195
- if (!element) return;
196
-
197
- input.checked ? element.classList.add("active") : element.classList.remove("active");
198
- }
199
-
200
- radioOnChange({target}: Event) {
201
- // Check whether target is <input>, is a happy input (.happy) & has the name attribute
202
- if (
203
- !(target instanceof HTMLInputElement) ||
204
- !target.classList.contains("happy") ||
205
- !target.hasAttribute("name")
206
- )
207
- return;
208
-
209
- const name = target.getAttribute("name")!;
210
-
211
- document
212
- .querySelectorAll(`.happy-radio[data-name="${name}"]`)
213
- .forEach(happyRadio => happyRadio.classList.remove("active"));
214
-
215
- this.checkRadioState(target);
216
- }
217
- }
@@ -1,19 +0,0 @@
1
- import { Datagrid } from "../..";
2
- import { DatagridPlugin } from "../../types";
3
- import { window } from "../../utils";
4
- import type { Happy } from "../../integrations";
5
-
6
- export class HappyPlugin implements DatagridPlugin {
7
- constructor(private happy?: Happy) {
8
- }
9
-
10
- onDatagridInit(datagrid: Datagrid): boolean {
11
- const happy = this.happy ?? window().happy ?? null;
12
-
13
- if (happy) {
14
- happy.init();
15
- }
16
-
17
- return true;
18
- }
19
- }