@douglasneuroinformatics/libui 2.4.0 → 2.4.2
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/dist/components/ActionDropdown/ActionDropdown.d.ts +4 -1
- package/dist/components/ActionDropdown/ActionDropdown.d.ts.map +1 -1
- package/dist/components/ActionDropdown/ActionDropdown.js +3 -3
- package/dist/components/DropdownButton/DropdownButton.js +1 -1
- package/dist/components/ListboxDropdown/ListboxDropdown.d.ts +5 -2
- package/dist/components/ListboxDropdown/ListboxDropdown.d.ts.map +1 -1
- package/dist/components/ListboxDropdown/ListboxDropdown.js +4 -3
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useTheme.js +3 -3
- package/package.json +1 -1
- package/src/components/ActionDropdown/ActionDropdown.tsx +14 -3
- package/src/components/DropdownButton/DropdownButton.tsx +1 -1
- package/src/components/ListboxDropdown/ListboxDropdown.tsx +12 -4
- package/src/hooks/useTheme.ts +4 -7
|
@@ -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,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GACxB,KAAK,CAAC;AAEZ,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,qBAAqB,IAAI;IACjE,KAAK,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAE1C,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;
|
|
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,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GACxB,KAAK,CAAC;AAEZ,MAAM,MAAM,mBAAmB,CAAC,CAAC,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,
|
|
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
|
-
|
|
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;
|
|
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:
|
|
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, {
|
|
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();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAE1C,eAAe;AACf,QAAA,MAAM,aAAa,EAAE,KAAe,CAAC;AAErC,eAAe;AACf,QAAA,MAAM,eAAe,cAAc,CAAC;AAEpC,eAAe;AACf,QAAA,MAAM,SAAS,UAAU,CAAC;AAE1B,eAAe;AACf,QAAA,MAAM,oBAAoB,iCAAiC,CAAC;AAE5D;;;;;GAKG;AACH,iBAAS,QAAQ,IAAI,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAE1C,eAAe;AACf,QAAA,MAAM,aAAa,EAAE,KAAe,CAAC;AAErC,eAAe;AACf,QAAA,MAAM,eAAe,cAAc,CAAC;AAEpC,eAAe;AACf,QAAA,MAAM,SAAS,UAAU,CAAC;AAE1B,eAAe;AACf,QAAA,MAAM,oBAAoB,iCAAiC,CAAC;AAE5D;;;;;GAKG;AACH,iBAAS,QAAQ,IAAI,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,CA2CjD;AAED,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/hooks/useTheme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
import { isBrowser } from '../utils.js';
|
|
3
3
|
/** @private */
|
|
4
4
|
const DEFAULT_THEME = 'light';
|
|
@@ -52,9 +52,9 @@ function useTheme() {
|
|
|
52
52
|
return () => observer.disconnect();
|
|
53
53
|
}, []);
|
|
54
54
|
// When the user wants to change the theme
|
|
55
|
-
const updateTheme =
|
|
55
|
+
const updateTheme = (theme) => {
|
|
56
56
|
document.documentElement.setAttribute(THEME_ATTRIBUTE, theme);
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
return [theme, updateTheme];
|
|
59
59
|
}
|
|
60
60
|
export { DEFAULT_THEME, SYS_DARK_MEDIA_QUERY, THEME_ATTRIBUTE, THEME_KEY, useTheme };
|
package/package.json
CHANGED
|
@@ -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}
|
|
53
|
+
<DropdownButton className={triggerClassName} disabled={disabled}>
|
|
54
|
+
{title}
|
|
55
|
+
</DropdownButton>
|
|
45
56
|
</DropdownMenu.Trigger>
|
|
46
|
-
<DropdownMenu.Content align={align}
|
|
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
|
-
|
|
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=
|
|
39
|
+
<DropdownMenu.Trigger asChild className={cn('w-full', triggerClassName)} disabled={disabled}>
|
|
32
40
|
<DropdownButton>{title}</DropdownButton>
|
|
33
41
|
</DropdownMenu.Trigger>
|
|
34
|
-
<DropdownMenu.Content
|
|
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 (
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { isBrowser } from '../utils.js';
|
|
4
4
|
|
|
@@ -62,12 +62,9 @@ function useTheme(): readonly [Theme, UpdateTheme] {
|
|
|
62
62
|
}, []);
|
|
63
63
|
|
|
64
64
|
// When the user wants to change the theme
|
|
65
|
-
const updateTheme =
|
|
66
|
-
(theme
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
[document.documentElement]
|
|
70
|
-
);
|
|
65
|
+
const updateTheme = (theme: Theme) => {
|
|
66
|
+
document.documentElement.setAttribute(THEME_ATTRIBUTE, theme);
|
|
67
|
+
};
|
|
71
68
|
|
|
72
69
|
return [theme, updateTheme] as const;
|
|
73
70
|
}
|