@osrd-project/ui-core 0.0.80 → 0.0.83

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.
Files changed (55) hide show
  1. package/dist/components/{inputs/Checkbox → Checkbox}/Checkbox.d.ts +3 -3
  2. package/dist/components/ComboBox/ComboBox.d.ts +34 -0
  3. package/dist/components/Dialog.d.ts +22 -0
  4. package/dist/components/SegmentedControl.d.ts +12 -0
  5. package/dist/components/Select.d.ts +3 -2
  6. package/dist/components/Table/Table.d.ts +15 -0
  7. package/dist/components/Table/tableAmbientThemes.d.ts +22 -0
  8. package/dist/components/{inputs/TextArea.d.ts → TextArea.d.ts} +1 -1
  9. package/dist/hooks/__tests__/useOutsideClick.spec.d.ts +1 -0
  10. package/dist/hooks/useOutsideClick.d.ts +1 -1
  11. package/dist/index.d.ts +18 -14
  12. package/dist/index.esm.js +321 -135
  13. package/dist/index.esm.js.map +1 -1
  14. package/dist/theme.css +436 -258
  15. package/dist/theme.css.map +1 -1
  16. package/package.json +11 -10
  17. package/dist/components/inputs/ComboBox/ComboBox.d.ts +0 -20
  18. package/dist/components/{buttons/Button.d.ts → Button.d.ts} +0 -0
  19. package/dist/components/{inputs/Checkbox → Checkbox}/CheckboxList.d.ts +0 -0
  20. package/dist/components/{inputs/Checkbox → Checkbox}/CheckboxTree.d.ts +1 -1
  21. package/dist/components/{inputs/Checkbox → Checkbox}/__tests__/utils.spec.d.ts +0 -0
  22. package/dist/components/{inputs/Checkbox → Checkbox}/index.d.ts +0 -0
  23. package/dist/components/{inputs/Checkbox → Checkbox}/type.d.ts +0 -0
  24. package/dist/components/{inputs/Checkbox → Checkbox}/utils.d.ts +0 -0
  25. package/dist/components/{inputs/ComboBox → ComboBox}/index.d.ts +0 -0
  26. package/dist/components/{inputs/ComboBox → ComboBox}/useDefaultComboBox.d.ts +0 -0
  27. package/dist/components/{inputs/datePicker → DatePicker}/Calendar.d.ts +0 -0
  28. package/dist/components/{inputs/datePicker → DatePicker}/CalendarPicker.d.ts +0 -0
  29. package/dist/components/{inputs/datePicker → DatePicker}/DatePicker.d.ts +1 -1
  30. package/dist/components/{inputs/datePicker → DatePicker}/__tests__/useCalendar.spec.d.ts +0 -0
  31. package/dist/components/{inputs/datePicker → DatePicker}/__tests__/useCalendarPicker.spec.d.ts +0 -0
  32. package/dist/components/{inputs/datePicker → DatePicker}/__tests__/useDatePicker.spec.d.ts +0 -0
  33. package/dist/components/{inputs/datePicker → DatePicker}/__tests__/utils.spec.d.ts +0 -0
  34. package/dist/components/{inputs/datePicker → DatePicker}/index.d.ts +0 -0
  35. package/dist/components/{inputs/datePicker → DatePicker}/type.d.ts +0 -0
  36. package/dist/components/{inputs/datePicker → DatePicker}/useCalendar.d.ts +0 -0
  37. package/dist/components/{inputs/datePicker → DatePicker}/useCalendarPicker.d.ts +0 -0
  38. package/dist/components/{inputs/datePicker → DatePicker}/useDatePicker.d.ts +1 -1
  39. /package/dist/components/{inputs/datePicker → DatePicker}/utils.d.ts +0 -0
  40. /package/dist/components/{inputs/FieldWrapper.d.ts → FieldWrapper.d.ts} +0 -0
  41. /package/dist/components/{inputs/Hint.d.ts → Hint.d.ts} +0 -0
  42. /package/dist/components/{inputs/Input.d.ts → Input.d.ts} +0 -0
  43. /package/dist/components/{Modal.d.ts → InputModal.d.ts} +0 -0
  44. /package/dist/components/{inputs/InputStatusIcon.d.ts → InputStatusIcon.d.ts} +0 -0
  45. /package/dist/components/{inputs/Label.d.ts → Label.d.ts} +0 -0
  46. /package/dist/components/{inputs/PasswordInput.d.ts → PasswordInput.d.ts} +0 -0
  47. /package/dist/components/{inputs/RadioButton.d.ts → RadioButton.d.ts} +0 -0
  48. /package/dist/components/{inputs/RadioGroup.d.ts → RadioGroup.d.ts} +0 -0
  49. /package/dist/components/{inputs/Slider.d.ts → Slider.d.ts} +0 -0
  50. /package/dist/components/{inputs/StatusMessage.d.ts → StatusMessage.d.ts} +0 -0
  51. /package/dist/components/{inputs/TimePicker.d.ts → TimePicker.d.ts} +0 -0
  52. /package/dist/components/{inputs/TokenInput.d.ts → TokenInput.d.ts} +0 -0
  53. /package/dist/components/{inputs/tolerancePicker → TolerancePicker}/TolerancePicker.d.ts +0 -0
  54. /package/dist/components/{inputs/tolerancePicker → TolerancePicker}/ToleranceRangeGrid.d.ts +0 -0
  55. /package/dist/components/{inputs/tolerancePicker → TolerancePicker}/consts.d.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  import React, { type InputHTMLAttributes } from 'react';
2
- export type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
2
+ export type CheckboxProps = React.PropsWithChildren<Omit<InputHTMLAttributes<HTMLInputElement>, 'children'> & {
3
3
  label?: string;
4
4
  small?: boolean;
5
5
  hint?: string;
6
6
  isIndeterminate?: boolean;
7
- };
8
- declare const Checkbox: ({ label, small, hint, disabled, checked, readOnly, isIndeterminate, onClick, onKeyUp, onBlur, ...rest }: CheckboxProps) => React.JSX.Element;
7
+ }>;
8
+ declare const Checkbox: ({ label, small, hint, disabled, checked, readOnly, isIndeterminate, onClick, children, ...rest }: CheckboxProps) => React.JSX.Element;
9
9
  export default Checkbox;
@@ -0,0 +1,34 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type InputProps } from '../Input';
3
+ export type ComboBoxProps<T> = Omit<InputProps, 'value'> & {
4
+ value?: T;
5
+ suggestions: Array<T>;
6
+ customLabel?: ReactNode;
7
+ numberOfSuggestionsToShow?: number;
8
+ getSuggestionLabel: (option: T) => string;
9
+ onSelectSuggestion: (option: T | undefined) => void;
10
+ resetSuggestions: () => void;
11
+ testIdPrefix?: string;
12
+ renderListElementComponent?: (params: {
13
+ suggestion: T;
14
+ index: number;
15
+ isActive: boolean;
16
+ isSelected: boolean;
17
+ }) => ReactNode;
18
+ renderFooterItem?: () => ReactNode;
19
+ allowCustomValue?: boolean;
20
+ onAddCustomValue?: (value: string) => void;
21
+ addCustomValueLabel?: string;
22
+ };
23
+ /**
24
+ * ComboBox component
25
+ *
26
+ * You can use the hook useDefaultComboBox to get the default behavior.
27
+ * See the stories.
28
+ *
29
+ * When `allowCustomValue` is true, an option appears at the bottom of the dropdown
30
+ * when the typed value doesn't match any existing suggestion.
31
+ * Defocusing without selecting cancels the input.
32
+ */
33
+ declare const ComboBox: <T>({ suggestions, customLabel, numberOfSuggestionsToShow, value, small, getSuggestionLabel, onChange, onSelectSuggestion, resetSuggestions, testIdPrefix, renderListElementComponent, renderFooterItem, allowCustomValue, onAddCustomValue, addCustomValueLabel, ...inputProps }: ComboBoxProps<T>) => React.JSX.Element;
34
+ export default ComboBox;
@@ -0,0 +1,22 @@
1
+ import React, { type DialogHTMLAttributes } from 'react';
2
+ type ModalProps = DialogHTMLAttributes<HTMLDialogElement> & {
3
+ fullscreen?: boolean;
4
+ headerClassname?: string;
5
+ bodyClassname?: string;
6
+ footerClassname?: string;
7
+ header: React.ReactNode;
8
+ footer: React.ReactNode;
9
+ };
10
+ /**
11
+ * Display a styled dialog box.
12
+ * You are in charge of its lifecycle (open & close), this componant just display it.
13
+ *
14
+ * Children must be an array of 3 items, where :
15
+ * - the first one is for the header
16
+ * - the second one is for the content
17
+ * - the last is for the footer
18
+ *
19
+ * NB: Inside header, only title tags have the good style (font weight and size)
20
+ */
21
+ declare const Dialog: ({ children, className, fullscreen, header, headerClassname, footer, footerClassname, bodyClassname, ...dialogProps }: ModalProps) => React.JSX.Element;
22
+ export default Dialog;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export type SegmentedControlProps<T> = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'checked'> & {
3
+ options: Array<T>;
4
+ onChange: (option: T) => void;
5
+ value: T;
6
+ getOptionLabel: (option: T) => string;
7
+ getOptionValue: (option: T) => string;
8
+ getOptionIcon?: (option: T) => React.ReactNode;
9
+ small?: boolean;
10
+ };
11
+ declare const SegmentedControl: <T>({ options, onChange, value, getOptionLabel, getOptionValue, getOptionIcon, small, ...inputProps }: SegmentedControlProps<T>) => React.JSX.Element;
12
+ export default SegmentedControl;
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
- import { type FieldWrapperProps } from './inputs/FieldWrapper';
2
+ import { type FieldWrapperProps } from './FieldWrapper';
3
3
  export type SelectProps<T> = Omit<React.InputHTMLAttributes<HTMLSelectElement>, 'value' | 'onChange'> & Omit<FieldWrapperProps, 'children'> & {
4
4
  options: Array<T>;
5
5
  value?: T;
6
+ dataTestId?: string;
6
7
  getOptionLabel: (option: T) => string;
7
8
  getOptionValue: (option: T) => string;
8
9
  onChange: (option?: T) => void;
9
10
  };
10
- declare const Select: <T>({ id, label, hint, value, options, placeholder, statusWithMessage, required, disabled, narrow, readOnly, small, getOptionLabel, getOptionValue, onChange, ...props }: SelectProps<T>) => React.JSX.Element;
11
+ declare const Select: <T>({ id, label, hint, value, options, placeholder, statusWithMessage, required, disabled, narrow, readOnly, small, getOptionLabel, getOptionValue, onChange, dataTestId, ...props }: SelectProps<T>) => React.JSX.Element;
11
12
  export default Select;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type AmbientVariant } from './tableAmbientThemes';
3
+ interface TableColumn {
4
+ key: string;
5
+ label: string;
6
+ className?: string;
7
+ }
8
+ type TableValue = string | number | boolean | null | undefined;
9
+ interface TableProps {
10
+ columns: Array<TableColumn>;
11
+ data: Array<Record<string, TableValue>>;
12
+ ambientVariant?: AmbientVariant;
13
+ }
14
+ declare const Table: ({ columns, data, ambientVariant }: TableProps) => React.JSX.Element;
15
+ export default Table;
@@ -0,0 +1,22 @@
1
+ export type AmbientVariant = 'A' | 'B' | 'C' | 'D';
2
+ export declare const colors: {
3
+ ambientA5: string;
4
+ ambientA10: string;
5
+ ambientA15: string;
6
+ ambientB5: string;
7
+ ambientB10: string;
8
+ ambientB15: string;
9
+ ambientC5: string;
10
+ ambientC10: string;
11
+ ambientC15: string;
12
+ ambientD5: string;
13
+ ambientD10: string;
14
+ ambientD15: string;
15
+ blackAlpha: string;
16
+ };
17
+ export declare const TABLE_AMBIENT_THEMES: Record<AmbientVariant, {
18
+ mix1: string;
19
+ mix2: string;
20
+ odd: string;
21
+ even: string;
22
+ }>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { type FieldWrapperProps } from './FieldWrapper';
3
3
  export type TextAreaProps = React.InputHTMLAttributes<HTMLTextAreaElement> & Omit<FieldWrapperProps, 'children'>;
4
- declare const TextArea: ({ id, label, value: initialValue, hint, required, disabled, statusWithMessage, maxLength, onChange, onKeyUp, onBlur, ...rest }: TextAreaProps) => React.JSX.Element;
4
+ declare const TextArea: ({ id, label, value, hint, required, disabled, statusWithMessage, maxLength, onChange, onKeyUp, onBlur, ...rest }: TextAreaProps) => React.JSX.Element;
5
5
  export default TextArea;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- declare const useOutsideClick: (ref: React.RefObject<HTMLElement | null>, handler: (event: MouseEvent) => void) => void;
1
+ declare const useOutsideClick: (ref: React.RefObject<HTMLElement | null> | null, handler: (event: MouseEvent) => void) => void;
2
2
  export default useOutsideClick;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,20 @@
1
1
  import './styles/main.css';
2
- export { default as Button, ButtonProps } from './components/buttons/Button';
3
- export { default as ComboBox, type ComboBoxProps, useDefaultComboBox, } from './components/inputs/ComboBox';
4
- export { Checkbox, CheckboxList, CheckboxListProps, CheckboxProps, CheckboxesTree, CheckboxesTreeProps, CheckboxTreeItem, } from './components/inputs/Checkbox';
5
- export { DatePicker, type CalendarSlot, type DatePickerProps, type RangeDatePickerProps, type SingleDatePickerProps, } from './components/inputs/datePicker';
6
- export { default as Input, InputProps } from './components/inputs/Input';
7
- export { default as PasswordInput, PasswordInputProps } from './components/inputs/PasswordInput';
8
- export { default as RadioButton, RadioButtonProps } from './components/inputs/RadioButton';
9
- export { default as RadioGroup, RadioGroupProps } from './components/inputs/RadioGroup';
10
- export { type StatusWithMessage } from './components/inputs/StatusMessage';
2
+ export { default as Button, ButtonProps } from './components/Button';
3
+ export { default as ComboBox, type ComboBoxProps, useDefaultComboBox } from './components/ComboBox';
4
+ export { Checkbox, CheckboxList, CheckboxListProps, CheckboxProps, CheckboxesTree, CheckboxesTreeProps, CheckboxTreeItem, } from './components/Checkbox';
5
+ export { DatePicker, type CalendarSlot, type DatePickerProps, type RangeDatePickerProps, type SingleDatePickerProps, } from './components/DatePicker';
6
+ export { default as Input, InputProps } from './components/Input';
7
+ export { default as PasswordInput, PasswordInputProps } from './components/PasswordInput';
8
+ export { default as RadioButton, RadioButtonProps } from './components/RadioButton';
9
+ export { default as RadioGroup, RadioGroupProps } from './components/RadioGroup';
10
+ export { type StatusWithMessage } from './components/StatusMessage';
11
11
  export { default as Select, SelectProps } from './components/Select';
12
- export { default as TextArea, TextAreaProps } from './components/inputs/TextArea';
13
- export { default as TimePicker, type TimePickerProps } from './components/inputs/TimePicker';
14
- export { default as Slider, SliderProps } from './components/inputs/Slider';
15
- export { default as TolerancePicker, type TolerancePickerProps, type ToleranceValues, } from './components/inputs/tolerancePicker/TolerancePicker';
16
- export { default as TokenInput, TokenInputProps } from './components/inputs/TokenInput';
12
+ export { default as TextArea, TextAreaProps } from './components/TextArea';
13
+ export { default as TimePicker, type TimePickerProps } from './components/TimePicker';
14
+ export { default as Slider, SliderProps } from './components/Slider';
15
+ export { default as TolerancePicker, type TolerancePickerProps, type ToleranceValues, } from './components/TolerancePicker/TolerancePicker';
16
+ export { default as TokenInput, TokenInputProps } from './components/TokenInput';
17
+ export { default as Table } from './components/Table/Table';
18
+ export { default as Dialog } from './components/Dialog';
19
+ export { default as SegmentedControl, SegmentedControlProps } from './components/SegmentedControl';
20
+ export { default as useOutsideClick } from './hooks/useOutsideClick';