@fibrae/semi-foundation 0.1.1 → 0.2.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 (194) hide show
  1. package/dist/anchor/foundation.d.ts +1 -1
  2. package/dist/anchor/foundation.js +21 -21
  3. package/dist/audio-player/foundation.d.ts +10 -10
  4. package/dist/audio-player/foundation.js +19 -19
  5. package/dist/auto-complete/foundation.d.ts +12 -12
  6. package/dist/auto-complete/foundation.js +51 -51
  7. package/dist/avatar/foundation.d.ts +5 -5
  8. package/dist/avatar/foundation.js +16 -16
  9. package/dist/backtop/foundation.d.ts +2 -2
  10. package/dist/backtop/foundation.js +7 -7
  11. package/dist/banner/foundation.d.ts +1 -1
  12. package/dist/banner/foundation.js +4 -4
  13. package/dist/base/auto-close-foundation.d.ts +8 -8
  14. package/dist/base/auto-close-foundation.js +15 -15
  15. package/dist/base/foundation.d.ts +4 -3
  16. package/dist/base/foundation.js +12 -11
  17. package/dist/breadcrumb/foundation.d.ts +5 -5
  18. package/dist/breadcrumb/foundation.js +9 -10
  19. package/dist/breadcrumb/item-foundation.d.ts +3 -3
  20. package/dist/breadcrumb/item-foundation.js +6 -6
  21. package/dist/calendar/event-util.js +1 -1
  22. package/dist/calendar/foundation.js +4 -4
  23. package/dist/calendar/month-foundation.d.ts +2 -2
  24. package/dist/calendar/month-foundation.js +6 -6
  25. package/dist/carousel/foundation.d.ts +17 -17
  26. package/dist/carousel/foundation.js +51 -51
  27. package/dist/cascader/foundation.d.ts +34 -26
  28. package/dist/cascader/foundation.js +143 -121
  29. package/dist/checkbox/checkbox-foundation.d.ts +2 -2
  30. package/dist/checkbox/checkbox-foundation.js +15 -15
  31. package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
  32. package/dist/checkbox/checkbox-group-foundation.js +8 -8
  33. package/dist/code-highlight/index.d.ts +1 -1
  34. package/dist/code-highlight/index.js +3 -3
  35. package/dist/collapse/foundation.d.ts +2 -2
  36. package/dist/collapse/foundation.js +7 -7
  37. package/dist/collapsible/foundation.d.ts +3 -3
  38. package/dist/collapsible/foundation.js +8 -8
  39. package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
  40. package/dist/color-picker/alpha-slider-foundation.js +10 -10
  41. package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
  42. package/dist/color-picker/color-choose-area-foundation.js +14 -14
  43. package/dist/color-picker/color-slider-foundation.d.ts +2 -4
  44. package/dist/color-picker/color-slider-foundation.js +10 -10
  45. package/dist/color-picker/data-part-foundation.d.ts +5 -5
  46. package/dist/color-picker/data-part-foundation.js +11 -11
  47. package/dist/color-picker/foundation.d.ts +4 -4
  48. package/dist/color-picker/foundation.js +10 -10
  49. package/dist/config-provider/breakpoint-observer.d.ts +3 -3
  50. package/dist/config-provider/breakpoint-observer.js +6 -6
  51. package/dist/cropper/foundation.d.ts +15 -15
  52. package/dist/cropper/foundation.js +26 -23
  53. package/dist/date-picker/_utils/picker-type.d.ts +1 -1
  54. package/dist/date-picker/foundation.d.ts +36 -36
  55. package/dist/date-picker/foundation.js +125 -129
  56. package/dist/date-picker/input-foundation.d.ts +9 -9
  57. package/dist/date-picker/input-foundation.js +28 -28
  58. package/dist/date-picker/months-grid-foundation.d.ts +16 -16
  59. package/dist/date-picker/months-grid-foundation.js +64 -65
  60. package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
  61. package/dist/date-picker/year-and-month-foundation.js +11 -11
  62. package/dist/drag-move/foundation.d.ts +2 -2
  63. package/dist/drag-move/foundation.js +15 -13
  64. package/dist/dropdown/foundation.d.ts +8 -5
  65. package/dist/dropdown/foundation.js +32 -28
  66. package/dist/dropdown/menu-foundation.d.ts +1 -1
  67. package/dist/dropdown/menu-foundation.js +11 -11
  68. package/dist/feedback/foundation.d.ts +9 -9
  69. package/dist/feedback/foundation.js +33 -33
  70. package/dist/form/form-api-proxy.d.ts +8 -7
  71. package/dist/form/form-api-proxy.js +25 -25
  72. package/dist/form/foundation.d.ts +5 -5
  73. package/dist/form/foundation.js +60 -61
  74. package/dist/highlight/foundation.js +1 -1
  75. package/dist/hot-keys/foundation.d.ts +2 -2
  76. package/dist/hot-keys/foundation.js +5 -5
  77. package/dist/image/image-foundation.d.ts +4 -4
  78. package/dist/image/image-foundation.js +10 -10
  79. package/dist/image/preview-footer-foundation.d.ts +3 -3
  80. package/dist/image/preview-footer-foundation.js +10 -10
  81. package/dist/image/preview-foundation.js +7 -6
  82. package/dist/image/preview-image-foundation.d.ts +6 -8
  83. package/dist/image/preview-image-foundation.js +14 -14
  84. package/dist/image/preview-inner-foundation.d.ts +9 -9
  85. package/dist/image/preview-inner-foundation.js +38 -38
  86. package/dist/input/foundation.d.ts +10 -10
  87. package/dist/input/foundation.js +47 -49
  88. package/dist/input/text-entry-foundation.d.ts +3 -3
  89. package/dist/input/text-entry-foundation.js +14 -14
  90. package/dist/input/textarea-foundation.d.ts +7 -7
  91. package/dist/input/textarea-foundation.js +36 -36
  92. package/dist/input-number/foundation.d.ts +16 -14
  93. package/dist/input-number/foundation.js +54 -53
  94. package/dist/json-viewer/foundation.d.ts +8 -8
  95. package/dist/json-viewer/foundation.js +23 -23
  96. package/dist/lottie/foundation.d.ts +1 -1
  97. package/dist/lottie/foundation.js +4 -4
  98. package/dist/markdown-render/foundation.d.ts +1 -1
  99. package/dist/markdown-render/foundation.js +4 -4
  100. package/dist/modal/modal-content-foundation.d.ts +7 -7
  101. package/dist/modal/modal-content-foundation.js +20 -20
  102. package/dist/modal/modal-foundation.d.ts +6 -6
  103. package/dist/modal/modal-foundation.js +24 -24
  104. package/dist/navigation/foundation.d.ts +1 -1
  105. package/dist/navigation/foundation.js +14 -14
  106. package/dist/navigation/item-foundation.d.ts +1 -1
  107. package/dist/navigation/item-foundation.js +8 -8
  108. package/dist/navigation/sub-nav-foundation.d.ts +3 -3
  109. package/dist/navigation/sub-nav-foundation.js +17 -17
  110. package/dist/notification/notification-list-foundation.d.ts +7 -7
  111. package/dist/notification/notification-list-foundation.js +12 -12
  112. package/dist/overflow-list/foundation.d.ts +4 -4
  113. package/dist/overflow-list/foundation.js +18 -18
  114. package/dist/pagination/foundation.d.ts +8 -8
  115. package/dist/pagination/foundation.js +28 -28
  116. package/dist/pincode/foundation.d.ts +5 -5
  117. package/dist/pincode/foundation.js +22 -22
  118. package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
  119. package/dist/popconfirm/popconfirm-foundation.js +26 -26
  120. package/dist/radio/radio-foundation.d.ts +5 -5
  121. package/dist/radio/radio-foundation.js +15 -15
  122. package/dist/radio/radio-group-foundation.d.ts +2 -2
  123. package/dist/radio/radio-group-foundation.js +9 -9
  124. package/dist/rating/foundation.d.ts +10 -10
  125. package/dist/rating/foundation.js +35 -35
  126. package/dist/resizable/group/index.d.ts +6 -6
  127. package/dist/resizable/group/index.js +40 -40
  128. package/dist/resizable/single/index.d.ts +2 -2
  129. package/dist/resizable/single/index.js +9 -9
  130. package/dist/scroll-list/item-foundation.d.ts +7 -7
  131. package/dist/scroll-list/item-foundation.js +35 -35
  132. package/dist/select/foundation.d.ts +42 -56
  133. package/dist/select/foundation.js +214 -279
  134. package/dist/select/option-foundation.d.ts +23 -27
  135. package/dist/select/option-foundation.js +10 -18
  136. package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
  137. package/dist/side-sheet/side-sheet-foundation.js +22 -22
  138. package/dist/slider/foundation.d.ts +16 -16
  139. package/dist/slider/foundation.js +46 -46
  140. package/dist/sortable/accessibility.d.ts +1 -1
  141. package/dist/sortable/accessibility.js +2 -2
  142. package/dist/spin/foundation.d.ts +2 -2
  143. package/dist/spin/foundation.js +6 -6
  144. package/dist/steps/utils.d.ts +1 -1
  145. package/dist/switch/foundation.d.ts +2 -2
  146. package/dist/switch/foundation.js +7 -7
  147. package/dist/table/foundation.d.ts +14 -14
  148. package/dist/table/foundation.js +93 -93
  149. package/dist/table/utils.d.ts +2 -2
  150. package/dist/tabs/foundation.d.ts +5 -5
  151. package/dist/tabs/foundation.js +17 -17
  152. package/dist/tag-input/foundation.d.ts +11 -11
  153. package/dist/tag-input/foundation.js +52 -52
  154. package/dist/time-picker/foundation.d.ts +13 -13
  155. package/dist/time-picker/foundation.js +39 -39
  156. package/dist/time-picker/input-foundation.d.ts +4 -4
  157. package/dist/time-picker/input-foundation.js +13 -13
  158. package/dist/toast/toast-list-foundation.d.ts +7 -7
  159. package/dist/toast/toast-list-foundation.js +14 -14
  160. package/dist/tooltip/foundation.d.ts +9 -9
  161. package/dist/tooltip/foundation.js +67 -61
  162. package/dist/transfer/foundation.d.ts +22 -9
  163. package/dist/transfer/foundation.js +38 -23
  164. package/dist/tree/foundation.d.ts +14 -14
  165. package/dist/tree/foundation.js +61 -61
  166. package/dist/tree/shared.d.ts +1 -1
  167. package/dist/tree-select/foundation.d.ts +26 -20
  168. package/dist/tree-select/foundation.js +91 -83
  169. package/dist/typography/ellipsis.d.ts +4 -4
  170. package/dist/typography/ellipsis.js +8 -8
  171. package/dist/typography/format-numeral.d.ts +1 -1
  172. package/dist/typography/format-numeral.js +2 -2
  173. package/dist/upload/constants.d.ts +1 -1
  174. package/dist/upload/foundation.d.ts +17 -17
  175. package/dist/upload/foundation.js +92 -92
  176. package/dist/upload/utils.d.ts +3 -3
  177. package/dist/upload/utils.js +6 -6
  178. package/dist/user-guide/foundation.d.ts +3 -3
  179. package/dist/user-guide/foundation.js +19 -19
  180. package/dist/utils/a11y.d.ts +1 -1
  181. package/dist/utils/announcer.d.ts +2 -2
  182. package/dist/utils/announcer.js +4 -4
  183. package/dist/utils/focus-handle.d.ts +1 -1
  184. package/dist/utils/focus-handle.js +1 -2
  185. package/dist/utils/focus-scope.d.ts +5 -5
  186. package/dist/utils/focus-scope.js +10 -10
  187. package/dist/utils/is-promise.d.ts +1 -1
  188. package/dist/utils/release-holder.d.ts +2 -2
  189. package/dist/utils/release-holder.js +4 -4
  190. package/dist/video-player/foundation.d.ts +15 -15
  191. package/dist/video-player/foundation.js +89 -89
  192. package/dist/video-player/progress-foundation.d.ts +2 -2
  193. package/dist/video-player/progress-foundation.js +12 -12
  194. package/package.json +2 -2
@@ -16,6 +16,6 @@ export interface CheckboxGroupAdapter<P extends CheckboxGroupBaseProps = Checkbo
16
16
  export default class CheckboxGroupFoundation<P extends CheckboxGroupBaseProps = CheckboxGroupBaseProps, S extends CheckboxGroupBaseState = CheckboxGroupBaseState> extends BaseFoundation<CheckboxGroupAdapter<P, S>, P, S> {
17
17
  static deriveValue(props: CheckboxGroupBaseProps, state: CheckboxGroupBaseState): CheckboxValue[];
18
18
  init(): void;
19
- handleChange(evt: BasicCheckboxEvent): void;
20
- handlePropValueChange(newPropValue: unknown): void;
19
+ handleChange: (evt: BasicCheckboxEvent) => void;
20
+ handlePropValueChange: (newPropValue: unknown) => void;
21
21
  }
@@ -10,19 +10,19 @@ var CheckboxGroupFoundation = class CheckboxGroupFoundation extends BaseFoundati
10
10
  if (typeof defaultValue !== "undefined" && !Array.isArray(defaultValue)) warning(true, "Warning: [Semi CheckboxGroup] defaultValue should be an Array");
11
11
  if (typeof value !== "undefined" && !Array.isArray(value)) warning(true, "Warning: [Semi CheckboxGroup] value should be an Array");
12
12
  }
13
- handleChange(evt) {
13
+ handleChange = (evt) => {
14
14
  const prevValue = CheckboxGroupFoundation.deriveValue(this.getProps(), this.getStates());
15
15
  const { checked, value } = evt.target;
16
16
  const newValue = checked ? [...prevValue, value] : prevValue.filter((item) => item !== value);
17
- if (!this._isControlledComponent()) this._adapter.updateGroupValue(newValue);
18
- this._adapter.notifyChange(newValue);
19
- }
20
- handlePropValueChange(newPropValue) {
21
- if (Array.isArray(newPropValue)) this._adapter.updateGroupValue(newPropValue);
17
+ if (!this.isControlledComponent()) this.adapter.updateGroupValue(newValue);
18
+ this.adapter.notifyChange(newValue);
19
+ };
20
+ handlePropValueChange = (newPropValue) => {
21
+ if (Array.isArray(newPropValue)) this.adapter.updateGroupValue(newPropValue);
22
22
  else {
23
- if (typeof newPropValue === "undefined") this._adapter.updateGroupValue([]);
23
+ if (typeof newPropValue === "undefined") this.adapter.updateGroupValue([]);
24
24
  warning(true, "Warning: [Semi CheckboxGroup] value should be an Array");
25
25
  }
26
- }
26
+ };
27
27
  };
28
28
  export { CheckboxGroupFoundation as default };
@@ -21,5 +21,5 @@ export interface CodeHighlightAdapter<P extends CodeHighlightBaseProps = CodeHig
21
21
  export default class CodeHighlightFoundation<P extends CodeHighlightBaseProps = CodeHighlightBaseProps, S extends CodeHighlightBaseState = CodeHighlightBaseState> extends BaseFoundation<CodeHighlightAdapter<P, S>, P, S> {
22
22
  #private;
23
23
  destroy(): void;
24
- highlightCode(): Promise<void>;
24
+ highlightCode: () => Promise<void>;
25
25
  }
@@ -5,7 +5,7 @@ var CodeHighlightFoundation = class extends BaseFoundation {
5
5
  destroy() {
6
6
  this.#requestId++;
7
7
  }
8
- async highlightCode() {
8
+ highlightCode = async () => {
9
9
  const { code = "", language, languages, themes } = this.getProps();
10
10
  const requestId = ++this.#requestId;
11
11
  const { highlight } = await import("./highlighter.js");
@@ -13,7 +13,7 @@ var CodeHighlightFoundation = class extends BaseFoundation {
13
13
  languages,
14
14
  themes
15
15
  });
16
- if (requestId === this.#requestId) this._adapter.setHtml(html, code);
17
- }
16
+ if (requestId === this.#requestId) this.adapter.setHtml(html, code);
17
+ };
18
18
  };
19
19
  export { CodeHighlightFoundation as default };
@@ -42,6 +42,6 @@ export default class CollapseFoundation<E = unknown> extends BaseFoundation<Coll
42
42
  lazyRender: boolean;
43
43
  everOpened: boolean;
44
44
  }): boolean;
45
- syncActiveKey(activeKey: CollapseProps['activeKey']): void;
46
- handleChange(newKey: string, e: E): void;
45
+ syncActiveKey: (activeKey: CollapseProps["activeKey"]) => void;
46
+ handleChange: (newKey: string, e: E) => void;
47
47
  }
@@ -25,20 +25,20 @@ var CollapseFoundation = class CollapseFoundation extends BaseFoundation {
25
25
  static isContentMounted({ hasBody, active, keepDOM, lazyRender, everOpened }) {
26
26
  return hasBody && (active || keepDOM && (!lazyRender || everOpened));
27
27
  }
28
- syncActiveKey(activeKey) {
28
+ syncActiveKey = (activeKey) => {
29
29
  if (activeKey !== void 0) {
30
30
  const newSet = toSet(activeKey);
31
- if (!isEqual(newSet, this.getStates().activeSet)) this._adapter.setActiveSet(newSet);
31
+ if (!isEqual(newSet, this.getStates().activeSet)) this.adapter.setActiveSet(newSet);
32
32
  }
33
- }
34
- handleChange(newKey, e) {
33
+ };
34
+ handleChange = (newKey, e) => {
35
35
  const { activeKey, accordion } = this.getProps();
36
36
  let newSet = new Set(CollapseFoundation.deriveActiveSet(this.getProps(), this.getStates()));
37
37
  if (newSet.has(newKey)) newSet.delete(newKey);
38
38
  else if (accordion) newSet = /* @__PURE__ */ new Set([newKey]);
39
39
  else newSet.add(newKey);
40
- this._adapter.notifyChange([...newSet.values()], e);
41
- if (typeof activeKey === "undefined") this._adapter.setActiveSet(newSet);
42
- }
40
+ this.adapter.notifyChange([...newSet.values()], e);
41
+ if (typeof activeKey === "undefined") this.adapter.setActiveSet(newSet);
42
+ };
43
43
  };
44
44
  export { CollapseFoundation as default };
@@ -56,13 +56,13 @@ export default class CollapsibleFoundation<P extends CollapsibleBaseProps = Coll
56
56
  * height animates between measured lengths instead and its end stands in for the transitionend. Removable, with
57
57
  * the max-height rule of collapsible.scss, once Firefox and Safari support calc-size().
58
58
  */
59
- handleOpenChange(): void;
59
+ handleOpenChange: () => void;
60
60
  /**
61
61
  * `isSelf`: the event comes from the wrapper, not bubbling from the content. Only `height` is awaited: toggling
62
62
  * `isOpen` always transitions it, even when `fade` also animates `opacity`.
63
63
  */
64
- handleTransitionEnd({ isSelf, propertyName }: {
64
+ handleTransitionEnd: ({ isSelf, propertyName }: {
65
65
  isSelf: boolean;
66
66
  propertyName: string;
67
- }): void;
67
+ }) => void;
68
68
  }
@@ -75,9 +75,9 @@ var CollapsibleFoundation = class CollapsibleFoundation extends BaseFoundation {
75
75
  * height animates between measured lengths instead and its end stands in for the transitionend. Removable, with
76
76
  * the max-height rule of collapsible.scss, once Firefox and Safari support calc-size().
77
77
  */
78
- handleOpenChange() {
78
+ handleOpenChange = () => {
79
79
  const { isOpen, duration, collapseHeight, collapseHeightAdaptive } = this.getProps();
80
- const wrapper = this._adapter.getWrapper();
80
+ const wrapper = this.adapter.getWrapper();
81
81
  if (!wrapper || !CollapsibleFoundation.hasMotion(this.getProps()) || CSS.supports("height", "calc-size(auto, size)")) return;
82
82
  const current = this.#heightAnimation && this.#heightAnimation.playState !== "finished" ? wrapper.offsetHeight : void 0;
83
83
  this.#heightAnimation?.cancel();
@@ -108,16 +108,16 @@ var CollapsibleFoundation = class CollapsibleFoundation extends BaseFoundation {
108
108
  });
109
109
  }
110
110
  }, () => void 0);
111
- }
111
+ };
112
112
  /**
113
113
  * `isSelf`: the event comes from the wrapper, not bubbling from the content. Only `height` is awaited: toggling
114
114
  * `isOpen` always transitions it, even when `fade` also animates `opacity`.
115
115
  */
116
- handleTransitionEnd({ isSelf, propertyName }) {
116
+ handleTransitionEnd = ({ isSelf, propertyName }) => {
117
117
  if (!isSelf || propertyName !== "height") return;
118
- if (!this.getProp("isOpen")) this._adapter.setVisible(false);
119
- this._adapter.setIsTransitioning(false);
120
- this._adapter.notifyMotionEnd();
121
- }
118
+ if (!this.getProp("isOpen")) this.adapter.setVisible(false);
119
+ this.adapter.setIsTransitioning(false);
120
+ this.adapter.notifyMotionEnd();
121
+ };
122
122
  };
123
123
  export { CollapsibleFoundation as default };
@@ -15,15 +15,13 @@ export interface AlphaSliderAdapter<P extends AlphaSliderBaseProps = AlphaSlider
15
15
  getDOM: () => HTMLDivElement;
16
16
  }
17
17
  export default class AlphaSliderFoundation<P extends AlphaSliderBaseProps = AlphaSliderBaseProps, S extends AlphaSliderBaseState = AlphaSliderBaseState> extends BaseFoundation<AlphaSliderAdapter<P, S>, P, S> {
18
+ #private;
18
19
  constructor(adapter: AlphaSliderAdapter<P, S>);
19
20
  /** Captures the pointer from the press, so moves and release arrive outside the slider too */
20
21
  handlePointerDown: (e: DragPointerEvent) => void;
21
22
  handlePointerMove: (e: DragPointerEvent) => void;
22
23
  /** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
23
24
  handleLostPointerCapture: () => void;
24
- setValue(percent: number): void;
25
+ setValue: (percent: number) => void;
25
26
  handleKeyDown: (e: RangeKeyEvent) => void;
26
- pickByPointer: (e: {
27
- clientX: number;
28
- }) => void;
29
27
  }
@@ -7,23 +7,29 @@ var AlphaSliderFoundation = class extends BaseFoundation {
7
7
  constructor(adapter) {
8
8
  super({ ...adapter });
9
9
  }
10
+ #pickByPointer(e) {
11
+ const rect = this.adapter.getDOM()?.getBoundingClientRect();
12
+ if (!rect) return;
13
+ const { width, foundation } = this.getProps();
14
+ foundation.handleAlphaChangeByHandle({ a: Number(clamp((e.clientX - rect.x) / width, 0, 1).toFixed(2)) });
15
+ }
10
16
  /** Captures the pointer from the press, so moves and release arrive outside the slider too */
11
17
  handlePointerDown = (e) => {
12
18
  if (isSecondaryPress(e)) return;
13
19
  e.currentTarget.setPointerCapture(e.pointerId);
14
20
  this.setState({ isHandleGrabbing: true });
15
- this.pickByPointer(e);
21
+ this.#pickByPointer(e);
16
22
  };
17
23
  handlePointerMove = (e) => {
18
- if (this.getState("isHandleGrabbing")) this.pickByPointer(e);
24
+ if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
19
25
  };
20
26
  /** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
21
27
  handleLostPointerCapture = () => {
22
28
  this.setState({ isHandleGrabbing: false });
23
29
  };
24
- setValue(percent) {
30
+ setValue = (percent) => {
25
31
  this.getProps().foundation.handleAlphaChangeByHandle({ a: percent / 100 });
26
- }
32
+ };
27
33
  handleKeyDown = (e) => {
28
34
  if (e.altKey || e.ctrlKey || e.metaKey) return;
29
35
  const percent = ColorPickerFoundation.getValueByKey(e.key, this.getProps().hsva.a * 100, 100);
@@ -31,11 +37,5 @@ var AlphaSliderFoundation = class extends BaseFoundation {
31
37
  e.preventDefault();
32
38
  this.setValue(percent);
33
39
  };
34
- pickByPointer = (e) => {
35
- const rect = this._adapter.getDOM()?.getBoundingClientRect();
36
- if (!rect) return;
37
- const { width, foundation } = this.getProps();
38
- foundation.handleAlphaChangeByHandle({ a: Number(clamp((e.clientX - rect.x) / width, 0, 1).toFixed(2)) });
39
- };
40
40
  };
41
41
  export { AlphaSliderFoundation as default };
@@ -21,16 +21,13 @@ export interface ColorChooseAreaAdapter<P extends ColorChooseAreaBaseProps = Col
21
21
  }) => void;
22
22
  }
23
23
  export default class ColorChooseAreaFoundation<P extends ColorChooseAreaBaseProps = ColorChooseAreaBaseProps, S extends ColorChooseAreaBaseState = ColorChooseAreaBaseState> extends BaseFoundation<ColorChooseAreaAdapter<P, S>, P, S> {
24
+ #private;
24
25
  constructor(adapter: ColorChooseAreaAdapter<P, S>);
25
- setValue(axis: 's' | 'v', value: number): void;
26
+ setValue: (axis: "s" | "v", value: number) => void;
26
27
  handleKeyDown: (focusedAxis: "s" | "v", e: RangeKeyEvent) => void;
27
28
  /** Captures the pointer from the press; positions outside pick the nearest edge or corner */
28
29
  handlePointerDown: (e: DragPointerEvent) => void;
29
30
  handlePointerMove: (e: DragPointerEvent) => void;
30
31
  /** Follows pointerup and pointercancel; also fires when the area leaves the page mid-drag */
31
32
  handleLostPointerCapture: () => void;
32
- pickByPointer: (e: {
33
- clientX: number;
34
- clientY: number;
35
- }) => void;
36
33
  }
@@ -7,14 +7,23 @@ var ColorChooseAreaFoundation = class extends BaseFoundation {
7
7
  constructor(adapter) {
8
8
  super({ ...adapter });
9
9
  }
10
- setValue(axis, value) {
10
+ #pickByPointer(e) {
11
+ const rect = this.adapter.getDOM()?.getBoundingClientRect();
12
+ if (!rect) return;
13
+ const { width, height } = this.getProps();
14
+ this.adapter.notifyChange({
15
+ s: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 100),
16
+ v: Math.round(100 - clamp((e.clientY - rect.y) / height, 0, 1) * 100)
17
+ });
18
+ }
19
+ setValue = (axis, value) => {
11
20
  const { hsva } = this.getProps();
12
- this._adapter.notifyChange({
21
+ this.adapter.notifyChange({
13
22
  s: hsva.s,
14
23
  v: hsva.v,
15
24
  [axis]: value
16
25
  });
17
- }
26
+ };
18
27
  handleKeyDown = (focusedAxis, e) => {
19
28
  if (e.altKey || e.ctrlKey || e.metaKey) return;
20
29
  let axis = focusedAxis;
@@ -35,23 +44,14 @@ var ColorChooseAreaFoundation = class extends BaseFoundation {
35
44
  if (isSecondaryPress(e)) return;
36
45
  e.currentTarget.setPointerCapture(e.pointerId);
37
46
  this.setState({ isHandleGrabbing: true });
38
- this.pickByPointer(e);
47
+ this.#pickByPointer(e);
39
48
  };
40
49
  handlePointerMove = (e) => {
41
- if (this.getState("isHandleGrabbing")) this.pickByPointer(e);
50
+ if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
42
51
  };
43
52
  /** Follows pointerup and pointercancel; also fires when the area leaves the page mid-drag */
44
53
  handleLostPointerCapture = () => {
45
54
  this.setState({ isHandleGrabbing: false });
46
55
  };
47
- pickByPointer = (e) => {
48
- const rect = this._adapter.getDOM()?.getBoundingClientRect();
49
- if (!rect) return;
50
- const { width, height } = this.getProps();
51
- this._adapter.notifyChange({
52
- s: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 100),
53
- v: Math.round(100 - clamp((e.clientY - rect.y) / height, 0, 1) * 100)
54
- });
55
- };
56
56
  };
57
57
  export { ColorChooseAreaFoundation as default };
@@ -15,15 +15,13 @@ export interface ColorSliderAdapter<P extends ColorSliderBaseProps = ColorSlider
15
15
  getDOM: () => HTMLDivElement;
16
16
  }
17
17
  export default class ColorSliderFoundation<P extends ColorSliderBaseProps = ColorSliderBaseProps, S extends ColorSliderBaseState = ColorSliderBaseState> extends BaseFoundation<ColorSliderAdapter<P, S>, P, S> {
18
+ #private;
18
19
  constructor(adapter: ColorSliderAdapter<P, S>);
19
20
  /** Captures the pointer from the press, so moves and release arrive outside the slider too */
20
21
  handlePointerDown: (e: DragPointerEvent) => void;
21
22
  handlePointerMove: (e: DragPointerEvent) => void;
22
23
  /** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
23
24
  handleLostPointerCapture: () => void;
24
- setValue(h: number): void;
25
+ setValue: (h: number) => void;
25
26
  handleKeyDown: (e: RangeKeyEvent) => void;
26
- pickByPointer: (e: {
27
- clientX: number;
28
- }) => void;
29
27
  }
@@ -7,23 +7,29 @@ var ColorSliderFoundation = class extends BaseFoundation {
7
7
  constructor(adapter) {
8
8
  super({ ...adapter });
9
9
  }
10
+ #pickByPointer(e) {
11
+ const rect = this.adapter.getDOM()?.getBoundingClientRect();
12
+ if (!rect) return;
13
+ const { width, foundation } = this.getProps();
14
+ foundation.handleColorChangeByHandle({ h: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 360) });
15
+ }
10
16
  /** Captures the pointer from the press, so moves and release arrive outside the slider too */
11
17
  handlePointerDown = (e) => {
12
18
  if (isSecondaryPress(e)) return;
13
19
  e.currentTarget.setPointerCapture(e.pointerId);
14
20
  this.setState({ isHandleGrabbing: true });
15
- this.pickByPointer(e);
21
+ this.#pickByPointer(e);
16
22
  };
17
23
  handlePointerMove = (e) => {
18
- if (this.getState("isHandleGrabbing")) this.pickByPointer(e);
24
+ if (this.getState("isHandleGrabbing")) this.#pickByPointer(e);
19
25
  };
20
26
  /** Follows pointerup and pointercancel; also fires when the slider leaves the page mid-drag */
21
27
  handleLostPointerCapture = () => {
22
28
  this.setState({ isHandleGrabbing: false });
23
29
  };
24
- setValue(h) {
30
+ setValue = (h) => {
25
31
  this.getProps().foundation.handleColorChangeByHandle({ h });
26
- }
32
+ };
27
33
  handleKeyDown = (e) => {
28
34
  if (e.altKey || e.ctrlKey || e.metaKey) return;
29
35
  const h = ColorPickerFoundation.getValueByKey(e.key, this.getProps().hue, 360);
@@ -31,11 +37,5 @@ var ColorSliderFoundation = class extends BaseFoundation {
31
37
  e.preventDefault();
32
38
  this.setValue(h);
33
39
  };
34
- pickByPointer = (e) => {
35
- const rect = this._adapter.getDOM()?.getBoundingClientRect();
36
- if (!rect) return;
37
- const { width, foundation } = this.getProps();
38
- foundation.handleColorChangeByHandle({ h: Math.round(clamp((e.clientX - rect.x) / width, 0, 1) * 360) });
39
- };
40
40
  };
41
41
  export { ColorSliderFoundation as default };
@@ -18,11 +18,11 @@ export default class DataPartFoundation<P extends DataPartBaseProps = DataPartBa
18
18
  #private;
19
19
  constructor(adapter: DataPartAdapter<P, S>);
20
20
  static getInputValue(currentColor: ColorValue, format: ColorFormat): string;
21
- syncInputValue(): void;
21
+ syncInputValue: () => void;
22
22
  /** Whether the text box already says `color`, so it must not overwrite what is being typed */
23
- isInputValueOf(color: ColorValue): boolean;
24
- getValueByInputValue(value: string): string | false | RgbaColor | HsvaColor;
23
+ isInputValueOf: (color: ColorValue) => boolean;
24
+ getValueByInputValue: (value: string) => string | false | RgbaColor | HsvaColor;
25
25
  handlePickValueWithStraw: () => Promise<void>;
26
- handleInputValueChange(value: string): void;
27
- handleFormatChange(format: ColorFormat): void;
26
+ handleInputValueChange: (value: string) => void;
27
+ handleFormatChange: (format: ColorFormat) => void;
28
28
  }
@@ -23,17 +23,17 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
23
23
  else if (format === "hsva") return `${hsva.h},${hsva.s},${hsva.v}`;
24
24
  else return hex.slice(0, 7);
25
25
  }
26
- syncInputValue() {
26
+ syncInputValue = () => {
27
27
  this.setState({ inputValue: DataPartFoundation.getInputValue(this.getProp("currentColor"), this.getState("format")) });
28
- }
28
+ };
29
29
  /** Whether the text box already says `color`, so it must not overwrite what is being typed */
30
- isInputValueOf(color) {
30
+ isInputValueOf = (color) => {
31
31
  const { format, inputValue } = this.getStates();
32
32
  const parsed = this.getValueByInputValue(inputValue);
33
33
  if (!parsed || format === "hex" && !inputValue.startsWith("#")) return false;
34
34
  return isEqual(ColorPickerFoundation.getColorValue(parsed, format, Boolean(this.getProp("alpha"))), color);
35
- }
36
- getValueByInputValue(value) {
35
+ };
36
+ getValueByInputValue = (value) => {
37
37
  const { format } = this.getStates();
38
38
  if (format === "rgba" || format === "hsva") {
39
39
  const parsed = format === "rgba" ? split(value, "rgba") : split(value, "hsva");
@@ -48,7 +48,7 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
48
48
  if (/^#[0-9a-f]{8}$/i.test(value)) return value;
49
49
  }
50
50
  return false;
51
- }
51
+ };
52
52
  handlePickValueWithStraw = async () => {
53
53
  const colorPickerFoundation = this.getProps().foundation;
54
54
  if (!window.EyeDropper) return;
@@ -63,14 +63,14 @@ var DataPartFoundation = class DataPartFoundation extends BaseFoundation {
63
63
  if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
64
64
  }
65
65
  };
66
- handleInputValueChange(value) {
67
- this._adapter.setState({ inputValue: value });
68
- }
69
- handleFormatChange(format) {
66
+ handleInputValueChange = (value) => {
67
+ this.adapter.setState({ inputValue: value });
68
+ };
69
+ handleFormatChange = (format) => {
70
70
  this.setState({
71
71
  format,
72
72
  inputValue: DataPartFoundation.getInputValue(this.getProp("currentColor"), format)
73
73
  });
74
- }
74
+ };
75
75
  };
76
76
  export { DataPartFoundation as default };
@@ -45,11 +45,11 @@ export default class ColorPickerFoundation<P extends ColorPickerProps = ColorPic
45
45
  */
46
46
  static getValueByKey(key: string, value: number, max: number): number;
47
47
  /** After a controlled `value` is dropped, the uncontrolled state restarts from `defaultValue` */
48
- resetToDefault(): void;
49
- handleChange(color: HsvaColor | RgbaColor | string, format: ColorFormat): void;
50
- handleAlphaChangeByHandle(newAlpha: {
48
+ resetToDefault: () => void;
49
+ handleChange: (color: HsvaColor | RgbaColor | string, format: ColorFormat) => void;
50
+ handleAlphaChangeByHandle: (newAlpha: {
51
51
  a: number;
52
- }): void;
52
+ }) => void;
53
53
  handleColorChangeByHandle(newHue: {
54
54
  h: number;
55
55
  }): void;
@@ -8,8 +8,8 @@ var ColorPickerFoundation = class ColorPickerFoundation extends BaseFoundation {
8
8
  super({ ...adapter });
9
9
  }
10
10
  #commit(color) {
11
- this._adapter.notifyChange(color);
12
- if (!this._isControlledComponent("value")) this._adapter.setState({ currentColor: color });
11
+ this.adapter.notifyChange(color);
12
+ if (!this.isControlledComponent("value")) this.adapter.setState({ currentColor: color });
13
13
  }
14
14
  handleChangeH(currentColor, newH) {
15
15
  const hsva = {
@@ -38,7 +38,7 @@ var ColorPickerFoundation = class ColorPickerFoundation extends BaseFoundation {
38
38
  });
39
39
  }
40
40
  getCurrentColor() {
41
- return this._isControlledComponent("value") ? this.getProp("value") ?? this.getProp("defaultValue") : this.getState("currentColor");
41
+ return this.isControlledComponent("value") ? this.getProp("value") ?? this.getProp("defaultValue") : this.getState("currentColor");
42
42
  }
43
43
  /** The full color of a value given in `format`; without alpha support the opacity is dropped */
44
44
  static getColorValue(color, format, alpha) {
@@ -133,15 +133,15 @@ var ColorPickerFoundation = class ColorPickerFoundation extends BaseFoundation {
133
133
  }
134
134
  }
135
135
  /** After a controlled `value` is dropped, the uncontrolled state restarts from `defaultValue` */
136
- resetToDefault() {
137
- this._adapter.setState({ currentColor: this.getProp("defaultValue") });
138
- }
139
- handleChange(color, format) {
136
+ resetToDefault = () => {
137
+ this.adapter.setState({ currentColor: this.getProp("defaultValue") });
138
+ };
139
+ handleChange = (color, format) => {
140
140
  this.#commit(ColorPickerFoundation.getColorValue(color, format, Boolean(this.getProp("alpha"))));
141
- }
142
- handleAlphaChangeByHandle(newAlpha) {
141
+ };
142
+ handleAlphaChangeByHandle = (newAlpha) => {
143
143
  this.handleChangeA(this.getCurrentColor(), newAlpha.a);
144
- }
144
+ };
145
145
  handleColorChangeByHandle(newHue) {
146
146
  this.handleChangeH(this.getCurrentColor(), newHue.h);
147
147
  }
@@ -13,9 +13,9 @@ export interface ObserveProps {
13
13
  export default class BreakpointObserver {
14
14
  #private;
15
15
  constructor(props: ObserveProps, render: (screens: BreakpointScreens) => void);
16
- sync(props: ObserveProps): void;
17
- commit(): void;
18
- destroy(): void;
16
+ sync: (props: ObserveProps) => void;
17
+ commit: () => void;
18
+ destroy: () => void;
19
19
  subscribe: {
20
20
  (callback: OnBreakpointScreensCallback): () => void;
21
21
  (breakpoints: Breakpoint[], callback: OnBreakpointChangeCallback): () => void;
@@ -81,10 +81,10 @@ var BreakpointObserver = class {
81
81
  if (!breakpoints || breakpoints.includes(screen)) callback(screen, matches);
82
82
  });
83
83
  }
84
- sync(props) {
84
+ sync = (props) => {
85
85
  this.#props = props;
86
- }
87
- commit() {
86
+ };
87
+ commit = () => {
88
88
  const prev = this.#committed;
89
89
  const props = this.#props;
90
90
  const prevScreens = this.#screens;
@@ -103,12 +103,12 @@ var BreakpointObserver = class {
103
103
  for (const screen of changed) if (!breakpoints || breakpoints.includes(screen)) callback(screen, screens[screen]);
104
104
  });
105
105
  }
106
- }
107
- destroy() {
106
+ };
107
+ destroy = () => {
108
108
  this.#unregister();
109
109
  this.#screensListeners.clear();
110
110
  this.#changeListeners.clear();
111
- }
111
+ };
112
112
  subscribe = (arg1, arg2) => {
113
113
  if (typeof arg1 === "function") {
114
114
  this.#screensListeners.add(arg1);
@@ -51,41 +51,41 @@ export interface CropperState {
51
51
  }
52
52
  export default class CropperFoundation extends BaseFoundation<CropperAdapter<CropperFoundationProps>, CropperFoundationProps, CropperState> {
53
53
  #private;
54
- handleCornerPointerMove: (e: any) => void;
54
+ handleCornerPointerMove: (e: Pick<PointerEvent, "clientX" | "clientY" | "preventDefault">) => void;
55
55
  /** Follows pointerup and pointercancel; also fires when the corner leaves the page mid-drag */
56
56
  handleCornerLostPointerCapture: () => void;
57
- handleCropperBoxPointerMove: ({ clientX, clientY }: any) => void;
57
+ handleCropperBoxPointerMove: ({ clientX, clientY }: Pick<PointerEvent, "clientX" | "clientY">) => void;
58
58
  handleCropperBoxLostPointerCapture: () => void;
59
- handleMaskPointerMove: ({ clientX, clientY }: any) => void;
59
+ handleMaskPointerMove: ({ clientX, clientY }: Pick<PointerEvent, "clientX" | "clientY">) => void;
60
60
  handleMaskLostPointerCapture: () => void;
61
61
  init(): void;
62
62
  destroy(): void;
63
- handleResize(): void;
63
+ handleResize: () => void;
64
64
  /**
65
65
  * Refits the crop box to a changed `aspectRatio`: height stays, width follows, and a box too big for the
66
66
  * container shrinks. It stays centered, moved only as far as the container edges require.
67
67
  */
68
- applyAspectRatio(): void;
69
- handleImageLoad(e: any): void;
68
+ applyAspectRatio: () => void;
69
+ handleImageLoad: ({ target }: Pick<Event, "target">) => void;
70
70
  /**
71
71
  * Brings the state to the `rotate` and `zoom` props once the image has loaded; a controlled zoom also undoes
72
72
  * wheel zooming the parent does not accept. Turns and scales around the cropper box center.
73
73
  */
74
- syncRotateAndZoom({ rotate: newRotate, zoom: newZoom }?: {
74
+ syncRotateAndZoom: ({ rotate: newRotate, zoom: newZoom }?: {
75
75
  rotate?: number;
76
76
  zoom?: number;
77
- }): void;
78
- handleWheel: (e: any) => void;
79
- updatePreview(): void;
80
- handleCornerPointerDown: (e: any) => void;
81
- handleCropperBoxPointerDown: (e: any) => void;
77
+ }) => void;
78
+ handleWheel: (e: Pick<WheelEvent, "clientX" | "clientY" | "deltaY" | "preventDefault">) => void;
79
+ updatePreview: () => void;
80
+ handleCornerPointerDown: (e: Pick<PointerEvent, "button" | "currentTarget" | "pointerId" | "preventDefault">) => void;
81
+ handleCropperBoxPointerDown: (e: Pick<PointerEvent, "button" | "clientX" | "clientY" | "currentTarget" | "pointerId" | "target">) => void;
82
82
  /**
83
83
  * Moves the box with the arrow keys by KEYBOARD_STEP px; Shift moves the bottom right corner instead, through
84
84
  * the drag path, so the box keeps to the container and the aspect ratio. Only with resize handles shown, as
85
85
  * with a pointer.
86
86
  */
87
- handleCropperBoxKeyDown: (e: any) => void;
88
- handleMaskPointerDown: (e: any) => void;
89
- getCropperCanvas(): HTMLCanvasElement;
87
+ handleCropperBoxKeyDown: (e: Pick<KeyboardEvent, "altKey" | "ctrlKey" | "key" | "metaKey" | "preventDefault" | "shiftKey">) => void;
88
+ handleMaskPointerDown: (e: Pick<PointerEvent, "button" | "clientX" | "clientY" | "currentTarget" | "pointerId" | "target">) => void;
89
+ getCropperCanvas: () => HTMLCanvasElement;
90
90
  }
91
91
  export {};