@speles7172/controls 0.1.1 → 0.2.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/dist/styles.css CHANGED
@@ -32,8 +32,10 @@
32
32
  --ctl-mark-bg: #fef08a;
33
33
  --ctl-mark-text: #422006;
34
34
  --ctl-error-text: #b91c1c;
35
+ --ctl-error-soft: #fef2f2;
35
36
  --ctl-radius: 8px;
36
37
  --ctl-shadow: 0 8px 24px rgb(15 23 42 / 12%);
38
+ --ctl-overlay: rgb(15 23 42 / 45%);
37
39
 
38
40
  color: var(--ctl-text);
39
41
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
@@ -55,7 +57,9 @@
55
57
  --ctl-mark-bg: #854d0e;
56
58
  --ctl-mark-text: #fef9c3;
57
59
  --ctl-error-text: #fca5a5;
60
+ --ctl-error-soft: #450a0a;
58
61
  --ctl-shadow: 0 8px 24px rgb(0 0 0 / 45%);
62
+ --ctl-overlay: rgb(0 0 0 / 65%);
59
63
  }
60
64
 
61
65
  @media (prefers-color-scheme: dark) {
@@ -70,7 +74,9 @@
70
74
  --ctl-mark-bg: #854d0e;
71
75
  --ctl-mark-text: #fef9c3;
72
76
  --ctl-error-text: #fca5a5;
77
+ --ctl-error-soft: #450a0a;
73
78
  --ctl-shadow: 0 8px 24px rgb(0 0 0 / 45%);
79
+ --ctl-overlay: rgb(0 0 0 / 65%);
74
80
  }
75
81
  }
76
82
 
@@ -367,3 +373,252 @@
367
373
  .ctl-link:hover {
368
374
  text-decoration: underline;
369
375
  }
376
+
377
+ /*
378
+ * ── Fields ────────────────────────────────────────────────────────────────
379
+ *
380
+ * `<ValueInput>` and the rows of `<KeyValueList>`. They share `.ctl-input` on
381
+ * purpose: a text box inside a list of entries and a text box on its own are
382
+ * the same thing to a reader, and giving each its own rule is how two controls
383
+ * in one form end up a pixel apart.
384
+ */
385
+
386
+ .ctl-field {
387
+ gap: 6px;
388
+ }
389
+
390
+ .ctl-input,
391
+ .ctl-textarea {
392
+ width: 100%;
393
+ padding: 8px 10px;
394
+ font: inherit;
395
+ color: var(--ctl-text);
396
+ background: var(--ctl-bg);
397
+ border: 1px solid var(--ctl-border);
398
+ border-radius: var(--ctl-radius);
399
+ }
400
+
401
+ .ctl-input:focus-visible,
402
+ .ctl-textarea:focus-visible {
403
+ outline: 2px solid var(--ctl-accent);
404
+ outline-offset: -1px;
405
+ }
406
+
407
+ .ctl-input:disabled,
408
+ .ctl-textarea:disabled {
409
+ color: var(--ctl-muted);
410
+ background: var(--ctl-surface);
411
+ cursor: not-allowed;
412
+ }
413
+
414
+ .ctl-input[aria-invalid="true"],
415
+ .ctl-textarea[aria-invalid="true"] {
416
+ border-color: var(--ctl-error-text);
417
+ }
418
+
419
+ .ctl-textarea {
420
+ resize: vertical;
421
+ }
422
+
423
+ /* JSON is read by shape as much as by content, and a proportional font hides it. */
424
+ .ctl-mono {
425
+ font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
426
+ font-size: 13px;
427
+ }
428
+
429
+ .ctl-switch {
430
+ display: inline-flex;
431
+ gap: 8px;
432
+ align-items: center;
433
+ cursor: pointer;
434
+ }
435
+
436
+ .ctl-switch-box {
437
+ width: 16px;
438
+ height: 16px;
439
+ accent-color: var(--ctl-accent);
440
+ cursor: inherit;
441
+ }
442
+
443
+ .ctl-switch-text {
444
+ color: var(--ctl-muted);
445
+ }
446
+
447
+ /*
448
+ * ── Key/value list ────────────────────────────────────────────────────────
449
+ *
450
+ * Four columns, and the same grid on the heading row and every entry so the
451
+ * headings stay over the boxes they name at any width.
452
+ */
453
+
454
+ .ctl-kv {
455
+ gap: 6px;
456
+ }
457
+
458
+ .ctl-kv-head,
459
+ .ctl-kv-row {
460
+ display: grid;
461
+ grid-template-columns: 1fr 1fr 1fr auto;
462
+ gap: 6px;
463
+ align-items: center;
464
+ }
465
+
466
+ .ctl-kv-head {
467
+ font-size: 12px;
468
+ color: var(--ctl-muted);
469
+ }
470
+
471
+ .ctl-kv-cell {
472
+ min-width: 0;
473
+ }
474
+
475
+ .ctl-kv-duplicate {
476
+ padding: 2px;
477
+ margin: -2px;
478
+ background: var(--ctl-error-soft);
479
+ border-radius: var(--ctl-radius);
480
+ }
481
+
482
+ .ctl-kv-actions {
483
+ display: flex;
484
+ gap: 2px;
485
+ justify-content: flex-end;
486
+ }
487
+
488
+ .ctl-kv-empty {
489
+ padding: 6px 0;
490
+ }
491
+
492
+ .ctl-kv-add {
493
+ align-self: flex-start;
494
+ }
495
+
496
+ /*
497
+ * The modal.
498
+ *
499
+ * `position: fixed` rather than a portal: the element stays inside whatever
500
+ * bridged `--ctl-*` onto its own palette (see `Modal.tsx`), and fixed
501
+ * positioning covers the viewport from wherever it sits. The one thing that
502
+ * breaks it is an ancestor with `transform`, `filter` or `will-change`, which
503
+ * makes itself the containing block for fixed descendants — the fix for that is
504
+ * on the ancestor.
505
+ */
506
+ .ctl-modal-overlay {
507
+ position: fixed;
508
+ inset: 0;
509
+ z-index: 40;
510
+ display: flex;
511
+ gap: 0;
512
+ align-items: center;
513
+ justify-content: center;
514
+ padding: 16px;
515
+ overflow-y: auto;
516
+ background: var(--ctl-overlay);
517
+ }
518
+
519
+ .ctl-modal {
520
+ display: flex;
521
+ flex-direction: column;
522
+ width: 100%;
523
+ max-width: 560px;
524
+ /* Bounded so the panel scrolls internally and its header and footer stay
525
+ put. A dialog taller than the viewport scrolls the backdrop instead, and
526
+ the close button ends up somewhere nobody can reach. */
527
+ max-height: calc(100vh - 32px);
528
+ background: var(--ctl-bg);
529
+ border: 1px solid var(--ctl-border);
530
+ border-radius: var(--ctl-radius);
531
+ box-shadow: var(--ctl-shadow);
532
+ animation: ctl-modal-in 120ms ease-out;
533
+ }
534
+
535
+ .ctl-modal-wide {
536
+ max-width: 880px;
537
+ }
538
+
539
+ .ctl-modal:focus-visible {
540
+ outline: 2px solid var(--ctl-accent);
541
+ outline-offset: 2px;
542
+ }
543
+
544
+ .ctl-modal-head {
545
+ display: flex;
546
+ flex-shrink: 0;
547
+ gap: 12px;
548
+ align-items: center;
549
+ justify-content: space-between;
550
+ padding: 12px 16px;
551
+ border-bottom: 1px solid var(--ctl-border);
552
+ }
553
+
554
+ .ctl-modal-title {
555
+ margin: 0;
556
+ font-size: 15px;
557
+ font-weight: 600;
558
+ }
559
+
560
+ .ctl-modal-close {
561
+ display: flex;
562
+ align-items: center;
563
+ justify-content: center;
564
+ padding: 4px;
565
+ color: var(--ctl-muted);
566
+ cursor: pointer;
567
+ background: none;
568
+ border: 0;
569
+ border-radius: 6px;
570
+ }
571
+
572
+ .ctl-modal-close:hover {
573
+ color: var(--ctl-text);
574
+ background: var(--ctl-surface);
575
+ }
576
+
577
+ .ctl-modal-close:focus-visible {
578
+ outline: 2px solid var(--ctl-accent);
579
+ outline-offset: 1px;
580
+ }
581
+
582
+ .ctl-modal-body {
583
+ flex: 1 1 auto;
584
+ padding: 16px;
585
+ overflow-y: auto;
586
+ }
587
+
588
+ .ctl-modal-foot {
589
+ display: flex;
590
+ flex-shrink: 0;
591
+ flex-wrap: wrap;
592
+ gap: 8px;
593
+ justify-content: flex-end;
594
+ padding: 12px 16px;
595
+ border-top: 1px solid var(--ctl-border);
596
+ }
597
+
598
+ @keyframes ctl-modal-in {
599
+ from {
600
+ opacity: 0;
601
+ transform: translateY(6px);
602
+ }
603
+ }
604
+
605
+ @media (prefers-reduced-motion: reduce) {
606
+ .ctl-modal {
607
+ animation: none;
608
+ }
609
+ }
610
+
611
+ /* Below this the panel is the screen: side padding buys nothing and costs
612
+ width the content needs. */
613
+ @media (max-width: 480px) {
614
+ .ctl-modal-overlay {
615
+ padding: 0;
616
+ }
617
+
618
+ .ctl-modal {
619
+ max-width: none;
620
+ min-height: 100%;
621
+ border: 0;
622
+ border-radius: 0;
623
+ }
624
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speles7172/controls",
3
- "version": "0.1.1",
4
- "description": "Reusable React form controls — starting with a searchable multi-select — over static options or a transport you supply.",
3
+ "version": "0.2.1",
4
+ "description": "Reusable React form controls — searchable selects, a typed value field and an editable key/value list — over static options or a transport you supply.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",