@nodeblocks/frontend-hero-block 0.1.1 → 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/Hero.d.ts +29 -32
- package/dist/Hero.d.ts.map +1 -1
- package/dist/context.d.ts +9 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -178
- package/dist/index.esm.js +1 -176
- package/dist/lib.d.ts +19 -3
- package/dist/lib.d.ts.map +1 -1
- package/package.json +26 -15
- package/dist/className.d.ts +0 -9
- package/dist/className.d.ts.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
package/dist/Hero.d.ts
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
3
|
-
import './hero.css';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { HeroContextValue } from './context';
|
|
4
3
|
import { BlocksOverride } from './lib';
|
|
4
|
+
import { StackProps, ButtonProps, BoxProps, TypographyProps } from '@mui/material';
|
|
5
5
|
export declare const Hero: {
|
|
6
|
-
<CustomBlocks extends Record<string, ReactNode> = {}>({
|
|
7
|
-
/** */
|
|
8
|
-
buttonText: string;
|
|
9
|
-
/**
|
|
10
|
-
* Configures the main byline text to display for this component.
|
|
11
|
-
* Supports components to handle inline images and text colors
|
|
12
|
-
*/
|
|
13
|
-
byline: ReactNode;
|
|
14
|
-
/** href for linking Hero */
|
|
15
|
-
onClickButton: () => void;
|
|
16
|
-
/** URL of the image to show in this hero image component */
|
|
17
|
-
imageUrl: string;
|
|
18
|
-
/** Show/hide secondary text */
|
|
19
|
-
secondaryText?: ReactNode;
|
|
20
|
-
/** Show/hide tertiary text */
|
|
21
|
-
tertiaryText?: ReactNode;
|
|
6
|
+
<CustomBlocks extends Record<string, ReactNode> = {}>({ className, children, ...props }: Omit<StackProps, "children"> & Required<Pick<HeroContextValue, "buttonText" | "byline" | "onClickButton" | "imageUrl">> & Partial<Pick<HeroContextValue, "secondaryText" | "tertiaryText">> & {
|
|
22
7
|
children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;
|
|
23
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
HeroImg({ src, ...props }: Partial<
|
|
9
|
+
HeroImg({ component, src, alt, className, ...props }: Partial<BoxProps<"img"> & Pick<HeroContextValue, "imageUrl">>): import("react/jsx-runtime").JSX.Element;
|
|
25
10
|
HeroContent: {
|
|
26
|
-
({ className, children, ...props }: Partial<
|
|
27
|
-
HeroByline({ className, children, ...props }: Partial<
|
|
28
|
-
SecondaryText({ className,
|
|
29
|
-
ActionButton({ className, children, onClick, ...props }: Partial<
|
|
30
|
-
TertiaryText({ className,
|
|
11
|
+
({ className, children, spacing, sx, ...props }: Partial<StackProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
HeroByline({ variant, className, children, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "byline">>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
SecondaryText({ className, variant, sx, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "secondaryText">>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
ActionButton({ className, variant, children, onClick, sx, ...props }: Partial<ButtonProps & Pick<HeroContextValue, "buttonText" | "onClickButton">>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
TertiaryText({ className, sx, color, variant, ...props }: Partial<TypographyProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
31
16
|
};
|
|
32
17
|
};
|
|
33
18
|
declare const defaultBlocks: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
({ className, children, ...props }: Partial<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
TertiaryText({ className, children, ...props }: Partial<ComponentProps<"span">>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
heroContent: import("react").ReactElement<Partial<StackProps>, {
|
|
20
|
+
({ className, children, spacing, sx, ...props }: Partial<StackProps>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
HeroByline({ variant, className, children, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "byline">>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
SecondaryText({ className, variant, sx, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "secondaryText">>): import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
ActionButton({ className, variant, children, onClick, sx, ...props }: Partial<ButtonProps & Pick<HeroContextValue, "buttonText" | "onClickButton">>): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
TertiaryText({ className, sx, color, variant, ...props }: Partial<TypographyProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
41
25
|
}>;
|
|
26
|
+
heroImg: import("react").ReactElement<Partial<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
|
|
27
|
+
component?: React.ElementType;
|
|
28
|
+
} & Pick<HeroContextValue, "imageUrl">>, ({ component, src, alt, className, ...props }: Partial<BoxProps<"img"> & Pick<HeroContextValue, "imageUrl">>) => import("react/jsx-runtime").JSX.Element>;
|
|
29
|
+
heroByline: import("react").ReactElement<Partial<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "children" | "p" | "style" | "color" | "left" | "right" | "className" | "classes" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "bottom" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "sx" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variant" | "variantMapping"> & {
|
|
30
|
+
component?: React.ElementType;
|
|
31
|
+
} & Pick<HeroContextValue, "byline">>, ({ variant, className, children, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "byline">>) => import("react/jsx-runtime").JSX.Element>;
|
|
32
|
+
secondaryText: import("react").ReactElement<Partial<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "children" | "p" | "style" | "color" | "left" | "right" | "className" | "classes" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "bottom" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "sx" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variant" | "variantMapping"> & {
|
|
33
|
+
component?: React.ElementType;
|
|
34
|
+
} & Pick<HeroContextValue, "secondaryText">>, ({ className, variant, sx, ...props }: Partial<TypographyProps & Pick<HeroContextValue, "secondaryText">>) => import("react/jsx-runtime").JSX.Element | null>;
|
|
35
|
+
actionButton: import("react").ReactElement<Partial<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children" | "style" | "color" | "className" | "classes" | "sx" | "tabIndex" | "loading" | "variant" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "href" | "loadingIndicator" | "loadingPosition" | "size" | "startIcon"> & {
|
|
36
|
+
component?: React.ElementType;
|
|
37
|
+
} & Pick<HeroContextValue, "buttonText" | "onClickButton">>, ({ className, variant, children, onClick, sx, ...props }: Partial<ButtonProps & Pick<HeroContextValue, "buttonText" | "onClickButton">>) => import("react/jsx-runtime").JSX.Element>;
|
|
38
|
+
tertiaryText: import("react").ReactElement<Partial<TypographyProps>, ({ className, sx, color, variant, ...props }: Partial<TypographyProps>) => import("react/jsx-runtime").JSX.Element | null>;
|
|
42
39
|
};
|
|
43
40
|
export {};
|
|
44
41
|
//# sourceMappingURL=Hero.d.ts.map
|
package/dist/Hero.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hero.d.ts","sourceRoot":"","sources":["../src/Hero.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Hero.d.ts","sourceRoot":"","sources":["../src/Hero.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAqD,MAAM,WAAW,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAmE,MAAM,OAAO,CAAC;AACxG,OAAO,EAAkC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEnH,eAAO,MAAM,IAAI;KAAI,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,0CAIhE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAC7B,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,QAAQ,GAAG,eAAe,GAAG,UAAU,CAAC,CAAC,GACxF,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,cAAc,CAAC,CAAC,GAAG;QAClE,QAAQ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B,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
type HeroContextValue = {
|
|
2
|
+
export type HeroContextValue = {
|
|
3
3
|
buttonText: string;
|
|
4
|
+
/**
|
|
5
|
+
* Configures the main byline text to display for this component.
|
|
6
|
+
* Supports components to handle inline images and text colors
|
|
7
|
+
*/
|
|
4
8
|
byline: ReactNode;
|
|
5
9
|
onClickButton: () => void;
|
|
10
|
+
/** URL of the image to show in this hero image component */
|
|
6
11
|
imageUrl: string;
|
|
12
|
+
/** Show/hide secondary text */
|
|
7
13
|
secondaryText?: ReactNode;
|
|
14
|
+
/** Show/hide tertiary text */
|
|
8
15
|
tertiaryText?: ReactNode;
|
|
9
16
|
};
|
|
17
|
+
export declare const keys: readonly ["buttonText", "byline", "onClickButton", "imageUrl", "secondaryText", "tertiaryText"];
|
|
10
18
|
export declare const HeroProvider: ({ children, ...value }: HeroContextValue & {
|
|
11
19
|
children: ReactNode;
|
|
12
20
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
21
|
export declare const useHeroContext: () => HeroContextValue;
|
|
14
|
-
export {};
|
|
15
22
|
//# 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,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,IAAI,iGAOyB,CAAC;AAW3C,eAAO,MAAM,YAAY,GAAI,wBAG1B,gBAAgB,GAAG;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,4CAEA,CAAC;AAEF,eAAO,MAAM,cAAc,wBAO1B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,178 +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
|
-
require('@basaldev/blocks-frontend-framework/dist/style.css');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Utility function to join class names together, ignoring undefined or nil values.
|
|
15
|
-
* @param classes - The class names to join.
|
|
16
|
-
* @returns The joined class names.
|
|
17
|
-
*/
|
|
18
|
-
function classNames(...classes) {
|
|
19
|
-
return classes.flat().filter(Boolean).join(' ');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const HeroContext = react.createContext(undefined);
|
|
23
|
-
const HeroProvider = ({ children, ...value }) => {
|
|
24
|
-
return jsxRuntime.jsx(HeroContext.Provider, { value: value, children: children });
|
|
25
|
-
};
|
|
26
|
-
const useHeroContext = () => {
|
|
27
|
-
const context = react.useContext(HeroContext);
|
|
28
|
-
if (!context) {
|
|
29
|
-
throw new Error('useHeroContext must be used within a HeroProvider');
|
|
30
|
-
}
|
|
31
|
-
return context;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function styleInject(css, ref) {
|
|
35
|
-
if ( ref === void 0 ) ref = {};
|
|
36
|
-
var insertAt = ref.insertAt;
|
|
37
|
-
|
|
38
|
-
if (typeof document === 'undefined') { return; }
|
|
39
|
-
|
|
40
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
41
|
-
var style = document.createElement('style');
|
|
42
|
-
style.type = 'text/css';
|
|
43
|
-
|
|
44
|
-
if (insertAt === 'top') {
|
|
45
|
-
if (head.firstChild) {
|
|
46
|
-
head.insertBefore(style, head.firstChild);
|
|
47
|
-
} else {
|
|
48
|
-
head.appendChild(style);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
head.appendChild(style);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (style.styleSheet) {
|
|
55
|
-
style.styleSheet.cssText = css;
|
|
56
|
-
} else {
|
|
57
|
-
style.appendChild(document.createTextNode(css));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var css_248z = ".nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n text-align: center;\n justify-content: center;\n flex-wrap: wrap;\n row-gap: 40px;\n font-family: var(--font-family);\n}\n\n.nbb-hero-content {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n gap: 1em;\n min-width: 400px;\n}\n\n.nbb-hero-tertiary-text {\n font-size: 30px;\n margin-block: 10px;\n}\n\n.nbb-hero-byline {\n font-size: 16px;\n margin-block: 10px;\n}\n\n.nbb-button {\n align-items: center;\n border-radius: var(--border-radius-3);\n border: 1px solid transparent;\n cursor: pointer;\n display: inline-flex;\n font-family: var(--font-family);\n gap: var(--spacing-5xs);\n transition:\n background-color 300ms,\n border-color 300ms,\n color 300ms;\n white-space: nowrap;\n padding: 13px 24px;\n color: var(--color-text-on-primary);\n background-color: var(--color-object-accent-primary);\n}\n";
|
|
62
|
-
styleInject(css_248z);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
|
|
66
|
-
*
|
|
67
|
-
* @param components - A map of default block keys to component functions.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* const defaultBlocks = createDefaultBlocks({
|
|
71
|
-
* title: Title,
|
|
72
|
-
* description: Description,
|
|
73
|
-
* form: Form,
|
|
74
|
-
* });
|
|
75
|
-
*/
|
|
76
|
-
function createDefaultBlocks(components) {
|
|
77
|
-
return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, react.createElement(Component, { key })]));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
|
|
81
|
-
* Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
|
|
82
|
-
*
|
|
83
|
-
* @param props
|
|
84
|
-
* @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
|
|
85
|
-
* @param props.defaultBlocks - The default blocks of outer component.
|
|
86
|
-
* @param props.children - A function returning the JSX to render.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* <BlocksOverrideComponent
|
|
90
|
-
* defaultBlocks={defaultFormBlocks}
|
|
91
|
-
* blocksOverride={children}
|
|
92
|
-
* >
|
|
93
|
-
* {({ blocks, blockOrder }) =>
|
|
94
|
-
* blockOrder.map((key) => (
|
|
95
|
-
* <Fragment key={String(key)}>{blocks[key]}</Fragment>
|
|
96
|
-
* ))
|
|
97
|
-
* }
|
|
98
|
-
* </BlocksOverrideComponent>
|
|
99
|
-
*/
|
|
100
|
-
function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
|
|
101
|
-
if (blocksOverride === undefined) {
|
|
102
|
-
return children({
|
|
103
|
-
// TODO: Remove this assertion
|
|
104
|
-
blocks: defaultBlocks,
|
|
105
|
-
blockOrder: defaultBlockOrder,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (typeof blocksOverride === 'function') {
|
|
109
|
-
const { blocks, blockOrder } = blocksOverride({
|
|
110
|
-
defaultBlocks,
|
|
111
|
-
defaultBlockOrder,
|
|
112
|
-
});
|
|
113
|
-
return children({ blocks, blockOrder });
|
|
114
|
-
}
|
|
115
|
-
return blocksOverride;
|
|
116
|
-
}
|
|
117
|
-
function deepMerge(obj1, obj2) {
|
|
118
|
-
const result = { ...obj1 };
|
|
119
|
-
for (const key in obj2) {
|
|
120
|
-
if (obj2.hasOwnProperty(key)) {
|
|
121
|
-
const val1 = result[key];
|
|
122
|
-
const val2 = obj2[key];
|
|
123
|
-
if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
124
|
-
// If either is an array, replace entirely with obj2's value
|
|
125
|
-
result[key] = val2;
|
|
126
|
-
}
|
|
127
|
-
else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
|
|
128
|
-
result[key] = deepMerge(val1, val2);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
result[key] = val2;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const Hero = ({ onClickButton, buttonText, imageUrl, secondaryText, tertiaryText, byline, className, children, ...props }) => {
|
|
139
|
-
return (jsxRuntime.jsx("div", { className: classNames('nbb-hero-block', className), ...props, children: jsxRuntime.jsx(HeroProvider, { onClickButton,
|
|
140
|
-
buttonText,
|
|
141
|
-
imageUrl,
|
|
142
|
-
secondaryText,
|
|
143
|
-
tertiaryText,
|
|
144
|
-
byline, children: jsxRuntime.jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { item, ...blocks }, blockOrder }) => blockOrder
|
|
145
|
-
.filter((key) => key in blocks)
|
|
146
|
-
.map((key) => jsxRuntime.jsx(react.Fragment, { children: blocks[key] }, String(key))) }) }) }));
|
|
147
|
-
};
|
|
148
|
-
Hero.HeroImg = ({ src, ...props }) => {
|
|
149
|
-
const { className, imageUrl } = deepMerge(useHeroContext(), props);
|
|
150
|
-
return jsxRuntime.jsx("img", { className: classNames('nbb-hero-img', className), src: src || imageUrl, alt: "hero image", ...props });
|
|
151
|
-
};
|
|
152
|
-
const HeroContent = ({ className, children, ...props }) => {
|
|
153
|
-
return (jsxRuntime.jsx("div", { className: classNames('nbb-hero-content', className), ...props, children: children || (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(HeroContent.HeroByline, {}), jsxRuntime.jsx(HeroContent.SecondaryText, {})] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(HeroContent.ActionButton, {}), jsxRuntime.jsx(HeroContent.TertiaryText, {})] })] })) }));
|
|
154
|
-
};
|
|
155
|
-
Hero.HeroContent = HeroContent;
|
|
156
|
-
HeroContent.HeroByline = ({ className, children, ...props }) => {
|
|
157
|
-
const { byline } = deepMerge(useHeroContext(), props);
|
|
158
|
-
return (jsxRuntime.jsx("h6", { className: classNames(className, 'nbb-hero-byline'), ...props, children: children || byline }));
|
|
159
|
-
};
|
|
160
|
-
HeroContent.SecondaryText = ({ className, children, ...props }) => {
|
|
161
|
-
const { secondaryText } = deepMerge(useHeroContext(), props);
|
|
162
|
-
return (jsxRuntime.jsx("h3", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || secondaryText }));
|
|
163
|
-
};
|
|
164
|
-
HeroContent.ActionButton = ({ className, children, onClick, ...props }) => {
|
|
165
|
-
const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);
|
|
166
|
-
return (jsxRuntime.jsx("button", { type: "button", onClick: onClick || onClickButton, className: classNames(className, 'nbb-button'), ...props, children: children || buttonText }));
|
|
167
|
-
};
|
|
168
|
-
HeroContent.TertiaryText = ({ className, children, ...props }) => {
|
|
169
|
-
const { tertiaryText } = deepMerge(useHeroContext(), props);
|
|
170
|
-
return (jsxRuntime.jsx("span", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || tertiaryText }));
|
|
171
|
-
};
|
|
172
|
-
const defaultBlocks = createDefaultBlocks({
|
|
173
|
-
heroImg: Hero.HeroImg,
|
|
174
|
-
heroContent: Hero.HeroContent,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
exports.Hero = Hero;
|
|
178
|
-
//# sourceMappingURL=index.cjs.js.map
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material");const n=["buttonText","byline","onClickButton","imageUrl","secondaryText","tertiaryText"],o=r.createContext(void 0),c=({children:r,...t})=>e.jsx(o.Provider,{value:t,children:r}),i=()=>{const e=r.useContext(o);if(!e)throw new Error("useHeroContext must be used within a HeroProvider");return e};function a({blocksOverride:e,defaultBlocks:r,defaultBlockOrder:t,children:n}){if(void 0===e)return n({blocks:r,blockOrder:t});if("function"==typeof e){const{blocks:o,blockOrder:c}=e({defaultBlocks:r,defaultBlockOrder:t});return n({blocks:o,blockOrder:c})}return e}function s(e,r){const t={...e};for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t}function l(...e){return e.flat().filter(Boolean).join(" ")}function h(e,...r){const t={...e};for(const e of r)delete t[e];return t}function x(e,...r){const t={};for(const n of r)n in e&&(t[n]=e[n]);return t}const d=({className:o,children:i,...s})=>e.jsx(t.Stack,{className:l("nbb-hero-block",o),...h(s,...n),children:e.jsx(c,{...x(s,...n),children:e.jsx(a,{defaultBlocks:b,defaultBlockOrder:Object.keys(b),blocksOverride:i,children:({blocks:{heroByline:t,secondaryText:n,actionButton:o,tertiaryText:c,...i},blockOrder:a})=>a.filter(e=>e in i).map(t=>e.jsx(r.Fragment,{children:i[t]},String(t)))})})});d.HeroImg=({component:r="img",src:o,alt:c="hero image",className:a,...x})=>{const d=i(),{imageUrl:y}=s(d,x);return e.jsx(t.Box,{component:r,src:o||y,alt:c,className:l("nbb-hero-hero-img","nbb-hero-img",a),...h(x,...n)})};const y=({className:r,children:n,spacing:o=3,sx:c,...i})=>e.jsx(t.Stack,{spacing:o,sx:{alignItems:"center",py:5.5,...Array.isArray(c)?c:[c]},className:l("nbb-hero-hero-content","nbb-hero-content",r),...i,children:n||e.jsxs(e.Fragment,{children:[e.jsxs(t.Stack,{sx:{alignItems:"center"},children:[e.jsx(y.HeroByline,{}),e.jsx(y.SecondaryText,{})]}),e.jsxs(t.Stack,{spacing:Number(o)/2,sx:{alignItems:"center"},children:[e.jsx(y.ActionButton,{}),e.jsx(y.TertiaryText,{})]})]})});d.HeroContent=y,y.HeroByline=({variant:r="h6",className:o,children:c,...a})=>{const x=i(),{byline:d}=s(x,a);return e.jsx(t.Typography,{variant:r,className:l(o,"nbb-hero-hero-content-hero-byline","nbb-hero-byline"),...h(a,...n),children:c||d})},y.SecondaryText=({className:r,variant:o="h2",sx:c,...a})=>{const x=i(),{secondaryText:d}=s(x,a),y="children"in a?a.children:d;return y?e.jsx(t.Typography,{variant:o,className:l(r,"nbb-hero-hero-content-secondary-text","nbb-hero-secondary-text"),sx:[{textAlign:"center"},...Array.isArray(c)?c:[c]],...h(a,...n),children:y}):null},y.ActionButton=({className:r,variant:o="contained",children:c,onClick:a,sx:x,...d})=>{const y=i(),{buttonText:b,onClickButton:u}=s(y,d);return e.jsx(t.Button,{variant:o,onClick:a||u,className:l(r,"nbb-hero-hero-content-action-button","nbb-button"),sx:[{fontWeight:600,px:4,py:1.5},...Array.isArray(x)?x:[x]],...h(d,...n),children:c||b})},y.TertiaryText=({className:r,sx:o,color:c="primary",variant:a="button",...x})=>{const d=i(),{tertiaryText:y}=s(d,x),b="children"in x?x.children:y;return b?e.jsx(t.Typography,{color:c,variant:a,className:l(r,"nbb-hero-hero-content-tertiary-text","nbb-hero-tertiary-text"),sx:[e=>({lineHeight:e.typography.body1.lineHeight,fontWeight:e.typography.h1.fontWeight}),...Array.isArray(o)?o:[o]],...h(x,...n),children:b}):null};const b=(u={heroContent:d.HeroContent,heroImg:d.HeroImg,heroByline:y.HeroByline,secondaryText:y.SecondaryText,actionButton:y.ActionButton,tertiaryText:y.TertiaryText},Object.fromEntries(Object.entries(u).map(([e,t])=>[e,r.createElement(t,{key:e})])));var u;exports.Hero=d;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,176 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof global === 'undefined') {
|
|
4
|
-
var global = window;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import { createContext, useContext, createElement, Fragment as Fragment$1 } from 'react';
|
|
9
|
-
import '@basaldev/blocks-frontend-framework/dist/style.css';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Utility function to join class names together, ignoring undefined or nil values.
|
|
13
|
-
* @param classes - The class names to join.
|
|
14
|
-
* @returns The joined class names.
|
|
15
|
-
*/
|
|
16
|
-
function classNames(...classes) {
|
|
17
|
-
return classes.flat().filter(Boolean).join(' ');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const HeroContext = createContext(undefined);
|
|
21
|
-
const HeroProvider = ({ children, ...value }) => {
|
|
22
|
-
return jsx(HeroContext.Provider, { value: value, children: children });
|
|
23
|
-
};
|
|
24
|
-
const useHeroContext = () => {
|
|
25
|
-
const context = useContext(HeroContext);
|
|
26
|
-
if (!context) {
|
|
27
|
-
throw new Error('useHeroContext must be used within a HeroProvider');
|
|
28
|
-
}
|
|
29
|
-
return context;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function styleInject(css, ref) {
|
|
33
|
-
if ( ref === void 0 ) ref = {};
|
|
34
|
-
var insertAt = ref.insertAt;
|
|
35
|
-
|
|
36
|
-
if (typeof document === 'undefined') { return; }
|
|
37
|
-
|
|
38
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
39
|
-
var style = document.createElement('style');
|
|
40
|
-
style.type = 'text/css';
|
|
41
|
-
|
|
42
|
-
if (insertAt === 'top') {
|
|
43
|
-
if (head.firstChild) {
|
|
44
|
-
head.insertBefore(style, head.firstChild);
|
|
45
|
-
} else {
|
|
46
|
-
head.appendChild(style);
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
head.appendChild(style);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (style.styleSheet) {
|
|
53
|
-
style.styleSheet.cssText = css;
|
|
54
|
-
} else {
|
|
55
|
-
style.appendChild(document.createTextNode(css));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var css_248z = ".nbb-hero-block {\n display: flex;\n flex-direction: row-reverse;\n text-align: center;\n justify-content: center;\n flex-wrap: wrap;\n row-gap: 40px;\n font-family: var(--font-family);\n}\n\n.nbb-hero-content {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n gap: 1em;\n min-width: 400px;\n}\n\n.nbb-hero-tertiary-text {\n font-size: 30px;\n margin-block: 10px;\n}\n\n.nbb-hero-byline {\n font-size: 16px;\n margin-block: 10px;\n}\n\n.nbb-button {\n align-items: center;\n border-radius: var(--border-radius-3);\n border: 1px solid transparent;\n cursor: pointer;\n display: inline-flex;\n font-family: var(--font-family);\n gap: var(--spacing-5xs);\n transition:\n background-color 300ms,\n border-color 300ms,\n color 300ms;\n white-space: nowrap;\n padding: 13px 24px;\n color: var(--color-text-on-primary);\n background-color: var(--color-object-accent-primary);\n}\n";
|
|
60
|
-
styleInject(css_248z);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
|
|
64
|
-
*
|
|
65
|
-
* @param components - A map of default block keys to component functions.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* const defaultBlocks = createDefaultBlocks({
|
|
69
|
-
* title: Title,
|
|
70
|
-
* description: Description,
|
|
71
|
-
* form: Form,
|
|
72
|
-
* });
|
|
73
|
-
*/
|
|
74
|
-
function createDefaultBlocks(components) {
|
|
75
|
-
return Object.fromEntries(Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })]));
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
|
|
79
|
-
* Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
|
|
80
|
-
*
|
|
81
|
-
* @param props
|
|
82
|
-
* @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
|
|
83
|
-
* @param props.defaultBlocks - The default blocks of outer component.
|
|
84
|
-
* @param props.children - A function returning the JSX to render.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* <BlocksOverrideComponent
|
|
88
|
-
* defaultBlocks={defaultFormBlocks}
|
|
89
|
-
* blocksOverride={children}
|
|
90
|
-
* >
|
|
91
|
-
* {({ blocks, blockOrder }) =>
|
|
92
|
-
* blockOrder.map((key) => (
|
|
93
|
-
* <Fragment key={String(key)}>{blocks[key]}</Fragment>
|
|
94
|
-
* ))
|
|
95
|
-
* }
|
|
96
|
-
* </BlocksOverrideComponent>
|
|
97
|
-
*/
|
|
98
|
-
function BlocksOverrideComponent({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }) {
|
|
99
|
-
if (blocksOverride === undefined) {
|
|
100
|
-
return children({
|
|
101
|
-
// TODO: Remove this assertion
|
|
102
|
-
blocks: defaultBlocks,
|
|
103
|
-
blockOrder: defaultBlockOrder,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (typeof blocksOverride === 'function') {
|
|
107
|
-
const { blocks, blockOrder } = blocksOverride({
|
|
108
|
-
defaultBlocks,
|
|
109
|
-
defaultBlockOrder,
|
|
110
|
-
});
|
|
111
|
-
return children({ blocks, blockOrder });
|
|
112
|
-
}
|
|
113
|
-
return blocksOverride;
|
|
114
|
-
}
|
|
115
|
-
function deepMerge(obj1, obj2) {
|
|
116
|
-
const result = { ...obj1 };
|
|
117
|
-
for (const key in obj2) {
|
|
118
|
-
if (obj2.hasOwnProperty(key)) {
|
|
119
|
-
const val1 = result[key];
|
|
120
|
-
const val2 = obj2[key];
|
|
121
|
-
if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
122
|
-
// If either is an array, replace entirely with obj2's value
|
|
123
|
-
result[key] = val2;
|
|
124
|
-
}
|
|
125
|
-
else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {
|
|
126
|
-
result[key] = deepMerge(val1, val2);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
result[key] = val2;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const Hero = ({ onClickButton, buttonText, imageUrl, secondaryText, tertiaryText, byline, className, children, ...props }) => {
|
|
137
|
-
return (jsx("div", { className: classNames('nbb-hero-block', className), ...props, children: jsx(HeroProvider, { onClickButton,
|
|
138
|
-
buttonText,
|
|
139
|
-
imageUrl,
|
|
140
|
-
secondaryText,
|
|
141
|
-
tertiaryText,
|
|
142
|
-
byline, children: jsx(BlocksOverrideComponent, { defaultBlocks: defaultBlocks, defaultBlockOrder: Object.keys(defaultBlocks), blocksOverride: children, children: ({ blocks: { item, ...blocks }, blockOrder }) => blockOrder
|
|
143
|
-
.filter((key) => key in blocks)
|
|
144
|
-
.map((key) => jsx(Fragment$1, { children: blocks[key] }, String(key))) }) }) }));
|
|
145
|
-
};
|
|
146
|
-
Hero.HeroImg = ({ src, ...props }) => {
|
|
147
|
-
const { className, imageUrl } = deepMerge(useHeroContext(), props);
|
|
148
|
-
return jsx("img", { className: classNames('nbb-hero-img', className), src: src || imageUrl, alt: "hero image", ...props });
|
|
149
|
-
};
|
|
150
|
-
const HeroContent = ({ className, children, ...props }) => {
|
|
151
|
-
return (jsx("div", { className: classNames('nbb-hero-content', className), ...props, children: children || (jsxs(Fragment, { children: [jsxs("div", { children: [jsx(HeroContent.HeroByline, {}), jsx(HeroContent.SecondaryText, {})] }), jsxs("div", { children: [jsx(HeroContent.ActionButton, {}), jsx(HeroContent.TertiaryText, {})] })] })) }));
|
|
152
|
-
};
|
|
153
|
-
Hero.HeroContent = HeroContent;
|
|
154
|
-
HeroContent.HeroByline = ({ className, children, ...props }) => {
|
|
155
|
-
const { byline } = deepMerge(useHeroContext(), props);
|
|
156
|
-
return (jsx("h6", { className: classNames(className, 'nbb-hero-byline'), ...props, children: children || byline }));
|
|
157
|
-
};
|
|
158
|
-
HeroContent.SecondaryText = ({ className, children, ...props }) => {
|
|
159
|
-
const { secondaryText } = deepMerge(useHeroContext(), props);
|
|
160
|
-
return (jsx("h3", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || secondaryText }));
|
|
161
|
-
};
|
|
162
|
-
HeroContent.ActionButton = ({ className, children, onClick, ...props }) => {
|
|
163
|
-
const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);
|
|
164
|
-
return (jsx("button", { type: "button", onClick: onClick || onClickButton, className: classNames(className, 'nbb-button'), ...props, children: children || buttonText }));
|
|
165
|
-
};
|
|
166
|
-
HeroContent.TertiaryText = ({ className, children, ...props }) => {
|
|
167
|
-
const { tertiaryText } = deepMerge(useHeroContext(), props);
|
|
168
|
-
return (jsx("span", { className: classNames(className, 'nbb-hero-tertiary-text'), ...props, children: children || tertiaryText }));
|
|
169
|
-
};
|
|
170
|
-
const defaultBlocks = createDefaultBlocks({
|
|
171
|
-
heroImg: Hero.HeroImg,
|
|
172
|
-
heroContent: Hero.HeroContent,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
export { Hero };
|
|
176
|
-
//# sourceMappingURL=index.esm.js.map
|
|
1
|
+
import{jsx as e,jsxs as r,Fragment as t}from"react/jsx-runtime";import{createContext as n,useContext as o,createElement as c,Fragment as i}from"react";import{Typography as a,Button as l,Stack as s,Box as h}from"@mui/material";const d=["buttonText","byline","onClickButton","imageUrl","secondaryText","tertiaryText"],b=n(void 0),y=({children:r,...t})=>e(b.Provider,{value:t,children:r}),u=()=>{const e=o(b);if(!e)throw new Error("useHeroContext must be used within a HeroProvider");return e};function m({blocksOverride:e,defaultBlocks:r,defaultBlockOrder:t,children:n}){if(void 0===e)return n({blocks:r,blockOrder:t});if("function"==typeof e){const{blocks:o,blockOrder:c}=e({defaultBlocks:r,defaultBlockOrder:t});return n({blocks:o,blockOrder:c})}return e}function x(e,r){const t={...e};for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t}function f(...e){return e.flat().filter(Boolean).join(" ")}function g(e,...r){const t={...e};for(const e of r)delete t[e];return t}function k(e,...r){const t={};for(const n of r)n in e&&(t[n]=e[n]);return t}const p=({className:r,children:t,...n})=>e(s,{className:f("nbb-hero-block",r),...g(n,...d),children:e(y,{...k(n,...d),children:e(m,{defaultBlocks:T,defaultBlockOrder:Object.keys(T),blocksOverride:t,children:({blocks:{heroByline:r,secondaryText:t,actionButton:n,tertiaryText:o,...c},blockOrder:a})=>a.filter(e=>e in c).map(r=>e(i,{children:c[r]},String(r)))})})});p.HeroImg=({component:r="img",src:t,alt:n="hero image",className:o,...c})=>{const i=u(),{imageUrl:a}=x(i,c);return e(h,{component:r,src:t||a,alt:n,className:f("nbb-hero-hero-img","nbb-hero-img",o),...g(c,...d)})};const B=({className:n,children:o,spacing:c=3,sx:i,...a})=>e(s,{spacing:c,sx:{alignItems:"center",py:5.5,...Array.isArray(i)?i:[i]},className:f("nbb-hero-hero-content","nbb-hero-content",n),...a,children:o||r(t,{children:[r(s,{sx:{alignItems:"center"},children:[e(B.HeroByline,{}),e(B.SecondaryText,{})]}),r(s,{spacing:Number(c)/2,sx:{alignItems:"center"},children:[e(B.ActionButton,{}),e(B.TertiaryText,{})]})]})});p.HeroContent=B,B.HeroByline=({variant:r="h6",className:t,children:n,...o})=>{const c=u(),{byline:i}=x(c,o);return e(a,{variant:r,className:f(t,"nbb-hero-hero-content-hero-byline","nbb-hero-byline"),...g(o,...d),children:n||i})},B.SecondaryText=({className:r,variant:t="h2",sx:n,...o})=>{const c=u(),{secondaryText:i}=x(c,o),l="children"in o?o.children:i;return l?e(a,{variant:t,className:f(r,"nbb-hero-hero-content-secondary-text","nbb-hero-secondary-text"),sx:[{textAlign:"center"},...Array.isArray(n)?n:[n]],...g(o,...d),children:l}):null},B.ActionButton=({className:r,variant:t="contained",children:n,onClick:o,sx:c,...i})=>{const a=u(),{buttonText:s,onClickButton:h}=x(a,i);return e(l,{variant:t,onClick:o||h,className:f(r,"nbb-hero-hero-content-action-button","nbb-button"),sx:[{fontWeight:600,px:4,py:1.5},...Array.isArray(c)?c:[c]],...g(i,...d),children:n||s})},B.TertiaryText=({className:r,sx:t,color:n="primary",variant:o="button",...c})=>{const i=u(),{tertiaryText:l}=x(i,c),s="children"in c?c.children:l;return s?e(a,{color:n,variant:o,className:f(r,"nbb-hero-hero-content-tertiary-text","nbb-hero-tertiary-text"),sx:[e=>({lineHeight:e.typography.body1.lineHeight,fontWeight:e.typography.h1.fontWeight}),...Array.isArray(t)?t:[t]],...g(c,...d),children:s}):null};const T=(v={heroContent:p.HeroContent,heroImg:p.HeroImg,heroByline:B.HeroByline,secondaryText:B.SecondaryText,actionButton:B.ActionButton,tertiaryText:B.TertiaryText},Object.fromEntries(Object.entries(v).map(([e,r])=>[e,c(r,{key:e})])));var v;export{p as Hero};
|
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,CAAC,EAAE,CAAC;CACrD,KAAK;IACJ,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,YAAY,C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C,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,32 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodeblocks/frontend-hero-block",
|
|
3
|
-
"version": "0.
|
|
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": "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
|
-
"
|
|
25
|
+
"@emotion/react": "^11.14.0",
|
|
26
|
+
"@emotion/styled": "^11.14.1",
|
|
27
|
+
"@mui/material": "^7.3.5",
|
|
28
|
+
"react": ">=18 <20",
|
|
29
|
+
"react-dom": ">=18 <20"
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
32
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
22
33
|
"@rollup/plugin-json": "^6.1.0",
|
|
23
34
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
35
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
24
36
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
25
|
-
"@types/react": "
|
|
26
|
-
"@types/react-dom": "
|
|
27
|
-
"rollup": "^4.
|
|
37
|
+
"@types/react": "19.2.7",
|
|
38
|
+
"@types/react-dom": "19.2.3",
|
|
39
|
+
"rollup": "^4.55.1",
|
|
28
40
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
29
|
-
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
30
41
|
"rollup-plugin-postcss": "^4.0.2",
|
|
31
42
|
"rollup-plugin-serve": "^1.1.1",
|
|
32
43
|
"tslib": "^2.8.1",
|
package/dist/className.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type ClassName = string | ClassName[] | undefined | null;
|
|
2
|
-
/**
|
|
3
|
-
* Utility function to join class names together, ignoring undefined or nil values.
|
|
4
|
-
* @param classes - The class names to join.
|
|
5
|
-
* @returns The joined class names.
|
|
6
|
-
*/
|
|
7
|
-
export declare function classNames(...classes: ClassName[]): string;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=className.d.ts.map
|
package/dist/className.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"className.d.ts","sourceRoot":"","sources":["../src/className.tsx"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAE1D"}
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/className.tsx","../src/context.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/Hero.tsx"],"sourcesContent":["type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { createContext, ReactNode, useContext } from 'react';\n\ntype HeroContextValue = {\n buttonText: string;\n byline: ReactNode;\n onClickButton: () => void;\n imageUrl: string;\n secondaryText?: ReactNode;\n tertiaryText?: ReactNode;\n};\n\nconst HeroContext = createContext<HeroContextValue | undefined>(undefined);\n\nexport const HeroProvider = ({\n children,\n ...value\n}: HeroContextValue & {\n children: ReactNode;\n}) => {\n return <HeroContext.Provider value={value}>{children}</HeroContext.Provider>;\n};\n\nexport const useHeroContext = () => {\n const context = useContext<HeroContextValue | undefined>(HeroContext);\n\n if (!context) {\n throw new Error('useHeroContext must be used within a HeroProvider');\n }\n return context;\n};\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { ComponentProps, createElement, FunctionComponent, ReactElement, ReactNode } from 'react';\n\n/**\n * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.\n *\n * @example\n * <Block>\n * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({\n * blocks: {\n * ...defaultBlocks,\n * header: {\n * ...header,\n * props: {\n * ...header.props,\n * label: \"Custom Label\"\n * }\n * },\n * subheader: <CustomComponent />\n * },\n * blockOrder: [\"header\", \"subheader\", \"body\", \"footer\"]\n * })}\n * </Block>\n */\nexport type BlocksOverride<DefaultBlocks, CustomBlocks> =\n | (({\n defaultBlocks,\n defaultBlockOrder,\n }: {\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: readonly (keyof DefaultBlocks)[];\n }) => {\n blocks: Partial<DefaultBlocks> & CustomBlocks;\n // NOTE: This specific combination allows proper autocomplete.\n blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];\n })\n | ReactNode;\n\n/**\n * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.\n *\n * @param components - A map of default block keys to component functions.\n *\n * @example\n * const defaultBlocks = createDefaultBlocks({\n * title: Title,\n * description: Description,\n * form: Form,\n * });\n */\nexport function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(\n components: T\n): {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n} {\n return Object.fromEntries(\n Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })])\n ) as {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n };\n}\n\n/**\n * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.\n * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.\n *\n * @param props\n * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).\n * @param props.defaultBlocks - The default blocks of outer component.\n * @param props.children - A function returning the JSX to render.\n *\n * @example\n * <BlocksOverrideComponent\n * defaultBlocks={defaultFormBlocks}\n * blocksOverride={children}\n * >\n * {({ blocks, blockOrder }) =>\n * blockOrder.map((key) => (\n * <Fragment key={String(key)}>{blocks[key]}</Fragment>\n * ))\n * }\n * </BlocksOverrideComponent>\n */\nexport function BlocksOverrideComponent<\n DefaultBlocks extends Record<string, ReactNode>,\n CustomBlocks extends Record<string, ReactNode>,\n>({\n blocksOverride,\n defaultBlocks,\n defaultBlockOrder,\n children,\n}: {\n blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: (keyof DefaultBlocks)[];\n children: ({\n blocks,\n blockOrder,\n }: {\n // TODO: Possibly find an alternative to Partial<CustomBlocks>\n blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;\n blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];\n }) => ReactNode;\n}) {\n if (blocksOverride === undefined) {\n return children({\n // TODO: Remove this assertion\n blocks: defaultBlocks as DefaultBlocks & Partial<CustomBlocks>,\n blockOrder: defaultBlockOrder,\n });\n }\n\n if (typeof blocksOverride === 'function') {\n const { blocks, blockOrder } = blocksOverride({\n defaultBlocks,\n defaultBlockOrder,\n });\n\n return children({ blocks, blockOrder });\n }\n\n return blocksOverride;\n}\n\ntype MergeTypes<Object1, Object2> = {\n [K in keyof Object1 | keyof Object2]: K extends keyof Object1\n ? Object1[K]\n : K extends keyof Object2\n ? Object2[K]\n : never;\n};\n\nexport function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B) {\n const result: Record<string, any> = { ...obj1 };\n\n for (const key in obj2) {\n if (obj2.hasOwnProperty(key)) {\n const val1 = result[key];\n const val2 = obj2[key];\n\n if (Array.isArray(val1) || Array.isArray(val2)) {\n // If either is an array, replace entirely with obj2's value\n result[key] = val2;\n } else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {\n result[key] = deepMerge(val1, val2);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as MergeTypes<B, A>;\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport { classNames } from './className';\nimport { HeroProvider, useHeroContext } from './context';\nimport '@basaldev/blocks-frontend-framework/dist/style.css';\nimport './hero.css';\nimport { BlocksOverride, BlocksOverrideComponent, createDefaultBlocks, deepMerge } from './lib';\n\nexport const Hero = <CustomBlocks extends Record<string, ReactNode> = {}>({\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Show/hide secondary text */\n secondaryText?: ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <div className={classNames('nbb-hero-block', className)} {...props}>\n <HeroProvider\n {...{\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n }}\n >\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { item, ...blocks }, blockOrder }) =>\n blockOrder\n .filter((key) => key in blocks)\n .map<ReactNode>((key) => <Fragment key={String(key)}>{blocks[key]}</Fragment>)\n }\n </BlocksOverrideComponent>\n </HeroProvider>\n </div>\n );\n};\n\nHero.HeroImg = ({ src, ...props }: Partial<ComponentProps<'img'>>) => {\n const { className, imageUrl } = deepMerge(useHeroContext(), props);\n\n return <img className={classNames('nbb-hero-img', className)} src={src || imageUrl} alt=\"hero image\" {...props} />;\n};\n\nconst HeroContent = ({ className, children, ...props }: Partial<ComponentProps<'div'>>) => {\n return (\n <div className={classNames('nbb-hero-content', className)} {...props}>\n {children || (\n <>\n <div>\n <HeroContent.HeroByline />\n <HeroContent.SecondaryText />\n </div>\n <div>\n <HeroContent.ActionButton />\n <HeroContent.TertiaryText />\n </div>\n </>\n )}\n </div>\n );\n};\n\nHero.HeroContent = HeroContent;\n\nHeroContent.HeroByline = ({ className, children, ...props }: Partial<ComponentProps<'h6'>>) => {\n const { byline } = deepMerge(useHeroContext(), props);\n\n return (\n <h6 className={classNames(className, 'nbb-hero-byline')} {...props}>\n {children || byline}\n </h6>\n );\n};\n\nHeroContent.SecondaryText = ({ className, children, ...props }: Partial<ComponentProps<'h3'>>) => {\n const { secondaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <h3 className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || secondaryText}\n </h3>\n );\n};\n\nHeroContent.ActionButton = ({ className, children, onClick, ...props }: Partial<ComponentProps<'button'>>) => {\n const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);\n\n return (\n <button type=\"button\" onClick={onClick || onClickButton} className={classNames(className, 'nbb-button')} {...props}>\n {children || buttonText}\n </button>\n );\n};\n\nHeroContent.TertiaryText = ({ className, children, ...props }: Partial<ComponentProps<'span'>>) => {\n const { tertiaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <span className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || tertiaryText}\n </span>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n heroImg: Hero.HeroImg,\n heroContent: Hero.HeroContent,\n});\n"],"names":["createContext","_jsx","useContext","createElement","Fragment","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,GAAG,OAAoB,EAAA;AAChD,IAAA,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD;;ACEA,MAAM,WAAW,GAAGA,mBAAa,CAA+B,SAAS,CAAC;AAEnE,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,GAAG,KAAK,EAGT,KAAI;IACH,OAAOC,cAAA,CAAC,W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KAAK,EAAA,QAAA,EACxE,QAAQ,IAAI,YAAY,EAAA,CACpB;AAEX,CAAC;AAED,MAAM,aAAa,GAAG,mBAAmB,CAAC;IACxC,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,WAAW,EAAE,IAAI,CAAC,WAAW;AAC9B,CAAA,CAAC;;;;","x_google_ignoreList":[2]}
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/className.tsx","../src/context.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/lib.ts","../src/Hero.tsx"],"sourcesContent":["type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { createContext, ReactNode, useContext } from 'react';\n\ntype HeroContextValue = {\n buttonText: string;\n byline: ReactNode;\n onClickButton: () => void;\n imageUrl: string;\n secondaryText?: ReactNode;\n tertiaryText?: ReactNode;\n};\n\nconst HeroContext = createContext<HeroContextValue | undefined>(undefined);\n\nexport const HeroProvider = ({\n children,\n ...value\n}: HeroContextValue & {\n children: ReactNode;\n}) => {\n return <HeroContext.Provider value={value}>{children}</HeroContext.Provider>;\n};\n\nexport const useHeroContext = () => {\n const context = useContext<HeroContextValue | undefined>(HeroContext);\n\n if (!context) {\n throw new Error('useHeroContext must be used within a HeroProvider');\n }\n return context;\n};\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { ComponentProps, createElement, FunctionComponent, ReactElement, ReactNode } from 'react';\n\n/**\n * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.\n *\n * @example\n * <Block>\n * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({\n * blocks: {\n * ...defaultBlocks,\n * header: {\n * ...header,\n * props: {\n * ...header.props,\n * label: \"Custom Label\"\n * }\n * },\n * subheader: <CustomComponent />\n * },\n * blockOrder: [\"header\", \"subheader\", \"body\", \"footer\"]\n * })}\n * </Block>\n */\nexport type BlocksOverride<DefaultBlocks, CustomBlocks> =\n | (({\n defaultBlocks,\n defaultBlockOrder,\n }: {\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: readonly (keyof DefaultBlocks)[];\n }) => {\n blocks: Partial<DefaultBlocks> & CustomBlocks;\n // NOTE: This specific combination allows proper autocomplete.\n blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];\n })\n | ReactNode;\n\n/**\n * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.\n *\n * @param components - A map of default block keys to component functions.\n *\n * @example\n * const defaultBlocks = createDefaultBlocks({\n * title: Title,\n * description: Description,\n * form: Form,\n * });\n */\nexport function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(\n components: T\n): {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n} {\n return Object.fromEntries(\n Object.entries(components).map(([key, Component]) => [key, createElement(Component, { key })])\n ) as {\n [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;\n };\n}\n\n/**\n * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.\n * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.\n *\n * @param props\n * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).\n * @param props.defaultBlocks - The default blocks of outer component.\n * @param props.children - A function returning the JSX to render.\n *\n * @example\n * <BlocksOverrideComponent\n * defaultBlocks={defaultFormBlocks}\n * blocksOverride={children}\n * >\n * {({ blocks, blockOrder }) =>\n * blockOrder.map((key) => (\n * <Fragment key={String(key)}>{blocks[key]}</Fragment>\n * ))\n * }\n * </BlocksOverrideComponent>\n */\nexport function BlocksOverrideComponent<\n DefaultBlocks extends Record<string, ReactNode>,\n CustomBlocks extends Record<string, ReactNode>,\n>({\n blocksOverride,\n defaultBlocks,\n defaultBlockOrder,\n children,\n}: {\n blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;\n defaultBlocks: DefaultBlocks;\n defaultBlockOrder: (keyof DefaultBlocks)[];\n children: ({\n blocks,\n blockOrder,\n }: {\n // TODO: Possibly find an alternative to Partial<CustomBlocks>\n blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;\n blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];\n }) => ReactNode;\n}) {\n if (blocksOverride === undefined) {\n return children({\n // TODO: Remove this assertion\n blocks: defaultBlocks as DefaultBlocks & Partial<CustomBlocks>,\n blockOrder: defaultBlockOrder,\n });\n }\n\n if (typeof blocksOverride === 'function') {\n const { blocks, blockOrder } = blocksOverride({\n defaultBlocks,\n defaultBlockOrder,\n });\n\n return children({ blocks, blockOrder });\n }\n\n return blocksOverride;\n}\n\ntype MergeTypes<Object1, Object2> = {\n [K in keyof Object1 | keyof Object2]: K extends keyof Object1\n ? Object1[K]\n : K extends keyof Object2\n ? Object2[K]\n : never;\n};\n\nexport function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B) {\n const result: Record<string, any> = { ...obj1 };\n\n for (const key in obj2) {\n if (obj2.hasOwnProperty(key)) {\n const val1 = result[key];\n const val2 = obj2[key];\n\n if (Array.isArray(val1) || Array.isArray(val2)) {\n // If either is an array, replace entirely with obj2's value\n result[key] = val2;\n } else if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null) {\n result[key] = deepMerge(val1, val2);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as MergeTypes<B, A>;\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import { ComponentProps, Fragment, ReactNode } from 'react';\nimport { classNames } from './className';\nimport { HeroProvider, useHeroContext } from './context';\nimport '@basaldev/blocks-frontend-framework/dist/style.css';\nimport './hero.css';\nimport { BlocksOverride, BlocksOverrideComponent, createDefaultBlocks, deepMerge } from './lib';\n\nexport const Hero = <CustomBlocks extends Record<string, ReactNode> = {}>({\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n className,\n children,\n ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n /** */\n buttonText: string;\n /**\n * Configures the main byline text to display for this component.\n * Supports components to handle inline images and text colors\n */\n byline: ReactNode;\n /** href for linking Hero */\n onClickButton: () => void;\n /** URL of the image to show in this hero image component */\n imageUrl: string;\n /** Show/hide secondary text */\n secondaryText?: ReactNode;\n /** Show/hide tertiary text */\n tertiaryText?: ReactNode;\n children?: BlocksOverride<typeof defaultBlocks, CustomBlocks>;\n}) => {\n return (\n <div className={classNames('nbb-hero-block', className)} {...props}>\n <HeroProvider\n {...{\n onClickButton,\n buttonText,\n imageUrl,\n secondaryText,\n tertiaryText,\n byline,\n }}\n >\n <BlocksOverrideComponent\n defaultBlocks={defaultBlocks}\n defaultBlockOrder={Object.keys(defaultBlocks) as (keyof typeof defaultBlocks)[]}\n blocksOverride={children}\n >\n {({ blocks: { item, ...blocks }, blockOrder }) =>\n blockOrder\n .filter((key) => key in blocks)\n .map<ReactNode>((key) => <Fragment key={String(key)}>{blocks[key]}</Fragment>)\n }\n </BlocksOverrideComponent>\n </HeroProvider>\n </div>\n );\n};\n\nHero.HeroImg = ({ src, ...props }: Partial<ComponentProps<'img'>>) => {\n const { className, imageUrl } = deepMerge(useHeroContext(), props);\n\n return <img className={classNames('nbb-hero-img', className)} src={src || imageUrl} alt=\"hero image\" {...props} />;\n};\n\nconst HeroContent = ({ className, children, ...props }: Partial<ComponentProps<'div'>>) => {\n return (\n <div className={classNames('nbb-hero-content', className)} {...props}>\n {children || (\n <>\n <div>\n <HeroContent.HeroByline />\n <HeroContent.SecondaryText />\n </div>\n <div>\n <HeroContent.ActionButton />\n <HeroContent.TertiaryText />\n </div>\n </>\n )}\n </div>\n );\n};\n\nHero.HeroContent = HeroContent;\n\nHeroContent.HeroByline = ({ className, children, ...props }: Partial<ComponentProps<'h6'>>) => {\n const { byline } = deepMerge(useHeroContext(), props);\n\n return (\n <h6 className={classNames(className, 'nbb-hero-byline')} {...props}>\n {children || byline}\n </h6>\n );\n};\n\nHeroContent.SecondaryText = ({ className, children, ...props }: Partial<ComponentProps<'h3'>>) => {\n const { secondaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <h3 className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || secondaryText}\n </h3>\n );\n};\n\nHeroContent.ActionButton = ({ className, children, onClick, ...props }: Partial<ComponentProps<'button'>>) => {\n const { buttonText, onClickButton } = deepMerge(useHeroContext(), props);\n\n return (\n <button type=\"button\" onClick={onClick || onClickButton} className={classNames(className, 'nbb-button')} {...props}>\n {children || buttonText}\n </button>\n );\n};\n\nHeroContent.TertiaryText = ({ className, children, ...props }: Partial<ComponentProps<'span'>>) => {\n const { tertiaryText } = deepMerge(useHeroContext(), props);\n\n return (\n <span className={classNames(className, 'nbb-hero-tertiary-text')} {...props}>\n {children || tertiaryText}\n </span>\n );\n};\n\nconst defaultBlocks = createDefaultBlocks({\n heroImg: Hero.HeroImg,\n heroContent: Hero.HeroContent,\n});\n"],"names":["_jsx","Fragment","_jsxs","_Fragment"],"mappings":";;;;;;;;;;AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,GAAG,OAAoB,EAAA;AACh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