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