@commercelayer/app-elements 1.8.3 → 1.9.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.
@@ -1,11 +1,20 @@
1
- /// <reference types="react" />
2
- import { type IconProps as PhosphorIconProps } from '@phosphor-icons/react';
1
+ import { type ComponentPropsWithRef } from 'react';
3
2
  import { iconMapping } from './icons';
4
- export interface IconProps extends PhosphorIconProps {
3
+ type IconWeight = 'regular' | 'bold';
4
+ export interface IconProps extends ComponentPropsWithRef<'svg'> {
5
5
  /**
6
6
  * Name of the icon to display
7
7
  */
8
8
  name: keyof typeof iconMapping;
9
+ /**
10
+ * Size in CSS units or a number of pixels.
11
+ */
12
+ size?: string | number;
13
+ /**
14
+ * Weight of the icon
15
+ */
16
+ weight?: IconWeight;
9
17
  }
10
18
  /** `app-elements` provides a subset of [Phosphor Icons](https://phosphoricons.com/) out-of-the-box. */
11
19
  export declare const Icon: React.FC<IconProps>;
20
+ export {};
@@ -1,7 +1,8 @@
1
1
  import * as phosphor from '@phosphor-icons/react';
2
2
  export declare const iconMapping: {
3
- readonly arrowBendDownRight: phosphor.Icon;
4
3
  readonly apps: phosphor.Icon;
4
+ readonly appWindow: phosphor.Icon;
5
+ readonly arrowBendDownRight: phosphor.Icon;
5
6
  readonly arrowCircleDown: phosphor.Icon;
6
7
  readonly arrowClockwise: phosphor.Icon;
7
8
  readonly arrowDown: phosphor.Icon;
@@ -9,6 +10,8 @@ export declare const iconMapping: {
9
10
  readonly arrowsLeftRight: phosphor.Icon;
10
11
  readonly arrowUpRight: phosphor.Icon;
11
12
  readonly asterisk: phosphor.Icon;
13
+ readonly buildings: phosphor.Icon;
14
+ readonly caretDown: phosphor.Icon;
12
15
  readonly caretRight: phosphor.Icon;
13
16
  readonly chatCircle: phosphor.Icon;
14
17
  readonly check: phosphor.Icon;
@@ -20,23 +23,29 @@ export declare const iconMapping: {
20
23
  readonly flag: phosphor.Icon;
21
24
  readonly funnel: phosphor.Icon;
22
25
  readonly github: phosphor.Icon;
26
+ readonly globe: phosphor.Icon;
23
27
  readonly google: phosphor.Icon;
24
28
  readonly home: phosphor.Icon;
25
29
  readonly hourglass: phosphor.Icon;
30
+ readonly lifebuoy: phosphor.Icon;
26
31
  readonly magnifyingGlass: phosphor.Icon;
27
32
  readonly minus: phosphor.Icon;
28
33
  readonly minusCircle: phosphor.Icon;
29
34
  readonly package: phosphor.Icon;
30
35
  readonly pencilSimple: phosphor.Icon;
36
+ readonly plus: phosphor.Icon;
31
37
  readonly printer: phosphor.Icon;
32
38
  readonly pulse: phosphor.Icon;
39
+ readonly puzzle: phosphor.Icon;
33
40
  readonly resources: phosphor.Icon;
34
41
  readonly settings: phosphor.Icon;
35
42
  readonly shoppingBag: phosphor.Icon;
43
+ readonly signOut: phosphor.Icon;
36
44
  readonly team: phosphor.Icon;
37
45
  readonly truck: phosphor.Icon;
38
46
  readonly upload: phosphor.Icon;
39
47
  readonly user: phosphor.Icon;
48
+ readonly userCircle: phosphor.Icon;
40
49
  readonly warning: phosphor.Icon;
41
50
  readonly warningCircle: phosphor.Icon;
42
51
  readonly x: phosphor.Icon;
@@ -9,11 +9,6 @@ export interface PageHeadingProps {
9
9
  * A short text that helps to describe the page
10
10
  */
11
11
  description?: ReactNode;
12
- /**
13
- * Optional callback that will be called when "go back" button is pressed
14
- * If missing, the "go back" button will not be shown
15
- */
16
- onGoBack?: () => void;
17
12
  /**
18
13
  * If `true` removes element vertical paddings
19
14
  */
@@ -26,12 +21,24 @@ export interface PageHeadingProps {
26
21
  * When set, it will render a badge (default as warning variant) above the title
27
22
  */
28
23
  badgeVariant?: BadgeProps['variant'];
24
+ /**
25
+ * When set, it will render a navigation (eg: go back) button on the left side of the first row
26
+ */
27
+ navigationButton?: {
28
+ label: string;
29
+ onClick: () => void;
30
+ /**
31
+ * Button icon
32
+ * @default arrowLeft
33
+ */
34
+ icon?: 'x' | 'arrowLeft';
35
+ };
29
36
  /**
30
37
  * When set, it will render a button on the right side of the first row
31
38
  */
32
39
  actionButton?: React.ReactNode;
33
40
  }
34
- declare function PageHeading({ gap, badgeLabel, onGoBack, title, description, badgeVariant, actionButton, ...rest }: PageHeadingProps): JSX.Element;
41
+ declare function PageHeading({ gap, badgeLabel, navigationButton, title, description, badgeVariant, actionButton, ...rest }: PageHeadingProps): JSX.Element;
35
42
  declare namespace PageHeading {
36
43
  var displayName: string;
37
44
  }
@@ -0,0 +1,5 @@
1
+ import { type FC } from 'react';
2
+ /**
3
+ * This component lets the window scrolls back to top once the window.location.pathname is changed
4
+ */
5
+ export declare const ScrollToTop: FC;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface DropdownProps {
2
+ import { type DropdownMenuProps } from '../../composite/Dropdown/DropdownMenu';
3
+ export interface DropdownProps extends Pick<DropdownMenuProps, 'menuHeader' | 'menuPosition'> {
3
4
  /** The trigger for the dropdown menu. Can be a JSX Element or simply a `string`. */
4
5
  dropdownLabel?: React.ReactNode;
5
6
  /** List of links and actions. You can use a combination of `DropdownItem` and `DropdownDivider` components. */
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,5 @@
1
- /// <reference types="react" />
1
+ import { type FC } from 'react';
2
2
  export interface DropdownDividerProps extends React.HTMLAttributes<HTMLElement> {
3
3
  children?: React.ReactNode;
4
4
  }
5
- export declare function DropdownDivider({ children, ...rest }: DropdownDividerProps): JSX.Element;
6
- export declare namespace DropdownDivider {
7
- var displayName: string;
8
- }
5
+ export declare const DropdownDivider: FC<DropdownDividerProps>;
@@ -1,9 +1,7 @@
1
- /// <reference types="react" />
1
+ import { type IconProps } from '../../atoms/Icon/Icon';
2
+ import { type FC } from 'react';
2
3
  export interface DropdownItemProps extends React.HTMLAttributes<HTMLElement> {
3
4
  label: string;
4
- icon?: React.ReactNode;
5
- }
6
- export declare function DropdownItem({ label, icon, ...rest }: DropdownItemProps): JSX.Element;
7
- export declare namespace DropdownItem {
8
- var displayName: string;
5
+ icon?: IconProps['name'] | 'keep-space';
9
6
  }
7
+ export declare const DropdownItem: FC<DropdownItemProps>;
@@ -1,10 +1,20 @@
1
- /// <reference types="react" />
2
- interface Props extends React.HTMLAttributes<HTMLElement> {
1
+ import { type FC } from 'react';
2
+ export interface DropdownMenuProps extends React.HTMLAttributes<HTMLElement> {
3
+ /** Menu content */
3
4
  children?: React.ReactNode;
5
+ /** Set to `none` to hide the top arrow */
4
6
  arrow?: 'none';
7
+ /** Optional header for the dropdown menu */
8
+ menuHeader?: string;
9
+ /**
10
+ * Opening position of the dropdown menu
11
+ * @default bottom-right
12
+ */
13
+ menuPosition?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
14
+ /**
15
+ * If set, the arrow will be centered when trigger button is smaller than 50px
16
+ * Otherwise it will fallback to a default centering based on 32px trigger button
17
+ */
18
+ parentElementRef?: React.RefObject<HTMLDivElement>;
5
19
  }
6
- export declare function DropdownMenu({ children, arrow, ...rest }: Props): JSX.Element;
7
- export declare namespace DropdownMenu {
8
- var displayName: string;
9
- }
10
- export {};
20
+ export declare const DropdownMenu: FC<DropdownMenuProps>;
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ export interface DropdownSearchProps {
3
+ /**
4
+ * Callback triggered when the user types in the search input.
5
+ * By default, this callback is debounced by 500ms.
6
+ */
7
+ onSearch: (hint: string) => void;
8
+ /**
9
+ * Debounce time in ms for the onSearch callback. Set to 0 to disable debounce.
10
+ * @default 500
11
+ */
12
+ debounceMs?: number;
13
+ /**
14
+ * Placeholder text for the input element
15
+ */
16
+ placeholder?: string;
17
+ /**
18
+ * Enable auto focus on the input element
19
+ */
20
+ autoFocus?: boolean;
21
+ }
22
+ /**
23
+ * This component renders an input as dropdown menu item with debounced `onSearch` callback.
24
+ */
25
+ export declare const DropdownSearch: import("react").ForwardRefExoticComponent<DropdownSearchProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,3 +1,4 @@
1
1
  export { Dropdown, type DropdownProps } from './Dropdown';
2
2
  export { DropdownDivider, type DropdownDividerProps } from './DropdownDivider';
3
3
  export { DropdownItem, type DropdownItemProps } from './DropdownItem';
4
+ export { DropdownSearch, type DropdownSearchProps } from './DropdownSearch';
@@ -1,14 +1,10 @@
1
1
  /// <reference types="react" />
2
- export interface PageErrorProps {
2
+ import { type PageHeadingProps } from '../atoms/PageHeading';
3
+ export interface PageErrorProps extends Pick<PageHeadingProps, 'navigationButton'> {
3
4
  /**
4
5
  * Main page title wrapped in a h1 element
5
6
  */
6
7
  pageTitle?: string;
7
- /**
8
- * Optional callback that will be called when "go back" button is pressed
9
- * If missing, the "go back" button will not be shown
10
- */
11
- onGoBack?: () => void;
12
8
  /**
13
9
  * The name of the error to be show above the detailed message text.
14
10
  * Example: 'Not Found'
@@ -24,7 +20,7 @@ export interface PageErrorProps {
24
20
  */
25
21
  actionButton?: JSX.Element;
26
22
  }
27
- export declare function PageError({ pageTitle, onGoBack, errorName, errorDescription, actionButton, ...rest }: PageErrorProps): JSX.Element;
23
+ export declare function PageError({ pageTitle, navigationButton, errorName, errorDescription, actionButton, ...rest }: PageErrorProps): JSX.Element;
28
24
  export declare namespace PageError {
29
25
  var displayName: string;
30
26
  }
@@ -1,7 +1,7 @@
1
1
  import type { ContainerProps } from '../atoms/Container';
2
2
  import { type PageHeadingProps } from '../atoms/PageHeading';
3
3
  import { type ReactNode } from 'react';
4
- export interface PageLayoutProps extends Pick<PageHeadingProps, 'title' | 'description' | 'onGoBack' | 'actionButton' | 'gap'>, Pick<ContainerProps, 'minHeight'> {
4
+ export interface PageLayoutProps extends Pick<PageHeadingProps, 'title' | 'description' | 'navigationButton' | 'actionButton' | 'gap'>, Pick<ContainerProps, 'minHeight'> {
5
5
  /**
6
6
  * Page content
7
7
  */
@@ -10,8 +10,12 @@ export interface PageLayoutProps extends Pick<PageHeadingProps, 'title' | 'descr
10
10
  * When mode is `test`, it will render a `TEST DATA` Badge to inform user api is working in test mode.
11
11
  */
12
12
  mode?: 'test' | 'live';
13
+ /**
14
+ * Optional prop to enable scroll to top behavior on location change
15
+ */
16
+ scrollToTop?: boolean;
13
17
  }
14
- export declare function PageLayout({ title, description, onGoBack, children, actionButton, mode, gap, minHeight, ...rest }: PageLayoutProps): JSX.Element;
18
+ export declare function PageLayout({ title, description, navigationButton, children, actionButton, mode, gap, minHeight, scrollToTop, ...rest }: PageLayoutProps): JSX.Element;
15
19
  export declare namespace PageLayout {
16
20
  var displayName: string;
17
21
  }
@@ -8,7 +8,7 @@ export declare const ListItemDescription: import('../../atoms/SkeletonTemplate')
8
8
  }>;
9
9
  export declare const ListItemIcon: import('../../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
10
10
  color: "none" | "green" | "orange" | "red" | "gray" | "teal" | "white" | "black" | undefined;
11
- icon: "download" | "package" | "settings" | "x" | "arrowBendDownRight" | "apps" | "arrowCircleDown" | "arrowClockwise" | "arrowDown" | "arrowLeft" | "arrowsLeftRight" | "arrowUpRight" | "asterisk" | "caretRight" | "chatCircle" | "check" | "cloud" | "credentials" | "creditCard" | "eye" | "flag" | "funnel" | "github" | "google" | "home" | "hourglass" | "magnifyingGlass" | "minus" | "minusCircle" | "pencilSimple" | "printer" | "pulse" | "resources" | "shoppingBag" | "team" | "truck" | "upload" | "user" | "warning" | "warningCircle" | "xCircle";
11
+ icon: "download" | "package" | "settings" | "x" | "apps" | "appWindow" | "arrowBendDownRight" | "arrowCircleDown" | "arrowClockwise" | "arrowDown" | "arrowLeft" | "arrowsLeftRight" | "arrowUpRight" | "asterisk" | "buildings" | "caretDown" | "caretRight" | "chatCircle" | "check" | "cloud" | "credentials" | "creditCard" | "eye" | "flag" | "funnel" | "github" | "globe" | "google" | "home" | "hourglass" | "lifebuoy" | "magnifyingGlass" | "minus" | "minusCircle" | "pencilSimple" | "plus" | "printer" | "pulse" | "puzzle" | "resources" | "shoppingBag" | "signOut" | "team" | "truck" | "upload" | "user" | "userCircle" | "warning" | "warningCircle" | "xCircle";
12
12
  delayMs?: number | undefined;
13
13
  isLoading?: boolean | undefined;
14
14
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/app-elements",
3
- "version": "1.8.3",
3
+ "version": "1.9.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [