pallote-react 0.16.12 → 0.16.14

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,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;
8
- subtitle?: string;
9
+ titleComponent?: CardHeaderTitleComponent;
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 {};
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';
@@ -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 }) => {
@@ -981,6 +981,15 @@ const NavBar = ({ logo, align, className, children, ...props }) => {
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
  {
@@ -988,7 +997,7 @@ const NavBar = ({ logo, align, className, children, ...props }) => {
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 }) => {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.12",
3
+ "version": "0.16.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.12",
3
+ "version": "0.16.14",
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.7"
27
+ "pallote-css": "^0.10.9"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@chromatic-com/storybook": "^3.2.4",