@udixio/ui-react 2.10.12 → 2.10.14

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 (179) hide show
  1. package/dist/index.cjs +3 -3
  2. package/dist/index.js +2696 -2710
  3. package/dist/lib/effects/ThemeProvider.d.ts.map +1 -1
  4. package/dist/theme.worker.js +6633 -0
  5. package/package.json +4 -1
  6. package/.eslintrc.mjs +0 -22
  7. package/.storybook/main.ts +0 -20
  8. package/.storybook/preview.ts +0 -1
  9. package/CHANGELOG.md +0 -1130
  10. package/dist/scrollDriven-AP2yWhzi.js +0 -121
  11. package/postcss.config.mjs +0 -5
  12. package/src/index.css +0 -4
  13. package/src/index.ts +0 -1
  14. package/src/lib/components/AnchorPositioner.tsx +0 -185
  15. package/src/lib/components/Button.tsx +0 -208
  16. package/src/lib/components/Card.tsx +0 -47
  17. package/src/lib/components/Carousel.tsx +0 -437
  18. package/src/lib/components/CarouselItem.tsx +0 -61
  19. package/src/lib/components/Checkbox.tsx +0 -120
  20. package/src/lib/components/Chip.tsx +0 -341
  21. package/src/lib/components/Chips.tsx +0 -331
  22. package/src/lib/components/ContextMenu.tsx +0 -109
  23. package/src/lib/components/DatePicker.tsx +0 -432
  24. package/src/lib/components/Divider.tsx +0 -20
  25. package/src/lib/components/Fab.tsx +0 -127
  26. package/src/lib/components/FabMenu.tsx +0 -239
  27. package/src/lib/components/IconButton.tsx +0 -146
  28. package/src/lib/components/Menu.tsx +0 -88
  29. package/src/lib/components/MenuGroup.tsx +0 -34
  30. package/src/lib/components/MenuHeadline.tsx +0 -9
  31. package/src/lib/components/MenuItem.tsx +0 -215
  32. package/src/lib/components/NavigationRail.tsx +0 -186
  33. package/src/lib/components/NavigationRailItem.tsx +0 -227
  34. package/src/lib/components/ProgressIndicator.tsx +0 -214
  35. package/src/lib/components/SideSheet.tsx +0 -135
  36. package/src/lib/components/Slider.tsx +0 -374
  37. package/src/lib/components/Snackbar.tsx +0 -77
  38. package/src/lib/components/Switch.tsx +0 -107
  39. package/src/lib/components/Tab.tsx +0 -123
  40. package/src/lib/components/TabGroup.tsx +0 -66
  41. package/src/lib/components/TabGroupContext.tsx +0 -16
  42. package/src/lib/components/TabPanel.tsx +0 -27
  43. package/src/lib/components/TabPanels.tsx +0 -76
  44. package/src/lib/components/Tabs.tsx +0 -105
  45. package/src/lib/components/TextField.tsx +0 -586
  46. package/src/lib/components/Tooltip.tsx +0 -217
  47. package/src/lib/components/index.ts +0 -34
  48. package/src/lib/config/config.interface.ts +0 -9
  49. package/src/lib/config/define-config.ts +0 -16
  50. package/src/lib/config/index.ts +0 -2
  51. package/src/lib/effects/AnimateOnScroll.ts +0 -391
  52. package/src/lib/effects/State.tsx +0 -90
  53. package/src/lib/effects/SyncedFixedWrapper.tsx +0 -62
  54. package/src/lib/effects/ThemeProvider.tsx +0 -172
  55. package/src/lib/effects/block-scroll.effect.tsx +0 -313
  56. package/src/lib/effects/custom-scroll/custom-scroll.effect.tsx +0 -407
  57. package/src/lib/effects/custom-scroll/custom-scroll.interface.ts +0 -29
  58. package/src/lib/effects/custom-scroll/custom-scroll.style.ts +0 -32
  59. package/src/lib/effects/custom-scroll/index.ts +0 -3
  60. package/src/lib/effects/index.ts +0 -7
  61. package/src/lib/effects/ripple/RippleEffect.tsx +0 -116
  62. package/src/lib/effects/ripple/index.tsx +0 -1
  63. package/src/lib/effects/scrollDriven.ts +0 -239
  64. package/src/lib/effects/smooth-scroll.effect.tsx +0 -112
  65. package/src/lib/effects/theme.worker.ts +0 -97
  66. package/src/lib/hooks/index.ts +0 -10
  67. package/src/lib/hooks/useTooltipTrigger.ts +0 -270
  68. package/src/lib/icon/icon.tsx +0 -125
  69. package/src/lib/icon/index.ts +0 -1
  70. package/src/lib/index.ts +0 -8
  71. package/src/lib/interfaces/button.interface.ts +0 -65
  72. package/src/lib/interfaces/card.interface.ts +0 -11
  73. package/src/lib/interfaces/carousel-item.interface.ts +0 -12
  74. package/src/lib/interfaces/carousel.interface.ts +0 -41
  75. package/src/lib/interfaces/checkbox.interface.ts +0 -39
  76. package/src/lib/interfaces/chip.interface.ts +0 -97
  77. package/src/lib/interfaces/chips.interface.ts +0 -37
  78. package/src/lib/interfaces/date-picker.interface.ts +0 -79
  79. package/src/lib/interfaces/divider.interface.ts +0 -7
  80. package/src/lib/interfaces/fab-menu.interface.ts +0 -12
  81. package/src/lib/interfaces/fab.interface.ts +0 -27
  82. package/src/lib/interfaces/icon-button.interface.ts +0 -38
  83. package/src/lib/interfaces/index.ts +0 -26
  84. package/src/lib/interfaces/menu-group.interface.ts +0 -13
  85. package/src/lib/interfaces/menu-item.interface.ts +0 -29
  86. package/src/lib/interfaces/menu.interface.ts +0 -19
  87. package/src/lib/interfaces/navigation-rail-item.interface.ts +0 -39
  88. package/src/lib/interfaces/navigation-rail.interface.ts +0 -39
  89. package/src/lib/interfaces/progress-indicator.interface.ts +0 -41
  90. package/src/lib/interfaces/side-sheet.interface.tsx +0 -28
  91. package/src/lib/interfaces/slider.interface.ts +0 -27
  92. package/src/lib/interfaces/snackbar.interface.ts +0 -13
  93. package/src/lib/interfaces/switch.interface.ts +0 -14
  94. package/src/lib/interfaces/tab-group.interface.ts +0 -13
  95. package/src/lib/interfaces/tab-panels.interface.ts +0 -21
  96. package/src/lib/interfaces/tab.interface.ts +0 -31
  97. package/src/lib/interfaces/tabs.interface.ts +0 -22
  98. package/src/lib/interfaces/text-field.interface.ts +0 -61
  99. package/src/lib/interfaces/tooltip.interface.ts +0 -61
  100. package/src/lib/styles/button.style.ts +0 -136
  101. package/src/lib/styles/card.style.ts +0 -29
  102. package/src/lib/styles/carousel-item.style.ts +0 -24
  103. package/src/lib/styles/carousel.style.ts +0 -22
  104. package/src/lib/styles/checkbox.style.ts +0 -64
  105. package/src/lib/styles/chip.style.ts +0 -62
  106. package/src/lib/styles/chips.style.ts +0 -20
  107. package/src/lib/styles/date-picker.style.ts +0 -43
  108. package/src/lib/styles/divider.style.ts +0 -31
  109. package/src/lib/styles/fab-menu.style.ts +0 -29
  110. package/src/lib/styles/fab.style.ts +0 -49
  111. package/src/lib/styles/icon-button.style.ts +0 -168
  112. package/src/lib/styles/index.ts +0 -25
  113. package/src/lib/styles/menu-group.style.ts +0 -34
  114. package/src/lib/styles/menu-headline.style.ts +0 -20
  115. package/src/lib/styles/menu-item.style.ts +0 -45
  116. package/src/lib/styles/menu.style.ts +0 -32
  117. package/src/lib/styles/navigation-rail-item.style.ts +0 -56
  118. package/src/lib/styles/navigation-rail.style.ts +0 -36
  119. package/src/lib/styles/progress-indicator.style.ts +0 -72
  120. package/src/lib/styles/side-sheet.style.ts +0 -45
  121. package/src/lib/styles/slider.style.ts +0 -41
  122. package/src/lib/styles/snackbar.style.ts +0 -26
  123. package/src/lib/styles/switch.style.ts +0 -67
  124. package/src/lib/styles/tab-panels.style.ts +0 -35
  125. package/src/lib/styles/tab.style.ts +0 -78
  126. package/src/lib/styles/tabs.style.ts +0 -22
  127. package/src/lib/styles/text-field.style.ts +0 -115
  128. package/src/lib/styles/tooltip.style.ts +0 -48
  129. package/src/lib/utils/component-helper.ts +0 -134
  130. package/src/lib/utils/component.ts +0 -34
  131. package/src/lib/utils/index.ts +0 -7
  132. package/src/lib/utils/string.ts +0 -9
  133. package/src/lib/utils/styles/classnames.ts +0 -49
  134. package/src/lib/utils/styles/get-classname.ts +0 -96
  135. package/src/lib/utils/styles/index.ts +0 -4
  136. package/src/lib/utils/styles/use-classnames.ts +0 -25
  137. package/src/stories/action/button.stories.tsx +0 -86
  138. package/src/stories/action/fab.stories.tsx +0 -54
  139. package/src/stories/action/icon-button.stories.tsx +0 -134
  140. package/src/stories/assets/accessibility.png +0 -0
  141. package/src/stories/assets/accessibility.svg +0 -5
  142. package/src/stories/assets/addon-library.png +0 -0
  143. package/src/stories/assets/assets.png +0 -0
  144. package/src/stories/assets/context.png +0 -0
  145. package/src/stories/assets/discord.svg +0 -15
  146. package/src/stories/assets/docs.png +0 -0
  147. package/src/stories/assets/figma-plugin.png +0 -0
  148. package/src/stories/assets/github.svg +0 -3
  149. package/src/stories/assets/share.png +0 -0
  150. package/src/stories/assets/styling.png +0 -0
  151. package/src/stories/assets/testing.png +0 -0
  152. package/src/stories/assets/theming.png +0 -0
  153. package/src/stories/assets/tutorials.svg +0 -12
  154. package/src/stories/assets/youtube.svg +0 -4
  155. package/src/stories/communication/ProgressIndicator.stories.tsx +0 -57
  156. package/src/stories/communication/SnackBar.stories.tsx +0 -32
  157. package/src/stories/communication/tool-tip.stories.tsx +0 -133
  158. package/src/stories/containment/card.stories.tsx +0 -42
  159. package/src/stories/containment/carousel.stories.tsx +0 -65
  160. package/src/stories/containment/divider.stories.tsx +0 -35
  161. package/src/stories/containment/slide-sheet.stories.tsx +0 -45
  162. package/src/stories/effect/smooth-scroll.stories.tsx +0 -54
  163. package/src/stories/navigation/navigation-rail/navigation-rail-item.stories.tsx +0 -65
  164. package/src/stories/navigation/navigation-rail/navigation-rail.stories.tsx +0 -122
  165. package/src/stories/navigation/tabs/tab.stories.tsx +0 -57
  166. package/src/stories/navigation/tabs/tabs.stories.tsx +0 -102
  167. package/src/stories/selection/slider.stories.tsx +0 -85
  168. package/src/stories/selection/switch.stories.tsx +0 -46
  169. package/src/stories/text-inputs/text-field.stories.tsx +0 -135
  170. package/src/tests/Button.spec.tsx +0 -67
  171. package/src/tests/useClassNames.spec.tsx +0 -82
  172. package/src/udixio.css +0 -120
  173. package/theme.config.ts +0 -7
  174. package/tsconfig.json +0 -16
  175. package/tsconfig.lib.json +0 -51
  176. package/tsconfig.spec.json +0 -37
  177. package/tsconfig.storybook.json +0 -38
  178. package/vite.config.ts +0 -82
  179. /package/dist/{scrollDriven-DWAu7CR0.cjs → scrollDriven.js} +0 -0
@@ -1,121 +0,0 @@
1
- let y = !1, h = null;
2
- function C() {
3
- if (typeof window > "u") return !1;
4
- try {
5
- if (window.CSS && typeof window.CSS.supports == "function")
6
- return CSS.supports("animation-timeline: view()") || CSS.supports("animation-timeline: scroll()") || CSS.supports("view-timeline-name: --a");
7
- } catch {
8
- }
9
- return !1;
10
- }
11
- function F() {
12
- return typeof window > "u" || !("matchMedia" in window) ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
13
- }
14
- function V(n, t) {
15
- return getComputedStyle(n).getPropertyValue(t).trim() || null;
16
- }
17
- function b(n) {
18
- if (!n) return null;
19
- const t = n.split(/\s+/), e = t[t.length - 1];
20
- if (!e) return null;
21
- if (e.endsWith("%")) {
22
- const r = parseFloat(e);
23
- if (!isNaN(r)) return Math.max(0, Math.min(100, r)) / 100;
24
- }
25
- return null;
26
- }
27
- function L(n) {
28
- const t = V(n, "--udx-range-start"), e = V(n, "--udx-range-end"), r = b(t) ?? 0.2, a = b(e) ?? 0.5, o = Math.max(0, Math.min(1, r)), l = Math.max(o + 1e-3, Math.min(1, a));
29
- return { start: o, end: l };
30
- }
31
- function i(n, t) {
32
- if (!n) return null;
33
- const e = n.trim(), r = parseFloat(e);
34
- return isNaN(r) ? null : r;
35
- }
36
- function p(n, t, e) {
37
- return n + (t - n) * e;
38
- }
39
- function N(n, t, e, r) {
40
- const a = t.opacity != null ? Number(t.opacity) : 1, o = e.opacity != null ? Number(e.opacity) : 1, l = p(a, o, r);
41
- n.style.opacity = String(l);
42
- const v = i(t["--tw-enter-translate-x"]) ?? i(t["--tw-exit-translate-x"]) ?? 0, g = i(t["--tw-enter-translate-y"]) ?? i(t["--tw-exit-translate-y"]) ?? 0, c = i(e["--tw-enter-translate-x"]) ?? i(e["--tw-exit-translate-x"]) ?? 0, u = i(e["--tw-enter-translate-y"]) ?? i(e["--tw-exit-translate-y"]) ?? 0, S = i(t["--tw-enter-scale"]) ?? i(t["--tw-exit-scale"]) ?? 1, M = i(e["--tw-enter-scale"]) ?? i(e["--tw-exit-scale"]) ?? 1, P = i(t["--tw-enter-rotate"]) ?? i(t["--tw-exit-rotate"]) ?? 0, f = i(e["--tw-enter-rotate"]) ?? i(e["--tw-exit-rotate"]) ?? 0, x = p(v, c, r), s = p(g, u, r), d = p(S, M, r), m = p(P, f, r), w = [];
43
- (x !== 0 || s !== 0) && w.push(`translate3d(${x}px, ${s}px, 0)`), d !== 1 && w.push(`scale(${d})`), m !== 0 && w.push(`rotate(${m}deg)`), n.style.transform = w.length ? w.join(" ") : "none";
44
- }
45
- function T(n) {
46
- const t = n.classList, e = t.contains("animate-in"), r = t.contains("animate-out");
47
- if (!e && !r) return null;
48
- const a = getComputedStyle(n), o = {
49
- opacity: i(a.getPropertyValue("--tw-enter-opacity")) ?? void 0,
50
- "--tw-enter-translate-x": a.getPropertyValue("--tw-enter-translate-x") || void 0,
51
- "--tw-enter-translate-y": a.getPropertyValue("--tw-enter-translate-y") || void 0,
52
- "--tw-enter-scale": a.getPropertyValue("--tw-enter-scale") || void 0,
53
- "--tw-enter-rotate": a.getPropertyValue("--tw-enter-rotate") || void 0
54
- }, l = {
55
- opacity: i(a.getPropertyValue("--tw-exit-opacity")) ?? void 0,
56
- "--tw-exit-translate-x": a.getPropertyValue("--tw-exit-translate-x") || void 0,
57
- "--tw-exit-translate-y": a.getPropertyValue("--tw-exit-translate-y") || void 0,
58
- "--tw-exit-scale": a.getPropertyValue("--tw-exit-scale") || void 0,
59
- "--tw-exit-rotate": a.getPropertyValue("--tw-exit-rotate") || void 0
60
- };
61
- return e ? {
62
- from: o,
63
- to: { opacity: 1, "--tw-enter-translate-x": "0", "--tw-enter-translate-y": "0", "--tw-enter-scale": "1", "--tw-enter-rotate": "0" }
64
- } : r ? {
65
- from: { opacity: 1, "--tw-exit-translate-x": "0", "--tw-exit-translate-y": "0", "--tw-exit-scale": "1", "--tw-exit-rotate": "0" },
66
- to: l
67
- } : null;
68
- }
69
- function $() {
70
- const n = [
71
- ".udx-view",
72
- ".udx-view-x",
73
- ".udx-view-y",
74
- ".udx-view-inline",
75
- ".udx-view-block",
76
- "[data-udx-view]"
77
- ].map((t) => `${t}.animate-in, ${t}.animate-out`).join(", ");
78
- return Array.from(document.querySelectorAll(n));
79
- }
80
- function k(n = {}) {
81
- if (y) return h || (() => {
82
- });
83
- if (typeof window > "u") return () => {
84
- };
85
- if (C() || F())
86
- return y = !0, () => {
87
- };
88
- y = !0;
89
- const t = n.once ?? !0, e = /* @__PURE__ */ new WeakSet();
90
- let r = null;
91
- const a = () => {
92
- const v = $(), g = window.innerHeight || 0;
93
- for (const c of v) {
94
- const u = c.getBoundingClientRect(), S = Math.min(u.bottom, g) - Math.max(u.top, 0), M = Math.max(0, Math.min(S, u.height)), P = u.height > 0 ? M / u.height : 0, { start: f, end: x } = L(c);
95
- let s = (P - f) / (x - f);
96
- s = Math.max(0, Math.min(1, s)), t && e.has(c) && s < 1 && (s = 1);
97
- const d = T(c);
98
- if (!d) continue;
99
- const { from: m, to: w } = d;
100
- N(c, m, w, s), s >= 1 && t && e.add(c);
101
- }
102
- }, o = () => {
103
- r == null && (r = window.requestAnimationFrame(() => {
104
- r = null, a();
105
- }));
106
- };
107
- a(), window.addEventListener("scroll", o, { passive: !0 }), window.addEventListener("resize", o);
108
- const l = new MutationObserver(() => {
109
- o();
110
- });
111
- return l.observe(document.documentElement, {
112
- childList: !0,
113
- subtree: !0,
114
- attributes: !0
115
- }), h = () => {
116
- window.removeEventListener("scroll", o), window.removeEventListener("resize", o), r != null && cancelAnimationFrame(r), l.disconnect(), y = !1, h = null;
117
- }, h;
118
- }
119
- export {
120
- k as initScrollViewFallback
121
- };
@@ -1,5 +0,0 @@
1
- export default {
2
- plugins: {
3
- '@tailwindcss/postcss': {},
4
- },
5
- };
package/src/index.css DELETED
@@ -1,4 +0,0 @@
1
- @import 'tailwindcss';
2
- @import "./udixio.css";
3
-
4
-
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './lib/index';
@@ -1,185 +0,0 @@
1
- import React, {
2
- CSSProperties,
3
- RefObject,
4
- useId,
5
- useLayoutEffect,
6
- useState,
7
- } from 'react';
8
- import { createPortal } from 'react-dom';
9
- import { SyncedFixedWrapper } from '../effects';
10
- import IntrinsicElements = React.JSX.IntrinsicElements;
11
-
12
- export type PositionKeyword =
13
- | 'left'
14
- | 'center'
15
- | 'right'
16
- | 'span-left'
17
- | 'span-right'
18
- | 'x-start'
19
- | 'x-end'
20
- | 'span-x-start'
21
- | 'span-x-end'
22
- | 'self-x-start'
23
- | 'self-x-end'
24
- | 'span-self-x-start'
25
- | 'span-self-x-end'
26
- | 'top'
27
- | 'bottom'
28
- | 'span-top'
29
- | 'span-bottom'
30
- | 'y-start'
31
- | 'y-end'
32
- | 'span-y-start'
33
- | 'span-y-end'
34
- | 'self-y-start'
35
- | 'self-y-end'
36
- | 'span-self-y-start'
37
- | 'span-self-y-end'
38
- | 'block-start'
39
- | 'block-end'
40
- | 'span-block-start'
41
- | 'span-block-end'
42
- | 'inline-start'
43
- | 'inline-end'
44
- | 'span-inline-start'
45
- | 'span-inline-end'
46
- | 'self-block-start'
47
- | 'self-block-end'
48
- | 'span-self-block-start'
49
- | 'span-self-block-end'
50
- | 'self-inline-start'
51
- | 'self-inline-end'
52
- | 'span-self-inline-start'
53
- | 'span-self-inline-end'
54
- | 'start'
55
- | 'end'
56
- | 'span-start'
57
- | 'span-end'
58
- | 'self-start'
59
- | 'self-end'
60
- | 'span-self-start'
61
- | 'span-self-end'
62
- | 'span-all';
63
-
64
- export type Position =
65
- | PositionKeyword
66
- | `${PositionKeyword} ${PositionKeyword}`
67
- | 'top-left'
68
- | 'top-right'
69
- | 'bottom-left'
70
- | 'bottom-right'
71
- | 'right-start'
72
- | 'right-end'
73
- | 'left-start'
74
- | 'left-end';
75
-
76
- export interface AnchorPositionerProps {
77
- anchorRef: RefObject<HTMLElement | null>;
78
- position?: Position;
79
- children: React.ReactNode;
80
- style?: CSSProperties;
81
- className?: string; // Optional if we want to wrap in a class
82
- }
83
-
84
- export const AnchorPositioner = ({
85
- anchorRef,
86
- position = 'bottom',
87
- children,
88
- style,
89
- ...restProps
90
- }: AnchorPositionerProps & IntrinsicElements['div']) => {
91
- const uniqueId = useId();
92
- const anchorName = `--anchor-${uniqueId.replace(/:/g, '')}`;
93
- const [supportsAnchor, setSupportsAnchor] = useState(false);
94
-
95
- useLayoutEffect(() => {
96
- if (typeof CSS !== 'undefined' && CSS.supports('anchor-name', '--a')) {
97
- setSupportsAnchor(true);
98
- }
99
- }, []);
100
-
101
- useLayoutEffect(() => {
102
- if (supportsAnchor && anchorRef.current) {
103
- const el = anchorRef.current;
104
- // Apply anchor name to the reference element
105
- (el.style as any).anchorName = anchorName;
106
- return () => {
107
- if (anchorRef.current) {
108
- (anchorRef.current.style as any).anchorName = '';
109
- }
110
- };
111
- }
112
- }, [supportsAnchor, anchorRef, anchorName]);
113
-
114
- if (supportsAnchor) {
115
- const floatingStyles: CSSProperties = {
116
- position: 'fixed',
117
- margin: 0,
118
- zIndex: 9999,
119
- positionAnchor: anchorName,
120
- positionArea: position,
121
- positionTryFallbacks: 'flip-block, flip-inline', // Correct CSS prop
122
- ...style,
123
- } as any;
124
-
125
- return createPortal(
126
- <div style={floatingStyles} {...restProps}>
127
- {children}
128
- </div>,
129
- document.body,
130
- );
131
- }
132
-
133
- const fallbackStyles: CSSProperties = {
134
- position: 'absolute',
135
- pointerEvents: 'auto',
136
- ...style,
137
- };
138
-
139
- switch (position) {
140
- case 'top':
141
- fallbackStyles.bottom = '100%';
142
- fallbackStyles.left = '50%';
143
- fallbackStyles.transform = 'translateX(-50%)';
144
- break;
145
- case 'top-left':
146
- fallbackStyles.bottom = '100%';
147
- fallbackStyles.left = 0;
148
- break;
149
- case 'top-right':
150
- fallbackStyles.bottom = '100%';
151
- fallbackStyles.right = 0;
152
- break;
153
- case 'bottom':
154
- fallbackStyles.top = '100%';
155
- fallbackStyles.left = '50%';
156
- fallbackStyles.transform = 'translateX(-50%)';
157
- break;
158
- case 'bottom-left':
159
- fallbackStyles.top = '100%';
160
- fallbackStyles.left = 0;
161
- break;
162
- case 'bottom-right':
163
- fallbackStyles.top = '100%';
164
- fallbackStyles.right = 0;
165
- break;
166
- case 'left':
167
- fallbackStyles.right = '100%';
168
- fallbackStyles.top = '50%';
169
- fallbackStyles.transform = 'translateY(-50%)';
170
- break;
171
- case 'right':
172
- fallbackStyles.left = '100%';
173
- fallbackStyles.top = '50%';
174
- fallbackStyles.transform = 'translateY(-50%)';
175
- break;
176
- }
177
-
178
- return (
179
- <SyncedFixedWrapper targetRef={anchorRef}>
180
- <div style={fallbackStyles} {...restProps}>
181
- {children}
182
- </div>
183
- </SyncedFixedWrapper>
184
- );
185
- };
@@ -1,208 +0,0 @@
1
-
2
- import { classNames, ReactProps } from '../utils';
3
- import { ButtonInterface } from '../interfaces';
4
- import { useButtonStyle } from '../styles';
5
- import { Icon } from '../icon';
6
- import { ProgressIndicator } from './ProgressIndicator';
7
- import { State } from '../effects';
8
- import React, { useEffect, useRef } from 'react';
9
-
10
- /**
11
- * Resolves variant aliases to their actual variant values
12
- */
13
- function resolveVariantAlias(
14
- variant?:
15
- | 'filled'
16
- | 'elevated'
17
- | 'tonal'
18
- | 'outlined'
19
- | 'text'
20
- | 'primary'
21
- | 'secondary',
22
- ): 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text' {
23
- const aliasMap = {
24
- primary: 'filled',
25
- secondary: 'tonal',
26
- } as const;
27
-
28
- if (variant && variant in aliasMap) {
29
- return aliasMap[variant as keyof typeof aliasMap];
30
- }
31
-
32
- return (
33
- (variant as 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text') ||
34
- 'filled'
35
- );
36
- }
37
-
38
- /**
39
- * Buttons prompt most actions in a UI
40
- * @status beta
41
- * @category Action
42
- * @devx
43
- * - Requires `label` or children; used for visible text and a11y.
44
- * - `onToggle` uses internal state; pair with `activated` for controlled usage.
45
- * @limitations
46
- * - No explicit `type` prop; HTML button defaults may submit in forms.
47
- * - When `href` is set, `disabled` is visual only (no `aria-disabled`).
48
- */
49
- export const Button = ({
50
- variant = 'filled',
51
- disabled = false,
52
- icon,
53
- href,
54
- label,
55
- disableTextMargins,
56
- className,
57
- iconPosition = 'left',
58
- loading = false,
59
- shape = 'rounded',
60
- onClick,
61
- onToggle,
62
- activated,
63
- ref,
64
- size = 'medium',
65
- allowShapeTransformation = true,
66
- transition,
67
- children,
68
- ...restProps
69
- }: ReactProps<ButtonInterface>) => {
70
- if (children) label = children;
71
- if (!label) {
72
- throw new Error(
73
- 'Button component requires either a label prop or children content',
74
- );
75
- }
76
- variant = resolveVariantAlias(variant);
77
-
78
- const ElementType = href ? 'a' : 'button';
79
-
80
- const defaultRef = useRef<HTMLDivElement>(null);
81
- const resolvedRef = ref || defaultRef;
82
-
83
- const [isActive, setIsActive] = React.useState(activated);
84
- useEffect(() => {
85
- setIsActive(activated);
86
- }, [activated]);
87
-
88
- transition = { duration: 0.3, ...transition };
89
-
90
- const handleClick = (e: React.MouseEvent<any, MouseEvent>) => {
91
- if (disabled) {
92
- e.preventDefault();
93
- }
94
- if (onToggle) {
95
- setIsActive(!isActive);
96
- onToggle(!isActive);
97
- } else if (onClick) {
98
- onClick(e);
99
- }
100
- };
101
-
102
- const styles = useButtonStyle({
103
- allowShapeTransformation,
104
- size,
105
- disableTextMargins,
106
- shape,
107
- href,
108
- disabled,
109
- icon,
110
- iconPosition,
111
- loading,
112
- variant,
113
- transition,
114
- className,
115
- isActive: isActive ?? false,
116
- onToggle,
117
- activated: isActive,
118
- label,
119
- children: label,
120
- });
121
- const iconElement = icon ? (
122
- <Icon icon={icon} className={styles.icon} />
123
- ) : (
124
- <></>
125
- );
126
-
127
- return (
128
- <ElementType
129
- ref={resolvedRef}
130
- href={href}
131
- className={styles.button}
132
- {...(restProps as any)}
133
- onClick={handleClick}
134
- disabled={disabled}
135
- aria-pressed={onToggle ? isActive : undefined}
136
- style={{ transition: transition.duration + 's' }}
137
- >
138
- <div className={styles.touchTarget}></div>
139
- <State
140
- style={{ transition: transition.duration + 's' }}
141
- className={styles.stateLayer}
142
- colorName={classNames(
143
- variant === 'filled' && {
144
- 'on-surface-variant': !isActive && Boolean(onToggle),
145
- 'on-primary': isActive || !onToggle,
146
- },
147
- variant === 'elevated' && {
148
- 'on-primary': isActive && Boolean(onToggle),
149
- primary: !isActive || !onToggle,
150
- },
151
- variant === 'tonal' && {
152
- 'on-secondary': isActive && Boolean(onToggle),
153
- 'on-secondary-container': !isActive || !onToggle,
154
- },
155
- variant === 'outlined' && {
156
- 'inverse-on-surface': isActive && Boolean(onToggle),
157
- 'on-surface-variant': !isActive || !onToggle,
158
- },
159
- variant === 'text' && 'primary',
160
- )}
161
- stateClassName={'state-ripple-group-[button]'}
162
- />
163
-
164
- {iconPosition === 'left' && iconElement}
165
- {loading && (
166
- <div
167
- className={
168
- '!absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2'
169
- }
170
- >
171
- <ProgressIndicator
172
- className={() => ({
173
- progressIndicator: 'h-6 w-6',
174
- activeIndicator: classNames(
175
- {
176
- '!stroke-primary': variant === 'elevated' && !disabled,
177
- '!stroke-on-surface/[38%]':
178
- variant === 'elevated' && disabled,
179
- },
180
- {
181
- '!stroke-on-primary': variant === 'filled' && !disabled,
182
- '!stroke-on-surface/[38%]': variant === 'filled' && disabled,
183
- },
184
- {
185
- '!stroke-on-secondary-container':
186
- variant === 'tonal' && !disabled,
187
- '!stroke-on-surface/[38%]': variant === 'tonal' && disabled,
188
- },
189
- {
190
- '!stroke-primary': variant === 'outlined' && !disabled,
191
- '!stroke-on-surface/[38%]':
192
- variant === 'outlined' && disabled,
193
- },
194
- {
195
- '!stroke-primary': variant === 'text' && !disabled,
196
- '!stroke-on-surface/[38%]': variant === 'text' && disabled,
197
- },
198
- ),
199
- })}
200
- variant={'circular-indeterminate'}
201
- />
202
- </div>
203
- )}
204
- <span className={styles.label}>{label}</span>
205
- {iconPosition === 'right' && iconElement}
206
- </ElementType>
207
- );
208
- };
@@ -1,47 +0,0 @@
1
- import { useRef } from 'react';
2
- import { CardInterface } from '../interfaces';
3
- import { useCardStyle } from '../styles';
4
- import { ReactProps } from '../utils';
5
- import { State } from '../effects';
6
-
7
- /**
8
- * Cards display content and actions about a single subject
9
- * @status beta
10
- * @category Layout
11
- * @devx
12
- * - `interactive` only adds a state layer; add your own click/role semantics.
13
- * @limitations
14
- * - No built-in header/actions slots; layout is fully custom via children.
15
- */
16
- export const Card = ({
17
- variant = 'outlined',
18
- className,
19
- children,
20
- interactive = false,
21
- ref,
22
- ...rest
23
- }: ReactProps<CardInterface>) => {
24
- const styles = useCardStyle({
25
- className,
26
- interactive,
27
- variant,
28
- children,
29
- });
30
-
31
- const defaultRef = useRef<HTMLDivElement>(null);
32
- const resolvedRef = ref || defaultRef;
33
-
34
- return (
35
- <div {...rest} ref={resolvedRef} className={styles.card}>
36
- {interactive && (
37
- <State
38
- className={styles.stateLayer}
39
- colorName={'on-surface'}
40
- stateClassName={'state-ripple-group-[card]'}
41
- />
42
- )}
43
-
44
- {children}
45
- </div>
46
- );
47
- };