@fibrae/semi-foundation 0.6.0 → 0.8.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 (124) hide show
  1. package/dist/base/index.d.ts +2 -1
  2. package/dist/base/index.js +2 -1
  3. package/dist/base/overlay-session.d.ts +16 -0
  4. package/dist/base/overlay-session.js +36 -0
  5. package/dist/components/audio-player/foundation.js +1 -1
  6. package/dist/components/auto-complete/constants.d.ts +3 -1
  7. package/dist/components/auto-complete/foundation.d.ts +1 -1
  8. package/dist/components/auto-complete/foundation.js +15 -16
  9. package/dist/components/badge/constants.d.ts +3 -1
  10. package/dist/components/button/constants.d.ts +3 -1
  11. package/dist/components/card/constants.d.ts +3 -1
  12. package/dist/components/cascader/constants.d.ts +2 -0
  13. package/dist/components/cascader/foundation.d.ts +2 -4
  14. package/dist/components/cascader/foundation.js +4 -1
  15. package/dist/components/color-picker/foundation.d.ts +2 -0
  16. package/dist/components/color-picker/foundation.js +5 -0
  17. package/dist/components/cropper/constants.d.ts +2 -0
  18. package/dist/components/date-picker/_utils/index.d.ts +1 -2
  19. package/dist/components/date-picker/_utils/index.js +1 -2
  20. package/dist/components/date-picker/_utils/is-timestamp.js +1 -1
  21. package/dist/components/date-picker/_utils/parse-value.js +1 -1
  22. package/dist/components/date-picker/_utils/picker-type.js +1 -1
  23. package/dist/components/date-picker/constants.d.ts +2 -0
  24. package/dist/components/date-picker/foundation.d.ts +3 -4
  25. package/dist/components/date-picker/foundation.js +8 -3
  26. package/dist/components/date-picker/input-foundation.d.ts +1 -0
  27. package/dist/components/date-picker/input-foundation.js +1 -1
  28. package/dist/components/date-picker/month-foundation.d.ts +1 -1
  29. package/dist/components/date-picker/month-foundation.js +1 -0
  30. package/dist/components/date-picker/months-grid-foundation.d.ts +1 -1
  31. package/dist/components/date-picker/months-grid-foundation.js +1 -1
  32. package/dist/components/descriptions/constants.d.ts +3 -1
  33. package/dist/components/dropdown/constants.d.ts +2 -0
  34. package/dist/components/dropdown/menu-foundation.d.ts +1 -1
  35. package/dist/components/empty/constants.d.ts +3 -1
  36. package/dist/components/feedback/constants.d.ts +3 -1
  37. package/dist/components/form/form.css +47 -2
  38. package/dist/components/form/form.scss +44 -2
  39. package/dist/components/form/foundation.d.ts +2 -1
  40. package/dist/components/form/foundation.js +63 -3
  41. package/dist/components/form/interface.d.ts +9 -1
  42. package/dist/components/form/json-schema.d.ts +35 -2
  43. package/dist/components/form/json-schema.js +75 -8
  44. package/dist/components/form/variables.scss +4 -0
  45. package/dist/components/highlight/constants.d.ts +3 -1
  46. package/dist/components/image/constants.d.ts +5 -1
  47. package/dist/components/image/preview-inner-foundation.js +6 -15
  48. package/dist/components/input/constants.d.ts +5 -1
  49. package/dist/components/input-number/constants.d.ts +3 -1
  50. package/dist/components/modal/constants.d.ts +3 -1
  51. package/dist/components/modal/modal-content-foundation.d.ts +3 -3
  52. package/dist/components/modal/modal-content-foundation.js +5 -3
  53. package/dist/components/modal/modal-foundation.d.ts +0 -2
  54. package/dist/components/modal/modal-foundation.js +6 -16
  55. package/dist/components/navigation/constants.d.ts +4 -0
  56. package/dist/components/overflow-list/constants.d.ts +2 -0
  57. package/dist/components/pagination/foundation.d.ts +1 -1
  58. package/dist/components/popconfirm/constants.d.ts +3 -1
  59. package/dist/components/popover/constants.d.ts +2 -0
  60. package/dist/components/radio/constants.d.ts +3 -1
  61. package/dist/components/scroll-list/item-foundation.js +1 -0
  62. package/dist/components/select/constants.d.ts +2 -0
  63. package/dist/components/select/foundation.d.ts +0 -3
  64. package/dist/components/select/foundation.js +31 -56
  65. package/dist/components/select/select.css +3 -3
  66. package/dist/components/select/select.scss +8 -3
  67. package/dist/components/side-sheet/constants.d.ts +2 -0
  68. package/dist/components/side-sheet/side-sheet-foundation.d.ts +6 -4
  69. package/dist/components/side-sheet/side-sheet-foundation.js +33 -23
  70. package/dist/components/slider/constants.d.ts +3 -1
  71. package/dist/components/slider/foundation.d.ts +6 -6
  72. package/dist/components/slider/foundation.js +9 -6
  73. package/dist/components/spin/constants.d.ts +3 -1
  74. package/dist/components/table/constants.d.ts +2 -0
  75. package/dist/components/table/foundation.d.ts +8 -0
  76. package/dist/components/table/foundation.js +12 -0
  77. package/dist/components/table/rtl.scss +5 -0
  78. package/dist/components/table/table.css +123 -0
  79. package/dist/components/table/table.scss +174 -0
  80. package/dist/components/tabs/constants.d.ts +2 -0
  81. package/dist/components/tabs/foundation.js +19 -60
  82. package/dist/components/time-picker/combobox-options.js +1 -1
  83. package/dist/components/time-picker/constants.d.ts +2 -0
  84. package/dist/components/time-picker/foundation.d.ts +3 -1
  85. package/dist/components/time-picker/foundation.js +7 -1
  86. package/dist/components/toast/toast.css +1 -1
  87. package/dist/components/toast/toast.scss +2 -1
  88. package/dist/components/tooltip/constants.d.ts +2 -0
  89. package/dist/components/tooltip/foundation.d.ts +13 -15
  90. package/dist/components/tooltip/foundation.js +54 -15
  91. package/dist/components/tooltip/tooltip.css +1 -1
  92. package/dist/components/tooltip/tooltip.scss +4 -2
  93. package/dist/components/tree/constants.d.ts +2 -0
  94. package/dist/components/tree/foundation.d.ts +17 -3
  95. package/dist/components/tree/foundation.js +37 -2
  96. package/dist/components/tree/shared.d.ts +37 -0
  97. package/dist/components/tree/shared.js +42 -1
  98. package/dist/components/tree-select/constants.d.ts +2 -0
  99. package/dist/components/tree-select/foundation.d.ts +15 -10
  100. package/dist/components/tree-select/foundation.js +44 -7
  101. package/dist/components/upload/constants.d.ts +3 -1
  102. package/dist/components/upload/utils.d.ts +5 -0
  103. package/dist/components/upload/utils.js +8 -2
  104. package/dist/components/video-player/foundation.js +1 -1
  105. package/dist/components/video-player/utils.d.ts +0 -2
  106. package/dist/components/video-player/utils.js +1 -14
  107. package/dist/locale/interface.d.ts +6 -0
  108. package/dist/locale/source/en_US.js +4 -1
  109. package/dist/locale/source/zh_CN.js +4 -1
  110. package/dist/utils/a11y.d.ts +9 -0
  111. package/dist/utils/a11y.js +19 -1
  112. package/dist/utils/date-fns-extra.d.ts +1 -0
  113. package/dist/utils/date-fns-extra.js +4 -1
  114. package/dist/utils/index.d.ts +4 -3
  115. package/dist/utils/index.js +4 -3
  116. package/dist/utils/media.d.ts +2 -0
  117. package/dist/utils/media.js +15 -0
  118. package/dist/utils/scroll-lock.d.ts +4 -3
  119. package/dist/utils/scroll-lock.js +15 -11
  120. package/dist/utils/supports.d.ts +2 -0
  121. package/dist/utils/supports.js +7 -1
  122. package/package.json +2 -2
  123. package/dist/components/date-picker/_utils/is-valid-date.d.ts +0 -1
  124. package/dist/components/date-picker/_utils/is-valid-date.js +0 -5
@@ -73,6 +73,14 @@
73
73
  .semi-table-container {
74
74
  position: relative;
75
75
  }
76
+ @supports (timeline-scope: --semi-table-body-x) {
77
+ .semi-table-container {
78
+ timeline-scope: --semi-table-body-x;
79
+ }
80
+ .semi-table-container > .semi-table-body {
81
+ scroll-timeline: --semi-table-body-x x;
82
+ }
83
+ }
76
84
  .semi-table-header {
77
85
  container-name: semi-table-scroll;
78
86
  container-type: scroll-state;
@@ -96,6 +104,41 @@
96
104
  .semi-table-header-sticky .semi-table-thead > .semi-table-row > .semi-table-row-head {
97
105
  background-color: var(--semi-color-bg-1);
98
106
  }
107
+ @supports (timeline-scope: --semi-table-body-x) {
108
+ .semi-table-header-sticky {
109
+ container-type: normal;
110
+ }
111
+ .semi-table-header-sticky > .semi-table {
112
+ animation: semi-table-header-follow linear both;
113
+ animation-timeline: --semi-table-body-x;
114
+ }
115
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-left, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right {
116
+ animation: semi-table-header-pin linear both;
117
+ animation-timeline: --semi-table-body-x;
118
+ }
119
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-left-last::after, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right-first::after {
120
+ animation: semi-table-header-edge-start linear both;
121
+ animation-timeline: --semi-table-body-x;
122
+ }
123
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right-first::after, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:dir(rtl) > .semi-table-cell-fixed-left-last::after {
124
+ animation-name: semi-table-header-edge-end;
125
+ }
126
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:dir(rtl) > .semi-table-cell-fixed-right-first::after {
127
+ animation-name: semi-table-header-edge-start;
128
+ }
129
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)) > .semi-table-cell-fixed-left-last {
130
+ animation-name: semi-table-header-pin, semi-table-header-line-left-start;
131
+ }
132
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)) > .semi-table-cell-fixed-right-first {
133
+ animation-name: semi-table-header-pin, semi-table-header-line-right-end;
134
+ }
135
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)):dir(rtl) > .semi-table-cell-fixed-left-last {
136
+ animation-name: semi-table-header-pin, semi-table-header-line-left-end;
137
+ }
138
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)):dir(rtl) > .semi-table-cell-fixed-right-first {
139
+ animation-name: semi-table-header-pin, semi-table-header-line-right-start;
140
+ }
141
+ }
99
142
  .semi-table-header-hidden {
100
143
  height: 0;
101
144
  }
@@ -131,6 +174,18 @@
131
174
  outline: 2px solid var(--semi-color-primary-light-active);
132
175
  outline-offset: -2px;
133
176
  }
177
+ .semi-table-fixed-header > .semi-table-container > .semi-table-body > .semi-table > .semi-table-thead {
178
+ position: sticky;
179
+ top: 0;
180
+ z-index: 102;
181
+ }
182
+ .semi-table-list-header {
183
+ position: sticky;
184
+ top: 0;
185
+ z-index: 102;
186
+ inline-size: fit-content;
187
+ min-inline-size: 100%;
188
+ }
134
189
  .semi-table-row:focus-visible {
135
190
  outline: 2px solid var(--semi-color-primary-light-active);
136
191
  outline-offset: -2px;
@@ -449,6 +504,12 @@
449
504
  :where(.semi-table-bordered) > .semi-table-container > .semi-table-footer {
450
505
  border-bottom: 1px solid var(--semi-color-border);
451
506
  }
507
+ :where(.semi-table-bordered > .semi-table-container > .semi-table-body) {
508
+ border-bottom: 1px solid var(--semi-color-border);
509
+ }
510
+ :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table > .semi-table-tbody > :last-child > .semi-table-row-cell, :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table-placeholder {
511
+ border-bottom: 0;
512
+ }
452
513
  :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-row-head .semi-table-resize-handle {
453
514
  background-color: transparent;
454
515
  }
@@ -609,6 +670,64 @@
609
670
  overflow-y: auto;
610
671
  }
611
672
 
673
+ @keyframes semi-table-header-follow {
674
+ to {
675
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1)) 0;
676
+ }
677
+ }
678
+ @keyframes semi-table-header-pin {
679
+ to {
680
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1) * -1) 0;
681
+ }
682
+ }
683
+ @keyframes semi-table-header-edge-start {
684
+ from {
685
+ opacity: 0;
686
+ }
687
+ 0.01%, to {
688
+ opacity: 1;
689
+ }
690
+ }
691
+ @keyframes semi-table-header-edge-end {
692
+ from, 99.99% {
693
+ opacity: 1;
694
+ }
695
+ to {
696
+ opacity: 0;
697
+ }
698
+ }
699
+ @keyframes semi-table-header-line-left-start {
700
+ from {
701
+ border-right-color: transparent;
702
+ }
703
+ 0.01%, to {
704
+ border-right-color: var(--semi-color-border);
705
+ }
706
+ }
707
+ @keyframes semi-table-header-line-left-end {
708
+ from, 99.99% {
709
+ border-right-color: var(--semi-color-border);
710
+ }
711
+ to {
712
+ border-right-color: transparent;
713
+ }
714
+ }
715
+ @keyframes semi-table-header-line-right-start {
716
+ from {
717
+ border-left-color: transparent;
718
+ }
719
+ 0.01%, to {
720
+ border-left-color: var(--semi-color-border);
721
+ }
722
+ }
723
+ @keyframes semi-table-header-line-right-end {
724
+ from, 99.99% {
725
+ border-left-color: var(--semi-color-border);
726
+ }
727
+ to {
728
+ border-left-color: transparent;
729
+ }
730
+ }
612
731
  .semi-table-column-filter-footer {
613
732
  display: flex;
614
733
  justify-content: flex-end;
@@ -617,6 +736,10 @@
617
736
  border-block-start: 1px solid var(--semi-color-border);
618
737
  }
619
738
 
739
+ .semi-table-container:dir(rtl) {
740
+ --semi-table-scroll-sign: 1;
741
+ }
742
+
620
743
  .semi-table-align-left:dir(rtl) .semi-table-operate-wrapper {
621
744
  justify-content: flex-end;
622
745
  }
@@ -56,6 +56,15 @@ $module: #{$prefix}-table;
56
56
 
57
57
  &-container {
58
58
  position: relative;
59
+
60
+ // scoped here so the sticky header, a sibling of the body, can follow the body's timeline
61
+ @supports (timeline-scope: --semi-table-body-x) {
62
+ timeline-scope: --semi-table-body-x;
63
+
64
+ & > .#{$module}-body {
65
+ scroll-timeline: --semi-table-body-x x;
66
+ }
67
+ }
59
68
  }
60
69
 
61
70
  &-header {
@@ -85,6 +94,63 @@ $module: #{$prefix}-table;
85
94
  .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
86
95
  background-color: $color-table-bg-default;
87
96
  }
97
+
98
+ // The header stuck to the page sits outside the body's scroller. A scroll-driven animation on the body's
99
+ // timeline shifts it, and holds its fixed cells in place, in the frame the compositor scrolls the body; the
100
+ // foundation writes the range. Elsewhere the host copies scrollLeft a frame late. Removable together with
101
+ // the foundation's headerFollowsInCss.
102
+ @supports (timeline-scope: --semi-table-body-x) {
103
+ // the header never scrolls itself, so its scroll state says nothing; the edges follow the body's timeline
104
+ container-type: normal;
105
+
106
+ & > .#{$module} {
107
+ animation: #{$module}-header-follow linear both;
108
+ animation-timeline: --semi-table-body-x;
109
+
110
+ & > .#{$module}-thead > .#{$module}-row {
111
+ & > .#{$module}-cell-fixed-left,
112
+ & > .#{$module}-cell-fixed-right {
113
+ animation: #{$module}-header-pin linear both;
114
+ animation-timeline: --semi-table-body-x;
115
+ }
116
+
117
+ & > .#{$module}-cell-fixed-left-last::after,
118
+ & > .#{$module}-cell-fixed-right-first::after {
119
+ animation: #{$module}-header-edge-start linear both;
120
+ animation-timeline: --semi-table-body-x;
121
+ }
122
+
123
+ // physical sides like the shadows: in RTL the body scrolls from its right end
124
+ & > .#{$module}-cell-fixed-right-first::after,
125
+ &:dir(rtl) > .#{$module}-cell-fixed-left-last::after {
126
+ animation-name: #{$module}-header-edge-end;
127
+ }
128
+
129
+ &:dir(rtl) > .#{$module}-cell-fixed-right-first::after {
130
+ animation-name: #{$module}-header-edge-start;
131
+ }
132
+
133
+ // without `bordered` the edge lines show only with the shadows
134
+ &:where(:not(.#{$module}-bordered *)) {
135
+ & > .#{$module}-cell-fixed-left-last {
136
+ animation-name: #{$module}-header-pin, #{$module}-header-line-left-start;
137
+ }
138
+
139
+ & > .#{$module}-cell-fixed-right-first {
140
+ animation-name: #{$module}-header-pin, #{$module}-header-line-right-end;
141
+ }
142
+
143
+ &:dir(rtl) > .#{$module}-cell-fixed-left-last {
144
+ animation-name: #{$module}-header-pin, #{$module}-header-line-left-end;
145
+ }
146
+
147
+ &:dir(rtl) > .#{$module}-cell-fixed-right-first {
148
+ animation-name: #{$module}-header-pin, #{$module}-header-line-right-start;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
88
154
  }
89
155
 
90
156
  &-hidden {
@@ -133,6 +199,23 @@ $module: #{$prefix}-table;
133
199
  &:focus-visible {
134
200
  @include focus-ring(-2px);
135
201
  }
202
+
203
+ // scroll.y keeps the header in the body's scroller, so the compositor moves both in the same frame; above the
204
+ // fixed body cells, and the fixed head cells inside stack above the other head cells
205
+ .#{$module}-fixed-header > .#{$module}-container > & > .#{$module} > .#{$module}-thead {
206
+ position: sticky;
207
+ top: 0;
208
+ z-index: $z-table_fixed_column + 1;
209
+ }
210
+ }
211
+
212
+ // the virtual list's header, in the list's scroller above the rows
213
+ &-list-header {
214
+ position: sticky;
215
+ top: 0;
216
+ z-index: $z-table_fixed_column + 1;
217
+ inline-size: fit-content;
218
+ min-inline-size: 100%;
136
219
  }
137
220
 
138
221
  // the scrolling body would clip an outside ring on a row focusable for drag sorting
@@ -552,7 +635,16 @@ $module: #{$prefix}-table;
552
635
  }
553
636
  }
554
637
 
638
+ // the container's side borders run down past a horizontal scrollbar; the body's bottom border closes the box
639
+ // below it, so the last row and the empty placeholder drop their own
555
640
  :where(& > .#{$module}-container > .#{$module}-body) {
641
+ border-bottom: $width-table_base_border $border-table_base-borderStyle $color-table-border-default;
642
+
643
+ & > .#{$module} > .#{$module}-tbody > :last-child > .#{$module}-row-cell,
644
+ & > .#{$module}-placeholder {
645
+ border-bottom: 0;
646
+ }
647
+
556
648
  & > .#{$module} > .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
557
649
  .#{$module}-resize-handle {
558
650
  background-color: transparent;
@@ -778,6 +870,88 @@ $module: #{$prefix}-table;
778
870
  }
779
871
  }
780
872
 
873
+ // the sticky header's table moves against the body's scroll, and its fixed cells move back by as much
874
+ @keyframes #{$module}-header-follow {
875
+ to {
876
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1)) 0;
877
+ }
878
+ }
879
+
880
+ @keyframes #{$module}-header-pin {
881
+ to {
882
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1) * -1) 0;
883
+ }
884
+ }
885
+
886
+ // a fixed edge shows while content hides behind it: past the scroll start, or short of the end
887
+ @keyframes #{$module}-header-edge-start {
888
+ from {
889
+ opacity: 0;
890
+ }
891
+
892
+ 0.01%,
893
+ to {
894
+ opacity: 1;
895
+ }
896
+ }
897
+
898
+ @keyframes #{$module}-header-edge-end {
899
+ from,
900
+ 99.99% {
901
+ opacity: 1;
902
+ }
903
+
904
+ to {
905
+ opacity: 0;
906
+ }
907
+ }
908
+
909
+ // stylelint-disable property-disallowed-list -- physical sides like the fixed-cell class names
910
+ @keyframes #{$module}-header-line-left-start {
911
+ from {
912
+ border-right-color: transparent;
913
+ }
914
+
915
+ 0.01%,
916
+ to {
917
+ border-right-color: $color-table_shadow-border-default;
918
+ }
919
+ }
920
+
921
+ @keyframes #{$module}-header-line-left-end {
922
+ from,
923
+ 99.99% {
924
+ border-right-color: $color-table_shadow-border-default;
925
+ }
926
+
927
+ to {
928
+ border-right-color: transparent;
929
+ }
930
+ }
931
+
932
+ @keyframes #{$module}-header-line-right-start {
933
+ from {
934
+ border-left-color: transparent;
935
+ }
936
+
937
+ 0.01%,
938
+ to {
939
+ border-left-color: $color-table_shadow-border-default;
940
+ }
941
+ }
942
+
943
+ @keyframes #{$module}-header-line-right-end {
944
+ from,
945
+ 99.99% {
946
+ border-left-color: $color-table_shadow-border-default;
947
+ }
948
+
949
+ to {
950
+ border-left-color: transparent;
951
+ }
952
+ }
953
+ // stylelint-enable property-disallowed-list
954
+
781
955
  .#{$module}-column-filter-footer {
782
956
  display: flex;
783
957
  justify-content: flex-end;
@@ -1,3 +1,5 @@
1
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
2
+ export type TabsPart = 'tabBar' | 'content' | 'visibleTabs';
1
3
  export declare const cssClasses: {
2
4
  TABS: string;
3
5
  TABS_BAR: string;
@@ -1,4 +1,5 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
+ import { getListTargetIndex, handlePrevent } from "../../utils/a11y.js";
2
3
  import { TAB_DATA_KEY_PREFIX, TAB_KEY_ATTRIBUTE, cssClasses } from "./constants.js";
3
4
  import { isEqual } from "es-toolkit";
4
5
  // src/components/tabs/foundation.ts
@@ -8,49 +9,15 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
8
9
  const { activeKey: stateActiveKey } = this.getStates();
9
10
  if (stateActiveKey !== activeKey) this.adapter.notifyChange(activeKey);
10
11
  }
11
- #handlePrevent(event) {
12
- event.stopPropagation();
13
- event.preventDefault();
14
- }
15
- #handleArrowKey(event, tab, allTabs) {
16
- const { tabPosition } = this.getProps();
17
- if (tabPosition === "left") {
18
- if (event.key === "ArrowUp" || event.key === "ArrowDown") {
19
- this.#switchTabOnArrowPress(event.key, tab, allTabs);
20
- this.#handlePrevent(event);
21
- }
22
- } else if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
23
- this.#switchTabOnArrowPress(event.key, tab, allTabs);
24
- this.#handlePrevent(event);
25
- }
26
- }
27
12
  #handleDeleteKeyDown(event, tab, tabs, itemKey, closable) {
28
13
  const { preventScroll } = this.getProps();
29
14
  if (closable && tab.getAttribute("aria-disabled") !== "true") {
30
- this.#handlePrevent(event);
15
+ handlePrevent(event);
31
16
  this.handleTabDelete(itemKey);
32
17
  const index = tabs.indexOf(tab);
33
18
  if (tabs.length !== 1) tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus({ preventScroll });
34
19
  }
35
20
  }
36
- #switchTabOnArrowPress(key, tab, allTabs) {
37
- const { preventScroll } = this.getProps();
38
- const rtl = this.adapter.getContext("direction") === "rtl";
39
- const step = {
40
- ArrowLeft: rtl ? 1 : -1,
41
- ArrowUp: -1,
42
- ArrowRight: rtl ? -1 : 1,
43
- ArrowDown: 1
44
- }[key];
45
- const start = allTabs.indexOf(tab);
46
- for (let offset = 1; offset < allTabs.length; offset++) {
47
- const candidate = allTabs[(start + step * offset + allTabs.length) % allTabs.length];
48
- if (candidate.getAttribute("aria-disabled") !== "true") {
49
- candidate.focus({ preventScroll });
50
- return;
51
- }
52
- }
53
- }
54
21
  handleNewActiveKey(activeKey) {
55
22
  const { activeKey: stateActiveKey } = this.getStates();
56
23
  if (stateActiveKey !== activeKey) this.setState({ activeKey });
@@ -129,33 +96,25 @@ var TabsFoundation = class TabsFoundation extends BaseFoundation {
129
96
  if (event.altKey || event.ctrlKey || event.metaKey) return;
130
97
  const tab = event.currentTarget;
131
98
  if (!(tab instanceof HTMLElement) || event.target !== tab) return;
132
- const { preventScroll } = this.getProps();
99
+ const { preventScroll, tabPosition } = this.getProps();
133
100
  const allTabs = [...tab.closest("[role=\"tablist\"]").querySelectorAll(`[${TAB_KEY_ATTRIBUTE}^="${TAB_DATA_KEY_PREFIX}"]`)];
134
- const tabs = allTabs.filter((item) => item.getAttribute("aria-disabled") !== "true");
135
- switch (event.key) {
136
- case "ArrowLeft":
137
- case "ArrowRight":
138
- case "ArrowUp":
139
- case "ArrowDown":
140
- this.#handleArrowKey(event, tab, allTabs);
141
- break;
142
- case "Backspace":
143
- case "Delete":
144
- this.#handleDeleteKeyDown(event, tab, tabs, itemKey, closable);
145
- break;
146
- case "Enter":
147
- case " ":
148
- if (tab.getAttribute("aria-disabled") === "true") break;
101
+ const isDisabled = (item) => item.getAttribute("aria-disabled") === "true";
102
+ if (event.key === "Backspace" || event.key === "Delete") this.#handleDeleteKeyDown(event, tab, allTabs.filter((item) => !isDisabled(item)), itemKey, closable);
103
+ else if (event.key === "Enter" || event.key === " ") {
104
+ if (!isDisabled(tab)) {
149
105
  this.handleTabClick(itemKey, event);
150
- this.#handlePrevent(event);
151
- break;
152
- case "Home":
153
- tabs[0]?.focus({ preventScroll });
154
- this.#handlePrevent(event);
155
- break;
156
- case "End":
157
- tabs.at(-1)?.focus({ preventScroll });
158
- this.#handlePrevent(event);
106
+ handlePrevent(event);
107
+ }
108
+ } else {
109
+ const target = getListTargetIndex(event.key, allTabs.indexOf(tab), allTabs.length, (index) => isDisabled(allTabs[index]), {
110
+ loop: true,
111
+ orientation: tabPosition === "left" ? "vertical" : "horizontal",
112
+ rtl: this.adapter.getContext("direction") === "rtl"
113
+ });
114
+ if (target !== null) {
115
+ allTabs[target].focus({ preventScroll });
116
+ handlePrevent(event);
117
+ }
159
118
  }
160
119
  };
161
120
  };
@@ -1,4 +1,4 @@
1
- import isValidDate from "../date-picker/_utils/is-valid-date.js";
1
+ import { isValidDate } from "../../utils/date-fns-extra.js";
2
2
  import { strings } from "./constants.js";
3
3
  // src/components/time-picker/combobox-options.ts
4
4
  function formatOption(option, disabledOptions) {
@@ -1,4 +1,6 @@
1
1
  export type PanelType = 'left' | 'right';
2
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
3
+ export type TimePickerPart = 'dropdown' | 'input';
2
4
  export declare const cssClasses: {
3
5
  PREFIX: string;
4
6
  RANGE_PICKER: string;
@@ -87,7 +87,7 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
87
87
  blur: () => void;
88
88
  handleFocus: (e: E) => void;
89
89
  /** A custom trigger without a focus target of its own is a button: Enter, Space and Down Arrow open the panel */
90
- handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault">) => void;
90
+ handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault"> & Partial<Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">>) => void;
91
91
  /** Closes the panel and reports openChange(false), without blur and without moving focus */
92
92
  close: () => void;
93
93
  /**
@@ -99,6 +99,8 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
99
99
  handlePanelOpen: () => void;
100
100
  /** Called for a mousedown outside the trigger and the panel while the panel is shown */
101
101
  handleClickOutside: (e: MouseEvent) => void;
102
+ /** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
103
+ handleDocumentFocusIn: (e: Pick<FocusEvent, "composedPath">, root?: Node | null) => void;
102
104
  handleInputChange: (input: string) => void;
103
105
  handleInputBlur: () => void;
104
106
  }
@@ -1,5 +1,7 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
2
  import { zonedTimeToUtc } from "../../utils/date-fns-extra.js";
3
+ import { containsWithPopups } from "../../utils/layer.js";
4
+ import { isBrowserChord } from "../../utils/a11y.js";
3
5
  import isValidTimeZone from "../../utils/is-valid-time-zone.js";
4
6
  import { fromWallTime, parseReference, toWallTime } from "../../utils/zoned-time.js";
5
7
  import { getColumns } from "./combobox-options.js";
@@ -217,7 +219,7 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
217
219
  };
218
220
  /** A custom trigger without a focus target of its own is a button: Enter, Space and Down Arrow open the panel */
219
221
  handleTriggerKeyDown = (e) => {
220
- if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
222
+ if (!isBrowserChord(e) && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
221
223
  e.preventDefault();
222
224
  this.handlePanelOpen();
223
225
  }
@@ -246,6 +248,10 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
246
248
  this.close();
247
249
  this.adapter.notifyBlur(e);
248
250
  };
251
+ /** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
252
+ handleDocumentFocusIn = (e, root) => {
253
+ if (root && !containsWithPopups(root, e.composedPath()[0]) && TimePickerFoundation.isPanelShown(this.getProps(), this.getStates())) this.close();
254
+ };
249
255
  handleInputChange = (input) => {
250
256
  this.setState({ inputValue: input });
251
257
  const rangeSeparator = this.getProp("rangeSeparator");
@@ -61,7 +61,7 @@
61
61
  justify-content: center;
62
62
  padding-block: 12px 12px;
63
63
  padding-inline: 8px 8px;
64
- margin: 12px;
64
+ margin: 12px 12px 0;
65
65
  font-weight: var(--semi-font-weight-bold);
66
66
  color: var(--semi-color-text-0);
67
67
  pointer-events: all;
@@ -86,7 +86,8 @@ $icon: #{$prefix}-toast-icon;
86
86
  justify-content: center;
87
87
  padding-block: $spacing-toast_content-paddingTop $spacing-toast_content-paddingBottom;
88
88
  padding-inline: $spacing-toast_content-paddingLeft $spacing-toast_content-paddingRight;
89
- margin: $spacing-toast_content-margin;
89
+ // no bottom margin: the gap between stacked toasts equals the first toast's distance from the top
90
+ margin: $spacing-toast_content-margin $spacing-toast_content-margin 0;
90
91
  font-weight: $font-toast_content-fontWeight;
91
92
  color: $color-toast-text-default;
92
93
  pointer-events: all;
@@ -1,6 +1,8 @@
1
1
  export declare const cssClasses: {
2
2
  readonly PREFIX: "semi-tooltip";
3
3
  };
4
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
5
+ export type TooltipPart = 'wrapper';
4
6
  export declare const strings: {
5
7
  readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver", "leftBottomOver", "rightBottomOver"];
6
8
  readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom", "contextMenu"];
@@ -9,25 +9,19 @@ export interface TooltipAdapter<P extends TooltipBaseProps = TooltipBaseProps> e
9
9
  insertPortal(): Pick<TooltipBaseState, 'portalTarget' | 'colorScheme'>;
10
10
  /** Drops what the host renders into the popup itself (its content), right before the foundation unmounts the popup */
11
11
  removePortal(): void;
12
- /** Shows the popup in the top layer, unless it is still open (reopened during its exit animation) */
13
- showPopover(): void;
14
- hidePopover(): void;
15
- /**
16
- * Settles once the popup's running animations finish or are cancelled, read when called; null when none runs, so
17
- * the step finishes at once
18
- */
19
- waitAnimations(): Promise<unknown> | null;
20
12
  /** Once per opening, after the enter animation; not for an opening closed before it finishes */
21
13
  notifyAfterOpen(): void;
22
14
  /** Once per opening, after the popup left or when the component unmounts while it is shown */
23
15
  notifyAfterClose(): void;
24
- /** Binds `handler` to every mousedown in the window until `unregisterClickOutsideHandler` */
25
- registerClickOutsideHandler(handler: (e: MouseEvent) => void): void;
26
- unregisterClickOutsideHandler(): void;
27
16
  isEventInTrigger(e: MouseEvent): boolean;
28
- /** Whether the press went through the popup, or through a popup opened from its content */
29
- isEventInPopup(e: MouseEvent): boolean;
17
+ /**
18
+ * The popups of Tooltips rendered in this one's trigger or content: portaled out of its DOM, they still count as
19
+ * inside for the press outside check. Empty where the framework's own event path covers them (React).
20
+ */
21
+ getNestedPopups(): (HTMLElement | null | undefined)[];
30
22
  notifyClickOutSide(e: MouseEvent): void;
23
+ /** Runs `fn`, the foundation's own window listener, as one update: the onVisibleChange it reports lands before the DOM updates (Solid) */
24
+ batch(fn: () => void): void;
31
25
  getPortalContainer(): HTMLElement | null;
32
26
  setInitialFocus(): void;
33
27
  /** The popup is shown and its enter transition has started; once per opening */
@@ -93,9 +87,11 @@ export default class Tooltip<P extends TooltipBaseProps = TooltipBaseProps> exte
93
87
  * Hosts call this after every commit that changes `isInsert`, `transitionState` or the popup element, and again
94
88
  * when a hidden popup shows again (Activity, KeepAlive), with the popup in the document. Entering shows the
95
89
  * popover, positions it, checks a hover opening a task later and reports afterOpen once the enter animation ends;
96
- * leaving waits for the exit animation, hides the popover, unmounts it unless keepDOM and reports afterClose.
90
+ * leaving releases the Escape layer at once, waits for the exit animation, hides the popover, unmounts it unless
91
+ * keepDOM and reports afterClose. The animations are read once `beforeRead` settles when a host passes one: the
92
+ * phase's DOM is not there yet (Svelte), or what follows must not run inside the closing event (Solid).
97
93
  */
98
- syncPopup: () => void;
94
+ syncPopup: (beforeRead?: Promise<unknown>) => void;
99
95
  /** Hosts call this when the component unmounts for good, not when it is only hidden: reports a close still owed */
100
96
  handleUnmount: () => void;
101
97
  delayShow(): void;
@@ -104,6 +100,8 @@ export default class Tooltip<P extends TooltipBaseProps = TooltipBaseProps> exte
104
100
  calcPosition: () => void;
105
101
  delayHide(): void;
106
102
  hide: () => void;
103
+ /** Hosts call this from a capture-phase mousedown on the popup content: a press bound for a nested popup portaled out of this DOM */
104
+ markPressInside: (e: Event) => void;
107
105
  /**
108
106
  * Escape that reaches the popup through the overlay stack (utils/layer) while it is the top layer, wherever the
109
107
  * focus is. Returns whether the popup took the key; one that does not leaves it to the layer below.