athameui 0.0.2

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 (54) hide show
  1. package/README.md +7 -0
  2. package/components/Accordion/Accordion.tsx +81 -0
  3. package/components/Accordion/AccordionItem.tsx +65 -0
  4. package/components/Accordion/index.ts +2 -0
  5. package/components/Button/BackToTopButton.tsx +53 -0
  6. package/components/Button/Button.tsx +114 -0
  7. package/components/Button/ButtonGroup.tsx +13 -0
  8. package/components/Button/ButtonPrimitive.tsx +16 -0
  9. package/components/Button/button.variants.ts +30 -0
  10. package/components/Button/index.ts +3 -0
  11. package/components/Button/stories/Buttons.stories.tsx +81 -0
  12. package/components/Header/Header.tsx +12 -0
  13. package/components/Header/index.ts +1 -0
  14. package/components/List/List.tsx +44 -0
  15. package/components/List/ListItem.tsx +52 -0
  16. package/components/index.ts +5 -0
  17. package/dist/athameui.cjs +188 -0
  18. package/dist/athameui.cjs.map +1 -0
  19. package/dist/athameui.mjs +181 -0
  20. package/dist/athameui.mjs.map +1 -0
  21. package/dist/components/Accordion/Accordion.d.ts +15 -0
  22. package/dist/components/Accordion/Accordion.d.ts.map +1 -0
  23. package/dist/components/Accordion/AccordionItem.d.ts +15 -0
  24. package/dist/components/Accordion/AccordionItem.d.ts.map +1 -0
  25. package/dist/components/Accordion/index.d.ts +3 -0
  26. package/dist/components/Accordion/index.d.ts.map +1 -0
  27. package/dist/components/Button/BackToTopButton.d.ts +7 -0
  28. package/dist/components/Button/BackToTopButton.d.ts.map +1 -0
  29. package/dist/components/Button/Button.d.ts +48 -0
  30. package/dist/components/Button/Button.d.ts.map +1 -0
  31. package/dist/components/Button/ButtonGroup.d.ts +8 -0
  32. package/dist/components/Button/ButtonGroup.d.ts.map +1 -0
  33. package/dist/components/Button/ButtonPrimitive.d.ts +3 -0
  34. package/dist/components/Button/ButtonPrimitive.d.ts.map +1 -0
  35. package/dist/components/Button/button.variants.d.ts +29 -0
  36. package/dist/components/Button/button.variants.d.ts.map +1 -0
  37. package/dist/components/Button/index.d.ts +4 -0
  38. package/dist/components/Button/index.d.ts.map +1 -0
  39. package/dist/components/Header/Header.d.ts +7 -0
  40. package/dist/components/Header/Header.d.ts.map +1 -0
  41. package/dist/components/Header/index.d.ts +2 -0
  42. package/dist/components/Header/index.d.ts.map +1 -0
  43. package/dist/components/List/List.d.ts +18 -0
  44. package/dist/components/List/List.d.ts.map +1 -0
  45. package/dist/components/List/ListItem.d.ts +20 -0
  46. package/dist/components/List/ListItem.d.ts.map +1 -0
  47. package/dist/components/index.d.ts +4 -0
  48. package/dist/components/index.d.ts.map +1 -0
  49. package/dist/main.d.ts +2 -0
  50. package/dist/main.d.ts.map +1 -0
  51. package/dist/utils/cx.d.ts +2 -0
  52. package/dist/utils/cx.d.ts.map +1 -0
  53. package/main.ts +1 -0
  54. package/package.json +73 -0
@@ -0,0 +1,181 @@
1
+ "use client";
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { forwardRef, createElement, useState, useEffect, useRef } from 'react';
4
+
5
+ const ButtonPrimitive = forwardRef(({ children, ...rest }, ref) => {
6
+ return (jsx("button", { ref: ref, ...rest, children: children }));
7
+ });
8
+
9
+ function cx(...classes) {
10
+ return classes.filter(Boolean).join(" ");
11
+ }
12
+
13
+ // button.variants.ts
14
+ const buttonVariants = {
15
+ size: {
16
+ small: "ath-button-small",
17
+ medium: "ath-button-medium",
18
+ large: "ath-button-large",
19
+ full: "ath-button-full",
20
+ },
21
+ variant: {
22
+ primary: "ath-button-primary",
23
+ secondary: "ath-button-secondary",
24
+ tertiary: "ath-button-tertiary",
25
+ danger: "ath-button-danger",
26
+ warning: "ath-button-warning",
27
+ success: "ath-button-success",
28
+ outline: "ath-button-outline",
29
+ ghost: "ath-button-ghost",
30
+ },
31
+ textAlign: {
32
+ left: "ath-button-text-left",
33
+ center: "ath-button-text-center",
34
+ right: "ath-button-text-right",
35
+ },
36
+ dark: "ath-button-dark",
37
+ };
38
+
39
+ const Button = forwardRef(({ children, className, variant = "primary", size = "medium", dark = false, disabled = false, icon, iconOnly, tabIndex, testId, type = "button", title, autoFocus = false, textAlign = "center", onBlur, onClick, onFocus, onKeyDown, ...rest }, ref) => {
40
+ const classes = cx("ath-button", buttonVariants.size[size], buttonVariants.variant[variant], buttonVariants.textAlign[textAlign], dark ? buttonVariants.dark : "", typeof className === "object" && className !== null
41
+ ? className.button
42
+ : className);
43
+ const onClickHandler = (e) => {
44
+ onClick?.(e);
45
+ };
46
+ return (jsx(ButtonPrimitive, { ref: ref, type: type, title: title, className: classes, disabled: disabled, autoFocus: autoFocus, tabIndex: disabled ? -1 : tabIndex, "data-testid": testId, onClick: onClickHandler, onKeyDown: onKeyDown, onFocus: onFocus, onBlur: onBlur, ...rest, children: icon ? (jsxs(Fragment, { children: [typeof icon === "string" ? (jsx("span", { "aria-hidden": "true", children: icon })) : (icon), !iconOnly && children] })) : (jsx(Fragment, { children: children })) }));
47
+ });
48
+ Button.displayName = "Button";
49
+
50
+ const ButtonGroup = ({ children, gap = "2", direction = "row", }) => {
51
+ return jsx("div", { className: `flex flex-${direction} gap-${gap}`, children: children });
52
+ };
53
+
54
+ const defaultAttributes = {
55
+ xmlns: 'http://www.w3.org/2000/svg',
56
+ width: 24,
57
+ height: 24,
58
+ viewBox: '0 0 24 24',
59
+ fill: 'none',
60
+ };
61
+ const HugeiconsIcon = forwardRef(({ color = 'currentColor', size = 24, strokeWidth, absoluteStrokeWidth = false, className = '', altIcon, showAlt = false, icon, primaryColor, secondaryColor, disableSecondaryOpacity = false, ...rest }, ref) => {
62
+ const calculatedStrokeWidth = strokeWidth !== undefined
63
+ ? (absoluteStrokeWidth ? (Number(strokeWidth) * 24) / Number(size) : strokeWidth)
64
+ : undefined;
65
+ const strokeProps = calculatedStrokeWidth !== undefined ? {
66
+ strokeWidth: calculatedStrokeWidth,
67
+ stroke: 'currentColor'
68
+ } : {};
69
+ const elementProps = {
70
+ ref,
71
+ ...defaultAttributes,
72
+ width: size,
73
+ height: size,
74
+ color: primaryColor || color,
75
+ className,
76
+ ...strokeProps,
77
+ ...rest,
78
+ };
79
+ const currentIcon = (showAlt && altIcon) ? altIcon : icon;
80
+ // Create SVG children with color handling for two-tone icons
81
+ const svgChildren = [...currentIcon]
82
+ .sort(([, a], [, b]) => {
83
+ const hasOpacityA = a.opacity !== undefined;
84
+ const hasOpacityB = b.opacity !== undefined;
85
+ return hasOpacityB ? 1 : hasOpacityA ? -1 : 0;
86
+ })
87
+ .map(([tag, attrs]) => {
88
+ const isSecondaryPath = attrs.opacity !== undefined;
89
+ const pathOpacity = isSecondaryPath && !disableSecondaryOpacity ? attrs.opacity : undefined;
90
+ // Handle both stroke and fill properties based on element type
91
+ const fillProps = secondaryColor ? {
92
+ ...(attrs.stroke !== undefined ? {
93
+ stroke: isSecondaryPath ? secondaryColor : (primaryColor || color)
94
+ } : {
95
+ fill: isSecondaryPath ? secondaryColor : (primaryColor || color)
96
+ })
97
+ } : {};
98
+ return createElement(tag, {
99
+ ...attrs,
100
+ ...strokeProps,
101
+ ...fillProps,
102
+ opacity: pathOpacity,
103
+ key: attrs.key
104
+ });
105
+ });
106
+ return createElement('svg', elementProps, svgChildren);
107
+ });
108
+ HugeiconsIcon.displayName = 'HugeiconsIcon';
109
+
110
+ const ll=[["path",{d:"M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M12 9.00014V16.0002M15.5 11.5C15.5 11.5 12.9223 8.00001 12 8C11.0777 7.99999 8.50003 11.5 8.50003 11.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];
111
+
112
+ const BackToTopButton = (props) => {
113
+ const { className, variant, dark = false, testId, title } = props;
114
+ const [visible, setVisible] = useState(false);
115
+ useEffect(() => {
116
+ const handleScroll = () => {
117
+ const scrollPosition = window.scrollY;
118
+ if (scrollPosition < 300) {
119
+ setVisible(false);
120
+ }
121
+ else {
122
+ setVisible(true);
123
+ }
124
+ };
125
+ window.addEventListener("scroll", handleScroll);
126
+ return () => {
127
+ window.removeEventListener("scroll", handleScroll);
128
+ };
129
+ }, []);
130
+ const scrollToTop = () => {
131
+ window.scrollTo({ top: 0, behavior: "smooth" });
132
+ };
133
+ if (!visible)
134
+ return null;
135
+ const classes = cx("ath-back-to-top-button", className);
136
+ return (jsx(Button, { className: classes, "data-testid": `${testId} "ath-back-to-top-button"`, onClick: scrollToTop, variant: variant ?? "secondary", title: title ?? "Back to Top", dark: dark, children: jsx(HugeiconsIcon, { icon: ll, width: "50", height: "50" }) }));
137
+ };
138
+
139
+ const Header = ({ children, className }) => {
140
+ const classes = cx("ath-header", className);
141
+ return jsx("header", { className: classes, children: children });
142
+ };
143
+
144
+ const AccordionItem = ({ item, expanded, onToggle, className, }) => {
145
+ const contentRef = useRef(null);
146
+ const contentHeight = contentRef.current?.scrollHeight;
147
+ const classes = cx("ath-accordion-item", typeof className === "object" && className !== null
148
+ ? className.accordionItem
149
+ : className);
150
+ return (jsxs("div", { className: classes, children: [jsx(Button, { className: "ath-accordion-item-heading", variant: "ghost", size: "full", textAlign: "left", onClick: () => onToggle(item.id), dark: true, children: jsx("h4", { children: item.heading }) }), jsx("div", { className: cx("ath-accordion-expansion-wrapper", expanded && "expanded"), style: { height: expanded ? contentHeight : 0 }, children: jsx("div", { ref: contentRef, className: "ath-accordion-item-content", children: item.content }) })] }));
151
+ };
152
+
153
+ const Accordion = ({ children, className, items, childrenFirst, expand = "one", expandToggleCallback, }) => {
154
+ const [expandedItems, setExpandedItems] = useState([]);
155
+ const classes = cx("ath-accordion", typeof className === "object" && className !== null
156
+ ? className.accordion
157
+ : className);
158
+ const expandToggle = (itemId) => {
159
+ console.log("Rendering AccordionItem:", itemId, "Expanded:", expandedItems.includes(itemId));
160
+ if (expandedItems.includes(itemId)) {
161
+ setExpandedItems(expandedItems.filter((id) => id !== itemId));
162
+ }
163
+ else {
164
+ if (expand === "one") {
165
+ setExpandedItems([itemId]);
166
+ }
167
+ else if (expand === "any") {
168
+ setExpandedItems([...expandedItems, itemId]);
169
+ }
170
+ }
171
+ if (expandToggleCallback) {
172
+ expandToggleCallback(expandedItems);
173
+ }
174
+ };
175
+ return (jsxs("div", { className: classes, children: [childrenFirst && children, items.map((item) => (jsx(AccordionItem, { item: item, expanded: expandedItems.includes(item.id), onToggle: expandToggle, className: typeof className === "object" && className !== null
176
+ ? className.accordionItem
177
+ : undefined }, item.id))), !childrenFirst && children] }));
178
+ };
179
+
180
+ export { Accordion, AccordionItem, BackToTopButton, Button, ButtonGroup, Header };
181
+ //# sourceMappingURL=athameui.mjs.map