@luxfi/ui 5.5.3 → 5.6.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.
- 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 +702 -0
- package/dist/collapsible.js +679 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.js +72 -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 +5779 -0
- package/dist/index.js +5619 -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 +630 -0
- package/dist/link.js +606 -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 +62 -0
- package/dist/provider.js +40 -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 +1044 -0
- package/dist/table.js +1013 -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 +270 -65
- 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 +125 -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 +326 -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/commerce/ui/conf.ts +0 -13
- package/commerce/ui/context.tsx +0 -123
- package/commerce/ui/store.ts +0 -295
- package/components/access-code-input.tsx +0 -71
- package/components/analytics.tsx +0 -23
- package/components/auth/auth-listener.tsx +0 -29
- package/components/auth/auth-token/clear-auth-token.tsx +0 -12
- package/components/auth/auth-token/set-auth-token.tsx +0 -16
- package/components/auth/common-auth-domains.ts +0 -17
- package/components/auth/login-panel.tsx +0 -111
- package/components/auth/mobile-login-button.tsx +0 -107
- package/components/auth/signup-panel.tsx +0 -113
- package/components/back-button.tsx +0 -49
- package/components/chat-widget.tsx +0 -85
- package/components/commerce/bag-button.tsx +0 -98
- package/components/commerce/buy-button.tsx +0 -34
- package/components/commerce/checkout-button.tsx +0 -129
- package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
- package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
- package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
- package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
- package/components/commerce/checkout-panel/index.tsx +0 -126
- package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
- package/components/commerce/checkout-panel/policy-links.tsx +0 -29
- package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
- package/components/commerce/checkout-panel/thank-you.tsx +0 -18
- package/components/commerce/desktop-bag-popup.tsx +0 -78
- package/components/commerce/drawer/index.tsx +0 -88
- package/components/commerce/drawer/micro.tsx +0 -145
- package/components/commerce/drawer/shell.tsx +0 -85
- package/components/contact-dialog/contact-form.tsx +0 -116
- package/components/contact-dialog/disclaimer.tsx +0 -13
- package/components/contact-dialog/index.tsx +0 -64
- package/components/copyright.tsx +0 -21
- package/components/drawer-margin.tsx +0 -28
- package/components/footer.tsx +0 -78
- package/components/header/desktop-nav-menu.tsx +0 -204
- package/components/header/desktop.tsx +0 -65
- package/components/header/index.tsx +0 -50
- package/components/header/mobile-bag-drawer.tsx +0 -51
- package/components/header/mobile-menu-toggle-button.tsx +0 -35
- package/components/header/mobile-nav-menu-ai.tsx +0 -51
- package/components/header/mobile-nav-menu-item.tsx +0 -47
- package/components/header/mobile-nav-menu.tsx +0 -102
- package/components/header/mobile.tsx +0 -170
- package/components/header/theme-toggle.tsx +0 -26
- package/components/icons/avatar.tsx +0 -11
- package/components/icons/bag-icon.tsx +0 -10
- package/components/icons/index.ts +0 -6
- package/components/icons/left-arrow.tsx +0 -11
- package/components/icons/lux-logo.tsx +0 -10
- package/components/icons/right-arrow.tsx +0 -10
- package/components/icons/social-icon.tsx +0 -35
- package/components/icons/social-svg.css +0 -3
- package/components/index.ts +0 -26
- package/components/logo.tsx +0 -92
- package/components/main.tsx +0 -27
- package/components/mini-chart/index.tsx +0 -8
- package/components/mini-chart/mini-chart-props.ts +0 -44
- package/components/mini-chart/mini-chart.tsx +0 -85
- package/components/mini-chart/wrapper.tsx +0 -23
- package/components/not-found/index.tsx +0 -28
- package/components/not-found/not-found-content.mdx +0 -5
- package/components/tooltip.tsx +0 -31
- package/environment.d.ts +0 -6
- package/next/analytics/fpixel.ts +0 -16
- package/next/analytics/google-analytics.ts +0 -14
- package/next/analytics/index.ts +0 -3
- package/next/analytics/pixel-analytics.tsx +0 -55
- package/next/font/get-app-router-font-classes.ts +0 -17
- package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
- package/next/font/local/Druk-Wide-Bold.ttf +0 -0
- package/next/font/local/Druk-Wide-Medium.ttf +0 -0
- package/next/font/local/InterVariable-Italic.ttf +0 -0
- package/next/font/local/InterVariable-Italic.woff2 +0 -0
- package/next/font/local/InterVariable.ttf +0 -0
- package/next/font/local/InterVariable.woff2 +0 -0
- package/next/font/next-font-desc.ts +0 -28
- package/next/font/pages-router-font-vars.tsx +0 -18
- package/next/head-metadata/from-next/metadata-types.ts +0 -158
- package/next/head-metadata/from-next/opengraph-types.ts +0 -267
- package/next/head-metadata/from-next/twitter-types.ts +0 -92
- package/next/head-metadata/index.tsx +0 -208
- package/next/index.ts +0 -2
- package/next/middleware/determine-device-mw.ts +0 -29
- package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
- package/root-layout/index.tsx +0 -112
- package/site-def/footer/community.tsx +0 -61
- package/site-def/footer/company.ts +0 -37
- package/site-def/footer/ecosystem.ts +0 -37
- package/site-def/footer/index.tsx +0 -26
- package/site-def/footer/legal.ts +0 -28
- package/site-def/footer/network.ts +0 -45
- package/site-def/footer/svg/warpcast-logo.svg +0 -12
- package/site-def/index.ts +0 -4
- package/site-def/main-nav.tsx +0 -460
- package/style/cart-animation.css +0 -29
- package/style/checkout-animation.css +0 -23
- package/style/drawer-handle-overrides.css +0 -160
- package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
- package/style/fonts/Druk-Wide-Bold.ttf +0 -0
- package/style/fonts/Druk-Wide-Medium.ttf +0 -0
- package/style/fonts/InterVariable-Italic.ttf +0 -0
- package/style/fonts/InterVariable-Italic.woff2 +0 -0
- package/style/fonts/InterVariable.ttf +0 -0
- package/style/fonts/InterVariable.woff2 +0 -0
- package/style/lux-colors.css +0 -85
- package/style/lux-fonts.css +0 -30
- package/style/lux-global-non-next.css +0 -52
- package/style/lux-global.css +0 -51
- package/tailwind/fontFamily.tailwind.lux.ts +0 -18
- package/tailwind/index.ts +0 -2
- package/tailwind/lux-tw-fonts.ts +0 -40
- package/tailwind/tailwind.config.lux-preset.ts +0 -10
- package/tsconfig.json +0 -15
- package/types/chatbot-config.ts +0 -7
- package/types/chatbot-suggested-question.ts +0 -7
- package/types/contact-info.ts +0 -11
- package/types/index.ts +0 -4
- package/types/site-def.ts +0 -46
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,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
|
+
|
|
27
|
+
var ColorModeContext = React__namespace.createContext(void 0);
|
|
28
|
+
function ColorModeProvider(props) {
|
|
29
|
+
const { children, defaultTheme = "light", value: controlledValue, onValueChange } = props;
|
|
30
|
+
const [internalMode, setInternalMode] = React__namespace.useState(() => {
|
|
31
|
+
if (controlledValue === "dark" || controlledValue === "light") {
|
|
32
|
+
return controlledValue;
|
|
33
|
+
}
|
|
34
|
+
if (typeof document !== "undefined") {
|
|
35
|
+
if (document.documentElement.classList.contains("dark")) return "dark";
|
|
36
|
+
}
|
|
37
|
+
return defaultTheme === "dark" ? "dark" : "light";
|
|
38
|
+
});
|
|
39
|
+
const colorMode = controlledValue === "dark" || controlledValue === "light" ? controlledValue : internalMode;
|
|
40
|
+
const setColorMode = React__namespace.useCallback((mode) => {
|
|
41
|
+
const resolved = mode === "dark" ? "dark" : "light";
|
|
42
|
+
setInternalMode(resolved);
|
|
43
|
+
onValueChange?.(resolved);
|
|
44
|
+
if (typeof document !== "undefined") {
|
|
45
|
+
document.documentElement.classList.toggle("dark", resolved === "dark");
|
|
46
|
+
document.documentElement.classList.toggle("light", resolved === "light");
|
|
47
|
+
}
|
|
48
|
+
}, [onValueChange]);
|
|
49
|
+
const toggleColorMode = React__namespace.useCallback(() => {
|
|
50
|
+
setColorMode(colorMode === "dark" ? "light" : "dark");
|
|
51
|
+
}, [colorMode, setColorMode]);
|
|
52
|
+
const ctx = React__namespace.useMemo(
|
|
53
|
+
() => ({ colorMode, setColorMode, toggleColorMode }),
|
|
54
|
+
[colorMode, setColorMode, toggleColorMode]
|
|
55
|
+
);
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ColorModeContext.Provider, { value: ctx, children });
|
|
57
|
+
}
|
|
58
|
+
function Provider(props) {
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ColorModeProvider, { ...props });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.Provider = Provider;
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var ColorModeContext = React.createContext(void 0);
|
|
6
|
+
function ColorModeProvider(props) {
|
|
7
|
+
const { children, defaultTheme = "light", value: controlledValue, onValueChange } = props;
|
|
8
|
+
const [internalMode, setInternalMode] = React.useState(() => {
|
|
9
|
+
if (controlledValue === "dark" || controlledValue === "light") {
|
|
10
|
+
return controlledValue;
|
|
11
|
+
}
|
|
12
|
+
if (typeof document !== "undefined") {
|
|
13
|
+
if (document.documentElement.classList.contains("dark")) return "dark";
|
|
14
|
+
}
|
|
15
|
+
return defaultTheme === "dark" ? "dark" : "light";
|
|
16
|
+
});
|
|
17
|
+
const colorMode = controlledValue === "dark" || controlledValue === "light" ? controlledValue : internalMode;
|
|
18
|
+
const setColorMode = React.useCallback((mode) => {
|
|
19
|
+
const resolved = mode === "dark" ? "dark" : "light";
|
|
20
|
+
setInternalMode(resolved);
|
|
21
|
+
onValueChange?.(resolved);
|
|
22
|
+
if (typeof document !== "undefined") {
|
|
23
|
+
document.documentElement.classList.toggle("dark", resolved === "dark");
|
|
24
|
+
document.documentElement.classList.toggle("light", resolved === "light");
|
|
25
|
+
}
|
|
26
|
+
}, [onValueChange]);
|
|
27
|
+
const toggleColorMode = React.useCallback(() => {
|
|
28
|
+
setColorMode(colorMode === "dark" ? "light" : "dark");
|
|
29
|
+
}, [colorMode, setColorMode]);
|
|
30
|
+
const ctx = React.useMemo(
|
|
31
|
+
() => ({ colorMode, setColorMode, toggleColorMode }),
|
|
32
|
+
[colorMode, setColorMode, toggleColorMode]
|
|
33
|
+
);
|
|
34
|
+
return /* @__PURE__ */ jsx(ColorModeContext.Provider, { value: ctx, children });
|
|
35
|
+
}
|
|
36
|
+
function Provider(props) {
|
|
37
|
+
return /* @__PURE__ */ jsx(ColorModeProvider, { ...props });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
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 };
|