modern-cmdk 1.0.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.
Files changed (32) hide show
  1. package/LICENSE +21 -0
  2. package/dist/codemod/cli.d.mts +1 -0
  3. package/dist/codemod/cli.mjs +89836 -0
  4. package/dist/codemod/cli.mjs.map +1 -0
  5. package/dist/codemod/transforms/data-attrs.d.mts +11 -0
  6. package/dist/codemod/transforms/data-attrs.d.mts.map +1 -0
  7. package/dist/codemod/transforms/data-attrs.mjs +68 -0
  8. package/dist/codemod/transforms/data-attrs.mjs.map +1 -0
  9. package/dist/codemod/transforms/forward-ref.d.mts +11 -0
  10. package/dist/codemod/transforms/forward-ref.d.mts.map +1 -0
  11. package/dist/codemod/transforms/forward-ref.mjs +53 -0
  12. package/dist/codemod/transforms/forward-ref.mjs.map +1 -0
  13. package/dist/codemod/transforms/import-rewrite.d.mts +11 -0
  14. package/dist/codemod/transforms/import-rewrite.d.mts.map +1 -0
  15. package/dist/codemod/transforms/import-rewrite.mjs +45 -0
  16. package/dist/codemod/transforms/import-rewrite.mjs.map +1 -0
  17. package/dist/codemod/transforms/should-filter.d.mts +10 -0
  18. package/dist/codemod/transforms/should-filter.d.mts.map +1 -0
  19. package/dist/codemod/transforms/should-filter.mjs +21 -0
  20. package/dist/codemod/transforms/should-filter.mjs.map +1 -0
  21. package/dist/core/index.d.mts +2 -0
  22. package/dist/core/index.mjs +2 -0
  23. package/dist/core-Bq0eDvlc.mjs +1217 -0
  24. package/dist/core-Bq0eDvlc.mjs.map +1 -0
  25. package/dist/index-Ctz7l29k.d.mts +562 -0
  26. package/dist/index-Ctz7l29k.d.mts.map +1 -0
  27. package/dist/react/index.d.mts +358 -0
  28. package/dist/react/index.d.mts.map +1 -0
  29. package/dist/react/index.mjs +905 -0
  30. package/dist/react/index.mjs.map +1 -0
  31. package/package.json +71 -0
  32. package/src/react/styles.css +609 -0
@@ -0,0 +1,609 @@
1
+ /* modern-cmdk/react — GPU-composited animations */
2
+ /* All animations respect prefers-reduced-motion */
3
+ /* Spring easing via linear() approximation — perceptually smooth */
4
+ /* Scroll-driven animations via animation-timeline: scroll() */
5
+ /* WCAG 2.1 AA: forced-colors, prefers-contrast, prefers-reduced-motion */
6
+ /* CSS Logical Properties: full RTL/LTR support */
7
+ /* CSS Nesting, @layer cascade control, oklch() color space */
8
+ /* Container queries for responsive item layout */
9
+
10
+ /* ─── CSS Custom Properties ─── */
11
+
12
+ @property --command-list-height {
13
+ syntax: "<length>";
14
+ inherits: false;
15
+ initial-value: 0px;
16
+ }
17
+
18
+ @property --command-count {
19
+ syntax: "<integer>";
20
+ inherits: false;
21
+ initial-value: 0;
22
+ }
23
+
24
+ @property --command-overlay-opacity {
25
+ syntax: "<number>";
26
+ inherits: false;
27
+ initial-value: 0;
28
+ }
29
+
30
+ @property --command-dialog-scale {
31
+ syntax: "<number>";
32
+ inherits: false;
33
+ initial-value: 0.96;
34
+ }
35
+
36
+ @property --command-dialog-translate {
37
+ syntax: "<length>";
38
+ inherits: false;
39
+ initial-value: 8px;
40
+ }
41
+
42
+ /* ─── User-Customizable Animation Properties ─── */
43
+ /* Override these on [data-command-root] or :root to customize all animations */
44
+
45
+ [data-command-root] {
46
+ --command-spring-easing: linear(
47
+ 0,
48
+ 0.006,
49
+ 0.025,
50
+ 0.058,
51
+ 0.104,
52
+ 0.163,
53
+ 0.234,
54
+ 0.315,
55
+ 0.404,
56
+ 0.499,
57
+ 0.596,
58
+ 0.693,
59
+ 0.784,
60
+ 0.867,
61
+ 0.939,
62
+ 0.998,
63
+ 1
64
+ );
65
+ --command-spring-easing-bouncy: linear(
66
+ 0,
67
+ 0.009,
68
+ 0.035,
69
+ 0.078,
70
+ 0.138,
71
+ 0.213,
72
+ 0.303,
73
+ 0.404,
74
+ 0.511,
75
+ 0.621,
76
+ 0.726,
77
+ 0.822,
78
+ 0.905,
79
+ 0.971,
80
+ 1.015,
81
+ 1.033,
82
+ 1.026,
83
+ 1
84
+ );
85
+ --command-easing-exit: cubic-bezier(0.4, 0, 1, 1);
86
+ --command-duration-enter: 200ms;
87
+ --command-duration-enter-scale: 250ms;
88
+ --command-duration-exit: 150ms;
89
+ --command-duration-item: 120ms;
90
+ --command-duration-list: 200ms;
91
+ --command-duration-page: 200ms;
92
+ --command-duration-loading: 1.5s;
93
+ --command-scale-from: 0.96;
94
+ --command-translate-from: 8px;
95
+ --command-overlay-blur: 4px;
96
+ --command-dialog-radius: 12px;
97
+ --command-dialog-max-width: 640px;
98
+ --command-dialog-max-height: 480px;
99
+ --command-item-height: 44px;
100
+ --command-fade-edge-size: 16px;
101
+ --command-highlight-color: oklch(0.85 0.15 90 / 0.3);
102
+ }
103
+
104
+ /* ─── Spring Easing ─── */
105
+ /* linear() approximation of a critically-damped spring (stiffness: 100, damping: 15) */
106
+ /* Generated from spring physics: x(t) = 1 - e^(-zt)(cos(wd*t) + (zw/wd)sin(wd*t)) */
107
+
108
+ @layer command.base, command.layout, command.animation, command.a11y;
109
+
110
+ @layer command.base {
111
+ /* ─── Screen Reader Only (for Radix Title/Description) ─── */
112
+
113
+ .sr-only {
114
+ position: absolute;
115
+ inline-size: 1px;
116
+ block-size: 1px;
117
+ padding: 0;
118
+ margin: -1px;
119
+ overflow: hidden;
120
+ clip: rect(0, 0, 0, 0);
121
+ white-space: nowrap;
122
+ border-width: 0;
123
+ }
124
+ }
125
+
126
+ @layer command.layout {
127
+ /* ─── Overlay ─── */
128
+
129
+ [data-command-overlay] {
130
+ position: fixed;
131
+ inset: 0;
132
+ z-index: 9998;
133
+ background: oklch(0 0 0 / var(--command-overlay-opacity, 0.4));
134
+ backdrop-filter: blur(var(--command-overlay-blur));
135
+ -webkit-backdrop-filter: blur(var(--command-overlay-blur));
136
+ }
137
+
138
+ /* ─── Dialog ─── */
139
+
140
+ [data-command-dialog] {
141
+ position: fixed;
142
+ z-index: 9999;
143
+ inset: 0;
144
+ display: flex;
145
+ align-items: flex-start;
146
+ justify-content: center;
147
+ padding-block-start: min(20vh, 140px);
148
+ pointer-events: none;
149
+
150
+ & > * {
151
+ pointer-events: auto;
152
+ }
153
+ }
154
+
155
+ /* Dialog content container — container query context */
156
+ [data-command-dialog-content] {
157
+ container-type: inline-size;
158
+ container-name: command-dialog;
159
+ inline-size: min(var(--command-dialog-max-width), calc(100vi - 32px));
160
+ max-block-size: min(var(--command-dialog-max-height), calc(100vb - 200px));
161
+ overflow: hidden;
162
+ border-radius: var(--command-dialog-radius);
163
+ contain: layout style;
164
+ }
165
+
166
+ /* ─── Input ─── */
167
+
168
+ [data-command-input] {
169
+ inline-size: 100%;
170
+ border: none;
171
+ outline: none;
172
+ background: transparent;
173
+ caret-color: currentColor;
174
+ font: inherit;
175
+
176
+ &::placeholder {
177
+ opacity: 0.5;
178
+ }
179
+ }
180
+
181
+ /* ─── List ─── */
182
+
183
+ [data-command-list] {
184
+ overflow-y: auto;
185
+ overscroll-behavior: contain;
186
+ scroll-timeline: --list-scroll block;
187
+ will-change: height;
188
+ transition: height var(--command-duration-list) var(--command-spring-easing);
189
+ scrollbar-gutter: stable;
190
+ scrollbar-width: thin;
191
+ }
192
+
193
+ /* ─── List Inner ─── */
194
+
195
+ [data-command-list-inner] {
196
+ position: relative;
197
+ contain: layout style paint;
198
+ }
199
+
200
+ /* ─── Item ─── */
201
+
202
+ [data-command-item] {
203
+ cursor: pointer;
204
+ user-select: none;
205
+ will-change: background-color;
206
+ transition: background-color var(--command-duration-item) linear(0, 0.25, 0.5, 0.75, 1);
207
+ scroll-margin-block: 8px;
208
+ content-visibility: auto;
209
+ contain-intrinsic-size: auto var(--command-item-height);
210
+
211
+ &[data-disabled] {
212
+ cursor: not-allowed;
213
+ opacity: 0.5;
214
+ pointer-events: none;
215
+ }
216
+ }
217
+
218
+ /* ─── Virtualization ─── */
219
+
220
+ [data-command-virtual-item] {
221
+ content-visibility: auto;
222
+ contain-intrinsic-size: auto var(--command-item-height);
223
+ }
224
+
225
+ [data-command-list-virtual] {
226
+ position: relative;
227
+ will-change: transform;
228
+ }
229
+
230
+ /* ─── Group ─── */
231
+
232
+ [data-command-group-heading] {
233
+ user-select: none;
234
+ font-size: 0.75em;
235
+ text-transform: uppercase;
236
+ letter-spacing: 0.05em;
237
+ opacity: 0.6;
238
+ }
239
+
240
+ /* ─── Separator ─── */
241
+
242
+ [data-command-separator] {
243
+ block-size: 1px;
244
+ opacity: 0.15;
245
+ background: currentColor;
246
+ }
247
+
248
+ /* ─── Highlight ─── */
249
+
250
+ [data-command-highlight] {
251
+ background: var(--command-highlight-color);
252
+ border-radius: 2px;
253
+ color: inherit;
254
+ }
255
+
256
+ /* ─── Empty ─── */
257
+
258
+ [data-command-empty] {
259
+ text-align: center;
260
+ opacity: 0.6;
261
+ }
262
+
263
+ /* ─── Shortcut Badge ─── */
264
+
265
+ [data-command-shortcut] {
266
+ font-family: inherit;
267
+ font-size: 0.75em;
268
+ opacity: 0.5;
269
+ letter-spacing: 0.05em;
270
+ }
271
+
272
+ [data-command-badge] {
273
+ font-size: 0.7em;
274
+ font-weight: 600;
275
+ text-transform: uppercase;
276
+ letter-spacing: 0.04em;
277
+ }
278
+
279
+ /* ─── Container Queries — responsive item layout ─── */
280
+
281
+ @container command-dialog (inline-size < 400px) {
282
+ [data-command-item] {
283
+ /* Stack shortcut below item text on narrow containers */
284
+ flex-wrap: wrap;
285
+
286
+ & [data-command-shortcut] {
287
+ inline-size: 100%;
288
+ margin-block-start: 4px;
289
+ }
290
+
291
+ & [data-command-badge] {
292
+ display: none;
293
+ }
294
+ }
295
+
296
+ [data-command-group-heading] {
297
+ font-size: 0.65em;
298
+ }
299
+ }
300
+
301
+ @container command-dialog (inline-size >= 400px) {
302
+ [data-command-item] {
303
+ /* Horizontal layout with shortcut inline */
304
+ flex-wrap: nowrap;
305
+ }
306
+ }
307
+ }
308
+
309
+ @layer command.animation {
310
+ /* ─── Overlay Animations ─── */
311
+
312
+ [data-command-overlay][data-state="open"] {
313
+ @starting-style {
314
+ --command-overlay-opacity: 0;
315
+ opacity: 0;
316
+ }
317
+ --command-overlay-opacity: 0.4;
318
+ opacity: 1;
319
+ transition:
320
+ opacity var(--command-duration-enter) var(--command-spring-easing),
321
+ --command-overlay-opacity var(--command-duration-enter) ease-out,
322
+ display var(--command-duration-enter) allow-discrete,
323
+ overlay var(--command-duration-enter) allow-discrete;
324
+ }
325
+
326
+ [data-command-overlay][data-state="closed"] {
327
+ --command-overlay-opacity: 0;
328
+ opacity: 0;
329
+ transition:
330
+ opacity var(--command-duration-exit) var(--command-easing-exit),
331
+ --command-overlay-opacity var(--command-duration-exit) ease-in,
332
+ display var(--command-duration-exit) allow-discrete,
333
+ overlay var(--command-duration-exit) allow-discrete;
334
+ }
335
+
336
+ /* ─── Dialog Animations ─── */
337
+ /* GPU-composited dialog animation — zero layout thrash */
338
+ /* Spring easing via linear() approximation */
339
+
340
+ [data-command-dialog][data-state="open"] {
341
+ @starting-style {
342
+ --command-dialog-scale: var(--command-scale-from);
343
+ --command-dialog-translate: var(--command-translate-from);
344
+ opacity: 0;
345
+ scale: var(--command-scale-from);
346
+ translate: 0 var(--command-translate-from);
347
+ }
348
+ --command-dialog-scale: 1;
349
+ --command-dialog-translate: 0px;
350
+ opacity: 1;
351
+ scale: 1;
352
+ translate: 0 0;
353
+ transition:
354
+ opacity var(--command-duration-enter) var(--command-spring-easing),
355
+ scale var(--command-duration-enter-scale) var(--command-spring-easing-bouncy),
356
+ translate var(--command-duration-enter-scale) var(--command-spring-easing-bouncy),
357
+ display var(--command-duration-enter-scale) allow-discrete,
358
+ overlay var(--command-duration-enter-scale) allow-discrete;
359
+ }
360
+
361
+ /* Exit animation — quicker, no spring overshoot */
362
+ [data-command-dialog][data-state="closed"] {
363
+ --command-dialog-scale: var(--command-scale-from);
364
+ --command-dialog-translate: 4px;
365
+ opacity: 0;
366
+ scale: var(--command-scale-from);
367
+ translate: 0 4px;
368
+ transition:
369
+ opacity var(--command-duration-exit) var(--command-easing-exit),
370
+ scale var(--command-duration-exit) var(--command-easing-exit),
371
+ translate var(--command-duration-exit) var(--command-easing-exit),
372
+ display var(--command-duration-exit) allow-discrete,
373
+ overlay var(--command-duration-exit) allow-discrete;
374
+ }
375
+
376
+ /* ─── Fading Edge Indicators (Scroll-Driven) ─── */
377
+
378
+ [data-command-list] {
379
+ &::before,
380
+ &::after {
381
+ content: "";
382
+ display: block;
383
+ position: sticky;
384
+ inset-inline: 0;
385
+ block-size: var(--command-fade-edge-size);
386
+ pointer-events: none;
387
+ z-index: 1;
388
+ opacity: 0;
389
+ transition: opacity var(--command-duration-exit) ease-out;
390
+ }
391
+
392
+ /* Top fade — visible when scrolled down */
393
+ &::before {
394
+ inset-block-start: 0;
395
+ background: linear-gradient(to bottom, currentColor, transparent);
396
+ opacity: 0.08;
397
+ animation: fade-edge-top linear both;
398
+ animation-timeline: --list-scroll;
399
+ animation-range: 0px 24px;
400
+ }
401
+
402
+ /* Bottom fade — visible when not scrolled to bottom */
403
+ &::after {
404
+ inset-block-end: 0;
405
+ background: linear-gradient(to top, currentColor, transparent);
406
+ opacity: 0.08;
407
+ animation: fade-edge-bottom linear both;
408
+ animation-timeline: --list-scroll;
409
+ animation-range: calc(100% - 24px) 100%;
410
+ }
411
+ }
412
+
413
+ @keyframes fade-edge-top {
414
+ from {
415
+ opacity: 0;
416
+ }
417
+ to {
418
+ opacity: 0.08;
419
+ }
420
+ }
421
+
422
+ @keyframes fade-edge-bottom {
423
+ from {
424
+ opacity: 0.08;
425
+ }
426
+ to {
427
+ opacity: 0;
428
+ }
429
+ }
430
+
431
+ /* ─── Scroll-Driven Progress Indicator ─── */
432
+
433
+ [data-command-scroll-indicator] {
434
+ block-size: 2px;
435
+ transform-origin: inline-start;
436
+ scale: 0 1;
437
+ animation: scroll-progress linear both;
438
+ animation-timeline: --list-scroll;
439
+ will-change: scale;
440
+ }
441
+
442
+ @keyframes scroll-progress {
443
+ from {
444
+ scale: 0 1;
445
+ }
446
+ to {
447
+ scale: 1 1;
448
+ }
449
+ }
450
+
451
+ /* ─── Focus Indicators ─── */
452
+
453
+ [data-command-item]:focus-visible {
454
+ outline: 2px solid currentColor;
455
+ outline-offset: -2px;
456
+ border-radius: 4px;
457
+ }
458
+
459
+ [data-command-input]:focus-visible {
460
+ outline: 2px solid currentColor;
461
+ outline-offset: 2px;
462
+ }
463
+
464
+ /* ─── Loading ─── */
465
+
466
+ [data-command-loading] {
467
+ animation: command-loading-pulse var(--command-duration-loading) ease-in-out infinite;
468
+ animation-composition: accumulate;
469
+ }
470
+
471
+ @keyframes command-loading-pulse {
472
+ 0%,
473
+ 100% {
474
+ opacity: 0.5;
475
+ }
476
+ 50% {
477
+ opacity: 1;
478
+ }
479
+ }
480
+
481
+ /* ─── Page Transitions ─── */
482
+
483
+ [data-command-page] {
484
+ animation: page-enter var(--command-duration-page) ease-out;
485
+ }
486
+
487
+ @keyframes page-enter {
488
+ from {
489
+ opacity: 0;
490
+ translate: var(--command-translate-from) 0;
491
+ }
492
+ to {
493
+ opacity: 1;
494
+ translate: 0 0;
495
+ }
496
+ }
497
+ }
498
+
499
+ /* ═══════════════════════════════════════════════════════════ */
500
+ /* ─── Accessibility Layer ─── */
501
+ /* ═══════════════════════════════════════════════════════════ */
502
+
503
+ @layer command.a11y {
504
+ /* ─── Reduced Motion ─── */
505
+
506
+ @media (prefers-reduced-motion: reduce) {
507
+ *,
508
+ *::before,
509
+ *::after {
510
+ animation-duration: 0.01ms;
511
+ animation-iteration-count: 1;
512
+ transition-duration: 0.01ms;
513
+ scroll-behavior: auto;
514
+ }
515
+
516
+ [data-command-dialog],
517
+ [data-command-overlay] {
518
+ &[data-state="open"],
519
+ &[data-state="closed"] {
520
+ transition: none;
521
+ }
522
+ }
523
+ }
524
+
525
+ /* ─── High Contrast ─── */
526
+
527
+ @media (prefers-contrast: more) {
528
+ [data-command-item] {
529
+ &[data-active] {
530
+ outline: 3px solid currentColor;
531
+ outline-offset: -3px;
532
+ }
533
+
534
+ &:focus-visible {
535
+ outline-width: 3px;
536
+ }
537
+ }
538
+
539
+ [data-command-input]:focus-visible {
540
+ outline-width: 3px;
541
+ }
542
+
543
+ [data-command-separator] {
544
+ opacity: 0.4;
545
+ }
546
+
547
+ [data-command-group-heading] {
548
+ opacity: 0.8;
549
+ }
550
+
551
+ [data-command-highlight] {
552
+ background: oklch(0.85 0.2 90 / 0.5);
553
+ text-decoration: underline;
554
+ text-decoration-thickness: 2px;
555
+ }
556
+ }
557
+
558
+ /* ─── Windows High Contrast (forced-colors) ─── */
559
+
560
+ @media (forced-colors: active) {
561
+ [data-command-item] {
562
+ &[data-active] {
563
+ background-color: Highlight;
564
+ color: HighlightText;
565
+ forced-color-adjust: none;
566
+ }
567
+
568
+ &:focus-visible {
569
+ outline-color: ButtonText;
570
+ outline-style: solid;
571
+ }
572
+
573
+ &[data-disabled] {
574
+ color: GrayText;
575
+ opacity: 1;
576
+ }
577
+ }
578
+
579
+ [data-command-overlay] {
580
+ background-color: Canvas;
581
+ opacity: 0.8;
582
+ }
583
+
584
+ [data-command-dialog-content] {
585
+ border: 2px solid ButtonText;
586
+ background-color: Canvas;
587
+ }
588
+
589
+ [data-command-input] {
590
+ border-block-end: 1px solid ButtonText;
591
+ }
592
+
593
+ [data-command-separator] {
594
+ background: ButtonText;
595
+ opacity: 1;
596
+ }
597
+
598
+ [data-command-highlight] {
599
+ background: transparent;
600
+ color: LinkText;
601
+ text-decoration: underline;
602
+ }
603
+
604
+ [data-command-group-heading] {
605
+ color: GrayText;
606
+ opacity: 1;
607
+ }
608
+ }
609
+ }