@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
@@ -1,6 +1,10 @@
1
1
  export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  };
4
+ /** Keys of `classNames` and `styles` of Nav; the root element takes `className` and `style` */
5
+ export type NavPart = 'body';
6
+ /** Keys of `classNames` and `styles` of SubNav; the root element takes `className` and `style` */
7
+ export type SubNavPart = 'dropdown';
4
8
  export declare const strings: {
5
9
  MODE_VERTICAL: string;
6
10
  MODE_HORIZONTAL: string;
@@ -3,6 +3,8 @@ export declare const cssClasses: {
3
3
  /** The element that holds the items in scroll mode, which scrolls instead of the list root */
4
4
  SCROLL_WRAPPER: string;
5
5
  };
6
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
7
+ export type OverflowListPart = 'wrapper';
6
8
  /** Attribute on the first element of each scroll-mode item that carries the item's key: the observer and Tabs find items by it */
7
9
  export declare const SCROLL_KEY_ATTRIBUTE = "data-scrollkey";
8
10
  export declare const strings: {
@@ -53,7 +53,7 @@ export default class PaginationFoundation<P extends PaginationBaseProps = Pagina
53
53
  sizeChangerShown: boolean;
54
54
  hidden: boolean;
55
55
  quickJumpDisabled: boolean;
56
- switchPosition: "bottomLeft" | "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
56
+ switchPosition: "bottom" | "top" | "left" | "right" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
57
57
  };
58
58
  static getDisabled(currentPage: number, total: number, pageSize: number): {
59
59
  prevDisabled: boolean;
@@ -1,4 +1,6 @@
1
1
  export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  POPOVER: string;
4
- };
4
+ };
5
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
6
+ export type PopconfirmPart = 'content' | 'arrow';
@@ -2,6 +2,8 @@ export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  ARROW: string;
4
4
  };
5
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
6
+ export type PopoverPart = 'content' | 'arrow';
5
7
  export declare const strings: {
6
8
  readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
7
9
  readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom", "contextMenu"];
@@ -13,4 +13,6 @@ export declare const strings: {
13
13
  readonly TYPE_CARD: "card";
14
14
  readonly TYPE_PURECARD: "pureCard";
15
15
  readonly BUTTON_SIZE: readonly ["middle", "small", "large"];
16
- };
16
+ };
17
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
18
+ export type RadioPart = 'addon';
@@ -294,6 +294,7 @@ var ItemFoundation = class ItemFoundation extends BaseFoundation {
294
294
  * APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
295
295
  */
296
296
  handleKeyDown = (event) => {
297
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
297
298
  const { list, selectedIndex, cycled } = this.getProps();
298
299
  let target = getListTargetIndex(event.key, selectedIndex, list.length, (index) => Boolean(list[index].disabled), { loop: cycled });
299
300
  if (target === null && this.#typeahead.accepts(event)) {
@@ -3,6 +3,8 @@ export declare const cssClasses: {
3
3
  PREFIX_OPTION: string;
4
4
  PREFIX_GROUP: string;
5
5
  };
6
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
7
+ export type SelectPart = 'dropdown';
6
8
  export declare const strings: {
7
9
  readonly SIZE_SET: readonly ["small", "large", "default"];
8
10
  readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver", "leftBottomOver", "rightBottomOver"];
@@ -3,8 +3,6 @@ import "../../base/index.js";
3
3
  import { isComposing } from "../../utils/key-code.js";
4
4
  import { BasicOptionProps, OptionRecord } from "./option-foundation.js";
5
5
  import { isEqual } from "es-toolkit";
6
- /** The id of the option at `index`, which `aria-activedescendant` points at and the scroll lookup finds; `listId` is the host's id for the list */
7
- export declare function getOptionId(listId: string, index: number): string;
8
6
  export interface SelectBaseProps {
9
7
  allowCreate?: boolean;
10
8
  autoClearSearchValue?: boolean;
@@ -35,7 +33,6 @@ export interface SelectBaseState {
35
33
  focusIndex: number;
36
34
  inputValue: string;
37
35
  isFocus: boolean;
38
- isFocusInContainer: boolean;
39
36
  isFullTags: boolean;
40
37
  isOpen: boolean;
41
38
  options: OptionRecord[];
@@ -1,6 +1,6 @@
1
1
  import FocusTrapHandle from "../../base/focus-handle.js";
2
2
  import BaseFoundation from "../../base/foundation.js";
3
- import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, handlePrevent, isInnerControlActivation, isInnerControlKey, isTextEditor } from "../../utils/a11y.js";
3
+ import { Typeahead, crossesFocusBoundary, getEnabledStepIndex, getListTargetIndex, getOptionId, handlePrevent, isBrowserChord, isInnerControlActivation, isInnerControlKey, isTextEditor, revealOption } from "../../utils/a11y.js";
4
4
  import { centerInScroller } from "../../utils/dom.js";
5
5
  import Event from "../../utils/event.js";
6
6
  import { ENTER_KEY, isComposing } from "../../utils/key-code.js";
@@ -9,10 +9,6 @@ import warning from "../../utils/warning.js";
9
9
  import { cssClasses, strings } from "./constants.js";
10
10
  import { isEqual } from "es-toolkit";
11
11
  // src/components/select/foundation.ts
12
- /** The id of the option at `index`, which `aria-activedescendant` points at and the scroll lookup finds; `listId` is the host's id for the list */
13
- function getOptionId(listId, index) {
14
- return `${listId}-option-${index}`;
15
- }
16
12
  var SelectFoundation = class SelectFoundation extends BaseFoundation {
17
13
  #blurPending = false;
18
14
  #popupFocusTrigger = null;
@@ -233,8 +229,12 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
233
229
  this.adapter.scrollVirtualTo(index);
234
230
  return;
235
231
  }
236
- const target = index === void 0 ? `.${cssClasses.PREFIX_OPTION}-selected, .${cssClasses.PREFIX_OPTION}-custom-selected` : `#${CSS.escape(getOptionId(this.adapter.getListId(), index))}`;
237
- const destNode = this.adapter.getOptionList()?.querySelector(target);
232
+ const optionList = this.adapter.getOptionList();
233
+ if (index !== void 0) {
234
+ revealOption(optionList, getOptionId(this.adapter.getListId(), index));
235
+ return;
236
+ }
237
+ const destNode = optionList?.querySelector(`.${cssClasses.PREFIX_OPTION}-selected, .${cssClasses.PREFIX_OPTION}-custom-selected`);
238
238
  const listbox = destNode?.closest("[role=\"listbox\"]");
239
239
  if (destNode && listbox) centerInScroller(destNode, listbox);
240
240
  }
@@ -292,40 +292,26 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
292
292
  else this.open();
293
293
  }
294
294
  #handleTabKeyDown(event) {
295
- const { isOpen } = this.getStates();
296
- if (isOpen) {
297
- const focusableElements = FocusTrapHandle.getFocusableElements(this.adapter.getOptionList());
298
- if (focusableElements.length > 0) {
299
- if (event.shiftKey) this.#handlePanelOpenShiftTabKeyDown(focusableElements, event);
300
- else this.#handlePanelOpenTabKeyDown(focusableElements, event);
301
- } else this.close({ event });
302
- }
303
- }
304
- #getActiveElement() {
305
- return FocusTrapHandle.getActiveElement(this.adapter.getOptionList());
306
- }
307
- #handlePanelOpenTabKeyDown(focusableElements, event) {
308
- const activeElement = this.#getActiveElement();
309
- const { isFocusInContainer } = this.getStates();
310
- if (!isFocusInContainer) {
311
- focusableElements[0].focus();
312
- this.setState({ isFocusInContainer: true });
313
- handlePrevent(event);
314
- } else if (activeElement === focusableElements.at(-1)) {
315
- this.#focusTrigger();
316
- this.close({ event });
317
- handlePrevent(event);
318
- }
319
- }
320
- #handlePanelOpenShiftTabKeyDown(focusableElements, event) {
321
- const activeElement = this.#getActiveElement();
322
- const { isFocusInContainer } = this.getStates();
323
- if (!isFocusInContainer) this.close({ event });
324
- else if (activeElement === focusableElements[0]) {
325
- this.#focusTrigger();
326
- this.setState({ isFocusInContainer: false });
327
- handlePrevent(event);
295
+ if (!this.getState("isOpen")) return;
296
+ const optionList = this.adapter.getOptionList();
297
+ if (!optionList?.contains(FocusTrapHandle.getActiveElement(optionList))) {
298
+ this.close({
299
+ event,
300
+ returnFocus: event.shiftKey
301
+ });
302
+ return;
328
303
  }
304
+ handlePrevent(event);
305
+ this.#focusTrigger();
306
+ const trigger = FocusTrapHandle.getActiveElement(optionList);
307
+ const root = trigger?.getRootNode();
308
+ const scopes = root instanceof ShadowRoot ? [...root.children] : [trigger?.ownerDocument.body];
309
+ const next = event.shiftKey || !trigger ? null : scopes.flatMap((scope) => FocusTrapHandle.getFocusableElements(scope)).find((node) => !trigger.contains(node) && !optionList.contains(node) && trigger.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING);
310
+ this.close({
311
+ event,
312
+ returnFocus: false
313
+ });
314
+ next?.focus();
329
315
  }
330
316
  #handleEnterKeyDown(event) {
331
317
  const { isOpen, options, focusIndex } = this.getStates();
@@ -395,7 +381,6 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
395
381
  }
396
382
  }
397
383
  #handleTriggerFocus(e) {
398
- this.setState({ isFocusInContainer: false });
399
384
  this.#notifyFocus(e);
400
385
  }
401
386
  #handleTriggerBlur(e) {
@@ -437,10 +422,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
437
422
  }
438
423
  #focusInput() {
439
424
  this.adapter.focusInput();
440
- this.setState({
441
- isFocus: true,
442
- isFocusInContainer: false
443
- });
425
+ this.setState({ isFocus: true });
444
426
  }
445
427
  #filterByKeyword(options) {
446
428
  const { inputValue } = this.getStates();
@@ -522,7 +504,6 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
522
504
  return {
523
505
  isOpen: false,
524
506
  isFocus: false,
525
- isFocusInContainer: false,
526
507
  isFullTags: false,
527
508
  inputValue: "",
528
509
  showInput: false,
@@ -541,10 +522,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
541
522
  const { isOpen } = this.getStates();
542
523
  const { searchPosition } = this.getProps();
543
524
  const shouldOpenDropdown = openDropdown !== false;
544
- this.setState({
545
- isFocus: true,
546
- isFocusInContainer: false
547
- });
525
+ this.setState({ isFocus: true });
548
526
  if (isFilterable) {
549
527
  /**
550
528
  * openDropdown false only refocuses the Select. With searchPosition='dropdown' the search input lives in
@@ -612,10 +590,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
612
590
  if (!isOpen) return;
613
591
  const { event, closeCb, notToggleInput, returnFocus = true } = closeConfig || {};
614
592
  if (isFocus && returnFocus) this.#focusTrigger();
615
- this.setState({
616
- isOpen: false,
617
- isFocusInContainer: false
618
- });
593
+ this.setState({ isOpen: false });
619
594
  this.adapter.notifyDropdownVisibleChange(false);
620
595
  const isFilterable = this.#isFilterable();
621
596
  if (isFilterable && !notToggleInput) this.#toggle2SearchInput(false);
@@ -683,7 +658,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
683
658
  handleKeyDown = (event) => {
684
659
  const { loading, filter, multiple, disabled, searchPosition } = this.getProps();
685
660
  const { isOpen, showInput } = this.getStates();
686
- if (loading || disabled || isComposing(event) || isInnerControlKey(event)) return;
661
+ if (loading || disabled || isComposing(event) || isInnerControlKey(event) || isBrowserChord(event)) return;
687
662
  if (!(isTextEditor(event.target) || filter && searchPosition === strings.SEARCH_POSITION_TRIGGER && showInput) && this.#handleSelectOnlyKeyDown(event)) return;
688
663
  switch (event.key) {
689
664
  case "ArrowUp":
@@ -815,4 +790,4 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
815
790
  this.setState({ focusIndex: -1 });
816
791
  };
817
792
  };
818
- export { SelectFoundation as default, getOptionId };
793
+ export { SelectFoundation as default };
@@ -242,8 +242,8 @@
242
242
  }
243
243
  .semi-select-content-wrapper-collapse {
244
244
  display: inline-flex;
245
- flex-shrink: 0;
246
- width: 100%;
245
+ flex: 0 1 auto;
246
+ min-width: 0;
247
247
  }
248
248
  .semi-select-content-wrapper-collapse .semi-overflow-list-overflow {
249
249
  min-width: 50px;
@@ -276,7 +276,7 @@
276
276
  display: flex;
277
277
  align-items: center;
278
278
  }
279
- .semi-select-multiple .semi-select-content-wrapper-one-line {
279
+ .semi-select-multiple .semi-select-content-wrapper-one-line, .semi-select-multiple .semi-select-content-wrapper:has(> .semi-select-content-wrapper-collapse) {
280
280
  flex-wrap: nowrap;
281
281
  }
282
282
  .semi-select-multiple .semi-select-content-wrapper-one-line .semi-tag-group {
@@ -206,10 +206,11 @@ $overflowList: #{$prefix}-overflow-list;
206
206
  overflow: hidden;
207
207
  white-space: nowrap;
208
208
 
209
+ // takes the row beside the search input, so the input stays on the tags' row and OverflowList folds into what is left
209
210
  &-collapse {
210
211
  display: inline-flex;
211
- flex-shrink: 0;
212
- width: 100%;
212
+ flex: 0 1 auto;
213
+ min-width: 0;
213
214
 
214
215
  .#{$overflowList}-overflow {
215
216
  min-width: 50px;
@@ -250,9 +251,13 @@ $overflowList: #{$prefix}-overflow-list;
250
251
  align-items: center;
251
252
  }
252
253
 
253
- &-one-line {
254
+ // wrapping comes before shrinking, so the folded tags would push the search input onto a second row
255
+ &-one-line,
256
+ &:has(> .#{$module}-content-wrapper-collapse) {
254
257
  flex-wrap: nowrap;
258
+ }
255
259
 
260
+ &-one-line {
256
261
  .#{$prefix}-tag-group {
257
262
  flex-shrink: 0;
258
263
  flex-wrap: nowrap;
@@ -1,6 +1,8 @@
1
1
  export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  };
4
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
5
+ export type SideSheetPart = 'mask' | 'content' | 'header' | 'body' | 'footer';
4
6
  export declare const strings: {
5
7
  HEIGHT: number;
6
8
  };
@@ -3,7 +3,6 @@ import "../../base/index.js";
3
3
  export type Placement = 'top' | 'bottom' | 'left' | 'right';
4
4
  export interface SideSheetProps {
5
5
  afterVisibleChange?: (isVisible: boolean) => void;
6
- bodyStyle?: Record<string, any>;
7
6
  className?: string;
8
7
  closable?: boolean;
9
8
  closeIcon?: any;
@@ -11,12 +10,10 @@ export interface SideSheetProps {
11
10
  disableScroll?: boolean;
12
11
  footer?: any;
13
12
  getPopupContainer?: () => HTMLElement;
14
- headerStyle?: Record<string, any>;
15
13
  height?: number | string;
16
14
  keepDOM?: boolean;
17
15
  mask?: boolean;
18
16
  maskClosable?: boolean;
19
- maskStyle?: Record<string, any>;
20
17
  motion?: boolean;
21
18
  onCancel?: (e: any) => void;
22
19
  placement?: Placement;
@@ -71,9 +68,14 @@ export default class SideSheetFoundation<P extends SideSheetProps = SideSheetPro
71
68
  /** Remembers the element to return focus to; hosts call it on opening, before anything inside the sheet takes focus */
72
69
  recordFocus: () => void;
73
70
  handleCancel: (e: unknown) => void;
71
+ /**
72
+ * Hosts call this when the dialog's animation ends, and at once when a run without motion starts: the end of an
73
+ * enter reports afterVisibleChange(true), once per showing.
74
+ */
75
+ handleAnimationEnd: () => void;
74
76
  /**
75
77
  * Hosts call this when the sheet stops or starts being hidden (once the animations ended), not on mount, and with
76
- * `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing.
78
+ * `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing, after its `true`.
77
79
  */
78
80
  handleHiddenChange: (isHidden: boolean) => void;
79
81
  beforeShow: () => void;
@@ -1,24 +1,35 @@
1
1
  import FocusTrapHandle from "../../base/focus-handle.js";
2
2
  import BaseFoundation from "../../base/foundation.js";
3
3
  import ModalResources from "../../base/modal-resources.js";
4
+ import OverlaySession from "../../base/overlay-session.js";
4
5
  import PopupLifecycle from "../../base/popup-lifecycle.js";
5
6
  import { coversPage } from "../../utils/dom.js";
7
+ import { warnIfDialogUnnamed } from "../../utils/a11y.js";
6
8
  import { strings } from "./constants.js";
7
9
  // src/components/side-sheet/side-sheet-foundation.ts
8
10
  var SideSheetFoundation = class SideSheetFoundation extends BaseFoundation {
9
- #shown = false;
10
- #resume = false;
11
+ #session = new OverlaySession();
11
12
  #lifecycle = new PopupLifecycle();
12
13
  #resources = new ModalResources();
14
+ #shownReported = false;
13
15
  constructor(adapter) {
14
16
  super(adapter);
15
- if (this.getProp("visible")) this.#lifecycle.show();
17
+ if (this.getProp("visible")) {
18
+ this.#lifecycle.show();
19
+ this.#shownReported = true;
20
+ }
16
21
  }
17
22
  #handleEscape = (e) => {
18
23
  if (!this.getProp("closeOnEsc")) return false;
19
24
  this.handleCancel(e);
20
25
  return true;
21
26
  };
27
+ #reportShown() {
28
+ if (!this.#shownReported) {
29
+ this.#shownReported = true;
30
+ this.adapter.notifyAfterVisibleChange(true);
31
+ }
32
+ }
22
33
  /** Without a mask the width goes on the outer element and the dialog fills it: a percentage repeated on the dialog would compound. */
23
34
  static getSheetSize({ placement, canVerticalSetWidth, width, height, mask }) {
24
35
  const horizontal = placement === "top" || placement === "bottom";
@@ -45,16 +56,10 @@ var SideSheetFoundation = class SideSheetFoundation extends BaseFoundation {
45
56
  return {};
46
57
  }
47
58
  init() {
48
- if (this.#resume) {
49
- this.#resume = false;
50
- this.beforeShow();
51
- }
59
+ if (this.#session.resume()) this.beforeShow();
52
60
  }
53
61
  destroy() {
54
- if (this.#shown) {
55
- this.afterHide();
56
- this.#resume = true;
57
- }
62
+ if (this.#session.suspend()) this.#resources.release();
58
63
  }
59
64
  /** Returns focus again, for a host whose framework refocuses the previously focused element after the close */
60
65
  restoreFocus = () => {
@@ -69,19 +74,26 @@ var SideSheetFoundation = class SideSheetFoundation extends BaseFoundation {
69
74
  this.adapter.notifyCancel(e);
70
75
  };
71
76
  /**
77
+ * Hosts call this when the dialog's animation ends, and at once when a run without motion starts: the end of an
78
+ * enter reports afterVisibleChange(true), once per showing.
79
+ */
80
+ handleAnimationEnd = () => {
81
+ if (this.getProp("visible")) this.#reportShown();
82
+ };
83
+ /**
72
84
  * Hosts call this when the sheet stops or starts being hidden (once the animations ended), not on mount, and with
73
- * `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing.
85
+ * `true` when it unmounts for good: afterVisibleChange(false) is reported once per showing, after its `true`.
74
86
  */
75
87
  handleHiddenChange = (isHidden) => {
76
- if (isHidden) this.#lifecycle.ended(() => this.adapter.notifyAfterVisibleChange(false));
77
- else {
78
- this.#lifecycle.show();
79
- this.adapter.notifyAfterVisibleChange(true);
80
- }
88
+ if (isHidden) this.#lifecycle.ended(() => {
89
+ this.#reportShown();
90
+ this.#shownReported = false;
91
+ this.adapter.notifyAfterVisibleChange(false);
92
+ });
93
+ else this.#lifecycle.show();
81
94
  };
82
95
  beforeShow = () => {
83
- if (this.#shown) return;
84
- this.#shown = true;
96
+ if (!this.#session.begin()) return;
85
97
  this.#lifecycle.show();
86
98
  const { mask, getPopupContainer, disableScroll } = this.getProps();
87
99
  const modal = SideSheetFoundation.isModal({
@@ -98,12 +110,10 @@ var SideSheetFoundation = class SideSheetFoundation extends BaseFoundation {
98
110
  focus: dialog,
99
111
  preventScroll: true
100
112
  });
113
+ warnIfDialogUnnamed(dialog ?? null, "SideSheet");
101
114
  };
102
115
  afterHide = () => {
103
- this.#resume = false;
104
- if (!this.#shown) return;
105
- this.#shown = false;
106
- this.#resources.release();
116
+ if (this.#session.end()) this.#resources.release();
107
117
  };
108
118
  };
109
119
  export { SideSheetFoundation as default };
@@ -6,4 +6,6 @@ export declare const cssClasses: {
6
6
  MARKS: string;
7
7
  HANDLE: string;
8
8
  HANDLE_DOT: string;
9
- };
9
+ };
10
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
11
+ export type SliderPart = 'rail';
@@ -30,7 +30,6 @@ export interface SliderProps {
30
30
  showArrow?: boolean;
31
31
  className?: string;
32
32
  showBoundary?: boolean;
33
- railStyle?: Record<string, any>;
34
33
  verticalReverse?: boolean;
35
34
  'aria-label'?: string;
36
35
  'aria-labelledby'?: string;
@@ -96,7 +95,7 @@ export default class SliderFoundation<P extends SliderProps = SliderProps> exten
96
95
  * `reverse` is the class suffix of a vertical slider drawn from the bottom.
97
96
  */
98
97
  static getLayout(props: SliderProps, value: SliderState['currentValue'], { chooseMovePos, isDrag }: Pick<SliderState, 'chooseMovePos' | 'isDrag'>, direction?: string): {
99
- startProp: "left" | "right" | "top";
98
+ startProp: "top" | "left" | "right";
100
99
  inputDir: "rtl" | "ltr";
101
100
  reverse: string;
102
101
  track: {
@@ -172,10 +171,11 @@ export default class SliderFoundation<P extends SliderProps = SliderProps> exten
172
171
  */
173
172
  handleInputChange: (value: number, pos: "min" | "max") => void;
174
173
  /**
175
- * A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
176
- * the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
177
- * (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
178
- * towards max increases; the cross-axis arrow follows Up and Right.
174
+ * A value key stays with the slider unless the consumer's handler already prevented it. Page keys keep the native
175
+ * range's change; arrows, Home and End are handled here, since engines map them differently over a vertical or RTL
176
+ * range (Chrome follows the visual direction for arrows, Firefox not when vertical, Safari in neither case, and
177
+ * Safari swaps Home and End on a vertical range). The arrow pointing towards max increases; the cross-axis arrow
178
+ * follows Up and Right.
179
179
  */
180
180
  handleKeyDown: (event: Pick<KeyboardEvent, "key" | "defaultPrevented" | "stopPropagation" | "preventDefault" | KeyModifiers>, pos: "min" | "max") => void;
181
181
  /**
@@ -409,10 +409,11 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
409
409
  }
410
410
  };
411
411
  /**
412
- * A value key stays with the slider unless the consumer's handler already prevented it. Page, Home and End keep
413
- * the native range's change; arrows step here, since engines map them differently over a vertical or RTL range
414
- * (Chrome follows the visual direction, Firefox not when vertical, Safari in neither case). The arrow pointing
415
- * towards max increases; the cross-axis arrow follows Up and Right.
412
+ * A value key stays with the slider unless the consumer's handler already prevented it. Page keys keep the native
413
+ * range's change; arrows, Home and End are handled here, since engines map them differently over a vertical or RTL
414
+ * range (Chrome follows the visual direction for arrows, Firefox not when vertical, Safari in neither case, and
415
+ * Safari swaps Home and End on a vertical range). The arrow pointing towards max increases; the cross-axis arrow
416
+ * follows Up and Right.
416
417
  */
417
418
  handleKeyDown = (event, pos) => {
418
419
  if (!VALUE_KEYS.includes(event.key) || hasModifier(event)) return;
@@ -428,11 +429,13 @@ var SliderFoundation = class SliderFoundation extends BaseFoundation {
428
429
  ArrowRight: "ArrowLeft"
429
430
  };
430
431
  const delta = increase.includes(event.key) ? 1 : increase.map((key) => opposite[key]).includes(event.key) ? -1 : 0;
431
- if (!delta) return;
432
+ if (!delta && event.key !== "Home" && event.key !== "End") return;
432
433
  event.preventDefault();
433
434
  const { currentValue } = this.getStates();
434
435
  const value = Array.isArray(currentValue) ? currentValue[pos === "min" ? 0 : 1] : currentValue;
435
- const next = this.normalizeValue(value + delta * (step > 0 ? step : 1));
436
+ const stepSize = step > 0 ? step : 1;
437
+ let next = this.normalizeValue(event.key === "Home" ? min : event.key === "End" ? min + Math.round((max - min) / stepSize) * stepSize : value + delta * stepSize);
438
+ if (event.key === "End" && next > max) next = this.normalizeValue(next - stepSize);
436
439
  if (next >= min && next <= max) this.handleInputChange(next, pos);
437
440
  };
438
441
  /**
@@ -1,3 +1,5 @@
1
1
  export declare const cssClasses: {
2
2
  PREFIX: string;
3
- };
3
+ };
4
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
5
+ export type SpinPart = 'child';
@@ -1,6 +1,8 @@
1
1
  export declare const cssClasses: {
2
2
  readonly PREFIX: "semi-table";
3
3
  };
4
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
5
+ export type TablePart = 'header';
4
6
  export declare const strings: {
5
7
  readonly SIZE_SMALL: "small";
6
8
  readonly SIZE_MIDDLE: "middle";
@@ -224,6 +224,14 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
224
224
  static getInitialState<R, C extends BaseColumnProps<R> = BaseColumnProps<R>>(props: TableBaseProps<R>, flattenColumns: C[], queries: C[]): TableColumnsState<R, C>;
225
225
  /** Hosts call it after mount, on body scroll and when the table or its content resizes */
226
226
  syncScrollEdges: () => void;
227
+ /**
228
+ * Whether a sticky header follows the body through a scroll-driven animation, which the compositor runs in the
229
+ * frame it scrolls the body, rather than through scrollLeft writes a frame late. Probed after mount, like
230
+ * syncScrollEdges. Removable with the scrollLeft path once Chrome 116, Firefox 159 and Safari 26 are the minimum.
231
+ */
232
+ headerFollowsInCss: () => boolean;
233
+ /** Hosts call it after commits and body resizes of a sticky table: the distance the header's animation spans */
234
+ syncHeaderScrollRange: () => void;
227
235
  /** `index` is the header row the widths were measured in */
228
236
  setHeadWidths: (widths: BaseHeadWidth[], index?: number) => void;
229
237
  setBodyHasScrollbar: (bodyHasScrollBar: boolean) => void;
@@ -11,6 +11,7 @@ import { get } from "es-toolkit/compat";
11
11
  // src/components/table/foundation.ts
12
12
  var TableFoundation = class TableFoundation extends BaseFoundation {
13
13
  #trackScrollEdges;
14
+ #headerFollowsInCss;
14
15
  #rangeAnchor = null;
15
16
  #rangeBase = null;
16
17
  #rangeResult = null;
@@ -755,6 +756,17 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
755
756
  const body = this.#trackScrollEdges ? this.adapter.getBodyWrapper() : null;
756
757
  if (body) TableFoundation.#syncScrollableEdges(body);
757
758
  };
759
+ /**
760
+ * Whether a sticky header follows the body through a scroll-driven animation, which the compositor runs in the
761
+ * frame it scrolls the body, rather than through scrollLeft writes a frame late. Probed after mount, like
762
+ * syncScrollEdges. Removable with the scrollLeft path once Chrome 116, Firefox 159 and Safari 26 are the minimum.
763
+ */
764
+ headerFollowsInCss = () => this.#headerFollowsInCss ??= CSS.supports("timeline-scope", "--semi-table-body-x");
765
+ /** Hosts call it after commits and body resizes of a sticky table: the distance the header's animation spans */
766
+ syncHeaderScrollRange = () => {
767
+ const body = this.headerFollowsInCss() ? this.adapter.getBodyWrapper() : null;
768
+ body?.parentElement?.style.setProperty("--semi-table-scroll-range", `${body.scrollWidth - body.clientWidth}px`);
769
+ };
758
770
  /** `index` is the header row the widths were measured in */
759
771
  setHeadWidths = (widths, index = 0) => {
760
772
  const prevHeadWidths = this.getState("headWidths") ?? [];
@@ -5,6 +5,11 @@
5
5
 
6
6
  $module: #{$prefix}-table;
7
7
 
8
+ // an RTL body scrolls toward its left end, so the sticky header's table moves right
9
+ .#{$module}-container:dir(rtl) {
10
+ --semi-table-scroll-sign: 1;
11
+ }
12
+
8
13
  .#{$module}-align-left:dir(rtl) .#{$module}-operate-wrapper {
9
14
  justify-content: flex-end;
10
15
  }