Skip to content

Commit 492ebb6

Browse files
committed
added ComboBox, Dropdown, NumberInput, ToggleButton
1 parent 75e1cbc commit 492ebb6

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

packages/core/src/combo-box/ComboBox.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
useFocus,
88
useInteractions,
99
} from "@floating-ui/react";
10+
import { useInjectedClassName } from "@salt-ds/styles";
1011
import { clsx } from "clsx";
1112
import {
1213
type ChangeEvent,
@@ -63,13 +64,22 @@ export type ComboBoxProps<Item = string> = {
6364

6465
const withBaseName = makePrefixer("saltComboBox");
6566

67+
declare module "@salt-ds/core" {
68+
interface ComponentPropMap {
69+
ComboBox: ComboBoxProps;
70+
}
71+
}
72+
6673
export const ComboBox = forwardRef(function ComboBox<Item>(
6774
props: ComboBoxProps<Item>,
6875
ref: ForwardedRef<HTMLDivElement>,
6976
) {
77+
const { className, props: finalProps } = useInjectedClassName(
78+
"saltComboBox",
79+
props,
80+
);
7081
const {
7182
children,
72-
className,
7383
disabled: disabledProp,
7484
endAdornment: endAdornmentProp,
7585
readOnly: readOnlyProp,
@@ -95,7 +105,7 @@ export const ComboBox = forwardRef(function ComboBox<Item>(
95105
bordered = false,
96106
OverlayProps,
97107
...rest
98-
} = props;
108+
} = finalProps;
99109

100110
const { CollapseIcon, ExpandIcon } = useIcon();
101111
const {

packages/core/src/dropdown/Dropdown.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
useFocus,
88
useInteractions,
99
} from "@floating-ui/react";
10-
import { useComponentCssInjection } from "@salt-ds/styles";
10+
import {
11+
useComponentCssInjection,
12+
useInjectedClassName,
13+
} from "@salt-ds/styles";
1114
import { useWindow } from "@salt-ds/window";
1215
import { clsx } from "clsx";
1316
import {
@@ -114,15 +117,24 @@ function ExpandIcon({ open }: { open: boolean }) {
114117
);
115118
}
116119

120+
declare module "@salt-ds/core" {
121+
interface ComponentPropMap {
122+
Dropdown: DropdownProps;
123+
}
124+
}
125+
117126
export const Dropdown = forwardRef(function Dropdown<Item>(
118127
props: DropdownProps<Item>,
119128
ref: ForwardedRef<HTMLButtonElement>,
120129
) {
130+
const { className, props: finalProps } = useInjectedClassName(
131+
"saltDropdown",
132+
props,
133+
);
121134
const {
122135
"aria-labelledby": ariaLabelledBy,
123136
"aria-describedby": ariaDescribedBy,
124137
children,
125-
className,
126138
disabled: disabledProp,
127139
emptyReadOnlyMarker = "—",
128140
readOnly: readOnlyProp,
@@ -146,7 +158,7 @@ export const Dropdown = forwardRef(function Dropdown<Item>(
146158
bordered = false,
147159
OverlayProps,
148160
...rest
149-
} = props;
161+
} = finalProps;
150162

151163
const targetWindow = useWindow();
152164
useComponentCssInjection({

packages/core/src/number-input/NumberInput.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { useComponentCssInjection } from "@salt-ds/styles";
1+
import {
2+
useComponentCssInjection,
3+
useInjectedClassName,
4+
} from "@salt-ds/styles";
25
import { useWindow } from "@salt-ds/window";
36
import { clsx } from "clsx";
47
import {
@@ -267,12 +270,21 @@ const defaultParse = (value: string, decimalScale: number): number | null => {
267270
return Number.parseFloat(floatString);
268271
};
269272

273+
declare module "@salt-ds/core" {
274+
interface ComponentPropMap {
275+
NumberInput: NumberInputProps;
276+
}
277+
}
278+
270279
export const NumberInput = forwardRef<HTMLDivElement, NumberInputProps>(
271-
function NumberInput(
272-
{
280+
function NumberInput(props, ref) {
281+
const { className, props: finalProps } = useInjectedClassName(
282+
"saltNumberInput",
283+
props,
284+
);
285+
const {
273286
"aria-valuetext": ariaValueTextProp,
274287
bordered,
275-
className,
276288
clamp,
277289
step = 1,
278290
stepMultiplier = 2,
@@ -307,9 +319,7 @@ export const NumberInput = forwardRef<HTMLDivElement, NumberInputProps>(
307319
validationStatus: validationStatusProp,
308320
variant = "primary",
309321
...restProps
310-
},
311-
ref,
312-
) {
322+
} = finalProps;
313323
const targetWindow = useWindow();
314324
useComponentCssInjection({
315325
testId: "salt-number-input",

packages/core/src/toggle-button/ToggleButton.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { useComponentCssInjection } from "@salt-ds/styles";
1+
import {
2+
useComponentCssInjection,
3+
useInjectedClassName,
4+
} from "@salt-ds/styles";
25
import { useWindow } from "@salt-ds/window";
36
import { clsx } from "clsx";
47
import {
@@ -50,12 +53,21 @@ export interface ToggleButtonProps extends ComponentPropsWithoutRef<"button"> {
5053

5154
const withBaseName = makePrefixer("saltToggleButton");
5255

56+
declare module "@salt-ds/core" {
57+
interface ComponentPropMap {
58+
ToggleButton: ToggleButtonProps;
59+
}
60+
}
61+
5362
export const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(
5463
function ToggleButton(props, ref) {
64+
const { className, props: finalProps } = useInjectedClassName(
65+
"saltButton",
66+
props,
67+
);
5568
const {
5669
appearance: appearanceProp,
5770
children,
58-
className,
5971
disabled: disabledProp,
6072
value,
6173
onClick,
@@ -66,7 +78,7 @@ export const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(
6678
defaultSelected,
6779
sentiment: sentimenentProp,
6880
...rest
69-
} = props;
81+
} = finalProps;
7082

7183
const targetWindow = useWindow();
7284
useComponentCssInjection({

0 commit comments

Comments
 (0)