pallote-react 0.16.13 → 0.16.16

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.
@@ -11,8 +11,8 @@ export interface ButtonProps extends Omit<ComponentPropsWithoutRef<'button'>, 't
11
11
  size?: ButtonSize;
12
12
  color?: ButtonColor;
13
13
  fullWidth?: boolean;
14
- iconLeft?: ReactNode;
15
- iconRight?: ReactNode;
14
+ iconStart?: ReactNode;
15
+ iconEnd?: ReactNode;
16
16
  type?: ButtonType;
17
17
  to?: string;
18
18
  [key: string]: unknown;
@@ -2,7 +2,7 @@ import { HTMLAttributes, ReactNode } from 'react';
2
2
  type CardSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
3
  type CardFill = 'default' | 'paper' | 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
4
4
  type CardDirection = 'portrait' | 'landscape';
5
- type CardAlign = 'left' | 'center' | 'right';
5
+ type CardAlign = 'start' | 'center' | 'end';
6
6
  export interface CardProps extends HTMLAttributes<HTMLDivElement> {
7
7
  size?: CardSize;
8
8
  fill?: CardFill;
@@ -1,12 +1,15 @@
1
1
  import React, { HTMLAttributes, ReactElement } from 'react';
2
+ type CardHeaderTitleComponent = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
2
3
  export interface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {
3
4
  icon?: ReactElement<{
4
5
  className?: string;
5
6
  }>;
6
7
  label?: string;
7
8
  title: string;
9
+ titleComponent?: CardHeaderTitleComponent;
8
10
  subtitle?: React.ReactNode;
9
11
  actions?: React.ReactNode;
10
12
  className?: string;
11
13
  }
12
- export declare const CardHeader: ({ icon, label, title, subtitle, actions, className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const CardHeader: ({ icon, label, title, titleComponent, subtitle, actions, className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -1,11 +1,11 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SectionProps } from './Section';
3
- type NavBarAlign = 'left' | 'right';
3
+ type NavBarAlign = 'start' | 'end';
4
4
  export interface NavBarProps extends Omit<SectionProps, 'children'> {
5
5
  logo?: ReactNode;
6
- align?: NavBarAlign;
6
+ logoPosition?: NavBarAlign;
7
7
  className?: string;
8
8
  children: ReactNode;
9
9
  }
10
- export declare const NavBar: ({ logo, align, className, children, ...props }: NavBarProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const NavBar: ({ logo, logoPosition, className, children, ...props }: NavBarProps) => import("react/jsx-runtime").JSX.Element;
11
11
  export {};
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
- type SectionAlign = 'left' | 'center' | 'right';
2
+ type SectionAlign = 'start' | 'center' | 'end';
3
3
  type SectionColor = 'default' | 'paper' | 'primary' | 'primaryLight';
4
4
  export interface SectionProps extends HTMLAttributes<HTMLDivElement> {
5
5
  align?: SectionAlign;
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
- type SectionContentAlign = 'left' | 'center' | 'right';
2
+ type SectionContentAlign = 'start' | 'center' | 'end';
3
3
  export interface SectionContentProps extends HTMLAttributes<HTMLDivElement> {
4
4
  align?: SectionContentAlign;
5
5
  className?: string;
@@ -6,7 +6,7 @@ export interface SectionHeaderProps extends HTMLAttributes<HTMLDivElement> {
6
6
  titleLevel?: TitleLevel;
7
7
  subtitle?: ReactNode;
8
8
  actions?: ReactNode;
9
- actionsPosition?: 'right' | 'bottom';
9
+ actionsPosition?: 'inline' | 'end';
10
10
  className?: string;
11
11
  }
12
12
  export declare const SectionHeader: ({ label, title, titleLevel, subtitle, actions, actionsPosition, className, ...props }: SectionHeaderProps) => import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as e$9 from 'react';
2
- import e__default, { useState, useEffect, createContext, Children, isValidElement, cloneElement, useContext, useRef, forwardRef, useId, useMemo } from 'react';
2
+ import e__default, { useState, useEffect, createContext, Children, isValidElement, cloneElement, useContext, useRef, forwardRef, useId, useMemo, useCallback } from 'react';
3
3
  import classnames from 'classnames';
4
4
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
5
  import { createPortal } from 'react-dom';
@@ -319,14 +319,14 @@ const Breadcrumbs = ({ items, separator = "slash", className }) => (jsx("nav", {
319
319
  className
320
320
  ]), children: jsx("ol", { children: items.map((item, index) => (jsx("li", { className: 'breadcrumbs_item', children: index === items.length - 1 ? (jsx("p", { "aria-current": "page", children: item.label })) : (jsx("a", { href: item.href, children: item.label })) }, index))) }) }));
321
321
 
322
- const Button = forwardRef(({ component = 'button', kind, variant = 'fill', size = 'md', color = 'primary', fullWidth, disabled, iconLeft, iconRight, className, children = 'button', type = 'button', ...props }, ref) => {
322
+ const Button = forwardRef(({ component = 'button', kind, variant = 'fill', size = 'md', color = 'primary', fullWidth, disabled, iconStart, iconEnd, className, children = 'button', type = 'button', ...props }, ref) => {
323
323
  const Component = component;
324
324
  let content;
325
325
  if (kind === 'icon') {
326
326
  content = children;
327
327
  }
328
328
  else {
329
- content = (jsxs(Fragment, { children: [iconLeft && iconLeft, children, iconRight && iconRight] }));
329
+ content = (jsxs(Fragment, { children: [iconStart && iconStart, children, iconEnd && iconEnd] }));
330
330
  }
331
331
  return (jsx(Component, { className: classnames([
332
332
  'button',
@@ -355,7 +355,7 @@ const Buttons = ({ direction = 'landscape', fullWidth, wide, className, children
355
355
  ]), ...props, children: children }));
356
356
  };
357
357
 
358
- const Card = ({ size = 'md', fill = 'paper', direction = 'portrait', align = 'left', hasShadow = false, transparent = false, className, children, ...props }) => {
358
+ const Card = ({ size = 'md', fill = 'paper', direction = 'portrait', align = 'start', hasShadow = false, transparent = false, className, children, ...props }) => {
359
359
  return (jsx(Color, { fill: transparent ? undefined : fill, children: jsx("div", { className: classnames([
360
360
  'card',
361
361
  {
@@ -389,11 +389,11 @@ const CardContent = ({ fullWidth, className, children, ...props }) => {
389
389
  ]), ...props, children: children }));
390
390
  };
391
391
 
392
- const CardHeader = ({ icon, label, title, subtitle, actions, className, ...props }) => {
392
+ const CardHeader = ({ icon, label, title, titleComponent = 'h3', subtitle, actions, className, ...props }) => {
393
393
  return (jsxs("div", { className: classnames([
394
394
  'card_header',
395
395
  className
396
- ]), ...props, children: [actions && (jsx("div", { className: "card_headerActions", children: actions })), icon ? e__default.cloneElement(icon, { className: `${icon.props.className ?? ''} card_icon` }) : null, label ? (jsx(Text, { className: classnames('card_label'), children: label })) : null, jsx(Text, { className: classnames('card_title'), children: title }), subtitle ? (jsx(Text, { className: classnames('card_subtitle'), children: subtitle })) : null] }));
396
+ ]), ...props, children: [actions && (jsx("div", { className: "card_headerActions", children: actions })), icon ? e__default.cloneElement(icon, { className: `${icon.props.className ?? ''} card_icon` }) : null, label ? (jsx(Text, { className: classnames('card_label'), children: label })) : null, jsx(Text, { component: titleComponent, className: classnames('card_title'), children: title }), subtitle ? (jsx(Text, { className: classnames('card_subtitle'), children: subtitle })) : null] }));
397
397
  };
398
398
 
399
399
  const CardMedia = ({ width, height, image, fullWidth, className, ...props }) => {
@@ -405,7 +405,7 @@ const CardMedia = ({ width, height, image, fullWidth, className, ...props }) =>
405
405
  className
406
406
  ]), ...props, children: jsx("div", { className: 'card_mediaInner', style: {
407
407
  width: width ? width + 'px' : undefined,
408
- paddingBottom: height,
408
+ paddingBlockEnd: height,
409
409
  backgroundImage: `url(${image})`
410
410
  } }) }));
411
411
  };
@@ -911,7 +911,7 @@ const Link = ({ component = 'a', icon, color, isExternal, href, className, child
911
911
  'link',
912
912
  { [`text-${color}`]: color },
913
913
  className
914
- ]), href: isExternal ? href : undefined, target: isExternal ? '_blank' : undefined, rel: isExternal ? 'noopener noreferrer' : undefined, ...props, children: [children, icon && !isExternal && jsx("span", { className: 'link_icon', "aria-hidden": "true", children: icon }), isExternal && (jsxs(Fragment, { children: [jsx("span", { className: "sr-only", children: " (opens in new tab)" }), jsx("span", { className: 'link_icon', "aria-hidden": "true", children: jsx(o$1, {}) })] }))] }));
914
+ ]), href: href, target: isExternal ? '_blank' : undefined, rel: isExternal ? 'noopener noreferrer' : undefined, ...props, children: [children, icon && !isExternal && jsx("span", { className: 'link_icon', "aria-hidden": "true", children: icon }), isExternal && (jsxs(Fragment, { children: [jsx("span", { className: "sr-only", children: " (opens in new tab)" }), jsx("span", { className: 'link_icon', "aria-hidden": "true", children: jsx(o$1, {}) })] }))] }));
915
915
  };
916
916
 
917
917
  const List = ({ dense, className, children, ...props }) => {
@@ -952,10 +952,10 @@ const SectionHeader = ({ label, title, titleLevel = 2, subtitle, actions, action
952
952
  'section_header',
953
953
  `section_header-${titleLevel}`,
954
954
  className
955
- ]), ...props, children: [label ? jsx(Text, { className: classnames('section_label'), children: label }) : null, jsxs("div", { className: "section_titleWrapper", children: [jsx(Text, { className: "section_title", variant: titleVariant, component: titleComponent, children: title }), actions && actionsPosition === 'right' ? (jsx(Display, { hide: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : null] }), subtitle ? jsx("div", { className: classnames('section_subtitle'), children: subtitle }) : null, actions ? (actionsPosition === 'right' ? (jsx(Display, { show: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : (jsx("div", { className: "section_actions", children: actions }))) : null] }));
955
+ ]), ...props, children: [label ? jsx(Text, { className: classnames('section_label'), children: label }) : null, jsxs("div", { className: "section_titleWrapper", children: [jsx(Text, { className: "section_title", variant: titleVariant, component: titleComponent, children: title }), actions && actionsPosition === 'inline' ? (jsx(Display, { hide: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : null] }), subtitle ? jsx("div", { className: classnames('section_subtitle'), children: subtitle }) : null, actions ? (actionsPosition === 'inline' ? (jsx(Display, { show: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : (jsx("div", { className: "section_actions", children: actions }))) : null] }));
956
956
  };
957
957
 
958
- const Section = ({ align = 'left', color = 'default', landing, className, children, ...props }) => {
958
+ const Section = ({ align = 'start', color = 'default', landing, className, children, ...props }) => {
959
959
  return (jsx("div", { className: classnames([
960
960
  'section',
961
961
  {
@@ -975,20 +975,29 @@ const Section = ({ align = 'left', color = 'default', landing, className, childr
975
975
  }) }) }));
976
976
  };
977
977
 
978
- const NavBar = ({ logo, align, className, children, ...props }) => {
978
+ const NavBar = ({ logo, logoPosition, className, children, ...props }) => {
979
979
  const [isOpen, setIsOpen] = useState(false);
980
980
  const toggleNav = () => {
981
981
  setIsOpen(!isOpen);
982
982
  document.body.classList.toggle('js-navbar', !isOpen);
983
983
  };
984
+ const closeNav = useCallback(() => {
985
+ setIsOpen(false);
986
+ document.body.classList.remove('js-navbar');
987
+ }, []);
988
+ const handleNavClick = useCallback((e) => {
989
+ const target = e.target.closest('a, [role="link"]');
990
+ if (target)
991
+ closeNav();
992
+ }, [closeNav]);
984
993
  return (jsx("header", { children: jsxs(Section, { className: classnames([
985
994
  'navbar',
986
995
  {
987
- [`navbar-${align}`]: align,
996
+ [`navbar-${logoPosition}`]: logoPosition,
988
997
  'js-opened': isOpen
989
998
  },
990
999
  className
991
- ]), ...props, children: [jsxs("div", { className: "navbar_main", children: [jsx("div", { className: "navbar_logo", children: logo }), jsx("button", { type: "button", "aria-label": isOpen ? "Close mobile menu" : "Open mobile menu", "aria-expanded": isOpen, "aria-controls": "navbar-nav", className: classnames('navbar_button', { 'js-opened': isOpen }), onClick: toggleNav, children: jsx("span", { "aria-hidden": "true" }) })] }), jsx("nav", { id: "navbar-nav", "aria-label": "Main navigation", className: classnames('navbar_nav nav', { 'js-opened': isOpen }), children: jsx("div", { className: 'nav_container', children: children }) })] }) }));
1000
+ ]), ...props, children: [jsxs("div", { className: "navbar_main", children: [jsx("div", { className: "navbar_logo", children: logo }), jsx("button", { type: "button", "aria-label": isOpen ? "Close mobile menu" : "Open mobile menu", "aria-expanded": isOpen, "aria-controls": "navbar-nav", className: classnames('navbar_button', { 'js-opened': isOpen }), onClick: toggleNav, children: jsx("span", { "aria-hidden": "true" }) })] }), jsx("nav", { id: "navbar-nav", "aria-label": "Main navigation", className: classnames('navbar_nav nav', { 'js-opened': isOpen }), onClick: handleNavClick, children: jsx("div", { className: 'nav_container', children: children }) })] }) }));
992
1001
  };
993
1002
 
994
1003
  const NavItem = ({ component, label, active, dropdown, icon, end, to, className, ...props }) => {
@@ -1054,7 +1063,7 @@ const RadioButtons = ({ id, label = 'Label', direction = 'portrait', error, disa
1054
1063
  ]), children: children })] }));
1055
1064
  };
1056
1065
 
1057
- const SectionContent = ({ align = 'left', className, children, ...props }) => {
1066
+ const SectionContent = ({ align = 'start', className, children, ...props }) => {
1058
1067
  return (jsx("div", { className: classnames([
1059
1068
  'section_content',
1060
1069
  {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.13",
3
+ "version": "0.16.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
2
  type TextVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subtitle' | 'body' | 'caption' | 'overline';
3
- type TextAlign = 'left' | 'center' | 'right' | 'justify';
3
+ type TextAlign = 'start' | 'center' | 'end' | 'justify';
4
4
  type TextWeight = 'regular' | 'bold';
5
5
  type TextTransform = 'none' | 'capitalize' | 'uppercase' | 'lowercase' | 'initial' | 'inherit';
6
6
  type TextColor = 'default' | 'alt' | 'disabled' | 'contrast' | 'contrastAlt' | 'contrastDisabled' | 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.13",
3
+ "version": "0.16.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "classnames": "^2.5.1",
25
25
  "react-syntax-highlighter": "^15.6.1",
26
26
  "sass": "^1.71.1",
27
- "pallote-css": "^0.10.8"
27
+ "pallote-css": "^0.10.11"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@chromatic-com/storybook": "^3.2.4",