@nodeblocks/frontend-footer-block 0.2.0 → 0.2.1
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/context.d.ts +2 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/footer.d.ts +11 -12
- package/dist/footer.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -180
- package/dist/index.esm.js +1 -178
- package/dist/lib.d.ts +19 -3
- package/dist/lib.d.ts.map +1 -1
- package/package.json +23 -15
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
type FooterContextValue = {
|
|
2
|
+
export type FooterContextValue = {
|
|
3
3
|
logoSrc: string;
|
|
4
4
|
copyright: ReactNode;
|
|
5
5
|
content: ReactNode;
|
|
6
6
|
};
|
|
7
|
+
export declare const keys: readonly ["logoSrc", "copyright", "content"];
|
|
7
8
|
export declare const FooterProvider: ({ children, ...value }: FooterContextValue & {
|
|
8
9
|
children: ReactNode;
|
|
9
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export declare const useFooterContext: () => FooterContextValue;
|
|
11
|
-
export {};
|
|
12
12
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,IAAI,8CAA+E,CAAC;AAWjG,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,22 +1,21 @@
|
|
|
1
|
+
import { Box, BoxProps, StackProps } from '@mui/material';
|
|
1
2
|
import { ComponentProps, ReactNode } from 'react';
|
|
2
|
-
import './
|
|
3
|
+
import { FooterContextValue } from './context';
|
|
3
4
|
import { BlocksOverride } from './lib';
|
|
4
|
-
import { Box, Stack } from '@mui/material';
|
|
5
5
|
declare const Footer: {
|
|
6
|
-
<CustomBlocks extends Record<string, ReactNode> = {}>({
|
|
7
|
-
logoSrc: string;
|
|
8
|
-
copyright: ReactNode;
|
|
9
|
-
content: ReactNode;
|
|
6
|
+
<CustomBlocks extends Record<string, ReactNode> = {}>({ className, children, sx, ...props }: Omit<StackProps, "content" | "children"> & Required<Pick<FooterContextValue, "logoSrc" | "content" | "copyright">> & {
|
|
10
7
|
children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;
|
|
11
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
Logo(props: Partial<ComponentProps<typeof Box>>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
Content(props: Partial<
|
|
14
|
-
Copyright(props: Partial<ComponentProps<typeof Box>>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
Logo({ className, sx, ...props }: Partial<ComponentProps<typeof Box> & Pick<FooterContextValue, "logoSrc">>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
Content({ className, children, ...props }: Partial<BoxProps & Pick<FooterContextValue, "content">>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
Copyright({ className, children, ...props }: Partial<ComponentProps<typeof Box> & Pick<FooterContextValue, "copyright">>): import("react/jsx-runtime").JSX.Element;
|
|
15
12
|
};
|
|
16
13
|
declare const defaultBlocks: {
|
|
17
|
-
logo: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme
|
|
18
|
-
content: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme
|
|
19
|
-
|
|
14
|
+
logo: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & Pick<FooterContextValue, "logoSrc">>, ({ className, sx, ...props }: Partial<ComponentProps<typeof Box> & Pick<FooterContextValue, "logoSrc">>) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
content: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
|
|
16
|
+
component?: React.ElementType;
|
|
17
|
+
} & Pick<FooterContextValue, "content">>, ({ className, children, ...props }: Partial<BoxProps & Pick<FooterContextValue, "content">>) => import("react/jsx-runtime").JSX.Element>;
|
|
18
|
+
copyright: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & Pick<FooterContextValue, "copyright">>, ({ className, children, ...props }: Partial<ComponentProps<typeof Box> & Pick<FooterContextValue, "copyright">>) => import("react/jsx-runtime").JSX.Element>;
|
|
20
19
|
};
|
|
21
20
|
export default Footer;
|
|
22
21
|
//# sourceMappingURL=footer.d.ts.map
|
package/dist/footer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../src/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../src/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAS,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,cAAc,EAAY,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAyD,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,cAAc,EAA+E,MAAM,OAAO,CAAC;AAEpH,QAAA,MAAM,MAAM;KAAI,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,8CAK3D,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,UAAU,CAAC,GACzC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC,GAAG;QACxE,QAAQ,CAAC,EAAE,cAAc,CAAC,OAAO,aAAa,EAAE,YAAY,CAAC,CAAC;KAC/D;sCA0CA,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;+CAuBvB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;iDAezG,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;CA5C7E,CAAC;AAuDF,QAAA,MAAM,aAAa;wWAjDhB,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;;;kFAuBvB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;qXAezG,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;CAe5E,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,180 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof global === 'undefined') {
|
|
4
|
-
var global = window;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
-
var react = require('react');
|
|
11
|
-
var material = require('@mui/material');
|
|
12
|
-
|
|
13
|
-
function styleInject(css, ref) {
|
|
14
|
-
if ( ref === void 0 ) ref = {};
|
|
15
|
-
var insertAt = ref.insertAt;
|
|
16
|
-
|
|
17
|
-
if (typeof document === 'undefined') { return; }
|
|
18
|
-
|
|
19
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
20
|
-
var style = document.createElement('style');
|
|
21
|
-
style.type = 'text/css';
|
|
22
|
-
|
|
23
|
-
if (insertAt === 'top') {
|
|
24
|
-
if (head.firstChild) {
|
|
25
|
-
head.insertBefore(style, head.firstChild);
|
|
26
|
-
} else {
|
|
27
|
-
head.appendChild(style);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
head.appendChild(style);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (style.styleSheet) {
|
|
34
|
-
style.styleSheet.cssText = css;
|
|
35
|
-
} else {
|
|
36
|
-
style.appendChild(document.createTextNode(css));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var css_248z = ".nbb-footer img {\n display: block;\n}\n\n.nbb-footer a {\n color: inherit;\n}\n.nbb-footer a:hover {\n text-decoration: underline;\n}\n";
|
|
41
|
-
styleInject(css_248z);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
|
|
45
|
-
*
|
|
46
|
-
* @param components - A map of default block keys to component functions.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* const defaultBlocks = createDefaultBlocks({
|
|
50
|
-
* title: Title,
|
|
51
|
-
* description: Description,
|
|
52
|
-
* form: Form,
|
|
53
|
-
* });
|
|
54
|
-
*/
|
|
55
|
-
function createDefaultBlocks(components) {
|
|
56
|
-
return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, react.createElement(Component, { key })]));
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
|
|
60
|
-
* Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
|
|
61
|
-
*
|
|
62
|
-
* @param props
|
|
63
|
-
* @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
|
|
64
|
-
* @param props.defaultBlocks - The default blocks of outer component.
|
|
65
|
-
* @param props.children - A function returning the JSX to render.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* <BlocksOverrideComponent
|
|
69
|
-
* defaultBlocks={defaultFormBlocks}
|
|
70
|
-
* blocksOverride={children}
|
|
71
|
-
* >
|
|
72
|
-
* {({ blocks, blockOrder }) =>
|
|
73
|
-
* blockOrder.map((key) => (
|
|
74
|
-
* <Fragment key={String(key)}>{blocks[key]}</Fragment>
|
|
75
|
-
* ))
|
|
76
|
-
* }
|
|
77
|
-
* </BlocksOverrideComponent>
|
|
78
|
-
*/
|
|
79
|
-
function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
|
|
80
|
-
if (blocksOverride === undefined) {
|
|
81
|
-
return children({
|
|
82
|
-
// TODO: Remove this assertion
|
|
83
|
-
blocks: defaultBlocks,
|
|
84
|
-
blockOrder: defaultBlockOrder,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (typeof blocksOverride === 'function') {
|
|
88
|
-
const { blocks, blockOrder } = blocksOverride({
|
|
89
|
-
defaultBlocks,
|
|
90
|
-
defaultBlockOrder,
|
|
91
|
-
});
|
|
92
|
-
return children({ blocks, blockOrder });
|
|
93
|
-
}
|
|
94
|
-
return blocksOverride;
|
|
95
|
-
}
|
|
96
|
-
function deepMerge(obj1, obj2) {
|
|
97
|
-
const result = { ...obj1 };
|
|
98
|
-
for (const key in obj2) {
|
|
99
|
-
if (obj2.hasOwnProperty(key)) {
|
|
100
|
-
const val1 = result[key];
|
|
101
|
-
const val2 = obj2[key];
|
|
102
|
-
if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
103
|
-
// If either is an array, replace entirely with obj2's value
|
|
104
|
-
result[key] = val2;
|
|
105
|
-
}
|
|
106
|
-
else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
|
|
107
|
-
result[key] = deepMerge(val1, val2);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
result[key] = val2;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Utility function to join class names together, ignoring undefined or nil values.
|
|
118
|
-
* @param classes - The class names to join.
|
|
119
|
-
* @returns The joined class names.
|
|
120
|
-
*/
|
|
121
|
-
function classNames(...classes) {
|
|
122
|
-
return classes.flat().filter(Boolean).join(' ');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const FooterContext = react.createContext(undefined);
|
|
126
|
-
const FooterProvider = ({ children, ...value }) => {
|
|
127
|
-
return jsxRuntime.jsx(FooterContext.Provider, { value: value, children: children });
|
|
128
|
-
};
|
|
129
|
-
const useFooterContext = () => {
|
|
130
|
-
const context = react.useContext(FooterContext);
|
|
131
|
-
if (!context) {
|
|
132
|
-
throw new Error('useFooterContext must be used within a FooterProvider');
|
|
133
|
-
}
|
|
134
|
-
return context;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const Footer = ({ logoSrc, content, copyright, className, children, ...props }) => {
|
|
138
|
-
const { sx: sxProp, ...restProps } = props;
|
|
139
|
-
const sx = [
|
|
140
|
-
{
|
|
141
|
-
backgroundColor: 'primary.main',
|
|
142
|
-
color: 'primary.contrastText',
|
|
143
|
-
py: 3,
|
|
144
|
-
px: 2,
|
|
145
|
-
typography: 'body2',
|
|
146
|
-
},
|
|
147
|
-
...(Array.isArray(sxProp) ? sxProp : [sxProp]),
|
|
148
|
-
];
|
|
149
|
-
return (jsxRuntime.jsx(material.Stack, { component: "footer", className: classNames('nbb-footer', className), spacing: 2, sx: sx, ...restProps, children: jsxRuntime.jsx(FooterProvider, { logoSrc,
|
|
150
|
-
content,
|
|
151
|
-
copyright, children: jsxRuntime.jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { ...blocks }, blockOrder }) => blockOrder
|
|
152
|
-
.filter((key) => key in blocks)
|
|
153
|
-
.map((key) => jsxRuntime.jsx(react.Fragment, { children: blocks[key] }, String(key))) }) }) }));
|
|
154
|
-
};
|
|
155
|
-
Footer.Logo = (props) => {
|
|
156
|
-
const { className, logoSrc, sx: sxProp, ...restProps } = deepMerge(useFooterContext(), props);
|
|
157
|
-
const sx = [
|
|
158
|
-
{
|
|
159
|
-
pb: 0.5,
|
|
160
|
-
},
|
|
161
|
-
...(Array.isArray(sxProp) ? sxProp : [sxProp]),
|
|
162
|
-
];
|
|
163
|
-
return (jsxRuntime.jsx(material.Box, { className: classNames('nbb-footer-logo', className), sx: sx, ...restProps, children: jsxRuntime.jsx("img", { src: logoSrc, alt: 'Footer logo' }) }));
|
|
164
|
-
};
|
|
165
|
-
Footer.Content = (props) => {
|
|
166
|
-
const { className, children, content } = deepMerge(useFooterContext(), props);
|
|
167
|
-
return (jsxRuntime.jsx(material.Box, { className: classNames('nbb-footer-content', className), ...props, children: content || children }));
|
|
168
|
-
};
|
|
169
|
-
Footer.Copyright = (props) => {
|
|
170
|
-
const { className, children, copyright } = deepMerge(useFooterContext(), props);
|
|
171
|
-
return (jsxRuntime.jsx(material.Box, { className: classNames('nbb-footer-copyright', className), ...props, children: copyright || children }));
|
|
172
|
-
};
|
|
173
|
-
const defaultBlocks = createDefaultBlocks({
|
|
174
|
-
logo: Footer.Logo,
|
|
175
|
-
content: Footer.Content,
|
|
176
|
-
copyright: Footer.Copyright,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
exports.Footer = Footer;
|
|
180
|
-
//# sourceMappingURL=index.cjs.js.map
|
|
1
|
+
"use strict";var r=require("react/jsx-runtime"),e=require("@mui/material"),o=require("react");const t=["logoSrc","copyright","content"],n=o.createContext(void 0),c=({children:e,...o})=>r.jsx(n.Provider,{value:o,children:e}),s=()=>{const r=o.useContext(n);if(!r)throw new Error("useFooterContext must be used within a FooterProvider");return r};function l({blocksOverride:r,defaultBlocks:e,defaultBlockOrder:o,children:t}){if(void 0===r)return t({blocks:e,blockOrder:o});if("function"==typeof r){const{blocks:n,blockOrder:c}=r({defaultBlocks:e,defaultBlockOrder:o});return t({blocks:n,blockOrder:c})}return r}function i(r,e){const o={...r};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r]);return o}function a(...r){return r.flat().filter(Boolean).join(" ")}function d(r,...e){const o={...r};for(const r of e)delete o[r];return o}function u(r,...e){const o={};for(const t of e)t in r&&(o[t]=r[t]);return o}const f=({className:n,children:s,sx:i,...f})=>r.jsx(e.Stack,{component:"footer",className:a("nbb-footer",n),spacing:2,sx:[{backgroundColor:"primary.main",color:"primary.contrastText",py:3,px:2,typography:"body2","& a":{color:"inherit"}},...Array.isArray(i)?i:[i]],...d(f,...t),children:r.jsx(c,{...u(f,...t),children:r.jsx(l,{defaultBlocks:b,defaultBlockOrder:Object.keys(b),blocksOverride:s,children:({blocks:{...e},blockOrder:t})=>t.filter(r=>r in e).map(t=>r.jsx(o.Fragment,{children:e[t]},String(t)))})})}),b=(h={logo:f.Logo=({className:o,sx:n,...c})=>{const l=s(),{logoSrc:u}=i(l,c);return r.jsx(e.Box,{className:a("nbb-footer-logo",o),sx:[{pb:.5,"& img":{display:"block"}},...Array.isArray(n)?n:[n]],...d(c,...t),children:r.jsx("img",{src:u,alt:"Footer logo"})})},content:f.Content=({className:o,children:n,...c})=>{const l=s(),{content:u}=i(l,c);return r.jsx(e.Box,{className:a("nbb-footer-content",o),...d(c,...t),children:u||n})},copyright:f.Copyright=({className:o,children:n,...c})=>{const l=s(),{copyright:u}=i(l,c);return r.jsx(e.Box,{className:a("nbb-footer-copyright",o),...d(c,...t),children:u||n})}},Object.fromEntries(Object.entries(h).map(([r,e])=>[r,o.createElement(e,{key:r})])));var h;exports.Footer=f;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,178 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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';
|
|
9
|
-
import { Stack, Box } from '@mui/material';
|
|
10
|
-
|
|
11
|
-
function styleInject(css, ref) {
|
|
12
|
-
if ( ref === void 0 ) ref = {};
|
|
13
|
-
var insertAt = ref.insertAt;
|
|
14
|
-
|
|
15
|
-
if (typeof document === 'undefined') { return; }
|
|
16
|
-
|
|
17
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
18
|
-
var style = document.createElement('style');
|
|
19
|
-
style.type = 'text/css';
|
|
20
|
-
|
|
21
|
-
if (insertAt === 'top') {
|
|
22
|
-
if (head.firstChild) {
|
|
23
|
-
head.insertBefore(style, head.firstChild);
|
|
24
|
-
} else {
|
|
25
|
-
head.appendChild(style);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
head.appendChild(style);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (style.styleSheet) {
|
|
32
|
-
style.styleSheet.cssText = css;
|
|
33
|
-
} else {
|
|
34
|
-
style.appendChild(document.createTextNode(css));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var css_248z = ".nbb-footer img {\n display: block;\n}\n\n.nbb-footer a {\n color: inherit;\n}\n.nbb-footer a:hover {\n text-decoration: underline;\n}\n";
|
|
39
|
-
styleInject(css_248z);
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
|
|
43
|
-
*
|
|
44
|
-
* @param components - A map of default block keys to component functions.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const defaultBlocks = createDefaultBlocks({
|
|
48
|
-
* title: Title,
|
|
49
|
-
* description: Description,
|
|
50
|
-
* form: Form,
|
|
51
|
-
* });
|
|
52
|
-
*/
|
|
53
|
-
function createDefaultBlocks(components) {
|
|
54
|
-
return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })]));
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
|
|
58
|
-
* Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
|
|
59
|
-
*
|
|
60
|
-
* @param props
|
|
61
|
-
* @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
|
|
62
|
-
* @param props.defaultBlocks - The default blocks of outer component.
|
|
63
|
-
* @param props.children - A function returning the JSX to render.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* <BlocksOverrideComponent
|
|
67
|
-
* defaultBlocks={defaultFormBlocks}
|
|
68
|
-
* blocksOverride={children}
|
|
69
|
-
* >
|
|
70
|
-
* {({ blocks, blockOrder }) =>
|
|
71
|
-
* blockOrder.map((key) => (
|
|
72
|
-
* <Fragment key={String(key)}>{blocks[key]}</Fragment>
|
|
73
|
-
* ))
|
|
74
|
-
* }
|
|
75
|
-
* </BlocksOverrideComponent>
|
|
76
|
-
*/
|
|
77
|
-
function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
|
|
78
|
-
if (blocksOverride === undefined) {
|
|
79
|
-
return children({
|
|
80
|
-
// TODO: Remove this assertion
|
|
81
|
-
blocks: defaultBlocks,
|
|
82
|
-
blockOrder: defaultBlockOrder,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
if (typeof blocksOverride === 'function') {
|
|
86
|
-
const { blocks, blockOrder } = blocksOverride({
|
|
87
|
-
defaultBlocks,
|
|
88
|
-
defaultBlockOrder,
|
|
89
|
-
});
|
|
90
|
-
return children({ blocks, blockOrder });
|
|
91
|
-
}
|
|
92
|
-
return blocksOverride;
|
|
93
|
-
}
|
|
94
|
-
function deepMerge(obj1, obj2) {
|
|
95
|
-
const result = { ...obj1 };
|
|
96
|
-
for (const key in obj2) {
|
|
97
|
-
if (obj2.hasOwnProperty(key)) {
|
|
98
|
-
const val1 = result[key];
|
|
99
|
-
const val2 = obj2[key];
|
|
100
|
-
if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
101
|
-
// If either is an array, replace entirely with obj2's value
|
|
102
|
-
result[key] = val2;
|
|
103
|
-
}
|
|
104
|
-
else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
|
|
105
|
-
result[key] = deepMerge(val1, val2);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
result[key] = val2;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Utility function to join class names together, ignoring undefined or nil values.
|
|
116
|
-
* @param classes - The class names to join.
|
|
117
|
-
* @returns The joined class names.
|
|
118
|
-
*/
|
|
119
|
-
function classNames(...classes) {
|
|
120
|
-
return classes.flat().filter(Boolean).join(' ');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const FooterContext = createContext(undefined);
|
|
124
|
-
const FooterProvider = ({ children, ...value }) => {
|
|
125
|
-
return jsx(FooterContext.Provider, { value: value, children: children });
|
|
126
|
-
};
|
|
127
|
-
const useFooterContext = () => {
|
|
128
|
-
const context = useContext(FooterContext);
|
|
129
|
-
if (!context) {
|
|
130
|
-
throw new Error('useFooterContext must be used within a FooterProvider');
|
|
131
|
-
}
|
|
132
|
-
return context;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const Footer = ({ logoSrc, content, copyright, className, children, ...props }) => {
|
|
136
|
-
const { sx: sxProp, ...restProps } = props;
|
|
137
|
-
const sx = [
|
|
138
|
-
{
|
|
139
|
-
backgroundColor: 'primary.main',
|
|
140
|
-
color: 'primary.contrastText',
|
|
141
|
-
py: 3,
|
|
142
|
-
px: 2,
|
|
143
|
-
typography: 'body2',
|
|
144
|
-
},
|
|
145
|
-
...(Array.isArray(sxProp) ? sxProp : [sxProp]),
|
|
146
|
-
];
|
|
147
|
-
return (jsx(Stack, { component: "footer", className: classNames('nbb-footer', className), spacing: 2, sx: sx, ...restProps, children: jsx(FooterProvider, { logoSrc,
|
|
148
|
-
content,
|
|
149
|
-
copyright, children: jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { ...blocks }, blockOrder }) => blockOrder
|
|
150
|
-
.filter((key) => key in blocks)
|
|
151
|
-
.map((key) => jsx(Fragment, { children: blocks[key] }, String(key))) }) }) }));
|
|
152
|
-
};
|
|
153
|
-
Footer.Logo = (props) => {
|
|
154
|
-
const { className, logoSrc, sx: sxProp, ...restProps } = deepMerge(useFooterContext(), props);
|
|
155
|
-
const sx = [
|
|
156
|
-
{
|
|
157
|
-
pb: 0.5,
|
|
158
|
-
},
|
|
159
|
-
...(Array.isArray(sxProp) ? sxProp : [sxProp]),
|
|
160
|
-
];
|
|
161
|
-
return (jsx(Box, { className: classNames('nbb-footer-logo', className), sx: sx, ...restProps, children: jsx("img", { src: logoSrc, alt: 'Footer logo' }) }));
|
|
162
|
-
};
|
|
163
|
-
Footer.Content = (props) => {
|
|
164
|
-
const { className, children, content } = deepMerge(useFooterContext(), props);
|
|
165
|
-
return (jsx(Box, { className: classNames('nbb-footer-content', className), ...props, children: content || children }));
|
|
166
|
-
};
|
|
167
|
-
Footer.Copyright = (props) => {
|
|
168
|
-
const { className, children, copyright } = deepMerge(useFooterContext(), props);
|
|
169
|
-
return (jsx(Box, { className: classNames('nbb-footer-copyright', className), ...props, children: copyright || children }));
|
|
170
|
-
};
|
|
171
|
-
const defaultBlocks = createDefaultBlocks({
|
|
172
|
-
logo: Footer.Logo,
|
|
173
|
-
content: Footer.Content,
|
|
174
|
-
copyright: Footer.Copyright,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
export { Footer };
|
|
178
|
-
//# sourceMappingURL=index.esm.js.map
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Stack as o,Box as e}from"@mui/material";import{createContext as t,useContext as n,createElement as c,Fragment as l}from"react";const i=["logoSrc","copyright","content"],s=t(void 0),a=({children:o,...e})=>r(s.Provider,{value:e,children:o}),d=()=>{const r=n(s);if(!r)throw new Error("useFooterContext must be used within a FooterProvider");return r};function f({blocksOverride:r,defaultBlocks:o,defaultBlockOrder:e,children:t}){if(void 0===r)return t({blocks:o,blockOrder:e});if("function"==typeof r){const{blocks:n,blockOrder:c}=r({defaultBlocks:o,defaultBlockOrder:e});return t({blocks:n,blockOrder:c})}return r}function u(r,o){const e={...r};for(const r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);return e}function b(...r){return r.flat().filter(Boolean).join(" ")}function m(r,...o){const e={...r};for(const r of o)delete e[r];return e}function p(r,...o){const e={};for(const t of o)t in r&&(e[t]=r[t]);return e}const h=({className:e,children:t,sx:n,...c})=>r(o,{component:"footer",className:b("nbb-footer",e),spacing:2,sx:[{backgroundColor:"primary.main",color:"primary.contrastText",py:3,px:2,typography:"body2","& a":{color:"inherit"}},...Array.isArray(n)?n:[n]],...m(c,...i),children:r(a,{...p(c,...i),children:r(f,{defaultBlocks:y,defaultBlockOrder:Object.keys(y),blocksOverride:t,children:({blocks:{...o},blockOrder:e})=>e.filter(r=>r in o).map(e=>r(l,{children:o[e]},String(e)))})})}),y=(k={logo:h.Logo=({className:o,sx:t,...n})=>{const c=d(),{logoSrc:l}=u(c,n);return r(e,{className:b("nbb-footer-logo",o),sx:[{pb:.5,"& img":{display:"block"}},...Array.isArray(t)?t:[t]],...m(n,...i),children:r("img",{src:l,alt:"Footer logo"})})},content:h.Content=({className:o,children:t,...n})=>{const c=d(),{content:l}=u(c,n);return r(e,{className:b("nbb-footer-content",o),...m(n,...i),children:l||t})},copyright:h.Copyright=({className:o,children:t,...n})=>{const c=d(),{copyright:l}=u(c,n);return r(e,{className:b("nbb-footer-copyright",o),...m(n,...i),children:l||t})}},Object.fromEntries(Object.entries(k).map(([r,o])=>[r,c(o,{key:r})])));var k;export{h as Footer};
|
package/dist/lib.d.ts
CHANGED
|
@@ -72,10 +72,12 @@ export declare function BlocksOverrideComponent<DefaultBlocks extends Record<str
|
|
|
72
72
|
blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];
|
|
73
73
|
}) => ReactNode;
|
|
74
74
|
}): ReactNode;
|
|
75
|
-
type
|
|
76
|
-
[K in keyof
|
|
75
|
+
type MergeKeepingRequired<A, B> = Omit<A, keyof B> & {
|
|
76
|
+
[K in keyof A & keyof B]-?: undefined extends B[K] ? A[K] : B[K];
|
|
77
|
+
} & {
|
|
78
|
+
[K in Exclude<keyof B, keyof A>]: B[K];
|
|
77
79
|
};
|
|
78
|
-
export declare function
|
|
80
|
+
export declare function merge<A extends Record<PropertyKey, any>, B extends Record<PropertyKey, any>>(a: A, b: B): MergeKeepingRequired<A, B>;
|
|
79
81
|
type ClassName = string | ClassName[] | undefined | null;
|
|
80
82
|
/**
|
|
81
83
|
* Utility function to join class names together, ignoring undefined or nil values.
|
|
@@ -83,5 +85,19 @@ type ClassName = string | ClassName[] | undefined | null;
|
|
|
83
85
|
* @returns The joined class names.
|
|
84
86
|
*/
|
|
85
87
|
export declare function classNames(...classes: ClassName[]): string;
|
|
88
|
+
/**
|
|
89
|
+
* Omits the given string keys from `source`.
|
|
90
|
+
*
|
|
91
|
+
* Usage:
|
|
92
|
+
* omit(obj, "a", "b")
|
|
93
|
+
*/
|
|
94
|
+
export declare function omit<T extends object, const Keys extends readonly string[]>(source: T, ...keys: Keys): Omit<T, Extract<Keys[number], keyof T>>;
|
|
95
|
+
/**
|
|
96
|
+
* Picks the given keys out of `source` into a new object.
|
|
97
|
+
*
|
|
98
|
+
* Usage:
|
|
99
|
+
* pick(obj, "a", "b")
|
|
100
|
+
*/
|
|
101
|
+
export declare function pick<T extends object, K extends PropertyKey>(source: T, ...keys: K[]): Pick<T, Extract<K, keyof T>>;
|
|
86
102
|
export {};
|
|
87
103
|
//# sourceMappingURL=lib.d.ts.map
|
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,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,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AC,CAAC,CAQzC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAWnH"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodeblocks/frontend-footer-block",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"main": "dist/index.cjs.js",
|
|
5
|
-
"module": "dist/index.esm.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"main": "./dist/index.cjs.js",
|
|
5
|
+
"module": "./dist/index.esm.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"development": "./src/index.ts",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"default": "./dist/index.esm.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
8
16
|
"files": [
|
|
9
|
-
"dist/"
|
|
10
|
-
"dist/index.css"
|
|
17
|
+
"dist/"
|
|
11
18
|
],
|
|
12
19
|
"scripts": {
|
|
13
|
-
"build": "rollup -c",
|
|
14
|
-
"watch": "rm -rf dist && cross-env NODE_ENV=development rollup -c --watch"
|
|
20
|
+
"build": "npm run typecheck && rollup -c",
|
|
21
|
+
"watch": "rm -rf dist && cross-env NODE_ENV=development rollup -c --watch",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
15
23
|
},
|
|
16
24
|
"peerDependencies": {
|
|
17
|
-
"react": ">=18 <20",
|
|
18
|
-
"react-dom": ">=18 <20",
|
|
19
|
-
"@mui/material": "^7.3.4",
|
|
20
25
|
"@emotion/react": "^11.14.0",
|
|
21
|
-
"@emotion/styled": "^11.14.1"
|
|
26
|
+
"@emotion/styled": "^11.14.1",
|
|
27
|
+
"@mui/material": "^7.3.4",
|
|
28
|
+
"react": ">=18 <20",
|
|
29
|
+
"react-dom": ">=18 <20"
|
|
22
30
|
},
|
|
23
31
|
"devDependencies": {
|
|
24
32
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
25
33
|
"@rollup/plugin-json": "^6.1.0",
|
|
26
34
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
35
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
27
36
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
28
37
|
"@types/react": "19.2.7",
|
|
29
38
|
"@types/react-dom": "19.2.3",
|
|
30
|
-
"rollup": "^4.
|
|
39
|
+
"rollup": "^4.55.1",
|
|
31
40
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
32
|
-
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
33
41
|
"rollup-plugin-postcss": "^4.0.2",
|
|
34
42
|
"rollup-plugin-serve": "^1.1.1",
|
|
35
43
|
"tslib": "^2.8.1",
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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\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 { 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';\nimport { Box, Stack } from '@mui/material';\n\nconst Footer = <CustomBlocks extends Record<string, ReactNode> = {}>({\n logoSrc,\n content,\n copyright,\n className,\n children,\n ...props\n}: Omit<ComponentProps<typeof Stack>, 'content' | 'children'> & {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n const { sx: sxProp, ...restProps } = props;\n const sx = [\n {\n backgroundColor: 'primary.main',\n color: 'primary.contrastText',\n py: 3,\n px: 2,\n typography: 'body2',\n },\n ...(Array.isArray(sxProp) ? sxProp : [sxProp]),\n ];\n return (\n <Stack component=\"footer\" className={classNames('nbb-footer', className)} spacing={2} sx={sx} {...restProps}>\n <FooterProvider\n {...{\n logoSrc,\n content,\n copyright,\n }}\n >\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 </FooterProvider>\n </Stack>\n );\n};\n\nFooter.Logo = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, logoSrc, sx: sxProp, ...restProps } = deepMerge(useFooterContext(), props);\n const sx = [\n {\n pb: 0.5,\n },\n ...(Array.isArray(sxProp) ? sxProp : [sxProp]),\n ];\n return (\n <Box className={classNames('nbb-footer-logo', className)} sx={sx} {...restProps}>\n <img src={logoSrc} alt={'Footer logo'} />\n </Box>\n );\n};\n\nFooter.Content = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, children, content } = deepMerge(useFooterContext(), props);\n\n return (\n <Box className={classNames('nbb-footer-content', className)} {...props}>\n {content || children}\n </Box>\n );\n};\n\nFooter.Copyright = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, children, copyright } = deepMerge(useFooterContext(), props);\n\n return (\n <Box className={classNames('nbb-footer-copyright', className)} {...props}>\n {copyright || children}\n </Box>\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","Stack","Fragment","Box"],"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,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;A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AO,EAAE,GAAG,SAAS,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC;IAE7E,QACEA,eAACI,YAAG,EAAA,EAAC,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAAA,GAAM,KAAK,EAAA,QAAA,EACnE,OAAO,IAAI,QAAQ,EAAA,CAChB;AAEV,CAAC;AAED,MAAM,CAAC,SAAS,GAAG,CAAC,KAA0C,KAAI;AAChE,IAAA,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC;IAE/E,QACEJ,eAACI,YAAG,EAAA,EAAC,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EAAA,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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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\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 { 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';\nimport { Box, Stack } from '@mui/material';\n\nconst Footer = <CustomBlocks extends Record<string, ReactNode> = {}>({\n logoSrc,\n content,\n copyright,\n className,\n children,\n ...props\n}: Omit<ComponentProps<typeof Stack>, 'content' | 'children'> & {\n logoSrc: string;\n copyright: ReactNode;\n content: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n const { sx: sxProp, ...restProps } = props;\n const sx = [\n {\n backgroundColor: 'primary.main',\n color: 'primary.contrastText',\n py: 3,\n px: 2,\n typography: 'body2',\n },\n ...(Array.isArray(sxProp) ? sxProp : [sxProp]),\n ];\n return (\n <Stack component=\"footer\" className={classNames('nbb-footer', className)} spacing={2} sx={sx} {...restProps}>\n <FooterProvider\n {...{\n logoSrc,\n content,\n copyright,\n }}\n >\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 </FooterProvider>\n </Stack>\n );\n};\n\nFooter.Logo = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, logoSrc, sx: sxProp, ...restProps } = deepMerge(useFooterContext(), props);\n const sx = [\n {\n pb: 0.5,\n },\n ...(Array.isArray(sxProp) ? sxProp : [sxProp]),\n ];\n return (\n <Box className={classNames('nbb-footer-logo', className)} sx={sx} {...restProps}>\n <img src={logoSrc} alt={'Footer logo'} />\n </Box>\n );\n};\n\nFooter.Content = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, children, content } = deepMerge(useFooterContext(), props);\n\n return (\n <Box className={classNames('nbb-footer-content', className)} {...props}>\n {content || children}\n </Box>\n );\n};\n\nFooter.Copyright = (props: Partial<ComponentProps<typeof Box>>) => {\n const { className, children, copyright } = deepMerge(useFooterContext(), props);\n\n return (\n <Box className={classNames('nbb-footer-copyright', className)} {...props}>\n {copyright || children}\n </Box>\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;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,G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