panelui-native 0.80.0 → 0.82.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 (92) hide show
  1. package/lib/module/components/bottom-sheet/index.js +90 -17
  2. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  3. package/lib/module/components/button/index.js +13 -0
  4. package/lib/module/components/button/index.js.map +1 -1
  5. package/lib/module/components/button-group/index.js +3 -0
  6. package/lib/module/components/button-group/index.js.map +1 -1
  7. package/lib/module/components/image-generation/dot-field.js +210 -0
  8. package/lib/module/components/image-generation/dot-field.js.map +1 -0
  9. package/lib/module/components/image-generation/index.js +417 -0
  10. package/lib/module/components/image-generation/index.js.map +1 -0
  11. package/lib/module/components/kpi/index.js +2 -4
  12. package/lib/module/components/kpi/index.js.map +1 -1
  13. package/lib/module/components/menu/index.js +8 -16
  14. package/lib/module/components/menu/index.js.map +1 -1
  15. package/lib/module/components/panelside/index.js +340 -33
  16. package/lib/module/components/panelside/index.js.map +1 -1
  17. package/lib/module/components/planner/index.js +446 -32
  18. package/lib/module/components/planner/index.js.map +1 -1
  19. package/lib/module/components/planner/planner-entries.js +36 -0
  20. package/lib/module/components/planner/planner-entries.js.map +1 -1
  21. package/lib/module/components/planner/planner-grid-navigation.js +34 -2
  22. package/lib/module/components/planner/planner-grid-navigation.js.map +1 -1
  23. package/lib/module/components/planner/planner-weeks.js +95 -0
  24. package/lib/module/components/planner/planner-weeks.js.map +1 -0
  25. package/lib/module/components/select/index.js +127 -23
  26. package/lib/module/components/select/index.js.map +1 -1
  27. package/lib/module/components/slide-button/index.js +610 -0
  28. package/lib/module/components/slide-button/index.js.map +1 -0
  29. package/lib/module/components/slide-button/slide-button-track.js +98 -0
  30. package/lib/module/components/slide-button/slide-button-track.js.map +1 -0
  31. package/lib/module/icons/index.js +553 -1934
  32. package/lib/module/icons/index.js.map +1 -1
  33. package/lib/module/index.js +3 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/primitives/portal.js +15 -1
  36. package/lib/module/primitives/portal.js.map +1 -1
  37. package/lib/module/utils/date.js +10 -3
  38. package/lib/module/utils/date.js.map +1 -1
  39. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  40. package/lib/typescript/src/components/button/index.d.ts +12 -0
  41. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  42. package/lib/typescript/src/components/button-group/index.d.ts +9 -0
  43. package/lib/typescript/src/components/button-group/index.d.ts.map +1 -1
  44. package/lib/typescript/src/components/image-generation/dot-field.d.ts +61 -0
  45. package/lib/typescript/src/components/image-generation/dot-field.d.ts.map +1 -0
  46. package/lib/typescript/src/components/image-generation/index.d.ts +126 -0
  47. package/lib/typescript/src/components/image-generation/index.d.ts.map +1 -0
  48. package/lib/typescript/src/components/kpi/index.d.ts.map +1 -1
  49. package/lib/typescript/src/components/menu/index.d.ts.map +1 -1
  50. package/lib/typescript/src/components/panelside/index.d.ts +194 -10
  51. package/lib/typescript/src/components/panelside/index.d.ts.map +1 -1
  52. package/lib/typescript/src/components/planner/index.d.ts +65 -4
  53. package/lib/typescript/src/components/planner/index.d.ts.map +1 -1
  54. package/lib/typescript/src/components/planner/planner-entries.d.ts +18 -0
  55. package/lib/typescript/src/components/planner/planner-entries.d.ts.map +1 -1
  56. package/lib/typescript/src/components/planner/planner-grid-navigation.d.ts +7 -1
  57. package/lib/typescript/src/components/planner/planner-grid-navigation.d.ts.map +1 -1
  58. package/lib/typescript/src/components/planner/planner-weeks.d.ts +50 -0
  59. package/lib/typescript/src/components/planner/planner-weeks.d.ts.map +1 -0
  60. package/lib/typescript/src/components/select/index.d.ts +75 -2
  61. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  62. package/lib/typescript/src/components/slide-button/index.d.ts +317 -0
  63. package/lib/typescript/src/components/slide-button/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/slide-button/slide-button-track.d.ts +70 -0
  65. package/lib/typescript/src/components/slide-button/slide-button-track.d.ts.map +1 -0
  66. package/lib/typescript/src/icons/index.d.ts +136 -189
  67. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  68. package/lib/typescript/src/index.d.ts +5 -3
  69. package/lib/typescript/src/index.d.ts.map +1 -1
  70. package/lib/typescript/src/primitives/portal.d.ts.map +1 -1
  71. package/lib/typescript/src/utils/date.d.ts +1 -1
  72. package/lib/typescript/src/utils/date.d.ts.map +1 -1
  73. package/package.json +3 -2
  74. package/src/components/bottom-sheet/index.tsx +97 -17
  75. package/src/components/button/index.tsx +10 -2
  76. package/src/components/button-group/index.tsx +1 -0
  77. package/src/components/image-generation/dot-field.ts +226 -0
  78. package/src/components/image-generation/index.tsx +488 -0
  79. package/src/components/kpi/index.tsx +2 -4
  80. package/src/components/menu/index.tsx +10 -15
  81. package/src/components/panelside/index.tsx +498 -33
  82. package/src/components/planner/index.tsx +516 -38
  83. package/src/components/planner/planner-entries.ts +33 -0
  84. package/src/components/planner/planner-grid-navigation.ts +37 -2
  85. package/src/components/planner/planner-weeks.ts +90 -0
  86. package/src/components/select/index.tsx +158 -31
  87. package/src/components/slide-button/index.tsx +681 -0
  88. package/src/components/slide-button/slide-button-track.ts +100 -0
  89. package/src/icons/index.tsx +338 -1327
  90. package/src/index.ts +30 -0
  91. package/src/primitives/portal.tsx +15 -1
  92. package/src/utils/date.ts +13 -3
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The arithmetic behind a slide, kept out of the component so it can be tested
3
+ * without a renderer — the same split `progress-button-hold` uses.
4
+ *
5
+ * The gesture's worklets carry their own copies of these three lines rather
6
+ * than calling in here. A pan handler is the one place in the library that
7
+ * cannot afford a surprise: a worklet reaching across a module boundary for a
8
+ * helper that reaches across again for another is a chain with more ways to go
9
+ * wrong than the arithmetic is long. What lives here is the definition, and
10
+ * the tests hold the component to it.
11
+ */
12
+
13
+ /** The fraction of the rail that has to be covered for the slide to count. */
14
+ export const DEFAULT_THRESHOLD = 0.9;
15
+
16
+ /** Milliseconds before an `autoReset` button offers itself again. */
17
+ export const DEFAULT_AUTO_RESET_DELAY = 1000;
18
+
19
+ /**
20
+ * Seconds of fling counted as distance already travelled.
21
+ *
22
+ * A slide released at speed near the end was going to arrive, and stopping it
23
+ * dead a few points short is the control arguing with a gesture that had
24
+ * plainly committed. Small, because the reverse mistake — a flick from
25
+ * halfway completing an action the reader was only playing with — is the
26
+ * worse one.
27
+ */
28
+ export const VELOCITY_LOOKAHEAD = 0.12;
29
+
30
+ /**
31
+ * How far past the end the thumb can be pushed, as a divisor on the overshoot.
32
+ *
33
+ * The rail has an end and the finger does not, so the distance past it is
34
+ * given back at an eighth. Without this the thumb parks under the finger with
35
+ * a gap opening behind it, which reads as the control having come loose.
36
+ */
37
+ export const OVERSHOOT_FRICTION = 8;
38
+
39
+ /**
40
+ * A threshold that cannot produce a button which fires on contact.
41
+ *
42
+ * Zero would complete the moment the thumb moved, which is a button with a
43
+ * gesture in front of it rather than a slide. One is allowed: it means the
44
+ * thumb has to reach the far end exactly, which is a legitimate ask for
45
+ * something destructive.
46
+ */
47
+ export function resolveThreshold(threshold: number | undefined): number {
48
+ if (threshold === undefined || !Number.isFinite(threshold)) return DEFAULT_THRESHOLD;
49
+ return Math.min(1, Math.max(0.1, threshold));
50
+ }
51
+
52
+ /**
53
+ * How far along the rail the thumb has been dragged, as `0` to `1`.
54
+ *
55
+ * `travel` is the rail minus the thumb — the distance the thumb's own leading
56
+ * edge can actually cover. Measuring against the full rail width instead would
57
+ * make the last thumb-width of the track unreachable, so a slide could never
58
+ * finish.
59
+ */
60
+ export function progressFor(translation: number, travel: number): number {
61
+ if (travel <= 0) return 0;
62
+ return clamp(translation / travel, 0, 1);
63
+ }
64
+
65
+ /**
66
+ * The thumb's offset in points, rubber-banded once it passes the end.
67
+ *
68
+ * Before the end it follows the finger exactly. There is no easing on the way
69
+ * out, because a thumb that lags its own finger reads as a slow app rather
70
+ * than as a heavy control.
71
+ */
72
+ export function offsetFor(translation: number, travel: number): number {
73
+ if (travel <= 0) return 0;
74
+ if (translation < 0) return translation / OVERSHOOT_FRICTION;
75
+ if (translation <= travel) return translation;
76
+ return travel + (translation - travel) / OVERSHOOT_FRICTION;
77
+ }
78
+
79
+ /**
80
+ * Whether a released slide should be honoured.
81
+ *
82
+ * Where it got to, plus where its speed was about to carry it. A slide let go
83
+ * short and still is refused; a slide let go short and travelling is not,
84
+ * because the reader has already made the movement that finishes it.
85
+ */
86
+ export function isCommitted(
87
+ progress: number,
88
+ velocity: number,
89
+ travel: number,
90
+ threshold: number
91
+ ): boolean {
92
+ if (travel <= 0) return false;
93
+ const projected = progress + (velocity * VELOCITY_LOOKAHEAD) / travel;
94
+ return projected >= threshold;
95
+ }
96
+
97
+ /** Keeps a number inside a range. Exported because the tests read it. */
98
+ export function clamp(value: number, low: number, high: number): number {
99
+ return Math.min(high, Math.max(low, value));
100
+ }