@nodeblocks/frontend-chat-conversation-block 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import { ComponentProps, FunctionComponent, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.
4
+ *
5
+ * @example
6
+ * <Block>
7
+ * {({ defaultBlocks: { header, ...defaultBlocks }, defaultBlockOrder }) => ({
8
+ * blocks: {
9
+ * ...defaultBlocks,
10
+ * header: {
11
+ * ...header,
12
+ * props: {
13
+ * ...header.props,
14
+ * label: "Custom Label"
15
+ * }
16
+ * },
17
+ * subheader: <CustomComponent />
18
+ * },
19
+ * blockOrder: ["header", "subheader", "body", "footer"]
20
+ * })}
21
+ * </Block>
22
+ */
23
+ export type BlocksOverride<DefaultBlocks, CustomBlocks> = (({ defaultBlocks, defaultBlockOrder, }: {
24
+ defaultBlocks: DefaultBlocks;
25
+ defaultBlockOrder: readonly (keyof DefaultBlocks)[];
26
+ }) => {
27
+ blocks: Partial<DefaultBlocks> & CustomBlocks;
28
+ blockOrder: readonly (keyof DefaultBlocks)[] | readonly (keyof CustomBlocks)[];
29
+ }) | ReactNode;
30
+ /**
31
+ * Creates a strongly typed `defaultBlocks` object, allowing for types to propagate into block override objects.
32
+ *
33
+ * @param components - A map of default block keys to component functions.
34
+ *
35
+ * @example
36
+ * const defaultBlocks = createDefaultBlocks({
37
+ * title: Title,
38
+ * description: Description,
39
+ * form: Form,
40
+ * });
41
+ */
42
+ export declare function createDefaultBlocks<T extends Record<string, FunctionComponent<any>>>(components: T): {
43
+ [K in keyof T]: ReactElement<ComponentProps<T[K]>, T[K]>;
44
+ };
45
+ /**
46
+ * A component for rendering {@link BlocksOverride|`BlocksOverride`} results.
47
+ * Exposes the evaluated `blocks` and `blockOrder` as arguments to the `children` function.
48
+ *
49
+ * @param props
50
+ * @param props.blocksOverride - The {@link BlocksOverride|`BlocksOverride`} (i.e. `children` of outer component).
51
+ * @param props.defaultBlocks - The default blocks of outer component.
52
+ * @param props.children - A function returning the JSX to render.
53
+ *
54
+ * @example
55
+ * <BlocksOverrideComponent
56
+ * defaultBlocks={defaultFormBlocks}
57
+ * blocksOverride={children}
58
+ * >
59
+ * {({ blocks, blockOrder }) =>
60
+ * blockOrder.map((key) => (
61
+ * <Fragment key={String(key)}>{blocks[key]}</Fragment>
62
+ * ))
63
+ * }
64
+ * </BlocksOverrideComponent>
65
+ */
66
+ export declare function BlocksOverrideComponent<DefaultBlocks extends Record<string, ReactNode>, CustomBlocks extends Record<string, ReactNode>>({ blocksOverride, defaultBlocks, defaultBlockOrder, children, }: {
67
+ blocksOverride: BlocksOverride<DefaultBlocks, CustomBlocks>;
68
+ defaultBlocks: DefaultBlocks;
69
+ defaultBlockOrder: (keyof DefaultBlocks)[];
70
+ children: ({ blocks, blockOrder, }: {
71
+ blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;
72
+ blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];
73
+ }) => ReactNode;
74
+ }): ReactNode;
75
+ type MergeTypes<Object1, Object2> = {
76
+ [K in keyof Object1 | keyof Object2]: K extends keyof Object1 ? Object1[K] : K extends keyof Object2 ? Object2[K] : never;
77
+ };
78
+ export declare function deepMerge<A extends Record<string, any>, B extends Record<string, any>>(obj1: A, obj2: B): MergeTypes<B, A>;
79
+ type ClassName = string | ClassName[] | undefined | null;
80
+ /**
81
+ * Utility function to join class names together, ignoring undefined or nil values.
82
+ * @param classes - The class names to join.
83
+ * @returns The joined class names.
84
+ */
85
+ export declare function classNames(...classes: ClassName[]): string;
86
+ export {};
87
+ //# 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,cAAc,EAAiB,iBAAiB,EAAE,YA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Aa,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QACvD,UAAU,EAAE,SAAS,CAAC,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,EAAE,CAAC;KACnE,KAAK,SAAS,CAAC;CACjB,aAmBA;AAED,KAAK,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI;KACjC,CAAC,IAAI,MAAM,OAAO,GAAG,MAAM,OAAO,GAAG,CAAC,SAAS,MAAM,OAAO,GACzD,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,MAAM,OAAO,GACrB,OAAO,CAAC,CAAC,CAAC,GACV,KAAK;CACZ,CAAC;AAEF,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAmBrF,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAClC;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 ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@nodeblocks/frontend-chat-conversation-block",
3
+ "version": "0.1.0",
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": "rm -rf dist && cross-env NODE_ENV=development 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.6",
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-polyfill-node": "^0.13.0",
30
+ "rollup-plugin-postcss": "^4.0.2",
31
+ "rollup-plugin-serve": "^1.1.1",
32
+ "tslib": "^2.8.1",
33
+ "typescript": "^5.7.2"
34
+ },
35
+ "dependencies": {
36
+ "@basaldev/blocks-frontend-framework": "^4.3.6",
37
+ "@mui/base": "5.0.0-beta.30",
38
+ "date-fns": "^4.1.0",
39
+ "deepmerge": "^4.3.1"
40
+ }
41
+ }
package/readme.md ADDED
@@ -0,0 +1,64 @@
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
+
7
+ - **๐Ÿš€ Bundling with Rollup:** Get a clean, minimalistic approach to bundling your JavaScript files for smoother frontend development.
8
+ - **๐Ÿ’™ TypeScript Support:** We've included a pre-configured `tsconfig.json` to ensure your TypeScript setup is strict, efficient, and ready to go.
9
+ - **โš™๏ธ Peer Dependencies:** Keep bundle sizes lean with React and React DOM set as peer dependencies.
10
+ - **๐ŸŽจ CSS Support:** Easily import and process CSS files, giving you more control over your styles.
11
+
12
+ ### ๐Ÿ› ๏ธ How to Use
13
+
14
+ 1. **Clone this repository** ๐ŸŒ€:
15
+
16
+ ```bash
17
+ git clone <repository-url>
18
+ cd <repository-directory>
19
+ ```
20
+
21
+ 2. **Install dependencies** ๐Ÿ“ฆ:
22
+
23
+ ```bash
24
+ npm install
25
+ ```
26
+
27
+ 3. **Start development** ๐Ÿ› ๏ธ:
28
+
29
+ ```bash
30
+ npm run watch
31
+ ```
32
+
33
+ 4. **Build for production** ๐Ÿ—๏ธ:
34
+ ```bash
35
+ npm run build
36
+ ```
37
+
38
+ ### ๐Ÿงช How to Test
39
+
40
+ 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:
41
+
42
+ - **Create React App** (Webpack)
43
+ - **Vite** โšก
44
+ - **Rollup** (itself) (Coming soon) ๐Ÿ”„
45
+ - **Parcel** (Coming soon) ๐Ÿ“ฆ
46
+
47
+ This ensures Nodeblocks libraries integrate seamlessly with different workflows. ๐Ÿ› ๏ธโœจ
48
+
49
+ **Before running each project make sure you run `npm link`:**
50
+
51
+ 1. In the root of this project:
52
+ ```bash
53
+ npm link
54
+ ```
55
+ 2. In the test project you want to run:
56
+
57
+ ```bash
58
+ npm i
59
+ npm link @basaldev/frontend-starter-kit
60
+ ```
61
+
62
+ (Note that in real life your library would not be called frontend-starter-kit.)
63
+
64
+ 3. Then you can follow your usual workflow either with **Create React App** (`npm start`) or with Vite (`npm run dev`). This will give you a development environment where whenever you change your library it will be available in your test project.