@speles7172/controls 0.7.0 → 0.7.2
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/README.md +65 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/DetailList.d.ts +35 -0
- package/dist/DetailList.d.ts.map +1 -0
- package/dist/DetailList.js +18 -0
- package/dist/DetailList.js.map +1 -0
- package/dist/EmojiPicker.d.ts +51 -0
- package/dist/EmojiPicker.d.ts.map +1 -0
- package/dist/EmojiPicker.js +97 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/IconButton.d.ts +47 -0
- package/dist/IconButton.d.ts.map +1 -0
- package/dist/IconButton.js +18 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/Modal.d.ts +23 -1
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +62 -9
- package/dist/Modal.js.map +1 -1
- package/dist/RecordModal.d.ts +58 -0
- package/dist/RecordModal.d.ts.map +1 -0
- package/dist/RecordModal.js +53 -0
- package/dist/RecordModal.js.map +1 -0
- package/dist/SideNav.d.ts +69 -0
- package/dist/SideNav.d.ts.map +1 -0
- package/dist/SideNav.js +118 -0
- package/dist/SideNav.js.map +1 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +3 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +422 -0
- package/dist/useRecentEmojis.d.ts +15 -0
- package/dist/useRecentEmojis.d.ts.map +1 -0
- package/dist/useRecentEmojis.js +52 -0
- package/dist/useRecentEmojis.js.map +1 -0
- package/package.json +2 -2
package/dist/styles.css
CHANGED
|
@@ -2604,6 +2604,337 @@
|
|
|
2604
2604
|
list-style: none;
|
|
2605
2605
|
}
|
|
2606
2606
|
|
|
2607
|
+
/*
|
|
2608
|
+
* The modal header's own actions — an Edit pencil, a history icon — sit
|
|
2609
|
+
* between the title and the close button. `margin-inline-start: auto` takes the
|
|
2610
|
+
* free space, so the title keeps its edge and the actions stay with the close.
|
|
2611
|
+
*/
|
|
2612
|
+
.ctl-modal-head-actions {
|
|
2613
|
+
display: flex;
|
|
2614
|
+
flex-shrink: 0;
|
|
2615
|
+
gap: var(--ctl-space-1);
|
|
2616
|
+
align-items: center;
|
|
2617
|
+
margin-inline-start: auto;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/*
|
|
2621
|
+
* An icon-only button. Muted at rest whatever its tone — six actions in a row
|
|
2622
|
+
* are six quiet glyphs, not a traffic light — and coloured on hover and focus,
|
|
2623
|
+
* as the answer to "what will this do".
|
|
2624
|
+
*/
|
|
2625
|
+
.ctl-icon-btn {
|
|
2626
|
+
display: inline-flex;
|
|
2627
|
+
flex-shrink: 0;
|
|
2628
|
+
align-items: center;
|
|
2629
|
+
justify-content: center;
|
|
2630
|
+
width: 32px;
|
|
2631
|
+
height: 32px;
|
|
2632
|
+
padding: 0;
|
|
2633
|
+
font: inherit;
|
|
2634
|
+
color: var(--ctl-muted);
|
|
2635
|
+
cursor: pointer;
|
|
2636
|
+
background: none;
|
|
2637
|
+
border: 0;
|
|
2638
|
+
border-radius: var(--ctl-radius-sm);
|
|
2639
|
+
transition:
|
|
2640
|
+
background 120ms ease,
|
|
2641
|
+
color 120ms ease;
|
|
2642
|
+
}
|
|
2643
|
+
.ctl-icon-btn-sm {
|
|
2644
|
+
width: 28px;
|
|
2645
|
+
height: 28px;
|
|
2646
|
+
}
|
|
2647
|
+
.ctl-icon-btn-md {
|
|
2648
|
+
width: 32px;
|
|
2649
|
+
height: 32px;
|
|
2650
|
+
}
|
|
2651
|
+
.ctl-icon-btn:focus-visible {
|
|
2652
|
+
outline: 2px solid var(--ctl-accent);
|
|
2653
|
+
outline-offset: 1px;
|
|
2654
|
+
}
|
|
2655
|
+
.ctl-icon-btn:disabled {
|
|
2656
|
+
cursor: default;
|
|
2657
|
+
opacity: 0.45;
|
|
2658
|
+
}
|
|
2659
|
+
.ctl-icon-btn-neutral:hover:not(:disabled),
|
|
2660
|
+
.ctl-icon-btn-neutral:focus-visible {
|
|
2661
|
+
color: var(--ctl-text);
|
|
2662
|
+
background: var(--ctl-hover);
|
|
2663
|
+
}
|
|
2664
|
+
.ctl-icon-btn-accent:hover:not(:disabled),
|
|
2665
|
+
.ctl-icon-btn-accent:focus-visible {
|
|
2666
|
+
color: var(--ctl-accent);
|
|
2667
|
+
background: var(--ctl-accent-soft);
|
|
2668
|
+
}
|
|
2669
|
+
.ctl-icon-btn-danger:hover:not(:disabled),
|
|
2670
|
+
.ctl-icon-btn-danger:focus-visible {
|
|
2671
|
+
color: var(--ctl-danger);
|
|
2672
|
+
background: var(--ctl-danger-soft);
|
|
2673
|
+
}
|
|
2674
|
+
.ctl-icon-btn-ok:hover:not(:disabled),
|
|
2675
|
+
.ctl-icon-btn-ok:focus-visible {
|
|
2676
|
+
color: var(--ctl-ok);
|
|
2677
|
+
background: var(--ctl-ok-soft);
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
/*
|
|
2681
|
+
* A record's read view: label over value, two facts to a row. The wrap is the
|
|
2682
|
+
* size container, so the two columns fold into one on the list's own width —
|
|
2683
|
+
* a record in a narrow side panel is one column on a wide monitor too.
|
|
2684
|
+
*/
|
|
2685
|
+
.ctl-details-wrap {
|
|
2686
|
+
container-type: inline-size;
|
|
2687
|
+
}
|
|
2688
|
+
.ctl-details {
|
|
2689
|
+
display: grid;
|
|
2690
|
+
gap: var(--ctl-space-3) var(--ctl-space-5);
|
|
2691
|
+
margin: 0;
|
|
2692
|
+
}
|
|
2693
|
+
.ctl-details-cols-1 {
|
|
2694
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2695
|
+
}
|
|
2696
|
+
.ctl-details-cols-2 {
|
|
2697
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
2698
|
+
}
|
|
2699
|
+
@container (max-width: 440px) {
|
|
2700
|
+
.ctl-details-cols-2 {
|
|
2701
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
.ctl-details-item {
|
|
2705
|
+
display: flex;
|
|
2706
|
+
flex-direction: column;
|
|
2707
|
+
gap: 2px;
|
|
2708
|
+
min-width: 0;
|
|
2709
|
+
}
|
|
2710
|
+
.ctl-details-item-wide {
|
|
2711
|
+
grid-column: 1 / -1;
|
|
2712
|
+
}
|
|
2713
|
+
.ctl-details-label {
|
|
2714
|
+
font-size: var(--ctl-text-sm);
|
|
2715
|
+
color: var(--ctl-muted);
|
|
2716
|
+
}
|
|
2717
|
+
.ctl-details-value {
|
|
2718
|
+
margin: 0;
|
|
2719
|
+
overflow-wrap: anywhere;
|
|
2720
|
+
color: var(--ctl-text);
|
|
2721
|
+
}
|
|
2722
|
+
.ctl-details-empty {
|
|
2723
|
+
color: var(--ctl-faint);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
/* A record dialog's content; a hook for the host, laid out by what it holds. */
|
|
2727
|
+
.ctl-record {
|
|
2728
|
+
min-width: 0;
|
|
2729
|
+
}
|
|
2730
|
+
.ctl-record-view,
|
|
2731
|
+
.ctl-record-edit {
|
|
2732
|
+
min-width: 0;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
/*
|
|
2736
|
+
* An application's vertical menu. One accent, on the current page; headings
|
|
2737
|
+
* small and muted; nothing else coloured. Logical properties throughout, so it
|
|
2738
|
+
* reads the same from the right in Hebrew.
|
|
2739
|
+
*/
|
|
2740
|
+
.ctl-sidenav {
|
|
2741
|
+
display: flex;
|
|
2742
|
+
flex-direction: column;
|
|
2743
|
+
gap: var(--ctl-space-2);
|
|
2744
|
+
min-height: 0;
|
|
2745
|
+
padding: var(--ctl-space-3) var(--ctl-space-2);
|
|
2746
|
+
background: var(--ctl-bg);
|
|
2747
|
+
}
|
|
2748
|
+
.ctl-sidenav-header,
|
|
2749
|
+
.ctl-sidenav-footer {
|
|
2750
|
+
flex-shrink: 0;
|
|
2751
|
+
padding: 0 var(--ctl-space-2);
|
|
2752
|
+
}
|
|
2753
|
+
.ctl-sidenav-footer {
|
|
2754
|
+
padding-block-start: var(--ctl-space-3);
|
|
2755
|
+
border-top: 1px solid var(--ctl-border);
|
|
2756
|
+
}
|
|
2757
|
+
.ctl-sidenav-body {
|
|
2758
|
+
display: flex;
|
|
2759
|
+
flex: 1;
|
|
2760
|
+
flex-direction: column;
|
|
2761
|
+
gap: var(--ctl-space-3);
|
|
2762
|
+
min-height: 0;
|
|
2763
|
+
overflow-y: auto;
|
|
2764
|
+
}
|
|
2765
|
+
.ctl-sidenav-section {
|
|
2766
|
+
display: flex;
|
|
2767
|
+
flex-direction: column;
|
|
2768
|
+
gap: 2px;
|
|
2769
|
+
}
|
|
2770
|
+
.ctl-sidenav-heading {
|
|
2771
|
+
display: flex;
|
|
2772
|
+
gap: var(--ctl-space-2);
|
|
2773
|
+
align-items: center;
|
|
2774
|
+
justify-content: space-between;
|
|
2775
|
+
width: 100%;
|
|
2776
|
+
padding: var(--ctl-space-1) var(--ctl-space-2);
|
|
2777
|
+
font: inherit;
|
|
2778
|
+
font-size: var(--ctl-text-xs);
|
|
2779
|
+
font-weight: 600;
|
|
2780
|
+
color: var(--ctl-muted);
|
|
2781
|
+
text-align: start;
|
|
2782
|
+
text-transform: uppercase;
|
|
2783
|
+
letter-spacing: 0.04em;
|
|
2784
|
+
cursor: pointer;
|
|
2785
|
+
background: none;
|
|
2786
|
+
border: 0;
|
|
2787
|
+
border-radius: var(--ctl-radius-sm);
|
|
2788
|
+
}
|
|
2789
|
+
.ctl-sidenav-heading:hover {
|
|
2790
|
+
color: var(--ctl-text);
|
|
2791
|
+
}
|
|
2792
|
+
.ctl-sidenav-heading:focus-visible {
|
|
2793
|
+
outline: 2px solid var(--ctl-accent);
|
|
2794
|
+
outline-offset: 1px;
|
|
2795
|
+
}
|
|
2796
|
+
.ctl-sidenav-heading-label {
|
|
2797
|
+
min-width: 0;
|
|
2798
|
+
overflow: hidden;
|
|
2799
|
+
text-overflow: ellipsis;
|
|
2800
|
+
white-space: nowrap;
|
|
2801
|
+
}
|
|
2802
|
+
.ctl-sidenav-chevron {
|
|
2803
|
+
flex-shrink: 0;
|
|
2804
|
+
transition: transform 120ms ease;
|
|
2805
|
+
}
|
|
2806
|
+
.ctl-sidenav-heading[aria-expanded="false"] .ctl-sidenav-chevron {
|
|
2807
|
+
transform: rotate(-90deg);
|
|
2808
|
+
}
|
|
2809
|
+
/* Folded, the chevron points along the reading direction: right in English,
|
|
2810
|
+
left in Hebrew. */
|
|
2811
|
+
:where([dir="rtl"]) .ctl-sidenav-heading[aria-expanded="false"] .ctl-sidenav-chevron {
|
|
2812
|
+
transform: rotate(90deg);
|
|
2813
|
+
}
|
|
2814
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2815
|
+
.ctl-sidenav-chevron {
|
|
2816
|
+
transition: none;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
.ctl-sidenav-list {
|
|
2820
|
+
display: flex;
|
|
2821
|
+
flex-direction: column;
|
|
2822
|
+
gap: 2px;
|
|
2823
|
+
padding: 0;
|
|
2824
|
+
margin: 0;
|
|
2825
|
+
list-style: none;
|
|
2826
|
+
}
|
|
2827
|
+
.ctl-sidenav-entry {
|
|
2828
|
+
margin: 0;
|
|
2829
|
+
}
|
|
2830
|
+
.ctl-sidenav-item {
|
|
2831
|
+
position: relative;
|
|
2832
|
+
display: flex;
|
|
2833
|
+
gap: var(--ctl-space-3);
|
|
2834
|
+
align-items: center;
|
|
2835
|
+
width: 100%;
|
|
2836
|
+
min-height: 36px;
|
|
2837
|
+
padding: var(--ctl-space-2);
|
|
2838
|
+
font: inherit;
|
|
2839
|
+
color: var(--ctl-text);
|
|
2840
|
+
text-align: start;
|
|
2841
|
+
text-decoration: none;
|
|
2842
|
+
cursor: pointer;
|
|
2843
|
+
background: none;
|
|
2844
|
+
border: 0;
|
|
2845
|
+
border-radius: var(--ctl-radius-sm);
|
|
2846
|
+
transition:
|
|
2847
|
+
background 120ms ease,
|
|
2848
|
+
color 120ms ease;
|
|
2849
|
+
}
|
|
2850
|
+
.ctl-sidenav-item:hover {
|
|
2851
|
+
background: var(--ctl-hover);
|
|
2852
|
+
}
|
|
2853
|
+
.ctl-sidenav-item:focus-visible {
|
|
2854
|
+
outline: 2px solid var(--ctl-accent);
|
|
2855
|
+
outline-offset: -2px;
|
|
2856
|
+
}
|
|
2857
|
+
.ctl-sidenav-item-current {
|
|
2858
|
+
font-weight: 600;
|
|
2859
|
+
color: var(--ctl-accent);
|
|
2860
|
+
background: var(--ctl-accent-soft);
|
|
2861
|
+
}
|
|
2862
|
+
.ctl-sidenav-item-current:hover {
|
|
2863
|
+
background: var(--ctl-accent-soft);
|
|
2864
|
+
}
|
|
2865
|
+
.ctl-sidenav-icon {
|
|
2866
|
+
display: inline-flex;
|
|
2867
|
+
flex-shrink: 0;
|
|
2868
|
+
color: var(--ctl-muted);
|
|
2869
|
+
}
|
|
2870
|
+
.ctl-sidenav-item-current .ctl-sidenav-icon {
|
|
2871
|
+
color: var(--ctl-accent);
|
|
2872
|
+
}
|
|
2873
|
+
.ctl-sidenav-label {
|
|
2874
|
+
flex: 1;
|
|
2875
|
+
min-width: 0;
|
|
2876
|
+
overflow: hidden;
|
|
2877
|
+
text-overflow: ellipsis;
|
|
2878
|
+
white-space: nowrap;
|
|
2879
|
+
}
|
|
2880
|
+
.ctl-sidenav-badge {
|
|
2881
|
+
flex-shrink: 0;
|
|
2882
|
+
min-width: 18px;
|
|
2883
|
+
padding: 0 6px;
|
|
2884
|
+
font-size: var(--ctl-text-xs);
|
|
2885
|
+
font-weight: 600;
|
|
2886
|
+
line-height: 18px;
|
|
2887
|
+
color: var(--ctl-accent-text);
|
|
2888
|
+
text-align: center;
|
|
2889
|
+
background: var(--ctl-accent);
|
|
2890
|
+
border-radius: var(--ctl-radius-pill);
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
/* The icon-only rail: labels and headings go; each section is a group with a
|
|
2894
|
+
hairline between it and the next. */
|
|
2895
|
+
.ctl-sidenav-collapsed {
|
|
2896
|
+
align-items: center;
|
|
2897
|
+
padding-inline: var(--ctl-space-1);
|
|
2898
|
+
}
|
|
2899
|
+
.ctl-sidenav-collapsed .ctl-sidenav-header,
|
|
2900
|
+
.ctl-sidenav-collapsed .ctl-sidenav-footer {
|
|
2901
|
+
padding-inline: 0;
|
|
2902
|
+
}
|
|
2903
|
+
.ctl-sidenav-collapsed .ctl-sidenav-section + .ctl-sidenav-section {
|
|
2904
|
+
padding-block-start: var(--ctl-space-3);
|
|
2905
|
+
border-top: 1px solid var(--ctl-border);
|
|
2906
|
+
}
|
|
2907
|
+
.ctl-sidenav-collapsed .ctl-sidenav-item {
|
|
2908
|
+
justify-content: center;
|
|
2909
|
+
width: 40px;
|
|
2910
|
+
padding: var(--ctl-space-2) 0;
|
|
2911
|
+
}
|
|
2912
|
+
.ctl-sidenav-collapsed .ctl-sidenav-label {
|
|
2913
|
+
display: none;
|
|
2914
|
+
}
|
|
2915
|
+
.ctl-sidenav-collapsed .ctl-sidenav-badge {
|
|
2916
|
+
position: absolute;
|
|
2917
|
+
inset-block-start: 2px;
|
|
2918
|
+
inset-inline-end: 2px;
|
|
2919
|
+
min-width: 8px;
|
|
2920
|
+
height: 8px;
|
|
2921
|
+
padding: 0;
|
|
2922
|
+
overflow: hidden;
|
|
2923
|
+
font-size: 0;
|
|
2924
|
+
line-height: 8px;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
@media (pointer: coarse) {
|
|
2928
|
+
.ctl-icon-btn {
|
|
2929
|
+
width: 44px;
|
|
2930
|
+
height: 44px;
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
.ctl-sidenav-item {
|
|
2934
|
+
min-height: 44px;
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2607
2938
|
/* Touch targets (PR #226 review): a chip and the toast's dismiss are 44px on a
|
|
2608
2939
|
coarse pointer, keeping their desktop sizes elsewhere. The dismiss grows
|
|
2609
2940
|
outward (negative margin) so the strip's visual size does not change. */
|
|
@@ -2629,3 +2960,94 @@
|
|
|
2629
2960
|
animation: none;
|
|
2630
2961
|
}
|
|
2631
2962
|
}
|
|
2963
|
+
|
|
2964
|
+
/* ── Emoji picker ───────────────────────────────────────────────────────────
|
|
2965
|
+
A trigger and a fixed popover. The root is a `.ctl` so it carries the
|
|
2966
|
+
palette, but it is an inline part beside a text box: the bare `.ctl` rule
|
|
2967
|
+
would make it a column, so this puts it back on one line. */
|
|
2968
|
+
.ctl.ctl-emoji {
|
|
2969
|
+
display: inline-flex;
|
|
2970
|
+
flex-direction: row;
|
|
2971
|
+
gap: 0;
|
|
2972
|
+
align-items: center;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
.ctl-emoji-trigger[aria-expanded="true"] {
|
|
2976
|
+
color: var(--ctl-text);
|
|
2977
|
+
background: var(--ctl-surface);
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
.ctl-emoji-trigger:disabled {
|
|
2981
|
+
cursor: default;
|
|
2982
|
+
opacity: 0.5;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
.ctl-emoji-panel {
|
|
2986
|
+
width: 304px;
|
|
2987
|
+
height: 340px;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
.ctl-emoji-search {
|
|
2991
|
+
display: flex;
|
|
2992
|
+
gap: var(--ctl-space-2);
|
|
2993
|
+
align-items: center;
|
|
2994
|
+
color: var(--ctl-faint);
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
.ctl-emoji-body {
|
|
2998
|
+
flex: 1;
|
|
2999
|
+
min-height: 0;
|
|
3000
|
+
padding: 0 var(--ctl-space-2) var(--ctl-space-2);
|
|
3001
|
+
overflow-y: auto;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
.ctl-emoji-heading {
|
|
3005
|
+
position: sticky;
|
|
3006
|
+
top: 0;
|
|
3007
|
+
padding: var(--ctl-space-2) 0 var(--ctl-space-1);
|
|
3008
|
+
margin: 0;
|
|
3009
|
+
font-size: var(--ctl-text-xs);
|
|
3010
|
+
font-weight: 600;
|
|
3011
|
+
color: var(--ctl-faint);
|
|
3012
|
+
text-transform: uppercase;
|
|
3013
|
+
letter-spacing: 0.04em;
|
|
3014
|
+
background: var(--ctl-bg);
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
.ctl-emoji-grid {
|
|
3018
|
+
display: grid;
|
|
3019
|
+
grid-template-columns: repeat(8, 1fr);
|
|
3020
|
+
gap: 2px;
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
.ctl-emoji-cell {
|
|
3024
|
+
display: flex;
|
|
3025
|
+
align-items: center;
|
|
3026
|
+
justify-content: center;
|
|
3027
|
+
height: 32px;
|
|
3028
|
+
padding: 0;
|
|
3029
|
+
font-size: 20px;
|
|
3030
|
+
line-height: 1;
|
|
3031
|
+
cursor: pointer;
|
|
3032
|
+
background: transparent;
|
|
3033
|
+
border: 0;
|
|
3034
|
+
border-radius: var(--ctl-radius-sm);
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
.ctl-emoji-cell:hover,
|
|
3038
|
+
.ctl-emoji-cell:focus-visible {
|
|
3039
|
+
background: var(--ctl-surface);
|
|
3040
|
+
outline: none;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
.ctl-emoji-cell:focus-visible {
|
|
3044
|
+
box-shadow: inset 0 0 0 2px var(--ctl-accent);
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
.ctl-emoji-empty {
|
|
3048
|
+
padding: var(--ctl-space-5) 0;
|
|
3049
|
+
margin: 0;
|
|
3050
|
+
font-size: var(--ctl-text-sm);
|
|
3051
|
+
color: var(--ctl-faint);
|
|
3052
|
+
text-align: center;
|
|
3053
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The emoji somebody used last, most recent first, kept in `localStorage` under
|
|
3
|
+
* `storageKey`.
|
|
4
|
+
*
|
|
5
|
+
* Name the key after the person (`emojiRecentStorageKey(userId)` from
|
|
6
|
+
* `controls-client/core`), so two people sharing a browser do not see each
|
|
7
|
+
* other's. Both the read and the write are wrapped: the storage accessor itself
|
|
8
|
+
* throws in a private window and on a full quota, and a picker that would not
|
|
9
|
+
* open because it could not remember a smiley is the worst possible trade.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useRecentEmojis(storageKey: string | null | undefined): {
|
|
12
|
+
recent: string[];
|
|
13
|
+
record(emoji: string): void;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useRecentEmojis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecentEmojis.d.ts","sourceRoot":"","sources":["../src/useRecentEmojis.ts"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IACtE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAgCA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { EMOJI_RECENT_LIMIT, parseRecentEmojis, recordRecentEmoji, } from '@speles7172/controls-client/core';
|
|
3
|
+
/**
|
|
4
|
+
* The emoji somebody used last, most recent first, kept in `localStorage` under
|
|
5
|
+
* `storageKey`.
|
|
6
|
+
*
|
|
7
|
+
* Name the key after the person (`emojiRecentStorageKey(userId)` from
|
|
8
|
+
* `controls-client/core`), so two people sharing a browser do not see each
|
|
9
|
+
* other's. Both the read and the write are wrapped: the storage accessor itself
|
|
10
|
+
* throws in a private window and on a full quota, and a picker that would not
|
|
11
|
+
* open because it could not remember a smiley is the worst possible trade.
|
|
12
|
+
*/
|
|
13
|
+
export function useRecentEmojis(storageKey) {
|
|
14
|
+
const [recent, setRecent] = useState(() => read(storageKey));
|
|
15
|
+
const [keyRead, setKeyRead] = useState(storageKey);
|
|
16
|
+
// A new person in the same mounted composer: re-read during render rather
|
|
17
|
+
// than in an effect, so the previous person's emoji are never painted.
|
|
18
|
+
if (keyRead !== storageKey) {
|
|
19
|
+
setKeyRead(storageKey);
|
|
20
|
+
setRecent(read(storageKey));
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
* ⚠️ **Written to storage here, never inside a state updater.** Choosing an
|
|
24
|
+
* emoji closes the panel in the same press, which unmounts this hook; an
|
|
25
|
+
* updater queued for an unmounted component never runs, so a write inside it
|
|
26
|
+
* would be lost every time — the one moment there is something to remember.
|
|
27
|
+
*/
|
|
28
|
+
const record = useCallback((emoji) => {
|
|
29
|
+
const next = recordRecentEmoji(read(storageKey), emoji, EMOJI_RECENT_LIMIT);
|
|
30
|
+
if (storageKey) {
|
|
31
|
+
try {
|
|
32
|
+
window.localStorage.setItem(storageKey, JSON.stringify(next));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Remembered for this page only.
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
setRecent(next);
|
|
39
|
+
}, [storageKey]);
|
|
40
|
+
return { recent, record };
|
|
41
|
+
}
|
|
42
|
+
function read(storageKey) {
|
|
43
|
+
if (!storageKey)
|
|
44
|
+
return [];
|
|
45
|
+
try {
|
|
46
|
+
return parseRecentEmojis(window.localStorage.getItem(storageKey));
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=useRecentEmojis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecentEmojis.js","sourceRoot":"","sources":["../src/useRecentEmojis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,UAAqC;IAInE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAW,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACnD,0EAA0E;IAC1E,uEAAuE;IACvE,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QAC3B,UAAU,CAAC,UAAU,CAAC,CAAC;QACvB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,MAAM,MAAM,GAAG,WAAW,CACxB,CAAC,KAAa,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;QAC5E,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAChE,CAAC;YAAC,MAAM,CAAC;gBACP,iCAAiC;YACnC,CAAC;QACH,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,IAAI,CAAC,UAAqC;IACjD,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speles7172/controls",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Reusable React building blocks — a data table, searchable selects, a date range filter with a Gregorian and Hebrew calendar, a modal, badges and the loading and empty states — over static options or a transport you supply.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"prepublishOnly": "npm run build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@speles7172/controls-client": "^0.3.
|
|
36
|
+
"@speles7172/controls-client": "^0.3.1",
|
|
37
37
|
"lucide-react": "^1.33.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|