@youp-grid/react 0.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.
@@ -0,0 +1,3 @@
1
+ export { YoupGrid } from "./YoupGrid.ts";
2
+ export { useYoupGrid } from "./useYoupGrid.ts";
3
+ export type { YoupGridCellContext, YoupGridController, YoupGridDensity, YoupGridHeaderContext, YoupGridOptions, YoupGridProps, YoupGridRowEvent, YoupGridRowsEndReachedEvent, YoupGridStateChange, } from "./types.ts";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { YoupGrid } from "./YoupGrid.js";
2
+ export { useYoupGrid } from "./useYoupGrid.js";
@@ -0,0 +1,682 @@
1
+ .youp-grid {
2
+ --youp-grid-border: #d8dee8;
3
+ --youp-grid-header: #f5f7fb;
4
+ --youp-grid-row-hover: #eef6ff;
5
+ --youp-grid-row-selected: #dbeafe;
6
+ --youp-grid-text: #172033;
7
+ --youp-grid-muted: #64748b;
8
+ --youp-grid-cell-block-padding: 9px;
9
+ --youp-grid-cell-inline-padding: 12px;
10
+ --youp-grid-editor-block-padding: 8px;
11
+ --youp-grid-header-group-block-padding: 7px;
12
+ border: 1px solid var(--youp-grid-border);
13
+ color: var(--youp-grid-text);
14
+ font-family:
15
+ Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
16
+ font-size: 13px;
17
+ line-height: 1.35;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .youp-grid--density-compact {
22
+ --youp-grid-cell-block-padding: 5px;
23
+ --youp-grid-cell-inline-padding: 10px;
24
+ --youp-grid-editor-block-padding: 4px;
25
+ --youp-grid-header-group-block-padding: 5px;
26
+ font-size: 12px;
27
+ }
28
+
29
+ .youp-grid--density-comfortable {
30
+ --youp-grid-cell-block-padding: 13px;
31
+ --youp-grid-cell-inline-padding: 14px;
32
+ --youp-grid-editor-block-padding: 12px;
33
+ --youp-grid-header-group-block-padding: 9px;
34
+ font-size: 14px;
35
+ }
36
+
37
+ .youp-grid,
38
+ .youp-grid *,
39
+ .youp-grid *::before,
40
+ .youp-grid *::after {
41
+ box-sizing: border-box;
42
+ }
43
+
44
+ .youp-grid__toolbar {
45
+ position: relative;
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 8px;
49
+ min-height: 42px;
50
+ padding: 7px 10px;
51
+ border-bottom: 1px solid var(--youp-grid-border);
52
+ background: #fff;
53
+ }
54
+
55
+ .youp-grid__toolbar-button {
56
+ min-height: 28px;
57
+ padding: 4px 9px;
58
+ border: 1px solid var(--youp-grid-border);
59
+ border-radius: 4px;
60
+ color: var(--youp-grid-text);
61
+ font: inherit;
62
+ font-weight: 700;
63
+ cursor: pointer;
64
+ background: #fff;
65
+ }
66
+
67
+ .youp-grid__density-control {
68
+ display: inline-flex;
69
+ align-items: center;
70
+ gap: 6px;
71
+ margin-left: auto;
72
+ color: var(--youp-grid-muted);
73
+ font-weight: 700;
74
+ }
75
+
76
+ .youp-grid__density-control select {
77
+ min-height: 28px;
78
+ padding: 4px 8px;
79
+ border: 1px solid var(--youp-grid-border);
80
+ border-radius: 4px;
81
+ color: var(--youp-grid-text);
82
+ font: inherit;
83
+ background: #fff;
84
+ }
85
+
86
+ .youp-grid__column-panel {
87
+ position: absolute;
88
+ top: calc(100% - 3px);
89
+ left: 10px;
90
+ z-index: 5;
91
+ display: grid;
92
+ gap: 8px;
93
+ width: min(520px, calc(100vw - 48px));
94
+ padding: 10px;
95
+ border: 1px solid var(--youp-grid-border);
96
+ border-radius: 6px;
97
+ background: #fff;
98
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
99
+ }
100
+
101
+ .youp-grid__column-panel-row {
102
+ display: grid;
103
+ grid-template-columns: minmax(120px, 1fr) auto;
104
+ align-items: center;
105
+ gap: 12px;
106
+ }
107
+
108
+ .youp-grid__column-toggle {
109
+ display: inline-flex;
110
+ align-items: center;
111
+ gap: 8px;
112
+ min-width: 0;
113
+ font-weight: 700;
114
+ }
115
+
116
+ .youp-grid__pin-controls {
117
+ display: inline-flex;
118
+ align-items: center;
119
+ gap: 4px;
120
+ }
121
+
122
+ .youp-grid__pin-button {
123
+ min-height: 26px;
124
+ padding: 3px 7px;
125
+ border: 1px solid var(--youp-grid-border);
126
+ border-radius: 4px;
127
+ color: var(--youp-grid-muted);
128
+ font: inherit;
129
+ cursor: pointer;
130
+ background: #fff;
131
+ }
132
+
133
+ .youp-grid__pin-button--active {
134
+ border-color: #3b82f6;
135
+ color: #1d4ed8;
136
+ background: #eff6ff;
137
+ }
138
+
139
+ .youp-grid__row {
140
+ display: flex;
141
+ min-width: max-content;
142
+ border-bottom: 1px solid var(--youp-grid-border);
143
+ }
144
+
145
+ .youp-grid__row:focus {
146
+ outline: 2px solid #3b82f6;
147
+ outline-offset: -2px;
148
+ }
149
+
150
+ .youp-grid__row:hover {
151
+ background: var(--youp-grid-row-hover);
152
+ }
153
+
154
+ .youp-grid__row--header {
155
+ background: var(--youp-grid-header);
156
+ }
157
+
158
+ .youp-grid__row--header-group {
159
+ background: var(--youp-grid-header);
160
+ }
161
+
162
+ .youp-grid__row--aggregation {
163
+ min-height: 36px;
164
+ border-top: 1px solid var(--youp-grid-border);
165
+ background: #f8fafc;
166
+ }
167
+
168
+ .youp-grid__row--group {
169
+ background: #f8fafc;
170
+ }
171
+
172
+ .youp-grid__row--header:hover,
173
+ .youp-grid__row--header-group:hover {
174
+ background: var(--youp-grid-header);
175
+ }
176
+
177
+ .youp-grid__body {
178
+ position: relative;
179
+ overflow: auto;
180
+ }
181
+
182
+ .youp-grid__virtual-spacer {
183
+ position: relative;
184
+ min-width: max-content;
185
+ }
186
+
187
+ .youp-grid__virtual-window {
188
+ position: absolute;
189
+ inset: 0 0 auto;
190
+ }
191
+
192
+ .youp-grid__row--selected {
193
+ background: var(--youp-grid-row-selected);
194
+ }
195
+
196
+ .youp-grid__selection-cell {
197
+ position: sticky;
198
+ left: 0;
199
+ z-index: 3;
200
+ display: grid;
201
+ place-items: center;
202
+ min-width: 44px;
203
+ padding: 0;
204
+ background: #fff;
205
+ }
206
+
207
+ .youp-grid__cell.youp-grid__selection-cell {
208
+ min-width: 44px;
209
+ }
210
+
211
+ .youp-grid__selection-cell--header,
212
+ .youp-grid__selection-cell--header-group {
213
+ z-index: 4;
214
+ background: var(--youp-grid-header);
215
+ }
216
+
217
+ .youp-grid__selection-cell--header {
218
+ align-content: center;
219
+ overflow: hidden;
220
+ }
221
+
222
+ .youp-grid__selection-cell--header-group {
223
+ display: grid;
224
+ padding: 0;
225
+ }
226
+
227
+ .youp-grid__row--selected .youp-grid__selection-cell {
228
+ background: var(--youp-grid-row-selected);
229
+ }
230
+
231
+ .youp-grid__row:hover .youp-grid__selection-cell {
232
+ background: var(--youp-grid-row-hover);
233
+ }
234
+
235
+ .youp-grid__row--selected:hover .youp-grid__selection-cell {
236
+ background: var(--youp-grid-row-selected);
237
+ }
238
+
239
+ .youp-grid__row--header:hover .youp-grid__selection-cell,
240
+ .youp-grid__row--header-group:hover .youp-grid__selection-cell {
241
+ background: var(--youp-grid-header);
242
+ }
243
+
244
+ .youp-grid__row--aggregation:hover .youp-grid__selection-cell {
245
+ background: #f8fafc;
246
+ }
247
+
248
+ .youp-grid__row--group:hover .youp-grid__selection-cell {
249
+ background: #f8fafc;
250
+ }
251
+
252
+ .youp-grid__selection-checkbox {
253
+ width: 16px;
254
+ height: 16px;
255
+ margin: 0;
256
+ accent-color: #2563eb;
257
+ }
258
+
259
+ .youp-grid__cell {
260
+ position: relative;
261
+ flex: 1 1 160px;
262
+ min-width: 80px;
263
+ padding: var(--youp-grid-cell-block-padding) var(--youp-grid-cell-inline-padding);
264
+ border-right: 1px solid var(--youp-grid-border);
265
+ overflow: hidden;
266
+ text-align: left;
267
+ text-overflow: ellipsis;
268
+ white-space: nowrap;
269
+ }
270
+
271
+ .youp-grid__cell:focus {
272
+ outline: none;
273
+ }
274
+
275
+ .youp-grid__cell--focused {
276
+ box-shadow: inset 0 0 0 2px #2563eb;
277
+ }
278
+
279
+ .youp-grid__cell--range-selected {
280
+ background: #dbeafe;
281
+ }
282
+
283
+ .youp-grid__cell--focused.youp-grid__cell--range-selected {
284
+ background: #bfdbfe;
285
+ }
286
+
287
+ .youp-grid__cell--fill-target {
288
+ background: #e0f2fe;
289
+ box-shadow: inset 0 0 0 1px #0ea5e9;
290
+ }
291
+
292
+ .youp-grid__cell--focused.youp-grid__cell--fill-target {
293
+ background: #bae6fd;
294
+ }
295
+
296
+ .youp-grid__fill-handle {
297
+ position: absolute;
298
+ right: 1px;
299
+ bottom: 1px;
300
+ z-index: 4;
301
+ width: 7px;
302
+ height: 7px;
303
+ border: 1px solid #fff;
304
+ background: #2563eb;
305
+ cursor: crosshair;
306
+ }
307
+
308
+ .youp-grid__cell--editing {
309
+ padding: 0;
310
+ box-shadow: inset 0 0 0 2px #1d4ed8;
311
+ }
312
+
313
+ .youp-grid__cell-editor {
314
+ width: 100%;
315
+ height: 100%;
316
+ min-height: 100%;
317
+ padding: var(--youp-grid-editor-block-padding) var(--youp-grid-cell-inline-padding);
318
+ border: 0;
319
+ color: var(--youp-grid-text);
320
+ font: inherit;
321
+ background: #fff;
322
+ outline: none;
323
+ }
324
+
325
+ .youp-grid__cell--pinned-left,
326
+ .youp-grid__cell--pinned-right {
327
+ position: sticky;
328
+ z-index: 2;
329
+ background: #fff;
330
+ }
331
+
332
+ .youp-grid__cell--header.youp-grid__cell--pinned-left,
333
+ .youp-grid__cell--header.youp-grid__cell--pinned-right {
334
+ z-index: 3;
335
+ background: var(--youp-grid-header);
336
+ }
337
+
338
+ .youp-grid__cell--left-last {
339
+ box-shadow: 6px 0 10px -10px rgba(15, 23, 42, 0.7);
340
+ }
341
+
342
+ .youp-grid__cell--right-first {
343
+ box-shadow: -6px 0 10px -10px rgba(15, 23, 42, 0.7);
344
+ }
345
+
346
+ .youp-grid__row--selected .youp-grid__cell--pinned-left,
347
+ .youp-grid__row--selected .youp-grid__cell--pinned-right {
348
+ background: var(--youp-grid-row-selected);
349
+ }
350
+
351
+ .youp-grid__cell--pinned-left.youp-grid__cell--range-selected,
352
+ .youp-grid__cell--pinned-right.youp-grid__cell--range-selected {
353
+ background: #dbeafe;
354
+ }
355
+
356
+ .youp-grid__cell--pinned-left.youp-grid__cell--focused.youp-grid__cell--range-selected,
357
+ .youp-grid__cell--pinned-right.youp-grid__cell--focused.youp-grid__cell--range-selected {
358
+ background: #bfdbfe;
359
+ }
360
+
361
+ .youp-grid__cell--pinned-left.youp-grid__cell--fill-target,
362
+ .youp-grid__cell--pinned-right.youp-grid__cell--fill-target {
363
+ background: #e0f2fe;
364
+ }
365
+
366
+ .youp-grid__cell--focused.youp-grid__cell--left-last {
367
+ box-shadow:
368
+ inset 0 0 0 2px #2563eb,
369
+ 6px 0 10px -10px rgba(15, 23, 42, 0.7);
370
+ }
371
+
372
+ .youp-grid__cell--focused.youp-grid__cell--right-first {
373
+ box-shadow:
374
+ inset 0 0 0 2px #2563eb,
375
+ -6px 0 10px -10px rgba(15, 23, 42, 0.7);
376
+ }
377
+
378
+ .youp-grid__cell--fill-target.youp-grid__cell--left-last {
379
+ box-shadow:
380
+ inset 0 0 0 1px #0ea5e9,
381
+ 6px 0 10px -10px rgba(15, 23, 42, 0.7);
382
+ }
383
+
384
+ .youp-grid__cell--fill-target.youp-grid__cell--right-first {
385
+ box-shadow:
386
+ inset 0 0 0 1px #0ea5e9,
387
+ -6px 0 10px -10px rgba(15, 23, 42, 0.7);
388
+ }
389
+
390
+ .youp-grid__cell--header {
391
+ position: relative;
392
+ display: grid;
393
+ align-content: start;
394
+ gap: 6px;
395
+ border-top: 0;
396
+ border-bottom: 0;
397
+ border-left: 0;
398
+ color: var(--youp-grid-muted);
399
+ font: inherit;
400
+ font-weight: 700;
401
+ overflow: visible;
402
+ background: var(--youp-grid-header);
403
+ }
404
+
405
+ .youp-grid__cell--header-group {
406
+ display: block;
407
+ padding: var(--youp-grid-header-group-block-padding) var(--youp-grid-cell-inline-padding);
408
+ border-right: 1px solid var(--youp-grid-border);
409
+ color: var(--youp-grid-muted);
410
+ font-weight: 800;
411
+ overflow: hidden;
412
+ text-overflow: ellipsis;
413
+ background: var(--youp-grid-header);
414
+ }
415
+
416
+ .youp-grid__cell--aggregation {
417
+ color: var(--youp-grid-text);
418
+ font-weight: 800;
419
+ background: #f8fafc;
420
+ }
421
+
422
+ .youp-grid__cell--aggregation.youp-grid__cell--pinned-left,
423
+ .youp-grid__cell--aggregation.youp-grid__cell--pinned-right,
424
+ .youp-grid__selection-cell--aggregation {
425
+ background: #f8fafc;
426
+ }
427
+
428
+ .youp-grid__cell--group {
429
+ display: flex;
430
+ align-items: center;
431
+ color: var(--youp-grid-text);
432
+ font-weight: 800;
433
+ background: #f8fafc;
434
+ }
435
+
436
+ .youp-grid__selection-cell--group {
437
+ background: #f8fafc;
438
+ }
439
+
440
+ .youp-grid__group-toggle {
441
+ display: inline-flex;
442
+ align-items: center;
443
+ gap: 8px;
444
+ min-width: 0;
445
+ padding: 0;
446
+ border: 0;
447
+ color: inherit;
448
+ font: inherit;
449
+ font-weight: 800;
450
+ cursor: pointer;
451
+ background: transparent;
452
+ }
453
+
454
+ .youp-grid__group-toggle:focus-visible {
455
+ outline: 2px solid #3b82f6;
456
+ outline-offset: 2px;
457
+ }
458
+
459
+ .youp-grid__group-caret {
460
+ width: 14px;
461
+ color: var(--youp-grid-muted);
462
+ text-align: center;
463
+ }
464
+
465
+ .youp-grid__group-label {
466
+ overflow: hidden;
467
+ text-overflow: ellipsis;
468
+ }
469
+
470
+ .youp-grid__group-count {
471
+ color: var(--youp-grid-muted);
472
+ font-weight: 700;
473
+ }
474
+
475
+ .youp-grid__cell--header-group-empty {
476
+ color: transparent;
477
+ }
478
+
479
+ .youp-grid__header-main {
480
+ display: grid;
481
+ grid-template-columns: minmax(0, 1fr) auto;
482
+ align-items: start;
483
+ gap: 4px;
484
+ }
485
+
486
+ .youp-grid__sort-button {
487
+ min-width: 0;
488
+ padding: 0;
489
+ border: 0;
490
+ color: inherit;
491
+ font: inherit;
492
+ font-weight: 700;
493
+ text-align: left;
494
+ cursor: pointer;
495
+ background: transparent;
496
+ }
497
+
498
+ .youp-grid__sort-button:disabled {
499
+ cursor: default;
500
+ }
501
+
502
+ .youp-grid__column-menu-button {
503
+ width: 22px;
504
+ min-width: 22px;
505
+ height: 22px;
506
+ padding: 0;
507
+ border: 1px solid transparent;
508
+ border-radius: 4px;
509
+ color: var(--youp-grid-muted);
510
+ font: inherit;
511
+ line-height: 1;
512
+ cursor: pointer;
513
+ background: transparent;
514
+ }
515
+
516
+ .youp-grid__column-menu-button:hover,
517
+ .youp-grid__column-menu-button[aria-expanded="true"] {
518
+ border-color: var(--youp-grid-border);
519
+ color: var(--youp-grid-text);
520
+ background: #fff;
521
+ }
522
+
523
+ .youp-grid__column-menu {
524
+ position: absolute;
525
+ top: 28px;
526
+ right: 8px;
527
+ z-index: 10;
528
+ display: grid;
529
+ min-width: 158px;
530
+ padding: 6px;
531
+ border: 1px solid var(--youp-grid-border);
532
+ border-radius: 6px;
533
+ background: #fff;
534
+ box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
535
+ }
536
+
537
+ .youp-grid__column-menu-item {
538
+ min-height: 28px;
539
+ padding: 5px 8px;
540
+ border: 0;
541
+ border-radius: 4px;
542
+ color: var(--youp-grid-text);
543
+ font: inherit;
544
+ font-weight: 600;
545
+ text-align: left;
546
+ cursor: pointer;
547
+ background: transparent;
548
+ }
549
+
550
+ .youp-grid__column-menu-item:hover {
551
+ background: #eef6ff;
552
+ }
553
+
554
+ .youp-grid__column-menu-item:disabled {
555
+ color: var(--youp-grid-muted);
556
+ cursor: not-allowed;
557
+ opacity: 0.58;
558
+ background: transparent;
559
+ }
560
+
561
+ .youp-grid__column-menu-separator {
562
+ height: 1px;
563
+ margin: 5px 2px;
564
+ background: var(--youp-grid-border);
565
+ }
566
+
567
+ .youp-grid__sort-button:focus-visible,
568
+ .youp-grid__column-menu-button:focus-visible,
569
+ .youp-grid__column-menu-item:focus-visible,
570
+ .youp-grid__filter:focus-visible,
571
+ .youp-grid__density-control select:focus-visible,
572
+ .youp-grid__selection-checkbox:focus-visible,
573
+ .youp-grid__toolbar-button:focus-visible,
574
+ .youp-grid__pin-button:focus-visible,
575
+ .youp-grid__pagination button:focus-visible,
576
+ .youp-grid__page-size select:focus-visible {
577
+ outline: 2px solid #3b82f6;
578
+ outline-offset: 2px;
579
+ }
580
+
581
+ .youp-grid__filter {
582
+ width: 100%;
583
+ min-width: 0;
584
+ padding: 5px 7px;
585
+ border: 1px solid var(--youp-grid-border);
586
+ border-radius: 4px;
587
+ color: var(--youp-grid-text);
588
+ font: inherit;
589
+ font-weight: 500;
590
+ background: #fff;
591
+ }
592
+
593
+ .youp-grid__resize-handle {
594
+ position: absolute;
595
+ top: 0;
596
+ right: -4px;
597
+ bottom: 0;
598
+ z-index: 1;
599
+ width: 8px;
600
+ cursor: col-resize;
601
+ }
602
+
603
+ .youp-grid__resize-handle::after {
604
+ position: absolute;
605
+ top: 8px;
606
+ right: 3px;
607
+ bottom: 8px;
608
+ width: 2px;
609
+ background: transparent;
610
+ content: "";
611
+ }
612
+
613
+ .youp-grid__resize-handle:hover::after {
614
+ background: #3b82f6;
615
+ }
616
+
617
+ .youp-grid__empty {
618
+ padding: 24px;
619
+ color: var(--youp-grid-muted);
620
+ }
621
+
622
+ .youp-grid__overlay {
623
+ position: absolute;
624
+ inset: 0;
625
+ z-index: 6;
626
+ display: grid;
627
+ place-items: center;
628
+ min-height: 100%;
629
+ padding: 24px;
630
+ color: var(--youp-grid-text);
631
+ text-align: center;
632
+ background: rgba(255, 255, 255, 0.82);
633
+ }
634
+
635
+ .youp-grid__overlay-content {
636
+ max-width: 360px;
637
+ font-weight: 700;
638
+ }
639
+
640
+ .youp-grid__overlay--error {
641
+ color: #991b1b;
642
+ background: rgba(255, 255, 255, 0.9);
643
+ }
644
+
645
+ .youp-grid__pagination {
646
+ display: flex;
647
+ align-items: center;
648
+ gap: 10px;
649
+ min-height: 42px;
650
+ padding: 8px 10px;
651
+ border-top: 1px solid var(--youp-grid-border);
652
+ background: #fff;
653
+ }
654
+
655
+ .youp-grid__pagination button,
656
+ .youp-grid__page-size select {
657
+ min-height: 28px;
658
+ padding: 4px 8px;
659
+ border: 1px solid var(--youp-grid-border);
660
+ border-radius: 4px;
661
+ color: var(--youp-grid-text);
662
+ font: inherit;
663
+ background: #fff;
664
+ }
665
+
666
+ .youp-grid__pagination button:disabled {
667
+ color: var(--youp-grid-muted);
668
+ cursor: not-allowed;
669
+ opacity: 0.62;
670
+ }
671
+
672
+ .youp-grid__page-status {
673
+ color: var(--youp-grid-muted);
674
+ }
675
+
676
+ .youp-grid__page-size {
677
+ display: inline-flex;
678
+ align-items: center;
679
+ gap: 6px;
680
+ margin-left: auto;
681
+ color: var(--youp-grid-muted);
682
+ }