@nodeblocks/frontend-how-to-use-block 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HowToUse.d.ts +2 -6
- package/dist/HowToUse.d.ts.map +1 -1
- package/dist/blocks.d.ts +5 -15
- package/dist/blocks.d.ts.map +1 -1
- package/dist/index.cjs.js +36 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +36 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/lib.d.ts +30 -0
- package/dist/lib.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/className.d.ts +0 -9
- package/dist/className.d.ts.map +0 -1
package/dist/HowToUse.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './how-to-use.css';
|
|
3
3
|
import { CardProps, DefaultBlocks, DefaultSettings } from './blocks';
|
|
4
|
+
import { DefaultBlocksFunction } from './lib';
|
|
4
5
|
type HowToUseProps = {
|
|
5
6
|
className: string;
|
|
6
7
|
title: string;
|
|
@@ -8,12 +9,7 @@ type HowToUseProps = {
|
|
|
8
9
|
linkHref?: string;
|
|
9
10
|
linkText?: string;
|
|
10
11
|
list: CardProps[];
|
|
11
|
-
children?:
|
|
12
|
-
blocks: {
|
|
13
|
-
[x: string]: any;
|
|
14
|
-
};
|
|
15
|
-
settings?: DefaultSettings;
|
|
16
|
-
};
|
|
12
|
+
children?: DefaultBlocksFunction<DefaultBlocks, DefaultSettings>;
|
|
17
13
|
};
|
|
18
14
|
export declare const HowToUse: React.FC<HowToUseProps>;
|
|
19
15
|
export default HowToUse;
|
package/dist/HowToUse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HowToUse.d.ts","sourceRoot":"","sources":["../src/HowToUse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"HowToUse.d.ts","sourceRoot":"","sources":["../src/HowToUse.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAkC,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAc,qBAAqB,EAAa,MAAM,OAAO,CAAC;AAErE,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,qBAAqB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;CAClE,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAuC5C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/dist/blocks.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export type DefaultBlocks = {
|
|
|
11
11
|
HowToUseArrowIcon: React.FC;
|
|
12
12
|
HowToUseCardList: React.FC<{
|
|
13
13
|
list: CardProps[];
|
|
14
|
+
CardComponent: React.FC<CardProps>;
|
|
15
|
+
IconComponent: React.FC;
|
|
16
|
+
showArrows: boolean;
|
|
14
17
|
}>;
|
|
15
18
|
};
|
|
16
19
|
export type DefaultSettings = {
|
|
@@ -21,27 +24,14 @@ export type CardProps = {
|
|
|
21
24
|
description: string;
|
|
22
25
|
icon: string;
|
|
23
26
|
};
|
|
24
|
-
export declare function setBlocks(defaultBlocks: DefaultBlocks, children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {
|
|
25
|
-
blocks: {
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
};
|
|
28
|
-
settings?: DefaultSettings;
|
|
29
|
-
}, settings?: DefaultSettings): {
|
|
30
|
-
blocks: {
|
|
31
|
-
[k: string]: any;
|
|
32
|
-
};
|
|
33
|
-
settings: {
|
|
34
|
-
showArrows?: boolean | undefined;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
27
|
export declare function BottomLink({ href, children }: {
|
|
38
28
|
href: string;
|
|
39
29
|
children: React.ReactNode;
|
|
40
30
|
}): import("react/jsx-runtime").JSX.Element;
|
|
41
31
|
export declare function ArrowIcon(): import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
export declare function CardList({ list,
|
|
32
|
+
export declare function CardList({ list, CardComponent, IconComponent, showArrows }: {
|
|
43
33
|
list: CardProps[];
|
|
44
|
-
|
|
34
|
+
CardComponent?: React.FC<CardProps>;
|
|
45
35
|
IconComponent?: React.FC;
|
|
46
36
|
showArrows?: boolean;
|
|
47
37
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IACxB,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAClC,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IAC1E,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5B,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;QACvB,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QACnC,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;QACxB,UAAU,EAAE,OAAO,CAAA;KACtB,CAAC,CAAC;CACN,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,UAAU,EAAE,OAAO,CAAC;CACvB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AA0BF,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAYzF;AACD,wBAAgB,SAAS,4CAExB;AAED,wBAAgB,QAAQ,CAAC,EACrB,IAAS,EACT,aAAoB,EACpB,aAAyB,EACzB,UAAiB,EACpB,EAAE;IACC,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;CACnB,2CAOJ;AAED,eAAO,MAAM,eAAe;;CAE3B,CAAA;AAED,eAAO,MAAM,aAAa;0CAjDmB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;iDAfpC,SAAS;;;;CAsEpD,CAAA"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -38,28 +38,15 @@ const Card = ({ title, description, icon }) => {
|
|
|
38
38
|
const HowToUseHeader = ({ title, subtitle }) => {
|
|
39
39
|
return (jsxRuntime.jsxs("div", { className: "nbb-section-header", children: [jsxRuntime.jsx("h6", { children: title }), jsxRuntime.jsx("h4", { children: subtitle })] }));
|
|
40
40
|
};
|
|
41
|
-
function setBlocks(defaultBlocks, children, settings) {
|
|
42
|
-
const { blocks: customBlocks = {}, settings: customSettings = {} } = children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };
|
|
43
|
-
return {
|
|
44
|
-
blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
|
|
45
|
-
key,
|
|
46
|
-
customBlocks[key] || defaultComponent,
|
|
47
|
-
])),
|
|
48
|
-
settings: {
|
|
49
|
-
...settings,
|
|
50
|
-
...customSettings,
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
41
|
function BottomLink({ href, children }) {
|
|
55
42
|
return (jsxRuntime.jsx("div", { className: "nbb-sign-up", children: jsxRuntime.jsx("a", { href: href, rel: "noreferrer noopener", className: "nbb-sign-up-button", children: children }) }));
|
|
56
43
|
}
|
|
57
44
|
function ArrowIcon() {
|
|
58
45
|
return jsxRuntime.jsx("span", { className: "material-symbols-outlined nbb-arrow", children: "expand_more" });
|
|
59
46
|
}
|
|
60
|
-
function CardList({ list = [],
|
|
47
|
+
function CardList({ list = [], CardComponent = Card, IconComponent = ArrowIcon, showArrows = true }) {
|
|
61
48
|
return jsxRuntime.jsx("div", { className: "nbb-how-to-use-steps", children: list.map(c => {
|
|
62
|
-
return jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(
|
|
49
|
+
return jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(CardComponent, { ...c }, c.title), showArrows && jsxRuntime.jsx(IconComponent, {})] }, c.title);
|
|
63
50
|
}) });
|
|
64
51
|
}
|
|
65
52
|
const defaultSettings = {
|
|
@@ -73,6 +60,38 @@ const defaultBlocks = {
|
|
|
73
60
|
HowToUseCardList: CardList,
|
|
74
61
|
};
|
|
75
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sets the blocks by merging default blocks with custom blocks provided by the children function.
|
|
65
|
+
*
|
|
66
|
+
* @param defaultBlocks - The default blocks to be used.
|
|
67
|
+
* @param defaultOptions - The default options to be passed to the children function.
|
|
68
|
+
* @param children - An optional function that returns custom blocks and additional options.
|
|
69
|
+
* @returns An object containing the merged blocks and all options from both defaults and children.
|
|
70
|
+
*/
|
|
71
|
+
function setBlocks(defaultBlocks, defaultOptions, children) {
|
|
72
|
+
let currentChildren = children;
|
|
73
|
+
if (Array.isArray(children)) {
|
|
74
|
+
const functionChild = children.find((child) => typeof child === 'function');
|
|
75
|
+
if (!functionChild) {
|
|
76
|
+
return { blocks: defaultBlocks };
|
|
77
|
+
}
|
|
78
|
+
currentChildren = functionChild;
|
|
79
|
+
}
|
|
80
|
+
if (typeof currentChildren !== 'function') {
|
|
81
|
+
return { blocks: defaultBlocks };
|
|
82
|
+
}
|
|
83
|
+
const results = currentChildren
|
|
84
|
+
? currentChildren({ defaultBlocks, ...defaultOptions })
|
|
85
|
+
: { blocks: {}, ...defaultOptions };
|
|
86
|
+
const customBlocks = results.blocks || {};
|
|
87
|
+
return {
|
|
88
|
+
...results,
|
|
89
|
+
blocks: {
|
|
90
|
+
...defaultBlocks,
|
|
91
|
+
...customBlocks,
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
76
95
|
/**
|
|
77
96
|
* Utility function to join class names together, ignoring undefined or nil values.
|
|
78
97
|
* @param classes - The class names to join.
|
|
@@ -83,8 +102,8 @@ function classNames(...classes) {
|
|
|
83
102
|
}
|
|
84
103
|
|
|
85
104
|
const HowToUse = ({ className, title, subtitle, list, linkHref = '/sign-up', linkText = '無料登録して求人を探す', children, }) => {
|
|
86
|
-
const { blocks: { HowToUseHeader,
|
|
87
|
-
return (jsxRuntime.jsx("div", { className: classNames('nbb-how-to-use', className), children: jsxRuntime.jsxs("div", { className: "nbb-how-to-use-section", children: [jsxRuntime.jsx(HowToUseHeader, { title: title, subtitle: subtitle }), jsxRuntime.jsx(
|
|
105
|
+
const { blocks: { HowToUseHeader, HowToUseCardList, HowToUseCard, HowToUseArrowIcon, HowToUseBottomLink, }, settings: { showArrows } } = setBlocks(defaultBlocks, defaultSettings, children);
|
|
106
|
+
return (jsxRuntime.jsx("div", { className: classNames('nbb-how-to-use', className), children: jsxRuntime.jsxs("div", { className: "nbb-how-to-use-section", children: [jsxRuntime.jsx(HowToUseHeader, { title: title, subtitle: subtitle }), jsxRuntime.jsx(HowToUseCardList, { list: list, CardComponent: HowToUseCard, IconComponent: HowToUseArrowIcon, showArrows: showArrows }), jsxRuntime.jsx(HowToUseBottomLink, { href: linkHref, children: linkText })] }) }));
|
|
88
107
|
};
|
|
89
108
|
|
|
90
109
|
exports.HowToUse = HowToUse;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/className.tsx","../src/HowToUse.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 HowToUse from \"./HowToUse\";\n\nexport type DefaultBlocks = {\n HowToUseHeader: React.FC<{ title: string; subtitle: string }>;\n HowToUseCard: React.FC<CardProps>;\n HowToUseBottomLink: React.FC<{ href: string; children: React.ReactNode }>;\n HowToUseArrowIcon: React.FC;\n HowToUseCardList: React.FC<{ list: CardProps[] }>;\n}\n\nexport type DefaultSettings = {\n showArrows: boolean;\n}\n\nexport type CardProps = {\n title: string;\n description: string;\n icon: string;\n};\n\nconst Card = ({ title, description, icon }: CardProps) => {\n return (\n <article className=\"nbb-step-card\">\n <header>\n <span className=\"material-symbols-outlined\">{icon}</span>\n <h6>{title}</h6>\n </header>\n <div className=\"nbb-step-text\">\n <p>{description}</p>\n </div>\n </article>\n );\n};\n\n\nconst HowToUseHeader = ({ title, subtitle }: { title: string; subtitle: string }) => {\n return (\n <div className=\"nbb-section-header\">\n <h6>{title}</h6>\n <h4>{subtitle}</h4>\n </div>\n );\n}\n\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n },\n settings?: DefaultSettings,\n) {\n const { blocks: customBlocks = {}, settings: customSettings = {} } =\n children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };\n\n return {\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n settings: {\n ...settings,\n ...customSettings,\n }\n };\n}\n\nexport function BottomLink({ href, children }: { href: string; children: React.ReactNode }) {\n return (\n <div className=\"nbb-sign-up\">\n <a\n href={href}\n rel=\"noreferrer noopener\"\n className=\"nbb-sign-up-button\"\n >\n {children}\n </a>\n </div>\n );\n}\nexport function ArrowIcon() {\n return <span className=\"material-symbols-outlined nbb-arrow\">expand_more</span>;\n}\n\nexport function CardList({\n list = [],\n Component = Card,\n IconComponent = ArrowIcon,\n showArrows = true\n}: {\n list: CardProps[],\n Component?: React.FC<CardProps>,\n IconComponent?: React.FC\n showArrows?: boolean\n }) {\n return <div className=\"nbb-how-to-use-steps\">{list.map(c => {\n return <div key={c.title} >\n <Component key={c.title} {...c} />\n {showArrows && <IconComponent />}\n </div>;\n })}</div>;\n}\n\nexport const defaultSettings = {\n showArrows: true\n}\n\nexport const defaultBlocks = {\n HowToUseHeader: HowToUseHeader,\n HowToUseCard: Card,\n HowToUseBottomLink: BottomLink,\n HowToUseArrowIcon: ArrowIcon,\n HowToUseCardList: CardList,\n}\n","type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import React from 'react';\nimport './how-to-use.css';\nimport { defaultBlocks, defaultSettings, setBlocks, CardProps, DefaultBlocks, DefaultSettings } from './blocks';\nimport { classNames } from './className';\n\ntype HowToUseProps = {\n className: string;\n title: string;\n subtitle: string;\n linkHref?: string;\n linkText?: string;\n list: CardProps[];\nchildren?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n};\n};\n\n\nexport const HowToUse: React.FC<HowToUseProps> = ({\n className,\n title,\n subtitle,\n list,\n linkHref = '/sign-up',\n linkText = '無料登録して求人を探す',\n children,\n}) => {\n \n const {\n blocks: {\n HowToUseHeader,\n HowToUseCard,\n HowToUseBottomLink,\n HowToUseArrowIcon,\n HowToUseCardList\n },\n settings: {\n showArrows\n }\n } = setBlocks(defaultBlocks, children, defaultSettings);\n\n return (\n <div className={classNames('nbb-how-to-use', className)}>\n <div className=\"nbb-how-to-use-section\">\n <HowToUseHeader title={title} subtitle={subtitle} />\n <div className=\"nbb-how-to-use-steps\">\n <HowToUseCardList\n list={list}\n Component={HowToUseCard}\n IconComponent={HowToUseArrowIcon}\n showArrows={showArrows}\n />\n </div>\n <HowToUseBottomLink href={linkHref}>\n {linkText}\n </HowToUseBottomLink>\n </div>\n </div>\n );\n};\n\nexport default HowToUse;\n"],"names":["_jsxs","_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;;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,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,EACD,QAAQ,EAAE,EACR,UAAU,EACX,EACF,GAAG,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,eAAe,CAAC;AAEvD,IAAA,QACEA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EACrD,QAAA,EAAAD,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EACrC,QAAA,EAAA,CAAAC,cAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,EACpDA,cAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,sBAAsB,EAAA,QAAA,EACnCA,cAAC,CAAA,gBAAgB,EACf,EAAA,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,iBAAiB,EAChC,UAAU,EAAE,UAAU,EAAA,CACtB,EACE,CAAA,EACNA,cAAC,CAAA,kBAAkB,IAAC,IAAI,EAAE,QAAQ,EAAA,QAAA,EAC/B,QAAQ,EAAA,CACU,CACjB,EAAA,CAAA,EAAA,CACF;AAEV;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/lib.ts","../src/HowToUse.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","export type DefaultBlocks = {\n HowToUseHeader: React.FC<{ title: string; subtitle: string }>;\n HowToUseCard: React.FC<CardProps>;\n HowToUseBottomLink: React.FC<{ href: string; children: React.ReactNode }>;\n HowToUseArrowIcon: React.FC;\n HowToUseCardList: React.FC<{ \n list: CardProps[], \n CardComponent: React.FC<CardProps>,\n IconComponent: React.FC,\n showArrows: boolean\n }>;\n}\n\nexport type DefaultSettings = {\n showArrows: boolean;\n}\n\nexport type CardProps = {\n title: string;\n description: string;\n icon: string;\n};\n\nconst Card = ({ title, description, icon }: CardProps) => {\n return (\n <article className=\"nbb-step-card\">\n <header>\n <span className=\"material-symbols-outlined\">{icon}</span>\n <h6>{title}</h6>\n </header>\n <div className=\"nbb-step-text\">\n <p>{description}</p>\n </div>\n </article>\n );\n};\n\n\nconst HowToUseHeader = ({ title, subtitle }: { title: string; subtitle: string }) => {\n return (\n <div className=\"nbb-section-header\">\n <h6>{title}</h6>\n <h4>{subtitle}</h4>\n </div>\n );\n}\n\nexport function BottomLink({ href, children }: { href: string; children: React.ReactNode }) {\n return (\n <div className=\"nbb-sign-up\">\n <a\n href={href}\n rel=\"noreferrer noopener\"\n className=\"nbb-sign-up-button\"\n >\n {children}\n </a>\n </div>\n );\n}\nexport function ArrowIcon() {\n return <span className=\"material-symbols-outlined nbb-arrow\">expand_more</span>;\n}\n\nexport function CardList({\n list = [],\n CardComponent = Card,\n IconComponent = ArrowIcon,\n showArrows = true\n}: {\n list: CardProps[],\n CardComponent?: React.FC<CardProps>,\n IconComponent?: React.FC,\n showArrows?: boolean\n }) {\n return <div className=\"nbb-how-to-use-steps\">{list.map(c => {\n return <div key={c.title} >\n <CardComponent key={c.title} {...c} />\n {showArrows && <IconComponent />}\n </div>;\n })}</div>;\n}\n\nexport const defaultSettings = {\n showArrows: true\n}\n\nexport const defaultBlocks = {\n HowToUseHeader: HowToUseHeader,\n HowToUseCard: Card,\n HowToUseBottomLink: BottomLink,\n HowToUseArrowIcon: ArrowIcon,\n HowToUseCardList: CardList,\n}\n","/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param defaultOptions - The default options to be passed to the children function.\n * @param children - An optional function that returns custom blocks and additional options.\n * @returns An object containing the merged blocks and all options from both defaults and children.\n */\n\ntype BlockComponent = React.ComponentType<any>; // Or use a more specific component type\n\ntype BlocksObject<T = BlockComponent> = {\n [key: string]: T;\n}\n\nexport type DefaultBlocksFunction<Blocks extends BlocksObject = BlocksObject, Options = {}> = ({defaultBlocks}: {defaultBlocks: Blocks } & Options) => {\n blocks: Blocks;\n} & Options\n\nexport function setBlocks<Blocks extends BlocksObject, Options>(\n defaultBlocks: Blocks,\n defaultOptions: Options,\n children?: DefaultBlocksFunction<Blocks, Options>\n): {\n blocks: Blocks;\n [key: string]: any;\n} {\n let currentChildren = children;\n if (Array.isArray(children)) {\n const functionChild = children.find((child) => typeof child === 'function');\n if (!functionChild) {\n return { blocks: defaultBlocks };\n }\n currentChildren = functionChild;\n }\n\n if (typeof currentChildren !== 'function') {\n return { blocks: defaultBlocks };\n }\n\n const results = currentChildren\n ? currentChildren({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n \n const customBlocks = results.blocks || {};\n return {\n ...results,\n blocks: {\n ...defaultBlocks,\n ...customBlocks,\n }\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}","import React from 'react';\nimport './how-to-use.css';\nimport { defaultBlocks, defaultSettings, CardProps, DefaultBlocks, DefaultSettings } from './blocks';\nimport { classNames, DefaultBlocksFunction, setBlocks } from './lib';\n\ntype HowToUseProps = {\n className: string;\n title: string;\n subtitle: string;\n linkHref?: string;\n linkText?: string;\n list: CardProps[];\n children?: DefaultBlocksFunction<DefaultBlocks, DefaultSettings>;\n};\n\n\nexport const HowToUse: React.FC<HowToUseProps> = ({\n className,\n title,\n subtitle,\n list,\n linkHref = '/sign-up',\n linkText = '無料登録して求人を探す',\n children,\n}) => {\n \n const {\n blocks: {\n HowToUseHeader,\n HowToUseCardList,\n HowToUseCard,\n HowToUseArrowIcon,\n HowToUseBottomLink,\n },\n settings: {\n showArrows\n }\n } = setBlocks<DefaultBlocks, DefaultSettings>(defaultBlocks, defaultSettings, children);\n\n return (\n <div className={classNames('nbb-how-to-use', className)}>\n <div className=\"nbb-how-to-use-section\">\n <HowToUseHeader title={title} subtitle={subtitle} />\n <HowToUseCardList\n list={list}\n CardComponent={HowToUseCard}\n IconComponent={HowToUseArrowIcon}\n showArrows={showArrows}\n />\n <HowToUseBottomLink href={linkHref}>\n {linkText}\n </HowToUseBottomLink>\n </div>\n </div>\n );\n};\n\nexport default HowToUse;\n"],"names":["_jsxs","_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;;AAExD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,KAAK,MAAM;AACX,MAAM,IAA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gB,EAAE,SAAS,CAAC,EACrD,QAAA,EAAAD,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CACrCC,cAAC,CAAA,cAAc,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,EACpDA,cAAC,CAAA,gBAAgB,EACb,EAAA,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,YAAY,EAC3B,aAAa,EAAE,iBAAiB,EAChC,UAAU,EAAE,UAAU,EACxB,CAAA,EACFA,cAAC,CAAA,kBAAkB,EAAC,EAAA,IAAI,EAAE,QAAQ,EAC/B,QAAA,EAAA,QAAQ,EACU,CAAA,CAAA,EAAA,CACjB,EACF,CAAA;AAEV;;;;","x_google_ignoreList":[0]}
|
package/dist/index.esm.js
CHANGED
|
@@ -36,28 +36,15 @@ const Card = ({ title, description, icon }) => {
|
|
|
36
36
|
const HowToUseHeader = ({ title, subtitle }) => {
|
|
37
37
|
return (jsxs("div", { className: "nbb-section-header", children: [jsx("h6", { children: title }), jsx("h4", { children: subtitle })] }));
|
|
38
38
|
};
|
|
39
|
-
function setBlocks(defaultBlocks, children, settings) {
|
|
40
|
-
const { blocks: customBlocks = {}, settings: customSettings = {} } = children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };
|
|
41
|
-
return {
|
|
42
|
-
blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
|
|
43
|
-
key,
|
|
44
|
-
customBlocks[key] || defaultComponent,
|
|
45
|
-
])),
|
|
46
|
-
settings: {
|
|
47
|
-
...settings,
|
|
48
|
-
...customSettings,
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
39
|
function BottomLink({ href, children }) {
|
|
53
40
|
return (jsx("div", { className: "nbb-sign-up", children: jsx("a", { href: href, rel: "noreferrer noopener", className: "nbb-sign-up-button", children: children }) }));
|
|
54
41
|
}
|
|
55
42
|
function ArrowIcon() {
|
|
56
43
|
return jsx("span", { className: "material-symbols-outlined nbb-arrow", children: "expand_more" });
|
|
57
44
|
}
|
|
58
|
-
function CardList({ list = [],
|
|
45
|
+
function CardList({ list = [], CardComponent = Card, IconComponent = ArrowIcon, showArrows = true }) {
|
|
59
46
|
return jsx("div", { className: "nbb-how-to-use-steps", children: list.map(c => {
|
|
60
|
-
return jsxs("div", { children: [jsx(
|
|
47
|
+
return jsxs("div", { children: [jsx(CardComponent, { ...c }, c.title), showArrows && jsx(IconComponent, {})] }, c.title);
|
|
61
48
|
}) });
|
|
62
49
|
}
|
|
63
50
|
const defaultSettings = {
|
|
@@ -71,6 +58,38 @@ const defaultBlocks = {
|
|
|
71
58
|
HowToUseCardList: CardList,
|
|
72
59
|
};
|
|
73
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Sets the blocks by merging default blocks with custom blocks provided by the children function.
|
|
63
|
+
*
|
|
64
|
+
* @param defaultBlocks - The default blocks to be used.
|
|
65
|
+
* @param defaultOptions - The default options to be passed to the children function.
|
|
66
|
+
* @param children - An optional function that returns custom blocks and additional options.
|
|
67
|
+
* @returns An object containing the merged blocks and all options from both defaults and children.
|
|
68
|
+
*/
|
|
69
|
+
function setBlocks(defaultBlocks, defaultOptions, children) {
|
|
70
|
+
let currentChildren = children;
|
|
71
|
+
if (Array.isArray(children)) {
|
|
72
|
+
const functionChild = children.find((child) => typeof child === 'function');
|
|
73
|
+
if (!functionChild) {
|
|
74
|
+
return { blocks: defaultBlocks };
|
|
75
|
+
}
|
|
76
|
+
currentChildren = functionChild;
|
|
77
|
+
}
|
|
78
|
+
if (typeof currentChildren !== 'function') {
|
|
79
|
+
return { blocks: defaultBlocks };
|
|
80
|
+
}
|
|
81
|
+
const results = currentChildren
|
|
82
|
+
? currentChildren({ defaultBlocks, ...defaultOptions })
|
|
83
|
+
: { blocks: {}, ...defaultOptions };
|
|
84
|
+
const customBlocks = results.blocks || {};
|
|
85
|
+
return {
|
|
86
|
+
...results,
|
|
87
|
+
blocks: {
|
|
88
|
+
...defaultBlocks,
|
|
89
|
+
...customBlocks,
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
74
93
|
/**
|
|
75
94
|
* Utility function to join class names together, ignoring undefined or nil values.
|
|
76
95
|
* @param classes - The class names to join.
|
|
@@ -81,8 +100,8 @@ function classNames(...classes) {
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
const HowToUse = ({ className, title, subtitle, list, linkHref = '/sign-up', linkText = '無料登録して求人を探す', children, }) => {
|
|
84
|
-
const { blocks: { HowToUseHeader,
|
|
85
|
-
return (jsx("div", { className: classNames('nbb-how-to-use', className), children: jsxs("div", { className: "nbb-how-to-use-section", children: [jsx(HowToUseHeader, { title: title, subtitle: subtitle }), jsx(
|
|
103
|
+
const { blocks: { HowToUseHeader, HowToUseCardList, HowToUseCard, HowToUseArrowIcon, HowToUseBottomLink, }, settings: { showArrows } } = setBlocks(defaultBlocks, defaultSettings, children);
|
|
104
|
+
return (jsx("div", { className: classNames('nbb-how-to-use', className), children: jsxs("div", { className: "nbb-how-to-use-section", children: [jsx(HowToUseHeader, { title: title, subtitle: subtitle }), jsx(HowToUseCardList, { list: list, CardComponent: HowToUseCard, IconComponent: HowToUseArrowIcon, showArrows: showArrows }), jsx(HowToUseBottomLink, { href: linkHref, children: linkText })] }) }));
|
|
86
105
|
};
|
|
87
106
|
|
|
88
107
|
export { HowToUse };
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/className.tsx","../src/HowToUse.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 HowToUse from \"./HowToUse\";\n\nexport type DefaultBlocks = {\n HowToUseHeader: React.FC<{ title: string; subtitle: string }>;\n HowToUseCard: React.FC<CardProps>;\n HowToUseBottomLink: React.FC<{ href: string; children: React.ReactNode }>;\n HowToUseArrowIcon: React.FC;\n HowToUseCardList: React.FC<{ list: CardProps[] }>;\n}\n\nexport type DefaultSettings = {\n showArrows: boolean;\n}\n\nexport type CardProps = {\n title: string;\n description: string;\n icon: string;\n};\n\nconst Card = ({ title, description, icon }: CardProps) => {\n return (\n <article className=\"nbb-step-card\">\n <header>\n <span className=\"material-symbols-outlined\">{icon}</span>\n <h6>{title}</h6>\n </header>\n <div className=\"nbb-step-text\">\n <p>{description}</p>\n </div>\n </article>\n );\n};\n\n\nconst HowToUseHeader = ({ title, subtitle }: { title: string; subtitle: string }) => {\n return (\n <div className=\"nbb-section-header\">\n <h6>{title}</h6>\n <h4>{subtitle}</h4>\n </div>\n );\n}\n\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n children?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n },\n settings?: DefaultSettings,\n) {\n const { blocks: customBlocks = {}, settings: customSettings = {} } =\n children ? children(defaultBlocks, settings) : { blocks: {}, settings: {} };\n\n return {\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n settings: {\n ...settings,\n ...customSettings,\n }\n };\n}\n\nexport function BottomLink({ href, children }: { href: string; children: React.ReactNode }) {\n return (\n <div className=\"nbb-sign-up\">\n <a\n href={href}\n rel=\"noreferrer noopener\"\n className=\"nbb-sign-up-button\"\n >\n {children}\n </a>\n </div>\n );\n}\nexport function ArrowIcon() {\n return <span className=\"material-symbols-outlined nbb-arrow\">expand_more</span>;\n}\n\nexport function CardList({\n list = [],\n Component = Card,\n IconComponent = ArrowIcon,\n showArrows = true\n}: {\n list: CardProps[],\n Component?: React.FC<CardProps>,\n IconComponent?: React.FC\n showArrows?: boolean\n }) {\n return <div className=\"nbb-how-to-use-steps\">{list.map(c => {\n return <div key={c.title} >\n <Component key={c.title} {...c} />\n {showArrows && <IconComponent />}\n </div>;\n })}</div>;\n}\n\nexport const defaultSettings = {\n showArrows: true\n}\n\nexport const defaultBlocks = {\n HowToUseHeader: HowToUseHeader,\n HowToUseCard: Card,\n HowToUseBottomLink: BottomLink,\n HowToUseArrowIcon: ArrowIcon,\n HowToUseCardList: CardList,\n}\n","type ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import React from 'react';\nimport './how-to-use.css';\nimport { defaultBlocks, defaultSettings, setBlocks, CardProps, DefaultBlocks, DefaultSettings } from './blocks';\nimport { classNames } from './className';\n\ntype HowToUseProps = {\n className: string;\n title: string;\n subtitle: string;\n linkHref?: string;\n linkText?: string;\n list: CardProps[];\nchildren?: (defaultBlocks: DefaultBlocks, settings?: DefaultSettings) => {\n blocks: { [x: string]: any };\n settings?: DefaultSettings;\n};\n};\n\n\nexport const HowToUse: React.FC<HowToUseProps> = ({\n className,\n title,\n subtitle,\n list,\n linkHref = '/sign-up',\n linkText = '無料登録して求人を探す',\n children,\n}) => {\n \n const {\n blocks: {\n HowToUseHeader,\n HowToUseCard,\n HowToUseBottomLink,\n HowToUseArrowIcon,\n HowToUseCardList\n },\n settings: {\n showArrows\n }\n } = setBlocks(defaultBlocks, children, defaultSettings);\n\n return (\n <div className={classNames('nbb-how-to-use', className)}>\n <div className=\"nbb-how-to-use-section\">\n <HowToUseHeader title={title} subtitle={subtitle} />\n <div className=\"nbb-how-to-use-steps\">\n <HowToUseCardList\n list={list}\n Component={HowToUseCard}\n IconComponent={HowToUseArrowIcon}\n showArrows={showArrows}\n />\n </div>\n <HowToUseBottomLink href={linkHref}>\n {linkText}\n </HowToUseBottomLink>\n </div>\n </div>\n );\n};\n\nexport default HowToUse;\n"],"names":["_jsxs","_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;;AAExD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7B;AACA,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B;;AAEA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG;AAClC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACnD;AACA;;;;;ACLA,MAAM,IAAI,G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A,CACF;AAEV;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/lib.ts","../src/HowToUse.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","export type DefaultBlocks = {\n HowToUseHeader: React.FC<{ title: string; subtitle: string }>;\n HowToUseCard: React.FC<CardProps>;\n HowToUseBottomLink: React.FC<{ href: string; children: React.ReactNode }>;\n HowToUseArrowIcon: React.FC;\n HowToUseCardList: React.FC<{ \n list: CardProps[], \n CardComponent: React.FC<CardProps>,\n IconComponent: React.FC,\n showArrows: boolean\n }>;\n}\n\nexport type DefaultSettings = {\n showArrows: boolean;\n}\n\nexport type CardProps = {\n title: string;\n description: string;\n icon: string;\n};\n\nconst Card = ({ title, description, icon }: CardProps) => {\n return (\n <article className=\"nbb-step-card\">\n <header>\n <span className=\"material-symbols-outlined\">{icon}</span>\n <h6>{title}</h6>\n </header>\n <div className=\"nbb-step-text\">\n <p>{description}</p>\n </div>\n </article>\n );\n};\n\n\nconst HowToUseHeader = ({ title, subtitle }: { title: string; subtitle: string }) => {\n return (\n <div className=\"nbb-section-header\">\n <h6>{title}</h6>\n <h4>{subtitle}</h4>\n </div>\n );\n}\n\nexport function BottomLink({ href, children }: { href: string; children: React.ReactNode }) {\n return (\n <div className=\"nbb-sign-up\">\n <a\n href={href}\n rel=\"noreferrer noopener\"\n className=\"nbb-sign-up-button\"\n >\n {children}\n </a>\n </div>\n );\n}\nexport function ArrowIcon() {\n return <span className=\"material-symbols-outlined nbb-arrow\">expand_more</span>;\n}\n\nexport function CardList({\n list = [],\n CardComponent = Card,\n IconComponent = ArrowIcon,\n showArrows = true\n}: {\n list: CardProps[],\n CardComponent?: React.FC<CardProps>,\n IconComponent?: React.FC,\n showArrows?: boolean\n }) {\n return <div className=\"nbb-how-to-use-steps\">{list.map(c => {\n return <div key={c.title} >\n <CardComponent key={c.title} {...c} />\n {showArrows && <IconComponent />}\n </div>;\n })}</div>;\n}\n\nexport const defaultSettings = {\n showArrows: true\n}\n\nexport const defaultBlocks = {\n HowToUseHeader: HowToUseHeader,\n HowToUseCard: Card,\n HowToUseBottomLink: BottomLink,\n HowToUseArrowIcon: ArrowIcon,\n HowToUseCardList: CardList,\n}\n","/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param defaultOptions - The default options to be passed to the children function.\n * @param children - An optional function that returns custom blocks and additional options.\n * @returns An object containing the merged blocks and all options from both defaults and children.\n */\n\ntype BlockComponent = React.ComponentType<any>; // Or use a more specific component type\n\ntype BlocksObject<T = BlockComponent> = {\n [key: string]: T;\n}\n\nexport type DefaultBlocksFunction<Blocks extends BlocksObject = BlocksObject, Options = {}> = ({defaultBlocks}: {defaultBlocks: Blocks } & Options) => {\n blocks: Blocks;\n} & Options\n\nexport function setBlocks<Blocks extends BlocksObject, Options>(\n defaultBlocks: Blocks,\n defaultOptions: Options,\n children?: DefaultBlocksFunction<Blocks, Options>\n): {\n blocks: Blocks;\n [key: string]: any;\n} {\n let currentChildren = children;\n if (Array.isArray(children)) {\n const functionChild = children.find((child) => typeof child === 'function');\n if (!functionChild) {\n return { blocks: defaultBlocks };\n }\n currentChildren = functionChild;\n }\n\n if (typeof currentChildren !== 'function') {\n return { blocks: defaultBlocks };\n }\n\n const results = currentChildren\n ? currentChildren({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n \n const customBlocks = results.blocks || {};\n return {\n ...results,\n blocks: {\n ...defaultBlocks,\n ...customBlocks,\n }\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}","import React from 'react';\nimport './how-to-use.css';\nimport { defaultBlocks, defaultSettings, CardProps, DefaultBlocks, DefaultSettings } from './blocks';\nimport { classNames, DefaultBlocksFunction, setBlocks } from './lib';\n\ntype HowToUseProps = {\n className: string;\n title: string;\n subtitle: string;\n linkHref?: string;\n linkText?: string;\n list: CardProps[];\n children?: DefaultBlocksFunction<DefaultBlocks, DefaultSettings>;\n};\n\n\nexport const HowToUse: React.FC<HowToUseProps> = ({\n className,\n title,\n subtitle,\n list,\n linkHref = '/sign-up',\n linkText = '無料登録して求人を探す',\n children,\n}) => {\n \n const {\n blocks: {\n HowToUseHeader,\n HowToUseCardList,\n HowToUseCard,\n HowToUseArrowIcon,\n HowToUseBottomLink,\n },\n settings: {\n showArrows\n }\n } = setBlocks<DefaultBlocks, DefaultSettings>(defaultBlocks, defaultSettings, children);\n\n return (\n <div className={classNames('nbb-how-to-use', className)}>\n <div className=\"nbb-how-to-use-section\">\n <HowToUseHeader title={title} subtitle={subtitle} />\n <HowToUseCardList\n list={list}\n CardComponent={HowToUseCard}\n IconComponent={HowToUseArrowIcon}\n showArrows={showArrows}\n />\n <HowToUseBottomLink href={linkHref}>\n {linkText}\n </HowToUseBottomLink>\n </div>\n </div>\n );\n};\n\nexport default HowToUse;\n"],"names":["_jsxs","_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,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,IAAI,CAAC,GAAG,CAAC;AACjD;;AC/Ca,MAAA,QAAQ,GAA4B,CAAC,EAChD,SAAS,EACT,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GAAG,UAAU,EACrB,QAAQ,GAAG,aAAa,EACxB,QAAQ,GACT,KAAI;AAEH,IAAA,MAAM,EACJ,MAAM,EAAE,EACN,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,EACD,QAAQ,EAAE,EACR,UAAU,EACX,EACF,GAAG,SAAS,CAAiC,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC;AAEvF,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EACrD,QAAA,EAAAD,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CACrCC,GAAC,CAAA,cAAc,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,EACpDA,GAAC,CAAA,gBAAgB,EACb,EAAA,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,YAAY,EAC3B,aAAa,EAAE,iBAAiB,EAChC,UAAU,EAAE,UAAU,EACxB,CAAA,EACFA,GAAC,CAAA,kBAAkB,EAAC,EAAA,IAAI,EAAE,QAAQ,EAC/B,QAAA,EAAA,QAAQ,EACU,CAAA,CAAA,EAAA,CACjB,EACF,CAAA;AAEV;;;;","x_google_ignoreList":[0]}
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the blocks by merging default blocks with custom blocks provided by the children function.
|
|
3
|
+
*
|
|
4
|
+
* @param defaultBlocks - The default blocks to be used.
|
|
5
|
+
* @param defaultOptions - The default options to be passed to the children function.
|
|
6
|
+
* @param children - An optional function that returns custom blocks and additional options.
|
|
7
|
+
* @returns An object containing the merged blocks and all options from both defaults and children.
|
|
8
|
+
*/
|
|
9
|
+
type BlockComponent = React.ComponentType<any>;
|
|
10
|
+
type BlocksObject<T = BlockComponent> = {
|
|
11
|
+
[key: string]: T;
|
|
12
|
+
};
|
|
13
|
+
export type DefaultBlocksFunction<Blocks extends BlocksObject = BlocksObject, Options = {}> = ({ defaultBlocks }: {
|
|
14
|
+
defaultBlocks: Blocks;
|
|
15
|
+
} & Options) => {
|
|
16
|
+
blocks: Blocks;
|
|
17
|
+
} & Options;
|
|
18
|
+
export declare function setBlocks<Blocks extends BlocksObject, Options>(defaultBlocks: Blocks, defaultOptions: Options, children?: DefaultBlocksFunction<Blocks, Options>): {
|
|
19
|
+
blocks: Blocks;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
type ClassName = string | ClassName[] | undefined | null;
|
|
23
|
+
/**
|
|
24
|
+
* Utility function to join class names together, ignoring undefined or nil values.
|
|
25
|
+
* @param classes - The class names to join.
|
|
26
|
+
* @returns The joined class names.
|
|
27
|
+
*/
|
|
28
|
+
export declare function classNames(...classes: ClassName[]): string;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,KAAK,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAE/C,KAAK,YAAY,CAAC,CAAC,GAAG,cAAc,IAAI;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,MAAM,SAAS,YAAY,GAAG,YAAY,EAAE,OAAO,GAAG,EAAE,IAAI,CAAC,EAAC,aAAa,EAAC,EAAE;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,KAAK;IACrJ,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAA;AAEX,wBAAgB,SAAS,CAAC,MAAM,SAAS,YAAY,EAAE,OAAO,EAC5D,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,OAAO,EACvB,QAAQ,CAAC,EAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,GAChD;IACD,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CA0BA;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAE1D"}
|
package/package.json
CHANGED
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"}
|