@douglasneuroinformatics/libui 2.4.0 → 2.4.1

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.
@@ -8,6 +8,8 @@ type ActionDropdownOptionKey<T> = T extends readonly string[] ? T[number] : T ex
8
8
  } ? Extract<keyof T, string> : never;
9
9
  export type ActionDropdownProps<T extends ActionDropdownOptions> = {
10
10
  align?: DropdownMenuContentProps['align'];
11
+ contentClassName?: string;
12
+ disabled?: boolean;
11
13
  /** Callback function invoked when user clicks an option */
12
14
  onSelection: (option: ActionDropdownOptionKey<T>) => void;
13
15
  /** Either a list of options for the dropdown, or an object with options mapped to custom labels */
@@ -15,7 +17,8 @@ export type ActionDropdownProps<T extends ActionDropdownOptions> = {
15
17
  /** The text content for the dropdown toggle */
16
18
  title: string;
17
19
  triggerClassName?: string;
20
+ widthFull?: boolean;
18
21
  };
19
- export declare function ActionDropdown<const T extends ActionDropdownOptions>({ align, onSelection, options, title, triggerClassName }: ActionDropdownProps<T>): React.JSX.Element;
22
+ export declare function ActionDropdown<const T extends ActionDropdownOptions>({ align, contentClassName, disabled, onSelection, options, title, triggerClassName, widthFull }: ActionDropdownProps<T>): React.JSX.Element;
20
23
  export {};
21
24
  //# sourceMappingURL=ActionDropdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAEvF,KAAK,qBAAqB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,SAAS,MAAM,EAAE,CAAC;AAE3E,KAAK,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,MAAM,EAAE,GACzD,CAAC,CAAC,MAAM,CAAC,GACT,CAAC,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AAC,SAAS,qBAAqB,IAAI;IACjE,KAAK,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAE1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,2DAA2D;IAC3D,WAAW,EAAE,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE1D,oGAAoG;IACpG,OAAO,EAAE,CAAC,CAAC;IAEX,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IAEd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAGF,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,qBAAqB,EAAE,EACpE,KAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,SAAS,EACV,EAAE,mBAAmB,CAAC,CAAC,CAAC,qBA2BxB"}
@@ -2,13 +2,13 @@ import React from 'react';
2
2
  import { DropdownButton } from '../DropdownButton/DropdownButton.js';
3
3
  import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
4
4
  // eslint-disable-next-line react/function-component-definition
5
- export function ActionDropdown({ align = 'start', onSelection, options, title, triggerClassName }) {
5
+ export function ActionDropdown({ align = 'start', contentClassName, disabled, onSelection, options, title, triggerClassName, widthFull }) {
6
6
  const optionKeys = options instanceof Array ? options : Object.keys(options);
7
7
  return (React.createElement(DropdownMenu, null,
8
8
  React.createElement("div", { className: "w-full" },
9
9
  React.createElement(DropdownMenu.Trigger, { asChild: true },
10
- React.createElement(DropdownButton, { className: triggerClassName }, title)),
11
- React.createElement(DropdownMenu.Content, { align: align, style: { width: 'var(--radix-popper-anchor-width)' } },
10
+ React.createElement(DropdownButton, { className: triggerClassName, disabled: disabled }, title)),
11
+ React.createElement(DropdownMenu.Content, { align: align, className: contentClassName, widthFull: widthFull },
12
12
  React.createElement(DropdownMenu.Group, null, optionKeys.map((option) => (React.createElement(DropdownMenu.Item, { key: option, onClick: () => {
13
13
  onSelection(option);
14
14
  } }, Array.isArray(options) ? option : options[option]))))))));
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ChevronDownIcon } from 'lucide-react';
3
3
  import { cn } from '../../utils.js';
4
4
  export const DropdownButton = React.forwardRef(function DropdownButton({ children, className, ...props }, ref) {
5
- return (React.createElement("button", { className: cn('flex h-9 w-full items-center whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', children ? 'justify-between' : 'justify-end', className), ref: ref, type: "button", ...props },
5
+ return (React.createElement("button", { className: cn('flex h-9 w-full items-center gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', children ? 'justify-between' : 'justify-end', className), ref: ref, type: "button", ...props },
6
6
  children,
7
7
  React.createElement(ChevronDownIcon, { className: "h-4 w-4 opacity-50" })));
8
8
  });
@@ -7,12 +7,15 @@ export type ListboxDropdownOption = {
7
7
  export type ListboxDropdownProps<T extends ListboxDropdownOption> = {
8
8
  checkPosition?: 'left' | 'right';
9
9
  className?: string;
10
+ contentClassName?: string;
11
+ disabled?: boolean;
10
12
  options: T[];
11
13
  selected: T[];
12
14
  setSelected: React.Dispatch<React.SetStateAction<T[]>>;
13
15
  title: string;
14
- /** The button variant to use for the dropdown toggle */
16
+ triggerClassName?: string;
15
17
  variant?: ButtonProps['variant'];
18
+ widthFull?: boolean;
16
19
  };
17
- export declare const ListboxDropdown: <T extends ListboxDropdownOption>({ options, selected, setSelected, title }: ListboxDropdownProps<T>) => React.JSX.Element;
20
+ export declare const ListboxDropdown: <T extends ListboxDropdownOption>({ contentClassName, disabled, options, selected, setSelected, title, triggerClassName, widthFull }: ListboxDropdownProps<T>) => React.JSX.Element;
18
21
  //# sourceMappingURL=ListboxDropdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListboxDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/ListboxDropdown/ListboxDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,qBAAqB,IAAI;IAClE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,eAAe,+EAKzB,qBAAqB,CAAC,CAAC,sBAiCzB,CAAC"}
1
+ {"version":3,"file":"ListboxDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/ListboxDropdown/ListboxDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,qBAAqB,IAAI;IAClE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe,wIASzB,qBAAqB,CAAC,CAAC,sBAiCzB,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
+ import { cn } from '../../utils.js';
2
3
  import {} from '../Button/Button.js';
3
4
  import { DropdownButton } from '../DropdownButton/DropdownButton.js';
4
5
  import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
5
- export const ListboxDropdown = ({ options, selected, setSelected, title }) => {
6
+ export const ListboxDropdown = ({ contentClassName, disabled, options, selected, setSelected, title, triggerClassName, widthFull }) => {
6
7
  return (React.createElement(DropdownMenu, null,
7
- React.createElement(DropdownMenu.Trigger, { asChild: true, className: "w-full" },
8
+ React.createElement(DropdownMenu.Trigger, { asChild: true, className: cn('w-full', triggerClassName), disabled: disabled },
8
9
  React.createElement(DropdownButton, null, title)),
9
- React.createElement(DropdownMenu.Content, { widthFull: true, align: "start" }, options.map((option) => {
10
+ React.createElement(DropdownMenu.Content, { align: "start", className: contentClassName, widthFull: widthFull }, options.map((option) => {
10
11
  const checked = Boolean(selected.find((selectedOption) => selectedOption.key === option.key));
11
12
  return (React.createElement(DropdownMenu.CheckboxItem, { checked: checked, className: "flex w-full items-center whitespace-nowrap bg-slate-50 p-2 text-sm hover:bg-slate-200 dark:bg-slate-800 dark:hover:bg-slate-700 ", "data-cy": "select-dropdown-option", key: option.key, onSelect: (event) => {
12
13
  event.preventDefault();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "packageManager": "pnpm@8.15.3",
6
6
  "description": "Generic UI components for DNP projects, built using React and TailwindCSS",
7
7
  "author": {
@@ -16,6 +16,10 @@ type ActionDropdownOptionKey<T> = T extends readonly string[]
16
16
  export type ActionDropdownProps<T extends ActionDropdownOptions> = {
17
17
  align?: DropdownMenuContentProps['align'];
18
18
 
19
+ contentClassName?: string;
20
+
21
+ disabled?: boolean;
22
+
19
23
  /** Callback function invoked when user clicks an option */
20
24
  onSelection: (option: ActionDropdownOptionKey<T>) => void;
21
25
 
@@ -26,24 +30,31 @@ export type ActionDropdownProps<T extends ActionDropdownOptions> = {
26
30
  title: string;
27
31
 
28
32
  triggerClassName?: string;
33
+
34
+ widthFull?: boolean;
29
35
  };
30
36
 
31
37
  // eslint-disable-next-line react/function-component-definition
32
38
  export function ActionDropdown<const T extends ActionDropdownOptions>({
33
39
  align = 'start',
40
+ contentClassName,
41
+ disabled,
34
42
  onSelection,
35
43
  options,
36
44
  title,
37
- triggerClassName
45
+ triggerClassName,
46
+ widthFull
38
47
  }: ActionDropdownProps<T>) {
39
48
  const optionKeys: readonly string[] = options instanceof Array ? options : Object.keys(options);
40
49
  return (
41
50
  <DropdownMenu>
42
51
  <div className="w-full">
43
52
  <DropdownMenu.Trigger asChild>
44
- <DropdownButton className={triggerClassName}>{title}</DropdownButton>
53
+ <DropdownButton className={triggerClassName} disabled={disabled}>
54
+ {title}
55
+ </DropdownButton>
45
56
  </DropdownMenu.Trigger>
46
- <DropdownMenu.Content align={align} style={{ width: 'var(--radix-popper-anchor-width)' }}>
57
+ <DropdownMenu.Content align={align} className={contentClassName} widthFull={widthFull}>
47
58
  <DropdownMenu.Group>
48
59
  {optionKeys.map((option) => (
49
60
  <DropdownMenu.Item
@@ -9,7 +9,7 @@ export const DropdownButton = React.forwardRef<HTMLButtonElement, React.ButtonHT
9
9
  return (
10
10
  <button
11
11
  className={cn(
12
- 'flex h-9 w-full items-center whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
12
+ 'flex h-9 w-full items-center gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
13
13
  children ? 'justify-between' : 'justify-end',
14
14
  className
15
15
  )}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
+ import { cn } from '../../utils.js';
3
4
  import { type ButtonProps } from '../Button/Button.js';
4
5
  import { DropdownButton } from '../DropdownButton/DropdownButton.js';
5
6
  import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
@@ -12,26 +13,33 @@ export type ListboxDropdownOption = {
12
13
  export type ListboxDropdownProps<T extends ListboxDropdownOption> = {
13
14
  checkPosition?: 'left' | 'right';
14
15
  className?: string;
16
+ contentClassName?: string;
17
+ disabled?: boolean;
15
18
  options: T[];
16
19
  selected: T[];
17
20
  setSelected: React.Dispatch<React.SetStateAction<T[]>>;
18
21
  title: string;
19
- /** The button variant to use for the dropdown toggle */
22
+ triggerClassName?: string;
20
23
  variant?: ButtonProps['variant'];
24
+ widthFull?: boolean;
21
25
  };
22
26
 
23
27
  export const ListboxDropdown = <T extends ListboxDropdownOption>({
28
+ contentClassName,
29
+ disabled,
24
30
  options,
25
31
  selected,
26
32
  setSelected,
27
- title
33
+ title,
34
+ triggerClassName,
35
+ widthFull
28
36
  }: ListboxDropdownProps<T>) => {
29
37
  return (
30
38
  <DropdownMenu>
31
- <DropdownMenu.Trigger asChild className="w-full">
39
+ <DropdownMenu.Trigger asChild className={cn('w-full', triggerClassName)} disabled={disabled}>
32
40
  <DropdownButton>{title}</DropdownButton>
33
41
  </DropdownMenu.Trigger>
34
- <DropdownMenu.Content widthFull align="start">
42
+ <DropdownMenu.Content align="start" className={contentClassName} widthFull={widthFull}>
35
43
  {options.map((option) => {
36
44
  const checked = Boolean(selected.find((selectedOption) => selectedOption.key === option.key));
37
45
  return (