@luxfi/ui 7.4.9 → 7.4.11

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 (82) hide show
  1. package/dist/accordion.cjs +107 -166
  2. package/dist/accordion.d.cts +18 -51
  3. package/dist/accordion.d.ts +18 -51
  4. package/dist/accordion.js +109 -166
  5. package/dist/chrome.cjs +193 -379
  6. package/dist/chrome.js +195 -379
  7. package/dist/collapsible.cjs +35 -26
  8. package/dist/collapsible.d.cts +2 -1
  9. package/dist/collapsible.d.ts +2 -1
  10. package/dist/collapsible.js +34 -24
  11. package/dist/dialog.d.cts +1 -1
  12. package/dist/dialog.d.ts +1 -1
  13. package/dist/drawer.cjs +92 -115
  14. package/dist/drawer.d.cts +43 -10
  15. package/dist/drawer.d.ts +43 -10
  16. package/dist/drawer.js +94 -115
  17. package/dist/field.cjs +60 -109
  18. package/dist/field.d.cts +0 -1
  19. package/dist/field.d.ts +0 -1
  20. package/dist/field.js +61 -109
  21. package/dist/heading.cjs +10 -17
  22. package/dist/heading.d.cts +0 -2
  23. package/dist/heading.d.ts +0 -2
  24. package/dist/heading.js +10 -17
  25. package/dist/icon-button.cjs +82 -82
  26. package/dist/icon-button.d.cts +16 -12
  27. package/dist/icon-button.d.ts +16 -12
  28. package/dist/icon-button.js +82 -82
  29. package/dist/index.cjs +1073 -1419
  30. package/dist/index.d.cts +1 -5
  31. package/dist/index.d.ts +1 -5
  32. package/dist/index.js +1075 -1414
  33. package/dist/input-group.cjs +11 -12
  34. package/dist/input-group.js +11 -12
  35. package/dist/input.cjs +27 -27
  36. package/dist/input.d.cts +21 -1
  37. package/dist/input.d.ts +21 -1
  38. package/dist/input.js +25 -28
  39. package/dist/menu.cjs +160 -271
  40. package/dist/menu.d.cts +41 -57
  41. package/dist/menu.d.ts +41 -57
  42. package/dist/menu.js +161 -251
  43. package/dist/next.cjs +6 -10
  44. package/dist/next.js +5 -9
  45. package/dist/popover.cjs +1 -1
  46. package/dist/popover.js +1 -1
  47. package/dist/select.cjs +40 -39
  48. package/dist/select.d.cts +35 -4
  49. package/dist/select.d.ts +35 -4
  50. package/dist/select.js +40 -38
  51. package/dist/separator.cjs +8 -33
  52. package/dist/separator.js +8 -33
  53. package/dist/tabs.cjs +108 -197
  54. package/dist/tabs.d.cts +16 -60
  55. package/dist/tabs.d.ts +16 -60
  56. package/dist/tabs.js +109 -196
  57. package/dist/textarea.cjs +56 -27
  58. package/dist/textarea.js +57 -28
  59. package/dist/toaster.cjs +97 -79
  60. package/dist/toaster.d.cts +7 -8
  61. package/dist/toaster.d.ts +7 -8
  62. package/dist/toaster.js +78 -80
  63. package/package.json +2 -16
  64. package/src/accordion.tsx +173 -227
  65. package/src/collapsible.tsx +55 -52
  66. package/src/drawer.tsx +123 -115
  67. package/src/engine.ts +0 -25
  68. package/src/field.tsx +68 -124
  69. package/src/heading.tsx +22 -26
  70. package/src/icon-button.tsx +134 -141
  71. package/src/ink.tsx +37 -0
  72. package/src/input-group.tsx +21 -12
  73. package/src/input.tsx +41 -32
  74. package/src/menu.tsx +224 -397
  75. package/src/next.ts +32 -1
  76. package/src/popover.tsx +1 -1
  77. package/src/select.tsx +80 -59
  78. package/src/separator.tsx +13 -34
  79. package/src/tabs.tsx +166 -296
  80. package/src/textarea.tsx +19 -29
  81. package/src/toaster.tsx +118 -86
  82. package/tokens.css +61 -0
package/dist/accordion.js CHANGED
@@ -1,186 +1,129 @@
1
1
  "use client";
2
- import * as AccordionPrimitive from '@radix-ui/react-accordion';
2
+ import { Accordion, Text, XStack, View } from '@hanzo/gui';
3
3
  import * as React from 'react';
4
- import { clsx } from 'clsx';
5
- import { twMerge } from 'tailwind-merge';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { Children, createElement } from 'react';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
6
 
8
7
  // src/accordion.tsx
9
- function cn(...inputs) {
10
- return twMerge(clsx(inputs));
11
- }
12
- var IndicatorIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
13
- var AccordionRoot = React.forwardRef(
14
- function AccordionRoot2(props, ref) {
15
- const {
16
- multiple: _multiple,
17
- value,
18
- defaultValue,
19
- onValueChange,
20
- variant,
21
- size,
22
- noAnimation: _noAnimation,
23
- lazyMount: _lazyMount,
24
- className,
25
- children,
26
- position: _position,
27
- w: _w,
28
- bgColor: _bgColor,
29
- borderRadius: _borderRadius,
30
- ...rest
31
- } = props;
32
- const handleValueChange = React.useCallback(
33
- (next) => {
34
- onValueChange?.({ value: next });
35
- },
36
- [onValueChange]
37
- );
38
- return /* @__PURE__ */ jsx(
39
- AccordionPrimitive.Root,
40
- {
41
- ref,
42
- type: "multiple",
43
- value,
44
- defaultValue,
45
- onValueChange: handleValueChange,
46
- className: cn(
47
- "w-full",
48
- variant === "faq" && "accordion-faq",
49
- size === "sm" && "accordion-sm",
50
- className
51
- ),
52
- "data-variant": variant,
53
- "data-size": size,
54
- ...rest,
55
- children
56
- }
57
- );
8
+ var ink = (children, Wrap = Text, props = {}) => {
9
+ let hasText = false;
10
+ Children.forEach(children, (child) => {
11
+ if (typeof child === "string" || typeof child === "number") hasText = true;
12
+ });
13
+ if (!hasText) return children;
14
+ return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
15
+ };
16
+ var IndicatorIcon = () => /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
17
+ var BAR = "var(--color-text-primary)";
18
+ var Indicator = ({ open, variant }) => variant === "faq" ? /* @__PURE__ */ jsxs(XStack, { width: 12, height: 12, flexShrink: 0, alignItems: "center", justifyContent: "center", position: "relative", children: [
19
+ /* @__PURE__ */ jsx(View, { position: "absolute", width: "100%", height: 2, borderRadius: 2, backgroundColor: BAR }),
20
+ /* @__PURE__ */ jsx(
21
+ View,
22
+ {
23
+ position: "absolute",
24
+ width: 2,
25
+ height: "100%",
26
+ borderRadius: 2,
27
+ backgroundColor: BAR,
28
+ rotate: open ? "90deg" : "0deg"
29
+ }
30
+ )
31
+ ] }) : /* @__PURE__ */ jsx(XStack, { flexShrink: 0, alignItems: "center", rotate: open ? "270deg" : "180deg", children: /* @__PURE__ */ jsx(IndicatorIcon, {}) });
32
+ var Variant = React.createContext(void 0);
33
+ var AccordionRoot = ({
34
+ value,
35
+ defaultValue,
36
+ onValueChange,
37
+ variant,
38
+ size,
39
+ children,
40
+ ...rest
41
+ }) => /* @__PURE__ */ jsx(Variant.Provider, { value: variant, children: /* @__PURE__ */ jsx(
42
+ Accordion,
43
+ {
44
+ unstyled: true,
45
+ type: "multiple",
46
+ width: "100%",
47
+ value,
48
+ defaultValue,
49
+ onValueChange: onValueChange ? (next) => onValueChange({ value: next }) : void 0,
50
+ "data-variant": variant,
51
+ "data-size": size,
52
+ ...rest,
53
+ children
58
54
  }
59
- );
60
- var AccordionItem = React.forwardRef(
61
- function AccordionItem2(props, ref) {
62
- const { className, as: _as, _first, _last, display: _display, ...rest } = props;
63
- return /* @__PURE__ */ jsx(
64
- AccordionPrimitive.Item,
65
- {
66
- ref,
67
- className: cn(
68
- "border-b border-[var(--color-border-divider)]",
69
- className
70
- ),
71
- ...rest
72
- }
73
- );
55
+ ) });
56
+ var AccordionItem = (props) => /* @__PURE__ */ jsx(
57
+ Accordion.Item,
58
+ {
59
+ unstyled: true,
60
+ borderBottomWidth: 1,
61
+ borderColor: "var(--color-border-divider)",
62
+ ...props
74
63
  }
75
64
  );
76
- var AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger2(props, ref) {
77
- const {
78
- children,
79
- indicatorPlacement: indicatorPlacementProp,
80
- variant,
81
- noIndicator,
82
- className,
83
- // Strip Chakra style props
84
- px: _px,
85
- py: _py,
86
- _hover,
87
- wordBreak: _wordBreak,
88
- textAlign: _textAlign,
89
- cursor: _cursor,
90
- display: _display,
91
- alignItems: _alignItems,
92
- columnGap: _columnGap,
93
- ...rest
94
- } = props;
95
- const indicatorPlacement = variant === "faq" ? "start" : indicatorPlacementProp ?? "end";
96
- const indicator = variant === "faq" ? /* @__PURE__ */ jsx(
97
- "span",
98
- {
99
- className: cn(
100
- "relative inline-block h-3 w-3 shrink-0",
101
- // horizontal bar (always visible)
102
- "before:absolute before:left-0 before:top-1/2 before:block before:h-[2px] before:w-full before:-translate-y-1/2 before:rounded-[2px] before:bg-current",
103
- // vertical bar (rotates to 0 when open)
104
- "after:absolute after:left-1/2 after:top-0 after:block after:h-full after:w-[2px]",
105
- "after:-translate-x-1/2 after:rounded-[2px] after:bg-current",
106
- "after:transition-transform after:duration-200 after:ease-in-out",
107
- // When parent trigger has data-state="open", rotate vertical bar
108
- "group-data-[state=open]/trigger:after:rotate-90"
109
- )
110
- }
111
- ) : /* @__PURE__ */ jsx(
112
- "span",
113
- {
114
- className: cn(
115
- "inline-flex shrink-0 transition-transform duration-200",
116
- "rotate-180",
117
- "group-data-[state=open]/trigger:rotate-[270deg]"
118
- ),
119
- children: /* @__PURE__ */ jsx(IndicatorIcon, { className: "h-5 w-5" })
120
- }
121
- );
122
- return /* @__PURE__ */ jsx(AccordionPrimitive.Header, { asChild: true, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
123
- AccordionPrimitive.Trigger,
65
+ var AccordionItemTrigger = ({
66
+ children,
67
+ indicatorPlacement: placementProp,
68
+ variant: variantProp,
69
+ noIndicator,
70
+ headingLevel = 3,
71
+ ...rest
72
+ }) => {
73
+ const variant = variantProp ?? React.useContext(Variant);
74
+ const placement = variant === "faq" ? "start" : placementProp ?? "end";
75
+ return /* @__PURE__ */ jsx(Accordion.Header, { unstyled: true, render: `h${headingLevel}`, "aria-level": headingLevel, display: "flex", width: "100%", children: /* @__PURE__ */ jsx(
76
+ Accordion.Trigger,
124
77
  {
125
- ref,
126
- className: cn(
127
- "group/trigger flex w-full cursor-pointer items-center gap-2 py-3 text-left text-[var(--color-text-primary)]",
128
- "hover:text-[var(--color-hover)]",
129
- "focus-visible:outline-none",
130
- className
131
- ),
78
+ unstyled: true,
79
+ type: "button",
80
+ width: "100%",
81
+ flexDirection: "row",
82
+ alignItems: "center",
83
+ gap: 8,
84
+ paddingVertical: 12,
85
+ paddingHorizontal: 0,
86
+ borderWidth: 0,
87
+ backgroundColor: "transparent",
88
+ cursor: "pointer",
89
+ className: "lux-accordion-trigger",
132
90
  ...rest,
133
- children: [
134
- indicatorPlacement === "start" && !noIndicator && indicator,
135
- children,
136
- indicatorPlacement === "end" && !noIndicator && indicator
137
- ]
91
+ children: (({ open }) => /* @__PURE__ */ jsxs(Fragment, { children: [
92
+ placement === "start" && !noIndicator && /* @__PURE__ */ jsx(Indicator, { open, variant }),
93
+ ink(children, void 0, { color: "inherit", textAlign: "left" }),
94
+ placement === "end" && !noIndicator && /* @__PURE__ */ jsx(Indicator, { open, variant })
95
+ ] }))
138
96
  }
139
- ) }) });
140
- });
141
- var AccordionItemContent = React.forwardRef(function AccordionItemContent2(props, ref) {
142
- const { className, children, pb: _pb, pr: _pr, pl: _pl, w: _w, display: _display, flexDir: _flexDir, rowGap: _rowGap, ...rest } = props;
143
- return /* @__PURE__ */ jsx(
144
- AccordionPrimitive.Content,
145
- {
146
- ref,
147
- className: cn(
148
- "overflow-hidden text-[var(--color-text-primary)]",
149
- "data-[state=open]:animate-accordion-down",
150
- "data-[state=closed]:animate-accordion-up",
151
- className
152
- ),
153
- ...rest,
154
- children: /* @__PURE__ */ jsx("div", { className: "pb-3", children })
155
- }
156
- );
157
- });
97
+ ) });
98
+ };
99
+ var AccordionItemContent = ({ children, ...rest }) => /* @__PURE__ */ jsx(
100
+ Accordion.Content,
101
+ {
102
+ unstyled: true,
103
+ overflow: "hidden",
104
+ paddingBottom: 12,
105
+ backgroundColor: "transparent",
106
+ ...rest,
107
+ children: ink(children, void 0, { color: "var(--color-text-primary)" })
108
+ }
109
+ );
158
110
  function useAccordion(items) {
159
111
  const [value, setValue] = React.useState([]);
160
- const onValueChange = React.useCallback(({ value: value2 }) => {
161
- setValue(value2);
112
+ const onValueChange = React.useCallback(({ value: next }) => {
113
+ setValue(next);
162
114
  }, []);
163
115
  const scrollToItemFromUrl = React.useCallback(() => {
164
116
  const hash = window.location.hash.replace("#", "");
165
- if (!hash) {
166
- return;
167
- }
117
+ if (!hash) return;
168
118
  const itemToScroll = items.find((item) => item.id === hash);
169
- if (itemToScroll) {
170
- const el = document.getElementById(itemToScroll.id);
171
- if (el) {
172
- el.scrollIntoView({ behavior: "smooth", block: "start" });
173
- }
174
- setValue([itemToScroll.id]);
175
- }
119
+ if (!itemToScroll) return;
120
+ document.getElementById(itemToScroll.id)?.scrollIntoView({ behavior: "smooth", block: "start" });
121
+ setValue([itemToScroll.id]);
176
122
  }, [items]);
177
- return React.useMemo(() => {
178
- return {
179
- value,
180
- onValueChange,
181
- scrollToItemFromUrl
182
- };
183
- }, [value, onValueChange, scrollToItemFromUrl]);
123
+ return React.useMemo(
124
+ () => ({ value, onValueChange, scrollToItemFromUrl }),
125
+ [value, onValueChange, scrollToItemFromUrl]
126
+ );
184
127
  }
185
128
 
186
129
  export { AccordionItem, AccordionItemContent, AccordionItemTrigger, AccordionRoot, useAccordion };