@qoretechnologies/reqore 0.78.5-pr.708.gbe112f0 → 0.78.6-pr.715.gdfefa70

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 (292) hide show
  1. package/dist/components/Accordion/index.d.ts.map +1 -1
  2. package/dist/components/Accordion/index.js +11 -15
  3. package/dist/components/Accordion/index.js.map +1 -1
  4. package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
  5. package/dist/components/Breadcrumbs/index.js +6 -7
  6. package/dist/components/Breadcrumbs/index.js.map +1 -1
  7. package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
  8. package/dist/components/Breadcrumbs/item.js +2 -6
  9. package/dist/components/Breadcrumbs/item.js.map +1 -1
  10. package/dist/components/Bubble/index.d.ts.map +1 -1
  11. package/dist/components/Bubble/index.js +39 -7
  12. package/dist/components/Bubble/index.js.map +1 -1
  13. package/dist/components/Button/index.d.ts +0 -8
  14. package/dist/components/Button/index.d.ts.map +1 -1
  15. package/dist/components/Button/index.js +12 -75
  16. package/dist/components/Button/index.js.map +1 -1
  17. package/dist/components/ButtonRail/index.d.ts.map +1 -1
  18. package/dist/components/ButtonRail/index.js +2 -3
  19. package/dist/components/ButtonRail/index.js.map +1 -1
  20. package/dist/components/Callout/index.d.ts +3 -4
  21. package/dist/components/Callout/index.d.ts.map +1 -1
  22. package/dist/components/Callout/index.js +8 -39
  23. package/dist/components/Callout/index.js.map +1 -1
  24. package/dist/components/Checkbox/index.js +8 -8
  25. package/dist/components/Checkbox/index.js.map +1 -1
  26. package/dist/components/Collapse/index.d.ts.map +1 -1
  27. package/dist/components/Collapse/index.js +36 -7
  28. package/dist/components/Collapse/index.js.map +1 -1
  29. package/dist/components/CollapsibleContent/index.d.ts.map +1 -1
  30. package/dist/components/CollapsibleContent/index.js +37 -5
  31. package/dist/components/CollapsibleContent/index.js.map +1 -1
  32. package/dist/components/Collection/index.js +3 -3
  33. package/dist/components/Collection/index.js.map +1 -1
  34. package/dist/components/Collection/item.d.ts.map +1 -1
  35. package/dist/components/Collection/item.js +4 -4
  36. package/dist/components/Collection/item.js.map +1 -1
  37. package/dist/components/Columns/column.d.ts.map +1 -1
  38. package/dist/components/Columns/column.js +35 -6
  39. package/dist/components/Columns/column.js.map +1 -1
  40. package/dist/components/Columns/index.d.ts.map +1 -1
  41. package/dist/components/Columns/index.js +35 -3
  42. package/dist/components/Columns/index.js.map +1 -1
  43. package/dist/components/Comment/index.js +8 -8
  44. package/dist/components/Comment/index.js.map +1 -1
  45. package/dist/components/CommentFeed/index.js +2 -2
  46. package/dist/components/CommentFeed/index.js.map +1 -1
  47. package/dist/components/Content/index.d.ts.map +1 -1
  48. package/dist/components/Content/index.js +35 -3
  49. package/dist/components/Content/index.js.map +1 -1
  50. package/dist/components/Content/wrapper.js +2 -2
  51. package/dist/components/Content/wrapper.js.map +1 -1
  52. package/dist/components/ControlGroup/index.js +3 -3
  53. package/dist/components/ControlGroup/index.js.map +1 -1
  54. package/dist/components/ControlGroup/item.d.ts.map +1 -1
  55. package/dist/components/ControlGroup/item.js +6 -35
  56. package/dist/components/ControlGroup/item.js.map +1 -1
  57. package/dist/components/DataView/index.d.ts.map +1 -1
  58. package/dist/components/DataView/index.js +49 -17
  59. package/dist/components/DataView/index.js.map +1 -1
  60. package/dist/components/DatePicker/index.d.ts.map +1 -1
  61. package/dist/components/DatePicker/index.js +8 -40
  62. package/dist/components/DatePicker/index.js.map +1 -1
  63. package/dist/components/DescriptionList/index.d.ts.map +1 -1
  64. package/dist/components/DescriptionList/index.js +39 -7
  65. package/dist/components/DescriptionList/index.js.map +1 -1
  66. package/dist/components/Drawer/backdrop.d.ts.map +1 -1
  67. package/dist/components/Drawer/backdrop.js +6 -35
  68. package/dist/components/Drawer/backdrop.js.map +1 -1
  69. package/dist/components/Drawer/index.d.ts +172 -0
  70. package/dist/components/Drawer/index.d.ts.map +1 -1
  71. package/dist/components/Drawer/index.js +296 -18
  72. package/dist/components/Drawer/index.js.map +1 -1
  73. package/dist/components/Effect/index.d.ts +6 -0
  74. package/dist/components/Effect/index.d.ts.map +1 -1
  75. package/dist/components/Effect/index.js +26 -27
  76. package/dist/components/Effect/index.js.map +1 -1
  77. package/dist/components/EntityRow/index.d.ts +1 -7
  78. package/dist/components/EntityRow/index.d.ts.map +1 -1
  79. package/dist/components/EntityRow/index.js +11 -32
  80. package/dist/components/EntityRow/index.js.map +1 -1
  81. package/dist/components/FadeScroller/index.d.ts.map +1 -1
  82. package/dist/components/FadeScroller/index.js +106 -26
  83. package/dist/components/FadeScroller/index.js.map +1 -1
  84. package/dist/components/FeatureCard/index.d.ts +1 -7
  85. package/dist/components/FeatureCard/index.d.ts.map +1 -1
  86. package/dist/components/FeatureCard/index.js +8 -30
  87. package/dist/components/FeatureCard/index.js.map +1 -1
  88. package/dist/components/Header/index.js +2 -2
  89. package/dist/components/Header/index.js.map +1 -1
  90. package/dist/components/Icon/index.d.ts.map +1 -1
  91. package/dist/components/Icon/index.js +16 -26
  92. package/dist/components/Icon/index.js.map +1 -1
  93. package/dist/components/IconPicker/index.js +2 -2
  94. package/dist/components/IconPicker/index.js.map +1 -1
  95. package/dist/components/Input/index.js +6 -6
  96. package/dist/components/Input/index.js.map +1 -1
  97. package/dist/components/InputClearButton/index.d.ts.map +1 -1
  98. package/dist/components/InputClearButton/index.js +3 -35
  99. package/dist/components/InputClearButton/index.js.map +1 -1
  100. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  101. package/dist/components/InternalPopover/index.js +4 -5
  102. package/dist/components/InternalPopover/index.js.map +1 -1
  103. package/dist/components/KeyboardShortcut/index.js +3 -3
  104. package/dist/components/KeyboardShortcut/index.js.map +1 -1
  105. package/dist/components/Layout/content.js +2 -2
  106. package/dist/components/Layout/content.js.map +1 -1
  107. package/dist/components/Layout/index.d.ts.map +1 -1
  108. package/dist/components/Layout/index.js +35 -3
  109. package/dist/components/Layout/index.js.map +1 -1
  110. package/dist/components/Link/index.d.ts.map +1 -1
  111. package/dist/components/Link/index.js +38 -6
  112. package/dist/components/Link/index.js.map +1 -1
  113. package/dist/components/Menu/divider.js +3 -3
  114. package/dist/components/Menu/divider.js.map +1 -1
  115. package/dist/components/Menu/index.d.ts.map +1 -1
  116. package/dist/components/Menu/index.js +4 -4
  117. package/dist/components/Menu/index.js.map +1 -1
  118. package/dist/components/Menu/item.d.ts.map +1 -1
  119. package/dist/components/Menu/item.js +0 -27
  120. package/dist/components/Menu/item.js.map +1 -1
  121. package/dist/components/Modal/index.d.ts +12 -2
  122. package/dist/components/Modal/index.d.ts.map +1 -1
  123. package/dist/components/Modal/index.js +2 -2
  124. package/dist/components/Modal/index.js.map +1 -1
  125. package/dist/components/NavRail/index.js +6 -6
  126. package/dist/components/NavRail/index.js.map +1 -1
  127. package/dist/components/Navbar/divider.d.ts.map +1 -1
  128. package/dist/components/Navbar/divider.js +6 -35
  129. package/dist/components/Navbar/divider.js.map +1 -1
  130. package/dist/components/Navbar/group.js +3 -3
  131. package/dist/components/Navbar/group.js.map +1 -1
  132. package/dist/components/Navbar/index.js +3 -3
  133. package/dist/components/Navbar/index.js.map +1 -1
  134. package/dist/components/Navbar/item.js +3 -3
  135. package/dist/components/Navbar/item.js.map +1 -1
  136. package/dist/components/Notifications/index.d.ts.map +1 -1
  137. package/dist/components/Notifications/index.js +35 -6
  138. package/dist/components/Notifications/index.js.map +1 -1
  139. package/dist/components/Notifications/notification.d.ts +11 -1
  140. package/dist/components/Notifications/notification.d.ts.map +1 -1
  141. package/dist/components/Notifications/notification.js +130 -21
  142. package/dist/components/Notifications/notification.js.map +1 -1
  143. package/dist/components/Notifications/styles.js +8 -8
  144. package/dist/components/Notifications/styles.js.map +1 -1
  145. package/dist/components/Paging/index.js +2 -2
  146. package/dist/components/Paging/index.js.map +1 -1
  147. package/dist/components/Panel/index.d.ts +0 -12
  148. package/dist/components/Panel/index.d.ts.map +1 -1
  149. package/dist/components/Panel/index.js +63 -197
  150. package/dist/components/Panel/index.js.map +1 -1
  151. package/dist/components/Paragraph/index.d.ts +0 -6
  152. package/dist/components/Paragraph/index.d.ts.map +1 -1
  153. package/dist/components/Paragraph/index.js +8 -57
  154. package/dist/components/Paragraph/index.js.map +1 -1
  155. package/dist/components/Popover/index.d.ts.map +1 -1
  156. package/dist/components/Popover/index.js +7 -36
  157. package/dist/components/Popover/index.js.map +1 -1
  158. package/dist/components/Progress/index.d.ts.map +1 -1
  159. package/dist/components/Progress/index.js +42 -10
  160. package/dist/components/Progress/index.js.map +1 -1
  161. package/dist/components/Rating/index.d.ts.map +1 -1
  162. package/dist/components/Rating/index.js +36 -4
  163. package/dist/components/Rating/index.js.map +1 -1
  164. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  165. package/dist/components/RichTextEditor/index.js +5 -16
  166. package/dist/components/RichTextEditor/index.js.map +1 -1
  167. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  168. package/dist/components/SegmentedControl/index.js +37 -5
  169. package/dist/components/SegmentedControl/index.js.map +1 -1
  170. package/dist/components/Select/valuePreview.js +2 -2
  171. package/dist/components/Select/valuePreview.js.map +1 -1
  172. package/dist/components/SeverityRow/index.d.ts +1 -7
  173. package/dist/components/SeverityRow/index.d.ts.map +1 -1
  174. package/dist/components/SeverityRow/index.js +10 -31
  175. package/dist/components/SeverityRow/index.js.map +1 -1
  176. package/dist/components/Skeleton/index.d.ts.map +1 -1
  177. package/dist/components/Skeleton/index.js +35 -6
  178. package/dist/components/Skeleton/index.js.map +1 -1
  179. package/dist/components/Slider/index.js +9 -9
  180. package/dist/components/Slider/index.js.map +1 -1
  181. package/dist/components/Spacer/index.js +7 -7
  182. package/dist/components/Spacer/index.js.map +1 -1
  183. package/dist/components/Span/index.d.ts.map +1 -1
  184. package/dist/components/Span/index.js +6 -35
  185. package/dist/components/Span/index.js.map +1 -1
  186. package/dist/components/StackedBar/index.d.ts.map +1 -1
  187. package/dist/components/StackedBar/index.js +38 -9
  188. package/dist/components/StackedBar/index.js.map +1 -1
  189. package/dist/components/Statistic/index.d.ts +8 -0
  190. package/dist/components/Statistic/index.d.ts.map +1 -1
  191. package/dist/components/Statistic/index.js +41 -9
  192. package/dist/components/Statistic/index.js.map +1 -1
  193. package/dist/components/Table/body.d.ts.map +1 -1
  194. package/dist/components/Table/body.js +38 -6
  195. package/dist/components/Table/body.js.map +1 -1
  196. package/dist/components/Table/cell.d.ts.map +1 -1
  197. package/dist/components/Table/cell.js +14 -7
  198. package/dist/components/Table/cell.js.map +1 -1
  199. package/dist/components/Table/header.d.ts.map +1 -1
  200. package/dist/components/Table/header.js +10 -13
  201. package/dist/components/Table/header.js.map +1 -1
  202. package/dist/components/Table/headerCell.d.ts.map +1 -1
  203. package/dist/components/Table/headerCell.js +38 -8
  204. package/dist/components/Table/headerCell.js.map +1 -1
  205. package/dist/components/Table/index.d.ts +1 -12
  206. package/dist/components/Table/index.d.ts.map +1 -1
  207. package/dist/components/Table/index.js +49 -34
  208. package/dist/components/Table/index.js.map +1 -1
  209. package/dist/components/Table/row.js +5 -5
  210. package/dist/components/Table/row.js.map +1 -1
  211. package/dist/components/Table/scrollbar.js +3 -3
  212. package/dist/components/Table/scrollbar.js.map +1 -1
  213. package/dist/components/Tabs/content.js +2 -2
  214. package/dist/components/Tabs/content.js.map +1 -1
  215. package/dist/components/Tabs/index.js +3 -3
  216. package/dist/components/Tabs/index.js.map +1 -1
  217. package/dist/components/Tabs/item.d.ts.map +1 -1
  218. package/dist/components/Tabs/item.js +4 -6
  219. package/dist/components/Tabs/item.js.map +1 -1
  220. package/dist/components/Tabs/list.js +3 -3
  221. package/dist/components/Tabs/list.js.map +1 -1
  222. package/dist/components/Tag/group.d.ts.map +1 -1
  223. package/dist/components/Tag/group.js +35 -3
  224. package/dist/components/Tag/group.js.map +1 -1
  225. package/dist/components/Tag/index.d.ts +0 -7
  226. package/dist/components/Tag/index.d.ts.map +1 -1
  227. package/dist/components/Tag/index.js +16 -79
  228. package/dist/components/Tag/index.js.map +1 -1
  229. package/dist/components/Testimonial/index.d.ts +1 -6
  230. package/dist/components/Testimonial/index.d.ts.map +1 -1
  231. package/dist/components/Testimonial/index.js +7 -28
  232. package/dist/components/Testimonial/index.js.map +1 -1
  233. package/dist/components/Textarea/index.d.ts +0 -10
  234. package/dist/components/Textarea/index.d.ts.map +1 -1
  235. package/dist/components/Textarea/index.js +14 -99
  236. package/dist/components/Textarea/index.js.map +1 -1
  237. package/dist/components/Tier/group.d.ts +5 -4
  238. package/dist/components/Tier/group.d.ts.map +1 -1
  239. package/dist/components/Tier/group.js +51 -131
  240. package/dist/components/Tier/group.js.map +1 -1
  241. package/dist/components/Tier/index.d.ts +0 -5
  242. package/dist/components/Tier/index.d.ts.map +1 -1
  243. package/dist/components/Tier/index.js +10 -14
  244. package/dist/components/Tier/index.js.map +1 -1
  245. package/dist/components/Timeline/index.d.ts.map +1 -1
  246. package/dist/components/Timeline/index.js +12 -13
  247. package/dist/components/Timeline/index.js.map +1 -1
  248. package/dist/components/TooltipComponent/index.d.ts.map +1 -1
  249. package/dist/components/TooltipComponent/index.js +7 -6
  250. package/dist/components/TooltipComponent/index.js.map +1 -1
  251. package/dist/components/Tree/index.js +3 -3
  252. package/dist/components/Tree/index.js.map +1 -1
  253. package/dist/constants/theme.d.ts +21 -0
  254. package/dist/constants/theme.d.ts.map +1 -1
  255. package/dist/constants/theme.js.map +1 -1
  256. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  257. package/dist/containers/ReqoreProvider.js +6 -8
  258. package/dist/containers/ReqoreProvider.js.map +1 -1
  259. package/dist/containers/UIProvider.d.ts.map +1 -1
  260. package/dist/containers/UIProvider.js +35 -3
  261. package/dist/containers/UIProvider.js.map +1 -1
  262. package/dist/helpers/colors.d.ts +11 -1
  263. package/dist/helpers/colors.d.ts.map +1 -1
  264. package/dist/helpers/colors.js +18 -1
  265. package/dist/helpers/colors.js.map +1 -1
  266. package/dist/helpers/gestures.d.ts +30 -0
  267. package/dist/helpers/gestures.d.ts.map +1 -0
  268. package/dist/helpers/gestures.js +36 -0
  269. package/dist/helpers/gestures.js.map +1 -0
  270. package/dist/helpers/styled.d.ts +26 -39
  271. package/dist/helpers/styled.d.ts.map +1 -1
  272. package/dist/helpers/styled.js +4 -156
  273. package/dist/helpers/styled.js.map +1 -1
  274. package/dist/hooks/usePointerDrag.d.ts +77 -0
  275. package/dist/hooks/usePointerDrag.d.ts.map +1 -0
  276. package/dist/hooks/usePointerDrag.js +192 -0
  277. package/dist/hooks/usePointerDrag.js.map +1 -0
  278. package/dist/hooks/useReqoreMedia.d.ts +24 -0
  279. package/dist/hooks/useReqoreMedia.d.ts.map +1 -0
  280. package/dist/hooks/useReqoreMedia.js +32 -0
  281. package/dist/hooks/useReqoreMedia.js.map +1 -0
  282. package/dist/index.d.ts +4 -0
  283. package/dist/index.d.ts.map +1 -1
  284. package/dist/index.js +17 -3
  285. package/dist/index.js.map +1 -1
  286. package/dist/styles.js +6 -6
  287. package/dist/styles.js.map +1 -1
  288. package/package.json +1 -1
  289. package/dist/hooks/useDragToScroll.d.ts +0 -55
  290. package/dist/hooks/useDragToScroll.d.ts.map +0 -1
  291. package/dist/hooks/useDragToScroll.js +0 -259
  292. package/dist/hooks/useDragToScroll.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import type { ComponentType, JSX } from 'react';
2
- import baseStyled from 'styled-components';
1
+ import type { ComponentType } from 'react';
3
2
  /**
4
3
  * The default prop validator styled-components hands to `shouldForwardProp`. It answers
5
4
  * "is this a real HTML attribute?" — it knows nothing about the element being rendered.
@@ -12,17 +11,32 @@ export type TReqoreStyledPropValidator = (prop: string | number | symbol) => boo
12
11
  */
13
12
  export type TReqoreStyledTarget = string | ComponentType<any>;
14
13
  /**
15
- * Reqore prop names that are ALSO an HTML attribute — of some elements. `isPropValid`, which
16
- * styled-components uses to filter a DOM tag's props, only asks whether a name is an attribute
17
- * anywhere, so `size='normal'` (a Reqore size) reached every `div` and `span` it was handed to as
18
- * `size="normal"`, a checkbox's `checked` reached its `div`, a table cell's `selected` and
19
- * `disabled` theirs, and so on. Each name maps to the elements it is an attribute of; on any
20
- * other HTML element it is a styling prop and stays back. A name with no elements is not an
21
- * attribute of any HTML element (only of SVG ones, or of nothing current).
14
+ * Builds a `shouldForwardProp` predicate for `styled(...).withConfig({ ... })` that keeps the
15
+ * named props out of the rendered element while leaving every other prop alone.
16
+ *
17
+ * Reqore layout flags (`fill`, `wrap`, ...) are meaningful to a parent — a `ReqoreControlGroup`
18
+ * propagates `fill` through polymorphic children, a `ReqoreTable` threads `wrap` into rows and
19
+ * cells — but they are not valid HTML attributes. Without this filter React renders them as
20
+ * boolean attributes and logs a "received `true` for a non-boolean attribute" warning.
21
+ *
22
+ * IMPORTANT — why the target type is checked. Supplying `shouldForwardProp` *replaces*
23
+ * styled-components' built-in rule outright; it does not layer on top of it. That built-in rule
24
+ * is `isTargetTag ? isPropValid(prop) : true` — a DOM tag only receives real HTML attributes,
25
+ * but a **component** target receives everything, because a component's props are its own API
26
+ * and `isPropValid` knows nothing about them. Chaining `defaultValidatorFn` unconditionally
27
+ * therefore strips a component's entire prop surface: `styled(ReqoreIcon)` silently lost
28
+ * `icon` / `wrapperElement` / `wrapperSize` (the input clear button rendered as an empty span),
29
+ * `styled(StyledEffect) as={Resizable}` lost re-resizable's `enable` / size / handle config, and
30
+ * `ReqoreTextarea as={Editable}` lost Slate's `renderElement` / `renderLeaf` / `decorate`. Each
31
+ * was previously patched with a bespoke per-call-site allow-list; mirroring the built-in rule
32
+ * here fixes all of them at the source, so `styled(SomeComponent)` keeps working like plain
33
+ * styled-components while the explicitly-omitted props still never reach the DOM.
34
+ *
35
+ * @example
36
+ * const StyledPanel = styled(StyledEffect).withConfig({
37
+ * shouldForwardProp: omitStyleProps('fill'),
38
+ * })<IStyledPanel>`...`;
22
39
  */
23
- export declare const REQORE_AMBIGUOUS_PROP_ELEMENTS: Readonly<Record<string, readonly (keyof JSX.IntrinsicElements)[]>>;
24
- /** Whether `prop` is an attribute of the element `tag`, as far as Reqore's names go. */
25
- export declare const isReqoreElementAttribute: (prop: string | number | symbol, tag: string) => boolean;
26
40
  export declare const omitStyleProps: (...propsToOmit: string[]) => (prop: string | number | symbol, defaultValidatorFn: TReqoreStyledPropValidator, elementToBeCreated?: TReqoreStyledTarget) => boolean;
27
41
  /**
28
42
  * The props `ReqoreControlGroup` clones onto every child that is a component (see the group's
@@ -32,31 +46,4 @@ export declare const omitStyleProps: (...propsToOmit: string[]) => (prop: string
32
46
  * them: `shouldForwardProp: omitStyleProps(...REQORE_CONTROL_GROUP_CHILD_PROPS)`.
33
47
  */
34
48
  export declare const REQORE_CONTROL_GROUP_CHILD_PROPS: string[];
35
- /**
36
- * The props of a styled component's prop interface `TProps` that only style it: every key that
37
- * is not one of `TTargetProps` — the attributes and props of what the component renders.
38
- *
39
- * `as`, `forwardedAs` and transient (`$`-prefixed) props are left out: styled-components consumes
40
- * those itself and never forwards them.
41
- */
42
- export type TReqoreStylePropKeys<TProps, TTargetProps> = Exclude<Extract<keyof TProps, string>, keyof TTargetProps | 'as' | 'forwardedAs' | `$${string}`>;
43
- /**
44
- * Lists a component's styling props for `omitStyleProps`, from a record the compiler checks
45
- * against the component's prop interface.
46
- *
47
- * A hand-written omit list goes stale: a prop added to the interface later reaches the rendered
48
- * element until someone remembers the list (ReqoreButton rendered `as` a router link handed its
49
- * `fluid`, `compact`, `maxWidth`, ... to the link, which wrote them onto its `<a>`; a resizable,
50
- * transparent ReqorePanel handed re-resizable `transparent`). Typed as
51
- * `Record<TReqoreStylePropKeys<...>, true>`, the record must name every such prop and nothing
52
- * else, so a new prop that is not added fails the build instead of leaking.
53
- *
54
- * @example
55
- * const BUTTON_STYLE_PROPS = listReqoreStyleProps<
56
- * TReqoreStylePropKeys<IReqoreButtonStyle, React.ButtonHTMLAttributes<HTMLButtonElement>>
57
- * >({ fluid: true, compact: true, ... });
58
- */
59
- export declare const listReqoreStyleProps: <TKeys extends string>(props: Record<TKeys, true>) => TKeys[];
60
- declare const reqoreStyled: typeof baseStyled;
61
- export default re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OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAG,KAAK,EAC9D,CAAC;AAgBhC,QAAA,MAAM,YAAY,EAGZ,OAAO,UAAU,CAAC;AAExB,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/helpers/styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,aAAa,MAAM,EAAE,MAInD,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,EAC9B,oBAAoB,0BAA0B,EAC9C,qBAAqB,mBAAmB,KACvC,OAQJ,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,UA0B5C,CAAC"}
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.listReqoreStyleProps = exports.REQORE_CONTROL_GROUP_CHILD_PROPS = exports.omitStyleProps = exports.isReqoreElementAttribute = exports.REQORE_AMBIGUOUS_PROP_ELEMENTS = void 0;
7
- var styled_components_1 = __importDefault(require("styled-components"));
3
+ exports.REQORE_CONTROL_GROUP_CHILD_PROPS = exports.omitStyleProps = void 0;
8
4
  /**
9
5
  * Builds a `shouldForwardProp` predicate for `styled(...).withConfig({ ... })` that keeps the
10
6
  * named props out of the rendered element while leaving every other prop alone.
@@ -32,106 +28,6 @@ var styled_components_1 = __importDefault(require("styled-components"));
32
28
  * shouldForwardProp: omitStyleProps('fill'),
33
29
  * })<IStyledPanel>`...`;
34
30
  */
35
- /** The SVG elements: their presentation attributes (`fill`, `opacity`, `width`, ...) are real. */
36
- var SVG_TAGS = new Set([
37
- 'svg',
38
- 'g',
39
- 'path',
40
- 'circle',
41
- 'ellipse',
42
- 'line',
43
- 'polyline',
44
- 'polygon',
45
- 'rect',
46
- 'text',
47
- 'tspan',
48
- 'textPath',
49
- 'defs',
50
- 'symbol',
51
- 'use',
52
- 'image',
53
- 'marker',
54
- 'mask',
55
- 'pattern',
56
- 'clipPath',
57
- 'linearGradient',
58
- 'radialGradient',
59
- 'stop',
60
- 'foreignObject',
61
- 'filter',
62
- ]);
63
- /**
64
- * Reqore prop names that are ALSO an HTML attribute — of some elements. `isPropValid`, which
65
- * styled-components uses to filter a DOM tag's props, only asks whether a name is an attribute
66
- * anywhere, so `size='normal'` (a Reqore size) reached every `div` and `span` it was handed to as
67
- * `size="normal"`, a checkbox's `checked` reached its `div`, a table cell's `selected` and
68
- * `disabled` theirs, and so on. Each name maps to the elements it is an attribute of; on any
69
- * other HTML element it is a styling prop and stays back. A name with no elements is not an
70
- * attribute of any HTML element (only of SVG ones, or of nothing current).
71
- */
72
- exports.REQORE_AMBIGUOUS_PROP_ELEMENTS = {
73
- size: ['input', 'select'],
74
- width: ['img', 'canvas', 'video', 'iframe', 'input', 'embed', 'object', 'col', 'colgroup'],
75
- height: ['img', 'canvas', 'video', 'iframe', 'input', 'embed', 'object'],
76
- wrap: ['textarea'],
77
- color: [],
78
- fill: [],
79
- opacity: [],
80
- direction: [],
81
- offset: [],
82
- spacing: [],
83
- disabled: ['button', 'input', 'select', 'textarea', 'option', 'optgroup', 'fieldset'],
84
- readOnly: ['input', 'textarea'],
85
- checked: ['input'],
86
- selected: ['option'],
87
- placeholder: ['input', 'textarea'],
88
- label: ['track', 'option', 'optgroup'],
89
- type: [
90
- 'input',
91
- 'button',
92
- 'ol',
93
- 'li',
94
- 'a',
95
- 'source',
96
- 'embed',
97
- 'object',
98
- 'script',
99
- 'style',
100
- 'link',
101
- ],
102
- value: [
103
- 'input',
104
- 'button',
105
- 'select',
106
- 'textarea',
107
- 'option',
108
- 'li',
109
- 'meter',
110
- 'progress',
111
- 'param',
112
- 'data',
113
- 'output',
114
- ],
115
- };
116
- /**
117
- * The state attributes a component's omit list may name for its default element but that are
118
- * the element's own when it is rendered `as` an element that has them (see `omitStyleProps`).
119
- */
120
- var REQORE_ELEMENT_STATE_PROPS = new Set([
121
- 'disabled',
122
- 'readOnly',
123
- 'checked',
124
- 'selected',
125
- ]);
126
- /** Whether `prop` is an attribute of the element `tag`, as far as Reqore's names go. */
127
- var isReqoreElementAttribute = function (prop, tag) {
128
- if (typeof prop !== 'string' || SVG_TAGS.has(tag)) {
129
- return true;
130
- }
131
- var elements = exports.REQORE_AMBIGUOUS_PROP_ELEMENTS[prop];
132
- return !elements || elements.includes(tag);
133
- };
134
- exports.isReqoreElementAttribute = isReqoreElementAttribute;
135
31
  var omitStyleProps = function () {
136
32
  var propsToOmit = [];
137
33
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -140,19 +36,10 @@ var omitStyleProps = function () {
140
36
  var omitted = new Set(propsToOmit);
141
37
  return function (prop, defaultValidatorFn, elementToBeCreated) {
142
38
  if (omitted.has(prop)) {
143
- // A component's omit list is built against its default element. Given `as` another tag
144
- // that has the state attribute — `<ReqorePanel as='fieldset' disabled>`, `<ReqoreTag
145
- // as='button' disabled>` — the attribute is that element's, so it goes through.
146
- return (typeof elementToBeCreated === 'string' &&
147
- REQORE_ELEMENT_STATE_PROPS.has(prop) &&
148
- defaultValidatorFn(prop) &&
149
- exports.REQORE_AMBIGUOUS_PROP_ELEMENTS[prop].includes(elementToBeCreated));
39
+ return false;
150
40
  }
151
- // Mirror styled-components' own default — a component gets everything, a DOM tag what is an
152
- // HTML attribute — except that a DOM tag only gets an attribute of ITS element.
153
- return typeof elementToBeCreated === 'string'
154
- ? defaultValidatorFn(prop) && (0, exports.isReqoreElementAttribute)(prop, elementToBeCreated)
155
- : true;
41
+ // Mirror styled-components' own default so only the omitted props change behaviour.
42
+ return typeof elementToBeCreated === 'string' ? defaultValidatorFn(prop) : true;
156
43
  };
157
44
  };
158
45
  exports.omitStyleProps = omitStyleProps;
@@ -190,43 +77,4 @@ exports.REQORE_CONTROL_GROUP_CHILD_PROPS = [
190
77
  'isMasterGroupRounded',
191
78
  'rounded',
192
79
  ];
193
- /**
194
- * Lists a component's styling props for `omitStyleProps`, from a record the compiler checks
195
- * against the component's prop interface.
196
- *
197
- * A hand-written omit list goes stale: a prop added to the interface later reaches the rendered
198
- * element until someone remembers the list (ReqoreButton rendered `as` a router link handed its
199
- * `fluid`, `compact`, `maxWidth`, ... to the link, which wrote them onto its `<a>`; a resizable,
200
- * transparent ReqorePanel handed re-resizable `transparent`). Typed as
201
- * `Record<TReqoreStylePropKeys<...>, true>`, the record must name every such prop and nothing
202
- * else, so a new prop that is not added fails the build instead of leaking.
203
- *
204
- * @example
205
- * const BUTTON_STYLE_PROPS = listReqoreStyleProps<
206
- * TReqoreStylePropKeys<IReqoreButtonStyle, React.ButtonHTMLAttributes<HTMLButtonElement>>
207
- * >({ fluid: true, compact: true, ... });
208
- */
209
- var listReqoreStyleProps = function (props) {
210
- return Object.keys(props);
211
- };
212
- exports.listReqoreStyleProps = listReqoreStyleProps;
213
- /**
214
- * Reqore's `styled`: styled-components' own, except that every styled component it makes filters
215
- * its props with `omitStyleProps()` — so a DOM element only receives the attributes of ITS
216
- * element (see `REQORE_AMBIGUOUS_PROP_ELEMENTS`), whether or not its author remembered to filter.
217
- *
218
- * Every Reqore source file imports `styled` from here (an ESLint rule forbids the default import
219
- * of `styled-components`). A styled component's own `.withConfig({ shouldForwardProp })`
220
- * replaces this filter, and is built with `omitStyleProps`, which includes it.
221
- */
222
- var withReqoreProps = function (construct) {
223
- return typeof (construct === null || construct === void 0 ? void 0 : construct.withConfig) === 'function'
224
- ? construct.withConfig({ shouldForwardProp: (0, exports.omitStyleProps)() })
225
- : construct;
226
- };
227
- var reqoreStyled = new Proxy(styled_components_1.default, {
228
- apply: function (target, thisArg, args) { return withReqoreProps(Reflect.apply(target, thisArg, args)); },
229
- get: function (target, key, receiver) { return withReqoreProps(Reflect.get(target, key, receiver)); },
230
- });
231
- exports.default = reqoreStyled;
232
80
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.js","sourceRoot":"","sources":["../../src/helpers/styled.ts"],"names":[],"mappings":";;;;;;AACA,wEAA2C;AAe3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,kGAAkG;AAClG,IAAM,QAAQ,GAAG,IAAI,GAAG,CAAS;IAC/B,KAAK;IACL,GAAG;IACH,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,UAAU;IACV,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,UAAU;IACV,MAAM;IACN,QAAQ;IACR,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,MAAM;IACN,eAAe;IACf,QAAQ;CACT,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACU,QAAA,8BAA8B,GAEvC;IACF,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IACzB,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC;IAC1F,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;IACxE,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;IACb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AC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClF,CAAC,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB;AAEF;;;;;;GAMG;AACU,QAAA,gCAAgC,GAAG;IAC9C,aAAa;IACb,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,cAAc;IACd,OAAO;IACP,qBAAqB;IACrB,SAAS;IACT,eAAe;IACf,SAAS;IACT,SAAS;IACT,cAAc;IACd,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,QAAQ;IACR,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;IACtB,SAAS;CACV,CAAC"}
@@ -0,0 +1,77 @@
1
+ /** The axis a drag is on. */
2
+ export type TPointerDragAxis = 'x' | 'y' | 'both';
3
+ /** Where a drag has got to. */
4
+ export interface IPointerDragDelta {
5
+ /** How far the pointer is from where it was pressed, in px. */
6
+ dx: number;
7
+ dy: number;
8
+ /** How fast it moved last, in px per ms; `0` until it has moved twice. */
9
+ vx: number;
10
+ vy: number;
11
+ }
12
+ /**
13
+ * The controls a press belongs to rather than to the surface around them: a button (a close
14
+ * control, an action), a link, a field, and the control group actions sit in. For a `canStart`
15
+ * that leaves those alone, as the drawer's title bar and a notification do.
16
+ */
17
+ export declare const DRAG_CONTROL_SELECTOR = "button, a, input, textarea, select, [role=\"button\"], [contenteditable], .reqore-control-group";
18
+ export interface IUsePointerDragOptions {
19
+ /** Off, every handler is inert and a press is just a press. Default `true`. */
20
+ enabled?: boolean;
21
+ /**
22
+ * Along `'x'` or `'y'`, a press that first moves mostly along the OTHER axis is not a drag: it
23
+ * is left to whatever that axis belongs to, which is usually the page or the content
24
+ * scrolling. `'both'` takes any direction. Default `'both'`.
25
+ */
26
+ axis?: TPointerDragAxis;
27
+ /** How far a press moves, in px, before it is a drag and not a click. Default `SWIPE.slop`. */
28
+ slop?: number;
29
+ /**
30
+ * Whether `dragging` is kept as state, so the element re-renders as a drag starts and ends.
31
+ * `false` for a surface that must not re-render mid-gesture — a rail of memoized tiles — which
32
+ * then carries its own drag state in `onStart` / `onEnd`. Default `true`.
33
+ */
34
+ trackDragging?: boolean;
35
+ /** Whether a press on this target may become a drag. Default: any primary-button press. */
36
+ canStart?: (event: React.PointerEvent<HTMLElement>) => boolean;
37
+ /** The press on `element` has moved past `slop` along the axis and is now a drag. */
38
+ onStart?: (element: HTMLElement, event: PointerEvent) => void;
39
+ /** The pointer moved while dragging. */
40
+ onMove?: (delta: IPointerDragDelta, event: PointerEvent) => void;
41
+ /**
42
+ * The drag ended: `committed` when the pointer was let go, not when the browser cancelled it
43
+ * (a touch the system took over), the window lost focus, or a mouse was let go off-window.
44
+ */
45
+ onEnd?: (delta: IPointerDragDelta, committed: boolean) => void;
46
+ }
47
+ /** The handlers to spread onto the element that takes the drag. */
48
+ export interface IPointerDragHandlers {
49
+ onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
50
+ /** Swallows the click a drag ends with, so it is not a click on whatever it ended over. */
51
+ onClickCapture: (event: React.MouseEvent<HTMLElement>) => void;
52
+ /** Keeps the browser's own drag-and-drop (an image, a link, selected text) out of a drag. */
53
+ onDragStart: (event: React.DragEvent<HTMLElement>) => void;
54
+ }
55
+ export interface IUsePointerDrag {
56
+ /** Whether a drag is under way (always `false` with `trackDragging: false`). */
57
+ dragging: boolean;
58
+ handlers: IPointerDragHandlers;
59
+ }
60
+ /**
61
+ * A pointer drag — mouse, touch or pen — on one element: a press becomes a drag once it has
62
+ * moved past `slop` along the right axis, every move reports the distance from the press and
63
+ * the latest velocity, and the click a drag would end with is swallowed. The one gesture a
64
+ * sheet is pushed away with, a modal moved by, a tier stack swiped and a scroller pulled.
65
+ *
66
+ * The live gesture is tracked on the WINDOW, not on the element. A pull leaves a thin handle
67
+ * at once and the release can land anywhere, including outside the browser window; an element
68
+ * listening only to itself would never see that release and would stay stuck to the pointer.
69
+ * Pointer capture alone does not cover it, because capture is taken only once the drag engages
70
+ * and a fast pull is past the element before the first qualifying move. The listeners are
71
+ * bound per gesture, so an idle element adds no global listener, and the gesture also ends on
72
+ * a move with no button held (a release the page never saw) and when the window loses focus.
73
+ *
74
+ * The handlers never change identity; the options are read as they are when an event arrives.
75
+ */
76
+ export declare const usePointerDrag: (options: IUsePointerDragOptions) => IUsePointerDrag;
77
+ //# sourceMappingURL=usePointerDrag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePointerDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/usePointerDrag.ts"],"names":[],"mappings":"AAGA,6BAA6B;AAC7B,MAAM,MAAM,gBAAgB,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAElD,+BAA+B;AAC/B,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,oGAC+D,CAAC;AAElG,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IAC/D,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9D,wCAAwC;IACxC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACjE;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAChE;AAED,mEAAmE;AACnE,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAChE,2FAA2F;IAC3F,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC/D,6FAA6F;IAC7F,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAgBD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,sBAAsB,KAAG,eA2MhE,CAAC"}
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePointerDrag = exports.DRAG_CONTROL_SELECTOR = void 0;
4
+ var react_1 = require("react");
5
+ var gestures_1 = require("../helpers/gestures");
6
+ /**
7
+ * The controls a press belongs to rather than to the surface around them: a button (a close
8
+ * control, an action), a link, a field, and the control group actions sit in. For a `canStart`
9
+ * that leaves those alone, as the drawer's title bar and a notification do.
10
+ */
11
+ exports.DRAG_CONTROL_SELECTOR = 'button, a, input, textarea, select, [role="button"], [contenteditable], .reqore-control-group';
12
+ /**
13
+ * A pointer drag — mouse, touch or pen — on one element: a press becomes a drag once it has
14
+ * moved past `slop` along the right axis, every move reports the distance from the press and
15
+ * the latest velocity, and the click a drag would end with is swallowed. The one gesture a
16
+ * sheet is pushed away with, a modal moved by, a tier stack swiped and a scroller pulled.
17
+ *
18
+ * The live gesture is tracked on the WINDOW, not on the element. A pull leaves a thin handle
19
+ * at once and the release can land anywhere, including outside the browser window; an element
20
+ * listening only to itself would never see that release and would stay stuck to the pointer.
21
+ * Pointer capture alone does not cover it, because capture is taken only once the drag engages
22
+ * and a fast pull is past the element before the first qualifying move. The listeners are
23
+ * bound per gesture, so an idle element adds no global listener, and the gesture also ends on
24
+ * a move with no button held (a release the page never saw) and when the window loses focus.
25
+ *
26
+ * The handlers never change identity; the options are read as they are when an event arrives.
27
+ */
28
+ var usePointerDrag = function (options) {
29
+ var optionsRef = (0, react_1.useRef)(options);
30
+ optionsRef.current = options;
31
+ var gestureRef = (0, react_1.useRef)(null);
32
+ var suppressClickRef = (0, react_1.useRef)(false);
33
+ // Takes down the live gesture's window listeners; `null` while none is live.
34
+ var stopTrackingRef = (0, react_1.useRef)(null);
35
+ var _a = (0, react_1.useState)(false), dragging = _a[0], setDragging = _a[1];
36
+ var finish = (0, react_1.useCallback)(function (committed) {
37
+ var _a, _b, _c, _d, _e;
38
+ var gesture = gestureRef.current;
39
+ gestureRef.current = null;
40
+ (_a = stopTrackingRef.current) === null || _a === void 0 ? void 0 : _a.call(stopTrackingRef);
41
+ stopTrackingRef.current = null;
42
+ if (!(gesture === null || gesture === void 0 ? void 0 : gesture.dragging)) {
43
+ return;
44
+ }
45
+ if ((_c = (_b = gesture.element).hasPointerCapture) === null || _c === void 0 ? void 0 : _c.call(_b, gesture.pointerId)) {
46
+ gesture.element.releasePointerCapture(gesture.pointerId);
47
+ }
48
+ // The click that ends a drag is not a click on whatever it ended over. A mouse's click
49
+ // follows its release at once; a touch drag produces none, so the flag is dropped on the
50
+ // next turn of the event loop rather than left armed for a later, unrelated click.
51
+ suppressClickRef.current = true;
52
+ setTimeout(function () {
53
+ suppressClickRef.current = false;
54
+ }, 0);
55
+ if (optionsRef.current.trackDragging !== false) {
56
+ setDragging(false);
57
+ }
58
+ (_e = (_d = optionsRef.current).onEnd) === null || _e === void 0 ? void 0 : _e.call(_d, {
59
+ dx: gesture.lastX - gesture.startX,
60
+ dy: gesture.lastY - gesture.startY,
61
+ vx: gesture.vx,
62
+ vy: gesture.vy,
63
+ }, committed);
64
+ }, []);
65
+ var track = (0, react_1.useCallback)(function () {
66
+ var onMove = function (event) {
67
+ var _a, _b, _c, _d;
68
+ var gesture = gestureRef.current;
69
+ if (!gesture || gesture.pointerId !== event.pointerId) {
70
+ return;
71
+ }
72
+ // Nothing is held, so the button came up somewhere this page could never observe it —
73
+ // off the edge of the window, the usual way. `buttons` is what is pressed RIGHT NOW, so
74
+ // during a real drag it can only be non-zero.
75
+ if (event.buttons === 0) {
76
+ finish(false);
77
+ return;
78
+ }
79
+ var dx = event.clientX - gesture.startX;
80
+ var dy = event.clientY - gesture.startY;
81
+ if (!gesture.dragging) {
82
+ var _e = optionsRef.current, _f = _e.axis, axis = _f === void 0 ? 'both' : _f, _g = _e.slop, slop = _g === void 0 ? gestures_1.SWIPE.slop : _g;
83
+ if (Math.abs(dx) < slop && Math.abs(dy) < slop) {
84
+ return;
85
+ }
86
+ // Mostly along the other axis: whatever that axis belongs to takes the press.
87
+ if ((axis === 'x' && Math.abs(dy) >= Math.abs(dx)) ||
88
+ (axis === 'y' && Math.abs(dx) >= Math.abs(dy))) {
89
+ finish(false);
90
+ return;
91
+ }
92
+ gesture.dragging = true;
93
+ // Capture keeps the moves addressed to the element while the pointer is over others;
94
+ // the window listeners are what make the drag survive leaving it.
95
+ try {
96
+ gesture.element.setPointerCapture(event.pointerId);
97
+ }
98
+ catch (_h) {
99
+ // Capture is a nicety, not the mechanism.
100
+ }
101
+ if (optionsRef.current.trackDragging !== false) {
102
+ setDragging(true);
103
+ }
104
+ (_b = (_a = optionsRef.current).onStart) === null || _b === void 0 ? void 0 : _b.call(_a, gesture.element, event);
105
+ }
106
+ var elapsed = event.timeStamp - gesture.lastTime;
107
+ if (elapsed > 0) {
108
+ gesture.vx = (event.clientX - gesture.lastX) / elapsed;
109
+ gesture.vy = (event.clientY - gesture.lastY) / elapsed;
110
+ }
111
+ gesture.lastX = event.clientX;
112
+ gesture.lastY = event.clientY;
113
+ gesture.lastTime = event.timeStamp;
114
+ (_d = (_c = optionsRef.current).onMove) === null || _d === void 0 ? void 0 : _d.call(_c, { dx: dx, dy: dy, vx: gesture.vx, vy: gesture.vy }, event);
115
+ };
116
+ var onEnd = function (event) {
117
+ var _a;
118
+ if (((_a = gestureRef.current) === null || _a === void 0 ? void 0 : _a.pointerId) === event.pointerId) {
119
+ finish(event.type === 'pointerup');
120
+ }
121
+ };
122
+ // Alt-tabbing mid-drag: the release happens in another window.
123
+ var onBlur = function () { return finish(false); };
124
+ window.addEventListener('pointermove', onMove);
125
+ window.addEventListener('pointerup', onEnd);
126
+ window.addEventListener('pointercancel', onEnd);
127
+ window.addEventListener('lostpointercapture', onEnd);
128
+ window.addEventListener('blur', onBlur);
129
+ stopTrackingRef.current = function () {
130
+ window.removeEventListener('pointermove', onMove);
131
+ window.removeEventListener('pointerup', onEnd);
132
+ window.removeEventListener('pointercancel', onEnd);
133
+ window.removeEventListener('lostpointercapture', onEnd);
134
+ window.removeEventListener('blur', onBlur);
135
+ };
136
+ }, [finish]);
137
+ // A gesture live at unmount would otherwise leave its window listeners behind.
138
+ (0, react_1.useEffect)(function () { return function () {
139
+ var _a;
140
+ gestureRef.current = null;
141
+ (_a = stopTrackingRef.current) === null || _a === void 0 ? void 0 : _a.call(stopTrackingRef);
142
+ stopTrackingRef.current = null;
143
+ }; }, []);
144
+ var handlers = (0, react_1.useMemo)(function () { return ({
145
+ onPointerDown: function (event) {
146
+ // A fresh press ends a gesture whose release the page never saw, and makes its click
147
+ // moot — INCLUDING a press this handler goes on to decline: pressing a field must not
148
+ // inherit a swallow from a drag that ended somewhere the page did not see.
149
+ if (gestureRef.current) {
150
+ finish(false);
151
+ }
152
+ suppressClickRef.current = false;
153
+ var _a = optionsRef.current, _b = _a.enabled, enabled = _b === void 0 ? true : _b, canStart = _a.canStart;
154
+ if (!enabled ||
155
+ (event.pointerType === 'mouse' && event.button !== 0) ||
156
+ (canStart && !canStart(event))) {
157
+ return;
158
+ }
159
+ gestureRef.current = {
160
+ pointerId: event.pointerId,
161
+ element: event.currentTarget,
162
+ startX: event.clientX,
163
+ startY: event.clientY,
164
+ lastX: event.clientX,
165
+ lastY: event.clientY,
166
+ lastTime: event.timeStamp,
167
+ vx: 0,
168
+ vy: 0,
169
+ dragging: false,
170
+ };
171
+ track();
172
+ },
173
+ onClickCapture: function (event) {
174
+ if (suppressClickRef.current) {
175
+ suppressClickRef.current = false;
176
+ event.preventDefault();
177
+ event.stopPropagation();
178
+ }
179
+ },
180
+ // A native drag beats pointer events to the punch on links and images; one that starts
181
+ // after the press became a drag is ours.
182
+ onDragStart: function (event) {
183
+ var _a;
184
+ if ((_a = gestureRef.current) === null || _a === void 0 ? void 0 : _a.dragging) {
185
+ event.preventDefault();
186
+ }
187
+ },
188
+ }); }, [finish, track]);
189
+ return { dragging: dragging, handlers: handlers };
190
+ };
191
+ exports.usePointerDrag = usePointerDrag;
192
+ //# sourceMappingURL=usePointerDrag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePointerDrag.js","sourceRoot":"","sources":["../../src/hooks/usePointerDrag.ts"],"names":[],"mappings":";;;AAAA,+BAA0E;AAC1E,gDAA4C;AAe5C;;;;GAIG;AACU,QAAA,qBAAqB,GAChC,+FAA+F,CAAC;AA6DlG;;;;;;;;;;;;;;;GAeG;AACI,IAAM,cAAc,GAAG,UAAC,OAA+B;IAC5D,IAAM,UAAU,GAAG,IAAA,cAAM,EAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,IAAM,UAAU,GAAG,IAAA,cAAM,EAAyB,IAAI,CAAC,CAAC;IACxD,IAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IACvC,6EAA6E;IAC7E,IA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E,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,uFAAuF;QACvF,yCAAyC;QACzC,WAAW,EAAE,UAAC,KAAK;;YACjB,IAAI,MAAA,UAAU,CAAC,OAAO,0CAAE,QAAQ,EAAE,CAAC;gBACjC,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;KACF,CAAC,EAjDI,CAiDJ,EACF,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IAEF,OAAO,EAAE,QAAQ,UAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAChC,CAAC,CAAC;AA3MW,QAAA,cAAc,kBA2MzB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Whether this environment can answer a media query at all. Decided ONCE at
3
+ * module load, on purpose: `useReqoreMedia` calls `useMedia` only when this is
4
+ * true, and a hook that appears in one render and not the next is a React
5
+ * error — a test that defines `window.matchMedia` after the module loaded
6
+ * (several do, to drive their own hooks) must not be able to flip it.
7
+ *
8
+ * jsdom has no `matchMedia`, so unit tests get fixed defaults. A real browser —
9
+ * the app, the Storybook dev server AND the browser-mode story runner — gets
10
+ * live queries, which is what makes a mobile story able to prove a breakpoint
11
+ * branch. The previous guard keyed on `NODE_ENV === 'test'`, which Vitest also
12
+ * sets for browser-mode stories, so every width-dependent behaviour in the
13
+ * library was unprovable by a story.
14
+ */
15
+ export declare const CAN_QUERY_MEDIA: boolean;
16
+ /**
17
+ * `useMedia` that degrades to `defaultState` where media queries cannot be
18
+ * evaluated (jsdom, SSR) instead of throwing. Reqore owns the breakpoints:
19
+ * this is for Reqore's own components — the provider's `isMobile` /
20
+ * `isTablet` / `isHoverCapable` and the drawer's sheet breakpoint — not a
21
+ * licence for a consumer to hand-roll a query of its own.
22
+ */
23
+ export declare const useReqoreMedia: (query: string, defaultState?: boolean) => boolean;
24
+ //# sourceMappingURL=useReqoreMedia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReqoreMedia.d.ts","sourceRoot":"","sources":["../../src/hooks/useReqoreMedia.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,SAC8C,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,sBAAoB,KAAG,OACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useReqoreMedia = exports.CAN_QUERY_MEDIA = void 0;
4
+ var react_use_1 = require("react-use");
5
+ /**
6
+ * Whether this environment can answer a media query at all. Decided ONCE at
7
+ * module load, on purpose: `useReqoreMedia` calls `useMedia` only when this is
8
+ * true, and a hook that appears in one render and not the next is a React
9
+ * error — a test that defines `window.matchMedia` after the module loaded
10
+ * (several do, to drive their own hooks) must not be able to flip it.
11
+ *
12
+ * jsdom has no `matchMedia`, so unit tests get fixed defaults. A real browser —
13
+ * the app, the Storybook dev server AND the browser-mode story runner — gets
14
+ * live queries, which is what makes a mobile story able to prove a breakpoint
15
+ * branch. The previous guard keyed on `NODE_ENV === 'test'`, which Vitest also
16
+ * sets for browser-mode stories, so every width-dependent behaviour in the
17
+ * library was unprovable by a story.
18
+ */
19
+ exports.CAN_QUERY_MEDIA = typeof window !== 'undefined' && typeof window.matchMedia === 'function';
20
+ /**
21
+ * `useMedia` that degrades to `defaultState` where media queries cannot be
22
+ * evaluated (jsdom, SSR) instead of throwing. Reqore owns the breakpoints:
23
+ * this is for Reqore's own components — the provider's `isMobile` /
24
+ * `isTablet` / `isHoverCapable` and the drawer's sheet breakpoint — not a
25
+ * licence for a consumer to hand-roll a query of its own.
26
+ */
27
+ var useReqoreMedia = function (query, defaultState) {
28
+ if (defaultState === void 0) { defaultState = false; }
29
+ return exports.CAN_QUERY_MEDIA ? (0, react_use_1.useMedia)(query, defaultState) : defaultState;
30
+ };
31
+ exports.useReqoreMedia = useReqoreMedia;
32
+ //# sourceMappingURL=useReqoreMedia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReqoreMedia.js","sourceRoot":"","sources":["../../src/hooks/useReqoreMedia.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAErC;;;;;;;;;;;;;GAaG;AACU,QAAA,eAAe,GAC1B,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,CAAC;AAE3E;;;;;;GAMG;AACI,IAAM,cAAc,GAAG,UAAC,KAAa,EAAE,YAAoB;IAApB,6BAAA,EAAA,oBAAoB;IAChE,OAAA,uBAAe,CAAC,CAAC,CAAC,IAAA,oBAAQ,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY;AAA9D,CAA8D,CAAC;AADpD,QAAA,cAAc,kBACsC"}