@allxsmith/bestax-bulma 5.67.5 → 5.67.6

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,8 +1,10 @@
1
1
  /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
2
  'use client';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import React from 'react';
4
5
  import { classNames, usePrefixedClassNames, prefixedClassNames } from '../helpers/classNames.js';
5
6
  import { withSubComponents } from '../helpers/withSubComponents.js';
7
+ import { isElementOf } from '../helpers/elementType.js';
6
8
  import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
7
9
  import { useConfig } from '../helpers/Config.js';
8
10
 
@@ -29,7 +31,12 @@ const MessageComponent = ({ className, title, textColor, color, bgColor, size, o
29
31
  });
30
32
  const deleteClass = usePrefixedClassNames('delete');
31
33
  const messageClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
32
- return (jsxs("article", { className: messageClasses, ...rest, "data-testid": "message", children: [(title || onClose) && (jsxs("div", { className: prefixedClassNames(classPrefix, 'message-header'), children: [title && jsx("span", { children: title }), onClose && (jsx("button", { className: deleteClass, "aria-label": "delete", onClick: onClose, type: "button", "data-testid": "message-close" }))] })), children && (jsx("div", { className: prefixedClassNames(classPrefix, 'message-body'), "data-testid": "message-body", children: children }))] }));
34
+ // Built from its parts, the header and body are the article's own
35
+ // children, as Bulma lays them out, so they get no body around them.
36
+ const composed = React.Children.toArray(children).some(child => isElementOf(child, MessageHeader, MessageBody));
37
+ return (jsxs("article", { className: messageClasses, ...rest, "data-testid": "message", children: [(title || onClose) && (jsxs("div", { className: prefixedClassNames(classPrefix, 'message-header'), children: [title && jsx("span", { children: title }), onClose && (jsx("button", { className: deleteClass, "aria-label": "delete", onClick: onClose, type: "button", "data-testid": "message-close" }))] })), composed
38
+ ? children
39
+ : children && (jsx("div", { className: prefixedClassNames(classPrefix, 'message-body'), "data-testid": "message-body", children: children }))] }));
33
40
  };
34
41
  /**
35
42
  * Message header compound component. Renders a `.message-header` element.
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","sources":["../../../src/components/Message.tsx"],"sourcesContent":["import React from 'react';\nimport {\n classNames,\n usePrefixedClassNames,\n prefixedClassNames,\n} from '../helpers/classNames';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport {\n useBulmaClasses,\n BulmaClassesProps,\n validColors,\n} from '../helpers/useBulmaClasses';\nimport { useConfig } from '../helpers/Config';\n\nconst validMessageSizes = ['small', 'medium', 'large'] as const;\n/**\n * Valid size values for the Message component (Bulma message sizes).\n */\nexport type MessageSize = (typeof validMessageSizes)[number];\n\n/**\n * Props for the Message component.\n */\nexport interface MessageProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'title'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'> {\n /** Additional CSS classes. */\n className?: string;\n /** Title string/node (renders header section). */\n title?: React.ReactNode;\n /** Text color for the message (Bulma helper). */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Bulma color modifier for the message. */\n color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';\n /** Background color for the message (Bulma helper). */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Size of the message. */\n size?: MessageSize;\n /** Callback for the close (\"X\") button. */\n onClose?: () => void;\n /** Body content for the message. */\n children?: React.ReactNode;\n}\n\n/**\n * The `Message` component provides Bulma's flexible notice/message box for your Bulma React UI.\n *\n * @function\n * @param {MessageProps} props - Props for the Message component.\n * @returns {JSX.Element} The rendered message.\n * @see {@link https://bulma.io/documentation/components/message/ | Bulma Message documentation}\n */\nconst MessageComponent: React.FC<MessageProps> = ({\n className,\n title,\n textColor,\n color,\n bgColor,\n size,\n onClose,\n children,\n ...props\n}) => {\n const { classPrefix } = useConfig();\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n\n // Generate Bulma classes with prefix\n const bulmaClasses = usePrefixedClassNames('message', {\n [`is-${color}`]: color,\n [`is-${size}`]: size && validMessageSizes.includes(size),\n });\n const deleteClass = usePrefixedClassNames('delete');\n\n const messageClasses = classNames(\n bulmaClasses,\n bulmaHelperClasses,\n className\n );\n\n return (\n <article className={messageClasses} {...rest} data-testid=\"message\">\n {(title || onClose) && (\n <div className={prefixedClassNames(classPrefix, 'message-header')}>\n {title && <span>{title}</span>}\n {onClose && (\n <button\n className={deleteClass}\n aria-label=\"delete\"\n onClick={onClose}\n type=\"button\"\n data-testid=\"message-close\"\n />\n )}\n </div>\n )}\n {children && (\n <div\n className={prefixedClassNames(classPrefix, 'message-body')}\n data-testid=\"message-body\"\n >\n {children}\n </div>\n )}\n </article>\n );\n};\n\n// Compound components for flexible composition\n\n/**\n * Props for the Message.Header compound component.\n */\nexport interface MessageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Additional CSS classes. */\n className?: string;\n /** Header content (title, close button, etc.). */\n children?: React.ReactNode;\n}\n\n/**\n * Props for the Message.Body compound component.\n */\nexport interface MessageBodyProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Additional CSS classes. */\n className?: string;\n /** Message body content. */\n children?: React.ReactNode;\n}\n\n/**\n * Message header compound component. Renders a `.message-header` element.\n *\n * @function\n * @param {MessageHeaderProps} props - Props for the MessageHeader component.\n * @returns {JSX.Element} The rendered message header.\n */\nexport const MessageHeader: React.FC<MessageHeaderProps> = ({\n className,\n children,\n ...props\n}) => (\n <div\n className={classNames(usePrefixedClassNames('message-header'), className)}\n {...props}\n >\n {children}\n </div>\n);\n\n/**\n * Message body compound component. Renders a `.message-body` element.\n *\n * @function\n * @param {MessageBodyProps} props - Props for the MessageBody component.\n * @returns {JSX.Element} The rendered message body.\n */\nexport const MessageBody: React.FC<MessageBodyProps> = ({\n className,\n children,\n ...props\n}) => (\n <div\n className={classNames(usePrefixedClassNames('message-body'), className)}\n {...props}\n >\n {children}\n </div>\n);\n\n// Attach compound components\nexport const Message = withSubComponents(\n MessageComponent,\n {\n Header: MessageHeader,\n Body: MessageBody,\n },\n 'Message'\n);\n\nexport default Message;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAcA,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU;AA+B/D;;;;;;;AAOG;AACH,MAAM,gBAAgB,GAA2B,CAAC,EAChD,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE;AACnC,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACnD,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,eAAe,EAAE,OAAO;AACxB,QAAA,GAAG,KAAK;AACT,KAAA,CAAC;;AAGF,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,SAAS,EAAE;AACpD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK;AACtB,QAAA,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,CAAE,GAAG,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;AACzD,KAAA,CAAC;AACF,IAAA,MAAM,WAAW,GAAG,qBAAqB,CAAC,QAAQ,CAAC;IAEnD,MAAM,cAAc,GAAG,UAAU,CAC/B,YAAY,EACZ,kBAAkB,EAClB,SAAS,CACV;AAED,IAAA,QACEA,IAAA,CAAA,SAAA,EAAA,EAAS,SAAS,EAAE,cAAc,KAAM,IAAI,EAAA,aAAA,EAAc,SAAS,EAAA,QAAA,EAAA,CAChE,CAAC,KAAK,IAAI,OAAO,MAChBA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,CAAC,EAAA,QAAA,EAAA,CAC9D,KAAK,IAAIC,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,KAAK,EAAA,CAAQ,EAC7B,OAAO,KACNA,GAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAE,WAAW,gBACX,QAAQ,EACnB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,QAAQ,iBACD,eAAe,EAAA,CAC3B,CACH,CAAA,EAAA,CACG,CACP,EACA,QAAQ,KACPA,aACE,SAAS,EAAE,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,EAAA,aAAA,EAC9C,cAAc,EAAA,QAAA,EAEzB,QAAQ,GACL,CACP,CAAA,EAAA,CACO;AAEd,CAAC;AAwBD;;;;;;AAMG;AACI,MAAM,aAAa,GAAiC,CAAC,EAC1D,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,MACCA,GAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,UAAU,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,KACrE,KAAK,EAAA,QAAA,EAER,QAAQ,EAAA,CACL;AAGR;;;;;;AAMG;AACI,MAAM,WAAW,GAA+B,CAAC,EACtD,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,MACCA,GAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,UAAU,CAAC,qBAAqB,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,KACnE,KAAK,EAAA,QAAA,EAER,QAAQ,EAAA,CACL;AAGR;AACO,MAAM,OAAO,GAAG,iBAAiB,CACtC,gBAAgB,EAChB;AACE,IAAA,MAAM,EAAE,aAAa;AACrB,IAAA,IAAI,EAAE,WAAW;CAClB,EACD,SAAS;;"}
1
+ {"version":3,"file":"Message.js","sources":["../../../src/components/Message.tsx"],"sourcesContent":["import React from 'react';\nimport {\n classNames,\n usePrefixedClassNames,\n prefixedClassNames,\n} from '../helpers/classNames';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { isElementOf } from '../helpers/elementType';\nimport {\n useBulmaClasses,\n BulmaClassesProps,\n validColors,\n} from '../helpers/useBulmaClasses';\nimport { useConfig } from '../helpers/Config';\n\nconst validMessageSizes = ['small', 'medium', 'large'] as const;\n/**\n * Valid size values for the Message component (Bulma message sizes).\n */\nexport type MessageSize = (typeof validMessageSizes)[number];\n\n/**\n * Props for the Message component.\n */\nexport interface MessageProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'title'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'> {\n /** Additional CSS classes. */\n className?: string;\n /** Title string/node (renders header section). */\n title?: React.ReactNode;\n /** Text color for the message (Bulma helper). */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Bulma color modifier for the message. */\n color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';\n /** Background color for the message (Bulma helper). */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Size of the message. */\n size?: MessageSize;\n /** Callback for the close (\"X\") button. */\n onClose?: () => void;\n /**\n * Body content for the message, wrapped in a `.message-body`. Children that\n * include a `Message.Header` or `Message.Body` aren't wrapped: they render as\n * the article's own children, after the header `title` and `onClose` make.\n */\n children?: React.ReactNode;\n}\n\n/**\n * The `Message` component provides Bulma's flexible notice/message box for your Bulma React UI.\n *\n * @function\n * @param {MessageProps} props - Props for the Message component.\n * @returns {JSX.Element} The rendered message.\n * @see {@link https://bulma.io/documentation/components/message/ | Bulma Message documentation}\n */\nconst MessageComponent: React.FC<MessageProps> = ({\n className,\n title,\n textColor,\n color,\n bgColor,\n size,\n onClose,\n children,\n ...props\n}) => {\n const { classPrefix } = useConfig();\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n\n // Generate Bulma classes with prefix\n const bulmaClasses = usePrefixedClassNames('message', {\n [`is-${color}`]: color,\n [`is-${size}`]: size && validMessageSizes.includes(size),\n });\n const deleteClass = usePrefixedClassNames('delete');\n\n const messageClasses = classNames(\n bulmaClasses,\n bulmaHelperClasses,\n className\n );\n\n // Built from its parts, the header and body are the article's own\n // children, as Bulma lays them out, so they get no body around them.\n const composed = React.Children.toArray(children).some(child =>\n isElementOf(child, MessageHeader, MessageBody)\n );\n\n return (\n <article className={messageClasses} {...rest} data-testid=\"message\">\n {(title || onClose) && (\n <div className={prefixedClassNames(classPrefix, 'message-header')}>\n {title && <span>{title}</span>}\n {onClose && (\n <button\n className={deleteClass}\n aria-label=\"delete\"\n onClick={onClose}\n type=\"button\"\n data-testid=\"message-close\"\n />\n )}\n </div>\n )}\n {composed\n ? children\n : children && (\n <div\n className={prefixedClassNames(classPrefix, 'message-body')}\n data-testid=\"message-body\"\n >\n {children}\n </div>\n )}\n </article>\n );\n};\n\n// Compound components for flexible composition\n\n/**\n * Props for the Message.Header compound component.\n */\nexport interface MessageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Additional CSS classes. */\n className?: string;\n /** Header content (title, close button, etc.). */\n children?: React.ReactNode;\n}\n\n/**\n * Props for the Message.Body compound component.\n */\nexport interface MessageBodyProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Additional CSS classes. */\n className?: string;\n /** Message body content. */\n children?: React.ReactNode;\n}\n\n/**\n * Message header compound component. Renders a `.message-header` element.\n *\n * @function\n * @param {MessageHeaderProps} props - Props for the MessageHeader component.\n * @returns {JSX.Element} The rendered message header.\n */\nexport const MessageHeader: React.FC<MessageHeaderProps> = ({\n className,\n children,\n ...props\n}) => (\n <div\n className={classNames(usePrefixedClassNames('message-header'), className)}\n {...props}\n >\n {children}\n </div>\n);\n\n/**\n * Message body compound component. Renders a `.message-body` element.\n *\n * @function\n * @param {MessageBodyProps} props - Props for the MessageBody component.\n * @returns {JSX.Element} The rendered message body.\n */\nexport const MessageBody: React.FC<MessageBodyProps> = ({\n className,\n children,\n ...props\n}) => (\n <div\n className={classNames(usePrefixedClassNames('message-body'), className)}\n {...props}\n >\n {children}\n </div>\n);\n\n// Attach compound components\nexport const Message = withSubComponents(\n MessageComponent,\n {\n Header: MessageHeader,\n Body: MessageBody,\n },\n 'Message'\n);\n\nexport default Message;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAeA,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU;AAmC/D;;;;;;;AAOG;AACH,MAAM,gBAAgB,GAA2B,CAAC,EAChD,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE;AACnC,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACnD,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,eAAe,EAAE,OAAO;AACxB,QAAA,GAAG,KAAK;AACT,KAAA,CAAC;;AAGF,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,SAAS,EAAE;AACpD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK;AACtB,QAAA,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,CAAE,GAAG,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;AACzD,KAAA,CAAC;AACF,IAAA,MAAM,WAAW,GAAG,qBAAqB,CAAC,QAAQ,CAAC;IAEnD,MAAM,cAAc,GAAG,UAAU,CAC/B,YAAY,EACZ,kBAAkB,EAClB,SAAS,CACV;;;IAID,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,IAC1D,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,CAAC,CAC/C;IAED,QACEA,IAAA,CAAA,SAAA,EAAA,EAAS,SAAS,EAAE,cAAc,EAAA,GAAM,IAAI,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