@orioncactuscorp/ui 1.2.0 → 1.4.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.
- package/README.md +56 -27
- package/dist/components/Accordion/Accordion.css +1 -1
- package/dist/components/Accordion/Accordion.js +39 -38
- package/dist/components/Accordion/Accordion.module.scss.js +5 -5
- package/dist/components/ActionArea/ActionArea.css +1 -1
- package/dist/components/ActionArea/ActionArea.js +101 -71
- package/dist/components/ActionArea/ActionAreaLayout.css +1 -0
- package/dist/components/ActionArea/ActionAreaLayout.js +145 -0
- package/dist/components/ActionArea/ActionAreaLayout.module.scss.js +11 -0
- package/dist/components/ActionArea.js +10 -4
- package/dist/components/Alert/Alert.css +1 -1
- package/dist/components/BackgroundIconButton/BackgroundIconButton.css +1 -1
- package/dist/components/BackgroundIconButton/BackgroundIconButton.js +72 -52
- package/dist/components/Badge/Badge.css +1 -1
- package/dist/components/Badge/Badge.js +69 -25
- package/dist/components/Button/Button.css +1 -1
- package/dist/components/Button/Button.js +79 -139
- package/dist/components/Cell/Cell.css +1 -1
- package/dist/components/Cell/Cell.js +98 -88
- package/dist/components/CheckMark/CheckMark.css +1 -1
- package/dist/components/CheckMark/CheckMark.js +20 -18
- package/dist/components/CheckMark/CheckMark.module.scss.js +7 -3
- package/dist/components/Checkbox/Checkbox.css +1 -1
- package/dist/components/Checkbox/Checkbox.module.scss.js +10 -8
- package/dist/components/Field/Field.css +1 -1
- package/dist/components/Fieldset/Fieldset.css +1 -1
- package/dist/components/IconButton/IconButton.css +1 -1
- package/dist/components/IconButton/IconButton.js +48 -29
- package/dist/components/Interaction/Interaction.css +1 -1
- package/dist/components/Loading/Loading.css +1 -1
- package/dist/components/Loading/Loading.js +10 -10
- package/dist/components/Menu/Menu.css +1 -1
- package/dist/components/Modal/Modal.css +1 -1
- package/dist/components/Modal/Modal.js +377 -346
- package/dist/components/Modal/useModalDrag.js +654 -614
- package/dist/components/Radio/Radio.css +1 -1
- package/dist/components/Radio/Radio.module.scss.js +9 -7
- package/dist/components/ScrollArea/ScrollArea.css +1 -1
- package/dist/components/SectionHeader/SectionHeader.css +1 -1
- package/dist/components/Select/Select.css +1 -1
- package/dist/components/Select/Select.js +15 -15
- package/dist/components/Select/SelectContent.css +1 -1
- package/dist/components/Switch/Switch.css +1 -1
- package/dist/components/Switch/Switch.module.scss.js +6 -4
- package/dist/components/TextArea/TextArea.css +1 -1
- package/dist/components/TextArea/TextAreaContent.css +1 -1
- package/dist/components/TextButton/TextButton.css +1 -1
- package/dist/components/TextInput/TextInput.css +1 -1
- package/dist/components/TextInput/TextInputContent.css +1 -1
- package/dist/components/Tooltip/Tooltip.css +1 -1
- package/dist/components/internal/Pressable.js +90 -0
- package/dist/foundations/atomic.css +1 -1
- package/dist/foundations/motion.css +1 -1
- package/dist/foundations/typo.css +1 -1
- package/dist/foundations.css +3 -3
- package/dist/index.js +102 -96
- package/dist/react/motion.js +109 -106
- package/dist/styles.css +32 -31
- package/dist/ui/src/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/ui/src/components/ActionArea/ActionArea.d.ts +1 -1
- package/dist/ui/src/components/ActionArea/ActionArea.d.ts.map +1 -1
- package/dist/ui/src/components/ActionArea/ActionAreaLayout.d.ts +12 -0
- package/dist/ui/src/components/ActionArea/ActionAreaLayout.d.ts.map +1 -0
- package/dist/ui/src/components/ActionArea/index.d.ts +2 -1
- package/dist/ui/src/components/ActionArea/index.d.ts.map +1 -1
- package/dist/ui/src/components/ActionArea/types.d.ts +13 -2
- package/dist/ui/src/components/ActionArea/types.d.ts.map +1 -1
- package/dist/ui/src/components/BackgroundIconButton/BackgroundIconButton.d.ts +1 -1
- package/dist/ui/src/components/BackgroundIconButton/BackgroundIconButton.d.ts.map +1 -1
- package/dist/ui/src/components/BackgroundIconButton/index.d.ts +1 -1
- package/dist/ui/src/components/BackgroundIconButton/index.d.ts.map +1 -1
- package/dist/ui/src/components/BackgroundIconButton/types.d.ts +6 -5
- package/dist/ui/src/components/BackgroundIconButton/types.d.ts.map +1 -1
- package/dist/ui/src/components/Badge/Badge.d.ts +1 -1
- package/dist/ui/src/components/Badge/Badge.d.ts.map +1 -1
- package/dist/ui/src/components/Badge/types.d.ts +19 -2
- package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
- package/dist/ui/src/components/Button/Button.d.ts.map +1 -1
- package/dist/ui/src/components/Button/types.d.ts +3 -7
- package/dist/ui/src/components/Button/types.d.ts.map +1 -1
- package/dist/ui/src/components/Cell/Cell.d.ts.map +1 -1
- package/dist/ui/src/components/CheckMark/CheckMark.d.ts +1 -1
- package/dist/ui/src/components/CheckMark/CheckMark.d.ts.map +1 -1
- package/dist/ui/src/components/CheckMark/index.d.ts +1 -1
- package/dist/ui/src/components/CheckMark/index.d.ts.map +1 -1
- package/dist/ui/src/components/CheckMark/types.d.ts +2 -0
- package/dist/ui/src/components/CheckMark/types.d.ts.map +1 -1
- package/dist/ui/src/components/IconButton/IconButton.d.ts +1 -1
- package/dist/ui/src/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/ui/src/components/IconButton/index.d.ts +1 -1
- package/dist/ui/src/components/IconButton/index.d.ts.map +1 -1
- package/dist/ui/src/components/IconButton/types.d.ts +6 -5
- package/dist/ui/src/components/IconButton/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/contexts.d.ts +1 -0
- package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/types.d.ts +7 -6
- package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
- package/dist/ui/src/components/internal/Pressable.d.ts +19 -0
- package/dist/ui/src/components/internal/Pressable.d.ts.map +1 -0
- package/dist/ui/src/index.d.ts +5 -5
- package/dist/ui/src/index.d.ts.map +1 -1
- package/dist/ui/src/react/motion/index.d.ts +9 -8
- package/dist/ui/src/react/motion/index.d.ts.map +1 -1
- package/dist/ui/src/utils/motion.d.ts +15 -14
- package/dist/ui/src/utils/motion.d.ts.map +1 -1
- package/dist/utils/motion.js +282 -183
- package/dist/vscode/oc-ui-vars.css +31 -16
- package/package.json +2 -2
- package/src/scss/foundations/atomic.scss +12 -10
- package/src/scss/foundations/atomic.test.ts +34 -0
- package/src/scss/foundations/motion.scss +30 -16
- package/src/scss/foundations/typo.scss +1 -1
- package/src/scss/index.scss +1 -0
- package/src/scss/mixins/_motion.scss +168 -77
- package/src/scss/mixins/_motion.test.ts +137 -54
- package/src/scss/mixins/_radius.scss +3 -0
- package/src/scss/mixins/_radius.test.ts +52 -0
- package/src/scss/mixins/_typo.scss +2 -2
package/dist/react/motion.js
CHANGED
|
@@ -1,170 +1,173 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { createSpringAnimator as
|
|
5
|
-
import { resolveOcMotion as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
2
|
+
import { jsx as H } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as s, useState as C, useCallback as j, useEffect as y, useLayoutEffect as ct } from "react";
|
|
4
|
+
import { createSpringAnimator as st } from "../utils/spring/animator.js";
|
|
5
|
+
import { resolveOcMotion as it } from "../utils/motion.js";
|
|
6
|
+
const T = "block-size";
|
|
7
|
+
function at(t, n) {
|
|
8
8
|
typeof t == "function" ? t(n) : t && (t.current = n);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const n =
|
|
10
|
+
function q(t) {
|
|
11
|
+
const n = s(t);
|
|
12
12
|
return y(() => {
|
|
13
13
|
n.current = t;
|
|
14
14
|
}, [t]), n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const [t, n] =
|
|
16
|
+
function ut() {
|
|
17
|
+
const [t, n] = C(() => typeof window > "u" || !window.matchMedia ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
18
18
|
return y(() => {
|
|
19
19
|
if (typeof window > "u" || !window.matchMedia) return;
|
|
20
|
-
const
|
|
21
|
-
return
|
|
20
|
+
const r = window.matchMedia("(prefers-reduced-motion: reduce)"), c = () => n(r.matches);
|
|
21
|
+
return c(), r.addEventListener("change", c), () => r.removeEventListener("change", c);
|
|
22
22
|
}, []), t;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function lt(t) {
|
|
25
25
|
if (!t) return 0;
|
|
26
26
|
const n = t.getBoundingClientRect().height;
|
|
27
27
|
return Math.max(0, n || t.scrollHeight);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function dt(t) {
|
|
30
30
|
return t ? Math.max(0, t.getBoundingClientRect().height) : 0;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function V(t) {
|
|
33
33
|
return `${Math.max(0, t).toFixed(3)}px`;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
(
|
|
38
|
-
u.current !==
|
|
35
|
+
function ft(t, n) {
|
|
36
|
+
const r = q(n), [c, d] = C(t), u = s(t), f = j(
|
|
37
|
+
(i) => {
|
|
38
|
+
u.current !== i && (u.current = i, d(i), r.current?.(i));
|
|
39
39
|
},
|
|
40
|
-
[
|
|
40
|
+
[r]
|
|
41
41
|
);
|
|
42
|
-
return { motionState:
|
|
42
|
+
return { motionState: c, setMotionState: f };
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function St({
|
|
45
45
|
children: t,
|
|
46
46
|
className: n = "",
|
|
47
|
-
contentProps:
|
|
48
|
-
disableAnimation:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
contentProps: r,
|
|
48
|
+
disableAnimation: c = !1,
|
|
49
|
+
durationFactor: d = 1,
|
|
50
|
+
extraBounce: u,
|
|
51
|
+
enterPhase: f = "enter",
|
|
52
|
+
exitPhase: i = "exit",
|
|
53
|
+
forceMount: l = !1,
|
|
54
|
+
intent: R = "expand",
|
|
55
|
+
onExitComplete: A,
|
|
56
|
+
onMotionStateChange: U,
|
|
56
57
|
open: o,
|
|
57
|
-
pace:
|
|
58
|
-
reduced:
|
|
59
|
-
ref:
|
|
60
|
-
scheduler:
|
|
61
|
-
style:
|
|
62
|
-
"data-oc-component":
|
|
63
|
-
|
|
58
|
+
pace: z = "normal",
|
|
59
|
+
reduced: b = "auto",
|
|
60
|
+
ref: W,
|
|
61
|
+
scheduler: x,
|
|
62
|
+
style: Y,
|
|
63
|
+
"data-oc-component": _ = "motion-expand",
|
|
64
|
+
...$
|
|
64
65
|
}) {
|
|
65
|
-
const L =
|
|
66
|
+
const L = s(null), E = s(null), a = s(null), D = s(o || l), B = s(!1), g = ut(), [m, F] = C(() => o || l), S = s(m), I = q(A), { motionState: G, setMotionState: h } = ft(
|
|
66
67
|
o ? "open" : "closed",
|
|
67
|
-
|
|
68
|
+
U
|
|
68
69
|
), {
|
|
69
|
-
className:
|
|
70
|
-
style:
|
|
71
|
-
"data-oc-part":
|
|
72
|
-
...
|
|
73
|
-
} =
|
|
74
|
-
...
|
|
70
|
+
className: J = "",
|
|
71
|
+
style: K,
|
|
72
|
+
"data-oc-part": Q = "content",
|
|
73
|
+
...X
|
|
74
|
+
} = r ?? {}, w = o || m || l, Z = {
|
|
75
|
+
...Y,
|
|
75
76
|
overflow: "hidden"
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
}, []),
|
|
79
|
-
L.current = e,
|
|
77
|
+
}, p = j((e) => {
|
|
78
|
+
S.current = e, F(e);
|
|
79
|
+
}, []), tt = (e) => {
|
|
80
|
+
L.current = e, at(W, e);
|
|
80
81
|
};
|
|
81
82
|
return y(() => {
|
|
82
|
-
|
|
83
|
-
}, [
|
|
83
|
+
S.current = m;
|
|
84
|
+
}, [m]), y(
|
|
84
85
|
() => () => {
|
|
85
86
|
a.current?.destroy(), a.current = null;
|
|
86
87
|
},
|
|
87
88
|
[]
|
|
88
|
-
),
|
|
89
|
-
if (!
|
|
90
|
-
const e = L.current,
|
|
91
|
-
if (!e || !
|
|
92
|
-
const
|
|
89
|
+
), ct(() => {
|
|
90
|
+
if (!w) return;
|
|
91
|
+
const e = L.current, O = E.current;
|
|
92
|
+
if (!e || !O) return;
|
|
93
|
+
const et = S.current, P = o ? lt(O) : 0, N = it({
|
|
93
94
|
element: e,
|
|
94
95
|
intent: R,
|
|
95
|
-
phase: o ?
|
|
96
|
-
pace:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
phase: o ? f : i,
|
|
97
|
+
pace: z,
|
|
98
|
+
durationFactor: d,
|
|
99
|
+
extraBounce: u,
|
|
100
|
+
reduced: b,
|
|
101
|
+
reducedMotion: g,
|
|
102
|
+
property: T
|
|
103
|
+
}), nt = !B.current && D.current, ot = !c && !nt && N.animate, M = () => {
|
|
102
104
|
if (e.style.willChange = "", o) {
|
|
103
|
-
e.style.blockSize = "auto",
|
|
105
|
+
e.style.blockSize = "auto", h("open"), p(!0);
|
|
104
106
|
return;
|
|
105
107
|
}
|
|
106
|
-
e.style.blockSize = "0px",
|
|
108
|
+
e.style.blockSize = "0px", h("closed"), l || p(!1), I.current?.();
|
|
107
109
|
};
|
|
108
|
-
if (a.current?.destroy(), a.current = null, o && !
|
|
109
|
-
|
|
110
|
+
if (a.current?.destroy(), a.current = null, o && !et && (e.style.blockSize = "0px", p(!0)), B.current = !0, !ot) {
|
|
111
|
+
M();
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
|
-
const
|
|
113
|
-
if (Math.abs(
|
|
114
|
-
|
|
114
|
+
const v = dt(e);
|
|
115
|
+
if (Math.abs(v - P) < 0.5) {
|
|
116
|
+
M();
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
|
-
e.style.blockSize =
|
|
118
|
-
const
|
|
119
|
-
value:
|
|
120
|
-
target:
|
|
121
|
-
spring:
|
|
122
|
-
scheduler:
|
|
119
|
+
e.style.blockSize = V(v), e.style.willChange = T, h(o ? "opening" : "closing");
|
|
120
|
+
const k = st({
|
|
121
|
+
value: v,
|
|
122
|
+
target: P,
|
|
123
|
+
spring: N.spring,
|
|
124
|
+
scheduler: x,
|
|
123
125
|
stabilityWindow: 0.02,
|
|
124
|
-
onUpdate: (
|
|
125
|
-
e.style.blockSize =
|
|
126
|
+
onUpdate: (rt) => {
|
|
127
|
+
e.style.blockSize = V(rt);
|
|
126
128
|
},
|
|
127
|
-
onComplete:
|
|
129
|
+
onComplete: M
|
|
128
130
|
});
|
|
129
|
-
return a.current =
|
|
130
|
-
a.current ===
|
|
131
|
+
return a.current = k, () => {
|
|
132
|
+
a.current === k && (k.destroy(), a.current = null);
|
|
131
133
|
};
|
|
132
134
|
}, [
|
|
133
|
-
|
|
134
|
-
l,
|
|
135
|
-
u,
|
|
135
|
+
c,
|
|
136
136
|
d,
|
|
137
|
-
|
|
137
|
+
u,
|
|
138
|
+
f,
|
|
139
|
+
i,
|
|
140
|
+
l,
|
|
138
141
|
R,
|
|
139
|
-
|
|
142
|
+
I,
|
|
140
143
|
o,
|
|
141
|
-
C,
|
|
142
144
|
z,
|
|
143
|
-
p,
|
|
144
145
|
b,
|
|
146
|
+
g,
|
|
147
|
+
x,
|
|
148
|
+
p,
|
|
145
149
|
h,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
]), v ? /* @__PURE__ */ N(
|
|
150
|
+
w
|
|
151
|
+
]), w ? /* @__PURE__ */ H(
|
|
149
152
|
"div",
|
|
150
153
|
{
|
|
151
|
-
|
|
152
|
-
ref:
|
|
154
|
+
...$,
|
|
155
|
+
ref: tt,
|
|
153
156
|
className: n,
|
|
154
|
-
style:
|
|
155
|
-
"data-oc-component":
|
|
157
|
+
style: Z,
|
|
158
|
+
"data-oc-component": _,
|
|
156
159
|
"data-oc-motion-intent": R,
|
|
157
|
-
"data-oc-motion-state":
|
|
158
|
-
"data-oc-reduced-motion":
|
|
160
|
+
"data-oc-motion-state": G,
|
|
161
|
+
"data-oc-reduced-motion": g ? "true" : void 0,
|
|
159
162
|
"data-oc-state": o ? "open" : "closed",
|
|
160
|
-
children: /* @__PURE__ */
|
|
163
|
+
children: /* @__PURE__ */ H(
|
|
161
164
|
"div",
|
|
162
165
|
{
|
|
163
|
-
...
|
|
164
|
-
ref:
|
|
165
|
-
className:
|
|
166
|
-
style:
|
|
167
|
-
"data-oc-part":
|
|
166
|
+
...X,
|
|
167
|
+
ref: E,
|
|
168
|
+
className: J,
|
|
169
|
+
style: K,
|
|
170
|
+
"data-oc-part": Q,
|
|
168
171
|
children: t
|
|
169
172
|
}
|
|
170
173
|
)
|
|
@@ -172,6 +175,6 @@ function gt({
|
|
|
172
175
|
) : null;
|
|
173
176
|
}
|
|
174
177
|
export {
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
St as MotionExpand,
|
|
179
|
+
St as default
|
|
177
180
|
};
|