@luxfi/ui 5.6.0 → 6.0.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.
Files changed (125) hide show
  1. package/README.md +109 -0
  2. package/package.json +81 -278
  3. package/dist/accordion.cjs +0 -213
  4. package/dist/accordion.js +0 -186
  5. package/dist/alert.cjs +0 -553
  6. package/dist/alert.js +0 -531
  7. package/dist/avatar.cjs +0 -149
  8. package/dist/avatar.js +0 -125
  9. package/dist/badge.cjs +0 -611
  10. package/dist/badge.js +0 -589
  11. package/dist/button.cjs +0 -689
  12. package/dist/button.js +0 -664
  13. package/dist/checkbox.cjs +0 -265
  14. package/dist/checkbox.js +0 -241
  15. package/dist/close-button.cjs +0 -73
  16. package/dist/close-button.js +0 -51
  17. package/dist/collapsible.cjs +0 -702
  18. package/dist/collapsible.js +0 -679
  19. package/dist/color-mode.cjs +0 -96
  20. package/dist/color-mode.js +0 -72
  21. package/dist/dialog.cjs +0 -279
  22. package/dist/dialog.js +0 -246
  23. package/dist/drawer.cjs +0 -207
  24. package/dist/drawer.js +0 -175
  25. package/dist/empty-state.cjs +0 -93
  26. package/dist/empty-state.js +0 -71
  27. package/dist/field.cjs +0 -183
  28. package/dist/field.js +0 -160
  29. package/dist/heading.cjs +0 -46
  30. package/dist/heading.js +0 -40
  31. package/dist/icon-button.cjs +0 -491
  32. package/dist/icon-button.js +0 -470
  33. package/dist/image.cjs +0 -572
  34. package/dist/image.js +0 -551
  35. package/dist/index.cjs +0 -5779
  36. package/dist/index.js +0 -5619
  37. package/dist/input-group.cjs +0 -155
  38. package/dist/input-group.js +0 -133
  39. package/dist/input.cjs +0 -65
  40. package/dist/input.js +0 -59
  41. package/dist/link.cjs +0 -630
  42. package/dist/link.js +0 -606
  43. package/dist/menu.cjs +0 -305
  44. package/dist/menu.js +0 -269
  45. package/dist/pin-input.cjs +0 -182
  46. package/dist/pin-input.js +0 -160
  47. package/dist/popover.cjs +0 -327
  48. package/dist/popover.js +0 -294
  49. package/dist/progress-circle.cjs +0 -152
  50. package/dist/progress-circle.js +0 -128
  51. package/dist/progress.cjs +0 -117
  52. package/dist/progress.js +0 -94
  53. package/dist/provider.cjs +0 -62
  54. package/dist/provider.js +0 -40
  55. package/dist/radio.cjs +0 -177
  56. package/dist/radio.js +0 -153
  57. package/dist/rating.cjs +0 -80
  58. package/dist/rating.js +0 -58
  59. package/dist/select.cjs +0 -791
  60. package/dist/select.js +0 -757
  61. package/dist/separator.cjs +0 -57
  62. package/dist/separator.js +0 -51
  63. package/dist/skeleton.cjs +0 -370
  64. package/dist/skeleton.js +0 -346
  65. package/dist/slider.cjs +0 -138
  66. package/dist/slider.js +0 -115
  67. package/dist/switch.cjs +0 -163
  68. package/dist/switch.js +0 -140
  69. package/dist/table.cjs +0 -1044
  70. package/dist/table.js +0 -1013
  71. package/dist/tabs.cjs +0 -240
  72. package/dist/tabs.js +0 -213
  73. package/dist/tag.cjs +0 -651
  74. package/dist/tag.js +0 -628
  75. package/dist/textarea.cjs +0 -65
  76. package/dist/textarea.js +0 -59
  77. package/dist/toaster.cjs +0 -99
  78. package/dist/toaster.js +0 -96
  79. package/dist/tooltip.cjs +0 -171
  80. package/dist/tooltip.js +0 -148
  81. package/dist/utils.cjs +0 -11
  82. package/dist/utils.js +0 -9
  83. package/src/accordion.tsx +0 -285
  84. package/src/alert.tsx +0 -221
  85. package/src/avatar.tsx +0 -174
  86. package/src/badge.tsx +0 -158
  87. package/src/button.tsx +0 -411
  88. package/src/checkbox.tsx +0 -307
  89. package/src/close-button.tsx +0 -51
  90. package/src/collapsible.tsx +0 -126
  91. package/src/color-mode.tsx +0 -125
  92. package/src/dialog.tsx +0 -356
  93. package/src/drawer.tsx +0 -186
  94. package/src/empty-state.tsx +0 -97
  95. package/src/field.tsx +0 -202
  96. package/src/heading.tsx +0 -55
  97. package/src/icon-button.tsx +0 -192
  98. package/src/image.tsx +0 -280
  99. package/src/index.ts +0 -192
  100. package/src/input-group.tsx +0 -159
  101. package/src/input.tsx +0 -60
  102. package/src/link.tsx +0 -326
  103. package/src/menu.tsx +0 -471
  104. package/src/pin-input.tsx +0 -187
  105. package/src/popover.tsx +0 -400
  106. package/src/progress-circle.tsx +0 -180
  107. package/src/progress.tsx +0 -109
  108. package/src/provider.tsx +0 -12
  109. package/src/radio.tsx +0 -175
  110. package/src/rating.tsx +0 -79
  111. package/src/select.tsx +0 -696
  112. package/src/separator.tsx +0 -59
  113. package/src/skeleton.tsx +0 -302
  114. package/src/slider.tsx +0 -152
  115. package/src/switch.tsx +0 -158
  116. package/src/table.tsx +0 -621
  117. package/src/tabs.tsx +0 -354
  118. package/src/tag.tsx +0 -159
  119. package/src/textarea.tsx +0 -60
  120. package/src/toaster.tsx +0 -117
  121. package/src/tokens.css +0 -438
  122. package/src/tooltip.tsx +0 -184
  123. package/src/utils/cn.ts +0 -7
  124. package/src/utils.ts +0 -6
  125. package/tokens.css +0 -438
package/dist/progress.js DELETED
@@ -1,94 +0,0 @@
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 };
package/dist/provider.cjs DELETED
@@ -1,62 +0,0 @@
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 DELETED
@@ -1,40 +0,0 @@
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 DELETED
@@ -1,177 +0,0 @@
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 DELETED
@@ -1,153 +0,0 @@
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 DELETED
@@ -1,80 +0,0 @@
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 DELETED
@@ -1,58 +0,0 @@
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 };