@knapsack/renderer-react-components 4.71.13--canary.5224.9b1b429.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.
Files changed (48) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +9 -0
  3. package/.lintstagedrc.mjs +11 -0
  4. package/.turbo/turbo-build.log +4 -0
  5. package/.turbo/turbo-lint.log +4 -0
  6. package/dist/demo-wrapper.d.ts +10 -0
  7. package/dist/demo-wrapper.d.ts.map +1 -0
  8. package/dist/demo-wrapper.js +4 -0
  9. package/dist/demo-wrapper.js.map +1 -0
  10. package/dist/error-catcher.d.ts +20 -0
  11. package/dist/error-catcher.d.ts.map +1 -0
  12. package/dist/error-catcher.js +34 -0
  13. package/dist/error-catcher.js.map +1 -0
  14. package/dist/prototype-template.d.ts +6 -0
  15. package/dist/prototype-template.d.ts.map +1 -0
  16. package/dist/prototype-template.js +3 -0
  17. package/dist/prototype-template.js.map +1 -0
  18. package/dist/react-renderer-client-app.d.ts +10 -0
  19. package/dist/react-renderer-client-app.d.ts.map +1 -0
  20. package/dist/react-renderer-client-app.js +8 -0
  21. package/dist/react-renderer-client-app.js.map +1 -0
  22. package/dist/test-fixtures/button.d.ts +6 -0
  23. package/dist/test-fixtures/button.d.ts.map +1 -0
  24. package/dist/test-fixtures/button.js +5 -0
  25. package/dist/test-fixtures/button.js.map +1 -0
  26. package/dist/test-fixtures/card-prop-types.d.ts +7 -0
  27. package/dist/test-fixtures/card-prop-types.d.ts.map +1 -0
  28. package/dist/test-fixtures/card-prop-types.js +50 -0
  29. package/dist/test-fixtures/card-prop-types.js.map +1 -0
  30. package/dist/test-fixtures/card.d.ts +23 -0
  31. package/dist/test-fixtures/card.d.ts.map +1 -0
  32. package/dist/test-fixtures/card.js +9 -0
  33. package/dist/test-fixtures/card.js.map +1 -0
  34. package/dist/test-fixtures/index.d.ts +4 -0
  35. package/dist/test-fixtures/index.d.ts.map +1 -0
  36. package/dist/test-fixtures/index.js +4 -0
  37. package/dist/test-fixtures/index.js.map +1 -0
  38. package/package.json +59 -0
  39. package/readme.md +1 -0
  40. package/src/demo-wrapper.tsx +14 -0
  41. package/src/error-catcher.tsx +79 -0
  42. package/src/prototype-template.tsx +5 -0
  43. package/src/react-renderer-client-app.tsx +26 -0
  44. package/src/test-fixtures/button.tsx +7 -0
  45. package/src/test-fixtures/card-prop-types.tsx +79 -0
  46. package/src/test-fixtures/card.tsx +54 -0
  47. package/src/test-fixtures/index.ts +3 -0
  48. package/tsconfig.json +12 -0
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist
package/.eslintrc.cjs ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ extends: [
3
+ '@knapsack/eslint-config-starter/react',
4
+ '@knapsack/eslint-config-starter',
5
+ ],
6
+ parserOptions: { tsconfigRootDir: __dirname },
7
+ ignorePatterns: [],
8
+ rules: {},
9
+ };
@@ -0,0 +1,11 @@
1
+ import { dirname } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+
4
+ import defaultConfig from '../../../../.lintstagedrc.mjs';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+
8
+ export default {
9
+ '*.{ts,tsx,js,jsx,cjs,mjs}': `cd ${__dirname} && ./node_modules/.bin/eslint`,
10
+ ...defaultConfig,
11
+ };
@@ -0,0 +1,4 @@
1
+
2
+ > @knapsack/renderer-react-components@4.71.12 build /home/runner/work/app-monorepo/app-monorepo/apps/client/libs/renderer-react-components
3
+ > tsc
4
+
@@ -0,0 +1,4 @@
1
+
2
+ > @knapsack/renderer-react-components@4.71.12 lint /home/runner/work/app-monorepo/app-monorepo/apps/client/libs/renderer-react-components
3
+ > eslint ./
4
+
@@ -0,0 +1,10 @@
1
+ import type { Demo } from '@knapsack/types';
2
+ export type DemoWrapperProps = {
3
+ children: React.ReactNode;
4
+ demo: Demo;
5
+ patternId: string;
6
+ templateId: string;
7
+ };
8
+ declare const DemoWrapper: ({ children }: DemoWrapperProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default DemoWrapper;
10
+ //# sourceMappingURL=demo-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-wrapper.d.ts","sourceRoot":"","sources":["../src/demo-wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,WAAW,iBAAkB,gBAAgB,4CAElD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const DemoWrapper = ({ children }) => (_jsx("div", { className: "demo-wrapper", children: children }));
3
+ export default DemoWrapper;
4
+ //# sourceMappingURL=demo-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-wrapper.js","sourceRoot":"","sources":["../src/demo-wrapper.tsx"],"names":[],"mappings":";AASA,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAoB,EAAE,EAAE,CAAC,CACtD,cAAK,SAAS,EAAC,cAAc,YAAE,QAAQ,GAAO,CAC/C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ type State = {
3
+ hasError: boolean;
4
+ componentStack?: string;
5
+ error?: Error;
6
+ };
7
+ export default class ErrorCatcher extends React.Component<{
8
+ children: React.ReactNode;
9
+ }, State> {
10
+ constructor(props: {
11
+ children: React.ReactNode;
12
+ });
13
+ static getDerivedStateFromError(_error: Error): {
14
+ hasError: boolean;
15
+ };
16
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
17
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=error-catcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-catcher.d.ts","sourceRoot":"","sources":["../src/error-catcher.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,SAAS,CACvD;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,EAC7B,KAAK,CACN;gBACa,KAAK,EAAE;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;IAQhD,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK;;;IAOpC,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI;IAQjE,MAAM;CA2ChB"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ export default class ErrorCatcher extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.state = {
7
+ hasError: false,
8
+ componentStack: '',
9
+ };
10
+ }
11
+ static getDerivedStateFromError(_error) {
12
+ // Update state so the next render will show the fallback UI.
13
+ return {
14
+ hasError: true,
15
+ };
16
+ }
17
+ componentDidCatch(error, errorInfo) {
18
+ const { componentStack } = errorInfo;
19
+ this.setState({
20
+ error,
21
+ componentStack: componentStack !== null && componentStack !== void 0 ? componentStack : '',
22
+ });
23
+ }
24
+ render() {
25
+ var _a, _b, _c, _d, _e, _f;
26
+ if (this.state.hasError) {
27
+ return (_jsxs("div", { style: {
28
+ padding: '5px',
29
+ }, children: [_jsx("h5", { children: "Error caught in React Components" }), ((_a = this.state.error) === null || _a === void 0 ? void 0 : _a.name) && (_jsxs("h5", { children: ["Error Name: ", _jsx("code", { children: (_b = this.state.error) === null || _b === void 0 ? void 0 : _b.name })] })), ((_c = this.state.error) === null || _c === void 0 ? void 0 : _c.message) && (_jsxs("h5", { children: ["Message:", (_d = this.state.error) === null || _d === void 0 ? void 0 : _d.message] })), this.state.componentStack && (_jsxs(_Fragment, { children: [_jsx("h6", { children: "Component Stack:" }), _jsx("pre", { children: _jsx("code", { children: this.state.componentStack }) }), _jsx("br", {})] })), ((_e = this.state.error) === null || _e === void 0 ? void 0 : _e.stack) && (_jsxs(_Fragment, { children: [_jsx("h6", { children: "Error Stack:" }), _jsx("pre", { children: _jsx("code", { children: (_f = this.state.error) === null || _f === void 0 ? void 0 : _f.stack }) })] }))] }));
30
+ }
31
+ return this.props.children;
32
+ }
33
+ }
34
+ //# sourceMappingURL=error-catcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-catcher.js","sourceRoot":"","sources":["../src/error-catcher.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,SAG/C;IACC,YAAY,KAAoC;QAC9C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAK;YACf,cAAc,EAAE,EAAE;SACnB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,MAAa;QAC3C,6DAA6D;QAC7D,OAAO;YACL,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAEQ,iBAAiB,CAAC,KAAY,EAAE,SAA0B;QACjE,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;QACrC,IAAI,CAAC,QAAQ,CAAC;YACZ,KAAK;YACL,cAAc,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE;SACrC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,CACL,eACE,KAAK,EAAE;oBACL,OAAO,EAAE,KAAK;iBACf,aAED,4DAAyC,EACxC,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,IAAI,KAAI,CACzB,yCACc,yBAAO,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,IAAI,GAAQ,IAC9C,CACN,EACA,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,OAAO,KAAI,CAC5B,qCAEG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,OAAO,IACvB,CACN,EACA,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,CAC5B,8BACE,4CAAyB,EACzB,wBACE,yBAAO,IAAI,CAAC,KAAK,CAAC,cAAc,GAAQ,GACpC,EACN,cAAM,IACL,CACJ,EACA,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,KAAI,CAC1B,8BACE,wCAAqB,EACrB,wBACE,yBAAO,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,GAAQ,GAClC,IACL,CACJ,IACG,CACP,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ declare const PrototypeWrapper: ({ children }: {
3
+ children: ReactNode;
4
+ }) => ReactNode;
5
+ export default PrototypeWrapper;
6
+ //# sourceMappingURL=prototype-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-template.d.ts","sourceRoot":"","sources":["../src/prototype-template.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,QAAA,MAAM,gBAAgB,iBAAkB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,cAAa,CAAC;AAE7E,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ const PrototypeWrapper = ({ children }) => children;
2
+ export default PrototypeWrapper;
3
+ //# sourceMappingURL=prototype-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-template.js","sourceRoot":"","sources":["../src/prototype-template.tsx"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC,QAAQ,CAAC;AAE7E,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type ComponentType } from 'react';
2
+ import type { Except } from '@knapsack/types';
3
+ import type { DemoWrapperProps } from './demo-wrapper.js';
4
+ export declare const ReactRendererClientApp: ({ DemoApp, DemoWrapper, disableReactStrictMode, demoWrapperProps, }: {
5
+ DemoApp: ComponentType<Record<string, unknown>>;
6
+ DemoWrapper: ComponentType<Record<string, unknown>>;
7
+ demoWrapperProps: Except<DemoWrapperProps, "children">;
8
+ disableReactStrictMode?: boolean;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=react-renderer-client-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-renderer-client-app.d.ts","sourceRoot":"","sources":["../src/react-renderer-client-app.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,sBAAsB,wEAKhC;IACD,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;IACvD,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,4CAUA,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { StrictMode } from 'react';
3
+ import ErrorCatcher from './error-catcher.js';
4
+ export const ReactRendererClientApp = ({ DemoApp, DemoWrapper, disableReactStrictMode, demoWrapperProps, }) => {
5
+ const app = (_jsx(ErrorCatcher, { children: _jsx(DemoWrapper, { ...demoWrapperProps, children: _jsx(DemoApp, {}) }) }));
6
+ return disableReactStrictMode ? app : _jsx(StrictMode, { children: app });
7
+ };
8
+ //# sourceMappingURL=react-renderer-client-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-renderer-client-app.js","sourceRoot":"","sources":["../src/react-renderer-client-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,OAAO,CAAC;AAEvD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAG9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,gBAAgB,GAMjB,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,CACV,KAAC,YAAY,cACX,KAAC,WAAW,OAAK,gBAAgB,YAC/B,KAAC,OAAO,KAAG,GACC,GACD,CAChB,CAAC;IAEF,OAAO,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAC,UAAU,cAAE,GAAG,GAAc,CAAC;AACvE,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const Button: (props: {
2
+ text: string;
3
+ size?: "small" | "medium" | "large";
4
+ children: React.ReactNode;
5
+ }) => import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/button.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,UAAW;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,4CAEA,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const Button = (props) => {
3
+ return _jsx("button", { type: "button", children: props.text });
4
+ };
5
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/test-fixtures/button.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAItB,EAAE,EAAE;IACH,OAAO,iBAAQ,IAAI,EAAC,QAAQ,YAAE,KAAK,CAAC,IAAI,GAAU,CAAC;AACrD,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare class CardPropTypes extends React.Component {
3
+ constructor(props: any);
4
+ handleButtonClick(): void;
5
+ render(): import("react/jsx-runtime").JSX.Element;
6
+ }
7
+ //# sourceMappingURL=card-prop-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-prop-types.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/card-prop-types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS;gBACpC,KAAK,EAAE,GAAG;IAQtB,iBAAiB;IAUR,MAAM;CAmChB"}
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ export class CardPropTypes extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.state = {
8
+ count: 0,
9
+ };
10
+ this.handleButtonClick = this.handleButtonClick.bind(this);
11
+ }
12
+ handleButtonClick() {
13
+ this.setState((prevState) => {
14
+ // @ts-expect-error purposely not typed
15
+ const newCount = prevState.count + 1;
16
+ // @ts-expect-error purposely not typed
17
+ this.props.handleClick(newCount);
18
+ return { count: newCount };
19
+ });
20
+ }
21
+ render() {
22
+ return (_jsxs("aside", {
23
+ // @ts-expect-error purposely not typed
24
+ className: `card card--align-${this.props.align}${
25
+ // @ts-expect-error purposely not typed
26
+ this.props.isDark ? ' card--dark' : ''}`, children: [this.props.headerSlot, _jsx("div", { className: "card__img",
27
+ // @ts-expect-error purposely not typed
28
+ style: { backgroundImage: `url("${this.props.img}")` } }), _jsxs("div", { className: "card__contents", children: [_jsx("h3", { className: "card__title", children: this.props.title }), _jsxs("p", { children: ["Count:", this.state.count] }), _jsx("button", { onClick: this.handleButtonClick, type: "button", children: "Add" }), _jsx("p", { className: "card__body", children: this.props.body })] }), _jsx("footer", { className: "card__footer", children: this.props.children })] }));
29
+ }
30
+ }
31
+ // @ts-expect-error purposely not typed
32
+ CardPropTypes.defaultProps = {
33
+ align: 'left',
34
+ children: null,
35
+ handleClick: () => { },
36
+ isDark: false,
37
+ };
38
+ // @ts-expect-error purposely not typed
39
+ CardPropTypes.propTypes = {
40
+ /**
41
+ * The card title
42
+ */
43
+ title: PropTypes.string.isRequired,
44
+ align: PropTypes.oneOf(['left', 'right']),
45
+ children: PropTypes.node,
46
+ headerSlot: PropTypes.node.isRequired,
47
+ handleClick: PropTypes.func,
48
+ isDark: PropTypes.bool,
49
+ };
50
+ //# sourceMappingURL=card-prop-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-prop-types.js","sourceRoot":"","sources":["../../src/test-fixtures/card-prop-types.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,MAAM,OAAO,aAAc,SAAQ,KAAK,CAAC,SAAS;IAChD,YAAY,KAAU;QACpB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,CAAC;SACT,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1B,uCAAuC;YACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC;YACrC,uCAAuC;YACvC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACjC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,CACL;YACE,uCAAuC;YACvC,SAAS,EAAE,oBAAoB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG;YAChD,uCAAuC;YACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EACtC,EAAE,aAGD,IAAI,CAAC,KAAK,CAAC,UAAU,EACtB,cACE,SAAS,EAAC,WAAW;oBACrB,uCAAuC;oBACvC,KAAK,EAAE,EAAE,eAAe,EAAE,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,GACtD,EACF,eAAK,SAAS,EAAC,gBAAgB,aAE7B,aAAI,SAAS,EAAC,aAAa,YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAM,EACnD,kCAGG,IAAI,CAAC,KAAK,CAAC,KAAK,IACf,EACJ,iBAAQ,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,EAAC,QAAQ,oBAE7C,EAET,YAAG,SAAS,EAAC,YAAY,YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAK,IAC3C,EAEN,iBAAQ,SAAS,EAAC,cAAc,YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAU,IACzD,CACT,CAAC;IACJ,CAAC;CACF;AAED,uCAAuC;AACvC,aAAa,CAAC,YAAY,GAAG;IAC3B,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,uCAAuC;AACvC,aAAa,CAAC,SAAS,GAAG;IACxB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACrC,WAAW,EAAE,SAAS,CAAC,IAAI;IAC3B,MAAM,EAAE,SAAS,CAAC,IAAI;CACvB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ textAlign?: 'left' | 'center' | 'right';
4
+ imgSrc?: string;
5
+ isDark?: boolean;
6
+ cardTitle?: string;
7
+ cardSubTitle?: string;
8
+ cardBody: string;
9
+ handleIt?: (x: string) => boolean;
10
+ header?: React.ReactNode;
11
+ /**
12
+ * Goes in footer
13
+ */
14
+ children?: React.ReactNode;
15
+ items: {
16
+ id: string;
17
+ title: string;
18
+ description?: string;
19
+ }[];
20
+ };
21
+ export declare const Card: React.FC<Props>;
22
+ export default Card;
23
+ //# sourceMappingURL=card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAExC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwBhC,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const Card = ({ textAlign = 'left', children, cardBody,
3
+ // cardHeader,
4
+ cardSubTitle, cardTitle, imgSrc, isDark = true, }) => {
5
+ const classes = `card text-${textAlign} ${isDark ? 'bg-dark' : ''}`;
6
+ return (_jsxs("div", { className: classes, children: [imgSrc && _jsx("img", { src: imgSrc, className: "card-img-top", alt: "hi" }), _jsxs("div", { className: "card-body", children: [_jsx("h5", { className: "card-title", children: cardTitle }), cardSubTitle && (_jsx("h6", { className: "card-subtitle mb-2 text-muted", children: cardSubTitle })), _jsx("p", { className: "card-text", children: cardBody }), children] })] }));
7
+ };
8
+ export default Card;
9
+ //# sourceMappingURL=card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card.js","sourceRoot":"","sources":["../../src/test-fixtures/card.tsx"],"names":[],"mappings":";AA2BA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EACpC,SAAS,GAAG,MAAM,EAClB,QAAQ,EACR,QAAQ;AACR,cAAc;AACd,YAAY,EACZ,SAAS,EACT,MAAM,EACN,MAAM,GAAG,IAAI,GACP,EAAE,EAAE;IACV,MAAM,OAAO,GAAG,aAAa,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpE,OAAO,CACL,eAAK,SAAS,EAAE,OAAO,aACpB,MAAM,IAAI,cAAK,GAAG,EAAE,MAAM,EAAE,SAAS,EAAC,cAAc,EAAC,GAAG,EAAC,IAAI,GAAG,EACjE,eAAK,SAAS,EAAC,WAAW,aACxB,aAAI,SAAS,EAAC,YAAY,YAAE,SAAS,GAAM,EAC1C,YAAY,IAAI,CACf,aAAI,SAAS,EAAC,+BAA+B,YAAE,YAAY,GAAM,CAClE,EACD,YAAG,SAAS,EAAC,WAAW,YAAE,QAAQ,GAAK,EACtC,QAAQ,IACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './button.js';
2
+ export * from './card.js';
3
+ export * from './card-prop-types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './button.js';
2
+ export * from './card.js';
3
+ export * from './card-prop-types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@knapsack/renderer-react-components",
3
+ "description": "",
4
+ "version": "4.71.13--canary.5224.9b1b429.0",
5
+ "type": "module",
6
+ "exports": {
7
+ "./demo-wrapper": {
8
+ "types": "./dist/demo-wrapper.d.ts",
9
+ "default": "./dist/demo-wrapper.js"
10
+ },
11
+ "./error-catcher": {
12
+ "types": "./dist/error-catcher.d.ts",
13
+ "default": "./dist/error-catcher.js"
14
+ },
15
+ "./package": "./package.json",
16
+ "./package.json": "./package.json",
17
+ "./prototype-template": {
18
+ "types": "./dist/prototype-template.d.ts",
19
+ "default": "./dist/prototype-template.js"
20
+ },
21
+ "./react-renderer-client-app": {
22
+ "types": "./dist/react-renderer-client-app.d.ts",
23
+ "default": "./dist/react-renderer-client-app.js"
24
+ },
25
+ "./test-fixtures": {
26
+ "types": "./dist/test-fixtures/index.d.ts",
27
+ "default": "./dist/test-fixtures/index.js"
28
+ }
29
+ },
30
+ "sideEffects": false,
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "clean": "rm -rf ./dist",
34
+ "lint": "eslint ./"
35
+ },
36
+ "devDependencies": {
37
+ "@knapsack/eslint-config-starter": "4.71.13--canary.5224.9b1b429.0",
38
+ "@knapsack/prettier-config": "4.71.13--canary.5224.9b1b429.0",
39
+ "@knapsack/types": "4.71.13--canary.5224.9b1b429.0",
40
+ "@knapsack/typescript-config-starter": "4.71.13--canary.5224.9b1b429.0",
41
+ "@types/node": "^20.17.8",
42
+ "@types/prop-types": "^15.7.13",
43
+ "@types/react": "^18.3.12",
44
+ "eslint": "^8.57.0",
45
+ "prop-types": "^15.8.1",
46
+ "react": "^18.3.1",
47
+ "typescript": "^5.6.3"
48
+ },
49
+ "license": "GPL-2.0-or-later",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "repository": {
54
+ "url": "https://github.com/knapsack-labs/app-monorepo",
55
+ "directory": "apps/client/libs/renderer-react-components",
56
+ "type": "git"
57
+ },
58
+ "gitHead": "9b1b429dcf7e68d4d957d5b0d9dc32bfdfc0ae02"
59
+ }
package/readme.md ADDED
@@ -0,0 +1 @@
1
+ This package exists because `@knapsack/renderer-react` is a CommonJS package and currently `.mtsx` files do not work with CommonJS packages.
@@ -0,0 +1,14 @@
1
+ import type { Demo } from '@knapsack/types';
2
+
3
+ export type DemoWrapperProps = {
4
+ children: React.ReactNode;
5
+ demo: Demo;
6
+ patternId: string;
7
+ templateId: string;
8
+ };
9
+
10
+ const DemoWrapper = ({ children }: DemoWrapperProps) => (
11
+ <div className="demo-wrapper">{children}</div>
12
+ );
13
+
14
+ export default DemoWrapper;
@@ -0,0 +1,79 @@
1
+ import * as React from 'react';
2
+
3
+ type State = {
4
+ hasError: boolean;
5
+ componentStack?: string;
6
+ error?: Error;
7
+ };
8
+
9
+ export default class ErrorCatcher extends React.Component<
10
+ { children: React.ReactNode },
11
+ State
12
+ > {
13
+ constructor(props: { children: React.ReactNode }) {
14
+ super(props);
15
+ this.state = {
16
+ hasError: false,
17
+ componentStack: '',
18
+ };
19
+ }
20
+
21
+ static getDerivedStateFromError(_error: Error) {
22
+ // Update state so the next render will show the fallback UI.
23
+ return {
24
+ hasError: true,
25
+ };
26
+ }
27
+
28
+ override componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
29
+ const { componentStack } = errorInfo;
30
+ this.setState({
31
+ error,
32
+ componentStack: componentStack ?? '',
33
+ });
34
+ }
35
+
36
+ override render() {
37
+ if (this.state.hasError) {
38
+ return (
39
+ <div
40
+ style={{
41
+ padding: '5px',
42
+ }}
43
+ >
44
+ <h5>Error caught in React Components</h5>
45
+ {this.state.error?.name && (
46
+ <h5>
47
+ Error Name: <code>{this.state.error?.name}</code>
48
+ </h5>
49
+ )}
50
+ {this.state.error?.message && (
51
+ <h5>
52
+ Message:
53
+ {this.state.error?.message}
54
+ </h5>
55
+ )}
56
+ {this.state.componentStack && (
57
+ <>
58
+ <h6>Component Stack:</h6>
59
+ <pre>
60
+ <code>{this.state.componentStack}</code>
61
+ </pre>
62
+ <br />
63
+ </>
64
+ )}
65
+ {this.state.error?.stack && (
66
+ <>
67
+ <h6>Error Stack:</h6>
68
+ <pre>
69
+ <code>{this.state.error?.stack}</code>
70
+ </pre>
71
+ </>
72
+ )}
73
+ </div>
74
+ );
75
+ }
76
+
77
+ return this.props.children;
78
+ }
79
+ }
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ const PrototypeWrapper = ({ children }: { children: ReactNode }) => children;
4
+
5
+ export default PrototypeWrapper;
@@ -0,0 +1,26 @@
1
+ import { StrictMode, type ComponentType } from 'react';
2
+ import type { Except } from '@knapsack/types';
3
+ import ErrorCatcher from './error-catcher.js';
4
+ import type { DemoWrapperProps } from './demo-wrapper.js';
5
+
6
+ export const ReactRendererClientApp = ({
7
+ DemoApp,
8
+ DemoWrapper,
9
+ disableReactStrictMode,
10
+ demoWrapperProps,
11
+ }: {
12
+ DemoApp: ComponentType<Record<string, unknown>>;
13
+ DemoWrapper: ComponentType<Record<string, unknown>>;
14
+ demoWrapperProps: Except<DemoWrapperProps, 'children'>;
15
+ disableReactStrictMode?: boolean;
16
+ }) => {
17
+ const app = (
18
+ <ErrorCatcher>
19
+ <DemoWrapper {...demoWrapperProps}>
20
+ <DemoApp />
21
+ </DemoWrapper>
22
+ </ErrorCatcher>
23
+ );
24
+
25
+ return disableReactStrictMode ? app : <StrictMode>{app}</StrictMode>;
26
+ };
@@ -0,0 +1,7 @@
1
+ export const Button = (props: {
2
+ text: string;
3
+ size?: 'small' | 'medium' | 'large';
4
+ children: React.ReactNode;
5
+ }) => {
6
+ return <button type="button">{props.text}</button>;
7
+ };
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ export class CardPropTypes extends React.Component {
5
+ constructor(props: any) {
6
+ super(props);
7
+ this.state = {
8
+ count: 0,
9
+ };
10
+ this.handleButtonClick = this.handleButtonClick.bind(this);
11
+ }
12
+
13
+ handleButtonClick() {
14
+ this.setState((prevState) => {
15
+ // @ts-expect-error purposely not typed
16
+ const newCount = prevState.count + 1;
17
+ // @ts-expect-error purposely not typed
18
+ this.props.handleClick(newCount);
19
+ return { count: newCount };
20
+ });
21
+ }
22
+
23
+ override render() {
24
+ return (
25
+ <aside
26
+ // @ts-expect-error purposely not typed
27
+ className={`card card--align-${this.props.align}${
28
+ // @ts-expect-error purposely not typed
29
+ this.props.isDark ? ' card--dark' : ''
30
+ }`}
31
+ >
32
+ {/* @ts-expect-error purposely not typed */}
33
+ {this.props.headerSlot}
34
+ <div
35
+ className="card__img"
36
+ // @ts-expect-error purposely not typed
37
+ style={{ backgroundImage: `url("${this.props.img}")` }}
38
+ />
39
+ <div className="card__contents">
40
+ {/* @ts-expect-error purposely not typed */}
41
+ <h3 className="card__title">{this.props.title}</h3>
42
+ <p>
43
+ Count:
44
+ {/* @ts-expect-error purposely not typed */}
45
+ {this.state.count}
46
+ </p>
47
+ <button onClick={this.handleButtonClick} type="button">
48
+ Add
49
+ </button>
50
+ {/* @ts-expect-error purposely not typed */}
51
+ <p className="card__body">{this.props.body}</p>
52
+ </div>
53
+ {/* @ts-expect-error purposely not typed */}
54
+ <footer className="card__footer">{this.props.children}</footer>
55
+ </aside>
56
+ );
57
+ }
58
+ }
59
+
60
+ // @ts-expect-error purposely not typed
61
+ CardPropTypes.defaultProps = {
62
+ align: 'left',
63
+ children: null,
64
+ handleClick: () => {},
65
+ isDark: false,
66
+ };
67
+
68
+ // @ts-expect-error purposely not typed
69
+ CardPropTypes.propTypes = {
70
+ /**
71
+ * The card title
72
+ */
73
+ title: PropTypes.string.isRequired,
74
+ align: PropTypes.oneOf(['left', 'right']),
75
+ children: PropTypes.node,
76
+ headerSlot: PropTypes.node.isRequired,
77
+ handleClick: PropTypes.func,
78
+ isDark: PropTypes.bool,
79
+ };
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+
3
+ // export const CardButton = ({ disabled = false, text }) => (
4
+ // <button>{text}</button>
5
+ // );
6
+
7
+ type Props = {
8
+ textAlign?: 'left' | 'center' | 'right';
9
+ // cardHeader?: string;
10
+ imgSrc?: string;
11
+ isDark?: boolean;
12
+ cardTitle?: string;
13
+ cardSubTitle?: string;
14
+ cardBody: string;
15
+ handleIt?: (x: string) => boolean;
16
+ header?: React.ReactNode;
17
+ /**
18
+ * Goes in footer
19
+ */
20
+ children?: React.ReactNode;
21
+ items: {
22
+ id: string;
23
+ title: string;
24
+ description?: string;
25
+ }[];
26
+ };
27
+
28
+ export const Card: React.FC<Props> = ({
29
+ textAlign = 'left',
30
+ children,
31
+ cardBody,
32
+ // cardHeader,
33
+ cardSubTitle,
34
+ cardTitle,
35
+ imgSrc,
36
+ isDark = true,
37
+ }: Props) => {
38
+ const classes = `card text-${textAlign} ${isDark ? 'bg-dark' : ''}`;
39
+ return (
40
+ <div className={classes}>
41
+ {imgSrc && <img src={imgSrc} className="card-img-top" alt="hi" />}
42
+ <div className="card-body">
43
+ <h5 className="card-title">{cardTitle}</h5>
44
+ {cardSubTitle && (
45
+ <h6 className="card-subtitle mb-2 text-muted">{cardSubTitle}</h6>
46
+ )}
47
+ <p className="card-text">{cardBody}</p>
48
+ {children}
49
+ </div>
50
+ </div>
51
+ );
52
+ };
53
+
54
+ export default Card;
@@ -0,0 +1,3 @@
1
+ export * from './button.js';
2
+ export * from './card.js';
3
+ export * from './card-prop-types.js';
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@knapsack/typescript-config-starter/tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "strict": false,
5
+ "strictNullChecks": false,
6
+ "module": "NodeNext",
7
+ "moduleResolution": "NodeNext",
8
+ "noImplicitAny": true,
9
+ "outDir": "./dist"
10
+ },
11
+ "include": ["./src"]
12
+ }