@orioncactuscorp/ui 1.12.2 → 1.14.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 (56) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +92 -12
  3. package/dist/components/Badge/Badge.css +1 -1
  4. package/dist/components/Badge/Badge.module.scss.js +12 -12
  5. package/dist/components/FloatingWindow/FloatingWindow.css +1 -0
  6. package/dist/components/FloatingWindow/FloatingWindow.js +692 -0
  7. package/dist/components/FloatingWindow/FloatingWindow.module.scss.js +17 -0
  8. package/dist/components/FloatingWindow/FloatingWindowManager.js +36 -0
  9. package/dist/components/FloatingWindow/contexts.js +25 -0
  10. package/dist/components/FloatingWindow/geometry.js +222 -0
  11. package/dist/components/FloatingWindow/stack.js +31 -0
  12. package/dist/components/FloatingWindow.d.ts +6 -0
  13. package/dist/components/FloatingWindow.js +18 -0
  14. package/dist/components/Modal/Modal.css +1 -1
  15. package/dist/components/Modal/Modal.js +534 -715
  16. package/dist/components/Modal/Modal.module.scss.js +46 -44
  17. package/dist/components/Modal/initialFocus.js +11 -0
  18. package/dist/components/Modal/useModalDrag.js +328 -310
  19. package/dist/components/internal/ModalPresentation.js +359 -0
  20. package/dist/index.js +108 -92
  21. package/dist/styles.css +3 -2
  22. package/dist/ui/src/components/Badge/types.d.ts +1 -1
  23. package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
  24. package/dist/ui/src/components/FloatingWindow/FloatingWindow.d.ts +32 -0
  25. package/dist/ui/src/components/FloatingWindow/FloatingWindow.d.ts.map +1 -0
  26. package/dist/ui/src/components/FloatingWindow/FloatingWindowManager.d.ts +4 -0
  27. package/dist/ui/src/components/FloatingWindow/FloatingWindowManager.d.ts.map +1 -0
  28. package/dist/ui/src/components/FloatingWindow/contexts.d.ts +36 -0
  29. package/dist/ui/src/components/FloatingWindow/contexts.d.ts.map +1 -0
  30. package/dist/ui/src/components/FloatingWindow/geometry.d.ts +31 -0
  31. package/dist/ui/src/components/FloatingWindow/geometry.d.ts.map +1 -0
  32. package/dist/ui/src/components/FloatingWindow/index.d.ts +4 -0
  33. package/dist/ui/src/components/FloatingWindow/index.d.ts.map +1 -0
  34. package/dist/ui/src/components/FloatingWindow/stack.d.ts +9 -0
  35. package/dist/ui/src/components/FloatingWindow/stack.d.ts.map +1 -0
  36. package/dist/ui/src/components/FloatingWindow/types.d.ts +121 -0
  37. package/dist/ui/src/components/FloatingWindow/types.d.ts.map +1 -0
  38. package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
  39. package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
  40. package/dist/ui/src/components/Modal/contexts.d.ts +3 -0
  41. package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
  42. package/dist/ui/src/components/Modal/initialFocus.d.ts +18 -0
  43. package/dist/ui/src/components/Modal/initialFocus.d.ts.map +1 -0
  44. package/dist/ui/src/components/Modal/types.d.ts +9 -1
  45. package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
  46. package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
  47. package/dist/ui/src/components/internal/ModalPresentation.d.ts +61 -0
  48. package/dist/ui/src/components/internal/ModalPresentation.d.ts.map +1 -0
  49. package/dist/ui/src/index.d.ts +2 -0
  50. package/dist/ui/src/index.d.ts.map +1 -1
  51. package/dist/ui/src/utils/motion.d.ts.map +1 -1
  52. package/dist/utils/motion.js +194 -135
  53. package/docs/api-conventions.md +2 -5
  54. package/docs/motion.md +4 -0
  55. package/docs/selector-contract.md +58 -0
  56. package/package.json +2 -2
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { jsx as W } from "react/jsx-runtime";
3
+ import { useRef as v, useState as F, useCallback as l, useMemo as m } from "react";
4
+ import { FloatingWindowManagerContext as M } from "./contexts.js";
5
+ import { registerFloatingWindow as w, unregisterFloatingWindow as d, activateFloatingWindow as k } from "./stack.js";
6
+ function q({
7
+ children: f
8
+ }) {
9
+ const r = v(/* @__PURE__ */ new Map()), [n, o] = F([]), i = l(
10
+ (t, e) => {
11
+ if (r.current.has(t))
12
+ throw new Error(
13
+ `FloatingWindowManager requires a unique windowId. Duplicate: "${t}".`
14
+ );
15
+ const g = Symbol(t);
16
+ return r.current.set(t, g), o(
17
+ (a) => w(a, { modality: e, windowId: t })
18
+ ), () => {
19
+ r.current.get(t) === g && (r.current.delete(t), o((a) => d(a, t)));
20
+ };
21
+ },
22
+ []
23
+ ), s = l((t) => {
24
+ o((e) => k(e, t));
25
+ }, []), c = m(
26
+ () => new Map(n.map((t, e) => [t.windowId, e])),
27
+ [n]
28
+ ), u = n.at(-1)?.windowId, p = m(
29
+ () => ({ activeWindowId: u, activateWindow: s, registerWindow: i, stackLevels: c }),
30
+ [u, s, i, c]
31
+ );
32
+ return /* @__PURE__ */ W(M.Provider, { value: p, children: f });
33
+ }
34
+ export {
35
+ q as FloatingWindowManager
36
+ };
@@ -0,0 +1,25 @@
1
+ import { useContext as o, createContext as e } from "react";
2
+ const i = e(null), r = e(null), u = e(null);
3
+ function l() {
4
+ return o(u);
5
+ }
6
+ function a(t) {
7
+ const n = o(i);
8
+ if (!n)
9
+ throw new Error(`${t} must be used inside FloatingWindowRoot.`);
10
+ return n;
11
+ }
12
+ function d(t) {
13
+ const n = o(r);
14
+ if (!n)
15
+ throw new Error(`${t} must be used inside FloatingWindowContent.`);
16
+ return n;
17
+ }
18
+ export {
19
+ r as FloatingWindowContentContext,
20
+ u as FloatingWindowManagerContext,
21
+ i as FloatingWindowRootContext,
22
+ d as useFloatingWindowContentContext,
23
+ l as useFloatingWindowManagerContext,
24
+ a as useFloatingWindowRootContext
25
+ };
@@ -0,0 +1,222 @@
1
+ function l(t, e, i) {
2
+ return Math.min(Math.max(t, e), Math.max(e, i));
3
+ }
4
+ function A({
5
+ alignment: t,
6
+ anchorStart: e,
7
+ anchorSize: i,
8
+ floatingSize: h,
9
+ offset: n,
10
+ reverse: c
11
+ }) {
12
+ return t === "center" ? e + (i - h) / 2 + n : (c ? t === "start" : t === "end") ? e + i - h + n : e + n;
13
+ }
14
+ function u({
15
+ alignOffset: t,
16
+ alignment: e,
17
+ anchor: i,
18
+ direction: h,
19
+ side: n,
20
+ sideOffset: c,
21
+ size: o
22
+ }) {
23
+ return n === "top" || n === "bottom" ? {
24
+ x: A({
25
+ alignment: e,
26
+ anchorStart: i.x,
27
+ anchorSize: i.width,
28
+ floatingSize: o.width,
29
+ offset: t,
30
+ reverse: h === "rtl"
31
+ }),
32
+ y: n === "top" ? i.y - o.height - c : i.y + i.height + c
33
+ } : {
34
+ x: n === "left" ? i.x - o.width - c : i.x + i.width + c,
35
+ y: A({
36
+ alignment: e,
37
+ anchorStart: i.y,
38
+ anchorSize: i.height,
39
+ floatingSize: o.height,
40
+ offset: t
41
+ })
42
+ };
43
+ }
44
+ function Y(t) {
45
+ switch (t) {
46
+ case "top":
47
+ return "bottom";
48
+ case "right":
49
+ return "left";
50
+ case "bottom":
51
+ return "top";
52
+ case "left":
53
+ return "right";
54
+ }
55
+ }
56
+ function H(t) {
57
+ return t === "start" ? "end" : t === "end" ? "start" : "center";
58
+ }
59
+ function v(t, e, i, h) {
60
+ const n = i.x + h, c = i.y + h, o = i.x + i.width - h, r = i.y + i.height - h;
61
+ return {
62
+ left: Math.max(0, n - t.x),
63
+ right: Math.max(0, t.x + e.width - o),
64
+ top: Math.max(0, c - t.y),
65
+ bottom: Math.max(0, t.y + e.height - r)
66
+ };
67
+ }
68
+ function M(t, e) {
69
+ return e[t];
70
+ }
71
+ function F(t, e) {
72
+ return t === "top" || t === "bottom" ? e.left + e.right : e.top + e.bottom;
73
+ }
74
+ function B({
75
+ alignOffset: t,
76
+ alignment: e,
77
+ anchor: i,
78
+ boundary: h,
79
+ collisionAvoidance: n,
80
+ direction: c,
81
+ padding: o,
82
+ side: r,
83
+ sideOffset: m,
84
+ size: w
85
+ }) {
86
+ const C = u({
87
+ alignOffset: t,
88
+ alignment: e,
89
+ anchor: i,
90
+ direction: c,
91
+ side: r,
92
+ sideOffset: m,
93
+ size: w
94
+ }), S = v(C, w, h, o);
95
+ let f = r, W = e, x = C;
96
+ if (n.side === "flip" && M(r, S) > 0) {
97
+ const g = Y(r), s = u({
98
+ alignOffset: t,
99
+ alignment: e,
100
+ anchor: i,
101
+ direction: c,
102
+ side: g,
103
+ sideOffset: m,
104
+ size: w
105
+ }), p = v(
106
+ s,
107
+ w,
108
+ h,
109
+ o
110
+ );
111
+ M(g, p) < M(r, S) && (f = g, x = s);
112
+ }
113
+ if (n.alignment === "flip" && e !== "center") {
114
+ const g = v(
115
+ x,
116
+ w,
117
+ h,
118
+ o
119
+ ), s = H(e), p = u({
120
+ alignOffset: t,
121
+ alignment: s,
122
+ anchor: i,
123
+ direction: c,
124
+ side: f,
125
+ sideOffset: m,
126
+ size: w
127
+ }), X = v(
128
+ p,
129
+ w,
130
+ h,
131
+ o
132
+ );
133
+ F(f, X) < F(f, g) && (W = s, x = p);
134
+ }
135
+ n.alignment === "shift" && (f === "top" || f === "bottom" ? x = {
136
+ ...x,
137
+ x: l(
138
+ x.x,
139
+ h.x + o,
140
+ h.x + h.width - w.width - o
141
+ )
142
+ } : x = {
143
+ ...x,
144
+ y: l(
145
+ x.y,
146
+ h.y + o,
147
+ h.y + h.height - w.height - o
148
+ )
149
+ });
150
+ const P = v(x, w, h, o);
151
+ return M(f, P) > 0 && (x = {
152
+ x: l(
153
+ x.x,
154
+ h.x + o,
155
+ h.x + h.width - w.width - o
156
+ ),
157
+ y: l(
158
+ x.y,
159
+ h.y + o,
160
+ h.y + h.height - w.height - o
161
+ )
162
+ }), {
163
+ alignment: W,
164
+ position: x,
165
+ side: f
166
+ };
167
+ }
168
+ function E({
169
+ boundary: t,
170
+ size: e
171
+ }) {
172
+ return {
173
+ x: t.x + (t.width - e.width) / 2,
174
+ y: t.y + (t.height - e.height) / 2
175
+ };
176
+ }
177
+ function L({
178
+ boundary: t,
179
+ dragHandleHeight: e,
180
+ padding: i,
181
+ position: h,
182
+ size: n
183
+ }) {
184
+ const c = t.x + i, o = Math.max(
185
+ c,
186
+ t.x + t.width - n.width - i
187
+ ), r = t.y + i, m = Math.min(n.height, e), w = Math.max(
188
+ r,
189
+ t.y + t.height - m - i
190
+ );
191
+ return {
192
+ x: l(h.x, c, o),
193
+ y: l(h.y, r, w)
194
+ };
195
+ }
196
+ function R(t) {
197
+ const e = t.getBoundingClientRect();
198
+ return {
199
+ x: e.left,
200
+ y: e.top,
201
+ width: e.width,
202
+ height: e.height
203
+ };
204
+ }
205
+ function O(t) {
206
+ if (t && t !== "viewport")
207
+ return R(t);
208
+ const e = window.visualViewport;
209
+ return {
210
+ x: e?.offsetLeft ?? 0,
211
+ y: e?.offsetTop ?? 0,
212
+ width: e?.width ?? window.innerWidth,
213
+ height: e?.height ?? window.innerHeight
214
+ };
215
+ }
216
+ export {
217
+ L as constrainFloatingWindowPosition,
218
+ O as getFloatingWindowBoundaryRect,
219
+ R as getFloatingWindowRect,
220
+ B as resolveAnchoredFloatingWindowPosition,
221
+ E as resolveCenteredFloatingWindowPosition
222
+ };
@@ -0,0 +1,31 @@
1
+ function o(n) {
2
+ return n === !1 ? 0 : 1;
3
+ }
4
+ function d(n, i) {
5
+ const t = o(i.modality), r = n.findIndex(
6
+ (e) => o(e.modality) > t
7
+ );
8
+ return r === -1 ? [...n, i] : [
9
+ ...n.slice(0, r),
10
+ i,
11
+ ...n.slice(r)
12
+ ];
13
+ }
14
+ function u(n, i) {
15
+ const t = n.filter((r) => r.windowId !== i.windowId);
16
+ return d(t, i);
17
+ }
18
+ function f(n, i) {
19
+ const t = n.find((e) => e.windowId === i);
20
+ if (!t) return [...n];
21
+ const r = n.filter((e) => e.windowId !== i);
22
+ return d(r, t);
23
+ }
24
+ function w(n, i) {
25
+ return n.filter((t) => t.windowId !== i);
26
+ }
27
+ export {
28
+ f as activateFloatingWindow,
29
+ u as registerFloatingWindow,
30
+ w as unregisterFloatingWindow
31
+ };
@@ -0,0 +1,6 @@
1
+ export * from '../ui/src/components/FloatingWindow/index'
2
+ export {}
3
+ import _default from '../ui/src/components/FloatingWindow/index'
4
+ export default _default
5
+ export * from '../ui/src/components/FloatingWindow/index'
6
+ export {}
@@ -0,0 +1,18 @@
1
+ import { FloatingWindowBody as n, FloatingWindowClose as t, FloatingWindowContent as a, FloatingWindowDescription as d, FloatingWindowDragHandle as g, FloatingWindowFooter as l, FloatingWindowHeader as e, FloatingWindowNavigationSection as w, FloatingWindowRoot as F, FloatingWindowTitle as W, FloatingWindowTrigger as r, ModalWindowRoot as f, default as p } from "./FloatingWindow/FloatingWindow.js";
2
+ import { FloatingWindowManager as m } from "./FloatingWindow/FloatingWindowManager.js";
3
+ export {
4
+ n as FloatingWindowBody,
5
+ t as FloatingWindowClose,
6
+ a as FloatingWindowContent,
7
+ d as FloatingWindowDescription,
8
+ g as FloatingWindowDragHandle,
9
+ l as FloatingWindowFooter,
10
+ e as FloatingWindowHeader,
11
+ m as FloatingWindowManager,
12
+ w as FloatingWindowNavigationSection,
13
+ F as FloatingWindowRoot,
14
+ W as FloatingWindowTitle,
15
+ r as FloatingWindowTrigger,
16
+ f as ModalWindowRoot,
17
+ p as default
18
+ };