@spark-ui/components 10.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.
- package/CHANGELOG.md +15 -0
- package/LICENSE.md +21 -0
- package/README.md +19 -0
- package/dist/DialogTrigger-5SI4dvpK.d.mts +142 -0
- package/dist/DialogTrigger-5SI4dvpK.d.ts +142 -0
- package/dist/Input-g0LpWuv0.d.mts +17 -0
- package/dist/Input-g0LpWuv0.d.ts +17 -0
- package/dist/InputGroup-aoaZxCLk.d.mts +28 -0
- package/dist/InputGroup-aoaZxCLk.d.ts +28 -0
- package/dist/InputTrailingIcon-BBp7sE6D.d.mts +20 -0
- package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +20 -0
- package/dist/LabelRequiredIndicator-DRnCzHMU.d.mts +19 -0
- package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +19 -0
- package/dist/accordion/index.d.mts +85 -0
- package/dist/accordion/index.d.ts +85 -0
- package/dist/accordion/index.js +461 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/accordion/index.mjs +249 -0
- package/dist/accordion/index.mjs.map +1 -0
- package/dist/alert-dialog/index.d.mts +119 -0
- package/dist/alert-dialog/index.d.ts +119 -0
- package/dist/alert-dialog/index.js +1451 -0
- package/dist/alert-dialog/index.js.map +1 -0
- package/dist/alert-dialog/index.mjs +177 -0
- package/dist/alert-dialog/index.mjs.map +1 -0
- package/dist/badge/index.d.mts +47 -0
- package/dist/badge/index.d.ts +47 -0
- package/dist/badge/index.js +122 -0
- package/dist/badge/index.js.map +1 -0
- package/dist/badge/index.mjs +95 -0
- package/dist/badge/index.mjs.map +1 -0
- package/dist/breadcrumb/index.d.mts +64 -0
- package/dist/breadcrumb/index.d.ts +64 -0
- package/dist/breadcrumb/index.js +326 -0
- package/dist/breadcrumb/index.js.map +1 -0
- package/dist/breadcrumb/index.mjs +149 -0
- package/dist/breadcrumb/index.mjs.map +1 -0
- package/dist/button/index.d.mts +40 -0
- package/dist/button/index.d.ts +40 -0
- package/dist/button/index.js +877 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button/index.mjs +10 -0
- package/dist/button/index.mjs.map +1 -0
- package/dist/carousel/index.d.mts +253 -0
- package/dist/carousel/index.d.ts +253 -0
- package/dist/carousel/index.js +1678 -0
- package/dist/carousel/index.js.map +1 -0
- package/dist/carousel/index.mjs +716 -0
- package/dist/carousel/index.mjs.map +1 -0
- package/dist/checkbox/index.d.mts +120 -0
- package/dist/checkbox/index.d.ts +120 -0
- package/dist/checkbox/index.js +873 -0
- package/dist/checkbox/index.js.map +1 -0
- package/dist/checkbox/index.mjs +349 -0
- package/dist/checkbox/index.mjs.map +1 -0
- package/dist/chip/index.d.mts +97 -0
- package/dist/chip/index.d.ts +97 -0
- package/dist/chip/index.js +905 -0
- package/dist/chip/index.js.map +1 -0
- package/dist/chip/index.mjs +793 -0
- package/dist/chip/index.mjs.map +1 -0
- package/dist/chunk-2KPFQEAA.mjs +52 -0
- package/dist/chunk-2KPFQEAA.mjs.map +1 -0
- package/dist/chunk-4F5DOL57.mjs +26 -0
- package/dist/chunk-4F5DOL57.mjs.map +1 -0
- package/dist/chunk-6JOA37TZ.mjs +742 -0
- package/dist/chunk-6JOA37TZ.mjs.map +1 -0
- package/dist/chunk-7PMPYEHJ.mjs +379 -0
- package/dist/chunk-7PMPYEHJ.mjs.map +1 -0
- package/dist/chunk-AESXFMCC.mjs +68 -0
- package/dist/chunk-AESXFMCC.mjs.map +1 -0
- package/dist/chunk-B42LOFIZ.mjs +308 -0
- package/dist/chunk-B42LOFIZ.mjs.map +1 -0
- package/dist/chunk-FGOZHKBT.mjs +97 -0
- package/dist/chunk-FGOZHKBT.mjs.map +1 -0
- package/dist/chunk-HLXYG643.mjs +52 -0
- package/dist/chunk-HLXYG643.mjs.map +1 -0
- package/dist/chunk-JKNBJHD5.mjs +601 -0
- package/dist/chunk-JKNBJHD5.mjs.map +1 -0
- package/dist/chunk-K7VP7DH3.mjs +66 -0
- package/dist/chunk-K7VP7DH3.mjs.map +1 -0
- package/dist/chunk-MUNDKRAE.mjs +80 -0
- package/dist/chunk-MUNDKRAE.mjs.map +1 -0
- package/dist/chunk-NBZKMCHF.mjs +36 -0
- package/dist/chunk-NBZKMCHF.mjs.map +1 -0
- package/dist/chunk-PZWESKAR.mjs +314 -0
- package/dist/chunk-PZWESKAR.mjs.map +1 -0
- package/dist/collapsible/index.d.mts +60 -0
- package/dist/collapsible/index.d.ts +60 -0
- package/dist/collapsible/index.js +140 -0
- package/dist/collapsible/index.js.map +1 -0
- package/dist/collapsible/index.mjs +8 -0
- package/dist/collapsible/index.mjs.map +1 -0
- package/dist/combobox/index.d.mts +285 -0
- package/dist/combobox/index.d.ts +285 -0
- package/dist/combobox/index.js +2920 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/combobox/index.mjs +1267 -0
- package/dist/combobox/index.mjs.map +1 -0
- package/dist/dialog/index.d.mts +33 -0
- package/dist/dialog/index.d.ts +33 -0
- package/dist/dialog/index.js +1286 -0
- package/dist/dialog/index.js.map +1 -0
- package/dist/dialog/index.mjs +13 -0
- package/dist/dialog/index.mjs.map +1 -0
- package/dist/divider/index.d.mts +61 -0
- package/dist/divider/index.d.ts +61 -0
- package/dist/divider/index.js +223 -0
- package/dist/divider/index.js.map +1 -0
- package/dist/divider/index.mjs +196 -0
- package/dist/divider/index.mjs.map +1 -0
- package/dist/drawer/index.d.mts +148 -0
- package/dist/drawer/index.d.ts +148 -0
- package/dist/drawer/index.js +1266 -0
- package/dist/drawer/index.js.map +1 -0
- package/dist/drawer/index.mjs +299 -0
- package/dist/drawer/index.mjs.map +1 -0
- package/dist/dropdown/index.d.mts +233 -0
- package/dist/dropdown/index.d.ts +233 -0
- package/dist/dropdown/index.js +2402 -0
- package/dist/dropdown/index.js.map +1 -0
- package/dist/dropdown/index.mjs +741 -0
- package/dist/dropdown/index.mjs.map +1 -0
- package/dist/form-field/index.d.mts +176 -0
- package/dist/form-field/index.d.ts +176 -0
- package/dist/form-field/index.js +540 -0
- package/dist/form-field/index.js.map +1 -0
- package/dist/form-field/index.mjs +13 -0
- package/dist/form-field/index.mjs.map +1 -0
- package/dist/icon/index.d.mts +28 -0
- package/dist/icon/index.d.ts +28 -0
- package/dist/icon/index.js +127 -0
- package/dist/icon/index.js.map +1 -0
- package/dist/icon/index.mjs +9 -0
- package/dist/icon/index.mjs.map +1 -0
- package/dist/icon-button/index.d.mts +16 -0
- package/dist/icon-button/index.d.ts +16 -0
- package/dist/icon-button/index.js +921 -0
- package/dist/icon-button/index.js.map +1 -0
- package/dist/icon-button/index.mjs +11 -0
- package/dist/icon-button/index.mjs.map +1 -0
- package/dist/input/index.d.mts +78 -0
- package/dist/input/index.d.ts +78 -0
- package/dist/input/index.js +1119 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/index.mjs +16 -0
- package/dist/input/index.mjs.map +1 -0
- package/dist/kbd/index.d.mts +9 -0
- package/dist/kbd/index.d.ts +9 -0
- package/dist/kbd/index.js +46 -0
- package/dist/kbd/index.js.map +1 -0
- package/dist/kbd/index.mjs +19 -0
- package/dist/kbd/index.mjs.map +1 -0
- package/dist/label/index.d.mts +11 -0
- package/dist/label/index.d.ts +11 -0
- package/dist/label/index.js +78 -0
- package/dist/label/index.js.map +1 -0
- package/dist/label/index.mjs +7 -0
- package/dist/label/index.mjs.map +1 -0
- package/dist/link-box/index.d.mts +34 -0
- package/dist/link-box/index.d.ts +34 -0
- package/dist/link-box/index.js +92 -0
- package/dist/link-box/index.js.map +1 -0
- package/dist/link-box/index.mjs +58 -0
- package/dist/link-box/index.mjs.map +1 -0
- package/dist/pagination/index.d.mts +143 -0
- package/dist/pagination/index.d.ts +143 -0
- package/dist/pagination/index.js +1303 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/index.mjs +326 -0
- package/dist/pagination/index.mjs.map +1 -0
- package/dist/popover/index.d.mts +93 -0
- package/dist/popover/index.d.ts +93 -0
- package/dist/popover/index.js +1280 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/popover/index.mjs +13 -0
- package/dist/popover/index.mjs.map +1 -0
- package/dist/portal/index.d.mts +13 -0
- package/dist/portal/index.d.ts +13 -0
- package/dist/portal/index.js +37 -0
- package/dist/portal/index.js.map +1 -0
- package/dist/portal/index.mjs +10 -0
- package/dist/portal/index.mjs.map +1 -0
- package/dist/progress/index.d.mts +48 -0
- package/dist/progress/index.d.ts +48 -0
- package/dist/progress/index.js +201 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/index.mjs +174 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress-tracker/index.d.mts +81 -0
- package/dist/progress-tracker/index.d.ts +81 -0
- package/dist/progress-tracker/index.js +834 -0
- package/dist/progress-tracker/index.js.map +1 -0
- package/dist/progress-tracker/index.mjs +716 -0
- package/dist/progress-tracker/index.mjs.map +1 -0
- package/dist/radio-group/index.d.mts +100 -0
- package/dist/radio-group/index.d.ts +100 -0
- package/dist/radio-group/index.js +824 -0
- package/dist/radio-group/index.js.map +1 -0
- package/dist/radio-group/index.mjs +297 -0
- package/dist/radio-group/index.mjs.map +1 -0
- package/dist/rating/index.d.mts +78 -0
- package/dist/rating/index.d.ts +78 -0
- package/dist/rating/index.js +362 -0
- package/dist/rating/index.js.map +1 -0
- package/dist/rating/index.mjs +247 -0
- package/dist/rating/index.mjs.map +1 -0
- package/dist/scrolling-list/index.d.mts +105 -0
- package/dist/scrolling-list/index.d.ts +105 -0
- package/dist/scrolling-list/index.js +1367 -0
- package/dist/scrolling-list/index.js.map +1 -0
- package/dist/scrolling-list/index.mjs +407 -0
- package/dist/scrolling-list/index.mjs.map +1 -0
- package/dist/select/index.d.mts +167 -0
- package/dist/select/index.d.ts +167 -0
- package/dist/select/index.js +991 -0
- package/dist/select/index.js.map +1 -0
- package/dist/select/index.mjs +470 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/skeleton/index.d.mts +67 -0
- package/dist/skeleton/index.d.ts +67 -0
- package/dist/skeleton/index.js +206 -0
- package/dist/skeleton/index.js.map +1 -0
- package/dist/skeleton/index.mjs +147 -0
- package/dist/skeleton/index.mjs.map +1 -0
- package/dist/slider/index.d.mts +97 -0
- package/dist/slider/index.d.ts +97 -0
- package/dist/slider/index.js +209 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/slider/index.mjs +182 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slot/index.d.mts +17 -0
- package/dist/slot/index.d.ts +17 -0
- package/dist/slot/index.js +51 -0
- package/dist/slot/index.js.map +1 -0
- package/dist/slot/index.mjs +11 -0
- package/dist/slot/index.mjs.map +1 -0
- package/dist/snackbar/index.d.mts +158 -0
- package/dist/snackbar/index.d.ts +158 -0
- package/dist/snackbar/index.js +1693 -0
- package/dist/snackbar/index.js.map +1 -0
- package/dist/snackbar/index.mjs +733 -0
- package/dist/snackbar/index.mjs.map +1 -0
- package/dist/spinner/index.d.mts +21 -0
- package/dist/spinner/index.d.ts +21 -0
- package/dist/spinner/index.js +139 -0
- package/dist/spinner/index.js.map +1 -0
- package/dist/spinner/index.mjs +9 -0
- package/dist/spinner/index.mjs.map +1 -0
- package/dist/stepper/index.d.mts +82 -0
- package/dist/stepper/index.d.ts +82 -0
- package/dist/stepper/index.js +2178 -0
- package/dist/stepper/index.js.map +1 -0
- package/dist/stepper/index.mjs +229 -0
- package/dist/stepper/index.mjs.map +1 -0
- package/dist/switch/index.d.mts +64 -0
- package/dist/switch/index.d.ts +64 -0
- package/dist/switch/index.js +768 -0
- package/dist/switch/index.js.map +1 -0
- package/dist/switch/index.mjs +245 -0
- package/dist/switch/index.mjs.map +1 -0
- package/dist/tabs/index.d.mts +103 -0
- package/dist/tabs/index.d.ts +103 -0
- package/dist/tabs/index.js +1315 -0
- package/dist/tabs/index.js.map +1 -0
- package/dist/tabs/index.mjs +391 -0
- package/dist/tabs/index.mjs.map +1 -0
- package/dist/tag/index.d.mts +27 -0
- package/dist/tag/index.d.ts +27 -0
- package/dist/tag/index.js +269 -0
- package/dist/tag/index.js.map +1 -0
- package/dist/tag/index.mjs +237 -0
- package/dist/tag/index.mjs.map +1 -0
- package/dist/text-link/index.d.mts +20 -0
- package/dist/text-link/index.d.ts +20 -0
- package/dist/text-link/index.js +99 -0
- package/dist/text-link/index.js.map +1 -0
- package/dist/text-link/index.mjs +8 -0
- package/dist/text-link/index.mjs.map +1 -0
- package/dist/textarea/index.d.mts +47 -0
- package/dist/textarea/index.d.ts +47 -0
- package/dist/textarea/index.js +1180 -0
- package/dist/textarea/index.js.map +1 -0
- package/dist/textarea/index.mjs +77 -0
- package/dist/textarea/index.mjs.map +1 -0
- package/dist/visually-hidden/index.d.mts +16 -0
- package/dist/visually-hidden/index.d.ts +16 -0
- package/dist/visually-hidden/index.js +67 -0
- package/dist/visually-hidden/index.js.map +1 -0
- package/dist/visually-hidden/index.mjs +8 -0
- package/dist/visually-hidden/index.mjs.map +1 -0
- package/global.d.ts +12 -0
- package/package.json +75 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +11 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/rating/index.ts
|
|
21
|
+
var rating_exports = {};
|
|
22
|
+
__export(rating_exports, {
|
|
23
|
+
Rating: () => Rating
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(rating_exports);
|
|
26
|
+
|
|
27
|
+
// src/rating/Rating.tsx
|
|
28
|
+
var import_use_combined_state = require("@spark-ui/use-combined-state");
|
|
29
|
+
var import_class_variance_authority4 = require("class-variance-authority");
|
|
30
|
+
var import_react3 = require("react");
|
|
31
|
+
|
|
32
|
+
// src/rating/RatingStar.tsx
|
|
33
|
+
var import_StarFill = require("@spark-ui/icons/StarFill");
|
|
34
|
+
var import_StarOutline = require("@spark-ui/icons/StarOutline");
|
|
35
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
36
|
+
|
|
37
|
+
// src/icon/Icon.tsx
|
|
38
|
+
var import_react2 = require("react");
|
|
39
|
+
|
|
40
|
+
// src/slot/Slot.tsx
|
|
41
|
+
var import_radix_ui = require("radix-ui");
|
|
42
|
+
var import_react = require("react");
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var Slottable = import_radix_ui.Slot.Slottable;
|
|
45
|
+
var Slot = ({ ref, ...props }) => {
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/visually-hidden/VisuallyHidden.tsx
|
|
50
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
51
|
+
var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
|
|
52
|
+
const Component = asChild ? Slot : "span";
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
54
|
+
Component,
|
|
55
|
+
{
|
|
56
|
+
...props,
|
|
57
|
+
ref,
|
|
58
|
+
style: {
|
|
59
|
+
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
60
|
+
position: "absolute",
|
|
61
|
+
border: 0,
|
|
62
|
+
width: 1,
|
|
63
|
+
height: 1,
|
|
64
|
+
padding: 0,
|
|
65
|
+
margin: -1,
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
clip: "rect(0, 0, 0, 0)",
|
|
68
|
+
whiteSpace: "nowrap",
|
|
69
|
+
wordWrap: "normal",
|
|
70
|
+
...props.style
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
VisuallyHidden.displayName = "VisuallyHidden";
|
|
76
|
+
|
|
77
|
+
// src/icon/Icon.styles.tsx
|
|
78
|
+
var import_internal_utils = require("@spark-ui/internal-utils");
|
|
79
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
80
|
+
var iconStyles = (0, import_class_variance_authority.cva)(["fill-current shrink-0"], {
|
|
81
|
+
variants: {
|
|
82
|
+
/**
|
|
83
|
+
* Color scheme of the icon.
|
|
84
|
+
*/
|
|
85
|
+
intent: (0, import_internal_utils.makeVariants)({
|
|
86
|
+
current: ["text-current"],
|
|
87
|
+
main: ["text-main"],
|
|
88
|
+
support: ["text-support"],
|
|
89
|
+
accent: ["text-accent"],
|
|
90
|
+
basic: ["text-basic"],
|
|
91
|
+
success: ["text-success"],
|
|
92
|
+
alert: ["text-alert"],
|
|
93
|
+
error: ["text-error"],
|
|
94
|
+
info: ["text-info"],
|
|
95
|
+
neutral: ["text-neutral"]
|
|
96
|
+
}),
|
|
97
|
+
/**
|
|
98
|
+
* Sets the size of the icon.
|
|
99
|
+
*/
|
|
100
|
+
size: (0, import_internal_utils.makeVariants)({
|
|
101
|
+
current: ["u-current-font-size"],
|
|
102
|
+
sm: ["w-sz-16", "h-sz-16"],
|
|
103
|
+
md: ["w-sz-24", "h-sz-24"],
|
|
104
|
+
lg: ["w-sz-32", "h-sz-32"],
|
|
105
|
+
xl: ["w-sz-40", "h-sz-40"]
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// src/icon/Icon.tsx
|
|
111
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
112
|
+
var Icon = ({
|
|
113
|
+
label,
|
|
114
|
+
className,
|
|
115
|
+
size = "current",
|
|
116
|
+
intent = "current",
|
|
117
|
+
children,
|
|
118
|
+
...others
|
|
119
|
+
}) => {
|
|
120
|
+
const child = import_react2.Children.only(children);
|
|
121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
122
|
+
(0, import_react2.cloneElement)(child, {
|
|
123
|
+
className: iconStyles({ className, size, intent }),
|
|
124
|
+
"data-spark-component": "icon",
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
focusable: "false",
|
|
127
|
+
...others
|
|
128
|
+
}),
|
|
129
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VisuallyHidden, { children: label })
|
|
130
|
+
] });
|
|
131
|
+
};
|
|
132
|
+
Icon.displayName = "Icon";
|
|
133
|
+
|
|
134
|
+
// src/rating/RatingStar.styles.ts
|
|
135
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
136
|
+
var emptyRemainingStarsOnHoverClass = (0, import_class_variance_authority2.cx)("[&_>_div]:peer-hover:w-0!");
|
|
137
|
+
var ratingStarStyles = (0, import_class_variance_authority2.cva)(
|
|
138
|
+
["peer", "after:inset-0", "group", "relative", "after:block after:absolute"],
|
|
139
|
+
{
|
|
140
|
+
variants: {
|
|
141
|
+
disabled: {
|
|
142
|
+
true: "opacity-dim-3",
|
|
143
|
+
false: ""
|
|
144
|
+
},
|
|
145
|
+
readOnly: {
|
|
146
|
+
true: "",
|
|
147
|
+
false: ""
|
|
148
|
+
},
|
|
149
|
+
gap: {
|
|
150
|
+
sm: ["after:w-[calc(100%+(var(--spacing-sm)))]", "last-of-type:after:content-none"],
|
|
151
|
+
md: ["after:w-[calc(100%+(var(--spacing-md)))]", "last-of-type:after:content-none"]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
compoundVariants: [
|
|
155
|
+
{
|
|
156
|
+
readOnly: false,
|
|
157
|
+
disabled: false,
|
|
158
|
+
className: (0, import_class_variance_authority2.cx)(emptyRemainingStarsOnHoverClass, "cursor-pointer")
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
defaultVariants: {
|
|
162
|
+
disabled: false,
|
|
163
|
+
readOnly: false,
|
|
164
|
+
gap: "sm"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
var ratingStarIconStyles = (0, import_class_variance_authority2.cva)("", {
|
|
169
|
+
variants: {
|
|
170
|
+
size: {
|
|
171
|
+
sm: "text-caption-link",
|
|
172
|
+
md: "text-body-1",
|
|
173
|
+
lg: "text-display-1"
|
|
174
|
+
},
|
|
175
|
+
design: {
|
|
176
|
+
filled: [
|
|
177
|
+
"text-main-variant",
|
|
178
|
+
"group-[[data-part=star][data-hovered]]:text-main-variant-hovered"
|
|
179
|
+
],
|
|
180
|
+
outlined: ["text-on-surface/dim-3"]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/rating/RatingStar.tsx
|
|
186
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
187
|
+
var RatingStar = ({
|
|
188
|
+
value,
|
|
189
|
+
size,
|
|
190
|
+
disabled,
|
|
191
|
+
readOnly,
|
|
192
|
+
onClick,
|
|
193
|
+
onMouseEnter,
|
|
194
|
+
ref: forwardedRef
|
|
195
|
+
}) => {
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
ref: forwardedRef,
|
|
200
|
+
onMouseEnter,
|
|
201
|
+
className: ratingStarStyles({
|
|
202
|
+
gap: size === "lg" ? "md" : "sm",
|
|
203
|
+
disabled,
|
|
204
|
+
readOnly
|
|
205
|
+
}),
|
|
206
|
+
"data-part": "star",
|
|
207
|
+
onClick,
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
className: (0, import_class_variance_authority3.cx)(
|
|
213
|
+
"z-raised absolute overflow-hidden",
|
|
214
|
+
"group-[[data-part=star][data-hovered]]:overflow-visible"
|
|
215
|
+
),
|
|
216
|
+
style: { width: value * 100 + "%" },
|
|
217
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
218
|
+
Icon,
|
|
219
|
+
{
|
|
220
|
+
className: ratingStarIconStyles({
|
|
221
|
+
size,
|
|
222
|
+
design: "filled"
|
|
223
|
+
}),
|
|
224
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_StarFill.StarFill, {})
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { className: ratingStarIconStyles({ size, design: "outlined" }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_StarOutline.StarOutline, {}) })
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/rating/utils.ts
|
|
236
|
+
function getNearestHalfDecimal(num) {
|
|
237
|
+
return Math.round(num / 0.5) * 0.5;
|
|
238
|
+
}
|
|
239
|
+
function getStarValue({ value, index }) {
|
|
240
|
+
if (value === void 0) return 0;
|
|
241
|
+
const starPosition = index + 1;
|
|
242
|
+
const formattedValue = getNearestHalfDecimal(value);
|
|
243
|
+
if (Math.ceil(formattedValue) < starPosition) return 0;
|
|
244
|
+
return formattedValue >= starPosition ? 1 : 0.5;
|
|
245
|
+
}
|
|
246
|
+
function splitAt(arr, index) {
|
|
247
|
+
const prev = arr.slice(0, index);
|
|
248
|
+
const next = arr.slice(index);
|
|
249
|
+
return [prev, next];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/rating/Rating.tsx
|
|
253
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
254
|
+
var Rating = ({
|
|
255
|
+
defaultValue,
|
|
256
|
+
value: propValue,
|
|
257
|
+
onValueChange,
|
|
258
|
+
size = "md",
|
|
259
|
+
disabled,
|
|
260
|
+
readOnly,
|
|
261
|
+
name,
|
|
262
|
+
id,
|
|
263
|
+
"aria-label": ariaLabel,
|
|
264
|
+
ref,
|
|
265
|
+
...rest
|
|
266
|
+
}) => {
|
|
267
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
268
|
+
const starRefList = (0, import_react3.useRef)([]);
|
|
269
|
+
const [value, setRatingValue] = (0, import_use_combined_state.useCombinedState)(propValue, defaultValue, onValueChange);
|
|
270
|
+
const valueRef = (0, import_react3.useRef)(value);
|
|
271
|
+
const isInteractive = !(disabled || readOnly);
|
|
272
|
+
function onStarClick(index) {
|
|
273
|
+
if (!inputRef.current) return;
|
|
274
|
+
setRatingValue(index + 1);
|
|
275
|
+
valueRef.current = index + 1;
|
|
276
|
+
inputRef.current.focus();
|
|
277
|
+
inputRef.current.setAttribute("data-clicked", "");
|
|
278
|
+
}
|
|
279
|
+
function onInputChange(event) {
|
|
280
|
+
if (valueRef.current === Number(event.target.value) || Number(event.target.value) === 0) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
valueRef.current = Number(event.target.value);
|
|
284
|
+
setRatingValue(Number(event.target.value));
|
|
285
|
+
}
|
|
286
|
+
function onStarMouseEnter({ currentTarget }) {
|
|
287
|
+
const currentStarIndex = starRefList.current.findIndex((star) => star === currentTarget);
|
|
288
|
+
const [previousStars, followingStars] = splitAt(starRefList.current, currentStarIndex + 1);
|
|
289
|
+
previousStars.forEach((star) => star.setAttribute("data-hovered", ""));
|
|
290
|
+
followingStars.forEach((star) => star.removeAttribute("data-hovered"));
|
|
291
|
+
}
|
|
292
|
+
const handleStarRef = (0, import_react3.useCallback)((elm) => {
|
|
293
|
+
if (!elm) return;
|
|
294
|
+
starRefList.current.push(elm);
|
|
295
|
+
}, []);
|
|
296
|
+
function resetDataPartInputAttr() {
|
|
297
|
+
inputRef.current?.removeAttribute("data-clicked");
|
|
298
|
+
}
|
|
299
|
+
function resetDataPartStarAttr() {
|
|
300
|
+
starRefList.current.forEach((star) => star.removeAttribute("data-hovered"));
|
|
301
|
+
}
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
303
|
+
"div",
|
|
304
|
+
{
|
|
305
|
+
className: "relative inline-flex",
|
|
306
|
+
ref,
|
|
307
|
+
"data-spark-component": "rating",
|
|
308
|
+
...rest,
|
|
309
|
+
onMouseLeave: resetDataPartStarAttr,
|
|
310
|
+
children: [
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
312
|
+
"input",
|
|
313
|
+
{
|
|
314
|
+
name,
|
|
315
|
+
id,
|
|
316
|
+
"aria-label": ariaLabel,
|
|
317
|
+
ref: inputRef,
|
|
318
|
+
"data-part": "input",
|
|
319
|
+
className: "peer absolute inset-0 opacity-0",
|
|
320
|
+
type: "range",
|
|
321
|
+
min: "0",
|
|
322
|
+
max: "5",
|
|
323
|
+
step: readOnly ? 0.5 : 1,
|
|
324
|
+
disabled,
|
|
325
|
+
readOnly,
|
|
326
|
+
value: getNearestHalfDecimal(value ?? 0),
|
|
327
|
+
onChange: (event) => isInteractive && onInputChange(event),
|
|
328
|
+
onBlur: resetDataPartInputAttr
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
className: (0, import_class_variance_authority4.cx)(
|
|
335
|
+
size === "lg" ? "gap-x-md" : "gap-x-sm",
|
|
336
|
+
"flex",
|
|
337
|
+
"peer-focus-visible:u-outline peer-[[data-part=input][data-clicked]]:shadow-none"
|
|
338
|
+
),
|
|
339
|
+
children: Array.from({ length: 5 }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
340
|
+
RatingStar,
|
|
341
|
+
{
|
|
342
|
+
disabled,
|
|
343
|
+
readOnly,
|
|
344
|
+
size,
|
|
345
|
+
onClick: () => isInteractive && onStarClick(index),
|
|
346
|
+
onMouseEnter: (event) => isInteractive && onStarMouseEnter(event),
|
|
347
|
+
ref: handleStarRef,
|
|
348
|
+
value: getStarValue({ index, value })
|
|
349
|
+
},
|
|
350
|
+
index
|
|
351
|
+
))
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
};
|
|
358
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
359
|
+
0 && (module.exports = {
|
|
360
|
+
Rating
|
|
361
|
+
});
|
|
362
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/rating/index.ts","../../src/rating/Rating.tsx","../../src/rating/RatingStar.tsx","../../src/icon/Icon.tsx","../../src/slot/Slot.tsx","../../src/visually-hidden/VisuallyHidden.tsx","../../src/icon/Icon.styles.tsx","../../src/rating/RatingStar.styles.ts","../../src/rating/utils.ts"],"sourcesContent":["export { Rating, type RatingProps } from './Rating'\n","import { useCombinedState } from '@spark-ui/use-combined-state'\nimport { cx } from 'class-variance-authority'\nimport {\n type ChangeEvent,\n type ComponentPropsWithRef,\n type MouseEvent,\n type PropsWithChildren,\n useCallback,\n useRef,\n} from 'react'\n\nimport { RatingStar, type RatingStarProps } from './RatingStar'\nimport { getNearestHalfDecimal, getStarValue, splitAt } from './utils'\n\nexport interface RatingProps extends PropsWithChildren<ComponentPropsWithRef<'div'>> {\n /**\n * Use the `defaultValue` prop to set the default value of the input, on a from 0 to 5.\n *\n * Use this when you want to use it in an uncontrolled manner\n */\n defaultValue?: number\n /**\n * The value is the number of the rating selected, on a scale from 0 to 5.\n *\n * Use this when you want to use it in a controlled manner,\n * in conjunction with the `onValueChange` prop\n */\n value?: number\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: number) => void\n /**\n * Sets the component as interactive or not.\n * @default undefined\n */\n readOnly?: boolean\n /**\n * When `true`, prevents the user from interacting.\n * @default false\n */\n disabled?: boolean\n /**\n * Sets the size of the stars.\n * @default 'md'\n */\n size?: RatingStarProps['size']\n /**\n * Name of the underlying input.\n * @default undefined\n */\n name?: string\n /**\n * id of the underlying input.\n * @default undefined\n */\n id?: string\n /**\n * aria-label of the underlying input.\n * @default undefined\n */\n 'aria-label': string\n}\n\nexport const Rating = ({\n defaultValue,\n value: propValue,\n onValueChange,\n size = 'md',\n disabled,\n readOnly,\n name,\n id,\n 'aria-label': ariaLabel,\n ref,\n ...rest\n}: RatingProps) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const starRefList = useRef<HTMLDivElement[]>([])\n\n const [value, setRatingValue] = useCombinedState(propValue, defaultValue, onValueChange)\n\n const valueRef = useRef(value)\n const isInteractive = !(disabled || readOnly)\n\n function onStarClick(index: number) {\n if (!inputRef.current) return\n\n setRatingValue(index + 1)\n valueRef.current = index + 1\n\n inputRef.current.focus()\n inputRef.current.setAttribute('data-clicked', '')\n }\n\n function onInputChange(event: ChangeEvent<HTMLInputElement>) {\n // 1. Avoiding unnecessary calls to onValueChange prop if value doesn't change\n // 2. Preventing value to be resetted to 0\n if (valueRef.current === Number(event.target.value) || Number(event.target.value) === 0) {\n return\n }\n valueRef.current = Number(event.target.value)\n\n setRatingValue(Number(event.target.value))\n }\n\n function onStarMouseEnter({ currentTarget }: MouseEvent<HTMLDivElement>) {\n const currentStarIndex = starRefList.current.findIndex(star => star === currentTarget)\n\n const [previousStars, followingStars] = splitAt(starRefList.current, currentStarIndex + 1)\n\n previousStars.forEach(star => star.setAttribute('data-hovered', ''))\n followingStars.forEach(star => star.removeAttribute('data-hovered'))\n }\n\n const handleStarRef = useCallback((elm: HTMLDivElement | null) => {\n if (!elm) return\n starRefList.current.push(elm)\n }, [])\n\n function resetDataPartInputAttr() {\n inputRef.current?.removeAttribute('data-clicked')\n }\n\n function resetDataPartStarAttr() {\n starRefList.current.forEach(star => star.removeAttribute('data-hovered'))\n }\n\n return (\n <div\n className=\"relative inline-flex\"\n ref={ref}\n data-spark-component=\"rating\"\n {...rest}\n onMouseLeave={resetDataPartStarAttr}\n >\n <input\n name={name}\n id={id}\n aria-label={ariaLabel}\n ref={inputRef}\n data-part=\"input\"\n className=\"peer absolute inset-0 opacity-0\"\n type=\"range\"\n min=\"0\"\n max=\"5\"\n step={readOnly ? 0.5 : 1}\n disabled={disabled}\n readOnly={readOnly}\n value={getNearestHalfDecimal(value ?? 0)}\n onChange={event => isInteractive && onInputChange(event)}\n onBlur={resetDataPartInputAttr}\n />\n <div\n className={cx(\n size === 'lg' ? 'gap-x-md' : 'gap-x-sm',\n 'flex',\n 'peer-focus-visible:u-outline peer-[[data-part=input][data-clicked]]:shadow-none'\n )}\n >\n {Array.from({ length: 5 }).map((_, index) => (\n <RatingStar\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n onClick={() => isInteractive && onStarClick(index)}\n onMouseEnter={event => isInteractive && onStarMouseEnter(event)}\n ref={handleStarRef}\n key={index}\n value={getStarValue({ index, value })}\n />\n ))}\n </div>\n </div>\n )\n}\n","import { StarFill } from '@spark-ui/icons/StarFill'\nimport { StarOutline } from '@spark-ui/icons/StarOutline'\nimport { cx } from 'class-variance-authority'\nimport { type MouseEvent, Ref } from 'react'\n\nimport { Icon } from '../icon'\nimport {\n ratingStarIconStyles,\n type RatingStarIconStylesProps,\n ratingStarStyles,\n type RatingStarstylesProps,\n} from './RatingStar.styles'\nimport type { StarValue } from './types'\n\nexport interface RatingStarProps extends RatingStarstylesProps, RatingStarIconStylesProps {\n value: StarValue\n onClick?: (event: MouseEvent<HTMLDivElement>) => void\n onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void\n ref?: Ref<HTMLDivElement>\n}\n\nexport const RatingStar = ({\n value,\n size,\n disabled,\n readOnly,\n onClick,\n onMouseEnter,\n ref: forwardedRef,\n}: RatingStarProps) => {\n return (\n <div\n ref={forwardedRef}\n onMouseEnter={onMouseEnter}\n className={ratingStarStyles({\n gap: size === 'lg' ? 'md' : 'sm',\n disabled,\n readOnly,\n })}\n data-part=\"star\"\n onClick={onClick}\n >\n <div\n className={cx(\n 'z-raised absolute overflow-hidden',\n 'group-[[data-part=star][data-hovered]]:overflow-visible'\n )}\n style={{ width: value * 100 + '%' }}\n >\n <Icon\n className={ratingStarIconStyles({\n size,\n design: 'filled',\n })}\n >\n <StarFill />\n </Icon>\n </div>\n\n <Icon className={ratingStarIconStyles({ size, design: 'outlined' })}>\n <StarOutline />\n </Icon>\n </div>\n )\n}\n","import { Children, cloneElement, ComponentPropsWithoutRef, ReactElement, ReactNode } from 'react'\n\nimport { VisuallyHidden } from '../visually-hidden'\nimport { iconStyles, IconVariantsProps } from './Icon.styles'\n\nexport interface IconProps extends IconVariantsProps, ComponentPropsWithoutRef<'svg'> {\n /**\n * The svg icon that will be wrapped\n */\n children: ReactNode\n /**\n * The accessible label for the icon. This label will be visually hidden but announced to screen\n * reader users, similar to `alt` text for `img` tags.\n */\n label?: string\n}\n\nexport const Icon = ({\n label,\n className,\n size = 'current',\n intent = 'current',\n children,\n ...others\n}: IconProps) => {\n const child = Children.only(children)\n\n return (\n <>\n {cloneElement(child as ReactElement<Record<string, any>>, {\n className: iconStyles({ className, size, intent }),\n 'data-spark-component': 'icon',\n 'aria-hidden': 'true',\n focusable: 'false',\n ...others,\n })}\n\n {label && <VisuallyHidden>{label}</VisuallyHidden>}\n </>\n )\n}\n\nIcon.displayName = 'Icon'\n","import { Slot as RadixSlot } from 'radix-ui'\nimport {\n cloneElement,\n HTMLAttributes,\n isValidElement,\n PropsWithChildren,\n ReactNode,\n Ref,\n} from 'react'\n\nexport const Slottable = RadixSlot.Slottable\n\nexport type SlotProps = PropsWithChildren<HTMLAttributes<HTMLElement>> & {\n ref?: Ref<HTMLElement>\n}\n\nexport const Slot = ({ ref, ...props }: SlotProps) => {\n return <RadixSlot.Root ref={ref} {...props} />\n}\n\n/**\n * When using Radix `Slot` component, it will consider its first child to merge its props with.\n * In some cases, you might need to wrap the top child with additional markup without breaking this behaviour.\n */\nexport const wrapPolymorphicSlot = (\n asChild: boolean | undefined,\n children: ReactNode,\n callback: (children: ReactNode) => ReactNode\n) => {\n if (!asChild) return callback(children) // If polymorphic behaviour is not used, we keep the original children\n\n return isValidElement(children)\n ? cloneElement(\n children,\n undefined,\n callback((children.props as { children: ReactNode }).children)\n )\n : null\n}\n","import { HTMLAttributes, PropsWithChildren, Ref } from 'react'\n\nimport { Slot } from '../slot'\n\nexport type VisuallyHiddenProps = PropsWithChildren<HTMLAttributes<HTMLElement>> & {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLElement>\n}\n\nexport const VisuallyHidden = ({ asChild = false, ref, ...props }: VisuallyHiddenProps) => {\n const Component = asChild ? Slot : 'span'\n\n return (\n <Component\n {...props}\n ref={ref}\n style={{\n // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss\n position: 'absolute',\n border: 0,\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n wordWrap: 'normal',\n ...props.style,\n }}\n />\n )\n}\n\nVisuallyHidden.displayName = 'VisuallyHidden'\n","import { makeVariants } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const iconStyles = cva(['fill-current shrink-0'], {\n variants: {\n /**\n * Color scheme of the icon.\n */\n intent: makeVariants<\n 'intent',\n [\n 'current',\n 'main',\n 'support',\n 'accent',\n 'basic',\n 'success',\n 'alert',\n 'error',\n 'info',\n 'neutral',\n ]\n >({\n current: ['text-current'],\n main: ['text-main'],\n support: ['text-support'],\n accent: ['text-accent'],\n basic: ['text-basic'],\n success: ['text-success'],\n alert: ['text-alert'],\n error: ['text-error'],\n info: ['text-info'],\n neutral: ['text-neutral'],\n }),\n /**\n * Sets the size of the icon.\n */\n size: makeVariants<'size', ['current', 'sm', 'md', 'lg', 'xl']>({\n current: ['u-current-font-size'],\n sm: ['w-sz-16', 'h-sz-16'],\n md: ['w-sz-24', 'h-sz-24'],\n lg: ['w-sz-32', 'h-sz-32'],\n xl: ['w-sz-40', 'h-sz-40'],\n }),\n },\n})\n\nexport type IconVariantsProps = VariantProps<typeof iconStyles>\n","import { cva, cx, type VariantProps } from 'class-variance-authority'\n\nconst emptyRemainingStarsOnHoverClass = cx('[&_>_div]:peer-hover:w-0!')\n\nconst ratingStarStyles = cva(\n ['peer', 'after:inset-0', 'group', 'relative', 'after:block after:absolute'],\n {\n variants: {\n disabled: {\n true: 'opacity-dim-3',\n false: '',\n },\n readOnly: {\n true: '',\n false: '',\n },\n gap: {\n sm: ['after:w-[calc(100%+(var(--spacing-sm)))]', 'last-of-type:after:content-none'],\n md: ['after:w-[calc(100%+(var(--spacing-md)))]', 'last-of-type:after:content-none'],\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n className: cx(emptyRemainingStarsOnHoverClass, 'cursor-pointer'),\n },\n ],\n defaultVariants: {\n disabled: false,\n readOnly: false,\n gap: 'sm',\n },\n }\n)\n\nconst ratingStarIconStyles = cva('', {\n variants: {\n size: {\n sm: 'text-caption-link',\n md: 'text-body-1',\n lg: 'text-display-1',\n },\n design: {\n filled: [\n 'text-main-variant',\n 'group-[[data-part=star][data-hovered]]:text-main-variant-hovered',\n ],\n outlined: ['text-on-surface/dim-3'],\n },\n },\n})\n\ntype RatingStarstylesProps = Omit<VariantProps<typeof ratingStarStyles>, 'gap'>\ntype RatingStarIconStylesProps = Omit<VariantProps<typeof ratingStarIconStyles>, 'design'>\n\nexport { ratingStarStyles, ratingStarIconStyles }\nexport type { RatingStarstylesProps, RatingStarIconStylesProps }\n","import { type StarValue } from './types'\n\nfunction getNearestHalfDecimal(num: number): number {\n return Math.round(num / 0.5) * 0.5\n}\n\nfunction getStarValue({ value, index }: { value?: number; index: number }): StarValue {\n if (value === undefined) return 0\n\n const starPosition = index + 1\n const formattedValue = getNearestHalfDecimal(value)\n\n if (Math.ceil(formattedValue) < starPosition) return 0\n\n return formattedValue >= starPosition ? 1 : 0.5\n}\n\nfunction splitAt<T>(arr: T[], index: number): [T[], T[]] {\n const prev = arr.slice(0, index)\n const next = arr.slice(index)\n\n return [prev, next]\n}\n\nexport { getNearestHalfDecimal, getStarValue, splitAt }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gCAAiC;AACjC,IAAAA,mCAAmB;AACnB,IAAAC,gBAOO;;;ACTP,sBAAyB;AACzB,yBAA4B;AAC5B,IAAAC,mCAAmB;;;ACFnB,IAAAC,gBAA0F;;;ACA1F,sBAAkC;AAClC,mBAOO;AASE;AAPF,IAAM,YAAY,gBAAAC,KAAU;AAM5B,IAAM,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,MAAiB;AACpD,SAAO,4CAAC,gBAAAA,KAAU,MAAV,EAAe,KAAW,GAAG,OAAO;AAC9C;;;ACFI,IAAAC,sBAAA;AAJG,IAAM,iBAAiB,CAAC,EAAE,UAAU,OAAO,KAAK,GAAG,MAAM,MAA2B;AACzF,QAAM,YAAY,UAAU,OAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA,OAAO;AAAA;AAAA,QAEL,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,GA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YACA;AAAA,YACA,cAAY;AAAA,YACZ,KAAK;AAAA,YACL,aAAU;AAAA,YACV,WAAU;AAAA,YACV,MAAK;AAAA,YACL,KAAI;AAAA,YACJ,KAAI;AAAA,YACJ,MAAM,WAAW,MAAM;AAAA,YACvB;AAAA,YACA;AAAA,YACA,OAAO,sBAAsB,SAAS,CAAC;AAAA,YACvC,UAAU,WAAS,iBAAiB,cAAc,KAAK;AAAA,YACvD,QAAQ;AAAA;AAAA,QACV;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,cACT,SAAS,OAAO,aAAa;AAAA,cAC7B;AAAA,cACA;AAAA,YACF;AAAA,YAEC,gBAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,UACjC;AAAA,cAAC;AAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,SAAS,MAAM,iBAAiB,YAAY,KAAK;AAAA,gBACjD,cAAc,WAAS,iBAAiB,iBAAiB,KAAK;AAAA,gBAC9D,KAAK;AAAA,gBAEL,OAAO,aAAa,EAAE,OAAO,MAAM,CAAC;AAAA;AAAA,cAD/B;AAAA,YAEP,CACD;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_class_variance_authority","import_react","import_class_variance_authority","import_react","RadixSlot","import_jsx_runtime","import_jsx_runtime","import_class_variance_authority","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Icon
|
|
3
|
+
} from "../chunk-AESXFMCC.mjs";
|
|
4
|
+
import "../chunk-NBZKMCHF.mjs";
|
|
5
|
+
import "../chunk-4F5DOL57.mjs";
|
|
6
|
+
|
|
7
|
+
// src/rating/Rating.tsx
|
|
8
|
+
import { useCombinedState } from "@spark-ui/use-combined-state";
|
|
9
|
+
import { cx as cx3 } from "class-variance-authority";
|
|
10
|
+
import {
|
|
11
|
+
useCallback,
|
|
12
|
+
useRef
|
|
13
|
+
} from "react";
|
|
14
|
+
|
|
15
|
+
// src/rating/RatingStar.tsx
|
|
16
|
+
import { StarFill } from "@spark-ui/icons/StarFill";
|
|
17
|
+
import { StarOutline } from "@spark-ui/icons/StarOutline";
|
|
18
|
+
import { cx as cx2 } from "class-variance-authority";
|
|
19
|
+
|
|
20
|
+
// src/rating/RatingStar.styles.ts
|
|
21
|
+
import { cva, cx } from "class-variance-authority";
|
|
22
|
+
var emptyRemainingStarsOnHoverClass = cx("[&_>_div]:peer-hover:w-0!");
|
|
23
|
+
var ratingStarStyles = cva(
|
|
24
|
+
["peer", "after:inset-0", "group", "relative", "after:block after:absolute"],
|
|
25
|
+
{
|
|
26
|
+
variants: {
|
|
27
|
+
disabled: {
|
|
28
|
+
true: "opacity-dim-3",
|
|
29
|
+
false: ""
|
|
30
|
+
},
|
|
31
|
+
readOnly: {
|
|
32
|
+
true: "",
|
|
33
|
+
false: ""
|
|
34
|
+
},
|
|
35
|
+
gap: {
|
|
36
|
+
sm: ["after:w-[calc(100%+(var(--spacing-sm)))]", "last-of-type:after:content-none"],
|
|
37
|
+
md: ["after:w-[calc(100%+(var(--spacing-md)))]", "last-of-type:after:content-none"]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
compoundVariants: [
|
|
41
|
+
{
|
|
42
|
+
readOnly: false,
|
|
43
|
+
disabled: false,
|
|
44
|
+
className: cx(emptyRemainingStarsOnHoverClass, "cursor-pointer")
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
disabled: false,
|
|
49
|
+
readOnly: false,
|
|
50
|
+
gap: "sm"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
var ratingStarIconStyles = cva("", {
|
|
55
|
+
variants: {
|
|
56
|
+
size: {
|
|
57
|
+
sm: "text-caption-link",
|
|
58
|
+
md: "text-body-1",
|
|
59
|
+
lg: "text-display-1"
|
|
60
|
+
},
|
|
61
|
+
design: {
|
|
62
|
+
filled: [
|
|
63
|
+
"text-main-variant",
|
|
64
|
+
"group-[[data-part=star][data-hovered]]:text-main-variant-hovered"
|
|
65
|
+
],
|
|
66
|
+
outlined: ["text-on-surface/dim-3"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/rating/RatingStar.tsx
|
|
72
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
73
|
+
var RatingStar = ({
|
|
74
|
+
value,
|
|
75
|
+
size,
|
|
76
|
+
disabled,
|
|
77
|
+
readOnly,
|
|
78
|
+
onClick,
|
|
79
|
+
onMouseEnter,
|
|
80
|
+
ref: forwardedRef
|
|
81
|
+
}) => {
|
|
82
|
+
return /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
ref: forwardedRef,
|
|
86
|
+
onMouseEnter,
|
|
87
|
+
className: ratingStarStyles({
|
|
88
|
+
gap: size === "lg" ? "md" : "sm",
|
|
89
|
+
disabled,
|
|
90
|
+
readOnly
|
|
91
|
+
}),
|
|
92
|
+
"data-part": "star",
|
|
93
|
+
onClick,
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
className: cx2(
|
|
99
|
+
"z-raised absolute overflow-hidden",
|
|
100
|
+
"group-[[data-part=star][data-hovered]]:overflow-visible"
|
|
101
|
+
),
|
|
102
|
+
style: { width: value * 100 + "%" },
|
|
103
|
+
children: /* @__PURE__ */ jsx(
|
|
104
|
+
Icon,
|
|
105
|
+
{
|
|
106
|
+
className: ratingStarIconStyles({
|
|
107
|
+
size,
|
|
108
|
+
design: "filled"
|
|
109
|
+
}),
|
|
110
|
+
children: /* @__PURE__ */ jsx(StarFill, {})
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsx(Icon, { className: ratingStarIconStyles({ size, design: "outlined" }), children: /* @__PURE__ */ jsx(StarOutline, {}) })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// src/rating/utils.ts
|
|
122
|
+
function getNearestHalfDecimal(num) {
|
|
123
|
+
return Math.round(num / 0.5) * 0.5;
|
|
124
|
+
}
|
|
125
|
+
function getStarValue({ value, index }) {
|
|
126
|
+
if (value === void 0) return 0;
|
|
127
|
+
const starPosition = index + 1;
|
|
128
|
+
const formattedValue = getNearestHalfDecimal(value);
|
|
129
|
+
if (Math.ceil(formattedValue) < starPosition) return 0;
|
|
130
|
+
return formattedValue >= starPosition ? 1 : 0.5;
|
|
131
|
+
}
|
|
132
|
+
function splitAt(arr, index) {
|
|
133
|
+
const prev = arr.slice(0, index);
|
|
134
|
+
const next = arr.slice(index);
|
|
135
|
+
return [prev, next];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/rating/Rating.tsx
|
|
139
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
140
|
+
var Rating = ({
|
|
141
|
+
defaultValue,
|
|
142
|
+
value: propValue,
|
|
143
|
+
onValueChange,
|
|
144
|
+
size = "md",
|
|
145
|
+
disabled,
|
|
146
|
+
readOnly,
|
|
147
|
+
name,
|
|
148
|
+
id,
|
|
149
|
+
"aria-label": ariaLabel,
|
|
150
|
+
ref,
|
|
151
|
+
...rest
|
|
152
|
+
}) => {
|
|
153
|
+
const inputRef = useRef(null);
|
|
154
|
+
const starRefList = useRef([]);
|
|
155
|
+
const [value, setRatingValue] = useCombinedState(propValue, defaultValue, onValueChange);
|
|
156
|
+
const valueRef = useRef(value);
|
|
157
|
+
const isInteractive = !(disabled || readOnly);
|
|
158
|
+
function onStarClick(index) {
|
|
159
|
+
if (!inputRef.current) return;
|
|
160
|
+
setRatingValue(index + 1);
|
|
161
|
+
valueRef.current = index + 1;
|
|
162
|
+
inputRef.current.focus();
|
|
163
|
+
inputRef.current.setAttribute("data-clicked", "");
|
|
164
|
+
}
|
|
165
|
+
function onInputChange(event) {
|
|
166
|
+
if (valueRef.current === Number(event.target.value) || Number(event.target.value) === 0) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
valueRef.current = Number(event.target.value);
|
|
170
|
+
setRatingValue(Number(event.target.value));
|
|
171
|
+
}
|
|
172
|
+
function onStarMouseEnter({ currentTarget }) {
|
|
173
|
+
const currentStarIndex = starRefList.current.findIndex((star) => star === currentTarget);
|
|
174
|
+
const [previousStars, followingStars] = splitAt(starRefList.current, currentStarIndex + 1);
|
|
175
|
+
previousStars.forEach((star) => star.setAttribute("data-hovered", ""));
|
|
176
|
+
followingStars.forEach((star) => star.removeAttribute("data-hovered"));
|
|
177
|
+
}
|
|
178
|
+
const handleStarRef = useCallback((elm) => {
|
|
179
|
+
if (!elm) return;
|
|
180
|
+
starRefList.current.push(elm);
|
|
181
|
+
}, []);
|
|
182
|
+
function resetDataPartInputAttr() {
|
|
183
|
+
inputRef.current?.removeAttribute("data-clicked");
|
|
184
|
+
}
|
|
185
|
+
function resetDataPartStarAttr() {
|
|
186
|
+
starRefList.current.forEach((star) => star.removeAttribute("data-hovered"));
|
|
187
|
+
}
|
|
188
|
+
return /* @__PURE__ */ jsxs2(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
className: "relative inline-flex",
|
|
192
|
+
ref,
|
|
193
|
+
"data-spark-component": "rating",
|
|
194
|
+
...rest,
|
|
195
|
+
onMouseLeave: resetDataPartStarAttr,
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx2(
|
|
198
|
+
"input",
|
|
199
|
+
{
|
|
200
|
+
name,
|
|
201
|
+
id,
|
|
202
|
+
"aria-label": ariaLabel,
|
|
203
|
+
ref: inputRef,
|
|
204
|
+
"data-part": "input",
|
|
205
|
+
className: "peer absolute inset-0 opacity-0",
|
|
206
|
+
type: "range",
|
|
207
|
+
min: "0",
|
|
208
|
+
max: "5",
|
|
209
|
+
step: readOnly ? 0.5 : 1,
|
|
210
|
+
disabled,
|
|
211
|
+
readOnly,
|
|
212
|
+
value: getNearestHalfDecimal(value ?? 0),
|
|
213
|
+
onChange: (event) => isInteractive && onInputChange(event),
|
|
214
|
+
onBlur: resetDataPartInputAttr
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ jsx2(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: cx3(
|
|
221
|
+
size === "lg" ? "gap-x-md" : "gap-x-sm",
|
|
222
|
+
"flex",
|
|
223
|
+
"peer-focus-visible:u-outline peer-[[data-part=input][data-clicked]]:shadow-none"
|
|
224
|
+
),
|
|
225
|
+
children: Array.from({ length: 5 }).map((_, index) => /* @__PURE__ */ jsx2(
|
|
226
|
+
RatingStar,
|
|
227
|
+
{
|
|
228
|
+
disabled,
|
|
229
|
+
readOnly,
|
|
230
|
+
size,
|
|
231
|
+
onClick: () => isInteractive && onStarClick(index),
|
|
232
|
+
onMouseEnter: (event) => isInteractive && onStarMouseEnter(event),
|
|
233
|
+
ref: handleStarRef,
|
|
234
|
+
value: getStarValue({ index, value })
|
|
235
|
+
},
|
|
236
|
+
index
|
|
237
|
+
))
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
export {
|
|
245
|
+
Rating
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=index.mjs.map
|