@fibrae/semi-foundation 0.6.0 → 0.7.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 (103) 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/highlight/constants.d.ts +3 -1
  38. package/dist/components/image/constants.d.ts +5 -1
  39. package/dist/components/image/preview-inner-foundation.js +6 -15
  40. package/dist/components/input/constants.d.ts +5 -1
  41. package/dist/components/input-number/constants.d.ts +3 -1
  42. package/dist/components/modal/constants.d.ts +3 -1
  43. package/dist/components/modal/modal-content-foundation.d.ts +3 -3
  44. package/dist/components/modal/modal-content-foundation.js +5 -3
  45. package/dist/components/modal/modal-foundation.d.ts +0 -2
  46. package/dist/components/modal/modal-foundation.js +6 -16
  47. package/dist/components/navigation/constants.d.ts +4 -0
  48. package/dist/components/overflow-list/constants.d.ts +2 -0
  49. package/dist/components/pagination/foundation.d.ts +1 -1
  50. package/dist/components/popconfirm/constants.d.ts +3 -1
  51. package/dist/components/popover/constants.d.ts +2 -0
  52. package/dist/components/radio/constants.d.ts +3 -1
  53. package/dist/components/scroll-list/item-foundation.js +1 -0
  54. package/dist/components/select/constants.d.ts +2 -0
  55. package/dist/components/select/foundation.d.ts +1 -4
  56. package/dist/components/select/foundation.js +31 -56
  57. package/dist/components/select/select.css +3 -3
  58. package/dist/components/select/select.scss +8 -3
  59. package/dist/components/side-sheet/constants.d.ts +2 -0
  60. package/dist/components/side-sheet/side-sheet-foundation.d.ts +6 -4
  61. package/dist/components/side-sheet/side-sheet-foundation.js +33 -23
  62. package/dist/components/slider/constants.d.ts +3 -1
  63. package/dist/components/slider/foundation.d.ts +7 -7
  64. package/dist/components/slider/foundation.js +9 -6
  65. package/dist/components/spin/constants.d.ts +3 -1
  66. package/dist/components/table/constants.d.ts +2 -0
  67. package/dist/components/tabs/constants.d.ts +2 -0
  68. package/dist/components/tabs/foundation.js +19 -60
  69. package/dist/components/time-picker/combobox-options.js +1 -1
  70. package/dist/components/time-picker/constants.d.ts +2 -0
  71. package/dist/components/time-picker/foundation.d.ts +3 -1
  72. package/dist/components/time-picker/foundation.js +7 -1
  73. package/dist/components/tooltip/constants.d.ts +2 -0
  74. package/dist/components/tooltip/foundation.d.ts +13 -15
  75. package/dist/components/tooltip/foundation.js +54 -15
  76. package/dist/components/tree/constants.d.ts +2 -0
  77. package/dist/components/tree/foundation.d.ts +17 -3
  78. package/dist/components/tree/foundation.js +37 -2
  79. package/dist/components/tree/shared.d.ts +37 -0
  80. package/dist/components/tree/shared.js +42 -1
  81. package/dist/components/tree-select/constants.d.ts +2 -0
  82. package/dist/components/tree-select/foundation.d.ts +15 -10
  83. package/dist/components/tree-select/foundation.js +44 -7
  84. package/dist/components/upload/constants.d.ts +4 -2
  85. package/dist/components/upload/utils.d.ts +5 -0
  86. package/dist/components/upload/utils.js +8 -2
  87. package/dist/components/video-player/foundation.js +1 -1
  88. package/dist/components/video-player/utils.d.ts +0 -2
  89. package/dist/components/video-player/utils.js +1 -14
  90. package/dist/locale/interface.d.ts +2 -0
  91. package/dist/locale/source/en_US.js +1 -0
  92. package/dist/locale/source/zh_CN.js +1 -0
  93. package/dist/utils/a11y.d.ts +9 -0
  94. package/dist/utils/a11y.js +19 -1
  95. package/dist/utils/date-fns-extra.d.ts +1 -0
  96. package/dist/utils/date-fns-extra.js +4 -1
  97. package/dist/utils/index.d.ts +3 -2
  98. package/dist/utils/index.js +3 -2
  99. package/dist/utils/media.d.ts +2 -0
  100. package/dist/utils/media.js +15 -0
  101. package/package.json +2 -2
  102. package/dist/components/date-picker/_utils/is-valid-date.d.ts +0 -1
  103. package/dist/components/date-picker/_utils/is-valid-date.js +0 -5
@@ -7,8 +7,9 @@ import BaseFoundation, { ContextOf, DefaultAdapter, DirectionContext, Lifecycle,
7
7
  import { HookApi, HookApiOptions, createHookApi } from "./hook-api.js";
8
8
  import ListStore, { FreshItems, ListStoreItem, ListStoreState, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, readNoticeText } from "./list-store.js";
9
9
  import ModalResources, { ModalHold } from "./modal-resources.js";
10
+ import OverlaySession from "./overlay-session.js";
10
11
  import PopupLifecycle from "./popup-lifecycle.js";
11
12
  import ReleaseHolder from "./release-holder.js";
12
13
  import { ResetTimer } from "./reset-timer.js";
13
14
  import StaticListWrapper from "./static-list-wrapper.js";
14
- export { AutoCloseAdapter, AutoCloseBaseProps, AutoCloseFoundation, AutoCloseListState, BASE_CLASS_PREFIX, BaseFoundation, ContextOf, DefaultAdapter, DirectionContext, FocusScope, FocusTrapHandle, FreshItems, GlobalDefaults, HookApi, HookApiOptions, InstanceIdKey, Lifecycle, ListStore, ListStoreItem, ListStoreState, ModalHold, ModalResources, PopupLifecycle, PropReactions, ReleaseHolder, ResetTimer, StaticListWrapper, VALIDATE_STATUS, ValidateStatus, createHookApi, createPropsTracker, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, omitInstanceIds, readNoticeText };
15
+ export { AutoCloseAdapter, AutoCloseBaseProps, AutoCloseFoundation, AutoCloseListState, BASE_CLASS_PREFIX, BaseFoundation, ContextOf, DefaultAdapter, DirectionContext, FocusScope, FocusTrapHandle, FreshItems, GlobalDefaults, HookApi, HookApiOptions, InstanceIdKey, Lifecycle, ListStore, ListStoreItem, ListStoreState, ModalHold, ModalResources, OverlaySession, PopupLifecycle, PropReactions, ReleaseHolder, ResetTimer, StaticListWrapper, VALIDATE_STATUS, ValidateStatus, createHookApi, createPropsTracker, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, omitInstanceIds, readNoticeText };
@@ -7,8 +7,9 @@ import BaseFoundation, { createPropsTracker } from "./foundation.js";
7
7
  import { createHookApi } from "./hook-api.js";
8
8
  import ListStore, { FreshItems, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, readNoticeText } from "./list-store.js";
9
9
  import ModalResources from "./modal-resources.js";
10
+ import OverlaySession from "./overlay-session.js";
10
11
  import PopupLifecycle from "./popup-lifecycle.js";
11
12
  import ReleaseHolder from "./release-holder.js";
12
13
  import { ResetTimer } from "./reset-timer.js";
13
14
  import StaticListWrapper from "./static-list-wrapper.js";
14
- export { AutoCloseFoundation, BASE_CLASS_PREFIX, BaseFoundation, FocusScope, FocusTrapHandle, FreshItems, ListStore, ModalResources, PopupLifecycle, ReleaseHolder, ResetTimer, StaticListWrapper, VALIDATE_STATUS, createHookApi, createPropsTracker, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, omitInstanceIds, readNoticeText };
15
+ export { AutoCloseFoundation, BASE_CLASS_PREFIX, BaseFoundation, FocusScope, FocusTrapHandle, FreshItems, ListStore, ModalResources, OverlaySession, PopupLifecycle, ReleaseHolder, ResetTimer, StaticListWrapper, VALIDATE_STATUS, createHookApi, createPropsTracker, getStackDepths, hasLostFocus, isAlertType, isStackExpanded, isStackHidden, omitInstanceIds, readNoticeText };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Whether an overlay (Modal, SideSheet, ImagePreview) is shown, that is holds its page resources, and whether a
3
+ * destroy while shown (KeepAlive, Activity, StrictMode replay) owes the showing back on the next init. Each method
4
+ * returns whether the caller takes or releases the resources.
5
+ */
6
+ export default class OverlaySession {
7
+ #private;
8
+ /** A showing begins; false when one is already going on */
9
+ begin(): boolean;
10
+ /** The showing ends, and a suspended one no longer resumes; false when none is going on */
11
+ end(): boolean;
12
+ /** The host destroys the foundation: a showing going on ends and begins again on the next `resume` */
13
+ suspend(): boolean;
14
+ /** The host initializes the foundation again: true when a suspended showing must begin again */
15
+ resume(): boolean;
16
+ }
@@ -0,0 +1,36 @@
1
+ // src/base/overlay-session.ts
2
+ /**
3
+ * Whether an overlay (Modal, SideSheet, ImagePreview) is shown, that is holds its page resources, and whether a
4
+ * destroy while shown (KeepAlive, Activity, StrictMode replay) owes the showing back on the next init. Each method
5
+ * returns whether the caller takes or releases the resources.
6
+ */
7
+ var OverlaySession = class {
8
+ #shown = false;
9
+ #resume = false;
10
+ /** A showing begins; false when one is already going on */
11
+ begin() {
12
+ if (this.#shown) return false;
13
+ this.#shown = true;
14
+ return true;
15
+ }
16
+ /** The showing ends, and a suspended one no longer resumes; false when none is going on */
17
+ end() {
18
+ this.#resume = false;
19
+ if (!this.#shown) return false;
20
+ this.#shown = false;
21
+ return true;
22
+ }
23
+ /** The host destroys the foundation: a showing going on ends and begins again on the next `resume` */
24
+ suspend() {
25
+ if (!this.end()) return false;
26
+ this.#resume = true;
27
+ return true;
28
+ }
29
+ /** The host initializes the foundation again: true when a suspended showing must begin again */
30
+ resume() {
31
+ const resume = this.#resume;
32
+ this.#resume = false;
33
+ return resume;
34
+ }
35
+ };
36
+ export { OverlaySession as default };
@@ -1,5 +1,5 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
- import { ignoreExpectedMediaErrors } from "../video-player/utils.js";
2
+ import { ignoreExpectedMediaErrors } from "../../utils/media.js";
3
3
  import { DEFAULT_RATE } from "./constants.js";
4
4
  // src/components/audio-player/foundation.ts
5
5
  var AudioPlayerFoundation = class extends BaseFoundation {
@@ -1,4 +1,6 @@
1
1
  export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  PREFIX_OPTION: string;
4
- };
4
+ };
5
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
6
+ export type AutoCompletePart = 'dropdown';
@@ -50,7 +50,7 @@ export default class AutoCompleteFoundation<P extends AutoCompleteBaseProps = Au
50
50
  protected initOnce(): void;
51
51
  static getInitialState(props: AutoCompleteBaseProps): AutoCompleteBaseState;
52
52
  handlePropsChange(): void;
53
- handleKeyDown: (event: Pick<KeyboardEvent, "key" | "preventDefault"> & Parameters<typeof isComposing>[0]) => void;
53
+ handleKeyDown: (event: Pick<KeyboardEvent, "key" | "preventDefault"> & Partial<Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">> & Parameters<typeof isComposing>[0]) => void;
54
54
  /** Mousedown outside the input and dropdown while shown */
55
55
  handleClickOutside: (_e: MouseEvent) => void;
56
56
  handleEscKeyDown: () => void;
@@ -1,10 +1,8 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
- import { getEnabledStepIndex, isInnerControlActivation } from "../../utils/a11y.js";
3
- import { centerInScroller } from "../../utils/dom.js";
2
+ import { getEnabledStepIndex, getOptionId, isBrowserChord, isInnerControlActivation, revealOption } from "../../utils/a11y.js";
4
3
  import isObject from "../../utils/is-object.js";
5
4
  import { isComposing } from "../../utils/key-code.js";
6
5
  import warning from "../../utils/warning.js";
7
- import { getOptionId } from "../select/foundation.js";
8
6
  // src/components/auto-complete/foundation.ts
9
7
  var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation {
10
8
  static propKeys = ["value"];
@@ -32,6 +30,9 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
32
30
  static #shown(options) {
33
31
  return options.filter((option) => option.show);
34
32
  }
33
+ static #firstEnabledIndex(options) {
34
+ return AutoCompleteFoundation.#shown(options).findIndex((option) => !option.disabled);
35
+ }
35
36
  static #getRenderSelectedItem({ renderSelectedItem }) {
36
37
  return renderSelectedItem ?? ((option) => option?.value);
37
38
  }
@@ -39,7 +40,7 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
39
40
  if (selectedValue === void 0) return {
40
41
  inputValue: "",
41
42
  selection: /* @__PURE__ */ new Map(),
42
- focusIndex: props.defaultActiveFirstOption ? 0 : -1
43
+ focusIndex: props.defaultActiveFirstOption ? AutoCompleteFoundation.#firstEnabledIndex(AutoCompleteFoundation.#generateList(props.data)) : -1
43
44
  };
44
45
  const renderSelectedItem = AutoCompleteFoundation.#getRenderSelectedItem(props);
45
46
  const options = AutoCompleteFoundation.#generateList(props.data);
@@ -60,36 +61,34 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
60
61
  return {
61
62
  inputValue,
62
63
  selection,
63
- focusIndex: selectedOptionIndex === -1 && props.defaultActiveFirstOption ? 0 : selectedOptionIndex
64
+ focusIndex: selectedOptionIndex === -1 && props.defaultActiveFirstOption ? AutoCompleteFoundation.#firstEnabledIndex(options) : selectedOptionIndex
64
65
  };
65
66
  }
66
67
  #modifyFocusIndex(searchValue) {
67
68
  let { focusIndex } = this.getStates();
68
69
  let { data, defaultActiveFirstOption } = this.getProps();
70
+ const allOptions = AutoCompleteFoundation.#generateList(data);
69
71
  let selectedOptionIndex = -1;
70
72
  if (searchValue) {
71
73
  let renderSelectedItem = AutoCompleteFoundation.#getRenderSelectedItem(this.getProps());
72
- selectedOptionIndex = AutoCompleteFoundation.#shown(AutoCompleteFoundation.#generateList(data)).findIndex((option) => renderSelectedItem(AutoCompleteFoundation.#toDataItem(option)) === searchValue);
74
+ selectedOptionIndex = AutoCompleteFoundation.#shown(allOptions).findIndex((option) => renderSelectedItem(AutoCompleteFoundation.#toDataItem(option)) === searchValue);
73
75
  }
74
- if (selectedOptionIndex === -1 && defaultActiveFirstOption) {
75
- if (focusIndex !== 0) this.setState({ focusIndex: 0 });
76
- } else if (selectedOptionIndex !== focusIndex) this.setState({ focusIndex: selectedOptionIndex });
76
+ const index = selectedOptionIndex === -1 && defaultActiveFirstOption ? AutoCompleteFoundation.#firstEnabledIndex(allOptions) : selectedOptionIndex;
77
+ if (index !== focusIndex) this.setState({ focusIndex: index });
77
78
  }
78
79
  #modifyFocusIndexOnPanelOpen() {
79
80
  let { inputValue } = this.getStates();
80
81
  this.#modifyFocusIndex(inputValue);
81
82
  }
82
- #scrollToOption(index) {
83
- const listbox = this.adapter.getListbox();
84
- const destNode = listbox?.querySelector(`#${CSS.escape(getOptionId(listbox.id, index))}`);
85
- if (listbox && destNode) centerInScroller(destNode, listbox);
86
- }
87
83
  #moveFocus(offset) {
88
84
  const { focusIndex, options } = this.getStates();
89
85
  const visibleOptions = AutoCompleteFoundation.#shown(options);
90
86
  const index = getEnabledStepIndex(offset, focusIndex, visibleOptions.length, (i) => visibleOptions[i].disabled);
91
87
  this.setState({ focusIndex: index });
92
- if (index !== -1) this.#scrollToOption(index);
88
+ if (index !== -1) {
89
+ const listbox = this.adapter.getListbox();
90
+ revealOption(listbox, getOptionId(listbox?.id, index));
91
+ }
93
92
  }
94
93
  #handleArrowKeyDown(offset) {
95
94
  const { visible } = this.getStates();
@@ -139,7 +138,7 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
139
138
  }
140
139
  handleKeyDown = (event) => {
141
140
  const listHidden = this.getProp("loading") && this.getState("visible");
142
- switch (isComposing(event) ? "" : event.key) {
141
+ switch (isComposing(event) || isBrowserChord(event) ? "" : event.key) {
143
142
  case "ArrowUp":
144
143
  event.preventDefault();
145
144
  if (!listHidden) this.#handleArrowKeyDown(-1);
@@ -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 BadgePart = 'count';
@@ -3,4 +3,6 @@ export declare const cssClasses: {
3
3
  };
4
4
  export declare const strings: {
5
5
  readonly DEFAULT_ICON_POSITION: "left";
6
- };
6
+ };
7
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
8
+ export type ButtonPart = 'content';
@@ -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 CardPart = 'header' | 'title' | 'extra' | 'cover' | 'body' | 'actions' | 'footer';
@@ -2,6 +2,8 @@ export declare const cssClasses: {
2
2
  PREFIX: string;
3
3
  PREFIX_OPTION: string;
4
4
  };
5
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
6
+ export type CascaderPart = 'dropdown';
5
7
  export declare const strings: {
6
8
  readonly SHOW_NEXT_BY_CLICK: "click";
7
9
  readonly SHOW_NEXT_BY_HOVER: "hover";
@@ -77,8 +77,6 @@ export interface BasicCascaderProps {
77
77
  autoMergeValue?: boolean;
78
78
  defaultValue?: BasicValue;
79
79
  disabled?: boolean;
80
- dropdownClassName?: string;
81
- dropdownStyle?: any;
82
80
  emptyContent?: any;
83
81
  filterLeafOnly?: boolean;
84
82
  motion?: boolean;
@@ -239,7 +237,7 @@ export default class CascaderFoundation<E = unknown, LE = unknown> extends BaseF
239
237
  static getItemPropPath(selectedKey: string, prop: string | unknown[], keyEntities: BasicEntities): any[];
240
238
  getStates(): BasicCascaderInnerData;
241
239
  getState<K extends keyof BasicCascaderInnerData>(key: K): BasicCascaderInnerData[K];
242
- handleKeyDown: (e: E & Pick<KeyboardEvent, "key" | "preventDefault">) => void;
240
+ handleKeyDown: (e: E & Pick<KeyboardEvent, "key" | "preventDefault" | "target">) => void;
243
241
  /**
244
242
  * Keys of the open popup (APG combobox with a tree popup, or a listbox while searching); focus stays on the
245
243
  * trigger or its search input. Up, Down, Home and End move within the current column or the search results;
@@ -288,7 +286,7 @@ export default class CascaderFoundation<E = unknown, LE = unknown> extends BaseF
288
286
  * While open with no current option (handleOptionKeyDown left the key), Space outside a text field acts like
289
287
  * Enter, as in Select and TreeSelect. A search input keeps Space, Home and End for its text.
290
288
  */
291
- handleSelectionKeyDown: (keyboardEvent: E & Pick<KeyboardEvent, "key" | "preventDefault" | "detail" | "target" | "currentTarget">) => void;
289
+ handleSelectionKeyDown: (keyboardEvent: E & Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey" | "altKey" | "preventDefault" | "detail" | "target" | "currentTarget">) => void;
292
290
  handleInputChange: (sugInput: string) => void;
293
291
  handleClear: () => void;
294
292
  handleListScroll: (e: LE, ind: number) => void;
@@ -3,7 +3,7 @@ import { calcCheckedStatus, calcRelatedCheckedKeys } from "../tree/shared.js";
3
3
  import { calcCheckedKeys, calcDisabledKeys, findAncestorKeys, normalizeKeyList, normalizedArr } from "../tree/tree-util.js";
4
4
  import { strings } from "./constants.js";
5
5
  import { calcMergeType, convertDataToEntities, filter, getColumns, getKeyByPos, getKeyByValuePath, getKeysByValuePath, getValueOrKey } from "./util.js";
6
- import { Typeahead, getListTargetIndex, isInnerControlActivation, isTextEditor } from "../../utils/a11y.js";
6
+ import { Typeahead, getListTargetIndex, isBrowserChord, isInnerControlActivation, isTextEditor } from "../../utils/a11y.js";
7
7
  import isEnterPress from "../../utils/is-enter-press.js";
8
8
  import isObject from "../../utils/is-object.js";
9
9
  import "../../utils/key-code.js";
@@ -652,7 +652,9 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
652
652
  if (e.key === "Escape") {
653
653
  if (this.getState("isOpen")) {
654
654
  e.preventDefault();
655
+ const focusInPopup = e.target instanceof Element && e.target.closest("[popover]") !== null;
655
656
  this.close();
657
+ if (focusInPopup) this.focus();
656
658
  }
657
659
  }
658
660
  };
@@ -807,6 +809,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
807
809
  * Enter, as in Select and TreeSelect. A search input keeps Space, Home and End for its text.
808
810
  */
809
811
  handleSelectionKeyDown = (keyboardEvent) => {
812
+ if (isBrowserChord(keyboardEvent)) return;
810
813
  const { key } = keyboardEvent;
811
814
  const isOpen = this.getState("isOpen");
812
815
  const opensOnArrow = (key === "ArrowDown" || key === "ArrowUp") && !isOpen;
@@ -29,6 +29,8 @@ export default class ColorPickerFoundation<P extends ColorPickerProps = ColorPic
29
29
  protected handleChangeH(currentColor: ColorValue, newH: number): void;
30
30
  protected handleChangeA(currentColor: ColorValue, newAlpha: number): void;
31
31
  static getInitialState(props: Pick<ColorPickerProps, 'value' | 'defaultValue'>): ColorPickerState;
32
+ /** APG dialog: focus enters the popup's first tabbable control, the popup itself when it has none */
33
+ static focusPopup(popup: HTMLElement | null): void;
32
34
  /** The color shown: a controlled `value` wins on the render it arrives in, `null` shows `defaultValue` */
33
35
  static deriveColor({ value, defaultValue }: Pick<ColorPickerProps, 'value' | 'defaultValue'>, { currentColor }: ColorPickerState): ColorValue;
34
36
  /** The full color of a value given in `format`; without alpha support the opacity is dropped */
@@ -1,4 +1,5 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
+ import FocusTrapHandle from "../../base/focus-handle.js";
2
3
  import { hexToHsva, hexToRgba, hsvaStringToHsva, hsvaToHex, hsvaToRgba, invalidColorString, rgbaStringToHsva, rgbaStringToRgba, rgbaToHex, rgbaToHsva } from "./utils/convert.js";
3
4
  import { clamp } from "es-toolkit";
4
5
  // src/components/color-picker/foundation.ts
@@ -38,6 +39,10 @@ var ColorPickerFoundation = class ColorPickerFoundation extends BaseFoundation {
38
39
  static getInitialState(props) {
39
40
  return { currentColor: props.value ?? props.defaultValue };
40
41
  }
42
+ /** APG dialog: focus enters the popup's first tabbable control, the popup itself when it has none */
43
+ static focusPopup(popup) {
44
+ (FocusTrapHandle.getFocusableElements(popup)[0] ?? popup)?.focus({ preventScroll: true });
45
+ }
41
46
  /** The color shown: a controlled `value` wins on the render it arrives in, `null` shows `defaultValue` */
42
47
  static deriveColor({ value, defaultValue }, { currentColor }) {
43
48
  return value !== void 0 ? value ?? defaultValue : currentColor;
@@ -17,5 +17,7 @@ export declare const strings: {
17
17
  readonly corner: readonly ["tl", "tm", "tr", "ml", "mr", "bl", "bm", "br"];
18
18
  readonly roundCorner: readonly ["tm", "ml", "mr", "bm"];
19
19
  };
20
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
21
+ export type CropperPart = 'cropperBox';
20
22
  /** A resize handle of the crop box: t/m/b for the row, l/m/r for the column */
21
23
  export type CornerDir = (typeof strings.corner)[number];
@@ -3,7 +3,6 @@ import isBefore from "./is-before.js";
3
3
  import isBetween from "./is-between.js";
4
4
  import isSameDay from "./is-same-day.js";
5
5
  import isTimestamp from "./is-timestamp.js";
6
- import isValidDate from "./is-valid-date.js";
7
6
  import getDefaultFormatToken from "./get-default-format-token.js";
8
7
  import getFullDateOffset from "./get-full-date-offset.js";
9
- export { getDefaultFormatToken, getFullDateOffset, isAfter, isBefore, isBetween, isSameDay, isTimestamp, isValidDate };
8
+ export { getDefaultFormatToken, getFullDateOffset, isAfter, isBefore, isBetween, isSameDay, isTimestamp };
@@ -3,7 +3,6 @@ import isBefore from "./is-before.js";
3
3
  import isBetween from "./is-between.js";
4
4
  import isSameDay from "./is-same-day.js";
5
5
  import isTimestamp from "./is-timestamp.js";
6
- import isValidDate from "./is-valid-date.js";
7
6
  import getDefaultFormatToken from "./get-default-format-token.js";
8
7
  import getFullDateOffset from "./get-full-date-offset.js";
9
- export { getDefaultFormatToken, getFullDateOffset, isAfter, isBefore, isBetween, isSameDay, isTimestamp, isValidDate };
8
+ export { getDefaultFormatToken, getFullDateOffset, isAfter, isBefore, isBetween, isSameDay, isTimestamp };
@@ -1,4 +1,4 @@
1
- import isValidDate from "./is-valid-date.js";
1
+ import { isValidDate } from "../../../utils/date-fns-extra.js";
2
2
  // src/components/date-picker/_utils/is-timestamp.ts
3
3
  function isTimestamp(ts) {
4
4
  return typeof ts === "number" && isValidDate(new Date(ts));
@@ -1,6 +1,6 @@
1
+ import { isValidDate } from "../../../utils/date-fns-extra.js";
1
2
  import { parseReference, toWallTime } from "../../../utils/zoned-time.js";
2
3
  import isTimestamp from "./is-timestamp.js";
3
- import isValidDate from "./is-valid-date.js";
4
4
  import { compatibleParse } from "./parser.js";
5
5
  // src/components/date-picker/_utils/parse-value.ts
6
6
  function isPickerValue(value) {
@@ -1,4 +1,4 @@
1
- import isValidDate from "./is-valid-date.js";
1
+ import { isValidDate } from "../../../utils/date-fns-extra.js";
2
2
  // src/components/date-picker/_utils/picker-type.ts
3
3
  function isRangeType(type) {
4
4
  return typeof type === "string" && type.endsWith("Range");
@@ -28,6 +28,8 @@ export declare const cssClasses: {
28
28
  readonly WEEK: "semi-datepicker-week";
29
29
  readonly DAY: "semi-datepicker-day";
30
30
  };
31
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
32
+ export type DatePickerPart = 'dropdown' | 'input';
31
33
  export declare const strings: {
32
34
  readonly FORMAT_FULL_DATE: "yyyy-MM-dd";
33
35
  readonly FORMAT_TIME_PICKER: "HH:mm:ss";
@@ -88,12 +88,9 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
88
88
  disabled?: boolean;
89
89
  disabledDate?: DisabledDateType;
90
90
  disabledTime?: DisabledTimeType;
91
- dropdownClassName?: string;
92
- dropdownStyle?: Record<string, any>;
93
91
  endDateOffset?: DateOffsetType;
94
92
  format?: string;
95
93
  inputReadOnly?: boolean;
96
- inputStyle?: Record<string, any>;
97
94
  max?: number;
98
95
  motion?: boolean;
99
96
  multiple?: boolean;
@@ -230,6 +227,8 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
230
227
  handlePropsChange(prev: Partial<DatePickerFoundationProps>): void;
231
228
  /** Called for a mousedown outside the trigger and the panel while the panel is shown */
232
229
  handleClickOutside: (e: MouseEvent) => void;
230
+ /** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
231
+ handleDocumentFocusIn: (e: Pick<FocusEvent, "composedPath">, root?: Node | null) => void;
233
232
  /** @param e the mousedown outside that closes the panel, passed on to onBlur */
234
233
  closePanel(e?: MouseEvent): void;
235
234
  open: () => void;
@@ -284,7 +283,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
284
283
  * APG combobox: Down Arrow on the closed trigger opens the panel (once it is open, the Popover moves focus into
285
284
  * it). A custom trigger that is itself the Tab stop is a button, so Enter and Space open it too.
286
285
  */
287
- handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault" | "target" | "currentTarget">, isTriggerButton: boolean) => void;
286
+ handleTriggerKeyDown: (e: Pick<KeyboardEvent, "key" | "preventDefault" | "target" | "currentTarget"> & Partial<Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">>, isTriggerButton: boolean) => void;
288
287
  handlePanelVisibleChange: (visible: boolean) => void;
289
288
  }
290
289
  export { type DateInputFoundationProps, type RangeInput, type Type, type WeekStartNumber, getYearMonthFromValue, isRangeType, isRangeValueComplete, isSplitRangeInputs, isYearOrMonthType, needConfirm };
@@ -1,13 +1,13 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
- import { zonedTimeToUtc } from "../../utils/date-fns-extra.js";
3
- import { isInnerControlActivation } from "../../utils/a11y.js";
2
+ import { isValidDate, zonedTimeToUtc } from "../../utils/date-fns-extra.js";
3
+ import { containsWithPopups } from "../../utils/layer.js";
4
+ import { isBrowserChord, isInnerControlActivation } from "../../utils/a11y.js";
4
5
  import isValidTimeZone from "../../utils/is-valid-time-zone.js";
5
6
  import warning from "../../utils/warning.js";
6
7
  import { parseReference, toWallTime } from "../../utils/zoned-time.js";
7
8
  import { getDefaultFormatTokenByType } from "./_utils/get-default-format-token.js";
8
9
  import getInsetInputFormatToken from "./_utils/get-inset-input-format-token.js";
9
10
  import getInsetInputValueFromInsetInputStr from "./_utils/get-inset-input-value-from-inset-input-str.js";
10
- import isValidDate from "./_utils/is-valid-date.js";
11
11
  import parseValue from "./_utils/parse-value.js";
12
12
  import { compatibleParse } from "./_utils/parser.js";
13
13
  import { isMultiple, isRangeType, isRangeValueComplete, isSplitRangeInputs, isYearOrMonthType, needConfirm } from "./_utils/picker-type.js";
@@ -467,6 +467,10 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
467
467
  this.adapter.notifyClickOutSide(e);
468
468
  if (!this.#needConfirm()) this.closePanel(e);
469
469
  };
470
+ /** Called for a focusin anywhere while the panel is shown; `root` contains the trigger the panel opens from */
471
+ handleDocumentFocusIn = (e, root) => {
472
+ if (root && !containsWithPopups(root, e.composedPath()[0]) && this.#isPanelShown() && !this.#needConfirm()) this.closePanel();
473
+ };
470
474
  /** @param e the mousedown outside that closes the panel, passed on to onBlur */
471
475
  closePanel(e) {
472
476
  this.#returnFocusFromPanel();
@@ -692,6 +696,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
692
696
  * it). A custom trigger that is itself the Tab stop is a button, so Enter and Space open it too.
693
697
  */
694
698
  handleTriggerKeyDown = (e, isTriggerButton) => {
699
+ if (isBrowserChord(e)) return;
695
700
  const open = this.isControlledComponent("open") ? this.getProp("open") : this.getState("panelShow");
696
701
  const opens = e.key === "ArrowDown" || isTriggerButton && (e.key === "Enter" || e.key === " ");
697
702
  if (!open && opens) {
@@ -38,6 +38,7 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
38
38
  type?: Type;
39
39
  showClear?: boolean;
40
40
  format?: string;
41
+ inputClassName?: string;
41
42
  inputStyle?: Record<string, any>;
42
43
  inputReadOnly?: boolean;
43
44
  validateStatus?: ValidateStatus;
@@ -1,7 +1,7 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
+ import { isValidDate } from "../../utils/date-fns-extra.js";
2
3
  import isObject from "../../utils/is-object.js";
3
4
  import { isSecondaryPress } from "../../utils/pointer.js";
4
- import isValidDate from "./_utils/is-valid-date.js";
5
5
  import { formatDateValues } from "./_utils/formatter.js";
6
6
  import { getDefaultFormatTokenByType } from "./_utils/get-default-format-token.js";
7
7
  import getDefaultPickerDate from "./_utils/get-default-picker-date.js";
@@ -174,5 +174,5 @@ export default class CalendarMonthFoundation extends BaseFoundation<MonthAdapter
174
174
  static getDayClasses(status: ReturnType<typeof CalendarMonthFoundation.getDayStatus>, isActive: boolean): Record<string, unknown>;
175
175
  selectDay: (day?: MonthDayInfo) => void;
176
176
  /** APG grid: focus stays on the grid; the keys move the active day, Enter or Space selects it. `todayText` is empty until mounted. */
177
- handleKeyDown: (event: Pick<KeyboardEvent, "key" | "shiftKey" | "preventDefault">, todayText: string) => void;
177
+ handleKeyDown: (event: Pick<KeyboardEvent, "key" | "shiftKey" | "preventDefault"> & Partial<Pick<KeyboardEvent, "altKey" | "ctrlKey" | "metaKey">>, todayText: string) => void;
178
178
  }
@@ -213,6 +213,7 @@ var CalendarMonthFoundation = class CalendarMonthFoundation extends BaseFoundati
213
213
  };
214
214
  /** APG grid: focus stays on the grid; the keys move the active day, Enter or Space selects it. `todayText` is empty until mounted. */
215
215
  handleKeyDown = (event, todayText) => {
216
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
216
217
  const { month, weekStartsOn } = this.getProps();
217
218
  const activeDate = CalendarMonthFoundation.getActiveDate(this.getProps(), this.getStates(), todayText);
218
219
  const action = CalendarMonthFoundation.getKeyAction(event, {
@@ -110,7 +110,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
110
110
  * Which panels show their year and month picker; while one does, its weeks need a minHeight, or a change of the
111
111
  * number of weeks makes the scroll list unstable
112
112
  */
113
- static getYAMOpenType(state: Pick<MonthsGridFoundationState, 'monthLeft' | 'monthRight'>): "none" | "left" | "right" | "both";
113
+ static getYAMOpenType(state: Pick<MonthsGridFoundationState, 'monthLeft' | 'monthRight'>): "left" | "right" | "none" | "both";
114
114
  static isYearOrTime(panel: PanelState): boolean;
115
115
  /** The `x-open-type` of a panel: what it shows in place of, or beside, its month */
116
116
  static getOpenType(panel: PanelState): "time" | "date" | "year";
@@ -1,9 +1,9 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
2
  import { formatLocale } from "../../locale/format.js";
3
+ import { isValidDate } from "../../utils/date-fns-extra.js";
3
4
  import getDefaultFormatToken, { getDefaultFormatTokenByType } from "./_utils/get-default-format-token.js";
4
5
  import getDefaultPickerDate from "./_utils/get-default-picker-date.js";
5
6
  import isBefore$1 from "./_utils/is-before.js";
6
- import isValidDate from "./_utils/is-valid-date.js";
7
7
  import getFullDateOffset from "./_utils/get-full-date-offset.js";
8
8
  import { compatibleParse } from "./_utils/parser.js";
9
9
  import { isDateTimeType, isMultiple, isRangeType } from "./_utils/picker-type.js";
@@ -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 DescriptionsItemPart = 'key';
@@ -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 DropdownPart = 'content' | 'wrapper';
4
6
  export declare const strings: {
5
7
  DEFAULT_LEAVE_DELAY: number;
6
8
  ITEM_SELECTOR: string;
@@ -5,7 +5,7 @@ export type DropdownSelectionMode = 'single' | 'multiple';
5
5
  * Role and checked state of a menu item, from the menu's selectionMode (as React Aria Menu) and showTick. Without a
6
6
  * selectionMode a tick shows a checked state, so showTick alone makes the items checkboxes.
7
7
  */
8
- export declare function getItemRole(selectionMode?: DropdownSelectionMode, showTick?: boolean): "menuitemradio" | "menuitemcheckbox" | "menuitem";
8
+ export declare function getItemRole(selectionMode?: DropdownSelectionMode, showTick?: boolean): "menuitem" | "menuitemradio" | "menuitemcheckbox";
9
9
  /**
10
10
  * What a Dropdown provides to everything inside its popup, read by the menus there and by a Dropdown whose trigger is
11
11
  * one of their items. A framework adapter passes it as the foundation context, with the reading direction added.
@@ -3,4 +3,6 @@ export declare const cssClasses: {
3
3
  };
4
4
  export declare const strings: {
5
5
  readonly LAYOUT: readonly ["vertical", "horizontal"];
6
- };
6
+ };
7
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
8
+ export type EmptyPart = 'image';
@@ -9,4 +9,6 @@ export declare const strings: {
9
9
  readonly normal: "😐";
10
10
  readonly good: "😃";
11
11
  };
12
- };
12
+ };
13
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style`. Forwarded to the Modal or SideSheet of the current mode */
14
+ export type FeedbackPart = 'mask' | 'header' | 'body';
@@ -1,3 +1,5 @@
1
1
  export declare const cssClasses: {
2
2
  readonly PREFIX: "semi-highlight";
3
- };
3
+ };
4
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
5
+ export type HighlightPart = 'highlight';
@@ -3,4 +3,8 @@ export declare const cssClasses: {
3
3
  };
4
4
  export declare const numbers: {
5
5
  DEFAULT_Z_INDEX: number;
6
- };
6
+ };
7
+ /** Keys of `classNames` and `styles`; the root element takes `className` and `style` */
8
+ export type ImagePart = 'img';
9
+ /** Keys of `classNames` and `styles` of an image preview; the group root takes `className` and `style` */
10
+ export type ImagePreviewPart = 'preview';