@indico-data/design-system 3.10.0 → 3.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "3.10.0",
3
+ "version": "3.12.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -14,6 +14,10 @@ The Button component is one of the most versitile components we can use in our D
14
14
 
15
15
  <Controls of={ButtonStories.Default} />
16
16
 
17
+ ## Event Handlers
18
+
19
+ Use the event props to respond to interactions, including `onBlur` for focus loss, `onClick` for activation, `onMouseEnter`/`onMouseExit` for hover changes, and `onKeyDown` for keyboard support.
20
+
17
21
  ## Sizes
18
22
 
19
23
  The Sizes available are small (`xs`), medium (`sm`), large (`md`), and extra large (`lg`). The default size is medium.
@@ -132,6 +132,10 @@ const meta: Meta = {
132
132
  },
133
133
 
134
134
  // Event Handlers
135
+ onBlur: {
136
+ table: { category: 'Event Handlers' },
137
+ action: 'blurred',
138
+ },
135
139
  onClick: {
136
140
  table: { category: 'Event Handlers' },
137
141
  action: 'clicked',
@@ -20,6 +20,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) =>
20
20
  onMouseEnter,
21
21
  onMouseExit,
22
22
  onKeyDown,
23
+ onBlur,
23
24
  className,
24
25
  href,
25
26
  ...rest
@@ -57,6 +58,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) =>
57
58
  onMouseEnter={onMouseEnter}
58
59
  onMouseLeave={onMouseExit}
59
60
  onKeyDown={onKeyDown}
61
+ onBlur={onBlur}
60
62
  {...rest}
61
63
  >
62
64
  {/* Loading Icon on the left (default) */}
@@ -27,6 +27,10 @@ export interface ButtonProps {
27
27
  * The function to call when the mouse exits the button
28
28
  */
29
29
  onMouseExit?: (event: React.MouseEvent<HTMLButtonElement>) => void;
30
+ /**
31
+ * The function to call when the button loses focus
32
+ */
33
+ onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
30
34
  /**
31
35
  * The function to call when the button is clicked
32
36
  */
@@ -34,30 +34,38 @@ const OptionComponent = <OptionType extends SelectOption>({
34
34
  );
35
35
  };
36
36
 
37
- const Select = <OptionType extends SelectOption>({
38
- classNamePrefix = 'select',
39
- className,
40
- components: customComponents,
41
- label,
42
- hasHiddenLabel,
43
- name,
44
- ...props
45
- }: SelectProps<OptionType>) => {
46
- const defaultComponents = {
47
- Option: OptionComponent as React.ComponentType<OptionProps<OptionType>>,
48
- };
37
+ const Select = React.forwardRef(
38
+ <OptionType extends SelectOption>(
39
+ {
40
+ classNamePrefix = 'select',
41
+ className,
42
+ components: customComponents,
43
+ label,
44
+ hasHiddenLabel,
45
+ name,
46
+ ...props
47
+ }: SelectProps<OptionType>,
48
+ ref: React.Ref<any>,
49
+ ) => {
50
+ const defaultComponents = {
51
+ Option: OptionComponent as React.ComponentType<OptionProps<OptionType>>,
52
+ };
49
53
 
50
- const mergedComponents = { ...defaultComponents, ...customComponents };
54
+ const mergedComponents = { ...defaultComponents, ...customComponents };
51
55
 
52
- return (
53
- <ReactSelect
54
- classNamePrefix={classNamePrefix}
55
- className={classNames('select-wrapper', className)}
56
- components={mergedComponents}
57
- {...props}
58
- />
59
- );
60
- };
56
+ return (
57
+ <ReactSelect
58
+ ref={ref}
59
+ classNamePrefix={classNamePrefix}
60
+ className={classNames('select-wrapper', className)}
61
+ components={mergedComponents}
62
+ {...props}
63
+ />
64
+ );
65
+ },
66
+ ) as <OptionType extends SelectOption>(
67
+ props: SelectProps<OptionType> & { ref?: React.Ref<any> },
68
+ ) => React.ReactElement;
61
69
 
62
70
  const LabeledSelect = withLabel(Select);
63
71
 
@@ -1,6 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+
1
3
  export type SelectOption = {
2
4
  label: string;
3
5
  value: string;
4
- detail?: string;
6
+ detail?: ReactNode;
5
7
  [key: string]: any; // Allow for additional properties
6
8
  };