Skip to content

Commit 0fe51a0

Browse files
committed
Add missing signals and slots to number-input
Signed-off-by: Zvonimir Fras <[email protected]>
1 parent 2563ed0 commit 0fe51a0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

player/react/src/lib/components/ui-number-input.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { NumberInput } from '@carbon/react';
3-
import { CssClasses } from '../types';
3+
import { CssClasses, SendSignal } from '../types';
44
import { stringToCssClassName } from '../utils';
55
import { commonSlots, slotsDisabled } from '../common-slots';
66

@@ -34,16 +34,31 @@ export interface NumberInputState {
3434

3535
export const type = 'number-input';
3636

37+
export const signals = ['change'];
38+
3739
export const slots = {
3840
...commonSlots,
39-
...slotsDisabled
41+
...slotsDisabled,
42+
value: 'number',
43+
min: 'number',
44+
max: 'number',
45+
step: 'number',
46+
label: 'string',
47+
warnText: 'string',
48+
warn: 'boolean',
49+
hideLavel: 'boolean',
50+
hideSteppers: 'boolean',
51+
readOnly: 'boolean',
52+
invalid: 'boolean',
53+
invalidText: 'string',
54+
allowEmpty: 'boolean'
4055
};
4156

42-
export const UINumberInput = ({ state, setState }: {
57+
export const UINumberInput = ({ state, sendSignal }: {
4358
state: NumberInputState;
4459
setState: (state: any) => void;
4560
setGlobalState: (state: any) => void;
46-
sendSignal: (id: number | string, signal: string) => void;
61+
sendSignal: SendSignal;
4762
}) => {
4863
if (state.type !== 'number-input') {
4964
// eslint-disable-next-line react/jsx-no-useless-fragment
@@ -79,6 +94,6 @@ export const UINumberInput = ({ state, setState }: {
7994
invalidText={state.invalidText}
8095
light={state.light}
8196
allowEmpty={state.allowEmpty}
82-
onChange={(_: any, { value }: any) => setState({ ...state, value })}
97+
onChange={(_: any, { value }: any) => sendSignal(state.id, 'change', [value], { ...state, value })}
8398
className={cssClasses} />;
8499
};

0 commit comments

Comments
 (0)