@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.
@@ -23,6 +23,10 @@ export interface ButtonProps {
23
23
  * The function to call when the mouse exits the button
24
24
  */
25
25
  onMouseExit?: (event: React.MouseEvent<HTMLButtonElement>) => void;
26
+ /**
27
+ * The function to call when the button loses focus
28
+ */
29
+ onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
26
30
  /**
27
31
  * The function to call when the button is clicked
28
32
  */
@@ -17,5 +17,7 @@ export interface SelectProps<OptionType extends SelectOption> extends ReactSelec
17
17
  /** Event handler for when the selected value changes */
18
18
  onChange?: (newValue: any, actionMeta: any) => void;
19
19
  }
20
- declare const LabeledSelect: React.ForwardRefExoticComponent<SelectProps<SelectOption> & import("../subcomponents/Label").LabelProps & React.RefAttributes<any>>;
20
+ declare const LabeledSelect: React.ForwardRefExoticComponent<Omit<SelectProps<SelectOption> & {
21
+ ref?: React.Ref<any>;
22
+ } & import("../subcomponents/Label").LabelProps, "ref"> & React.RefAttributes<any>>;
21
23
  export { LabeledSelect as Select };
@@ -1,6 +1,7 @@
1
+ import { ReactNode } from 'react';
1
2
  export type SelectOption = {
2
3
  label: string;
3
4
  value: string;
4
- detail?: string;
5
+ detail?: ReactNode;
5
6
  [key: string]: any;
6
7
  };
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { UseFloatingOptions } from '@floating-ui/react-dom';
3
3
  export * from '@floating-ui/react-dom';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ContainerProps, RowProps, ColProps } from 'react-grid-system';
6
- import React$1, { CSSProperties, MouseEventHandler, ReactElement, ReactNode } from 'react';
6
+ import React$1, { CSSProperties, MouseEventHandler, ReactNode, ReactElement } from 'react';
7
7
  import { IDataTableProps, Direction as Direction$1, TableColumn as TableColumn$1 } from 'react-data-table-component';
8
8
  import { CSSObject } from 'styled-components';
9
9
  import { Props as Props$4 } from 'react-select';
@@ -200,7 +200,7 @@ type IconProps = PermafrostComponent & {
200
200
  type SelectOption = {
201
201
  label: string;
202
202
  value: string;
203
- detail?: string;
203
+ detail?: ReactNode;
204
204
  [key: string]: any;
205
205
  };
206
206
 
@@ -281,6 +281,10 @@ interface ButtonProps {
281
281
  * The function to call when the mouse exits the button
282
282
  */
283
283
  onMouseExit?: (event: React.MouseEvent<HTMLButtonElement>) => void;
284
+ /**
285
+ * The function to call when the button loses focus
286
+ */
287
+ onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
284
288
  /**
285
289
  * The function to call when the button is clicked
286
290
  */
@@ -483,7 +487,9 @@ interface SelectProps<OptionType extends SelectOption> extends Props$4<OptionTyp
483
487
  /** Event handler for when the selected value changes */
484
488
  onChange?: (newValue: any, actionMeta: any) => void;
485
489
  }
486
- declare const LabeledSelect: React$1.ForwardRefExoticComponent<SelectProps<SelectOption> & LabelProps & React$1.RefAttributes<any>>;
490
+ declare const LabeledSelect: React$1.ForwardRefExoticComponent<Omit<SelectProps<SelectOption> & {
491
+ ref?: React$1.Ref<any>;
492
+ } & LabelProps, "ref"> & React$1.RefAttributes<any>>;
487
493
 
488
494
  interface DatePickerProps {
489
495
  ref?: React.LegacyRef<HTMLInputElement>;
package/lib/index.esm.js CHANGED
@@ -5042,7 +5042,7 @@ const Icon = (_a) => {
5042
5042
  };
5043
5043
 
5044
5044
  const Button$1 = forwardRef((props, ref) => {
5045
- const { ariaLabel, children, isLoading, isDisabled, variant = 'solid', isPill, iconLeft, iconRight, onClick, type = 'button', size = 'md', onMouseEnter, onMouseExit, onKeyDown, className, href } = props, rest = __rest(props, ["ariaLabel", "children", "isLoading", "isDisabled", "variant", "isPill", "iconLeft", "iconRight", "onClick", "type", "size", "onMouseEnter", "onMouseExit", "onKeyDown", "className", "href"]);
5045
+ const { ariaLabel, children, isLoading, isDisabled, variant = 'solid', isPill, iconLeft, iconRight, onClick, type = 'button', size = 'md', onMouseEnter, onMouseExit, onKeyDown, onBlur, className, href } = props, rest = __rest(props, ["ariaLabel", "children", "isLoading", "isDisabled", "variant", "isPill", "iconLeft", "iconRight", "onClick", "type", "size", "onMouseEnter", "onMouseExit", "onKeyDown", "onBlur", "className", "href"]);
5046
5046
  const buttonClasses = classNames('btn', {
5047
5047
  [`btn--${variant}`]: variant,
5048
5048
  [`btn--${size}`]: size,
@@ -5055,7 +5055,7 @@ const Button$1 = forwardRef((props, ref) => {
5055
5055
  onClick(event);
5056
5056
  }
5057
5057
  };
5058
- return (jsxs("button", Object.assign({ ref: ref, disabled: isLoading || isDisabled, className: buttonClasses, role: "button", onClick: handleOnClick, "aria-label": ariaLabel || 'button', "aria-disabled": isLoading || isDisabled, "aria-busy": isLoading, type: type, onMouseEnter: onMouseEnter, onMouseLeave: onMouseExit, onKeyDown: onKeyDown }, rest, { children: [isLoading && !iconRight && (jsx(Icon, { name: "indico-o", style: { animation: 'spin 1s linear infinite' }, className: children ? 'mr-2' : '', ariaLabel: "Loading...", size: size })), iconLeft && !isLoading && (jsx(Icon, { name: iconLeft, className: children ? 'mr-2' : '', ariaLabel: `${iconLeft} Icon`, size: size })), children, iconRight && !isLoading && (jsx(Icon, { name: iconRight, className: children ? 'ml-2' : '', ariaLabel: `${iconRight} Icon`, size: size })), isLoading && iconRight && (jsx(Icon, { name: "indico-o", style: { animation: 'spin 1s linear infinite' }, className: children ? 'ml-2' : '', ariaLabel: "Loading...", size: size }))] })));
5058
+ return (jsxs("button", Object.assign({ ref: ref, disabled: isLoading || isDisabled, className: buttonClasses, role: "button", onClick: handleOnClick, "aria-label": ariaLabel || 'button', "aria-disabled": isLoading || isDisabled, "aria-busy": isLoading, type: type, onMouseEnter: onMouseEnter, onMouseLeave: onMouseExit, onKeyDown: onKeyDown, onBlur: onBlur }, rest, { children: [isLoading && !iconRight && (jsx(Icon, { name: "indico-o", style: { animation: 'spin 1s linear infinite' }, className: children ? 'mr-2' : '', ariaLabel: "Loading...", size: size })), iconLeft && !isLoading && (jsx(Icon, { name: iconLeft, className: children ? 'mr-2' : '', ariaLabel: `${iconLeft} Icon`, size: size })), children, iconRight && !isLoading && (jsx(Icon, { name: iconRight, className: children ? 'ml-2' : '', ariaLabel: `${iconRight} Icon`, size: size })), isLoading && iconRight && (jsx(Icon, { name: "indico-o", style: { animation: 'spin 1s linear infinite' }, className: children ? 'ml-2' : '', ariaLabel: "Loading...", size: size }))] })));
5059
5059
  });
5060
5060
 
5061
5061
  var l;function r$1(e,t){return e[t]}function i(e=[],t,n=0){return [...e.slice(0,n),t,...e.slice(n)]}function s(e=[],t,n="id"){const o=e.slice(),a=r$1(t,n);return a?o.splice(o.findIndex((e=>r$1(e,n)===a)),1):o.splice(o.findIndex((e=>e===t)),1),o}function d(e){return e.map(((e,t)=>{const n=Object.assign(Object.assign({},e),{sortable:e.sortable||!!e.sortFunction||void 0});return e.id||(n.id=t+1),n}))}function c(e,t){return Math.ceil(e/t)}function g(e,t){return Math.min(e,t)}!function(e){e.ASC="asc",e.DESC="desc";}(l||(l={}));const u=()=>null;function p(e,t=[],n=[]){let o={},a=[...n];return t.length&&t.forEach((t=>{if(!t.when||"function"!=typeof t.when)throw new Error('"when" must be defined in the conditional style object and must be function');t.when(e)&&(o=t.style||{},t.classNames&&(a=[...a,...t.classNames]),"function"==typeof t.style&&(o=t.style(e)||{}));})),{conditionalStyle:o,classNames:a.join(" ")}}function b$1(e,t=[],n="id"){const o=r$1(e,n);return o?t.some((e=>r$1(e,n)===o)):t.some((t=>t===e))}function m(e,t){return t?e.findIndex((e=>h$1(e.id,t))):-1}function h$1(e,t){return e==t}function w$1(e,t){const n=!e.toggleOnSelectedRowsChange;switch(t.type){case"SELECT_ALL_ROWS":{const{keyField:n,rows:o,rowCount:a,mergeSelections:l}=t,r=!e.allSelected,i=!e.toggleOnSelectedRowsChange;if(l){const t=r?[...e.selectedRows,...o.filter((t=>!b$1(t,e.selectedRows,n)))]:e.selectedRows.filter((e=>!b$1(e,o,n)));return Object.assign(Object.assign({},e),{allSelected:r,selectedCount:t.length,selectedRows:t,toggleOnSelectedRowsChange:i})}return Object.assign(Object.assign({},e),{allSelected:r,selectedCount:r?a:0,selectedRows:r?o:[],toggleOnSelectedRowsChange:i})}case"SELECT_SINGLE_ROW":{const{keyField:o,row:a,isSelected:l,rowCount:r,singleSelect:d}=t;return d?l?Object.assign(Object.assign({},e),{selectedCount:0,allSelected:!1,selectedRows:[],toggleOnSelectedRowsChange:n}):Object.assign(Object.assign({},e),{selectedCount:1,allSelected:!1,selectedRows:[a],toggleOnSelectedRowsChange:n}):l?Object.assign(Object.assign({},e),{selectedCount:e.selectedRows.length>0?e.selectedRows.length-1:0,allSelected:!1,selectedRows:s(e.selectedRows,a,o),toggleOnSelectedRowsChange:n}):Object.assign(Object.assign({},e),{selectedCount:e.selectedRows.length+1,allSelected:e.selectedRows.length+1===r,selectedRows:i(e.selectedRows,a),toggleOnSelectedRowsChange:n})}case"SELECT_MULTIPLE_ROWS":{const{keyField:o,selectedRows:a,totalRows:l,mergeSelections:r}=t;if(r){const t=[...e.selectedRows,...a.filter((t=>!b$1(t,e.selectedRows,o)))];return Object.assign(Object.assign({},e),{selectedCount:t.length,allSelected:!1,selectedRows:t,toggleOnSelectedRowsChange:n})}return Object.assign(Object.assign({},e),{selectedCount:a.length,allSelected:a.length===l,selectedRows:a,toggleOnSelectedRowsChange:n})}case"CLEAR_SELECTED_ROWS":{const{selectedRowsFlag:n}=t;return Object.assign(Object.assign({},e),{allSelected:!1,selectedCount:0,selectedRows:[],selectedRowsFlag:n})}case"SORT_CHANGE":{const{sortDirection:o,selectedColumn:a,clearSelectedOnSort:l}=t;return Object.assign(Object.assign(Object.assign({},e),{selectedColumn:a,sortDirection:o,currentPage:1}),l&&{allSelected:!1,selectedCount:0,selectedRows:[],toggleOnSelectedRowsChange:n})}case"CHANGE_PAGE":{const{page:o,paginationServer:a,visibleOnly:l,persistSelectedOnPageChange:r}=t,i=a&&r,s=a&&!r||l;return Object.assign(Object.assign(Object.assign(Object.assign({},e),{currentPage:o}),i&&{allSelected:!1}),s&&{allSelected:!1,selectedCount:0,selectedRows:[],toggleOnSelectedRowsChange:n})}case"CHANGE_ROWS_PER_PAGE":{const{rowsPerPage:n,page:o}=t;return Object.assign(Object.assign({},e),{currentPage:o,rowsPerPage:n})}}}const f=css`
@@ -5816,14 +5816,14 @@ const OptionComponent = (_a) => {
5816
5816
  var props = __rest(_a, []);
5817
5817
  return (jsx(components$1.Option, Object.assign({}, props, { children: jsxs("div", { className: "select__items", children: [jsx("div", { className: "select__item-value", children: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.label }), ((_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.detail) && jsx("div", { className: "select__item-detail", children: (_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.detail })] }) })));
5818
5818
  };
5819
- const Select$1 = (_a) => {
5819
+ const Select$1 = React__default.forwardRef((_a, ref) => {
5820
5820
  var { classNamePrefix = 'select', className, components: customComponents, label, hasHiddenLabel, name } = _a, props = __rest(_a, ["classNamePrefix", "className", "components", "label", "hasHiddenLabel", "name"]);
5821
5821
  const defaultComponents = {
5822
5822
  Option: OptionComponent,
5823
5823
  };
5824
5824
  const mergedComponents = Object.assign(Object.assign({}, defaultComponents), customComponents);
5825
- return (jsx(ReactSelect, Object.assign({ classNamePrefix: classNamePrefix, className: classNames('select-wrapper', className), components: mergedComponents }, props)));
5826
- };
5825
+ return (jsx(ReactSelect, Object.assign({ ref: ref, classNamePrefix: classNamePrefix, className: classNames('select-wrapper', className), components: mergedComponents }, props)));
5826
+ });
5827
5827
  const LabeledSelect = withLabel(Select$1);
5828
5828
 
5829
5829
  /**