@nodeblocks/frontend-faq-block 0.0.2

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/README.md ADDED
@@ -0,0 +1,57 @@
1
+ ## ๐Ÿš€ Nodeblocks Frontend Starter Kit
2
+
3
+ Welcome to the Nodeblocks Frontend Starter Kit! ๐ŸŽ‰ This kit is designed to make building frontend libraries in React super easy, helping you streamline your development workflow with minimal fuss. Let's dive in! ๐Ÿคฟ
4
+
5
+ ### โœจ Features
6
+ - **๐Ÿš€ Bundling with Rollup:** Get a clean, minimalistic approach to bundling your JavaScript files for smoother frontend development.
7
+ - **๐Ÿ’™ TypeScript Support:** We've included a pre-configured `tsconfig.json` to ensure your TypeScript setup is strict, efficient, and ready to go.
8
+ - **โš™๏ธ Peer Dependencies:** Keep bundle sizes lean with React and React DOM set as peer dependencies.
9
+ - **๐ŸŽจ CSS Support:** Easily import and process CSS files, giving you more control over your styles.
10
+
11
+ ### ๐Ÿ› ๏ธ How to Use
12
+ 1. **Clone this repository** ๐ŸŒ€:
13
+ ```bash
14
+ git clone <repository-url>
15
+ cd <repository-directory>
16
+ ```
17
+
18
+ 2. **Install dependencies** ๐Ÿ“ฆ:
19
+ ```bash
20
+ npm install
21
+ ```
22
+
23
+ 3. **Start development** ๐Ÿ› ๏ธ:
24
+ ```bash
25
+ npm run watch
26
+ ```
27
+
28
+ 4. **Build for production** ๐Ÿ—๏ธ:
29
+ ```bash
30
+ npm run build
31
+ ```
32
+
33
+ ### ๐Ÿงช How to Test
34
+
35
+ The `test` folder contains examples that demonstrate how to use the libraries you create with this starter kit. These examples show compatibility with various bundlers, such as:
36
+
37
+ - **Create React App** (Webpack)
38
+ - **Vite** โšก
39
+ - **Rollup** (itself) (Coming soon) ๐Ÿ”„
40
+ - **Parcel** (Coming soon) ๐Ÿ“ฆ
41
+
42
+ This ensures Nodeblocks libraries integrate seamlessly with different workflows. ๐Ÿ› ๏ธโœจ
43
+
44
+ **Before running each project make sure you run `npm link`:**
45
+
46
+ 1. In the root of this project:
47
+ ```bash
48
+ npm link
49
+ ```
50
+ 2. In the test project you want to run:
51
+ ```bash
52
+ npm i
53
+ npm link @basaldev/frontend-starter-kit
54
+ ```
55
+ (Note that in real life your library would not be called frontend-starter-kit.)
56
+
57
+ 3. Then you can follow your usual workflow either with **Create React App** (`npm start`) or with Vite (`npm run dev`). This will give you a development environment where whenever you change your library it will be available in your test project.
@@ -0,0 +1,17 @@
1
+ import { DefaultBlocks, FAQListItem } from './types';
2
+ export declare function FAQTitle({ title, subtitle }: {
3
+ title: string;
4
+ subtitle: string;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ export declare function FAQItem({ item, index, activeIndex, toggleAccordion, ChevronIcon }: {
7
+ item: FAQListItem;
8
+ index: number;
9
+ activeIndex: number | null;
10
+ toggleAccordion: (index: number) => void;
11
+ ChevronIcon: React.FC<{
12
+ direction: string;
13
+ }>;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export declare const defaultOptions: {};
16
+ export declare const defaultBlocks: DefaultBlocks;
17
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAiCpD,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,2CAOhF;AACD,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,KAAK,EACL,WAAW,EACX,eAAe,EACf,WAAW,EAAE,EAAE;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C,2CAsBF;AAED,eAAO,MAAM,cAAc,IAAK,CAAA;AAEhC,eAAO,MAAM,aAAa,EAAE,aAI3B,CAAC"}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
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/faq.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './faq.css';
3
+ import { FAQProps } from './types';
4
+ export declare const FAQ: React.FC<FAQProps>;
5
+ export default FAQ;
6
+ //# sourceMappingURL=faq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faq.d.ts","sourceRoot":"","sources":["../src/faq.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,WAAW,CAAC;AAGnB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CA+BlC,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+
6
+ function styleInject(css, ref) {
7
+ if ( ref === void 0 ) ref = {};
8
+ var insertAt = ref.insertAt;
9
+
10
+ if (typeof document === 'undefined') { return; }
11
+
12
+ var head = document.head || document.getElementsByTagName('head')[0];
13
+ var style = document.createElement('style');
14
+ style.type = 'text/css';
15
+
16
+ if (insertAt === 'top') {
17
+ if (head.firstChild) {
18
+ head.insertBefore(style, head.firstChild);
19
+ } else {
20
+ head.appendChild(style);
21
+ }
22
+ } else {
23
+ head.appendChild(style);
24
+ }
25
+
26
+ if (style.styleSheet) {
27
+ style.styleSheet.cssText = css;
28
+ } else {
29
+ style.appendChild(document.createTextNode(css));
30
+ }
31
+ }
32
+
33
+ var css_248z = ".nbb-faq-accordion {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n --border-radius-4: 8px;\n --color-text-mid-emphasis: #1D1E20;\n --color-surface-secondary: #d1d1d1;\n --color-surface-primary: #fff;\n\n background-color: var(--color-surface-primary);\n padding: 16px;\n max-width: 600px;\n margin: 0 auto;\n}\n\n.nbb-faq-heading {\n color: var(--color-text-mid-emphasis);\n margin-bottom: 16px;\n text-align: center;\n}\n\n.nbb-faq-heading h2 {\n margin: 0;\n font-size: 25px;\n}\n\n.nbb-faq-heading h3 {\n color: var(--color-object-accent-primary);\n margin: 0 0 8px 0;\n font-size: 18px;\n}\n\n.nbb-faq-item {\n padding: 16px 0px;\n margin-bottom: 8px;\n overflow: hidden;\n border-top: 1px solid var(--color-surface-secondary);\n background-color: transparent;\n}\n\n.nbb-faq-question {\n background-color: transparent;\n color: var(--color-text-mid-emphasis);\n padding: 12px 16px;\n width: 100%;\n border: none;\n font-size: 18px;\n font-weight: bold;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n}\n\n.nbb-faq-question:focus {\n outline: none;\n}\n\n.nbb-faq-header {\n display: flex;\n justify-content: flex-start;\n gap: 16px;\n text-align: left;\n}\n\n.nbb-question-mark {\n align-self: center;\n color: var(--color-object-accent-primary);\n width: 24px;\n height: 24px;\n}\n\n.nbb-faq-answer {\n background-color: var(--color-surface-primary);\n color: var(--color-text-mid-emphasis);\n padding: 12px 16px;\n transition: all 0.3s;\n text-align: left;\n}\n";
34
+ styleInject(css_248z);
35
+
36
+ function DefaultChevronIcon({ direction }) {
37
+ return direction === 'up' ? (jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M7.41 15.59L12 11L16.59 15.59L18 14.17L12 8.17L6 14.17L7.41 15.59Z", fill: "#737D90" }) })) : (jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M7.41 8.41L12 13L16.59 8.41L18 9.83L12 15.83L6 9.83L7.41 8.41Z", fill: "#737D90" }) }));
38
+ }
39
+ function FAQTitle({ title, subtitle }) {
40
+ return (jsxRuntime.jsxs("div", { className: "nbb-faq-heading", children: [jsxRuntime.jsx("h3", { children: title }), jsxRuntime.jsx("h2", { children: subtitle })] }));
41
+ }
42
+ function FAQItem({ item, index, activeIndex, toggleAccordion, ChevronIcon }) {
43
+ return (jsxRuntime.jsxs("div", { className: "nbb-faq-item", children: [jsxRuntime.jsxs("button", { className: `nbb-faq-question ${activeIndex === index ? 'active' : ''}`, onClick: () => toggleAccordion(index), children: [jsxRuntime.jsxs("div", { className: "nbb-faq-header", children: [jsxRuntime.jsx("span", { className: "nbb-question-mark", children: "Q." }), jsxRuntime.jsx("span", { children: item.question })] }), jsxRuntime.jsx("span", { className: "nbb-faq-toggle", children: jsxRuntime.jsx(ChevronIcon, { direction: `${activeIndex === index ? 'up' : 'down'}` }) })] }), activeIndex === index && (jsxRuntime.jsx("div", { className: "nbb-faq-answer", children: jsxRuntime.jsx("p", { children: item.answer }) }))] }));
44
+ }
45
+ const defaultOptions = {};
46
+ const defaultBlocks = {
47
+ FAQTitle: FAQTitle,
48
+ FAQItem: FAQItem,
49
+ FAQChevronIcon: DefaultChevronIcon
50
+ };
51
+
52
+ /**
53
+ * Sets the blocks by merging default blocks with custom blocks provided by the children function.
54
+ *
55
+ * @param defaultBlocks - The default blocks to be used.
56
+ * @param children - An optional function that returns custom blocks and arguments.
57
+ * @param args - Additional unknown arguments.
58
+ * @returns An object containing the merged blocks and additional arguments.
59
+ */
60
+ function setBlocks(defaultBlocks, defaultOptions, children) {
61
+ const results = children
62
+ ? children({ defaultBlocks, ...defaultOptions })
63
+ : { blocks: {}, ...defaultOptions };
64
+ const { blocks: customBlocks = {} } = results;
65
+ return {
66
+ ...results,
67
+ blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
68
+ key,
69
+ customBlocks[key] || defaultComponent,
70
+ ])),
71
+ };
72
+ }
73
+
74
+ /**
75
+ * Utility function to join class names together, ignoring undefined or nil values.
76
+ * @param classes - The class names to join.
77
+ * @returns The joined class names.
78
+ */
79
+ function classNames(...classes) {
80
+ return classes.flat().filter(Boolean).join(' ');
81
+ }
82
+
83
+ const FAQ = ({ className, title, subtitle, questionsAndAnswers, children, }) => {
84
+ const [activeIndex, setActiveIndex] = react.useState(null);
85
+ const toggleAccordion = (index) => {
86
+ setActiveIndex(activeIndex === index ? null : index);
87
+ };
88
+ const { blocks } = setBlocks(defaultBlocks, defaultOptions, children);
89
+ const { FAQItem, FAQTitle, FAQChevronIcon } = blocks;
90
+ return (jsxRuntime.jsxs("div", { className: classNames('nbb-faq-accordion', className), children: [jsxRuntime.jsx(FAQTitle, { title: title, subtitle: subtitle }), questionsAndAnswers.map((item, index) => (jsxRuntime.jsx(FAQItem, { item: item, index: index, activeIndex: activeIndex, toggleAccordion: toggleAccordion, ChevronIcon: FAQChevronIcon }, index)))] }));
91
+ };
92
+
93
+ exports.FAQ = FAQ;
94
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/lib.ts","../src/className.tsx","../src/faq.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 { DefaultBlocks, FAQListItem } from './types'\n\nfunction DefaultChevronIcon({ direction }: { direction: string }) {\n return direction === 'up' ? (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.41 15.59L12 11L16.59 15.59L18 14.17L12 8.17L6 14.17L7.41 15.59Z\"\n fill=\"#737D90\"\n />\n </svg>\n ) : (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.41 8.41L12 13L16.59 8.41L18 9.83L12 15.83L6 9.83L7.41 8.41Z\"\n fill=\"#737D90\"\n />\n </svg>\n );\n}\n\n\nexport function FAQTitle({ title, subtitle }: { title: string; subtitle: string }) {\n return (\n <div className=\"nbb-faq-heading\">\n <h3>{title}</h3>\n <h2>{subtitle}</h2>\n </div>\n )\n}\nexport function FAQItem({\n item,\n index,\n activeIndex, \n toggleAccordion,\n ChevronIcon }: {\n item: FAQListItem;\n index: number;\n activeIndex: number | null;\n toggleAccordion: (index: number) => void;\n ChevronIcon: React.FC<{ direction: string }>\n }) {\n return (\n <div className=\"nbb-faq-item\">\n <button\n className={`nbb-faq-question ${activeIndex === index ? 'active' : ''}`}\n onClick={() => toggleAccordion(index)}\n >\n <div className=\"nbb-faq-header\">\n <span className=\"nbb-question-mark\">Q.</span>\n <span>{item.question}</span>\n </div>\n <span className=\"nbb-faq-toggle\">\n <ChevronIcon direction={`${activeIndex === index ? 'up' : 'down'}`} />\n </span>\n </button>\n {activeIndex === index && (\n <div className=\"nbb-faq-answer\">\n <p>{item.answer}</p>\n </div>\n )}\n </div>\n )\n}\n\nexport const defaultOptions = {}\n\nexport const defaultBlocks: DefaultBlocks = {\n FAQTitle: FAQTitle,\n FAQItem: FAQItem,\n FAQChevronIcon: DefaultChevronIcon\n};\n","import { DefaultBlocks, DefaultOptions, ChildrenProps } from './types';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}","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, { useState } from 'react';\nimport './faq.css';\nimport { defaultBlocks, defaultOptions } from './blocks';\nimport { setBlocks } from './lib';\nimport { FAQProps } from './types';\nimport { classNames } from './className';\n\nexport const FAQ: React.FC<FAQProps> = ({\n className,\n title,\n subtitle,\n questionsAndAnswers,\n children,\n}) => {\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n\n const toggleAccordion = (index: number) => {\n setActiveIndex(activeIndex === index ? null : index);\n };\n\n const { blocks } = setBlocks(defaultBlocks, defaultOptions, children);\n const { FAQItem, FAQTitle, FAQChevronIcon } = blocks;\n\n return (\n <div className={classNames('nbb-faq-accordion', className)}>\n <FAQTitle title={title} subtitle={subtitle} />\n {questionsAndAnswers.map((item, index) => (\n <FAQItem\n key={index}\n item={item}\n index={index}\n activeIndex={activeIndex}\n toggleAccordion={toggleAccordion}\n ChevronIcon={FAQChevronIcon}\n />\n ))}\n </div>\n );\n};\n\nexport default FAQ;\n"],"names":["_jsx","_jsxs","useState"],"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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AAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,EAC7C,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACnCA,cAAA,CAAC,OAAO,EAAA,EAEN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,cAAc,EALtB,EAAA,KAAK,CAMV,CACH,CAAC,CAAA,EAAA,CACE;AAEV;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,2 @@
1
+ export { default as FAQ } from "./faq";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+
4
+ function styleInject(css, ref) {
5
+ if ( ref === void 0 ) ref = {};
6
+ var insertAt = ref.insertAt;
7
+
8
+ if (typeof document === 'undefined') { return; }
9
+
10
+ var head = document.head || document.getElementsByTagName('head')[0];
11
+ var style = document.createElement('style');
12
+ style.type = 'text/css';
13
+
14
+ if (insertAt === 'top') {
15
+ if (head.firstChild) {
16
+ head.insertBefore(style, head.firstChild);
17
+ } else {
18
+ head.appendChild(style);
19
+ }
20
+ } else {
21
+ head.appendChild(style);
22
+ }
23
+
24
+ if (style.styleSheet) {
25
+ style.styleSheet.cssText = css;
26
+ } else {
27
+ style.appendChild(document.createTextNode(css));
28
+ }
29
+ }
30
+
31
+ var css_248z = ".nbb-faq-accordion {\n --color-object-accent-primary: #006EAD;\n --color-object-accent-primary-emphasis: #006EAD;\n --border-radius-4: 8px;\n --color-text-mid-emphasis: #1D1E20;\n --color-surface-secondary: #d1d1d1;\n --color-surface-primary: #fff;\n\n background-color: var(--color-surface-primary);\n padding: 16px;\n max-width: 600px;\n margin: 0 auto;\n}\n\n.nbb-faq-heading {\n color: var(--color-text-mid-emphasis);\n margin-bottom: 16px;\n text-align: center;\n}\n\n.nbb-faq-heading h2 {\n margin: 0;\n font-size: 25px;\n}\n\n.nbb-faq-heading h3 {\n color: var(--color-object-accent-primary);\n margin: 0 0 8px 0;\n font-size: 18px;\n}\n\n.nbb-faq-item {\n padding: 16px 0px;\n margin-bottom: 8px;\n overflow: hidden;\n border-top: 1px solid var(--color-surface-secondary);\n background-color: transparent;\n}\n\n.nbb-faq-question {\n background-color: transparent;\n color: var(--color-text-mid-emphasis);\n padding: 12px 16px;\n width: 100%;\n border: none;\n font-size: 18px;\n font-weight: bold;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n}\n\n.nbb-faq-question:focus {\n outline: none;\n}\n\n.nbb-faq-header {\n display: flex;\n justify-content: flex-start;\n gap: 16px;\n text-align: left;\n}\n\n.nbb-question-mark {\n align-self: center;\n color: var(--color-object-accent-primary);\n width: 24px;\n height: 24px;\n}\n\n.nbb-faq-answer {\n background-color: var(--color-surface-primary);\n color: var(--color-text-mid-emphasis);\n padding: 12px 16px;\n transition: all 0.3s;\n text-align: left;\n}\n";
32
+ styleInject(css_248z);
33
+
34
+ function DefaultChevronIcon({ direction }) {
35
+ return direction === 'up' ? (jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M7.41 15.59L12 11L16.59 15.59L18 14.17L12 8.17L6 14.17L7.41 15.59Z", fill: "#737D90" }) })) : (jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M7.41 8.41L12 13L16.59 8.41L18 9.83L12 15.83L6 9.83L7.41 8.41Z", fill: "#737D90" }) }));
36
+ }
37
+ function FAQTitle({ title, subtitle }) {
38
+ return (jsxs("div", { className: "nbb-faq-heading", children: [jsx("h3", { children: title }), jsx("h2", { children: subtitle })] }));
39
+ }
40
+ function FAQItem({ item, index, activeIndex, toggleAccordion, ChevronIcon }) {
41
+ return (jsxs("div", { className: "nbb-faq-item", children: [jsxs("button", { className: `nbb-faq-question ${activeIndex === index ? 'active' : ''}`, onClick: () => toggleAccordion(index), children: [jsxs("div", { className: "nbb-faq-header", children: [jsx("span", { className: "nbb-question-mark", children: "Q." }), jsx("span", { children: item.question })] }), jsx("span", { className: "nbb-faq-toggle", children: jsx(ChevronIcon, { direction: `${activeIndex === index ? 'up' : 'down'}` }) })] }), activeIndex === index && (jsx("div", { className: "nbb-faq-answer", children: jsx("p", { children: item.answer }) }))] }));
42
+ }
43
+ const defaultOptions = {};
44
+ const defaultBlocks = {
45
+ FAQTitle: FAQTitle,
46
+ FAQItem: FAQItem,
47
+ FAQChevronIcon: DefaultChevronIcon
48
+ };
49
+
50
+ /**
51
+ * Sets the blocks by merging default blocks with custom blocks provided by the children function.
52
+ *
53
+ * @param defaultBlocks - The default blocks to be used.
54
+ * @param children - An optional function that returns custom blocks and arguments.
55
+ * @param args - Additional unknown arguments.
56
+ * @returns An object containing the merged blocks and additional arguments.
57
+ */
58
+ function setBlocks(defaultBlocks, defaultOptions, children) {
59
+ const results = children
60
+ ? children({ defaultBlocks, ...defaultOptions })
61
+ : { blocks: {}, ...defaultOptions };
62
+ const { blocks: customBlocks = {} } = results;
63
+ return {
64
+ ...results,
65
+ blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
66
+ key,
67
+ customBlocks[key] || defaultComponent,
68
+ ])),
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Utility function to join class names together, ignoring undefined or nil values.
74
+ * @param classes - The class names to join.
75
+ * @returns The joined class names.
76
+ */
77
+ function classNames(...classes) {
78
+ return classes.flat().filter(Boolean).join(' ');
79
+ }
80
+
81
+ const FAQ = ({ className, title, subtitle, questionsAndAnswers, children, }) => {
82
+ const [activeIndex, setActiveIndex] = useState(null);
83
+ const toggleAccordion = (index) => {
84
+ setActiveIndex(activeIndex === index ? null : index);
85
+ };
86
+ const { blocks } = setBlocks(defaultBlocks, defaultOptions, children);
87
+ const { FAQItem, FAQTitle, FAQChevronIcon } = blocks;
88
+ return (jsxs("div", { className: classNames('nbb-faq-accordion', className), children: [jsx(FAQTitle, { title: title, subtitle: subtitle }), questionsAndAnswers.map((item, index) => (jsx(FAQItem, { item: item, index: index, activeIndex: activeIndex, toggleAccordion: toggleAccordion, ChevronIcon: FAQChevronIcon }, index)))] }));
89
+ };
90
+
91
+ export { FAQ };
92
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/blocks.tsx","../src/lib.ts","../src/className.tsx","../src/faq.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 { DefaultBlocks, FAQListItem } from './types'\n\nfunction DefaultChevronIcon({ direction }: { direction: string }) {\n return direction === 'up' ? (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.41 15.59L12 11L16.59 15.59L18 14.17L12 8.17L6 14.17L7.41 15.59Z\"\n fill=\"#737D90\"\n />\n </svg>\n ) : (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.41 8.41L12 13L16.59 8.41L18 9.83L12 15.83L6 9.83L7.41 8.41Z\"\n fill=\"#737D90\"\n />\n </svg>\n );\n}\n\n\nexport function FAQTitle({ title, subtitle }: { title: string; subtitle: string }) {\n return (\n <div className=\"nbb-faq-heading\">\n <h3>{title}</h3>\n <h2>{subtitle}</h2>\n </div>\n )\n}\nexport function FAQItem({\n item,\n index,\n activeIndex, \n toggleAccordion,\n ChevronIcon }: {\n item: FAQListItem;\n index: number;\n activeIndex: number | null;\n toggleAccordion: (index: number) => void;\n ChevronIcon: React.FC<{ direction: string }>\n }) {\n return (\n <div className=\"nbb-faq-item\">\n <button\n className={`nbb-faq-question ${activeIndex === index ? 'active' : ''}`}\n onClick={() => toggleAccordion(index)}\n >\n <div className=\"nbb-faq-header\">\n <span className=\"nbb-question-mark\">Q.</span>\n <span>{item.question}</span>\n </div>\n <span className=\"nbb-faq-toggle\">\n <ChevronIcon direction={`${activeIndex === index ? 'up' : 'down'}`} />\n </span>\n </button>\n {activeIndex === index && (\n <div className=\"nbb-faq-answer\">\n <p>{item.answer}</p>\n </div>\n )}\n </div>\n )\n}\n\nexport const defaultOptions = {}\n\nexport const defaultBlocks: DefaultBlocks = {\n FAQTitle: FAQTitle,\n FAQItem: FAQItem,\n FAQChevronIcon: DefaultChevronIcon\n};\n","import { DefaultBlocks, DefaultOptions, ChildrenProps } from './types';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}","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, { useState } from 'react';\nimport './faq.css';\nimport { defaultBlocks, defaultOptions } from './blocks';\nimport { setBlocks } from './lib';\nimport { FAQProps } from './types';\nimport { classNames } from './className';\n\nexport const FAQ: React.FC<FAQProps> = ({\n className,\n title,\n subtitle,\n questionsAndAnswers,\n children,\n}) => {\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n\n const toggleAccordion = (index: number) => {\n setActiveIndex(activeIndex === index ? null : index);\n };\n\n const { blocks } = setBlocks(defaultBlocks, defaultOptions, children);\n const { FAQItem, FAQTitle, FAQChevronIcon } = blocks;\n\n return (\n <div className={classNames('nbb-faq-accordion', className)}>\n <FAQTitle title={title} subtitle={subtitle} />\n {questionsAndAnswers.map((item, index) => (\n <FAQItem\n key={index}\n item={item}\n index={index}\n activeIndex={activeIndex}\n toggleAccordion={toggleAccordion}\n ChevronIcon={FAQChevronIcon}\n />\n ))}\n </div>\n );\n};\n\nexport default FAQ;\n"],"names":["_jsx","_jsxs"],"mappings":";;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAA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nE,IAAA,MAAM,eAAe,GAAG,CAAC,KAAa,KAAI;AACxC,QAAA,cAAc,CAAC,WAAW,KAAK,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AACtD,KAAC;AAED,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,aAAa,EAAE,cAAc,EAAE,QAAQ,CAAC;IACrE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM;AAEpD,IAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,SAAS,CAAC,EACxD,QAAA,EAAA,CAAAD,GAAA,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,EAC7C,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACnCA,GAAA,CAAC,OAAO,EAAA,EAEN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,cAAc,EALtB,EAAA,KAAK,CAMV,CACH,CAAC,CAAA,EAAA,CACE;AAEV;;;;","x_google_ignoreList":[0]}
package/dist/lib.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { DefaultBlocks, DefaultOptions, ChildrenProps } from './types';
2
+ /**
3
+ * Sets the blocks by merging default blocks with custom blocks provided by the children function.
4
+ *
5
+ * @param defaultBlocks - The default blocks to be used.
6
+ * @param children - An optional function that returns custom blocks and arguments.
7
+ * @param args - Additional unknown arguments.
8
+ * @returns An object containing the merged blocks and additional arguments.
9
+ */
10
+ export declare function setBlocks(defaultBlocks: DefaultBlocks, defaultOptions: DefaultOptions, children?: (props: ChildrenProps) => DefaultOptions & {
11
+ blocks: {
12
+ [x: string]: any;
13
+ };
14
+ }): {
15
+ blocks: {
16
+ [k: string]: any;
17
+ };
18
+ };
19
+ type ClassName = string | ClassName[] | undefined | null;
20
+ /**
21
+ * Utility function to join class names together, ignoring undefined or nil values.
22
+ * @param classes - The class names to join.
23
+ * @returns The joined class names.
24
+ */
25
+ export declare function classNames(...classes: ClassName[]): string;
26
+ export {};
27
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvE;;;;;;;GAOG;AAEH,wBAAgB,SAAS,CACvB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,GAAG;IACpD,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC9B;;;;EAiBF;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,38 @@
1
+ export type FAQListItem = {
2
+ question: string;
3
+ answer: string;
4
+ };
5
+ export type ChildrenProps = {
6
+ defaultBlocks: DefaultBlocks;
7
+ };
8
+ export type FAQProps = {
9
+ className?: string;
10
+ title: string;
11
+ subtitle: string;
12
+ questionsAndAnswers: FAQListItem[];
13
+ children?: (props: ChildrenProps) => DefaultOptions & {
14
+ blocks: {
15
+ [x: string]: any;
16
+ };
17
+ };
18
+ };
19
+ export type DefaultBlocks = {
20
+ FAQTitle: React.FC<{
21
+ title: string;
22
+ subtitle: string;
23
+ }>;
24
+ FAQItem: React.FC<{
25
+ item: FAQListItem;
26
+ index: number;
27
+ activeIndex: number | null;
28
+ toggleAccordion: (index: number) => void;
29
+ ChevronIcon: React.FC<{
30
+ direction: string;
31
+ }>;
32
+ }>;
33
+ FAQChevronIcon: React.FC<{
34
+ direction: string;
35
+ }>;
36
+ };
37
+ export type DefaultOptions = {};
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IACxB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEJ,MAAM,MAAM,QAAQ,GAAG;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,WAAW,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,GAAG;QAClD,MAAM,EAAE;YAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;KAC9B,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACd,IAAI,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACvJ,CAAC,CAAC;IACH,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,EAAE,CAAA"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@nodeblocks/frontend-faq-block",
3
+ "version": "0.0.2",
4
+ "main": "dist/index.cjs.js",
5
+ "module": "dist/index.esm.js",
6
+ "browser": "dist/index.iife.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist/",
10
+ "dist/index.css"
11
+ ],
12
+ "scripts": {
13
+ "build": "rollup -c",
14
+ "watch": "rollup -c --watch"
15
+ },
16
+ "peerDependencies": {
17
+ "react": "^18.3.1",
18
+ "react-dom": "^18.3.1"
19
+ },
20
+ "devDependencies": {
21
+ "@rollup/plugin-commonjs": "^28.0.1",
22
+ "@rollup/plugin-json": "^6.1.0",
23
+ "@rollup/plugin-node-resolve": "^15.3.0",
24
+ "@rollup/plugin-typescript": "^12.1.1",
25
+ "@types/react": "^18.3.12",
26
+ "@types/react-dom": "^18.3.1",
27
+ "rollup": "^4.28.0",
28
+ "rollup-plugin-peer-deps-external": "^2.2.4",
29
+ "rollup-plugin-postcss": "^4.0.2",
30
+ "rollup-plugin-serve": "^1.1.1",
31
+ "tslib": "^2.8.1",
32
+ "typescript": "^5.7.2"
33
+ }
34
+ }