@dust-tt/sparkle 0.2.267 → 0.2.268-rc-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +199 -592
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +1 -1
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Checkbox.d.ts +9 -20
- package/dist/esm/components/Checkbox.d.ts.map +1 -1
- package/dist/esm/components/Checkbox.js +56 -43
- package/dist/esm/components/Checkbox.js.map +1 -1
- package/dist/esm/components/DropdownMenu.d.ts.map +1 -1
- package/dist/esm/components/DropdownMenu.js +1 -1
- package/dist/esm/components/DropdownMenu.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +1 -1
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/Popover.d.ts +2 -1
- package/dist/esm/components/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover.js +2 -2
- package/dist/esm/components/Popover.js.map +1 -1
- package/dist/esm/components/Tooltip.d.ts +2 -1
- package/dist/esm/components/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip.js +2 -2
- package/dist/esm/components/Tooltip.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -2
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/Checkbox.stories.d.ts +10 -4
- package/dist/esm/stories/Checkbox.stories.d.ts.map +1 -1
- package/dist/esm/stories/Checkbox.stories.js +51 -26
- package/dist/esm/stories/Checkbox.stories.js.map +1 -1
- package/dist/esm/stories/Tree.stories.d.ts.map +1 -1
- package/dist/esm/stories/Tree.stories.js +76 -37
- package/dist/esm/stories/Tree.stories.js.map +1 -1
- package/dist/sparkle.css +61 -37
- package/package.json +1 -3
- package/src/components/Button.tsx +6 -1
- package/src/components/Checkbox.tsx +103 -87
- package/src/components/DropdownMenu.tsx +1 -0
- package/src/components/IconButton.tsx +1 -0
- package/src/components/Popover.tsx +3 -2
- package/src/components/Tooltip.tsx +8 -2
- package/src/components/index.ts +1 -6
- package/src/stories/Checkbox.stories.tsx +87 -44
- package/src/stories/Tree.stories.tsx +76 -37
package/dist/sparkle.css
CHANGED
|
@@ -904,10 +904,6 @@ select {
|
|
|
904
904
|
margin-top: -0.5rem;
|
|
905
905
|
}
|
|
906
906
|
|
|
907
|
-
.-s-mt-px {
|
|
908
|
-
margin-top: -1px;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
907
|
.s-mb-0 {
|
|
912
908
|
margin-bottom: 0px;
|
|
913
909
|
}
|
|
@@ -1900,6 +1896,11 @@ select {
|
|
|
1900
1896
|
border-color: rgb(103 232 249 / var(--tw-border-opacity));
|
|
1901
1897
|
}
|
|
1902
1898
|
|
|
1899
|
+
.s-border-element-600 {
|
|
1900
|
+
--tw-border-opacity: 1;
|
|
1901
|
+
border-color: rgb(148 163 184 / var(--tw-border-opacity));
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1903
1904
|
.s-border-emerald-100 {
|
|
1904
1905
|
--tw-border-opacity: 1;
|
|
1905
1906
|
border-color: rgb(209 250 229 / var(--tw-border-opacity));
|
|
@@ -2020,11 +2021,6 @@ select {
|
|
|
2020
2021
|
border-color: rgb(249 168 212 / var(--tw-border-opacity));
|
|
2021
2022
|
}
|
|
2022
2023
|
|
|
2023
|
-
.s-border-primary-500 {
|
|
2024
|
-
--tw-border-opacity: 1;
|
|
2025
|
-
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
2024
|
.s-border-purple-100 {
|
|
2029
2025
|
--tw-border-opacity: 1;
|
|
2030
2026
|
border-color: rgb(243 232 255 / var(--tw-border-opacity));
|
|
@@ -2413,6 +2409,11 @@ select {
|
|
|
2413
2409
|
background-color: rgb(203 213 225 / var(--tw-bg-opacity));
|
|
2414
2410
|
}
|
|
2415
2411
|
|
|
2412
|
+
.s-bg-element-700 {
|
|
2413
|
+
--tw-bg-opacity: 1;
|
|
2414
|
+
background-color: rgb(100 116 139 / var(--tw-bg-opacity));
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2416
2417
|
.s-bg-emerald-100 {
|
|
2417
2418
|
--tw-bg-opacity: 1;
|
|
2418
2419
|
background-color: rgb(209 250 229 / var(--tw-bg-opacity));
|
|
@@ -3713,10 +3714,6 @@ select {
|
|
|
3713
3714
|
color: rgb(16 185 129 / var(--tw-text-opacity));
|
|
3714
3715
|
}
|
|
3715
3716
|
|
|
3716
|
-
.s-text-current {
|
|
3717
|
-
color: currentColor;
|
|
3718
|
-
}
|
|
3719
|
-
|
|
3720
3717
|
.s-text-cyan-700 {
|
|
3721
3718
|
--tw-text-opacity: 1;
|
|
3722
3719
|
color: rgb(14 116 144 / var(--tw-text-opacity));
|
|
@@ -4162,6 +4159,10 @@ select {
|
|
|
4162
4159
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
4163
4160
|
}
|
|
4164
4161
|
|
|
4162
|
+
.s-text-white\/0 {
|
|
4163
|
+
color: rgb(255 255 255 / 0);
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4165
4166
|
.s-text-white\/50 {
|
|
4166
4167
|
color: rgb(255 255 255 / 0.5);
|
|
4167
4168
|
}
|
|
@@ -4297,10 +4298,6 @@ select {
|
|
|
4297
4298
|
--tw-ring-color: rgb(254 202 202 / var(--tw-ring-opacity));
|
|
4298
4299
|
}
|
|
4299
4300
|
|
|
4300
|
-
.s-ring-offset-background {
|
|
4301
|
-
--tw-ring-offset-color: #fff;
|
|
4302
|
-
}
|
|
4303
|
-
|
|
4304
4301
|
.s-brightness-90 {
|
|
4305
4302
|
--tw-brightness: brightness(.9);
|
|
4306
4303
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
@@ -4408,6 +4405,10 @@ select {
|
|
|
4408
4405
|
transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
|
|
4409
4406
|
}
|
|
4410
4407
|
|
|
4408
|
+
.s-ease-in-out {
|
|
4409
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4411
4412
|
.s-ease-out {
|
|
4412
4413
|
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
4413
4414
|
}
|
|
@@ -4477,6 +4478,10 @@ select {
|
|
|
4477
4478
|
animation-timing-function: cubic-bezier(0.4, 0, 1, 1);
|
|
4478
4479
|
}
|
|
4479
4480
|
|
|
4481
|
+
.s-ease-in-out {
|
|
4482
|
+
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
4483
|
+
}
|
|
4484
|
+
|
|
4480
4485
|
.s-ease-out {
|
|
4481
4486
|
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
4482
4487
|
}
|
|
@@ -4611,6 +4616,11 @@ select {
|
|
|
4611
4616
|
background-color: rgb(219 234 254 / var(--tw-bg-opacity));
|
|
4612
4617
|
}
|
|
4613
4618
|
|
|
4619
|
+
.hover\:s-bg-action-200:hover {
|
|
4620
|
+
--tw-bg-opacity: 1;
|
|
4621
|
+
background-color: rgb(191 219 254 / var(--tw-bg-opacity));
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4614
4624
|
.hover\:s-bg-action-400:hover {
|
|
4615
4625
|
--tw-bg-opacity: 1;
|
|
4616
4626
|
background-color: rgb(96 165 250 / var(--tw-bg-opacity));
|
|
@@ -4671,6 +4681,10 @@ select {
|
|
|
4671
4681
|
color: rgb(248 113 113 / var(--tw-text-opacity));
|
|
4672
4682
|
}
|
|
4673
4683
|
|
|
4684
|
+
.hover\:s-text-white\/100:hover {
|
|
4685
|
+
color: rgb(255 255 255 / 1);
|
|
4686
|
+
}
|
|
4687
|
+
|
|
4674
4688
|
.hover\:s-brightness-110:hover {
|
|
4675
4689
|
--tw-brightness: brightness(1.1);
|
|
4676
4690
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
@@ -4981,31 +4995,11 @@ select {
|
|
|
4981
4995
|
pointer-events: none;
|
|
4982
4996
|
}
|
|
4983
4997
|
|
|
4984
|
-
.data-\[state\=checked\]\:s-bg-action-500[data-state=checked] {
|
|
4985
|
-
--tw-bg-opacity: 1;
|
|
4986
|
-
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
4987
|
-
}
|
|
4988
|
-
|
|
4989
|
-
.data-\[state\=checked\]\:s-bg-muted-foreground[data-state=checked] {
|
|
4990
|
-
--tw-bg-opacity: 1;
|
|
4991
|
-
background-color: rgb(100 116 139 / var(--tw-bg-opacity));
|
|
4992
|
-
}
|
|
4993
|
-
|
|
4994
4998
|
.data-\[disabled\]\:s-text-primary-400[data-disabled] {
|
|
4995
4999
|
--tw-text-opacity: 1;
|
|
4996
5000
|
color: rgb(96 165 250 / var(--tw-text-opacity));
|
|
4997
5001
|
}
|
|
4998
5002
|
|
|
4999
|
-
.data-\[state\=checked\]\:s-text-foreground[data-state=checked] {
|
|
5000
|
-
--tw-text-opacity: 1;
|
|
5001
|
-
color: rgb(2 6 23 / var(--tw-text-opacity));
|
|
5002
|
-
}
|
|
5003
|
-
|
|
5004
|
-
.data-\[state\=checked\]\:s-text-white[data-state=checked] {
|
|
5005
|
-
--tw-text-opacity: 1;
|
|
5006
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
5007
|
-
}
|
|
5008
|
-
|
|
5009
5003
|
.data-\[state\=open\]\:s-animate-in[data-state=open] {
|
|
5010
5004
|
animation-name: enter;
|
|
5011
5005
|
animation-duration: 150ms;
|
|
@@ -5068,6 +5062,11 @@ select {
|
|
|
5068
5062
|
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
5069
5063
|
}
|
|
5070
5064
|
|
|
5065
|
+
:is(.s-dark .dark\:s-border-element-500-dark) {
|
|
5066
|
+
--tw-border-opacity: 1;
|
|
5067
|
+
border-color: rgb(100 116 139 / var(--tw-border-opacity));
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5071
5070
|
:is(.s-dark .dark\:s-border-structure-100-dark) {
|
|
5072
5071
|
--tw-border-opacity: 1;
|
|
5073
5072
|
border-color: rgb(30 41 59 / var(--tw-border-opacity));
|
|
@@ -5101,6 +5100,11 @@ select {
|
|
|
5101
5100
|
background-color: rgb(30 58 138 / var(--tw-bg-opacity));
|
|
5102
5101
|
}
|
|
5103
5102
|
|
|
5103
|
+
:is(.s-dark .dark\:s-bg-action-500-dark) {
|
|
5104
|
+
--tw-bg-opacity: 1;
|
|
5105
|
+
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
5106
|
+
}
|
|
5107
|
+
|
|
5104
5108
|
:is(.s-dark .dark\:s-bg-amber-500) {
|
|
5105
5109
|
--tw-bg-opacity: 1;
|
|
5106
5110
|
background-color: rgb(245 158 11 / var(--tw-bg-opacity));
|
|
@@ -5111,6 +5115,16 @@ select {
|
|
|
5111
5115
|
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
5112
5116
|
}
|
|
5113
5117
|
|
|
5118
|
+
:is(.s-dark .dark\:s-bg-element-500-dark) {
|
|
5119
|
+
--tw-bg-opacity: 1;
|
|
5120
|
+
background-color: rgb(100 116 139 / var(--tw-bg-opacity));
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5123
|
+
:is(.s-dark .dark\:s-bg-element-700-dark) {
|
|
5124
|
+
--tw-bg-opacity: 1;
|
|
5125
|
+
background-color: rgb(203 213 225 / var(--tw-bg-opacity));
|
|
5126
|
+
}
|
|
5127
|
+
|
|
5114
5128
|
:is(.s-dark .dark\:s-bg-emerald-500) {
|
|
5115
5129
|
--tw-bg-opacity: 1;
|
|
5116
5130
|
background-color: rgb(16 185 129 / var(--tw-bg-opacity));
|
|
@@ -5275,6 +5289,11 @@ select {
|
|
|
5275
5289
|
border-color: rgb(29 78 216 / var(--tw-border-opacity));
|
|
5276
5290
|
}
|
|
5277
5291
|
|
|
5292
|
+
:is(.s-dark .dark\:hover\:s-border-action-500-dark:hover) {
|
|
5293
|
+
--tw-border-opacity: 1;
|
|
5294
|
+
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
5295
|
+
}
|
|
5296
|
+
|
|
5278
5297
|
:is(.s-dark .dark\:hover\:s-border-action-600-dark:hover) {
|
|
5279
5298
|
--tw-border-opacity: 1;
|
|
5280
5299
|
border-color: rgb(96 165 250 / var(--tw-border-opacity));
|
|
@@ -5285,6 +5304,11 @@ select {
|
|
|
5285
5304
|
border-color: rgb(185 28 28 / var(--tw-border-opacity));
|
|
5286
5305
|
}
|
|
5287
5306
|
|
|
5307
|
+
:is(.s-dark .dark\:hover\:s-bg-action-200-dark:hover) {
|
|
5308
|
+
--tw-bg-opacity: 1;
|
|
5309
|
+
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
|
|
5310
|
+
}
|
|
5311
|
+
|
|
5288
5312
|
:is(.s-dark .dark\:hover\:s-bg-action-400:hover) {
|
|
5289
5313
|
--tw-bg-opacity: 1;
|
|
5290
5314
|
background-color: rgb(96 165 250 / var(--tw-bg-opacity));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dust-tt/sparkle",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.268-rc-1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
|
|
6
6
|
"tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
|
|
@@ -94,7 +94,6 @@
|
|
|
94
94
|
"@emoji-mart/data": "^1.1.2",
|
|
95
95
|
"@emoji-mart/react": "^1.1.1",
|
|
96
96
|
"@headlessui/react": "^1.7.19",
|
|
97
|
-
"@radix-ui/react-checkbox": "^1.1.2",
|
|
98
97
|
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
99
98
|
"@radix-ui/react-label": "^2.1.0",
|
|
100
99
|
"@radix-ui/react-popover": "^1.1.2",
|
|
@@ -102,7 +101,6 @@
|
|
|
102
101
|
"@radix-ui/react-slot": "^1.1.0",
|
|
103
102
|
"@radix-ui/react-tooltip": "^1.1.3",
|
|
104
103
|
"@tanstack/react-table": "^8.13.0",
|
|
105
|
-
"class-variance-authority": "^0.7.0",
|
|
106
104
|
"clsx": "^2.1.1",
|
|
107
105
|
"emoji-mart": "^5.5.2",
|
|
108
106
|
"lottie-react": "^2.4.0",
|
|
@@ -217,7 +217,12 @@ export function Button({
|
|
|
217
217
|
return labelVisible || disabledTooltip ? (
|
|
218
218
|
buttonBase
|
|
219
219
|
) : (
|
|
220
|
-
<Tooltip
|
|
220
|
+
<Tooltip
|
|
221
|
+
trigger={buttonBase}
|
|
222
|
+
label={label}
|
|
223
|
+
side={tooltipPosition}
|
|
224
|
+
tooltipTriggerIsButton
|
|
225
|
+
/>
|
|
221
226
|
);
|
|
222
227
|
}
|
|
223
228
|
|
|
@@ -1,106 +1,122 @@
|
|
|
1
|
-
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
2
|
-
import { cva, VariantProps } from "class-variance-authority";
|
|
3
1
|
import React from "react";
|
|
4
2
|
|
|
5
3
|
import { CheckIcon, DashIcon } from "@sparkle/icons/solid";
|
|
6
|
-
import {
|
|
4
|
+
import { classNames } from "@sparkle/lib/utils";
|
|
7
5
|
|
|
8
6
|
import { Icon } from "./Icon";
|
|
9
|
-
import { Label } from "./Label";
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
cn(
|
|
13
|
-
"s-shrink-0 s-peer s-border s-border-primary-500 s-text-foreground",
|
|
14
|
-
"data-[state=checked]:s-text-white data-[state=checked]:s-text-foreground",
|
|
15
|
-
"focus-visible:s-ring-ring s-ring-offset-background focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2",
|
|
16
|
-
"disabled:s-cursor-not-allowed disabled:s-opacity-50"
|
|
17
|
-
),
|
|
18
|
-
{
|
|
19
|
-
variants: {
|
|
20
|
-
checked: {
|
|
21
|
-
true: "data-[state=checked]:s-bg-action-500",
|
|
22
|
-
partial: "data-[state=checked]:s-bg-muted-foreground",
|
|
23
|
-
false: "",
|
|
24
|
-
},
|
|
25
|
-
size: {
|
|
26
|
-
xs: "s-h-4 s-w-4 s-rounded",
|
|
27
|
-
sm: "s-h-5 s-w-5 s-rounded-md",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
defaultVariants: {
|
|
31
|
-
size: "sm",
|
|
32
|
-
checked: false,
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
type CheckBoxStateType = boolean | "partial";
|
|
8
|
+
export type CheckBoxCheckedStatus = "checked" | "unchecked" | "partial";
|
|
38
9
|
|
|
39
|
-
interface CheckboxProps
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
export interface CheckboxProps {
|
|
11
|
+
variant?: "selectable" | "checkable";
|
|
12
|
+
size?: "xs" | "sm";
|
|
13
|
+
checked?: CheckBoxCheckedStatus;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
onChange: (checked: boolean) => void;
|
|
16
|
+
className?: string;
|
|
46
17
|
}
|
|
47
18
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
19
|
+
export function Checkbox({
|
|
20
|
+
variant = "selectable",
|
|
21
|
+
checked = "unchecked",
|
|
22
|
+
size = "sm",
|
|
23
|
+
onChange,
|
|
24
|
+
className = "",
|
|
25
|
+
disabled,
|
|
26
|
+
}: CheckboxProps) {
|
|
27
|
+
let isChecked: boolean;
|
|
28
|
+
let isPartialChecked: boolean;
|
|
29
|
+
switch (checked) {
|
|
30
|
+
case "checked":
|
|
31
|
+
isChecked = true;
|
|
32
|
+
isPartialChecked = false;
|
|
33
|
+
break;
|
|
34
|
+
case "unchecked":
|
|
35
|
+
isChecked = false;
|
|
36
|
+
isPartialChecked = false;
|
|
37
|
+
break;
|
|
38
|
+
case "partial":
|
|
39
|
+
isChecked = true;
|
|
40
|
+
isPartialChecked = true;
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
throw new Error("Invalid checked prop");
|
|
44
|
+
}
|
|
65
45
|
|
|
66
|
-
|
|
46
|
+
const baseStyleClasses = {
|
|
47
|
+
base: "s-border s-justify-center s-flex s-items-center s-transition-colors s-duration-300 s-ease-out",
|
|
48
|
+
idle: "s-bg-structure-50 s-border-element-600 s-cursor-pointer",
|
|
49
|
+
hover:
|
|
50
|
+
"hover:s-border-action-500 hover:s-bg-action-200 hover:s-text-white/100",
|
|
51
|
+
disabled: "s-bg-structure-0 s-border-structure-300 s-cursor-default",
|
|
52
|
+
dark: {
|
|
53
|
+
base: "dark:s-bg-structure-50-dark dark:s-border-element-500-dark",
|
|
54
|
+
hover:
|
|
55
|
+
"dark:hover:s-border-action-500-dark dark:hover:s-bg-action-200-dark",
|
|
56
|
+
disabled:
|
|
57
|
+
"dark:s-bg-structure-0-dark dark:s-border-structure-300-dark s-cursor-default",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
const baseSizeClasses = {
|
|
62
|
+
xs: "s-w-4 s-h-4 s-rounded",
|
|
63
|
+
sm: "s-w-5 s-h-5 s-rounded-md",
|
|
64
|
+
};
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
const checkedIndicatorClasses = {
|
|
67
|
+
base: "s-transition s-duration-300 s-ease-in-out",
|
|
68
|
+
selected: "s-opacity-100 s-bg-action-500 dark:s-bg-action-500-dark",
|
|
69
|
+
unselected: "s-opacity-0",
|
|
70
|
+
partialChecked: "s-opacity-100 s-bg-element-700 dark:s-bg-element-700-dark",
|
|
71
|
+
disabled: "s-opacity-100 s-bg-element-500 dark:s-bg-element-500-dark",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const sizeStyles = {
|
|
75
|
+
xs: { width: "12px", height: "12px", borderRadius: "2px" },
|
|
76
|
+
sm: { width: "14px", height: "14px", borderRadius: "3px" },
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const combinedBaseClasses = classNames(
|
|
80
|
+
baseStyleClasses.base,
|
|
81
|
+
baseSizeClasses[size],
|
|
82
|
+
isChecked || isPartialChecked ? "s-text-white" : "s-text-white/0",
|
|
83
|
+
disabled ? baseStyleClasses.disabled : baseStyleClasses.idle,
|
|
84
|
+
!disabled ? baseStyleClasses.hover : "",
|
|
85
|
+
disabled ? baseStyleClasses.dark.disabled : baseStyleClasses.dark.base,
|
|
86
|
+
!disabled ? baseStyleClasses.dark.hover : "",
|
|
87
|
+
className
|
|
80
88
|
);
|
|
81
|
-
}
|
|
82
89
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
const combinedCheckedIndicatorClasses = classNames(
|
|
91
|
+
checkedIndicatorClasses.base,
|
|
92
|
+
disabled ? checkedIndicatorClasses.disabled : "",
|
|
93
|
+
isChecked && !isPartialChecked && !disabled
|
|
94
|
+
? checkedIndicatorClasses.selected
|
|
95
|
+
: "",
|
|
96
|
+
isPartialChecked && !disabled ? checkedIndicatorClasses.partialChecked : "",
|
|
97
|
+
!isChecked && !disabled ? checkedIndicatorClasses.unselected : ""
|
|
98
|
+
);
|
|
86
99
|
|
|
87
|
-
function CheckBoxWithTextAndDescription({
|
|
88
|
-
text,
|
|
89
|
-
description,
|
|
90
|
-
...props
|
|
91
|
-
}: CheckboxWithTextAndDescriptionProps) {
|
|
92
100
|
return (
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
<label>
|
|
102
|
+
<input
|
|
103
|
+
type="checkbox"
|
|
104
|
+
checked={isChecked}
|
|
105
|
+
onChange={(e) => onChange && onChange(e.target.checked)}
|
|
106
|
+
className="s-hidden"
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
/>
|
|
109
|
+
<div className={classNames(combinedBaseClasses, "s-relative")}>
|
|
110
|
+
<div
|
|
111
|
+
className={combinedCheckedIndicatorClasses}
|
|
112
|
+
style={sizeStyles[size]}
|
|
113
|
+
/>
|
|
114
|
+
{variant === "checkable" && (
|
|
115
|
+
<div className="s-absolute">
|
|
116
|
+
<Icon visual={isPartialChecked ? DashIcon : CheckIcon} size="xs" />
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
100
119
|
</div>
|
|
101
|
-
</
|
|
120
|
+
</label>
|
|
102
121
|
);
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
export { Checkbox, CheckboxWithText, CheckBoxWithTextAndDescription };
|
|
106
|
-
export type { CheckboxProps };
|
|
@@ -50,13 +50,14 @@ const PopoverContent = React.forwardRef<
|
|
|
50
50
|
|
|
51
51
|
interface PopoverProps extends Omit<PopoverContentProps, "content"> {
|
|
52
52
|
trigger: React.ReactNode;
|
|
53
|
+
popoverTriggerAsChild?: boolean;
|
|
53
54
|
content: React.ReactNode;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
function Popover({ trigger, content, ...props }: PopoverProps) {
|
|
57
|
+
function Popover({ trigger, popoverTriggerAsChild = false, content, ...props }: PopoverProps) {
|
|
57
58
|
return (
|
|
58
59
|
<PopoverRoot>
|
|
59
|
-
<PopoverTrigger>{trigger}</PopoverTrigger>
|
|
60
|
+
<PopoverTrigger asChild={popoverTriggerAsChild}>{trigger}</PopoverTrigger>
|
|
60
61
|
<PopoverContent {...props}>{content}</PopoverContent>
|
|
61
62
|
</PopoverRoot>
|
|
62
63
|
);
|
|
@@ -31,14 +31,20 @@ const TooltipContent = React.forwardRef<
|
|
|
31
31
|
|
|
32
32
|
interface TooltipProps extends TooltipContentProps {
|
|
33
33
|
trigger: React.ReactNode;
|
|
34
|
+
tooltipTriggerIsButton?: boolean;
|
|
34
35
|
label: React.ReactNode;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
function Tooltip({
|
|
38
|
+
function Tooltip({
|
|
39
|
+
trigger,
|
|
40
|
+
tooltipTriggerIsButton = false,
|
|
41
|
+
label,
|
|
42
|
+
...props
|
|
43
|
+
}: TooltipProps) {
|
|
38
44
|
return (
|
|
39
45
|
<TooltipProvider>
|
|
40
46
|
<TooltipRoot>
|
|
41
|
-
<TooltipTrigger>{trigger}</TooltipTrigger>
|
|
47
|
+
<TooltipTrigger asChild={tooltipTriggerIsButton}>{trigger}</TooltipTrigger>
|
|
42
48
|
<TooltipContent {...props}>{label}</TooltipContent>
|
|
43
49
|
</TooltipRoot>
|
|
44
50
|
</TooltipProvider>
|
package/src/components/index.ts
CHANGED
|
@@ -5,12 +5,7 @@ export { BarHeader } from "./BarHeader";
|
|
|
5
5
|
export { Breadcrumbs } from "./Breadcrumbs";
|
|
6
6
|
export { Button } from "./Button";
|
|
7
7
|
export { CardButton } from "./CardButton";
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
10
|
-
Checkbox,
|
|
11
|
-
CheckboxWithText,
|
|
12
|
-
CheckBoxWithTextAndDescription,
|
|
13
|
-
} from "./Checkbox";
|
|
8
|
+
export { Checkbox } from "./Checkbox";
|
|
14
9
|
export { Chip } from "./Chip";
|
|
15
10
|
export { Citation } from "./Citation";
|
|
16
11
|
export { default as CollapseButton } from "./CollapseButton";
|