@ttoss/ui 6.3.2 → 6.4.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/dist/esm/index.js +41 -9
- package/dist/index.d.ts +3 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -755,6 +755,35 @@ import { Radio } from "theme-ui";
|
|
|
755
755
|
// src/components/SegmentedControl.tsx
|
|
756
756
|
import * as React11 from "react";
|
|
757
757
|
import { Box as Box3, Flex as Flex2 } from "theme-ui";
|
|
758
|
+
var variantTokens = {
|
|
759
|
+
primary: {
|
|
760
|
+
selectedBg: "action.background.primary.default",
|
|
761
|
+
selectedColor: "action.text.primary.default",
|
|
762
|
+
unselectedColor: "display.text.primary.default",
|
|
763
|
+
hoverBg: "action.background.muted.default",
|
|
764
|
+
divider: "action.text.primary.default",
|
|
765
|
+
thumb: "action.background.primary.default",
|
|
766
|
+
border: "display.border.primary.default"
|
|
767
|
+
},
|
|
768
|
+
secondary: {
|
|
769
|
+
selectedBg: "action.background.secondary.default",
|
|
770
|
+
selectedColor: "action.text.secondary.default",
|
|
771
|
+
unselectedColor: "display.text.secondary.default",
|
|
772
|
+
hoverBg: "action.background.muted.default",
|
|
773
|
+
divider: "action.text.secondary.default",
|
|
774
|
+
thumb: "action.background.secondary.default",
|
|
775
|
+
border: "display.border.muted.default"
|
|
776
|
+
},
|
|
777
|
+
accent: {
|
|
778
|
+
selectedBg: "action.background.accent.default",
|
|
779
|
+
selectedColor: "action.text.accent.default",
|
|
780
|
+
unselectedColor: "action.text.accent.default",
|
|
781
|
+
hoverBg: "action.background.muted.default",
|
|
782
|
+
divider: "action.text.accent.default",
|
|
783
|
+
thumb: "action.background.accent.default",
|
|
784
|
+
border: "display.border.primary.default"
|
|
785
|
+
}
|
|
786
|
+
};
|
|
758
787
|
var SegmentedControl = /* @__PURE__ */__name(({
|
|
759
788
|
options,
|
|
760
789
|
value: propValue,
|
|
@@ -762,6 +791,7 @@ var SegmentedControl = /* @__PURE__ */__name(({
|
|
|
762
791
|
onChange,
|
|
763
792
|
disabled,
|
|
764
793
|
className,
|
|
794
|
+
variant = "accent",
|
|
765
795
|
sx,
|
|
766
796
|
...rest
|
|
767
797
|
}) => {
|
|
@@ -784,13 +814,15 @@ var SegmentedControl = /* @__PURE__ */__name(({
|
|
|
784
814
|
} : option;
|
|
785
815
|
});
|
|
786
816
|
const currentValue = propValue !== void 0 ? propValue : internalValue;
|
|
817
|
+
const tokens = variantTokens[variant];
|
|
787
818
|
return /* @__PURE__ */React11.createElement(Flex2, {
|
|
788
819
|
className,
|
|
820
|
+
"data-variant": variant,
|
|
789
821
|
sx: {
|
|
790
822
|
width: "100%",
|
|
791
823
|
borderRadius: "4xl",
|
|
792
824
|
border: "sm",
|
|
793
|
-
borderColor:
|
|
825
|
+
borderColor: tokens.border,
|
|
794
826
|
overflow: "hidden",
|
|
795
827
|
position: "relative",
|
|
796
828
|
".rc-segmented": {
|
|
@@ -817,7 +849,7 @@ var SegmentedControl = /* @__PURE__ */__name(({
|
|
|
817
849
|
display: "flex",
|
|
818
850
|
alignItems: "center",
|
|
819
851
|
justifyContent: "center",
|
|
820
|
-
color:
|
|
852
|
+
color: tokens.unselectedColor,
|
|
821
853
|
flex: "1 1 auto",
|
|
822
854
|
minWidth: "min-content",
|
|
823
855
|
whiteSpace: "nowrap",
|
|
@@ -828,28 +860,28 @@ var SegmentedControl = /* @__PURE__ */__name(({
|
|
|
828
860
|
cursor: "pointer",
|
|
829
861
|
"&:focus": {
|
|
830
862
|
outline: "2px solid",
|
|
831
|
-
outlineColor:
|
|
863
|
+
outlineColor: tokens.selectedBg,
|
|
832
864
|
outlineOffset: "2px",
|
|
833
865
|
boxShadow: "0 0 0 1px rgba(0, 0, 0, 0.1)"
|
|
834
866
|
},
|
|
835
867
|
"&:focus-visible": {
|
|
836
868
|
outline: "2px solid",
|
|
837
|
-
outlineColor:
|
|
869
|
+
outlineColor: tokens.selectedBg,
|
|
838
870
|
outlineOffset: "2px"
|
|
839
871
|
},
|
|
840
872
|
"&:hover:not(.rc-segmented-item-selected)": {
|
|
841
|
-
backgroundColor:
|
|
873
|
+
backgroundColor: tokens.hoverBg
|
|
842
874
|
},
|
|
843
875
|
'input[type="radio"]': {
|
|
844
876
|
display: "none"
|
|
845
877
|
}
|
|
846
878
|
},
|
|
847
879
|
".rc-segmented-item-selected": {
|
|
848
|
-
backgroundColor:
|
|
849
|
-
color:
|
|
880
|
+
backgroundColor: tokens.selectedBg,
|
|
881
|
+
color: tokens.selectedColor
|
|
850
882
|
},
|
|
851
883
|
".rc-segmented-thumb": {
|
|
852
|
-
backgroundColor:
|
|
884
|
+
backgroundColor: tokens.thumb,
|
|
853
885
|
borderRadius: "4xl",
|
|
854
886
|
zIndex: -1,
|
|
855
887
|
margin: 0,
|
|
@@ -903,7 +935,7 @@ var SegmentedControl = /* @__PURE__ */__name(({
|
|
|
903
935
|
sx: {
|
|
904
936
|
height: "60%",
|
|
905
937
|
width: "1px",
|
|
906
|
-
backgroundColor:
|
|
938
|
+
backgroundColor: tokens.divider,
|
|
907
939
|
opacity: 0.4,
|
|
908
940
|
alignSelf: "center",
|
|
909
941
|
zIndex: 3
|
package/dist/index.d.ts
CHANGED
|
@@ -165,8 +165,10 @@ interface SegmentedControlProps {
|
|
|
165
165
|
disabled?: boolean;
|
|
166
166
|
className?: string;
|
|
167
167
|
sx?: FlexProps['sx'];
|
|
168
|
+
/** Visual variant that maps to theme color tokens */
|
|
169
|
+
variant?: 'primary' | 'secondary' | 'accent';
|
|
168
170
|
}
|
|
169
|
-
declare const SegmentedControl: ({ options, value: propValue, defaultValue, onChange, disabled, className, sx, ...rest }: SegmentedControlProps) => react_jsx_runtime.JSX.Element;
|
|
171
|
+
declare const SegmentedControl: ({ options, value: propValue, defaultValue, onChange, disabled, className, variant, sx, ...rest }: SegmentedControlProps) => react_jsx_runtime.JSX.Element;
|
|
170
172
|
|
|
171
173
|
/**
|
|
172
174
|
* We're using React Select component to build ttoss Select.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react": "^19.2.1",
|
|
46
46
|
"tsup": "^8.5.1",
|
|
47
47
|
"@ttoss/config": "^1.35.12",
|
|
48
|
-
"@ttoss/
|
|
49
|
-
"@ttoss/
|
|
48
|
+
"@ttoss/test-utils": "^4.0.2",
|
|
49
|
+
"@ttoss/react-icons": "^0.5.6"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"React",
|