@nodeblocks/frontend-hero-block 0.0.2 → 0.1.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.
package/dist/Hero.d.ts CHANGED
@@ -1,30 +1,44 @@
1
- import React from "react";
2
- import "./hero.css";
3
- import { DefaultBlocks, DefaultSettings } from "./blocks";
4
- export interface HeroProps {
5
- /** */
6
- buttonText: string;
7
- /**
8
- * Configures the main byline text to display for this component.
9
- * Supports components to handle inline images and text colors
10
- */
11
- byline: string | React.ReactNode;
12
- /** href for linking Hero */
13
- onClickButton: () => void;
14
- /** URL of the image to show in this hero image component */
15
- imageUrl: string;
16
- /** Screen size to show for this block */
17
- className: string;
18
- /** Show/hide secondary text */
19
- secondaryText?: string | React.ReactNode;
20
- /** Show/hide tertiary text */
21
- tertiaryText?: string | React.ReactNode;
22
- children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {
23
- blocks: {
24
- [x: string]: any;
25
- };
26
- settings?: DefaultSettings;
1
+ import { ComponentProps, ReactNode } from 'react';
2
+ import '@basaldev/blocks-frontend-framework/dist/style.css';
3
+ import './hero.css';
4
+ import { BlocksOverride } from './lib';
5
+ export declare const Hero: {
6
+ <CustomBlocks extends Record<string, ReactNode> = {}>({ onClickButton, buttonText, imageUrl, secondaryText, tertiaryText, byline, className, children, ...props }: Omit<ComponentProps<"div">, "children"> & {
7
+ /** */
8
+ buttonText: string;
9
+ /**
10
+ * Configures the main byline text to display for this component.
11
+ * Supports components to handle inline images and text colors
12
+ */
13
+ byline: ReactNode;
14
+ /** href for linking Hero */
15
+ onClickButton: () => void;
16
+ /** URL of the image to show in this hero image component */
17
+ imageUrl: string;
18
+ /** Show/hide secondary text */
19
+ secondaryText?: ReactNode;
20
+ /** Show/hide tertiary text */
21
+ tertiaryText?: ReactNode;
22
+ children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;
23
+ }): import("react/jsx-runtime").JSX.Element;
24
+ HeroImg({ src, ...props }: Partial<ComponentProps<"img">>): import("react/jsx-runtime").JSX.Element;
25
+ HeroContent: {
26
+ ({ className, ...props }: Partial<ComponentProps<"div">>): import("react/jsx-runtime").JSX.Element;
27
+ HeroByline({ className, children, ...props }: Partial<ComponentProps<"h6">>): import("react/jsx-runtime").JSX.Element;
28
+ SecondaryText({ className, children, ...props }: Partial<ComponentProps<"h3">>): import("react/jsx-runtime").JSX.Element;
29
+ ActionButton({ className, children, onClick, ...props }: Partial<ComponentProps<"button">>): import("react/jsx-runtime").JSX.Element;
30
+ TertiaryText({ className, children, ...props }: Partial<ComponentProps<"span">>): import("react/jsx-runtime").JSX.Element;
27
31
  };
28
- }
29
- export declare const Hero: React.FC<HeroProps>;
32
+ };
33
+ declare const defaultBlocks: {
34
+ heroImg: import("react").ReactElement<Partial<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>>, ({ src, ...props }: Partial<ComponentProps<"img">>) => import("react/jsx-runtime").JSX.Element>;
35
+ heroContent: import("react").ReactElement<Partial<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>, {
36
+ ({ className, ...props }: Partial<ComponentProps<"div">>): import("react/jsx-runtime").JSX.Element;
37
+ HeroByline({ className, children, ...props }: Partial<ComponentProps<"h6">>): import("react/jsx-runtime").JSX.Element;
38
+ SecondaryText({ className, children, ...props }: Partial<ComponentProps<"h3">>): import("react/jsx-runtime").JSX.Element;
39
+ ActionButton({ className, children, onClick, ...props }: Partial<ComponentProps<"button">>): import("react/jsx-runtime").JSX.Element;
40
+ TertiaryText({ className, children, ...props }: Partial<ComponentProps<"span">>): import("react/jsx-runtime").JSX.Element;
41
+ }>;
42
+ };
43
+ export {};
30
44
  //# sourceMappingURL=Hero.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Hero.d.ts","sourceRoot":"","sources":["../src/Hero.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,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nB;;;WAGG;QACH,MAAM,EAAE,SAAS,CAAC;QAClB,4BAA4B;QAC5B,aAAa,EAAE,MAAM,IAAI,CAAC;QAC1B,4DAA4D;QAC5D,QAAQ,EAAE,MAAM,CAAC;QACjB,+BAA+B;QAC/B,aAAa,CAAC,EAAE,SAAS,CAAC;QAC1B,8BAA8B;QAC9B,YAAY,CAAC,EAAE,SAAS,CAAC;QACzB,QAAQ,CAAC,EAAE,cAAc,CAAC,OAAO,aAAa,EAAE,YAAY,CAAC,CAAC;KAC/D;+BA6BkC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;;kCAMnB,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;sDAiBf,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;yDAU1B,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;iEAUrB,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;wDAU1C,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;;CAvD7F,CAAC;AAiEF,QAAA,MAAM,aAAa;iLA/DgB,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;;kCAMnB,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;sDAiBf,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;yDAU1B,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;iEAUrB,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;wDAU1C,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;;CAa5F,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ type HeroContextValue = {
3
+ buttonText: string;
4
+ byline: ReactNode;
5
+ onClickButton: () => void;
6
+ imageUrl: string;
7
+ secondaryText?: ReactNode;
8
+ tertiaryText?: ReactNode;
9
+ };
10
+ export declare const HeroProvider: ({ children, ...value }: HeroContextValue & {
11
+ children: ReactNode;
12
+ }) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const useHeroContext: () => HeroContextValue;
14
+ export {};
15
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAIF,eAAO,MAAM,YAAY,GAAI,wBAG1B,gBAAgB,GAAG;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,4CAEA,CAAC;AAEF,eAAO,MAAM,cAAc,wBAO1B,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,35 @@
1
+
2
+
3
+ if (typeof global === 'undefined') {
4
+ var global = window;
5
+ }
6
+
1
7
  'use strict';
2
8
 
3
9
  var jsxRuntime = require('react/jsx-runtime');
10
+ var react = require('react');
11
+ require('@basaldev/blocks-frontend-framework/dist/style.css');
12
+
13
+ /**
14
+ * Utility function to join class names together, ignoring undefined or nil values.
15
+ * @param classes - The class names to join.
16
+ * @returns The joined class names.
17
+ */
18
+ function classNames(...classes) {
19
+ return classes.flat().filter(Boolean).join(' ');
20
+ }
21
+
22
+ const HeroContext = react.createContext(undefined);
23
+ const HeroProvider = ({ children, ...value }) => {
24
+ return jsxRuntime.jsx(HeroContext.Provider, { value: value, children: children });
25
+ };
26
+ const useHeroContext = () => {
27
+ const context = react.useContext(HeroContext);
28
+ if (!context) {
29
+ throw new Error('useHeroContext must be used within a HeroProvider');
30
+ }
31
+ return context;
32
+ };
4
33
 
5
34
  function styleInject(css, ref) {
6
35
  if ( ref === void 0 ) ref = {};
@@ -29,59 +58,121 @@ function styleInject(css, ref) {
29
58
  }
30
59
  }
31
60
 
32
- var css_248z = ".nbb-hero-block {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n display: flex;\n flex-direction: column-reverse;\n text-align: center;\n justify-content: start;\n}\n\n.nbb-hero-block .nbb-button {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n}\n\n@media (min-width: 680px) {\n .nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n position: relative;\n align-items: center;\n }\n .nbb-hero-img {\n width: 50%;\n }\n .nbb-hero-block .text-content {\n left: 146px;\n width: 600px;\n text-align: left;\n margin-left: 32px;\n }\n}";
61
+ var css_248z = ".nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n text-align: center;\n justify-content: center;\n flex-wrap: wrap;\n row-gap: 40px;\n font-family: var(--font-family);\n}\n\n.nbb-hero-content {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n gap: 1em;\n min-width: 400px;\n}\n\n.nbb-hero-tertiary-text {\n font-size: 30px;\n margin-block: 10px;\n}\n\n.nbb-hero-byline {\n font-size: 16px;\n margin-block: 10px;\n}\n\n.nbb-button {\n align-items: center;\n border-radius: var(--border-radius-3);\n border: 1px solid transparent;\n cursor: pointer;\n display: inline-flex;\n font-family: var(--font-family);\n gap: var(--spacing-5xs);\n transition:\n background-color 300ms,\n border-color 300ms,\n color 300ms;\n white-space: nowrap;\n padding: 13px 24px;\n color: var(--color-text-on-primary);\n background-color: var(--color-object-accent-primary);\n}\n";
33
62
  styleInject(css_248z);
34
63
 
35
64
  /**
36
- * Utility function to join class names together, ignoring undefined or nil values.
37
- * @param classes - The class names to join.
38
- * @returns The joined class names.
65
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
66
+ *
67
+ * @param components - A map of default block keys to component functions.
68
+ *
69
+ * @example
70
+ * const defaultBlocks = createDefaultBlocks({
71
+ * title: Title,
72
+ * description: Description,
73
+ * form: Form,
74
+ * });
39
75
  */
40
- function classNames(...classes) {
41
- return classes.flat().filter(Boolean).join(' ');
42
- }
43
-
44
- function HeroImg({ imageUrl }) {
45
- return jsxRuntime.jsx("img", { className: "nbb-hero-img", src: imageUrl, alt: "hero image" });
46
- }
47
- function HeroByline({ byline }) {
48
- return jsxRuntime.jsx("h6", { children: byline });
49
- }
50
- function SecondaryText({ secondaryText }) {
51
- return jsxRuntime.jsx("h3", { children: secondaryText });
76
+ function createDefaultBlocks(components) {
77
+ return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, react.createElement(Component, { key })]));
52
78
  }
53
- function ActionButton({ onClickButton, buttonText }) {
54
- return (jsxRuntime.jsx("button", { type: "button", onClick: onClickButton, className: "nbb-button primary", children: buttonText }));
55
- }
56
- function TertiaryText({ text }) {
57
- return jsxRuntime.jsx("span", { className: "nbb-typography nbb-typography-color-brand nbb-typography-size-s nbb-typography-weight-bold", children: text });
79
+ /**
80
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
81
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
82
+ *
83
+ * @param props
84
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
85
+ * @param props.defaultBlocks - The default blocks of outer component.
86
+ * @param props.children - A function returning the JSX to render.
87
+ *
88
+ * @example
89
+ * <BlocksOverrideComponent
90
+ * defaultBlocks={defaultFormBlocks}
91
+ * blocksOverride={children}
92
+ * >
93
+ * {({ blocks, blockOrder }) =>
94
+ * blockOrder.map((key) => (
95
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
96
+ * ))
97
+ * }
98
+ * </BlocksOverrideComponent>
99
+ */
100
+ function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
101
+ if (blocksOverride === undefined) {
102
+ return children({
103
+ // TODO: Remove this assertion
104
+ blocks: defaultBlocks,
105
+ blockOrder: defaultBlockOrder,
106
+ });
107
+ }
108
+ if (typeof blocksOverride === 'function') {
109
+ const { blocks, blockOrder } = blocksOverride({
110
+ defaultBlocks,
111
+ defaultBlockOrder,
112
+ });
113
+ return children({ blocks, blockOrder });
114
+ }
115
+ return blocksOverride;
58
116
  }
59
- function setBlocks(defaultBlocks, children, settings) {
60
- const { blocks: customBlocks = {}, settings: customSettings = {} } = children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };
61
- return {
62
- blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
63
- key,
64
- customBlocks[key] || defaultComponent,
65
- ])),
66
- settings: {
67
- ...settings,
68
- ...customSettings,
117
+ function deepMerge(obj1, obj2) {
118
+ const result = { ...obj1 };
119
+ for (const key in obj2) {
120
+ if (obj2.hasOwnProperty(key)) {
121
+ const val1 = result[key];
122
+ const val2 = obj2[key];
123
+ if (Array.isArray(val1) || Array.isArray(val2)) {
124
+ // If either is an array, replace entirely with obj2's value
125
+ result[key] = val2;
126
+ }
127
+ else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
128
+ result[key] = deepMerge(val1, val2);
129
+ }
130
+ else {
131
+ result[key] = val2;
132
+ }
69
133
  }
70
- };
134
+ }
135
+ return result;
71
136
  }
72
- const defaultBlocks = {
73
- HeroImg: HeroImg,
74
- HeroByline: HeroByline,
75
- SecondaryText: SecondaryText,
76
- ActionButton: ActionButton,
77
- TertiaryText: TertiaryText,
78
- };
79
137
 
80
- const Hero = ({ onClickButton, buttonText, imageUrl, className, secondaryText, tertiaryText, byline, children, }) => {
81
- const { blocks } = setBlocks(defaultBlocks, children, {});
82
- const { HeroImg, HeroByline, SecondaryText, ActionButton, TertiaryText } = blocks;
83
- return (jsxRuntime.jsxs("div", { className: classNames('nbb-hero-block', className), children: [jsxRuntime.jsx(HeroImg, { imageUrl: imageUrl }), jsxRuntime.jsxs("div", { className: "text-content", children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(HeroByline, { byline: byline }), jsxRuntime.jsx(SecondaryText, { secondaryText: secondaryText })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(ActionButton, { onClickButton: onClickButton, buttonText: buttonText }), jsxRuntime.jsx(TertiaryText, { text: tertiaryText })] })] })] }));
138
+ const Hero = ({ onClickButton, buttonText, imageUrl, secondaryText, tertiaryText, byline, className, children, ...props }) => {
139
+ return (jsxRuntime.jsx("div", { className: classNames('nbb-hero-block', className), ...props, children: jsxRuntime.jsx(HeroProvider, { onClickButton,
140
+ buttonText,
141
+ imageUrl,
142
+ secondaryText,
143
+ tertiaryText,
144
+ byline, children: jsxRuntime.jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { item, ...blocks }, blockOrder }) => blockOrder
145
+ .filter((key) => key in blocks)
146
+ .map((key) => jsxRuntime.jsx(react.Fragment, { children: blocks[key] }, String(key))) }) }) }));
147
+ };
148
+ Hero.HeroImg = ({ src, ...props }) => {
149
+ const { className, imageUrl } = deepMerge(useHeroContext(), props);
150
+ return jsxRuntime.jsx("img", { className: classNames('nbb-hero-img', className), src: src || imageUrl, alt: "hero image", ...props });
151
+ };
152
+ const HeroContent = ({ className, ...props }) => {
153
+ return (jsxRuntime.jsxs("div", { className: classNames('nbb-hero-content', className), ...props, children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(HeroContent.HeroByline, {}), jsxRuntime.jsx(HeroContent.SecondaryText, {})] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(HeroContent.ActionButton, {}), jsxRuntime.jsx(HeroContent.TertiaryText, {})] })] }));
154
+ };
155
+ Hero.HeroContent = HeroContent;
156
+ HeroContent.HeroByline = ({ className, children, ...props }) => {
157
+ const { byline } = deepMerge(useHeroContext(), props);
158
+ return (jsxRuntime.jsx("h6", { className: classNames(className, 'nbb-hero-byline'), ...props, children: children || byline }));
159
+ };
160
+ HeroContent.SecondaryText = ({ className, children, ...props }) => {
161
+ const { secondaryText } = deepMerge(useHeroContext(), props);
162
+ return (jsxRuntime.jsx("h3", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || secondaryText }));
163
+ };
164
+ HeroContent.ActionButton = ({ className, children, onClick, ...props }) => {
165
+ const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);
166
+ return (jsxRuntime.jsx("button", { type: "button", onClick: onClick || onClickButton, className: classNames(className, 'nbb-button'), ...props, children: children || buttonText }));
167
+ };
168
+ HeroContent.TertiaryText = ({ className, children, ...props }) => {
169
+ const { tertiaryText } = deepMerge(useHeroContext(), props);
170
+ return (jsxRuntime.jsx("span", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || tertiaryText }));
84
171
  };
172
+ const defaultBlocks = createDefaultBlocks({
173
+ heroImg: Hero.HeroImg,
174
+ heroContent: Hero.HeroContent,
175
+ });
85
176
 
86
177
  exports.Hero = Hero;
87
178
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/className.tsx","../src/blocks.tsx","../src/Hero.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","export type DefaultBlocks = {\n HeroImg: React.FC<{ imageUrl: string }>;\n HeroByline: React.FC<{ byline: string | React.ReactNode }>;\n SecondaryText: React.FC<{ secondaryText: string | React.ReactNode }>;\n ActionButton: React.FC<{ onClickButton: () => void; buttonText: string }>;\n TertiaryText: React.FC<{ text: string | React.ReactNode }>;\n}\n\nexport type DefaultSettings = {\n}\n\nexport function HeroImg({ imageUrl }: { imageUrl: string }) {\n return <img className=\"nbb-hero-img\" src={imageUrl} alt=\"hero image\" />;\n }\n \n export function HeroByline({ byline }: { byline: string | React.ReactNode }) {\n return <h6>{byline}</h6>;\n }\n \n export function SecondaryText({ secondaryText }: { secondaryText: string | React.ReactNode }) {\n return <h3>{secondaryText}</h3>\n }\n \n export function ActionButton({ onClickButton, buttonText }: { onClickButton: () => void; buttonText: string }) {\n return (\n <button\n type=\"button\"\n onClick={onClickButton}\n className=\"nbb-button primary\"\n >\n {buttonText}\n </button>\n );\n }\n export function TertiaryText({ text }: { text: string | React.ReactNode }) {\n return <span className=\"nbb-typography nbb-typography-color-brand nbb-typography-size-s nbb-typography-weight-bold\">{text}</span>;\n }\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n },\n settings?: DefaultSettings,\n) {\n const { blocks: customBlocks = {}, settings: customSettings = {} } =\n children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };\n\n return {\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n settings: {\n ...settings,\n ...customSettings,\n }\n };\n}\n\n\nexport const defaultSettings = {\n}\n\nexport const defaultBlocks = {\n HeroImg: HeroImg,\n HeroByline: HeroByline,\n SecondaryText: SecondaryText,\n ActionButton: ActionButton,\n TertiaryText: TertiaryText,\n}\n","import React from \"react\";\nimport \"./hero.css\";\nimport { classNames } from \"./className\";\nimport { DefaultBlocks, defaultBlocks, DefaultSettings, setBlocks } from \"./blocks\";\nexport interface HeroProps {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: string | React.ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Screen size to show for this block */\n className: string;\n /** Show/hide secondary text */\n secondaryText?: string | React.ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: string | React.ReactNode;\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n},\n}\n\nexport const Hero: React.FC<HeroProps> = ({\n onClickButton,\n buttonText,\n imageUrl,\n className,\n secondaryText,\n tertiaryText,\n byline,\n children,\n}) => {\n const { blocks } = setBlocks(defaultBlocks, children, {});\n const { HeroImg, HeroByline, SecondaryText, ActionButton, TertiaryText} = blocks;\n return (\n \n <div className={classNames('nbb-hero-block', className)}>\n <HeroImg imageUrl={imageUrl} />\n <div className=\"text-content\">\n <div>\n <HeroByline byline={byline} />\n <SecondaryText secondaryText={secondaryText} />\n </div>\n <div>\n <ActionButton onClickButton={onClickButton} buttonText={buttonText} />\n <TertiaryText text={tertiaryText} />\n </div>\n </div>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO;;AAExD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAA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AAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;AACzD,IAAA,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAC,GAAG,MAAM;AAChF,IAAA,QAEEC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EACrD,QAAA,EAAA,CAAAD,cAAA,CAAC,OAAO,EAAC,EAAA,QAAQ,EAAE,QAAQ,EAAI,CAAA,EAC/BC,eAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,cAAc,EAAA,QAAA,EAAA,CAC3BA,eACE,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,CAAAD,cAAA,CAAC,UAAU,EAAA,EAAC,MAAM,EAAE,MAAM,EAAI,CAAA,EAC9BA,cAAC,CAAA,aAAa,EAAC,EAAA,aAAa,EAAE,aAAa,EAAI,CAAA,CAAA,EAAA,CAC3C,EACNC,eAAA,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,CACED,cAAC,CAAA,YAAY,EAAC,EAAA,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI,EACtEA,cAAA,CAAC,YAAY,EAAC,EAAA,IAAI,EAAE,YAAY,EAAK,CAAA,CAAA,EAAA,CACjC,CACF,EAAA,CAAA,CAAA,EAAA,CACF;AAEV;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/className.tsx","../src/context.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/Hero.tsx"],"sourcesContent":["type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { createContext, ReactNode, useContext } from 'react';\n\ntype HeroContextValue = {\n buttonText: string;\n byline: ReactNode;\n onClickButton: () => void;\n imageUrl: string;\n secondaryText?: ReactNode;\n tertiaryText?: ReactNode;\n};\n\nconst HeroContext = createContext<HeroContextValue | undefined>(undefined);\n\nexport const HeroProvider = ({\n children,\n ...value\n}: HeroContextValue & {\n children: ReactNode;\n}) => {\n return <HeroContext.Provider value={value}>{children}</HeroContext.Provider>;\n};\n\nexport const useHeroContext = () => {\n const context = useContext<HeroContextValue | undefined>(HeroContext);\n\n if (!context) {\n throw new Error('useHeroContext must be used within a HeroProvider');\n }\n return context;\n};\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { ComponentProps, createElement, FunctionComponent, ReactElement, ReactNode } from 'react';\n\n/**\n * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.\n *\n * @example\n * <Block>\n * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({\n * blocks: {\n * ...defaultBlocks,\n * header: {\n * ...header,\n * props: {\n * ...header.props,\n * label: \"Custom Label\"\n * }\n * },\n * subheader: <CustomComponent />\n * },\n * blockOrder: [\"header\", \"subheader\", \"body\", \"footer\"]\n * })}\n * </Block>\n */\nexport type BlocksOverride<DefaultBlocks, CustomBlocks> =\n | (({\n defaultBlocks,\n defaultBlockOrder,\n }: {\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: readonly (keyof DefaultBlocks)[];\n }) => {\n blocks: Partial<DefaultBlocks> & CustomBlocks;\n // NOTE: This specific combination allows proper autocomplete.\n blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];\n })\n | ReactNode;\n\n/**\n * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.\n *\n * @param components - A map of default block keys to component functions.\n *\n * @example\n * const defaultBlocks = createDefaultBlocks({\n * title: Title,\n * description: Description,\n * form: Form,\n * });\n */\nexport function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(\n components: T\n): {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n} {\n return Object.fromEntries(\n Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })])\n ) as {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n };\n}\n\n/**\n * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.\n * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.\n *\n * @param props\n * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).\n * @param props.defaultBlocks - The default blocks of outer component.\n * @param props.children - A function returning the JSX to render.\n *\n * @example\n * <BlocksOverrideComponent\n * defaultBlocks={defaultFormBlocks}\n * blocksOverride={children}\n * >\n * {({ blocks, blockOrder }) =>\n * blockOrder.map((key) => (\n * <Fragment key={String(key)}>{blocks[key]}</Fragment>\n * ))\n * }\n * </BlocksOverrideComponent>\n */\nexport function BlocksOverrideComponent<\n DefaultBlocks extends Record<string, ReactNode>,\n CustomBlocks extends Record<string, ReactNode>,\n>({\n blocksOverride,\n defaultBlocks,\n defaultBlockOrder,\n children,\n}: {\n blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: (keyof DefaultBlocks)[];\n children: ({\n blocks,\n blockOrder,\n }: {\n // TODO: Possibly find an alternative to Partial<CustomBlocks>\n blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;\n blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];\n }) => ReactNode;\n}) {\n if (blocksOverride === undefined) {\n return children({\n // TODO: Remove this assertion\n blocks: defaultBlocks as DefaultBlocks & Partial<CustomBlocks>,\n blockOrder: defaultBlockOrder,\n });\n }\n\n if (typeof blocksOverride === 'function') {\n const { blocks, blockOrder } = blocksOverride({\n defaultBlocks,\n defaultBlockOrder,\n });\n\n return children({ blocks, blockOrder });\n }\n\n return blocksOverride;\n}\n\ntype MergeTypes<Object1, Object2> = {\n [K in keyof Object1 | keyof Object2]: K extends keyof Object1\n ? Object1[K]\n : K extends keyof Object2\n ? Object2[K]\n : never;\n};\n\nexport function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B) {\n const result: Record<string, any> = { ...obj1 };\n\n for (const key in obj2) {\n if (obj2.hasOwnProperty(key)) {\n const val1 = result[key];\n const val2 = obj2[key];\n\n if (Array.isArray(val1) || Array.isArray(val2)) {\n // If either is an array, replace entirely with obj2's value\n result[key] = val2;\n } else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {\n result[key] = deepMerge(val1, val2);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as MergeTypes<B, A>;\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport { classNames } from './className';\nimport { HeroProvider, useHeroContext } from './context';\nimport '@basaldev/blocks-frontend-framework/dist/style.css';\nimport './hero.css';\nimport { BlocksOverride, BlocksOverrideComponent, createDefaultBlocks, deepMerge } from './lib';\n\nexport const Hero = <CustomBlocks extends Record<string, ReactNode> = {}>({\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Show/hide secondary text */\n secondaryText?: ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <div className={classNames('nbb-hero-block', className)} {...props}>\n <HeroProvider\n {...{\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n }}\n >\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { item, ...blocks }, blockOrder }) =>\n blockOrder\n .filter((key) => key in blocks)\n .map<ReactNode>((key) => <Fragment key={String(key)}>{blocks[key]}</Fragment>)\n }\n </BlocksOverrideComponent>\n </HeroProvider>\n </div>\n );\n};\n\nHero.HeroImg = ({ src, ...props }: Partial<ComponentProps<'img'>>) => {\n const { className, imageUrl } = deepMerge(useHeroContext(), props);\n\n return <img className={classNames('nbb-hero-img', className)} src={src || imageUrl} alt=\"hero image\" {...props} />;\n};\n\nconst HeroContent = ({ className, ...props }: Partial<ComponentProps<'div'>>) => {\n return (\n <div className={classNames('nbb-hero-content', className)} {...props}>\n <div>\n <HeroContent.HeroByline />\n <HeroContent.SecondaryText />\n </div>\n <div>\n <HeroContent.ActionButton />\n <HeroContent.TertiaryText />\n </div>\n </div>\n );\n};\n\nHero.HeroContent = HeroContent;\n\nHeroContent.HeroByline = ({ className, children, ...props }: Partial<ComponentProps<'h6'>>) => {\n const { byline } = deepMerge(useHeroContext(), props);\n\n return (\n <h6 className={classNames(className, 'nbb-hero-byline')} {...props}>\n {children || byline}\n </h6>\n );\n};\n\nHeroContent.SecondaryText = ({ className, children, ...props }: Partial<ComponentProps<'h3'>>) => {\n const { secondaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <h3 className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || secondaryText}\n </h3>\n );\n};\n\nHeroContent.ActionButton = ({ className, children, onClick, ...props }: Partial<ComponentProps<'button'>>) => {\n const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);\n\n return (\n <button type=\"button\" onClick={onClick || onClickButton} className={classNames(className, 'nbb-button')} {...props}>\n {children || buttonText}\n </button>\n );\n};\n\nHeroContent.TertiaryText = ({ className, children, ...props }: Partial<ComponentProps<'span'>>) => {\n const { tertiaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <span className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || tertiaryText}\n </span>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n heroImg: Hero.HeroImg,\n heroContent: Hero.HeroContent,\n});\n"],"names":["createContext","_jsx","useContext","createElement","Fragment","_jsxs"],"mappings":";;;;;;;;;;;;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,GAAG,OAAoB,EAAA;AAChD,IAAA,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD;;ACEA,MAAM,WAAW,GAAGA,mBAAa,CAA+B,SAAS,CAAC;AAEnE,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,GAAG,KAAK,EAGT,KAAI;IACH,OAAOC,cAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAC9E,CAAC;AAEM,MAAM,cAAc,GAAG,MAAK;AACjC,IAAA,MAAM,OAAO,GAAGC,gBAAU,CAA+B,WAAW,CAAC;IAErE,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;;AAEtE,IAAA,OAAO,OAAO;AAChB,CAAC;;AC7BD,SAAS,WAAW,C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I,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,wBAAwB,CAAC,EAAA,GAAM,KAAK,EAAA,QAAA,EACtE,QAAQ,IAAI,aAAa,EAAA,CACvB;AAET,CAAC;AAED,WAAW,CAAC,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAqC,KAAI;AAC3G,IAAA,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC,cAAc,EAAE,EAAE,KAAK,CAAC;AAExE,IAAA,QACEA,cAAA,CAAA,QAAA,EAAA,EAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,EAAA,GAAM,KAAK,EAAA,QAAA,EAC/G,QAAQ,IAAI,UAAU,EAAA,CAChB;AAEb,CAAC;AAED,WAAW,CAAC,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAmC,KAAI;IAChG,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC,cAAc,EAAE,EAAE,KAAK,CAAC;AAE3D,IAAA,QACEA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,wBAAwB,CAAC,EAAA,GAAM,KAAK,EAAA,QAAA,EACxE,QAAQ,IAAI,YAAY,EAAA,CACpB;AAEX,CAAC;AAED,MAAM,aAAa,GAAG,mBAAmB,CAAC;IACxC,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,WAAW,EAAE,IAAI,CAAC,WAAW;AAC9B,CAAA,CAAC;;;;","x_google_ignoreList":[2]}
package/dist/index.esm.js CHANGED
@@ -1,4 +1,33 @@
1
+
2
+
3
+ if (typeof global === 'undefined') {
4
+ var global = window;
5
+ }
6
+
1
7
  import { jsx, jsxs } from 'react/jsx-runtime';
8
+ import { createContext, useContext, createElement, Fragment } from 'react';
9
+ import '@basaldev/blocks-frontend-framework/dist/style.css';
10
+
11
+ /**
12
+ * Utility function to join class names together, ignoring undefined or nil values.
13
+ * @param classes - The class names to join.
14
+ * @returns The joined class names.
15
+ */
16
+ function classNames(...classes) {
17
+ return classes.flat().filter(Boolean).join(' ');
18
+ }
19
+
20
+ const HeroContext = createContext(undefined);
21
+ const HeroProvider = ({ children, ...value }) => {
22
+ return jsx(HeroContext.Provider, { value: value, children: children });
23
+ };
24
+ const useHeroContext = () => {
25
+ const context = useContext(HeroContext);
26
+ if (!context) {
27
+ throw new Error('useHeroContext must be used within a HeroProvider');
28
+ }
29
+ return context;
30
+ };
2
31
 
3
32
  function styleInject(css, ref) {
4
33
  if ( ref === void 0 ) ref = {};
@@ -27,59 +56,121 @@ function styleInject(css, ref) {
27
56
  }
28
57
  }
29
58
 
30
- var css_248z = ".nbb-hero-block {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n display: flex;\n flex-direction: column-reverse;\n text-align: center;\n justify-content: start;\n}\n\n.nbb-hero-block .nbb-button {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n}\n\n@media (min-width: 680px) {\n .nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n position: relative;\n align-items: center;\n }\n .nbb-hero-img {\n width: 50%;\n }\n .nbb-hero-block .text-content {\n left: 146px;\n width: 600px;\n text-align: left;\n margin-left: 32px;\n }\n}";
59
+ var css_248z = ".nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n text-align: center;\n justify-content: center;\n flex-wrap: wrap;\n row-gap: 40px;\n font-family: var(--font-family);\n}\n\n.nbb-hero-content {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n gap: 1em;\n min-width: 400px;\n}\n\n.nbb-hero-tertiary-text {\n font-size: 30px;\n margin-block: 10px;\n}\n\n.nbb-hero-byline {\n font-size: 16px;\n margin-block: 10px;\n}\n\n.nbb-button {\n align-items: center;\n border-radius: var(--border-radius-3);\n border: 1px solid transparent;\n cursor: pointer;\n display: inline-flex;\n font-family: var(--font-family);\n gap: var(--spacing-5xs);\n transition:\n background-color 300ms,\n border-color 300ms,\n color 300ms;\n white-space: nowrap;\n padding: 13px 24px;\n color: var(--color-text-on-primary);\n background-color: var(--color-object-accent-primary);\n}\n";
31
60
  styleInject(css_248z);
32
61
 
33
62
  /**
34
- * Utility function to join class names together, ignoring undefined or nil values.
35
- * @param classes - The class names to join.
36
- * @returns The joined class names.
63
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
64
+ *
65
+ * @param components - A map of default block keys to component functions.
66
+ *
67
+ * @example
68
+ * const defaultBlocks = createDefaultBlocks({
69
+ * title: Title,
70
+ * description: Description,
71
+ * form: Form,
72
+ * });
37
73
  */
38
- function classNames(...classes) {
39
- return classes.flat().filter(Boolean).join(' ');
40
- }
41
-
42
- function HeroImg({ imageUrl }) {
43
- return jsx("img", { className: "nbb-hero-img", src: imageUrl, alt: "hero image" });
44
- }
45
- function HeroByline({ byline }) {
46
- return jsx("h6", { children: byline });
47
- }
48
- function SecondaryText({ secondaryText }) {
49
- return jsx("h3", { children: secondaryText });
74
+ function createDefaultBlocks(components) {
75
+ return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })]));
50
76
  }
51
- function ActionButton({ onClickButton, buttonText }) {
52
- return (jsx("button", { type: "button", onClick: onClickButton, className: "nbb-button primary", children: buttonText }));
53
- }
54
- function TertiaryText({ text }) {
55
- return jsx("span", { className: "nbb-typography nbb-typography-color-brand nbb-typography-size-s nbb-typography-weight-bold", children: text });
77
+ /**
78
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
79
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
80
+ *
81
+ * @param props
82
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
83
+ * @param props.defaultBlocks - The default blocks of outer component.
84
+ * @param props.children - A function returning the JSX to render.
85
+ *
86
+ * @example
87
+ * <BlocksOverrideComponent
88
+ * defaultBlocks={defaultFormBlocks}
89
+ * blocksOverride={children}
90
+ * >
91
+ * {({ blocks, blockOrder }) =>
92
+ * blockOrder.map((key) => (
93
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
94
+ * ))
95
+ * }
96
+ * </BlocksOverrideComponent>
97
+ */
98
+ function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
99
+ if (blocksOverride === undefined) {
100
+ return children({
101
+ // TODO: Remove this assertion
102
+ blocks: defaultBlocks,
103
+ blockOrder: defaultBlockOrder,
104
+ });
105
+ }
106
+ if (typeof blocksOverride === 'function') {
107
+ const { blocks, blockOrder } = blocksOverride({
108
+ defaultBlocks,
109
+ defaultBlockOrder,
110
+ });
111
+ return children({ blocks, blockOrder });
112
+ }
113
+ return blocksOverride;
56
114
  }
57
- function setBlocks(defaultBlocks, children, settings) {
58
- const { blocks: customBlocks = {}, settings: customSettings = {} } = children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };
59
- return {
60
- blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
61
- key,
62
- customBlocks[key] || defaultComponent,
63
- ])),
64
- settings: {
65
- ...settings,
66
- ...customSettings,
115
+ function deepMerge(obj1, obj2) {
116
+ const result = { ...obj1 };
117
+ for (const key in obj2) {
118
+ if (obj2.hasOwnProperty(key)) {
119
+ const val1 = result[key];
120
+ const val2 = obj2[key];
121
+ if (Array.isArray(val1) || Array.isArray(val2)) {
122
+ // If either is an array, replace entirely with obj2's value
123
+ result[key] = val2;
124
+ }
125
+ else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
126
+ result[key] = deepMerge(val1, val2);
127
+ }
128
+ else {
129
+ result[key] = val2;
130
+ }
67
131
  }
68
- };
132
+ }
133
+ return result;
69
134
  }
70
- const defaultBlocks = {
71
- HeroImg: HeroImg,
72
- HeroByline: HeroByline,
73
- SecondaryText: SecondaryText,
74
- ActionButton: ActionButton,
75
- TertiaryText: TertiaryText,
76
- };
77
135
 
78
- const Hero = ({ onClickButton, buttonText, imageUrl, className, secondaryText, tertiaryText, byline, children, }) => {
79
- const { blocks } = setBlocks(defaultBlocks, children, {});
80
- const { HeroImg, HeroByline, SecondaryText, ActionButton, TertiaryText } = blocks;
81
- return (jsxs("div", { className: classNames('nbb-hero-block', className), children: [jsx(HeroImg, { imageUrl: imageUrl }), jsxs("div", { className: "text-content", children: [jsxs("div", { children: [jsx(HeroByline, { byline: byline }), jsx(SecondaryText, { secondaryText: secondaryText })] }), jsxs("div", { children: [jsx(ActionButton, { onClickButton: onClickButton, buttonText: buttonText }), jsx(TertiaryText, { text: tertiaryText })] })] })] }));
136
+ const Hero = ({ onClickButton, buttonText, imageUrl, secondaryText, tertiaryText, byline, className, children, ...props }) => {
137
+ return (jsx("div", { className: classNames('nbb-hero-block', className), ...props, children: jsx(HeroProvider, { onClickButton,
138
+ buttonText,
139
+ imageUrl,
140
+ secondaryText,
141
+ tertiaryText,
142
+ byline, children: jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { item, ...blocks }, blockOrder }) => blockOrder
143
+ .filter((key) => key in blocks)
144
+ .map((key) => jsx(Fragment, { children: blocks[key] }, String(key))) }) }) }));
145
+ };
146
+ Hero.HeroImg = ({ src, ...props }) => {
147
+ const { className, imageUrl } = deepMerge(useHeroContext(), props);
148
+ return jsx("img", { className: classNames('nbb-hero-img', className), src: src || imageUrl, alt: "hero image", ...props });
149
+ };
150
+ const HeroContent = ({ className, ...props }) => {
151
+ return (jsxs("div", { className: classNames('nbb-hero-content', className), ...props, children: [jsxs("div", { children: [jsx(HeroContent.HeroByline, {}), jsx(HeroContent.SecondaryText, {})] }), jsxs("div", { children: [jsx(HeroContent.ActionButton, {}), jsx(HeroContent.TertiaryText, {})] })] }));
152
+ };
153
+ Hero.HeroContent = HeroContent;
154
+ HeroContent.HeroByline = ({ className, children, ...props }) => {
155
+ const { byline } = deepMerge(useHeroContext(), props);
156
+ return (jsx("h6", { className: classNames(className, 'nbb-hero-byline'), ...props, children: children || byline }));
157
+ };
158
+ HeroContent.SecondaryText = ({ className, children, ...props }) => {
159
+ const { secondaryText } = deepMerge(useHeroContext(), props);
160
+ return (jsx("h3", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || secondaryText }));
161
+ };
162
+ HeroContent.ActionButton = ({ className, children, onClick, ...props }) => {
163
+ const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);
164
+ return (jsx("button", { type: "button", onClick: onClick || onClickButton, className: classNames(className, 'nbb-button'), ...props, children: children || buttonText }));
165
+ };
166
+ HeroContent.TertiaryText = ({ className, children, ...props }) => {
167
+ const { tertiaryText } = deepMerge(useHeroContext(), props);
168
+ return (jsx("span", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || tertiaryText }));
82
169
  };
170
+ const defaultBlocks = createDefaultBlocks({
171
+ heroImg: Hero.HeroImg,
172
+ heroContent: Hero.HeroContent,
173
+ });
83
174
 
84
175
  export { Hero };
85
176
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/className.tsx","../src/blocks.tsx","../src/Hero.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","export type DefaultBlocks = {\n HeroImg: React.FC<{ imageUrl: string }>;\n HeroByline: React.FC<{ byline: string | React.ReactNode }>;\n SecondaryText: React.FC<{ secondaryText: string | React.ReactNode }>;\n ActionButton: React.FC<{ onClickButton: () => void; buttonText: string }>;\n TertiaryText: React.FC<{ text: string | React.ReactNode }>;\n}\n\nexport type DefaultSettings = {\n}\n\nexport function HeroImg({ imageUrl }: { imageUrl: string }) {\n return <img className=\"nbb-hero-img\" src={imageUrl} alt=\"hero image\" />;\n }\n \n export function HeroByline({ byline }: { byline: string | React.ReactNode }) {\n return <h6>{byline}</h6>;\n }\n \n export function SecondaryText({ secondaryText }: { secondaryText: string | React.ReactNode }) {\n return <h3>{secondaryText}</h3>\n }\n \n export function ActionButton({ onClickButton, buttonText }: { onClickButton: () => void; buttonText: string }) {\n return (\n <button\n type=\"button\"\n onClick={onClickButton}\n className=\"nbb-button primary\"\n >\n {buttonText}\n </button>\n );\n }\n export function TertiaryText({ text }: { text: string | React.ReactNode }) {\n return <span className=\"nbb-typography nbb-typography-color-brand nbb-typography-size-s nbb-typography-weight-bold\">{text}</span>;\n }\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n },\n settings?: DefaultSettings,\n) {\n const { blocks: customBlocks = {}, settings: customSettings = {} } =\n children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };\n\n return {\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n settings: {\n ...settings,\n ...customSettings,\n }\n };\n}\n\n\nexport const defaultSettings = {\n}\n\nexport const defaultBlocks = {\n HeroImg: HeroImg,\n HeroByline: HeroByline,\n SecondaryText: SecondaryText,\n ActionButton: ActionButton,\n TertiaryText: TertiaryText,\n}\n","import React from \"react\";\nimport \"./hero.css\";\nimport { classNames } from \"./className\";\nimport { DefaultBlocks, defaultBlocks, DefaultSettings, setBlocks } from \"./blocks\";\nexport interface HeroProps {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: string | React.ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Screen size to show for this block */\n className: string;\n /** Show/hide secondary text */\n secondaryText?: string | React.ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: string | React.ReactNode;\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n},\n}\n\nexport const Hero: React.FC<HeroProps> = ({\n onClickButton,\n buttonText,\n imageUrl,\n className,\n secondaryText,\n tertiaryText,\n byline,\n children,\n}) => {\n const { blocks } = setBlocks(defaultBlocks, children, {});\n const { HeroImg, HeroByline, SecondaryText, ActionButton, TertiaryText} = blocks;\n return (\n \n <div className={classNames('nbb-hero-block', className)}>\n <HeroImg imageUrl={imageUrl} />\n <div className=\"text-content\">\n <div>\n <HeroByline byline={byline} />\n <SecondaryText secondaryText={secondaryText} />\n </div>\n <div>\n <ActionButton onClickButton={onClickButton} buttonText={buttonText} />\n <TertiaryText text={tertiaryText} />\n </div>\n </div>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO;;AAExD,EAAE,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C7CY,IAAI,GAAwB,CAAC,EACxC,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,GACT,KAAI;AACH,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;AACzD,IAAA,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAC,GAAG,MAAM;AAChF,IAAA,QAEEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EACrD,QAAA,EAAA,CAAAD,GAAA,CAAC,OAAO,EAAC,EAAA,QAAQ,EAAE,QAAQ,EAAI,CAAA,EAC/BC,IAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,cAAc,EAAA,QAAA,EAAA,CAC3BA,IACE,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,CAAAD,GAAA,CAAC,UAAU,EAAA,EAAC,MAAM,EAAE,MAAM,EAAI,CAAA,EAC9BA,GAAC,CAAA,aAAa,EAAC,EAAA,aAAa,EAAE,aAAa,EAAI,CAAA,CAAA,EAAA,CAC3C,EACNC,IAAA,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,CACED,GAAC,CAAA,YAAY,EAAC,EAAA,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI,EACtEA,GAAA,CAAC,YAAY,EAAC,EAAA,IAAI,EAAE,YAAY,EAAK,CAAA,CAAA,EAAA,CACjC,CACF,EAAA,CAAA,CAAA,EAAA,CACF;AAEV;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/className.tsx","../src/context.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/Hero.tsx"],"sourcesContent":["type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { createContext, ReactNode, useContext } from 'react';\n\ntype HeroContextValue = {\n buttonText: string;\n byline: ReactNode;\n onClickButton: () => void;\n imageUrl: string;\n secondaryText?: ReactNode;\n tertiaryText?: ReactNode;\n};\n\nconst HeroContext = createContext<HeroContextValue | undefined>(undefined);\n\nexport const HeroProvider = ({\n children,\n ...value\n}: HeroContextValue & {\n children: ReactNode;\n}) => {\n return <HeroContext.Provider value={value}>{children}</HeroContext.Provider>;\n};\n\nexport const useHeroContext = () => {\n const context = useContext<HeroContextValue | undefined>(HeroContext);\n\n if (!context) {\n throw new Error('useHeroContext must be used within a HeroProvider');\n }\n return context;\n};\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { ComponentProps, createElement, FunctionComponent, ReactElement, ReactNode } from 'react';\n\n/**\n * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.\n *\n * @example\n * <Block>\n * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({\n * blocks: {\n * ...defaultBlocks,\n * header: {\n * ...header,\n * props: {\n * ...header.props,\n * label: \"Custom Label\"\n * }\n * },\n * subheader: <CustomComponent />\n * },\n * blockOrder: [\"header\", \"subheader\", \"body\", \"footer\"]\n * })}\n * </Block>\n */\nexport type BlocksOverride<DefaultBlocks, CustomBlocks> =\n | (({\n defaultBlocks,\n defaultBlockOrder,\n }: {\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: readonly (keyof DefaultBlocks)[];\n }) => {\n blocks: Partial<DefaultBlocks> & CustomBlocks;\n // NOTE: This specific combination allows proper autocomplete.\n blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];\n })\n | ReactNode;\n\n/**\n * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.\n *\n * @param components - A map of default block keys to component functions.\n *\n * @example\n * const defaultBlocks = createDefaultBlocks({\n * title: Title,\n * description: Description,\n * form: Form,\n * });\n */\nexport function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(\n components: T\n): {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n} {\n return Object.fromEntries(\n Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })])\n ) as {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n };\n}\n\n/**\n * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.\n * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.\n *\n * @param props\n * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).\n * @param props.defaultBlocks - The default blocks of outer component.\n * @param props.children - A function returning the JSX to render.\n *\n * @example\n * <BlocksOverrideComponent\n * defaultBlocks={defaultFormBlocks}\n * blocksOverride={children}\n * >\n * {({ blocks, blockOrder }) =>\n * blockOrder.map((key) => (\n * <Fragment key={String(key)}>{blocks[key]}</Fragment>\n * ))\n * }\n * </BlocksOverrideComponent>\n */\nexport function BlocksOverrideComponent<\n DefaultBlocks extends Record<string, ReactNode>,\n CustomBlocks extends Record<string, ReactNode>,\n>({\n blocksOverride,\n defaultBlocks,\n defaultBlockOrder,\n children,\n}: {\n blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: (keyof DefaultBlocks)[];\n children: ({\n blocks,\n blockOrder,\n }: {\n // TODO: Possibly find an alternative to Partial<CustomBlocks>\n blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;\n blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];\n }) => ReactNode;\n}) {\n if (blocksOverride === undefined) {\n return children({\n // TODO: Remove this assertion\n blocks: defaultBlocks as DefaultBlocks & Partial<CustomBlocks>,\n blockOrder: defaultBlockOrder,\n });\n }\n\n if (typeof blocksOverride === 'function') {\n const { blocks, blockOrder } = blocksOverride({\n defaultBlocks,\n defaultBlockOrder,\n });\n\n return children({ blocks, blockOrder });\n }\n\n return blocksOverride;\n}\n\ntype MergeTypes<Object1, Object2> = {\n [K in keyof Object1 | keyof Object2]: K extends keyof Object1\n ? Object1[K]\n : K extends keyof Object2\n ? Object2[K]\n : never;\n};\n\nexport function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B) {\n const result: Record<string, any> = { ...obj1 };\n\n for (const key in obj2) {\n if (obj2.hasOwnProperty(key)) {\n const val1 = result[key];\n const val2 = obj2[key];\n\n if (Array.isArray(val1) || Array.isArray(val2)) {\n // If either is an array, replace entirely with obj2's value\n result[key] = val2;\n } else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {\n result[key] = deepMerge(val1, val2);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as MergeTypes<B, A>;\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport { classNames } from './className';\nimport { HeroProvider, useHeroContext } from './context';\nimport '@basaldev/blocks-frontend-framework/dist/style.css';\nimport './hero.css';\nimport { BlocksOverride, BlocksOverrideComponent, createDefaultBlocks, deepMerge } from './lib';\n\nexport const Hero = <CustomBlocks extends Record<string, ReactNode> = {}>({\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Show/hide secondary text */\n secondaryText?: ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <div className={classNames('nbb-hero-block', className)} {...props}>\n <HeroProvider\n {...{\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n }}\n >\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { item, ...blocks }, blockOrder }) =>\n blockOrder\n .filter((key) => key in blocks)\n .map<ReactNode>((key) => <Fragment key={String(key)}>{blocks[key]}</Fragment>)\n }\n </BlocksOverrideComponent>\n </HeroProvider>\n </div>\n );\n};\n\nHero.HeroImg = ({ src, ...props }: Partial<ComponentProps<'img'>>) => {\n const { className, imageUrl } = deepMerge(useHeroContext(), props);\n\n return <img className={classNames('nbb-hero-img', className)} src={src || imageUrl} alt=\"hero image\" {...props} />;\n};\n\nconst HeroContent = ({ className, ...props }: Partial<ComponentProps<'div'>>) => {\n return (\n <div className={classNames('nbb-hero-content', className)} {...props}>\n <div>\n <HeroContent.HeroByline />\n <HeroContent.SecondaryText />\n </div>\n <div>\n <HeroContent.ActionButton />\n <HeroContent.TertiaryText />\n </div>\n </div>\n );\n};\n\nHero.HeroContent = HeroContent;\n\nHeroContent.HeroByline = ({ className, children, ...props }: Partial<ComponentProps<'h6'>>) => {\n const { byline } = deepMerge(useHeroContext(), props);\n\n return (\n <h6 className={classNames(className, 'nbb-hero-byline')} {...props}>\n {children || byline}\n </h6>\n );\n};\n\nHeroContent.SecondaryText = ({ className, children, ...props }: Partial<ComponentProps<'h3'>>) => {\n const { secondaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <h3 className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || secondaryText}\n </h3>\n );\n};\n\nHeroContent.ActionButton = ({ className, children, onClick, ...props }: Partial<ComponentProps<'button'>>) => {\n const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);\n\n return (\n <button type=\"button\" onClick={onClick || onClickButton} className={classNames(className, 'nbb-button')} {...props}>\n {children || buttonText}\n </button>\n );\n};\n\nHeroContent.TertiaryText = ({ className, children, ...props }: Partial<ComponentProps<'span'>>) => {\n const { tertiaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <span className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || tertiaryText}\n </span>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n heroImg: Hero.HeroImg,\n heroContent: Hero.HeroContent,\n});\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,GAAG,OAAoB,EAAA;AAChD,IAAA,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD;;ACEA,MAAM,WAAW,GAAG,aAAa,CAA+B,SAAS,CAAC;AAEnE,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,GAAG,KAAK,EAGT,KAAI;IACH,OAAOA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAC9E,CAAC;AAEM,MAAM,cAAc,GAAG,MAAK;AACjC,IAAA,MAAM,OAAO,GAAG,UAAU,CAA+B,WAAW,CAAC;IAErE,IAAI,CAAC,OAAO,EAAE;AACZ,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ent, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.
4
+ *
5
+ * @example
6
+ * <Block>
7
+ * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({
8
+ * blocks: {
9
+ * ...defaultBlocks,
10
+ * header: {
11
+ * ...header,
12
+ * props: {
13
+ * ...header.props,
14
+ * label: "Custom Label"
15
+ * }
16
+ * },
17
+ * subheader: <CustomComponent />
18
+ * },
19
+ * blockOrder: ["header", "subheader", "body", "footer"]
20
+ * })}
21
+ * </Block>
22
+ */
23
+ export type BlocksOverride<DefaultBlocks, CustomBlocks> = (({ defaultBlocks, defaultBlockOrder, }: {
24
+ defaultBlocks: DefaultBlocks;
25
+ defaultBlockOrder: readonly (keyof DefaultBlocks)[];
26
+ }) => {
27
+ blocks: Partial<DefaultBlocks> & CustomBlocks;
28
+ blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];
29
+ }) | ReactNode;
30
+ /**
31
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
32
+ *
33
+ * @param components - A map of default block keys to component functions.
34
+ *
35
+ * @example
36
+ * const defaultBlocks = createDefaultBlocks({
37
+ * title: Title,
38
+ * description: Description,
39
+ * form: Form,
40
+ * });
41
+ */
42
+ export declare function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(components: T): {
43
+ [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;
44
+ };
45
+ /**
46
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
47
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
48
+ *
49
+ * @param props
50
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
51
+ * @param props.defaultBlocks - The default blocks of outer component.
52
+ * @param props.children - A function returning the JSX to render.
53
+ *
54
+ * @example
55
+ * <BlocksOverrideComponent
56
+ * defaultBlocks={defaultFormBlocks}
57
+ * blocksOverride={children}
58
+ * >
59
+ * {({ blocks, blockOrder }) =>
60
+ * blockOrder.map((key) => (
61
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
62
+ * ))
63
+ * }
64
+ * </BlocksOverrideComponent>
65
+ */
66
+ export declare function BlocksOverrideComponent<DefaultBlocks extends Record<string, ReactNode>, CustomBlocks extends Record<string, ReactNode>>({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }: {
67
+ blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;
68
+ defaultBlocks: DefaultBlocks;
69
+ defaultBlockOrder: (keyof DefaultBlocks)[];
70
+ children: ({ blocks, blockOrder, }: {
71
+ blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;
72
+ blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];
73
+ }) => ReactNode;
74
+ }): ReactNode;
75
+ type MergeTypes<Object1, Object2> = {
76
+ [K in keyof Object1 | keyof Object2]: K extends keyof Object1 ? Object1[K] : K extends keyof Object2 ? Object2[K] : never;
77
+ };
78
+ export declare function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B): MergeTypes<B, A>;
79
+ type ClassName = string | ClassName[] | undefined | null;
80
+ /**
81
+ * Utility function to join class names together, ignoring undefined or nil values.
82
+ * @param classes - The class names to join.
83
+ * @returns The joined class names.
84
+ */
85
+ export declare function classNames(...classes: ClassName[]): string;
86
+ export {};
87
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,cAAc,CAAC,aAAa,EAAE,YAAY,IAClD,CAAC,CAAC,EACA,aAAa,EACb,iBAAiB,GAClB,EAAE;I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CAAC,OAAO,EAAE,OAAO,IAAI;KACjC,CAAC,IAAI,MAAM,OAAO,GAAG,MAAM,OAAO,GAAG,CAAC,SAAS,MAAM,OAAO,GACzD,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,MAAM,OAAO,GACrB,OAAO,CAAC,CAAC,CAAC,GACV,KAAK;CACZ,CAAC;AAEF,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAmBrF,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAClC;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAE1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodeblocks/frontend-hero-block",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "browser": "dist/index.iife.js",
@@ -15,10 +15,10 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": "^18.3.1",
18
- "react-dom": "^18.0.0"
18
+ "react-dom": "^18.3.1"
19
19
  },
20
20
  "devDependencies": {
21
- "@rollup/plugin-commonjs": "^28.0.1",
21
+ "@rollup/plugin-commonjs": "^28.0.6",
22
22
  "@rollup/plugin-json": "^6.1.0",
23
23
  "@rollup/plugin-node-resolve": "^15.3.0",
24
24
  "@rollup/plugin-typescript": "^12.1.1",
@@ -26,6 +26,7 @@
26
26
  "@types/react-dom": "^18.3.1",
27
27
  "rollup": "^4.28.0",
28
28
  "rollup-plugin-peer-deps-external": "^2.2.4",
29
+ "rollup-plugin-polyfill-node": "^0.13.0",
29
30
  "rollup-plugin-postcss": "^4.0.2",
30
31
  "rollup-plugin-serve": "^1.1.1",
31
32
  "tslib": "^2.8.1",
package/readme.md CHANGED
@@ -3,24 +3,29 @@
3
3
  Welcome to the Nodeblocks Frontend Starter Kit! 🎉 This kit is designed to make building frontend libraries in React super easy, helping you streamline your development workflow with minimal fuss. Let's dive in! 🤿
4
4
 
5
5
  ### ✨ Features
6
+
6
7
  - **🚀 Bundling with Rollup:** Get a clean, minimalistic approach to bundling your JavaScript files for smoother frontend development.
7
8
  - **💙 TypeScript Support:** We've included a pre-configured `tsconfig.json` to ensure your TypeScript setup is strict, efficient, and ready to go.
8
9
  - **⚙️ Peer Dependencies:** Keep bundle sizes lean with React and React DOM set as peer dependencies.
9
10
  - **🎨 CSS Support:** Easily import and process CSS files, giving you more control over your styles.
10
11
 
11
12
  ### 🛠️ How to Use
13
+
12
14
  1. **Clone this repository** 🌀:
15
+
13
16
  ```bash
14
17
  git clone <repository-url>
15
18
  cd <repository-directory>
16
19
  ```
17
20
 
18
21
  2. **Install dependencies** 📦:
22
+
19
23
  ```bash
20
24
  npm install
21
25
  ```
22
26
 
23
27
  3. **Start development** 🛠️:
28
+
24
29
  ```bash
25
30
  npm run watch
26
31
  ```
@@ -48,10 +53,12 @@ This ensures Nodeblocks libraries integrate seamlessly with different workflows.
48
53
  npm link
49
54
  ```
50
55
  2. In the test project you want to run:
56
+
51
57
  ```bash
52
58
  npm i
53
59
  npm link @basaldev/frontend-starter-kit
54
60
  ```
55
- (Note that in real life your library would not be called frontend-starter-kit.)
56
61
 
57
- 3. Then you can follow your usual workflow either with **Create React App** (`npm start`) or with Vite (`npm run dev`). This will give you a development environment where whenever you change your library it will be available in your test project.
62
+ (Note that in real life your library would not be called frontend-starter-kit.)
63
+
64
+ 3. Then you can follow your usual workflow either with **Create React App** (`npm start`) or with Vite (`npm run dev`). This will give you a development environment where whenever you change your library it will be available in your test project.
package/dist/blocks.d.ts DELETED
@@ -1,55 +0,0 @@
1
- export type DefaultBlocks = {
2
- HeroImg: React.FC<{
3
- imageUrl: string;
4
- }>;
5
- HeroByline: React.FC<{
6
- byline: string | React.ReactNode;
7
- }>;
8
- SecondaryText: React.FC<{
9
- secondaryText: string | React.ReactNode;
10
- }>;
11
- ActionButton: React.FC<{
12
- onClickButton: () => void;
13
- buttonText: string;
14
- }>;
15
- TertiaryText: React.FC<{
16
- text: string | React.ReactNode;
17
- }>;
18
- };
19
- export type DefaultSettings = {};
20
- export declare function HeroImg({ imageUrl }: {
21
- imageUrl: string;
22
- }): import("react/jsx-runtime").JSX.Element;
23
- export declare function HeroByline({ byline }: {
24
- byline: string | React.ReactNode;
25
- }): import("react/jsx-runtime").JSX.Element;
26
- export declare function SecondaryText({ secondaryText }: {
27
- secondaryText: string | React.ReactNode;
28
- }): import("react/jsx-runtime").JSX.Element;
29
- export declare function ActionButton({ onClickButton, buttonText }: {
30
- onClickButton: () => void;
31
- buttonText: string;
32
- }): import("react/jsx-runtime").JSX.Element;
33
- export declare function TertiaryText({ text }: {
34
- text: string | React.ReactNode;
35
- }): import("react/jsx-runtime").JSX.Element;
36
- export declare function setBlocks(defaultBlocks: DefaultBlocks, children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {
37
- blocks: {
38
- [x: string]: any;
39
- };
40
- settings?: DefaultSettings;
41
- }, settings?: DefaultSettings): {
42
- blocks: {
43
- [k: string]: any;
44
- };
45
- settings: {};
46
- };
47
- export declare const defaultSettings: {};
48
- export declare const defaultBlocks: {
49
- HeroImg: typeof HeroImg;
50
- HeroByline: typeof HeroByline;
51
- SecondaryText: typeof SecondaryText;
52
- ActionButton: typeof ActionButton;
53
- TertiaryText: typeof TertiaryText;
54
- };
55
- //# sourceMappingURL=blocks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IACxB,OAAO,EAAE,KA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