@deepnoid/ui 0.1.164 → 0.1.166

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.
@@ -5210,18 +5210,28 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5210
5210
  allowHalf = false,
5211
5211
  classNames,
5212
5212
  filledColor = "text-primary-main",
5213
- emptyColor = "text-neutral-light"
5213
+ emptyColor = "text-neutral-soft"
5214
5214
  } = { ...props, ...variantProps };
5215
5215
  const slots = (0, import_react.useMemo)(() => starRatingStyle({ ...variantProps }), [variantProps]);
5216
5216
  const [hoverRating, setHoverRating] = (0, import_react.useState)(0);
5217
5217
  const handleStarClick = (starIndex, isHalf = false) => {
5218
5218
  if (readOnly || !onChange) return;
5219
- const newRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
5219
+ let newRating;
5220
+ if (allowHalf && isHalf) {
5221
+ newRating = starIndex - 0.5;
5222
+ } else {
5223
+ newRating = starIndex;
5224
+ }
5220
5225
  onChange(newRating);
5221
5226
  };
5222
5227
  const handleStarHover = (starIndex, isHalf = false) => {
5223
5228
  if (readOnly) return;
5224
- const newHoverRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
5229
+ let newHoverRating;
5230
+ if (allowHalf && isHalf) {
5231
+ newHoverRating = starIndex - 0.5;
5232
+ } else {
5233
+ newHoverRating = starIndex;
5234
+ }
5225
5235
  setHoverRating(newHoverRating);
5226
5236
  };
5227
5237
  const handleMouseLeave = () => {
@@ -5234,7 +5244,9 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5234
5244
  const renderStar = (starIndex) => {
5235
5245
  const currentRating = readOnly ? value : hoverRating || value;
5236
5246
  const isFull = currentRating >= starIndex;
5237
- const isHalf = allowHalf && currentRating >= starIndex - 0.5 && currentRating < starIndex;
5247
+ const isEmpty = currentRating < starIndex - 1;
5248
+ const isPartial = !isFull && !isEmpty;
5249
+ const fillPercentage = isPartial ? (currentRating - (starIndex - 1)) * 100 : 0;
5238
5250
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: slots.starWrapper({ class: classNames == null ? void 0 : classNames.starWrapper }), children: [
5239
5251
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5240
5252
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -5254,7 +5266,22 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5254
5266
  }
5255
5267
  )
5256
5268
  ] }),
5257
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isHalf ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "halfStar", className: filledColor, size }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: isFull, className: isFull ? filledColor : emptyColor, size }) })
5269
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
5270
+ (isFull || isPartial) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size }),
5272
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5273
+ "div",
5274
+ {
5275
+ className: "absolute left-0 top-0 overflow-hidden",
5276
+ style: {
5277
+ width: isFull ? "100%" : `${fillPercentage}%`
5278
+ },
5279
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: filledColor, size })
5280
+ }
5281
+ )
5282
+ ] }),
5283
+ isEmpty && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size })
5284
+ ] })
5258
5285
  ] }, starIndex);
5259
5286
  };
5260
5287
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref, className: slots.base({ class: classNames == null ? void 0 : classNames.base }), onMouseLeave: handleMouseLeave, children: createRange(stars).map(renderStar) });
@@ -2,7 +2,7 @@
2
2
  import "../../chunk-OLQOLLKG.mjs";
3
3
  import {
4
4
  starRating_default
5
- } from "../../chunk-INRA6IED.mjs";
5
+ } from "../../chunk-XTS6WKFD.mjs";
6
6
  import "../../chunk-ZYIIXWVY.mjs";
7
7
  import "../../chunk-R7KUEH3N.mjs";
8
8
  import "../../chunk-E3G5QXSH.mjs";
@@ -5209,18 +5209,28 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5209
5209
  allowHalf = false,
5210
5210
  classNames,
5211
5211
  filledColor = "text-primary-main",
5212
- emptyColor = "text-neutral-light"
5212
+ emptyColor = "text-neutral-soft"
5213
5213
  } = { ...props, ...variantProps };
5214
5214
  const slots = (0, import_react.useMemo)(() => starRatingStyle({ ...variantProps }), [variantProps]);
5215
5215
  const [hoverRating, setHoverRating] = (0, import_react.useState)(0);
5216
5216
  const handleStarClick = (starIndex, isHalf = false) => {
5217
5217
  if (readOnly || !onChange) return;
5218
- const newRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
5218
+ let newRating;
5219
+ if (allowHalf && isHalf) {
5220
+ newRating = starIndex - 0.5;
5221
+ } else {
5222
+ newRating = starIndex;
5223
+ }
5219
5224
  onChange(newRating);
5220
5225
  };
5221
5226
  const handleStarHover = (starIndex, isHalf = false) => {
5222
5227
  if (readOnly) return;
5223
- const newHoverRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
5228
+ let newHoverRating;
5229
+ if (allowHalf && isHalf) {
5230
+ newHoverRating = starIndex - 0.5;
5231
+ } else {
5232
+ newHoverRating = starIndex;
5233
+ }
5224
5234
  setHoverRating(newHoverRating);
5225
5235
  };
5226
5236
  const handleMouseLeave = () => {
@@ -5233,7 +5243,9 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5233
5243
  const renderStar = (starIndex) => {
5234
5244
  const currentRating = readOnly ? value : hoverRating || value;
5235
5245
  const isFull = currentRating >= starIndex;
5236
- const isHalf = allowHalf && currentRating >= starIndex - 0.5 && currentRating < starIndex;
5246
+ const isEmpty = currentRating < starIndex - 1;
5247
+ const isPartial = !isFull && !isEmpty;
5248
+ const fillPercentage = isPartial ? (currentRating - (starIndex - 1)) * 100 : 0;
5237
5249
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: slots.starWrapper({ class: classNames == null ? void 0 : classNames.starWrapper }), children: [
5238
5250
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5239
5251
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -5253,7 +5265,22 @@ var StarRating = (0, import_react.forwardRef)((originalProps, ref) => {
5253
5265
  }
5254
5266
  )
5255
5267
  ] }),
5256
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isHalf ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "halfStar", className: filledColor, size }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: isFull, className: isFull ? filledColor : emptyColor, size }) })
5268
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
5269
+ (isFull || isPartial) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5270
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size }),
5271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5272
+ "div",
5273
+ {
5274
+ className: "absolute left-0 top-0 overflow-hidden",
5275
+ style: {
5276
+ width: isFull ? "100%" : `${fillPercentage}%`
5277
+ },
5278
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: filledColor, size })
5279
+ }
5280
+ )
5281
+ ] }),
5282
+ isEmpty && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size })
5283
+ ] })
5257
5284
  ] }, starIndex);
5258
5285
  };
5259
5286
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref, className: slots.base({ class: classNames == null ? void 0 : classNames.base }), onMouseLeave: handleMouseLeave, children: createRange(stars).map(renderStar) });
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  starRatingStyle,
4
4
  starRating_default
5
- } from "../../chunk-INRA6IED.mjs";
5
+ } from "../../chunk-XTS6WKFD.mjs";
6
6
  import "../../chunk-ZYIIXWVY.mjs";
7
7
  import "../../chunk-R7KUEH3N.mjs";
8
8
  import "../../chunk-E3G5QXSH.mjs";
@@ -5,16 +5,16 @@ import {
5
5
  } from "../../chunk-DS5CGU2X.mjs";
6
6
  import {
7
7
  table_default
8
- } from "../../chunk-PX4RCHOE.mjs";
8
+ } from "../../chunk-DWW4ZESK.mjs";
9
9
  import "../../chunk-7B7LRG5J.mjs";
10
10
  import "../../chunk-WLTBJF4I.mjs";
11
11
  import "../../chunk-F3HENRVM.mjs";
12
+ import "../../chunk-QZ3LVYJW.mjs";
13
+ import "../../chunk-OEIEALIP.mjs";
12
14
  import "../../chunk-2GCSFWHD.mjs";
13
15
  import "../../chunk-VNRGOOSY.mjs";
14
16
  import "../../chunk-DQRAFUDA.mjs";
15
17
  import "../../chunk-EWS3FESG.mjs";
16
- import "../../chunk-QZ3LVYJW.mjs";
17
- import "../../chunk-OEIEALIP.mjs";
18
18
  import "../../chunk-ZYIIXWVY.mjs";
19
19
  import "../../chunk-R7KUEH3N.mjs";
20
20
  import "../../chunk-E3G5QXSH.mjs";
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import {
3
3
  table_body_default
4
- } from "../../chunk-PX4RCHOE.mjs";
4
+ } from "../../chunk-DWW4ZESK.mjs";
5
5
  import "../../chunk-7B7LRG5J.mjs";
6
6
  import "../../chunk-WLTBJF4I.mjs";
7
7
  import "../../chunk-F3HENRVM.mjs";
8
+ import "../../chunk-QZ3LVYJW.mjs";
9
+ import "../../chunk-OEIEALIP.mjs";
8
10
  import "../../chunk-2GCSFWHD.mjs";
9
11
  import "../../chunk-VNRGOOSY.mjs";
10
12
  import "../../chunk-DQRAFUDA.mjs";
11
13
  import "../../chunk-EWS3FESG.mjs";
12
- import "../../chunk-QZ3LVYJW.mjs";
13
- import "../../chunk-OEIEALIP.mjs";
14
14
  import "../../chunk-ZYIIXWVY.mjs";
15
15
  import "../../chunk-R7KUEH3N.mjs";
16
16
  import "../../chunk-E3G5QXSH.mjs";
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import {
3
3
  table_head_default
4
- } from "../../chunk-PX4RCHOE.mjs";
4
+ } from "../../chunk-DWW4ZESK.mjs";
5
5
  import "../../chunk-7B7LRG5J.mjs";
6
6
  import "../../chunk-WLTBJF4I.mjs";
7
7
  import "../../chunk-F3HENRVM.mjs";
8
+ import "../../chunk-QZ3LVYJW.mjs";
9
+ import "../../chunk-OEIEALIP.mjs";
8
10
  import "../../chunk-2GCSFWHD.mjs";
9
11
  import "../../chunk-VNRGOOSY.mjs";
10
12
  import "../../chunk-DQRAFUDA.mjs";
11
13
  import "../../chunk-EWS3FESG.mjs";
12
- import "../../chunk-QZ3LVYJW.mjs";
13
- import "../../chunk-OEIEALIP.mjs";
14
14
  import "../../chunk-ZYIIXWVY.mjs";
15
15
  import "../../chunk-R7KUEH3N.mjs";
16
16
  import "../../chunk-E3G5QXSH.mjs";
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  getCellStyle,
4
4
  table_default
5
- } from "../../chunk-PX4RCHOE.mjs";
5
+ } from "../../chunk-DWW4ZESK.mjs";
6
6
  import "../../chunk-7B7LRG5J.mjs";
7
7
  import "../../chunk-WLTBJF4I.mjs";
8
8
  import "../../chunk-F3HENRVM.mjs";
9
+ import "../../chunk-QZ3LVYJW.mjs";
10
+ import "../../chunk-OEIEALIP.mjs";
9
11
  import "../../chunk-2GCSFWHD.mjs";
10
12
  import "../../chunk-VNRGOOSY.mjs";
11
13
  import "../../chunk-DQRAFUDA.mjs";
12
14
  import "../../chunk-EWS3FESG.mjs";
13
- import "../../chunk-QZ3LVYJW.mjs";
14
- import "../../chunk-OEIEALIP.mjs";
15
15
  import "../../chunk-ZYIIXWVY.mjs";
16
16
  import "../../chunk-R7KUEH3N.mjs";
17
17
  import "../../chunk-E3G5QXSH.mjs";
package/dist/index.d.mts CHANGED
@@ -31,7 +31,7 @@ export { default as DatePicker, DatePickerProps, DateRangeValue, DateValue } fro
31
31
  export { default as TimePicker, TimePickerProps } from './components/picker/timePicker.mjs';
32
32
  export { default as ScrollArea } from './components/scroll/scrollArea.mjs';
33
33
  export { default as Tree, TreeNode } from './components/tree/tree.mjs';
34
- export { default as FileUpload } from './components/fileUpload/fileUpload.mjs';
34
+ export { DefaultFile, default as FileUpload, FileUploadProps } from './components/fileUpload/fileUpload.mjs';
35
35
  export { default as Skeleton } from './components/skeleton/skeleton.mjs';
36
36
  export { default as CircularProgress } from './components/charts/circularProgress.mjs';
37
37
  export { default as AreaChart } from './components/charts/areaChart.mjs';
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { default as DatePicker, DatePickerProps, DateRangeValue, DateValue } fro
31
31
  export { default as TimePicker, TimePickerProps } from './components/picker/timePicker.js';
32
32
  export { default as ScrollArea } from './components/scroll/scrollArea.js';
33
33
  export { default as Tree, TreeNode } from './components/tree/tree.js';
34
- export { default as FileUpload } from './components/fileUpload/fileUpload.js';
34
+ export { DefaultFile, default as FileUpload, FileUploadProps } from './components/fileUpload/fileUpload.js';
35
35
  export { default as Skeleton } from './components/skeleton/skeleton.js';
36
36
  export { default as CircularProgress } from './components/charts/circularProgress.js';
37
37
  export { default as AreaChart } from './components/charts/areaChart.js';
package/dist/index.js CHANGED
@@ -12342,29 +12342,32 @@ function FileUpload({
12342
12342
  helperMessage,
12343
12343
  showProgress,
12344
12344
  name,
12345
- classNames
12345
+ classNames,
12346
+ defaultFile
12346
12347
  }) {
12347
12348
  const fileInputRef = (0, import_react37.useRef)(null);
12348
12349
  const uploadIntervalRef = (0, import_react37.useRef)(null);
12349
- const [file, setFile] = (0, import_react37.useState)(null);
12350
+ const [currentFile, setCurrentFile] = (0, import_react37.useState)(null);
12350
12351
  const [uploadProgress, setUploadProgress] = (0, import_react37.useState)(0);
12351
12352
  const [message, setMessage] = (0, import_react37.useState)(errorMessage);
12353
+ const [displayFileName, setDisplayFileName] = (0, import_react37.useState)(() => (defaultFile == null ? void 0 : defaultFile.name) || "");
12354
+ const [hasUploadedFile, setHasUploadedFile] = (0, import_react37.useState)(false);
12352
12355
  const slots = fileUploadStyle();
12353
12356
  const handleButtonClick = () => {
12354
12357
  var _a;
12355
12358
  (_a = fileInputRef.current) == null ? void 0 : _a.click();
12356
12359
  };
12357
- const validateFile = (file2) => {
12358
- if (accept.length && !accept.includes(file2.type)) {
12360
+ const validateFile = (file) => {
12361
+ if (accept.length && !accept.includes(file.type)) {
12359
12362
  return acceptErrorMessage;
12360
12363
  }
12361
- const sizeMB = file2.size / 1024 / 1024;
12364
+ const sizeMB = file.size / 1024 / 1024;
12362
12365
  if (sizeMB > maxSizeMB) {
12363
12366
  return `${sizeErrorMessage} (${maxSizeMB}MB)`;
12364
12367
  }
12365
12368
  return null;
12366
12369
  };
12367
- const startUploadSimulation = (file2) => {
12370
+ const startUploadSimulation = (file) => {
12368
12371
  let progress = 0;
12369
12372
  setUploadProgress(0);
12370
12373
  uploadIntervalRef.current = window.setInterval(() => {
@@ -12372,7 +12375,7 @@ function FileUpload({
12372
12375
  setUploadProgress(progress);
12373
12376
  if (progress >= 100) {
12374
12377
  clearInterval(uploadIntervalRef.current);
12375
- onFileUpload == null ? void 0 : onFileUpload(file2);
12378
+ onFileUpload == null ? void 0 : onFileUpload(file);
12376
12379
  }
12377
12380
  }, 100);
12378
12381
  };
@@ -12383,20 +12386,26 @@ function FileUpload({
12383
12386
  const error = validateFile(selectedFile);
12384
12387
  if (error) {
12385
12388
  setMessage(error);
12386
- setFile(null);
12389
+ setCurrentFile(null);
12390
+ setDisplayFileName((defaultFile == null ? void 0 : defaultFile.name) || "");
12391
+ setHasUploadedFile(false);
12387
12392
  return;
12388
12393
  }
12389
- setFile(selectedFile);
12394
+ setCurrentFile(selectedFile);
12395
+ setDisplayFileName(selectedFile.name);
12390
12396
  setMessage("");
12397
+ setHasUploadedFile(true);
12391
12398
  startUploadSimulation(selectedFile);
12392
12399
  };
12393
12400
  const handleCancelUpload = () => {
12394
12401
  if (uploadIntervalRef.current) {
12395
12402
  clearInterval(uploadIntervalRef.current);
12396
12403
  }
12397
- setFile(null);
12404
+ setCurrentFile(null);
12398
12405
  setUploadProgress(0);
12399
12406
  setMessage("");
12407
+ setDisplayFileName((defaultFile == null ? void 0 : defaultFile.name) || "");
12408
+ setHasUploadedFile(false);
12400
12409
  if (onCancelUpload) onCancelUpload();
12401
12410
  };
12402
12411
  (0, import_react37.useEffect)(() => {
@@ -12407,8 +12416,11 @@ function FileUpload({
12407
12416
  };
12408
12417
  }, []);
12409
12418
  (0, import_react37.useEffect)(() => {
12410
- setMessage(errorMessage);
12411
- }, [setMessage, errorMessage]);
12419
+ if (errorMessage !== void 0) {
12420
+ setMessage(errorMessage);
12421
+ }
12422
+ }, [errorMessage]);
12423
+ const shouldShowCloseButton = hasUploadedFile;
12412
12424
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.base({ class: classNames == null ? void 0 : classNames.base }), children: [
12413
12425
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.container({ class: classNames == null ? void 0 : classNames.container }), children: [
12414
12426
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.inputWrapper(), children: [
@@ -12420,14 +12432,15 @@ function FileUpload({
12420
12432
  variant: "outline",
12421
12433
  full: true,
12422
12434
  placeholder,
12423
- defaultValue: file == null ? void 0 : file.name,
12435
+ value: displayFileName,
12424
12436
  errorMessage: message
12425
12437
  }
12426
12438
  ),
12427
- file && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
12439
+ shouldShowCloseButton && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
12428
12440
  icon_button_default,
12429
12441
  {
12430
12442
  name: "close",
12443
+ size: "sm",
12431
12444
  variant: "ghost",
12432
12445
  color: "neutral",
12433
12446
  onClick: handleCancelUpload,
@@ -12436,10 +12449,19 @@ function FileUpload({
12436
12449
  }
12437
12450
  )
12438
12451
  ] }),
12439
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(button_default, { type: "button", variant: "outline", onClick: handleButtonClick, disabled: !!file, children: buttonText }),
12452
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
12453
+ button_default,
12454
+ {
12455
+ type: "button",
12456
+ variant: "outline",
12457
+ onClick: handleButtonClick,
12458
+ disabled: !!(currentFile && hasUploadedFile),
12459
+ children: buttonText
12460
+ }
12461
+ ),
12440
12462
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("input", { ref: fileInputRef, type: "file", hidden: true, accept: accept.join(","), onChange: handleFileChange })
12441
12463
  ] }),
12442
- showProgress && file && uploadProgress < 100 && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(progress_default, { value: uploadProgress }),
12464
+ showProgress && currentFile && hasUploadedFile && uploadProgress < 100 && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(progress_default, { value: uploadProgress }),
12443
12465
  !message && helperMessage && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: slots.helperMessage(), children: helperMessage })
12444
12466
  ] });
12445
12467
  }
@@ -12450,7 +12472,7 @@ var fileUploadStyle = (0, import_tailwind_variants34.tv)({
12450
12472
  base: ["flex", "flex-col", "gap-[5px]"],
12451
12473
  container: ["flex", "gap-[10px]"],
12452
12474
  inputWrapper: ["relative", "flex-1"],
12453
- cancelButton: ["absolute", "top-1/2", "right-0", "-translate-y-1/2"],
12475
+ cancelButton: ["absolute", "top-1/2", "right-0", "-translate-y-1/2", "mr-[4px]"],
12454
12476
  errorMessage: ["text-danger-main", "text-sm"],
12455
12477
  helperMessage: ["text-neutral-main", "text-sm"]
12456
12478
  }
@@ -13210,18 +13232,28 @@ var StarRating = (0, import_react42.forwardRef)((originalProps, ref) => {
13210
13232
  allowHalf = false,
13211
13233
  classNames,
13212
13234
  filledColor = "text-primary-main",
13213
- emptyColor = "text-neutral-light"
13235
+ emptyColor = "text-neutral-soft"
13214
13236
  } = { ...props, ...variantProps };
13215
13237
  const slots = (0, import_react42.useMemo)(() => starRatingStyle({ ...variantProps }), [variantProps]);
13216
13238
  const [hoverRating, setHoverRating] = (0, import_react42.useState)(0);
13217
13239
  const handleStarClick = (starIndex, isHalf = false) => {
13218
13240
  if (readOnly || !onChange) return;
13219
- const newRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
13241
+ let newRating;
13242
+ if (allowHalf && isHalf) {
13243
+ newRating = starIndex - 0.5;
13244
+ } else {
13245
+ newRating = starIndex;
13246
+ }
13220
13247
  onChange(newRating);
13221
13248
  };
13222
13249
  const handleStarHover = (starIndex, isHalf = false) => {
13223
13250
  if (readOnly) return;
13224
- const newHoverRating = allowHalf && isHalf ? starIndex - 0.5 : starIndex;
13251
+ let newHoverRating;
13252
+ if (allowHalf && isHalf) {
13253
+ newHoverRating = starIndex - 0.5;
13254
+ } else {
13255
+ newHoverRating = starIndex;
13256
+ }
13225
13257
  setHoverRating(newHoverRating);
13226
13258
  };
13227
13259
  const handleMouseLeave = () => {
@@ -13234,7 +13266,9 @@ var StarRating = (0, import_react42.forwardRef)((originalProps, ref) => {
13234
13266
  const renderStar = (starIndex) => {
13235
13267
  const currentRating = readOnly ? value : hoverRating || value;
13236
13268
  const isFull = currentRating >= starIndex;
13237
- const isHalf = allowHalf && currentRating >= starIndex - 0.5 && currentRating < starIndex;
13269
+ const isEmpty = currentRating < starIndex - 1;
13270
+ const isPartial = !isFull && !isEmpty;
13271
+ const fillPercentage = isPartial ? (currentRating - (starIndex - 1)) * 100 : 0;
13238
13272
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: slots.starWrapper({ class: classNames == null ? void 0 : classNames.starWrapper }), children: [
13239
13273
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
13240
13274
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
@@ -13254,7 +13288,22 @@ var StarRating = (0, import_react42.forwardRef)((originalProps, ref) => {
13254
13288
  }
13255
13289
  )
13256
13290
  ] }),
13257
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { children: isHalf ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon_default, { name: "halfStar", className: filledColor, size }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon_default, { name: "star", fill: isFull, className: isFull ? filledColor : emptyColor, size }) })
13291
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "relative", children: [
13292
+ (isFull || isPartial) && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
13293
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size }),
13294
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
13295
+ "div",
13296
+ {
13297
+ className: "absolute left-0 top-0 overflow-hidden",
13298
+ style: {
13299
+ width: isFull ? "100%" : `${fillPercentage}%`
13300
+ },
13301
+ children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon_default, { name: "star", fill: true, className: filledColor, size })
13302
+ }
13303
+ )
13304
+ ] }),
13305
+ isEmpty && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon_default, { name: "star", fill: true, className: emptyColor, size })
13306
+ ] })
13258
13307
  ] }, starIndex);
13259
13308
  };
13260
13309
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref, className: slots.base({ class: classNames == null ? void 0 : classNames.base }), onMouseLeave: handleMouseLeave, children: createRange(stars).map(renderStar) });
package/dist/index.mjs CHANGED
@@ -9,10 +9,6 @@ import "./chunk-MBLZYQCN.mjs";
9
9
  import {
10
10
  tree_default
11
11
  } from "./chunk-WSBUOY2M.mjs";
12
- import "./chunk-RRAZM5D3.mjs";
13
- import {
14
- textarea_default
15
- } from "./chunk-3CRSSRCH.mjs";
16
12
  import "./chunk-LUWGOKLG.mjs";
17
13
  import {
18
14
  ToastProvider,
@@ -22,29 +18,33 @@ import "./chunk-ZOTHPHXA.mjs";
22
18
  import {
23
19
  toast_default
24
20
  } from "./chunk-6574ITBF.mjs";
25
- import "./chunk-3MY6LO7N.mjs";
21
+ import "./chunk-MZ76AA76.mjs";
26
22
  import {
27
- tabs_default
28
- } from "./chunk-DW3BX4M2.mjs";
23
+ skeleton_default
24
+ } from "./chunk-6PN3DGOE.mjs";
29
25
  import "./chunk-DX3KXNP6.mjs";
30
26
  import {
31
27
  definition_table_default
32
28
  } from "./chunk-DS5CGU2X.mjs";
33
29
  import {
34
30
  table_default
35
- } from "./chunk-PX4RCHOE.mjs";
36
- import "./chunk-MZ76AA76.mjs";
31
+ } from "./chunk-DWW4ZESK.mjs";
32
+ import "./chunk-RRAZM5D3.mjs";
37
33
  import {
38
- skeleton_default
39
- } from "./chunk-6PN3DGOE.mjs";
34
+ textarea_default
35
+ } from "./chunk-3CRSSRCH.mjs";
36
+ import "./chunk-OLQOLLKG.mjs";
37
+ import {
38
+ starRating_default
39
+ } from "./chunk-XTS6WKFD.mjs";
40
40
  import "./chunk-LVFI2NOH.mjs";
41
41
  import {
42
42
  switch_default
43
43
  } from "./chunk-AGE57VDD.mjs";
44
- import "./chunk-OLQOLLKG.mjs";
44
+ import "./chunk-3MY6LO7N.mjs";
45
45
  import {
46
- starRating_default
47
- } from "./chunk-INRA6IED.mjs";
46
+ tabs_default
47
+ } from "./chunk-DW3BX4M2.mjs";
48
48
  import "./chunk-TPFN22HR.mjs";
49
49
  import {
50
50
  radio_default
@@ -55,12 +55,6 @@ import {
55
55
  } from "./chunk-WLTBJF4I.mjs";
56
56
  import "./chunk-F3HENRVM.mjs";
57
57
  import "./chunk-4VWG4726.mjs";
58
- import {
59
- datePicker_default
60
- } from "./chunk-NJFJJIWK.mjs";
61
- import {
62
- day_default
63
- } from "./chunk-XZYQFBCT.mjs";
64
58
  import {
65
59
  timePicker_default
66
60
  } from "./chunk-BM3MR3JR.mjs";
@@ -68,7 +62,13 @@ import "./chunk-QCEKPS7U.mjs";
68
62
  import {
69
63
  select_default
70
64
  } from "./chunk-5G6CCE55.mjs";
65
+ import {
66
+ datePicker_default
67
+ } from "./chunk-W66K4FK5.mjs";
71
68
  import "./chunk-FWFEKWWD.mjs";
69
+ import {
70
+ day_default
71
+ } from "./chunk-XZYQFBCT.mjs";
72
72
  import "./chunk-7MVEAQ7Z.mjs";
73
73
  import {
74
74
  list_default
@@ -80,18 +80,18 @@ import "./chunk-DJOG6Z35.mjs";
80
80
  import {
81
81
  modal_default
82
82
  } from "./chunk-SCQCMQDP.mjs";
83
- import "./chunk-MGEWSREV.mjs";
84
- import {
85
- chip_default
86
- } from "./chunk-2B3HDC26.mjs";
87
83
  import "./chunk-32GA3YW4.mjs";
88
84
  import {
89
85
  drawer_default
90
86
  } from "./chunk-45Y7ANPK.mjs";
87
+ import "./chunk-QZ3LVYJW.mjs";
88
+ import {
89
+ checkbox_default
90
+ } from "./chunk-OEIEALIP.mjs";
91
91
  import "./chunk-RLXOHILK.mjs";
92
92
  import {
93
93
  fileUpload_default
94
- } from "./chunk-OOX5X2MN.mjs";
94
+ } from "./chunk-W7MZB2KA.mjs";
95
95
  import "./chunk-7VOQKIIK.mjs";
96
96
  import {
97
97
  progress_default
@@ -118,10 +118,10 @@ import {
118
118
  import {
119
119
  radarChart_default
120
120
  } from "./chunk-U7SYKG2C.mjs";
121
- import "./chunk-QZ3LVYJW.mjs";
121
+ import "./chunk-MGEWSREV.mjs";
122
122
  import {
123
- checkbox_default
124
- } from "./chunk-OEIEALIP.mjs";
123
+ chip_default
124
+ } from "./chunk-2B3HDC26.mjs";
125
125
  import "./chunk-SE5TU755.mjs";
126
126
  import {
127
127
  backdrop_default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/ui",
3
- "version": "0.1.164",
3
+ "version": "0.1.166",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  pagination_default
4
4
  } from "./chunk-WLTBJF4I.mjs";
5
- import {
6
- scrollArea_default
7
- } from "./chunk-EWS3FESG.mjs";
8
5
  import {
9
6
  checkbox_default
10
7
  } from "./chunk-OEIEALIP.mjs";
8
+ import {
9
+ scrollArea_default
10
+ } from "./chunk-EWS3FESG.mjs";
11
11
  import {
12
12
  mapPropsVariants
13
13
  } from "./chunk-E3G5QXSH.mjs";
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import {
3
- day_default
4
- } from "./chunk-XZYQFBCT.mjs";
5
2
  import {
6
3
  formatDateToString,
7
4
  formatStringToDate
8
5
  } from "./chunk-FWFEKWWD.mjs";
6
+ import {
7
+ day_default
8
+ } from "./chunk-XZYQFBCT.mjs";
9
9
  import {
10
10
  input_default
11
11
  } from "./chunk-VNRGOOSY.mjs";