@luxfi/ui 1.0.1
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/dist/accordion.cjs +213 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +553 -0
- package/dist/alert.js +531 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +611 -0
- package/dist/badge.js +589 -0
- package/dist/button.cjs +689 -0
- package/dist/button.js +664 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +73 -0
- package/dist/close-button.js +51 -0
- package/dist/collapsible.cjs +711 -0
- package/dist/collapsible.js +685 -0
- package/dist/color-mode.cjs +36 -0
- package/dist/color-mode.js +32 -0
- package/dist/dialog.cjs +279 -0
- package/dist/dialog.js +246 -0
- package/dist/drawer.cjs +207 -0
- package/dist/drawer.js +175 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.js +71 -0
- package/dist/field.cjs +183 -0
- package/dist/field.js +160 -0
- package/dist/heading.cjs +46 -0
- package/dist/heading.js +40 -0
- package/dist/icon-button.cjs +491 -0
- package/dist/icon-button.js +470 -0
- package/dist/image.cjs +572 -0
- package/dist/image.js +551 -0
- package/dist/index.cjs +5749 -0
- package/dist/index.js +5586 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +639 -0
- package/dist/link.js +612 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.js +269 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.js +160 -0
- package/dist/popover.cjs +327 -0
- package/dist/popover.js +294 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +22 -0
- package/dist/provider.js +20 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +791 -0
- package/dist/select.js +757 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +370 -0
- package/dist/skeleton.js +346 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.js +115 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +1053 -0
- package/dist/table.js +1019 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +651 -0
- package/dist/tag.js +628 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +171 -0
- package/dist/tooltip.js +148 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.js +9 -0
- package/package.json +296 -0
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +158 -0
- package/src/button.tsx +411 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +51 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +37 -0
- package/src/dialog.tsx +356 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/field.tsx +202 -0
- package/src/heading.tsx +55 -0
- package/src/icon-button.tsx +192 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +192 -0
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +333 -0
- package/src/menu.tsx +471 -0
- package/src/pin-input.tsx +187 -0
- package/src/popover.tsx +400 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +302 -0
- package/src/slider.tsx +152 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +184 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
package/dist/progress.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as RadixProgress from '@radix-ui/react-progress';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/progress.tsx
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
var SIZE_CLASSES = {
|
|
13
|
+
sm: "h-1",
|
|
14
|
+
md: "h-2",
|
|
15
|
+
lg: "h-3",
|
|
16
|
+
xl: "h-4"
|
|
17
|
+
};
|
|
18
|
+
function normalizeValue(value, min, max) {
|
|
19
|
+
if (value == null) return 0;
|
|
20
|
+
if (max <= min) return 0;
|
|
21
|
+
return Math.round((value - min) / (max - min) * 100);
|
|
22
|
+
}
|
|
23
|
+
var Progress = React.forwardRef(
|
|
24
|
+
function Progress2(props, ref) {
|
|
25
|
+
const {
|
|
26
|
+
value,
|
|
27
|
+
min = 0,
|
|
28
|
+
max = 100,
|
|
29
|
+
size = "md",
|
|
30
|
+
color,
|
|
31
|
+
trackProps,
|
|
32
|
+
className,
|
|
33
|
+
style,
|
|
34
|
+
w,
|
|
35
|
+
flex,
|
|
36
|
+
...rest
|
|
37
|
+
} = props;
|
|
38
|
+
const percent = normalizeValue(value, min, max);
|
|
39
|
+
const trackStyle = {
|
|
40
|
+
...trackProps?.style,
|
|
41
|
+
...trackProps?.borderStartRadius !== void 0 && {
|
|
42
|
+
borderStartStartRadius: trackProps.borderStartRadius,
|
|
43
|
+
borderEndStartRadius: trackProps.borderStartRadius
|
|
44
|
+
},
|
|
45
|
+
...trackProps?.borderEndRadius !== void 0 && {
|
|
46
|
+
borderStartEndRadius: trackProps.borderEndRadius,
|
|
47
|
+
borderEndEndRadius: trackProps.borderEndRadius
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const rootStyle = {
|
|
51
|
+
...style,
|
|
52
|
+
...w !== void 0 && { width: w === "full" ? "100%" : w },
|
|
53
|
+
...flex !== void 0 && { flex }
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
className: cn("relative", className),
|
|
60
|
+
style: rootStyle,
|
|
61
|
+
...rest,
|
|
62
|
+
children: /* @__PURE__ */ jsx(
|
|
63
|
+
RadixProgress.Root,
|
|
64
|
+
{
|
|
65
|
+
value: percent,
|
|
66
|
+
max: 100,
|
|
67
|
+
className: cn(
|
|
68
|
+
"w-full overflow-hidden rounded-full",
|
|
69
|
+
"bg-[var(--color-progress-track)]",
|
|
70
|
+
SIZE_CLASSES[size],
|
|
71
|
+
trackProps?.className
|
|
72
|
+
),
|
|
73
|
+
style: trackStyle,
|
|
74
|
+
children: /* @__PURE__ */ jsx(
|
|
75
|
+
RadixProgress.Indicator,
|
|
76
|
+
{
|
|
77
|
+
className: cn(
|
|
78
|
+
"h-full rounded-full transition-transform duration-500 ease-out",
|
|
79
|
+
!color && "bg-[var(--color-progress-indicator)]"
|
|
80
|
+
),
|
|
81
|
+
style: {
|
|
82
|
+
width: `${percent}%`,
|
|
83
|
+
...color && { backgroundColor: `var(--color-${color.replace(".", "-")}, ${color})` }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export { Progress };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var nextThemes = require('next-themes');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function ColorModeProvider(props) {
|
|
8
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9
|
+
nextThemes.ThemeProvider,
|
|
10
|
+
{
|
|
11
|
+
attribute: "class",
|
|
12
|
+
scriptProps: { "data-cfasync": "false" },
|
|
13
|
+
disableTransitionOnChange: true,
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function Provider(props) {
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ColorModeProvider, { ...props });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.Provider = Provider;
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ThemeProvider } from 'next-themes';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function ColorModeProvider(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
ThemeProvider,
|
|
8
|
+
{
|
|
9
|
+
attribute: "class",
|
|
10
|
+
scriptProps: { "data-cfasync": "false" },
|
|
11
|
+
disableTransitionOnChange: true,
|
|
12
|
+
...props
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function Provider(props) {
|
|
17
|
+
return /* @__PURE__ */ jsx(ColorModeProvider, { ...props });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Provider };
|
package/dist/radio.cjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var RadixRadioGroup = require('@radix-ui/react-radio-group');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var tailwindMerge = require('tailwind-merge');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var RadixRadioGroup__namespace = /*#__PURE__*/_interopNamespace(RadixRadioGroup);
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
+
|
|
31
|
+
// src/radio.tsx
|
|
32
|
+
function cn(...inputs) {
|
|
33
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
34
|
+
}
|
|
35
|
+
var SIZE_CLASSES = {
|
|
36
|
+
xs: {
|
|
37
|
+
root: "gap-1.5",
|
|
38
|
+
control: "h-3 w-3",
|
|
39
|
+
indicator: "h-1.5 w-1.5",
|
|
40
|
+
label: "text-xs"
|
|
41
|
+
},
|
|
42
|
+
sm: {
|
|
43
|
+
root: "gap-1.5",
|
|
44
|
+
control: "h-3.5 w-3.5",
|
|
45
|
+
indicator: "h-1.5 w-1.5",
|
|
46
|
+
label: "text-xs"
|
|
47
|
+
},
|
|
48
|
+
md: {
|
|
49
|
+
root: "gap-2",
|
|
50
|
+
control: "h-4 w-4",
|
|
51
|
+
indicator: "h-2 w-2",
|
|
52
|
+
label: "text-sm"
|
|
53
|
+
},
|
|
54
|
+
lg: {
|
|
55
|
+
root: "gap-2.5",
|
|
56
|
+
control: "h-5 w-5",
|
|
57
|
+
indicator: "h-2.5 w-2.5",
|
|
58
|
+
label: "text-base"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var RadioSizeContext = React__namespace.createContext("md");
|
|
62
|
+
var RadioGroupBase = React__namespace.forwardRef(
|
|
63
|
+
function RadioGroup(props, ref) {
|
|
64
|
+
const {
|
|
65
|
+
children,
|
|
66
|
+
name,
|
|
67
|
+
required,
|
|
68
|
+
disabled = false,
|
|
69
|
+
readOnly = false,
|
|
70
|
+
orientation = "vertical",
|
|
71
|
+
loop = true,
|
|
72
|
+
defaultValue,
|
|
73
|
+
value,
|
|
74
|
+
onValueChange,
|
|
75
|
+
size = "md",
|
|
76
|
+
className,
|
|
77
|
+
...rest
|
|
78
|
+
} = props;
|
|
79
|
+
const handleValueChange = React__namespace.useCallback(
|
|
80
|
+
(nextValue) => {
|
|
81
|
+
if (readOnly) return;
|
|
82
|
+
onValueChange?.({ value: nextValue });
|
|
83
|
+
},
|
|
84
|
+
[readOnly, onValueChange]
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadioSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
RadixRadioGroup__namespace.Root,
|
|
88
|
+
{
|
|
89
|
+
ref,
|
|
90
|
+
name,
|
|
91
|
+
required,
|
|
92
|
+
disabled: disabled || readOnly,
|
|
93
|
+
orientation,
|
|
94
|
+
loop,
|
|
95
|
+
defaultValue,
|
|
96
|
+
value: value ?? void 0,
|
|
97
|
+
onValueChange: handleValueChange,
|
|
98
|
+
className: cn(
|
|
99
|
+
"flex",
|
|
100
|
+
orientation === "vertical" ? "flex-col gap-3" : "flex-row gap-6",
|
|
101
|
+
className
|
|
102
|
+
),
|
|
103
|
+
...rest,
|
|
104
|
+
children
|
|
105
|
+
}
|
|
106
|
+
) });
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
var RadioGroup2 = RadioGroupBase;
|
|
110
|
+
var NOOP = () => {
|
|
111
|
+
};
|
|
112
|
+
var RadioBase = React__namespace.forwardRef(
|
|
113
|
+
function Radio(props, ref) {
|
|
114
|
+
const { children, inputProps, rootRef, value, disabled, className, ...rest } = props;
|
|
115
|
+
const size = React__namespace.useContext(RadioSizeContext);
|
|
116
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
118
|
+
"label",
|
|
119
|
+
{
|
|
120
|
+
ref: rootRef,
|
|
121
|
+
className: cn(
|
|
122
|
+
"inline-flex items-center cursor-pointer select-none",
|
|
123
|
+
sizeClasses.root,
|
|
124
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
125
|
+
className
|
|
126
|
+
),
|
|
127
|
+
"data-disabled": disabled || void 0,
|
|
128
|
+
...rest,
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
+
RadixRadioGroup__namespace.Item,
|
|
132
|
+
{
|
|
133
|
+
value,
|
|
134
|
+
disabled,
|
|
135
|
+
className: cn(
|
|
136
|
+
"inline-flex items-center justify-center shrink-0 rounded-full",
|
|
137
|
+
"border-2 border-current/30",
|
|
138
|
+
"data-[state=checked]:border-gray-800 dark:border-white",
|
|
139
|
+
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500",
|
|
140
|
+
"transition-colors duration-150",
|
|
141
|
+
sizeClasses.control
|
|
142
|
+
),
|
|
143
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
RadixRadioGroup__namespace.Indicator,
|
|
145
|
+
{
|
|
146
|
+
className: cn(
|
|
147
|
+
"block rounded-full bg-gray-800 dark:bg-white",
|
|
148
|
+
sizeClasses.indicator
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
155
|
+
"input",
|
|
156
|
+
{
|
|
157
|
+
ref,
|
|
158
|
+
type: "radio",
|
|
159
|
+
className: "sr-only",
|
|
160
|
+
value,
|
|
161
|
+
disabled,
|
|
162
|
+
tabIndex: -1,
|
|
163
|
+
"aria-hidden": true,
|
|
164
|
+
onChange: NOOP,
|
|
165
|
+
...inputProps
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
children != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: sizeClasses.label, children })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
var Radio2 = RadioBase;
|
|
175
|
+
|
|
176
|
+
exports.Radio = Radio2;
|
|
177
|
+
exports.RadioGroup = RadioGroup2;
|
package/dist/radio.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as RadixRadioGroup from '@radix-ui/react-radio-group';
|
|
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';
|
|
7
|
+
|
|
8
|
+
// src/radio.tsx
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
var SIZE_CLASSES = {
|
|
13
|
+
xs: {
|
|
14
|
+
root: "gap-1.5",
|
|
15
|
+
control: "h-3 w-3",
|
|
16
|
+
indicator: "h-1.5 w-1.5",
|
|
17
|
+
label: "text-xs"
|
|
18
|
+
},
|
|
19
|
+
sm: {
|
|
20
|
+
root: "gap-1.5",
|
|
21
|
+
control: "h-3.5 w-3.5",
|
|
22
|
+
indicator: "h-1.5 w-1.5",
|
|
23
|
+
label: "text-xs"
|
|
24
|
+
},
|
|
25
|
+
md: {
|
|
26
|
+
root: "gap-2",
|
|
27
|
+
control: "h-4 w-4",
|
|
28
|
+
indicator: "h-2 w-2",
|
|
29
|
+
label: "text-sm"
|
|
30
|
+
},
|
|
31
|
+
lg: {
|
|
32
|
+
root: "gap-2.5",
|
|
33
|
+
control: "h-5 w-5",
|
|
34
|
+
indicator: "h-2.5 w-2.5",
|
|
35
|
+
label: "text-base"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var RadioSizeContext = React.createContext("md");
|
|
39
|
+
var RadioGroupBase = React.forwardRef(
|
|
40
|
+
function RadioGroup(props, ref) {
|
|
41
|
+
const {
|
|
42
|
+
children,
|
|
43
|
+
name,
|
|
44
|
+
required,
|
|
45
|
+
disabled = false,
|
|
46
|
+
readOnly = false,
|
|
47
|
+
orientation = "vertical",
|
|
48
|
+
loop = true,
|
|
49
|
+
defaultValue,
|
|
50
|
+
value,
|
|
51
|
+
onValueChange,
|
|
52
|
+
size = "md",
|
|
53
|
+
className,
|
|
54
|
+
...rest
|
|
55
|
+
} = props;
|
|
56
|
+
const handleValueChange = React.useCallback(
|
|
57
|
+
(nextValue) => {
|
|
58
|
+
if (readOnly) return;
|
|
59
|
+
onValueChange?.({ value: nextValue });
|
|
60
|
+
},
|
|
61
|
+
[readOnly, onValueChange]
|
|
62
|
+
);
|
|
63
|
+
return /* @__PURE__ */ jsx(RadioSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsx(
|
|
64
|
+
RadixRadioGroup.Root,
|
|
65
|
+
{
|
|
66
|
+
ref,
|
|
67
|
+
name,
|
|
68
|
+
required,
|
|
69
|
+
disabled: disabled || readOnly,
|
|
70
|
+
orientation,
|
|
71
|
+
loop,
|
|
72
|
+
defaultValue,
|
|
73
|
+
value: value ?? void 0,
|
|
74
|
+
onValueChange: handleValueChange,
|
|
75
|
+
className: cn(
|
|
76
|
+
"flex",
|
|
77
|
+
orientation === "vertical" ? "flex-col gap-3" : "flex-row gap-6",
|
|
78
|
+
className
|
|
79
|
+
),
|
|
80
|
+
...rest,
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
) });
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
var RadioGroup2 = RadioGroupBase;
|
|
87
|
+
var NOOP = () => {
|
|
88
|
+
};
|
|
89
|
+
var RadioBase = React.forwardRef(
|
|
90
|
+
function Radio(props, ref) {
|
|
91
|
+
const { children, inputProps, rootRef, value, disabled, className, ...rest } = props;
|
|
92
|
+
const size = React.useContext(RadioSizeContext);
|
|
93
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
94
|
+
return /* @__PURE__ */ jsxs(
|
|
95
|
+
"label",
|
|
96
|
+
{
|
|
97
|
+
ref: rootRef,
|
|
98
|
+
className: cn(
|
|
99
|
+
"inline-flex items-center cursor-pointer select-none",
|
|
100
|
+
sizeClasses.root,
|
|
101
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
102
|
+
className
|
|
103
|
+
),
|
|
104
|
+
"data-disabled": disabled || void 0,
|
|
105
|
+
...rest,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
RadixRadioGroup.Item,
|
|
109
|
+
{
|
|
110
|
+
value,
|
|
111
|
+
disabled,
|
|
112
|
+
className: cn(
|
|
113
|
+
"inline-flex items-center justify-center shrink-0 rounded-full",
|
|
114
|
+
"border-2 border-current/30",
|
|
115
|
+
"data-[state=checked]:border-gray-800 dark:border-white",
|
|
116
|
+
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500",
|
|
117
|
+
"transition-colors duration-150",
|
|
118
|
+
sizeClasses.control
|
|
119
|
+
),
|
|
120
|
+
children: /* @__PURE__ */ jsx(
|
|
121
|
+
RadixRadioGroup.Indicator,
|
|
122
|
+
{
|
|
123
|
+
className: cn(
|
|
124
|
+
"block rounded-full bg-gray-800 dark:bg-white",
|
|
125
|
+
sizeClasses.indicator
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"input",
|
|
133
|
+
{
|
|
134
|
+
ref,
|
|
135
|
+
type: "radio",
|
|
136
|
+
className: "sr-only",
|
|
137
|
+
value,
|
|
138
|
+
disabled,
|
|
139
|
+
tabIndex: -1,
|
|
140
|
+
"aria-hidden": true,
|
|
141
|
+
onChange: NOOP,
|
|
142
|
+
...inputProps
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
children != null && /* @__PURE__ */ jsx("span", { className: sizeClasses.label, children })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
var Radio2 = RadioBase;
|
|
152
|
+
|
|
153
|
+
export { Radio2 as Radio, RadioGroup2 as RadioGroup };
|
package/dist/rating.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var tailwindMerge = require('tailwind-merge');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
// src/rating.tsx
|
|
30
|
+
function cn(...inputs) {
|
|
31
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
32
|
+
}
|
|
33
|
+
var StarFilledIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" }) });
|
|
34
|
+
var StarOutlineIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z", strokeWidth: "1.5" }) });
|
|
35
|
+
var Rating = React__namespace.forwardRef(
|
|
36
|
+
function Rating2(props, ref) {
|
|
37
|
+
const { count = 5, label: labelProp, defaultValue = 0, onValueChange, readOnly, className, ...rest } = props;
|
|
38
|
+
const [value, setValue] = React__namespace.useState(defaultValue);
|
|
39
|
+
const [hoveredIndex, setHoveredIndex] = React__namespace.useState(-1);
|
|
40
|
+
const highlightedIndex = hoveredIndex >= 0 && !readOnly ? hoveredIndex + 1 : value;
|
|
41
|
+
const label = Array.isArray(labelProp) ? labelProp[highlightedIndex - 1] : labelProp;
|
|
42
|
+
const handleClick = React__namespace.useCallback((index) => () => {
|
|
43
|
+
if (readOnly) return;
|
|
44
|
+
setValue(index);
|
|
45
|
+
onValueChange?.({ value: index });
|
|
46
|
+
}, [readOnly, onValueChange]);
|
|
47
|
+
const handleMouseEnter = React__namespace.useCallback((index) => () => {
|
|
48
|
+
if (readOnly) return;
|
|
49
|
+
setHoveredIndex(index);
|
|
50
|
+
}, [readOnly]);
|
|
51
|
+
const handleMouseLeave = React__namespace.useCallback(() => {
|
|
52
|
+
setHoveredIndex(-1);
|
|
53
|
+
}, []);
|
|
54
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("inline-flex items-center gap-1", className), ...rest, children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center", onMouseLeave: handleMouseLeave, children: Array.from({ length: count }).map((_, index) => {
|
|
56
|
+
const filled = index < highlightedIndex;
|
|
57
|
+
const starIndex = index + 1;
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
type: "button",
|
|
62
|
+
tabIndex: readOnly ? -1 : 0,
|
|
63
|
+
"aria-label": `Rate ${starIndex} of ${count}`,
|
|
64
|
+
className: cn(
|
|
65
|
+
"inline-flex items-center justify-center w-5 h-5 text-current",
|
|
66
|
+
readOnly ? "cursor-default" : "cursor-pointer"
|
|
67
|
+
),
|
|
68
|
+
onClick: handleClick(starIndex),
|
|
69
|
+
onMouseEnter: handleMouseEnter(index),
|
|
70
|
+
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(StarFilledIcon, { className: "w-5 h-5" }) : /* @__PURE__ */ jsxRuntime.jsx(StarOutlineIcon, { className: "w-5 h-5" })
|
|
71
|
+
},
|
|
72
|
+
index
|
|
73
|
+
);
|
|
74
|
+
}) }),
|
|
75
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: label })
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
exports.Rating = Rating;
|
package/dist/rating.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/rating.tsx
|
|
8
|
+
function cn(...inputs) {
|
|
9
|
+
return twMerge(clsx(inputs));
|
|
10
|
+
}
|
|
11
|
+
var StarFilledIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" }) });
|
|
12
|
+
var StarOutlineIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z", strokeWidth: "1.5" }) });
|
|
13
|
+
var Rating = React.forwardRef(
|
|
14
|
+
function Rating2(props, ref) {
|
|
15
|
+
const { count = 5, label: labelProp, defaultValue = 0, onValueChange, readOnly, className, ...rest } = props;
|
|
16
|
+
const [value, setValue] = React.useState(defaultValue);
|
|
17
|
+
const [hoveredIndex, setHoveredIndex] = React.useState(-1);
|
|
18
|
+
const highlightedIndex = hoveredIndex >= 0 && !readOnly ? hoveredIndex + 1 : value;
|
|
19
|
+
const label = Array.isArray(labelProp) ? labelProp[highlightedIndex - 1] : labelProp;
|
|
20
|
+
const handleClick = React.useCallback((index) => () => {
|
|
21
|
+
if (readOnly) return;
|
|
22
|
+
setValue(index);
|
|
23
|
+
onValueChange?.({ value: index });
|
|
24
|
+
}, [readOnly, onValueChange]);
|
|
25
|
+
const handleMouseEnter = React.useCallback((index) => () => {
|
|
26
|
+
if (readOnly) return;
|
|
27
|
+
setHoveredIndex(index);
|
|
28
|
+
}, [readOnly]);
|
|
29
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
30
|
+
setHoveredIndex(-1);
|
|
31
|
+
}, []);
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("inline-flex items-center gap-1", className), ...rest, children: [
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center", onMouseLeave: handleMouseLeave, children: Array.from({ length: count }).map((_, index) => {
|
|
34
|
+
const filled = index < highlightedIndex;
|
|
35
|
+
const starIndex = index + 1;
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
type: "button",
|
|
40
|
+
tabIndex: readOnly ? -1 : 0,
|
|
41
|
+
"aria-label": `Rate ${starIndex} of ${count}`,
|
|
42
|
+
className: cn(
|
|
43
|
+
"inline-flex items-center justify-center w-5 h-5 text-current",
|
|
44
|
+
readOnly ? "cursor-default" : "cursor-pointer"
|
|
45
|
+
),
|
|
46
|
+
onClick: handleClick(starIndex),
|
|
47
|
+
onMouseEnter: handleMouseEnter(index),
|
|
48
|
+
children: filled ? /* @__PURE__ */ jsx(StarFilledIcon, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(StarOutlineIcon, { className: "w-5 h-5" })
|
|
49
|
+
},
|
|
50
|
+
index
|
|
51
|
+
);
|
|
52
|
+
}) }),
|
|
53
|
+
label && /* @__PURE__ */ jsx("span", { className: "text-sm", children: label })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export { Rating };
|