@nodeblocks/frontend-footer-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.
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ type FooterContextValue = {
3
+ logoSrc: string;
4
+ copyright: ReactNode;
5
+ content: ReactNode;
6
+ };
7
+ export declare const FooterProvider: ({ children, ...value }: FooterContextValue & {
8
+ children: ReactNode;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const useFooterContext: () => FooterContextValue;
11
+ export {};
12
+ //# 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,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,cAAc,GAAI,wBAG5B,kBAAkB,GAAG;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,4CAEA,CAAC;AAEF,eAAO,MAAM,gBAAgB,0BAO5B,CAAC"}
package/dist/footer.d.ts CHANGED
@@ -1,23 +1,21 @@
1
- import React from "react";
2
- import { DefaultBlocks } from "./blocks";
3
- import "./footer.css";
4
- export type FooterChildren = (props: {
5
- defaultBlocks: DefaultBlocks;
6
- settings?: {
7
- [key: string]: any;
8
- };
9
- }) => {
10
- blocks: Partial<DefaultBlocks>;
11
- settings?: {
12
- [key: string]: any;
13
- };
1
+ import { ComponentProps, ReactNode } from 'react';
2
+ import './footer.css';
3
+ import { BlocksOverride } from './lib';
4
+ declare const Footer: {
5
+ <CustomBlocks extends Record<string, ReactNode> = {}>({ logoSrc, content, copyright, className, children, ...props }: Omit<ComponentProps<"footer">, "content"> & {
6
+ logoSrc: string;
7
+ copyright: ReactNode;
8
+ content: ReactNode;
9
+ children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ Logo(props: Partial<ComponentProps<"img">>): import("react/jsx-runtime").JSX.Element;
12
+ Content(props: Partial<ComponentProps<"div">>): import("react/jsx-runtime").JSX.Element;
13
+ Copyright(props: Partial<ComponentProps<"div">>): import("react/jsx-runtime").JSX.Element;
14
+ };
15
+ declare const defaultBlocks: {
16
+ logo: import("react").ReactElement<Partial<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>>, (props: Partial<ComponentProps<"img">>) => import("react/jsx-runtime").JSX.Element>;
17
+ content: import("react").ReactElement<Partial<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>, (props: Partial<ComponentProps<"div">>) => import("react/jsx-runtime").JSX.Element>;
18
+ copyright: import("react").ReactElement<Partial<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>, (props: Partial<ComponentProps<"div">>) => import("react/jsx-runtime").JSX.Element>;
14
19
  };
15
- declare const Footer: ({ logoSrc, items, className, children, copyright }: {
16
- className: string;
17
- logoSrc: string;
18
- copyright: React.ReactNode | string;
19
- items: Array<React.ReactNode>;
20
- children?: FooterChildren;
21
- }) => import("react/jsx-runtime").JSX.Element;
22
20
  export default Footer;
23
21
  //# sourceMappingURL=footer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../src/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAiB,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,cAAc,CAAC;AAEtB,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,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cAAc,CAAC,KAAK,CAAC,CAAC;8JAQ3B,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gKAU5B,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;CAcvD,CAAC;AAEH,eAAe,MAAM,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1,34 +1,13 @@
1
- 'use strict';
2
1
 
3
- var jsxRuntime = require('react/jsx-runtime');
4
2
 
5
- function setBlocks(defaultBlocks, defaultOptions, children) {
6
- const results = children
7
- ? children({ defaultBlocks, ...defaultOptions })
8
- : { blocks: {}, ...defaultOptions };
9
- const { blocks: customBlocks = {} } = results;
10
- return {
11
- ...results,
12
- blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
13
- key,
14
- customBlocks[key] || defaultComponent,
15
- ])),
16
- };
17
- }
18
- /**
19
- * Utility function to join class names together, ignoring undefined or nil values.
20
- * @param classes - The class names to join.
21
- * @returns The joined class names.
22
- */
23
- function classNames(...classes) {
24
- return classes.flat().filter(Boolean).join(' ');
25
- }
3
+ if (typeof global === 'undefined') {
4
+ var global = window;
5
+ }
6
+
7
+ 'use strict';
26
8
 
27
- const defaultBlocks = {
28
- FooterLogo: ({ src, alt }) => (jsxRuntime.jsx("img", { className: "nbb-footer-logo", src: src, alt: alt || 'Footer logo' })),
29
- FooterText: ({ children }) => jsxRuntime.jsx("p", { className: "nbb-footer-text", children: children }),
30
- FooterCopyright: ({ children }) => (jsxRuntime.jsx("p", { className: "nbb-footer-copyright", children: children })),
31
- };
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var react = require('react');
32
11
 
33
12
  function styleInject(css, ref) {
34
13
  if ( ref === void 0 ) ref = {};
@@ -57,14 +36,127 @@ function styleInject(css, ref) {
57
36
  }
58
37
  }
59
38
 
60
- var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006EAD;\n --color-text-on-primary: #fff;\n \n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px; \n text-align: left;\n }\n \n .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n }\n \n .nbb-footer-text {\n font-size: 16px;\n margin-bottom: 8px;\n }\n .nbb-footer-text a {\n color: inherit\n }\n .nbb-footer-text a:hover {\n text-decoration: underline;\n }\n \n \n .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n }\n ";
39
+ var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006ead;\n --color-text-on-primary: #fff;\n\n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px;\n text-align: left;\n}\n\n.nbb-footer .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n}\n\n.nbb-footer .nbb-footer-content {\n font-size: 16px;\n margin-bottom: 8px;\n}\n.nbb-footer .nbb-footer-content a {\n color: inherit;\n}\n.nbb-footer .nbb-footer-content a:hover {\n text-decoration: underline;\n}\n\n.nbb-footer .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n}\n";
61
40
  styleInject(css_248z);
62
41
 
63
- const Footer = ({ logoSrc, items = [], className, children, copyright }) => {
64
- const { blocks } = setBlocks(defaultBlocks, {}, children);
65
- const { FooterLogo, FooterText, FooterCopyright } = blocks;
66
- return (jsxRuntime.jsxs("footer", { className: classNames("nbb-footer", className), children: [jsxRuntime.jsx(FooterLogo, { src: logoSrc }), items.map((item, index) => (jsxRuntime.jsx(FooterText, { children: item }, index))), jsxRuntime.jsx(FooterCopyright, { children: copyright })] }));
42
+ /**
43
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
44
+ *
45
+ * @param components - A map of default block keys to component functions.
46
+ *
47
+ * @example
48
+ * const defaultBlocks = createDefaultBlocks({
49
+ * title: Title,
50
+ * description: Description,
51
+ * form: Form,
52
+ * });
53
+ */
54
+ function createDefaultBlocks(components) {
55
+ return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, react.createElement(Component, { key })]));
56
+ }
57
+ /**
58
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
59
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
60
+ *
61
+ * @param props
62
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
63
+ * @param props.defaultBlocks - The default blocks of outer component.
64
+ * @param props.children - A function returning the JSX to render.
65
+ *
66
+ * @example
67
+ * <BlocksOverrideComponent
68
+ * defaultBlocks={defaultFormBlocks}
69
+ * blocksOverride={children}
70
+ * >
71
+ * {({ blocks, blockOrder }) =>
72
+ * blockOrder.map((key) => (
73
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
74
+ * ))
75
+ * }
76
+ * </BlocksOverrideComponent>
77
+ */
78
+ function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
79
+ if (blocksOverride === undefined) {
80
+ return children({
81
+ // TODO: Remove this assertion
82
+ blocks: defaultBlocks,
83
+ blockOrder: defaultBlockOrder,
84
+ });
85
+ }
86
+ if (typeof blocksOverride === 'function') {
87
+ const { blocks, blockOrder } = blocksOverride({
88
+ defaultBlocks,
89
+ defaultBlockOrder,
90
+ });
91
+ return children({ blocks, blockOrder });
92
+ }
93
+ return blocksOverride;
94
+ }
95
+ function deepMerge(obj1, obj2) {
96
+ const result = { ...obj1 };
97
+ for (const key in obj2) {
98
+ if (obj2.hasOwnProperty(key)) {
99
+ const val1 = result[key];
100
+ const val2 = obj2[key];
101
+ if (Array.isArray(val1) || Array.isArray(val2)) {
102
+ // If either is an array, replace entirely with obj2's value
103
+ result[key] = val2;
104
+ }
105
+ else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
106
+ result[key] = deepMerge(val1, val2);
107
+ }
108
+ else {
109
+ result[key] = val2;
110
+ }
111
+ }
112
+ }
113
+ return result;
114
+ }
115
+ /**
116
+ * Utility function to join class names together, ignoring undefined or nil values.
117
+ * @param classes - The class names to join.
118
+ * @returns The joined class names.
119
+ */
120
+ function classNames(...classes) {
121
+ return classes.flat().filter(Boolean).join(' ');
122
+ }
123
+
124
+ const FooterContext = react.createContext(undefined);
125
+ const FooterProvider = ({ children, ...value }) => {
126
+ return jsxRuntime.jsx(FooterContext.Provider, { value: value, children: children });
127
+ };
128
+ const useFooterContext = () => {
129
+ const context = react.useContext(FooterContext);
130
+ if (!context) {
131
+ throw new Error('useFooterContext must be used within a FooterProvider');
132
+ }
133
+ return context;
134
+ };
135
+
136
+ const Footer = ({ logoSrc, content, copyright, className, children, ...props }) => {
137
+ return (jsxRuntime.jsx(FooterProvider, { logoSrc,
138
+ content,
139
+ copyright, children: jsxRuntime.jsx("footer", { className: classNames('nbb-footer', className), ...props, children: jsxRuntime.jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { ...blocks }, blockOrder }) => blockOrder
140
+ .filter((key) => key in blocks)
141
+ .map((key) => jsxRuntime.jsx(react.Fragment, { children: blocks[key] }, String(key))) }) }) }));
142
+ };
143
+ Footer.Logo = (props) => {
144
+ const { className, logoSrc, src } = deepMerge(useFooterContext(), props);
145
+ return (jsxRuntime.jsx("img", { className: classNames('nbb-footer-logo', className), src: logoSrc || src, alt: 'Footer logo', ...props }));
146
+ };
147
+ Footer.Content = (props) => {
148
+ const { className, children, content } = deepMerge(useFooterContext(), props);
149
+ return (jsxRuntime.jsx("div", { className: classNames('nbb-footer-content', className), ...props, children: content || children }));
150
+ };
151
+ Footer.Copyright = (props) => {
152
+ const { className, children, copyright } = deepMerge(useFooterContext(), props);
153
+ return (jsxRuntime.jsx("div", { className: classNames('nbb-footer-copyright', className), ...props, children: copyright || children }));
67
154
  };
155
+ const defaultBlocks = createDefaultBlocks({
156
+ logo: Footer.Logo,
157
+ content: Footer.Content,
158
+ copyright: Footer.Copyright,
159
+ });
68
160
 
69
161
  exports.Footer = Footer;
70
162
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/lib.ts","../src/blocks.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/footer.tsx"],"sourcesContent":["import { DefaultBlocks, DefaultOptions } from './blocks';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\n\ntype ChildrenProps = {\n defaultBlocks: DefaultBlocks;\n};\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\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 React from 'react';\n\nexport type DefaultBlocks = {\n FooterLogo: React.FC<{ src: string; alt?: string }>;\n FooterText: React.FC<{ children: React.ReactNode }>;\n FooterCopyright: React.FC<{ children: React.ReactNode }>;\n};\n\nexport type DefaultOptions = {\n hideTitle?: boolean;\n};\n\nexport const defaultOptions: DefaultOptions = {\n hideTitle: false,\n};\n\nfunction FooterTitle({ children }: { children: React.ReactNode }) {\n return <h2 className=\"nbb-footer-title\">{children}</h2>;\n}\n\nfunction FooterText({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-text\">{children}</p>;\n}\n\nfunction FooterCopyright({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-copyright\">{children}</p>;\n}\n\n\n\nexport const defaultBlocks: DefaultBlocks = {\n FooterLogo: ({ src, alt }) => (\n <img className=\"nbb-footer-logo\" src={src} alt={alt || 'Footer logo'} />\n ),\n FooterText: ({ children }) => <p className=\"nbb-footer-text\">{children}</p>,\n FooterCopyright: ({ children }) => (\n <p className=\"nbb-footer-copyright\">{children}</p>\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 React from \"react\";\nimport { setBlocks, classNames } from \"./lib\";\nimport { defaultBlocks, DefaultBlocks } from \"./blocks\";\nimport \"./footer.css\";\n\nexport type FooterChildren = (props: {\n defaultBlocks: DefaultBlocks,\n settings?: { [key: string]: any }\n}\n) => {\n blocks: Partial<DefaultBlocks>;\n settings?: { [key: string]: any };\n};\n\nconst Footer = ({\n logoSrc,\n items = [],\n className,\n children, copyright }:\n {\n className: string;\n logoSrc: string;\n copyright: React.ReactNode | string;\n items: Array<React.ReactNode>;\n children?: FooterChildren;\n}) => {\n const { blocks } = setBlocks(defaultBlocks, {}, children);\n const { FooterLogo, FooterText, FooterCopyright } = blocks;\n\n return (\n <footer className={classNames(\"nbb-footer\", className)}>\n <FooterLogo src={logoSrc} />\n {items.map((item, index) => (\n <FooterText key={index}>{item}</FooterText>\n ))}\n <FooterCopyright>{copyright}</FooterCopyright>\n </footer>\n );\n};\n\nexport default Footer;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;SAgBgB,SAAS,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UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CACpDD,eAAC,UAAU,EAAA,EAAC,GAAG,EAAE,OAAO,GAAI,EAC3B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACrBA,cAAC,CAAA,UAAU,EAAc,EAAA,QAAA,EAAA,IAAI,EAAZ,EAAA,KAAK,CAAqB,CAC5C,CAAC,EACFA,cAAC,CAAA,eAAe,cAAE,SAAS,EAAA,CAAmB,CACvC,EAAA,CAAA;AAEb;;;;","x_google_ignoreList":[2]}
1
+ {"version":3,"file":"index.cjs.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/context.tsx","../src/footer.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","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\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 A & B;\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 { createContext, ReactNode, useContext } from 'react';\n\ntype FooterContextValue = {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n};\n\nconst FooterContext = createContext<FooterContextValue | undefined>(undefined);\n\nexport const FooterProvider = ({\n children,\n ...value\n}: FooterContextValue & {\n children: ReactNode;\n}) => {\n return <FooterContext.Provider value={value}>{children}</FooterContext.Provider>;\n};\n\nexport const useFooterContext = () => {\n const context = useContext<FooterContextValue | undefined>(FooterContext);\n\n if (!context) {\n throw new Error('useFooterContext must be used within a FooterProvider');\n }\n return context;\n};\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport './footer.css';\nimport { BlocksOverride, BlocksOverrideComponent, classNames, createDefaultBlocks, deepMerge } from './lib';\nimport { FooterProvider, useFooterContext } from './context';\n\nconst Footer = <CustomBlocks extends Record<string, ReactNode> = {}>({\n logoSrc,\n content,\n copyright,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'footer'>, 'content'> & {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <FooterProvider\n {...{\n logoSrc,\n content,\n copyright,\n }}\n >\n <footer className={classNames('nbb-footer', className)} {...props}>\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { ...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 </footer>\n </FooterProvider>\n );\n};\n\nFooter.Logo = (props: Partial<ComponentProps<'img'>>) => {\n const { className, logoSrc, src } = deepMerge(useFooterContext(), props);\n\n return (\n <img className={classNames('nbb-footer-logo', className)} src={logoSrc || src} alt={'Footer logo'} {...props} />\n );\n};\n\nFooter.Content = (props: Partial<ComponentProps<'div'>>) => {\n const { className, children, content } = deepMerge(useFooterContext(), props);\n\n return (\n <div className={classNames('nbb-footer-content', className)} {...props}>\n {content || children}\n </div>\n );\n};\n\nFooter.Copyright = (props: Partial<ComponentProps<'div'>>) => {\n const { className, children, copyright } = deepMerge(useFooterContext(), props);\n\n return (\n <div className={classNames('nbb-footer-copyright', className)} {...props}>\n {copyright || children}\n </div>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n logo: Footer.Logo,\n content: Footer.Content,\n copyright: Footer.Copyright,\n});\n\nexport default Footer;\n"],"names":["createElement","createContext","_jsx","useContext","Fragment"],"mappings":";;;;;;;;;;;AAA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A,GAAM,KAAK,EAAA,QAAA,EACrE,SAAS,IAAI,QAAQ,EAAA,CAClB;AAEV,CAAC;AAED,MAAM,aAAa,GAAG,mBAAmB,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,CAAA,CAAC;;;;","x_google_ignoreList":[0]}
package/dist/index.esm.js CHANGED
@@ -1,32 +1,11 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
1
 
3
- function setBlocks(defaultBlocks, defaultOptions, children) {
4
- const results = children
5
- ? children({ defaultBlocks, ...defaultOptions })
6
- : { blocks: {}, ...defaultOptions };
7
- const { blocks: customBlocks = {} } = results;
8
- return {
9
- ...results,
10
- blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
11
- key,
12
- customBlocks[key] || defaultComponent,
13
- ])),
14
- };
15
- }
16
- /**
17
- * Utility function to join class names together, ignoring undefined or nil values.
18
- * @param classes - The class names to join.
19
- * @returns The joined class names.
20
- */
21
- function classNames(...classes) {
22
- return classes.flat().filter(Boolean).join(' ');
23
- }
24
2
 
25
- const defaultBlocks = {
26
- FooterLogo: ({ src, alt }) => (jsx("img", { className: "nbb-footer-logo", src: src, alt: alt || 'Footer logo' })),
27
- FooterText: ({ children }) => jsx("p", { className: "nbb-footer-text", children: children }),
28
- FooterCopyright: ({ children }) => (jsx("p", { className: "nbb-footer-copyright", children: children })),
29
- };
3
+ if (typeof global === 'undefined') {
4
+ var global = window;
5
+ }
6
+
7
+ import { jsx } from 'react/jsx-runtime';
8
+ import { createElement, createContext, useContext, Fragment } from 'react';
30
9
 
31
10
  function styleInject(css, ref) {
32
11
  if ( ref === void 0 ) ref = {};
@@ -55,14 +34,127 @@ function styleInject(css, ref) {
55
34
  }
56
35
  }
57
36
 
58
- var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006EAD;\n --color-text-on-primary: #fff;\n \n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px; \n text-align: left;\n }\n \n .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n }\n \n .nbb-footer-text {\n font-size: 16px;\n margin-bottom: 8px;\n }\n .nbb-footer-text a {\n color: inherit\n }\n .nbb-footer-text a:hover {\n text-decoration: underline;\n }\n \n \n .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n }\n ";
37
+ var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006ead;\n --color-text-on-primary: #fff;\n\n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px;\n text-align: left;\n}\n\n.nbb-footer .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n}\n\n.nbb-footer .nbb-footer-content {\n font-size: 16px;\n margin-bottom: 8px;\n}\n.nbb-footer .nbb-footer-content a {\n color: inherit;\n}\n.nbb-footer .nbb-footer-content a:hover {\n text-decoration: underline;\n}\n\n.nbb-footer .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n}\n";
59
38
  styleInject(css_248z);
60
39
 
61
- const Footer = ({ logoSrc, items = [], className, children, copyright }) => {
62
- const { blocks } = setBlocks(defaultBlocks, {}, children);
63
- const { FooterLogo, FooterText, FooterCopyright } = blocks;
64
- return (jsxs("footer", { className: classNames("nbb-footer", className), children: [jsx(FooterLogo, { src: logoSrc }), items.map((item, index) => (jsx(FooterText, { children: item }, index))), jsx(FooterCopyright, { children: copyright })] }));
40
+ /**
41
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
42
+ *
43
+ * @param components - A map of default block keys to component functions.
44
+ *
45
+ * @example
46
+ * const defaultBlocks = createDefaultBlocks({
47
+ * title: Title,
48
+ * description: Description,
49
+ * form: Form,
50
+ * });
51
+ */
52
+ function createDefaultBlocks(components) {
53
+ return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })]));
54
+ }
55
+ /**
56
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
57
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
58
+ *
59
+ * @param props
60
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
61
+ * @param props.defaultBlocks - The default blocks of outer component.
62
+ * @param props.children - A function returning the JSX to render.
63
+ *
64
+ * @example
65
+ * <BlocksOverrideComponent
66
+ * defaultBlocks={defaultFormBlocks}
67
+ * blocksOverride={children}
68
+ * >
69
+ * {({ blocks, blockOrder }) =>
70
+ * blockOrder.map((key) => (
71
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
72
+ * ))
73
+ * }
74
+ * </BlocksOverrideComponent>
75
+ */
76
+ function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
77
+ if (blocksOverride === undefined) {
78
+ return children({
79
+ // TODO: Remove this assertion
80
+ blocks: defaultBlocks,
81
+ blockOrder: defaultBlockOrder,
82
+ });
83
+ }
84
+ if (typeof blocksOverride === 'function') {
85
+ const { blocks, blockOrder } = blocksOverride({
86
+ defaultBlocks,
87
+ defaultBlockOrder,
88
+ });
89
+ return children({ blocks, blockOrder });
90
+ }
91
+ return blocksOverride;
92
+ }
93
+ function deepMerge(obj1, obj2) {
94
+ const result = { ...obj1 };
95
+ for (const key in obj2) {
96
+ if (obj2.hasOwnProperty(key)) {
97
+ const val1 = result[key];
98
+ const val2 = obj2[key];
99
+ if (Array.isArray(val1) || Array.isArray(val2)) {
100
+ // If either is an array, replace entirely with obj2's value
101
+ result[key] = val2;
102
+ }
103
+ else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
104
+ result[key] = deepMerge(val1, val2);
105
+ }
106
+ else {
107
+ result[key] = val2;
108
+ }
109
+ }
110
+ }
111
+ return result;
112
+ }
113
+ /**
114
+ * Utility function to join class names together, ignoring undefined or nil values.
115
+ * @param classes - The class names to join.
116
+ * @returns The joined class names.
117
+ */
118
+ function classNames(...classes) {
119
+ return classes.flat().filter(Boolean).join(' ');
120
+ }
121
+
122
+ const FooterContext = createContext(undefined);
123
+ const FooterProvider = ({ children, ...value }) => {
124
+ return jsx(FooterContext.Provider, { value: value, children: children });
125
+ };
126
+ const useFooterContext = () => {
127
+ const context = useContext(FooterContext);
128
+ if (!context) {
129
+ throw new Error('useFooterContext must be used within a FooterProvider');
130
+ }
131
+ return context;
132
+ };
133
+
134
+ const Footer = ({ logoSrc, content, copyright, className, children, ...props }) => {
135
+ return (jsx(FooterProvider, { logoSrc,
136
+ content,
137
+ copyright, children: jsx("footer", { className: classNames('nbb-footer', className), ...props, children: jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { ...blocks }, blockOrder }) => blockOrder
138
+ .filter((key) => key in blocks)
139
+ .map((key) => jsx(Fragment, { children: blocks[key] }, String(key))) }) }) }));
140
+ };
141
+ Footer.Logo = (props) => {
142
+ const { className, logoSrc, src } = deepMerge(useFooterContext(), props);
143
+ return (jsx("img", { className: classNames('nbb-footer-logo', className), src: logoSrc || src, alt: 'Footer logo', ...props }));
144
+ };
145
+ Footer.Content = (props) => {
146
+ const { className, children, content } = deepMerge(useFooterContext(), props);
147
+ return (jsx("div", { className: classNames('nbb-footer-content', className), ...props, children: content || children }));
148
+ };
149
+ Footer.Copyright = (props) => {
150
+ const { className, children, copyright } = deepMerge(useFooterContext(), props);
151
+ return (jsx("div", { className: classNames('nbb-footer-copyright', className), ...props, children: copyright || children }));
65
152
  };
153
+ const defaultBlocks = createDefaultBlocks({
154
+ logo: Footer.Logo,
155
+ content: Footer.Content,
156
+ copyright: Footer.Copyright,
157
+ });
66
158
 
67
159
  export { Footer };
68
160
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/lib.ts","../src/blocks.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/footer.tsx"],"sourcesContent":["import { DefaultBlocks, DefaultOptions } from './blocks';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\n\ntype ChildrenProps = {\n defaultBlocks: DefaultBlocks;\n};\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\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 React from 'react';\n\nexport type DefaultBlocks = {\n FooterLogo: React.FC<{ src: string; alt?: string }>;\n FooterText: React.FC<{ children: React.ReactNode }>;\n FooterCopyright: React.FC<{ children: React.ReactNode }>;\n};\n\nexport type DefaultOptions = {\n hideTitle?: boolean;\n};\n\nexport const defaultOptions: DefaultOptions = {\n hideTitle: false,\n};\n\nfunction FooterTitle({ children }: { children: React.ReactNode }) {\n return <h2 className=\"nbb-footer-title\">{children}</h2>;\n}\n\nfunction FooterText({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-text\">{children}</p>;\n}\n\nfunction FooterCopyright({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-copyright\">{children}</p>;\n}\n\n\n\nexport const defaultBlocks: DefaultBlocks = {\n FooterLogo: ({ src, alt }) => (\n <img className=\"nbb-footer-logo\" src={src} alt={alt || 'Footer logo'} />\n ),\n FooterText: ({ children }) => <p className=\"nbb-footer-text\">{children}</p>,\n FooterCopyright: ({ children }) => (\n <p className=\"nbb-footer-copyright\">{children}</p>\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 React from \"react\";\nimport { setBlocks, classNames } from \"./lib\";\nimport { defaultBlocks, DefaultBlocks } from \"./blocks\";\nimport \"./footer.css\";\n\nexport type FooterChildren = (props: {\n defaultBlocks: DefaultBlocks,\n settings?: { [key: string]: any }\n}\n) => {\n blocks: Partial<DefaultBlocks>;\n settings?: { [key: string]: any };\n};\n\nconst Footer = ({\n logoSrc,\n items = [],\n className,\n children, copyright }:\n {\n className: string;\n logoSrc: string;\n copyright: React.ReactNode | string;\n items: Array<React.ReactNode>;\n children?: FooterChildren;\n}) => {\n const { blocks } = setBlocks(defaultBlocks, {}, children);\n const { FooterLogo, FooterText, FooterCopyright } = blocks;\n\n return (\n <footer className={classNames(\"nbb-footer\", className)}>\n <FooterLogo src={logoSrc} />\n {items.map((item, index) => (\n <FooterText key={index}>{item}</FooterText>\n ))}\n <FooterCopyright>{copyright}</FooterCopyright>\n </footer>\n );\n};\n\nexport default Footer;\n"],"names":["_jsx","_jsxs"],"mappings":";;SAgBgB,SAAS,CACvB,aAA4B,EAC5B,cAA8B,EAC9B,QAEC,EAAA;IAED,MAAM,OAAO,GAAG;UACZ,QAAQ,CA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GAAG,EAAE,OAAO,GAAI,EAC3B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACrBA,GAAC,CAAA,UAAU,EAAc,EAAA,QAAA,EAAA,IAAI,EAAZ,EAAA,KAAK,CAAqB,CAC5C,CAAC,EACFA,GAAC,CAAA,eAAe,cAAE,SAAS,EAAA,CAAmB,CACvC,EAAA,CAAA;AAEb;;;;","x_google_ignoreList":[2]}
1
+ {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/context.tsx","../src/footer.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","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\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 A & B;\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 { createContext, ReactNode, useContext } from 'react';\n\ntype FooterContextValue = {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n};\n\nconst FooterContext = createContext<FooterContextValue | undefined>(undefined);\n\nexport const FooterProvider = ({\n children,\n ...value\n}: FooterContextValue & {\n children: ReactNode;\n}) => {\n return <FooterContext.Provider value={value}>{children}</FooterContext.Provider>;\n};\n\nexport const useFooterContext = () => {\n const context = useContext<FooterContextValue | undefined>(FooterContext);\n\n if (!context) {\n throw new Error('useFooterContext must be used within a FooterProvider');\n }\n return context;\n};\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport './footer.css';\nimport { BlocksOverride, BlocksOverrideComponent, classNames, createDefaultBlocks, deepMerge } from './lib';\nimport { FooterProvider, useFooterContext } from './context';\n\nconst Footer = <CustomBlocks extends Record<string, ReactNode> = {}>({\n logoSrc,\n content,\n copyright,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'footer'>, 'content'> & {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <FooterProvider\n {...{\n logoSrc,\n content,\n copyright,\n }}\n >\n <footer className={classNames('nbb-footer', className)} {...props}>\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { ...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 </footer>\n </FooterProvider>\n );\n};\n\nFooter.Logo = (props: Partial<ComponentProps<'img'>>) => {\n const { className, logoSrc, src } = deepMerge(useFooterContext(), props);\n\n return (\n <img className={classNames('nbb-footer-logo', className)} src={logoSrc || src} alt={'Footer logo'} {...props} />\n );\n};\n\nFooter.Content = (props: Partial<ComponentProps<'div'>>) => {\n const { className, children, content } = deepMerge(useFooterContext(), props);\n\n return (\n <div className={classNames('nbb-footer-content', className)} {...props}>\n {content || children}\n </div>\n );\n};\n\nFooter.Copyright = (props: Partial<ComponentProps<'div'>>) => {\n const { className, children, copyright } = deepMerge(useFooterContext(), props);\n\n return (\n <div className={classNames('nbb-footer-copyright', className)} {...props}>\n {copyright || children}\n </div>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n logo: Footer.Logo,\n content: Footer.Content,\n copyright: Footer.Copyright,\n});\n\nexport default Footer;\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AACh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xC,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,CAAA,CAAC;;;;","x_google_ignoreList":[0]}
package/dist/lib.d.ts CHANGED
@@ -1,25 +1,78 @@
1
- import { DefaultBlocks, DefaultOptions } from './blocks';
1
+ import { ComponentProps, FunctionComponent, ReactElement, ReactNode } from 'react';
2
2
  /**
3
- * Sets the blocks by merging default blocks with custom blocks provided by the children function.
3
+ * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.
4
4
  *
5
- * @param defaultBlocks - The default blocks to be used.
6
- * @param children - An optional function that returns custom blocks and arguments.
7
- * @param args - Additional unknown arguments.
8
- * @returns An object containing the merged blocks and additional arguments.
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>
9
22
  */
10
- type ChildrenProps = {
23
+ export type BlocksOverride<DefaultBlocks, CustomBlocks> = (({ defaultBlocks, defaultBlockOrder, }: {
11
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]>;
12
44
  };
13
- export declare function setBlocks(defaultBlocks: DefaultBlocks, defaultOptions: DefaultOptions, children?: (props: ChildrenProps) => DefaultOptions & {
14
- blocks: {
15
- [x: string]: any;
16
- };
17
- }): {
18
- blocks: {
19
- [k: string]: any;
20
- };
21
- hideTitle?: boolean;
22
- };
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
+ export declare function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B): A & B;
23
76
  type ClassName = string | ClassName[] | undefined | null;
24
77
  /**
25
78
  * Utility function to join class names together, ignoring undefined or nil values.
package/dist/lib.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD;;;;;;;GAOG;AAGH,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,SAAS,CACvB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,GAAG;IACpD,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC9B;;;;;EAiBF;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"}
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;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,CAAC;CACrD,KAAK;IACJ,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;IAE9C,UAAU,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG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G,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-footer-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,7 +15,7 @@
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
21
  "@rollup/plugin-commonjs": "^28.0.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,19 +0,0 @@
1
- import React from 'react';
2
- export type DefaultBlocks = {
3
- FooterLogo: React.FC<{
4
- src: string;
5
- alt?: string;
6
- }>;
7
- FooterText: React.FC<{
8
- children: React.ReactNode;
9
- }>;
10
- FooterCopyright: React.FC<{
11
- children: React.ReactNode;
12
- }>;
13
- };
14
- export type DefaultOptions = {
15
- hideTitle?: boolean;
16
- };
17
- export declare const defaultOptions: DefaultOptions;
18
- export declare const defaultBlocks: DefaultBlocks;
19
- //# sourceMappingURL=blocks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IACpD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAE5B,CAAC;AAgBF,eAAO,MAAM,aAAa,EAAE,aAQ3B,CAAC"}