@enonic/ui 0.12.0 → 0.13.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.
@@ -0,0 +1,15 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ export type AvatarImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
3
+ export type AvatarContextValue = {
4
+ imageLoadingStatus: AvatarImageLoadingStatus;
5
+ onImageLoadingStatusChange: (status: AvatarImageLoadingStatus) => void;
6
+ };
7
+ export type AvatarProviderProps = {
8
+ value: AvatarContextValue;
9
+ children?: ReactNode;
10
+ };
11
+ export declare const AvatarProvider: {
12
+ ({ value, children }: AvatarProviderProps): ReactElement;
13
+ displayName: string;
14
+ };
15
+ export declare const useAvatar: () => AvatarContextValue;
@@ -0,0 +1,23 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ export type ComboboxContextValue = {
3
+ baseId: string;
4
+ open: boolean;
5
+ setOpen: (next: boolean) => void;
6
+ closeOnBlur: boolean;
7
+ inputValue: string;
8
+ setInputValue: (value: string) => void;
9
+ selection: readonly string[];
10
+ active?: string;
11
+ keyHandler: (e: React.KeyboardEvent<HTMLElement>) => void;
12
+ disabled?: boolean;
13
+ error?: boolean;
14
+ };
15
+ export type ComboboxProviderProps = {
16
+ value: ComboboxContextValue;
17
+ children?: ReactNode;
18
+ };
19
+ export declare const ComboboxProvider: {
20
+ ({ value, children }: ComboboxProviderProps): ReactElement;
21
+ displayName: string;
22
+ };
23
+ export declare const useCombobox: () => ComboboxContextValue;
@@ -7,4 +7,10 @@ export declare const IdProvider: {
7
7
  ({ children, prefix }: IdProviderProps): ReactElement;
8
8
  displayName: string;
9
9
  };
10
- export declare const usePrefixedId: (providedId?: string) => string;
10
+ /**
11
+ * Prefix provided or generated id with a prefix from the context
12
+ * @param providedId - The id to prefix. Will use `useId()` if not provided.
13
+ * @param prefix - A custom prefix used in addition to the one from context.
14
+ * @returns The prefixed id
15
+ */
16
+ export declare const usePrefixedId: (providedId?: string, prefix?: string) => string;
@@ -1,2 +1,6 @@
1
+ export * from './avatar-provider';
2
+ export * from './combobox-provider';
1
3
  export * from './dialog-provider';
2
4
  export * from './id-provider';
5
+ export * from './listbox-provider';
6
+ export * from './menu-provider';
@@ -0,0 +1,21 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ export type ListboxContextValue = {
3
+ baseId: string;
4
+ active?: string;
5
+ selection: ReadonlySet<string>;
6
+ selectionMode: 'single' | 'multiple';
7
+ disabled?: boolean;
8
+ focusable?: boolean;
9
+ setActive: (id?: string) => void;
10
+ toggleValue: (value: string) => void;
11
+ keyHandler?: (e: React.KeyboardEvent<HTMLElement>) => void;
12
+ };
13
+ export type ListboxProviderProps = {
14
+ value: ListboxContextValue;
15
+ children?: ReactNode;
16
+ };
17
+ export declare const ListboxProvider: {
18
+ ({ value, children }: ListboxProviderProps): ReactElement;
19
+ displayName: string;
20
+ };
21
+ export declare const useListbox: () => ListboxContextValue;
@@ -0,0 +1,20 @@
1
+ import { ReactElement, ReactNode, RefObject } from 'react';
2
+ export type MenuContextValue = {
3
+ open: boolean;
4
+ setOpen: (open: boolean) => void;
5
+ active: string | undefined;
6
+ setActive: (id: string | undefined) => void;
7
+ registerItem: (id: string, disabled?: boolean) => void;
8
+ unregisterItem: (id: string) => void;
9
+ getItems: () => string[];
10
+ isItemDisabled: (id: string) => boolean;
11
+ triggerId: string;
12
+ menuId: string;
13
+ triggerRef: RefObject<HTMLButtonElement> | null;
14
+ };
15
+ export type MenuProviderProps = {
16
+ value: MenuContextValue;
17
+ children?: ReactNode;
18
+ };
19
+ export declare const MenuProvider: ({ value, children }: MenuProviderProps) => ReactElement;
20
+ export declare const useMenu: () => MenuContextValue;
@@ -1,2 +1,3 @@
1
1
  export * from './cn';
2
+ export * from './ref';
2
3
  export * from './unwrap';
@@ -1,3 +1,3 @@
1
1
  import { ForwardedRef, Ref } from 'react';
2
2
  export declare function setRef<T>(ref: Ref<T> | undefined, value: T | null): void;
3
- export declare function useComposedRefs<T>(...refs: (Ref<T> | undefined)[]): ForwardedRef<T>;
3
+ export declare function useComposedRefs<T>(...refs: (Ref<T> | undefined | null)[]): ForwardedRef<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic/ui",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Enonic UI Component Library",
5
5
  "author": "Enonic",
6
6
  "license": "MIT",