@astryxdesign/core 0.7.7-canary.fc68123 → 0.7.7

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 (240) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/AlertDialog/AlertDialog.d.ts +1 -4
  3. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  4. package/dist/AlertDialog/AlertDialog.js +6 -36
  5. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  6. package/dist/BottomSheet/BottomSheetPanel.js +4 -23
  7. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  8. package/dist/BottomSheet/useSheetGestures.js +1 -3
  9. package/dist/Button/Button.d.ts.map +1 -1
  10. package/dist/Button/Button.js +1 -17
  11. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  12. package/dist/CheckboxInput/CheckboxInput.js +2 -13
  13. package/dist/ComplexSelector/ComplexSelector.d.ts +1 -4
  14. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  15. package/dist/ComplexSelector/ComplexSelector.js +4 -14
  16. package/dist/ContextMenu/ContextMenu.js +2 -2
  17. package/dist/Dialog/Dialog.d.ts.map +1 -1
  18. package/dist/Dialog/Dialog.js +31 -7
  19. package/dist/Field/Field.js +2 -2
  20. package/dist/HoverCard/HoverCard.d.ts +3 -4
  21. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  22. package/dist/HoverCard/HoverCard.js +2 -27
  23. package/dist/HoverCard/useHoverCard.d.ts +4 -5
  24. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  25. package/dist/HoverCard/useHoverCard.js +31 -17
  26. package/dist/Icon/Icon.d.ts +1 -5
  27. package/dist/Icon/Icon.d.ts.map +1 -1
  28. package/dist/Icon/Icon.js +2 -5
  29. package/dist/Layer/usePressPin.d.ts +5 -17
  30. package/dist/Layer/usePressPin.d.ts.map +1 -1
  31. package/dist/Layer/usePressPin.js +12 -62
  32. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  33. package/dist/Lightbox/Lightbox.js +0 -18
  34. package/dist/PowerSearch/PowerSearch.d.ts +3 -36
  35. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  36. package/dist/PowerSearch/PowerSearch.js +127 -433
  37. package/dist/PowerSearch/PowerSearchEditPopover.d.ts +1 -32
  38. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  39. package/dist/PowerSearch/PowerSearchEditPopover.js +6 -17
  40. package/dist/PowerSearch/PowerSearchValueEditor.d.ts +3 -38
  41. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  42. package/dist/PowerSearch/PowerSearchValueEditor.js +61 -170
  43. package/dist/PowerSearch/formatFilterValue.d.ts +0 -7
  44. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  45. package/dist/PowerSearch/formatFilterValue.js +1 -11
  46. package/dist/RadioList/RadioList.d.ts.map +1 -1
  47. package/dist/RadioList/RadioList.js +2 -3
  48. package/dist/RadioList/RadioListItem.d.ts +1 -1
  49. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  50. package/dist/RadioList/RadioListItem.js +3 -5
  51. package/dist/Resizable/ResizeHandle.d.ts +1 -2
  52. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  53. package/dist/Resizable/ResizeHandle.js +77 -99
  54. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
  55. package/dist/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
  56. package/dist/Slider/sliderTouchController.js +2 -2
  57. package/dist/Spinner/Spinner.d.ts +1 -1
  58. package/dist/Spinner/Spinner.d.ts.map +1 -1
  59. package/dist/Spinner/Spinner.js +58 -60
  60. package/dist/Switch/useSwitchTouch.js +4 -4
  61. package/dist/Table/BaseTable.d.ts.map +1 -1
  62. package/dist/Table/BaseTable.js +8 -29
  63. package/dist/TextInput/TextInput.d.ts +2 -2
  64. package/dist/TextInput/TextInput.d.ts.map +1 -1
  65. package/dist/TextInput/TextInput.js +7 -10
  66. package/dist/Toast/Toast.d.ts +1 -11
  67. package/dist/Toast/Toast.d.ts.map +1 -1
  68. package/dist/Toast/Toast.js +15 -25
  69. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  70. package/dist/Toast/ToastViewport.js +34 -94
  71. package/dist/Toast/types.d.ts +3 -9
  72. package/dist/Toast/types.d.ts.map +1 -1
  73. package/dist/Tooltip/useTooltip.d.ts +1 -19
  74. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  75. package/dist/Tooltip/useTooltip.js +53 -34
  76. package/dist/Typeahead/TypeaheadItem.d.ts +1 -2
  77. package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
  78. package/dist/astryx.css +6 -35
  79. package/dist/gestures/PressTracker.d.ts.map +1 -1
  80. package/dist/gestures/PressTracker.js +3 -4
  81. package/dist/hooks/actionGroupTracker.d.ts +1 -4
  82. package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
  83. package/dist/hooks/actionGroupTracker.js +3 -13
  84. package/dist/hooks/index.d.ts +0 -1
  85. package/dist/hooks/index.d.ts.map +1 -1
  86. package/dist/hooks/index.js +0 -1
  87. package/dist/hooks/useAttachment.d.ts +1 -1
  88. package/dist/hooks/useAttachment.js +1 -1
  89. package/dist/hooks/useInputStatusIcon.d.ts +1 -1
  90. package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
  91. package/dist/hooks/useInputStatusIcon.js +2 -2
  92. package/dist/hooks/useLongPress.d.ts +2 -6
  93. package/dist/hooks/useLongPress.d.ts.map +1 -1
  94. package/dist/hooks/useLongPress.js +15 -95
  95. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
  96. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +0 -6
  97. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  98. package/dist/i18n/generated-locales/en.generated.js +0 -30
  99. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  100. package/dist/i18n/generated-locales/pseudo.generated.js +0 -30
  101. package/dist/index.d.ts +0 -1
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +0 -4
  104. package/dist/motion/animatedLayout.d.ts.map +1 -1
  105. package/dist/motion/animatedLayout.js +6 -5
  106. package/dist/motion/animator.d.ts +14 -14
  107. package/dist/motion/animator.d.ts.map +1 -1
  108. package/dist/motion/animator.js +18 -41
  109. package/dist/utils/dateParser.d.ts.map +1 -1
  110. package/dist/utils/dateParser.js +0 -12
  111. package/dist/utils/focusReturn.d.ts +0 -15
  112. package/dist/utils/focusReturn.d.ts.map +1 -1
  113. package/dist/utils/focusReturn.js +0 -28
  114. package/dist/utils/interactionOverlay.stylex.d.ts +2 -3
  115. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  116. package/dist/utils/interactionOverlay.stylex.js +2 -3
  117. package/dist/utils/pressFeedback.d.ts.map +1 -1
  118. package/dist/utils/pressFeedback.js +6 -19
  119. package/locales/en.json +0 -120
  120. package/locales/pseudo.json +0 -90
  121. package/package.json +5 -10
  122. package/src/AlertDialog/AlertDialog.doc.mjs +2 -2
  123. package/src/AlertDialog/AlertDialog.tsx +5 -37
  124. package/src/BottomSheet/BottomSheetPanel.tsx +3 -37
  125. package/src/BottomSheet/useSheetGestures.ts +1 -3
  126. package/src/Button/Button.tsx +4 -26
  127. package/src/CheckboxInput/CheckboxInput.doc.mjs +0 -18
  128. package/src/CheckboxInput/CheckboxInput.tsx +9 -36
  129. package/src/ComplexSelector/ComplexSelector.tsx +5 -20
  130. package/src/ContextMenu/ContextMenu.tsx +2 -2
  131. package/src/Dialog/Dialog.tsx +31 -10
  132. package/src/Field/Field.tsx +2 -2
  133. package/src/HoverCard/HoverCard.doc.mjs +2 -4
  134. package/src/HoverCard/HoverCard.tsx +4 -35
  135. package/src/HoverCard/useHoverCard.doc.mjs +36 -178
  136. package/src/HoverCard/useHoverCard.tsx +52 -46
  137. package/src/Icon/Icon.doc.mjs +8 -49
  138. package/src/Icon/Icon.tsx +7 -15
  139. package/src/Layer/usePressPin.ts +15 -81
  140. package/src/Lightbox/Lightbox.tsx +0 -18
  141. package/src/PowerSearch/PowerSearch.doc.mjs +5 -54
  142. package/src/PowerSearch/PowerSearch.tsx +155 -609
  143. package/src/PowerSearch/PowerSearchEditPopover.tsx +6 -28
  144. package/src/PowerSearch/PowerSearchValueEditor.tsx +38 -203
  145. package/src/PowerSearch/formatFilterValue.ts +1 -18
  146. package/src/RadioList/RadioList.tsx +2 -3
  147. package/src/RadioList/RadioListItem.tsx +3 -5
  148. package/src/Resizable/Resizable.doc.mjs +4 -5
  149. package/src/Resizable/ResizeHandle.tsx +109 -167
  150. package/src/SegmentedControl/useSegmentedSelectionMotion.ts +3 -6
  151. package/src/Slider/sliderTouchController.ts +2 -2
  152. package/src/Spinner/Spinner.tsx +63 -77
  153. package/src/Switch/useSwitchTouch.ts +4 -4
  154. package/src/Table/BaseTable.tsx +12 -46
  155. package/src/TextInput/TextInput.tsx +10 -11
  156. package/src/Toast/Toast.doc.mjs +3 -4
  157. package/src/Toast/Toast.tsx +32 -52
  158. package/src/Toast/ToastViewport.tsx +35 -121
  159. package/src/Toast/types.ts +3 -9
  160. package/src/Tooltip/useTooltip.doc.mjs +0 -24
  161. package/src/Tooltip/useTooltip.tsx +56 -61
  162. package/src/Typeahead/TypeaheadItem.doc.mjs +3 -6
  163. package/src/Typeahead/TypeaheadItem.tsx +1 -2
  164. package/src/gestures/PressTracker.ts +3 -4
  165. package/src/gestures/README.md +1 -7
  166. package/src/hooks/actionGroupTracker.ts +5 -20
  167. package/src/hooks/index.ts +0 -2
  168. package/src/hooks/useAttachment.ts +1 -1
  169. package/src/hooks/useInputStatusIcon.tsx +2 -3
  170. package/src/hooks/useLongPress.doc.mjs +2 -2
  171. package/src/hooks/useLongPress.ts +15 -136
  172. package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +0 -6
  173. package/src/i18n/generated-locales/en.generated.ts +0 -41
  174. package/src/i18n/generated-locales/pseudo.generated.ts +0 -42
  175. package/src/index.ts +0 -13
  176. package/src/motion/README.md +5 -9
  177. package/src/motion/animatedLayout.ts +4 -5
  178. package/src/motion/animator.ts +29 -61
  179. package/src/utils/dateParser.ts +0 -16
  180. package/src/utils/focusReturn.ts +0 -30
  181. package/src/utils/interactionOverlay.stylex.ts +2 -3
  182. package/src/utils/pressFeedback.ts +6 -19
  183. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +0 -100
  184. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +0 -1
  185. package/dist/PowerSearch/PowerSearchBottomSheet.js +0 -1913
  186. package/dist/PowerSearch/formatTokenValue.d.ts +0 -28
  187. package/dist/PowerSearch/formatTokenValue.d.ts.map +0 -1
  188. package/dist/PowerSearch/formatTokenValue.js +0 -160
  189. package/dist/PowerSearch/powerSearchSheetUtils.d.ts +0 -65
  190. package/dist/PowerSearch/powerSearchSheetUtils.d.ts.map +0 -1
  191. package/dist/PowerSearch/powerSearchSheetUtils.js +0 -168
  192. package/dist/animator/createAnimator.d.ts +0 -98
  193. package/dist/animator/createAnimator.d.ts.map +0 -1
  194. package/dist/animator/createAnimator.js +0 -259
  195. package/dist/hooks/pressGroupContext.d.ts +0 -6
  196. package/dist/hooks/pressGroupContext.d.ts.map +0 -1
  197. package/dist/hooks/pressGroupContext.js +0 -20
  198. package/dist/hooks/useActionGroupTracking.d.ts +0 -53
  199. package/dist/hooks/useActionGroupTracking.d.ts.map +0 -1
  200. package/dist/hooks/useActionGroupTracking.js +0 -174
  201. package/dist/hooks/useAnimator.d.ts +0 -41
  202. package/dist/hooks/useAnimator.d.ts.map +0 -1
  203. package/dist/hooks/useAnimator.js +0 -70
  204. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts +0 -8
  205. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +0 -1
  206. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +0 -42
  207. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts +0 -8
  208. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts.map +0 -1
  209. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.js +0 -14
  210. package/dist/internal/indicatorPress.stylex.d.ts +0 -20
  211. package/dist/internal/indicatorPress.stylex.d.ts.map +0 -1
  212. package/dist/internal/indicatorPress.stylex.js +0 -26
  213. package/dist/motion/progress.d.ts +0 -88
  214. package/dist/motion/progress.d.ts.map +0 -1
  215. package/dist/motion/progress.js +0 -128
  216. package/dist/motion/uikit/alert.d.ts +0 -41
  217. package/dist/motion/uikit/alert.d.ts.map +0 -1
  218. package/dist/motion/uikit/alert.js +0 -43
  219. package/dist/privateAttributes/pressGroupItem.stylex.d.ts +0 -15
  220. package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +0 -1
  221. package/dist/privateAttributes/pressGroupItem.stylex.js +0 -23
  222. package/dist/utils/triggerFocus.d.ts +0 -36
  223. package/dist/utils/triggerFocus.d.ts.map +0 -1
  224. package/dist/utils/triggerFocus.js +0 -65
  225. package/src/PowerSearch/PowerSearchBottomSheet.tsx +0 -2515
  226. package/src/PowerSearch/formatTokenValue.ts +0 -215
  227. package/src/PowerSearch/powerSearchSheetUtils.ts +0 -224
  228. package/src/animator/createAnimator.doc.mjs +0 -153
  229. package/src/animator/createAnimator.ts +0 -324
  230. package/src/hooks/pressGroupContext.ts +0 -21
  231. package/src/hooks/useActionGroupTracking.ts +0 -224
  232. package/src/hooks/useAnimator.doc.mjs +0 -109
  233. package/src/hooks/useAnimator.ts +0 -67
  234. package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +0 -43
  235. package/src/i18n/generated-english/PowerSearch/formatTokenValue.generated.ts +0 -15
  236. package/src/internal/indicatorPress.stylex.ts +0 -24
  237. package/src/motion/progress.ts +0 -155
  238. package/src/motion/uikit/alert.ts +0 -43
  239. package/src/privateAttributes/pressGroupItem.stylex.ts +0 -23
  240. package/src/utils/triggerFocus.ts +0 -80
@@ -1,67 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- 'use client';
4
-
5
- /**
6
- * @file useAnimator.ts
7
- * @input React (useState), the element ref the caller owns, the public
8
- * animator factory (animator/createAnimator.ts) and useAttachment
9
- * @output Exports `useAnimator(ref)`: the public animator for the element
10
- * behind `ref`
11
- * @position Public hook, exported from `@astryxdesign/core/hooks`. A thin
12
- * wrapper over `createAnimator` with no behavior of its own.
13
- *
14
- * SYNC: When modified, update:
15
- * - /packages/core/src/hooks/useAnimator.test.tsx
16
- * - /packages/core/src/hooks/useAnimator.doc.mjs
17
- */
18
-
19
- import {useState, type RefObject} from 'react';
20
- import {
21
- createAttachableAnimator,
22
- type AnimatorHandle,
23
- } from '../animator/createAnimator';
24
- import {useAttachment} from './useAttachment';
25
-
26
- /**
27
- * Animates the element behind `ref` with the motion Core uses. Call
28
- * `animate`, `decay`, `set`, `get`, `getVelocity` or `stop` on the returned
29
- * animator from event handlers and effects. Pass the same `ref` to a gesture
30
- * hook to drag and animate one element.
31
- *
32
- * The hook makes the animator once, and animating never re-renders the
33
- * component. After each commit, the animator follows the element behind
34
- * `ref`, also a node that replaces it. An unmount stops running motion and
35
- * drops the values. A remount, or a node that replaces the element, starts
36
- * at rest. While no element is attached, every call does nothing, and
37
- * `animate` and `decay` resolve at once.
38
- *
39
- * @example
40
- * ```
41
- * const ref = useRef<HTMLDivElement>(null);
42
- * const animator = useAnimator(ref);
43
- * return (
44
- * <div ref={ref} onClick={() => animator.animate({scale: 1.2})}>
45
- * Card
46
- * </div>
47
- * );
48
- * ```
49
- */
50
- export function useAnimator(
51
- ref: RefObject<HTMLElement | null>,
52
- ): AnimatorHandle {
53
- const [{handle, attach}] = useState(() => {
54
- const {animator, attach: attachElement} = createAttachableAnimator();
55
- // The handle without `destroy`: the hook owns the element's lifetime.
56
- const {destroy: _destroy, ...handle} = animator;
57
- return {
58
- handle,
59
- attach: (element: HTMLElement) => {
60
- attachElement(element);
61
- return () => attachElement(null);
62
- },
63
- };
64
- });
65
- useAttachment(ref, attach, null);
66
- return handle;
67
- }
@@ -1,43 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @generated by scripts/generate-i18n-runtime.mjs from packages/core/locales/en.json,
5
- * holding the English for the catalog keys named in packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx.
6
- * Do not edit by hand. Run `pnpm generate:i18n-runtime` instead.
7
- */
8
-
9
- const english: Readonly<Record<string, string>> = {
10
- "@astryx.powersearch.allFiltersRemoved": "All filters removed",
11
- "@astryx.powersearch.editableFiltersRemoved": "Editable filters removed",
12
- "@astryx.powersearch.editor.apply": "Apply",
13
- "@astryx.powersearch.editor.cancel": "Cancel",
14
- "@astryx.powersearch.editor.operator": "Operator",
15
- "@astryx.powersearch.sheet.addFilter": "Add filter",
16
- "@astryx.powersearch.sheet.clearAll": "Clear all",
17
- "@astryx.powersearch.sheet.clearAllCancel": "Keep filters",
18
- "@astryx.powersearch.sheet.clearAllConfirm": "Clear filters",
19
- "@astryx.powersearch.sheet.clearAllDescription": "This removes all editable filters from this search.",
20
- "@astryx.powersearch.sheet.clearAllTitle": "Clear all filters?",
21
- "@astryx.powersearch.sheet.done": "Done",
22
- "@astryx.powersearch.sheet.editableFiltersClearedWithCount": "Editable filters removed. {resultCount}",
23
- "@astryx.powersearch.sheet.fieldOperator": "{field} {operator}",
24
- "@astryx.powersearch.sheet.filterUnavailable": "This filter is no longer available",
25
- "@astryx.powersearch.sheet.filtersClearedWithCount": "All filters removed. {resultCount}",
26
- "@astryx.powersearch.sheet.filtersTitle": "Filters",
27
- "@astryx.powersearch.sheet.labelValue": "{label} {value}",
28
- "@astryx.powersearch.sheet.noFilters": "No filters applied",
29
- "@astryx.powersearch.sheet.noFiltersDescription": "Add a filter to narrow your results and find what you need faster.",
30
- "@astryx.powersearch.sheet.noMatchingFields": "No filters match your search",
31
- "@astryx.powersearch.sheet.noResults": "No results found",
32
- "@astryx.powersearch.sheet.removeFilter": "Remove {field} filter",
33
- "@astryx.powersearch.sheet.search": "Search",
34
- "@astryx.powersearch.sheet.searchFields": "Search filters",
35
- "@astryx.powersearch.sheet.searchFieldsPlaceholder": "Search filters…",
36
- "@astryx.powersearch.sheet.searchResults": "Search results",
37
- "@astryx.powersearch.sheet.tryDifferentSearch": "Try a different search.",
38
- "@astryx.powersearch.sheet.ungroupedFields": "General",
39
- "@astryx.tokenizer.tokenAdded": "Added {label}",
40
- "@astryx.tokenizer.tokenRemoved": "Removed {label}"
41
- };
42
-
43
- export default english;
@@ -1,15 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @generated by scripts/generate-i18n-runtime.mjs from packages/core/locales/en.json,
5
- * holding the English for the catalog keys named in packages/core/src/PowerSearch/formatTokenValue.ts.
6
- * Do not edit by hand. Run `pnpm generate:i18n-runtime` instead.
7
- */
8
-
9
- const english: Readonly<Record<string, string>> = {
10
- "@astryx.powersearch.valueEditor.dateRange": "date range",
11
- "@astryx.powersearch.valueEditor.filtersCount": "{count, number} {count, plural, one {filter} other {filters}}",
12
- "@astryx.powersearch.valueEditor.itemsCount": "{count, number} {count, plural, one {item} other {items}}"
13
- };
14
-
15
- export default english;
@@ -1,24 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file indicatorPress.stylex.ts
5
- * @input Uses StyleX
6
- * @output Exports `indicatorPressScope`, the marker of a first-party
7
- * indicator that paints its own press
8
- * @position Internal entry for Astryx's own replacement indicators;
9
- * CheckboxInput reads it
10
- */
11
-
12
- import * as stylex from '@stylexjs/stylex';
13
-
14
- /**
15
- * Marks a first-party replacement indicator that paints its own press, for
16
- * a shape that CheckboxInput's rounded-square press layer would tint past,
17
- * such as a circle. CheckboxInput leaves that layer off over an indicator
18
- * with this marker.
19
- *
20
- * @internal Not public API: the touch press reaches the indicator through a
21
- * private property.
22
- */
23
- export const indicatorPressScope: ReturnType<typeof stylex.defineMarker> =
24
- stylex.defineMarker();
@@ -1,155 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file progress.ts
5
- * @input A spring, a normalized progress, an animator's presented velocities
6
- * @output Exports `progressCurve` (a spring's progress from 0 to 1 as a
7
- * MotionCurve), `mapProgress` (one curve as a function of another),
8
- * `mapRange` (the clamped linear map most companions use) and
9
- * `presentedProgressVelocity` (the progress velocity that continues what
10
- * an animator shows)
11
- * @position Shared by the motion building blocks that move several channels
12
- * along one path and by companion motion (a
13
- * scrim's dim following a sheet): one velocity unit, one curve mapping and
14
- * one way to continue an interrupted motion
15
- *
16
- * A path is described by a normalized progress: 0 where it starts, 1 where
17
- * it rests, beyond either end on a spring's overshoot. Its velocity is in
18
- * progress per second; each channel's own velocity stays in the channel's
19
- * units per second.
20
- *
21
- * An interrupted motion continues from what is on screen: the
22
- * block reads the presented values and velocities from the animator at one
23
- * `now` (`get`, `getVelocity`), restarts a path from those values, and starts
24
- * its progress with the presented velocity projected on the path's tangent
25
- * at its start, v·t / (t·t), where t = d(values)/dp. Channels are weighted
26
- * into one unit first (px per unit of scale, say), so a scale and a
27
- * translation count alike.
28
- *
29
- * A companion follows a driving curve through `mapProgress`, most often
30
- * with `mapRange`: `mapProgress(sheetY, mapRange([closedY, openY], [0, dim]))`
31
- * dims a scrim as a sheet rises. Played on another animator, it stays in
32
- * lockstep only when it starts with its driver: pass the driver's start,
33
- * `scrim.play({opacity}, {at: start})` with `start = await handle.started`
34
- * (or one shared `at` for both calls); two calls from rest otherwise each
35
- * start at their own commit.
36
- *
37
- * SYNC: When modified, update /packages/core/src/motion/progress.test.ts and
38
- * /packages/core/src/motion/README.md.
39
- */
40
-
41
- import type {Animator, MotionCurve, MotionProperty} from './animator';
42
- import {
43
- SETTLING_EPSILON,
44
- solveSpring,
45
- toSpring,
46
- type SpringDescription,
47
- } from './spring';
48
-
49
- /** The step of the finite differences taken on a progress. */
50
- const STEP = 1e-4;
51
-
52
- /**
53
- * The progress of `spring` from 0 to 1, starting with `velocity` (progress
54
- * per second): exactly 1 once it settles within `epsilon`.
55
- */
56
- export function progressCurve(
57
- spring: SpringDescription,
58
- {
59
- velocity = 0,
60
- epsilon = SETTLING_EPSILON,
61
- }: {velocity?: number; epsilon?: number} = {},
62
- ): MotionCurve {
63
- const curve = solveSpring(toSpring(spring), {from: 0, to: 1, velocity});
64
- const duration = curve.settleTime(epsilon);
65
- return {
66
- duration,
67
- at: t => (t >= duration ? 1 : curve.value(t)),
68
- velocity: t => (t >= duration ? 0 : curve.velocity(t)),
69
- };
70
- }
71
-
72
- /**
73
- * The curve of `f(driver(t))`, its velocity by the chain rule: a channel
74
- * following a path as its progress moves, or a companion following any
75
- * driving curve (a sheet's `y` mapped onto its scrim's opacity). The driver
76
- * is any MotionCurve, not only a progress from 0 to 1. A companion played on
77
- * another animator starts with its driver (`{at: start}`; see the file
78
- * header).
79
- */
80
- export function mapProgress(
81
- driver: MotionCurve,
82
- f: (value: number) => number,
83
- ): MotionCurve {
84
- return {
85
- duration: driver.duration,
86
- at: t => f(driver.at(t)),
87
- velocity: t => {
88
- const value = driver.at(t);
89
- return (
90
- ((f(value + STEP) - f(value - STEP)) / (2 * STEP)) * driver.velocity(t)
91
- );
92
- },
93
- };
94
- }
95
-
96
- /**
97
- * The linear map from `input` to `output`, held at `output`'s ends outside
98
- * `input` unless `clamp` is false: what most companions are (a scrim's dim
99
- * along a sheet's travel, a parallax, a dismissal's fade). Either range may
100
- * run backward (`[openY, closedY]`).
101
- */
102
- export function mapRange(
103
- input: readonly [number, number],
104
- output: readonly [number, number],
105
- {clamp = true}: {clamp?: boolean} = {},
106
- ): (x: number) => number {
107
- const [a, b] = input;
108
- const [c, d] = output;
109
- return x => {
110
- let t = a === b ? (x < a ? 0 : 1) : (x - a) / (b - a);
111
- if (clamp) {
112
- t = Math.min(1, Math.max(0, t));
113
- }
114
- // Exact at both ends.
115
- return t === 0 ? c : t === 1 ? d : c + (d - c) * t;
116
- };
117
- }
118
-
119
- /**
120
- * One channel of a path: an animator property and its value at each
121
- * progress.
122
- */
123
- export interface ProgressChannel {
124
- readonly property: MotionProperty;
125
- /** The property's value at progress `p`. */
126
- at(p: number): number;
127
- /**
128
- * What one unit of the property weighs in the projection, in a unit the
129
- * channels share (px per unit of scale for a box `weight` px wide). 1 by
130
- * default.
131
- */
132
- readonly weight?: number;
133
- }
134
-
135
- /**
136
- * The progress velocity, per second, that continues what `animator`
137
- * presents at `now` along a path that starts there: the presented velocity
138
- * projected on the path's tangent at progress 0, v·t / (t·t). 0 when the
139
- * path does not move any of its channels.
140
- */
141
- export function presentedProgressVelocity(
142
- animator: Pick<Animator, 'getVelocity'>,
143
- channels: ReadonlyArray<ProgressChannel>,
144
- now?: number,
145
- ): number {
146
- let along = 0;
147
- let squared = 0;
148
- for (const channel of channels) {
149
- const weight = channel.weight ?? 1;
150
- const tangent = ((channel.at(STEP) - channel.at(0)) / STEP) * weight;
151
- along += animator.getVelocity(channel.property, now) * weight * tangent;
152
- squared += tangent * tangent;
153
- }
154
- return squared > 1e-12 ? along / squared : 0;
155
- }
@@ -1,43 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file alert.ts
5
- * @input Nothing; data only
6
- * @output Exports `alertController`: how UIAlertController (`.alert`) tracks
7
- * a finger across its actions
8
- * @position The alert domain of the UIKit constants table (motion/uikit);
9
- * its springs are `springs.alertPresent` and `springs.alertDismiss`
10
- *
11
- * Every value was read from UIKit on the iOS 26.2 simulator. A host app
12
- * presented `UIAlertController(.alert)` with two and with three actions.
13
- * Real HID touches drove it, and the action views' highlight was sampled
14
- * every frame. Lengths are in pt (CSS px), durations in ms.
15
- *
16
- * Every leaf carries one or more `@source`; GUESS values also carry the
17
- * `@measure` task that will confirm or replace them. uikit.test.ts enforces
18
- * both.
19
- *
20
- * SYNC: When modified, update /packages/core/src/motion/MEASUREMENTS.md
21
- */
22
-
23
- export const alertController = {
24
- actions: {
25
- /**
26
- * How long after touch-down the touched action highlights: none, it is
27
- * highlighted in the touch-down frame (a tap and a 300 ms hold alike).
28
- * @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
29
- * iPhone 17 Pro, per-frame highlight of the action views under real HID
30
- * touches, Oct 23 2026
31
- */
32
- highlightOnsetMs: 0,
33
- /**
34
- * How far outside an action the finger may go and keep it highlighted:
35
- * none. The highlight cleared 1 pt below the action, and a lift there ran
36
- * nothing. UIButton keeps 70 pt; an alert action does not.
37
- * @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
38
- * iPhone 17 Pro, per-frame highlight of the action views under real HID
39
- * touches, Oct 23 2026
40
- */
41
- highlightExpansion: 0,
42
- },
43
- } as const;
@@ -1,23 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
- /**
3
- * @file privateAttributes/pressGroupItem.stylex.ts
4
- * @input Nothing: the private press-group-item attribute
5
- * @output pressGroupItemProps, which marks an action a group's tracker
6
- * follows, and isTrackedByGroup, which reads the mark
7
- * @position Owner module of the private press-group-item attribute: the only
8
- * file that writes its name. AlertDialog marks its actions, and the press
9
- * controller (utils/pressFeedback.ts) leaves their press to the group's
10
- * tracker. No package entry exports it.
11
- */
12
-
13
- const PRESS_GROUP_ITEM = 'data-astryx-press-group-item';
14
-
15
- /** Spread on each action that a group's tracker follows. */
16
- export const pressGroupItemProps: Readonly<Record<string, string>> = {
17
- [PRESS_GROUP_ITEM]: '',
18
- };
19
-
20
- /** Whether a group's tracker paints the press on `element` or an ancestor. */
21
- export function isTrackedByGroup(element: Element): boolean {
22
- return element.closest(`[${PRESS_GROUP_ITEM}]`) != null;
23
- }
@@ -1,80 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file triggerFocus.ts
5
- * @input A focus event on a hover-layer trigger and its focusTrigger value
6
- * @output Whether that focus counts as focus on the trigger, and a gate that
7
- * remembers it for the matching blur
8
- * @position Shared focus-trigger judgement for Tooltip and HoverCard
9
- */
10
-
11
- /** When focus on a trigger opens its layer. */
12
- export type TriggerFocusMode = 'auto' | 'always' | 'never';
13
-
14
- /** Whether `element` is in the tab order or naturally focusable. */
15
- export function isFocusableTrigger(element: HTMLElement): boolean {
16
- if (element.hasAttribute('tabindex')) {
17
- return element.tabIndex >= 0;
18
- }
19
- const focusableTags = ['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
20
- if (focusableTags.includes(element.tagName)) {
21
- return !(element as HTMLButtonElement).disabled;
22
- }
23
- return element.isContentEditable;
24
- }
25
-
26
- /**
27
- * Whether a focus event on a trigger (its `currentTarget`) counts as focus on
28
- * the trigger.
29
- *
30
- * Under `auto` it is decided when focus arrives, not when listeners attach: a
31
- * roving-tabindex member that was `tabindex="-1"` then can be the tab stop
32
- * now. A trigger that receives focus is focusable by definition, which covers
33
- * focusable elements this check does not list, such as a `<summary>` or an SVG
34
- * link. Focus inside the trigger counts only while the trigger is focusable
35
- * too, so a plain wrapper ignores its children's focus.
36
- */
37
- export function isFocusForTrigger(
38
- event: Event,
39
- mode: TriggerFocusMode,
40
- ): boolean {
41
- if (mode === 'always') {
42
- return true;
43
- }
44
- if (mode === 'never') {
45
- return false;
46
- }
47
- const trigger = event.currentTarget as HTMLElement | null;
48
- return (
49
- trigger != null && (event.target === trigger || isFocusableTrigger(trigger))
50
- );
51
- }
52
-
53
- /** Remembers whether a trigger's current focus counted when it arrived. */
54
- export interface TriggerFocusGate {
55
- /** On focusin: whether this focus opens the layer. */
56
- focusIn(event: Event, mode: TriggerFocusMode): boolean;
57
- /**
58
- * On focusout: whether this blur closes the layer. A focus that counted
59
- * closes on blur even if the trigger has since left the tab order.
60
- */
61
- focusOut(event: Event, mode: TriggerFocusMode): boolean;
62
- }
63
-
64
- /** A gate for one trigger; each hook keeps one for its lifetime. */
65
- export function createTriggerFocusGate(): TriggerFocusGate {
66
- let isCounted = false;
67
- return {
68
- focusIn(event, mode) {
69
- isCounted = isFocusForTrigger(event, mode);
70
- return isCounted;
71
- },
72
- focusOut(event, mode) {
73
- if (!isCounted && !isFocusForTrigger(event, mode)) {
74
- return false;
75
- }
76
- isCounted = false;
77
- return true;
78
- },
79
- };
80
- }