notionsoft-ui 1.0.41 → 1.0.42
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/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import CircleLoader from "@/components/notion-ui/circle-loader";
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { CheckIcon } from "lucide-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
export interface CheckboxProps
|
|
7
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
8
|
+
onCheckedChange: (value: boolean) => void;
|
|
9
|
+
checked: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
classNames?: {
|
|
14
|
+
rootDivClassName?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
|
18
|
+
(props, ref: any) => {
|
|
19
|
+
const {
|
|
20
|
+
onCheckedChange,
|
|
21
|
+
checked,
|
|
22
|
+
loading,
|
|
23
|
+
label,
|
|
24
|
+
description,
|
|
25
|
+
className,
|
|
26
|
+
readOnly,
|
|
27
|
+
classNames,
|
|
28
|
+
} = props;
|
|
29
|
+
const { rootDivClassName } = classNames || {};
|
|
30
|
+
|
|
31
|
+
const readOnlyStyle = readOnly && "opacity-40";
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
className={cn(
|
|
36
|
+
"flex items-center space-x-3",
|
|
37
|
+
rootDivClassName,
|
|
38
|
+
readOnlyStyle
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
{loading ? (
|
|
42
|
+
<CircleLoader className="size-4" />
|
|
43
|
+
) : (
|
|
44
|
+
<label className="inline-flex items-center">
|
|
45
|
+
<input
|
|
46
|
+
ref={ref}
|
|
47
|
+
type="checkbox"
|
|
48
|
+
checked={checked}
|
|
49
|
+
onChange={(e) => onCheckedChange(e.target.checked)}
|
|
50
|
+
className={cn("peer sr-only", className)}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<CheckIcon className="size-4 shadow-sm p-px border border-tertiary/60 text-transparent peer-checked:bg-primary peer-checked:text-primary-foreground transition-transform rounded peer-checked:scale-100" />
|
|
54
|
+
</label>
|
|
55
|
+
)}
|
|
56
|
+
|
|
57
|
+
<label className="text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
58
|
+
{label && (
|
|
59
|
+
<h1 className="text-start rtl:text-[18px] ltr:text-[13px] font-semibold">
|
|
60
|
+
{label}
|
|
61
|
+
</h1>
|
|
62
|
+
)}
|
|
63
|
+
{description && (
|
|
64
|
+
<h1 className="text-start rtl:pr-1 rtl:text-[17px] ltr:text-xs pt-0.5 ltr:leading-3.5 rtl:leading-5 text-primary/80">
|
|
65
|
+
{description}
|
|
66
|
+
</h1>
|
|
67
|
+
)}
|
|
68
|
+
</label>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
export default Checkbox;
|
|
@@ -88,12 +88,10 @@ const PageSizeSelect: React.FC<SelectProps> = ({
|
|
|
88
88
|
const cached = await loadFn(paginationKey);
|
|
89
89
|
if (cached) {
|
|
90
90
|
setSelectData((p) => ({ ...p, select: cached }));
|
|
91
|
-
onChange?.(cached.value);
|
|
92
91
|
} else {
|
|
93
92
|
const item = { key: paginationKey, value: "10", option: KEYS.default };
|
|
94
93
|
setSelectData((p) => ({ ...p, select: item }));
|
|
95
94
|
saveFn(paginationKey, item);
|
|
96
|
-
onChange?.("10");
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
loadCache();
|
|
@@ -188,7 +186,7 @@ const PageSizeSelect: React.FC<SelectProps> = ({
|
|
|
188
186
|
<div ref={selectRef} className={cn("w-full", className)}>
|
|
189
187
|
<button
|
|
190
188
|
onClick={() => setSelectData((p) => ({ ...p, isOpen: !p.isOpen }))}
|
|
191
|
-
className="w-full px-
|
|
189
|
+
className="w-full gap-1 text-sm px-2 py-2 border rounded-md flex items-center justify-between bg-card"
|
|
192
190
|
>
|
|
193
191
|
{selectData.select.value || placeholder}
|
|
194
192
|
<ChevronDown
|
|
@@ -252,16 +250,14 @@ const PageSizeSelect: React.FC<SelectProps> = ({
|
|
|
252
250
|
{/* Options */}
|
|
253
251
|
<ul className="max-h-60 overflow-auto">
|
|
254
252
|
{options.length === 0 ? (
|
|
255
|
-
<li className="px-4 py-2 text-center
|
|
256
|
-
{emptyPlaceholder}
|
|
257
|
-
</li>
|
|
253
|
+
<li className="px-4 py-2 text-center">{emptyPlaceholder}</li>
|
|
258
254
|
) : (
|
|
259
255
|
options.map((o) => (
|
|
260
256
|
<li
|
|
261
257
|
key={o.value}
|
|
262
258
|
onClick={() => handleSelect(o.value)}
|
|
263
259
|
className={cn(
|
|
264
|
-
"px-4 py-2 cursor-pointer flex justify-between hover:bg-primary/10",
|
|
260
|
+
"px-4 py-2 text-sm cursor-pointer flex justify-between hover:bg-primary/10",
|
|
265
261
|
selectData.select.value === o.value && "bg-primary/10"
|
|
266
262
|
)}
|
|
267
263
|
>
|
|
@@ -166,9 +166,9 @@ export const SidebarItem = memo(function SidebarItem({
|
|
|
166
166
|
<div
|
|
167
167
|
onClick={handleClick}
|
|
168
168
|
className={cn(
|
|
169
|
-
`grid grid-cols-[1fr_auto] ltr:py-2 rtl:p-1 ltr:pl-2.5 rtl:pr-
|
|
169
|
+
`grid grid-cols-[1fr_auto] ltr:py-2 dark:text-primary/70 rtl:p-1 ltr:pl-2.5 rtl:pr-[7px] ltr:mx-1 rtl:mx-1.5 text-primary items-center rtl:text-lg ltr:text-xs cursor-pointer rounded-md ${
|
|
170
170
|
isActive
|
|
171
|
-
? `bg-tertiary/90 text-card font-semibold`
|
|
171
|
+
? `bg-tertiary/90 text-card dark:text-primary font-semibold`
|
|
172
172
|
: "hover:opacity-75"
|
|
173
173
|
}`
|
|
174
174
|
)}
|