@repodeckhz/react 0.6.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/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @repodeckhz/react
2
+
3
+ > Thin React wrapper around the [`repodeck`](../web-component) web component.
4
+
5
+ Gives React users a familiar `<RepoDeck />` component instead of dealing with custom-element refs directly.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @repodeckhz/react repodeck
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { RepoDeck, RepoDeckList } from '@repodeckhz/react';
17
+
18
+ export default function Page() {
19
+ return (
20
+ <div>
21
+ <RepoDeck
22
+ owner="your-name"
23
+ repo="your-repo"
24
+ preset="standard"
25
+ showStats
26
+ onLoad={(data) => console.log('loaded', data)}
27
+ onModalOpen={() => console.log('modal opened')}
28
+ />
29
+
30
+ <RepoDeckList
31
+ repos="your-name/project-a,your-name/project-b,your-name/project-c"
32
+ showStats
33
+ lazy
34
+ sort="stars"
35
+ sortOrder="desc"
36
+ />
37
+ </div>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## Props
43
+
44
+ ### `<RepoDeck>`
45
+
46
+ | Prop | Type | Default | Description |
47
+ |---|---|---|---|
48
+ | `owner` | `string` | required | GitHub owner |
49
+ | `repo` | `string` | required | GitHub repo |
50
+ | `branch` | `string` | `main` | Branch to read from |
51
+ | `ref` | `string` | (none) | Tag or commit SHA pin |
52
+ | `preset` | `'minimal' \| 'standard' \| 'detailed'` | `standard` | Card preset |
53
+ | `configPath` | `string` | `config-repodeck` | Custom config folder name |
54
+ | `theme` | `'light' \| 'dark' \| 'auto'` | `auto` | Card theme |
55
+ | `modalSections` | `string` | `readme,screenshots,link` | Ordered modal sections |
56
+ | `radius` | `'sharp' \| 'soft' \| 'round' \| string` | `soft` | Corner radius |
57
+ | `dataUrl` | `string` | (none) | Custom data endpoint, `inline`, or `direct` |
58
+ | `token` | `string` | (none) | GitHub token sent to the data endpoint |
59
+ | `showStats` | `boolean` | false | Show stars/forks badge |
60
+ | `lazy` | `boolean` | false | IntersectionObserver lazy load |
61
+ | `hideBranding` | `boolean` | false | Hide "powered by" link |
62
+ | `noOptimize` | `boolean` | false | Disable the default WebP re-encoding of screenshots |
63
+ | `locale` | `'en' \| 'pt' \| 'es' \| 'fr'` | `en` | UI language |
64
+ | `debug` | `boolean` | false | Verbose lifecycle logging |
65
+ | `onLoad` | `(data) => void` | (none) | Called when data loads |
66
+ | `onError` | `(error) => void` | (none) | Called on error |
67
+ | `onModalOpen` | `() => void` | (none) | Called when modal opens |
68
+ | `onModalClose` | `() => void` | (none) | Called when modal closes |
69
+
70
+ ### `<RepoDeckList>`
71
+
72
+ | Prop | Type | Default | Description |
73
+ |---|---|---|---|
74
+ | `repos` | `string` | required | Comma-separated `owner/repo` list |
75
+ | `cols` | `string` | (none) | Grid columns (e.g. `3` or `repeat(auto-fit, minmax(280px, 1fr))`) |
76
+ | `gap` | `string` | (none) | Grid gap (e.g. `16px`) |
77
+ | `sort` | `'none' \| 'order' \| 'stars' \| 'name'` | `none` | Sort key |
78
+ | `sortOrder` | `'asc' \| 'desc'` | `asc` | Sort direction |
79
+ | `filterTag` | `string` | (none) | Filter by frontmatter tags |
80
+ | `batchCheck` | `boolean` | false | Check rate limit before loading |
81
+ | `token` | `string` | (none) | GitHub token forwarded to each card |
82
+ | `noOptimize` | `boolean` | false | Disables WebP re-encoding on every card |
83
+ | ... | | | All other props from `<RepoDeck>` are forwarded to each card |
84
+
85
+ ## License
86
+
87
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,145 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ require('@repodeckhz/web/auto');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
+
13
+ var RepoDeck = React__default.default.forwardRef(function RepoDeck2(props, forwardedRef) {
14
+ const {
15
+ owner,
16
+ repo,
17
+ branch,
18
+ ref: refAttr,
19
+ preset,
20
+ configPath,
21
+ theme,
22
+ modalSections,
23
+ radius,
24
+ dataUrl,
25
+ showStats,
26
+ lazy,
27
+ hideBranding,
28
+ locale,
29
+ debug,
30
+ noOptimize,
31
+ token,
32
+ className,
33
+ style,
34
+ onLoad,
35
+ onError,
36
+ onModalOpen,
37
+ onModalClose
38
+ } = props;
39
+ const internalRef = React.useRef(null);
40
+ React.useEffect(() => {
41
+ const el = internalRef.current;
42
+ if (!el) return;
43
+ if (typeof forwardedRef === "function") forwardedRef(el);
44
+ else if (forwardedRef) forwardedRef.current = el;
45
+ if (refAttr) el.setAttribute("ref", refAttr);
46
+ if (onLoad) {
47
+ const handler = (e) => onLoad(e.detail?.data);
48
+ el.addEventListener("repodeck:loaded", handler);
49
+ }
50
+ if (onError) {
51
+ const handler = (e) => onError(e.detail?.error);
52
+ el.addEventListener("repodeck:error", handler);
53
+ }
54
+ if (onModalOpen) {
55
+ el.addEventListener("repodeck:modal-open", onModalOpen);
56
+ }
57
+ if (onModalClose) {
58
+ el.addEventListener("repodeck:modal-close", onModalClose);
59
+ }
60
+ }, [forwardedRef, refAttr, onLoad, onError, onModalOpen, onModalClose]);
61
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style, children: /* @__PURE__ */ jsxRuntime.jsx(
62
+ "repo-deck",
63
+ {
64
+ ref: internalRef,
65
+ owner,
66
+ repo,
67
+ ...branch ? { branch } : {},
68
+ ...preset ? { preset } : {},
69
+ ...configPath ? { "config-path": configPath } : {},
70
+ ...theme ? { theme } : {},
71
+ ...modalSections ? { "modal-sections": modalSections } : {},
72
+ ...radius ? { radius } : {},
73
+ ...dataUrl ? { "data-url": dataUrl } : {},
74
+ ...showStats ? { "show-stats": "" } : {},
75
+ ...lazy ? { lazy: "" } : {},
76
+ ...hideBranding ? { "hide-branding": "" } : {},
77
+ ...locale ? { locale } : {},
78
+ ...debug ? { debug: "" } : {},
79
+ ...noOptimize ? { "no-optimize": "" } : {},
80
+ ...token ? { token } : {}
81
+ }
82
+ ) });
83
+ });
84
+ var RepoDeckList = React__default.default.forwardRef(function RepoDeckList2(props, forwardedRef) {
85
+ const {
86
+ repos,
87
+ preset,
88
+ theme,
89
+ radius,
90
+ cols,
91
+ gap,
92
+ showStats,
93
+ lazy,
94
+ locale,
95
+ sort,
96
+ sortOrder,
97
+ filterTag,
98
+ batchCheck,
99
+ dataUrl,
100
+ modalSections,
101
+ configPath,
102
+ noOptimize,
103
+ token,
104
+ className,
105
+ style
106
+ } = props;
107
+ const internalRef = React.useRef(null);
108
+ React.useEffect(() => {
109
+ const el = internalRef.current;
110
+ if (!el) return;
111
+ if (typeof forwardedRef === "function") forwardedRef(el);
112
+ else if (forwardedRef) forwardedRef.current = el;
113
+ }, [forwardedRef]);
114
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style, children: /* @__PURE__ */ jsxRuntime.jsx(
115
+ "repodeck-list",
116
+ {
117
+ ref: internalRef,
118
+ repos,
119
+ ...preset ? { preset } : {},
120
+ ...theme ? { theme } : {},
121
+ ...radius ? { radius } : {},
122
+ ...cols ? { cols } : {},
123
+ ...gap ? { gap } : {},
124
+ ...showStats ? { "show-stats": "" } : {},
125
+ ...lazy ? { lazy: "" } : {},
126
+ ...locale ? { locale } : {},
127
+ ...sort ? { sort } : {},
128
+ ...sortOrder ? { "sort-order": sortOrder } : {},
129
+ ...filterTag ? { "filter-tag": filterTag } : {},
130
+ ...batchCheck ? { "batch-check": "" } : {},
131
+ ...dataUrl ? { "data-url": dataUrl } : {},
132
+ ...modalSections ? { "modal-sections": modalSections } : {},
133
+ ...configPath ? { "config-path": configPath } : {},
134
+ ...noOptimize ? { "no-optimize": "" } : {},
135
+ ...token ? { token } : {}
136
+ }
137
+ ) });
138
+ });
139
+ var index_default = RepoDeck;
140
+
141
+ exports.RepoDeck = RepoDeck;
142
+ exports.RepoDeckList = RepoDeckList;
143
+ exports.default = index_default;
144
+ //# sourceMappingURL=index.cjs.map
145
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","RepoDeck","useRef","useEffect","jsx","RepoDeckList"],"mappings":";;;;;;;;;;;;AA0DO,IAAM,WAAWA,sBAAA,CAAM,UAAA,CAAuC,SAASC,SAAAA,CAC5E,OACA,YAAA,EACA;AACA,EAAA,MAAM;AAAA,IACJ,KAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAK,OAAA;AAAA,IACL,MAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AAEJ,EAAA,MAAM,WAAA,GAAcC,aAAoB,IAAI,CAAA;AAE5C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,KAAK,WAAA,CAAY,OAAA;AACvB,IAAA,IAAI,CAAC,EAAA,EAAI;AAGT,IAAA,IAAI,OAAO,YAAA,KAAiB,UAAA,EAAY,YAAA,CAAa,EAAE,CAAA;AAAA,SAAA,IAC9C,YAAA,EAAe,YAAA,CAA4D,OAAA,GAAU,EAAA;AAI9F,IAAA,IAAI,OAAA,EAAS,EAAA,CAAG,YAAA,CAAa,KAAA,EAAO,OAAO,CAAA;AAG3C,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,MAAM,UAAU,CAAC,CAAA,KAAa,MAAA,CAAQ,CAAA,CAAkB,QAAQ,IAAI,CAAA;AAC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CAAA;AAEJ,CAAC;AAED,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\r\n * @repodeckhz/react — thin React wrapper around the <repo-deck> web component.\r\n *\r\n * Plan §2: \"wrapper fino em cima do web component, opcional/futuro\".\r\n * This gives React users a familiar <RepoDeck /> component instead of\r\n * dealing with custom-element refs directly.\r\n *\r\n * The web component auto-registers on import — this wrapper just provides\r\n * typed props.\r\n */\r\n\r\n'use client';\r\n\r\nimport React, { useEffect, useRef } from 'react';\r\nimport '@repodeckhz/web/auto';\r\n\r\nexport interface RepoDeckProps {\r\n owner: string;\r\n repo: string;\r\n branch?: string;\r\n ref?: string;\r\n preset?: 'minimal' | 'standard' | 'detailed';\r\n configPath?: string;\r\n theme?: 'light' | 'dark' | 'auto';\r\n modalSections?: string;\r\n radius?: 'sharp' | 'soft' | 'round' | string;\r\n dataUrl?: string;\r\n showStats?: boolean;\r\n lazy?: boolean;\r\n hideBranding?: boolean;\r\n locale?: string;\r\n debug?: boolean;\r\n /** Disables the default client-side WebP re-encoding of screenshots. */\r\n noOptimize?: boolean;\r\n /** GitHub token forwarded to the data endpoint via the Authorization header. */\r\n token?: string;\r\n /** Optional className for the wrapper div. */\r\n className?: string;\r\n /** Optional style for the wrapper div. */\r\n style?: React.CSSProperties;\r\n /** Called when the card data loads. */\r\n onLoad?: (data: unknown) => void;\r\n /** Called when the card errors. */\r\n onError?: (error: unknown) => void;\r\n /** Called when the modal opens. */\r\n onModalOpen?: () => void;\r\n /** Called when the modal closes. */\r\n onModalClose?: () => void;\r\n}\r\n\r\n/**\r\n * React wrapper for the <repo-deck> Custom Element.\r\n *\r\n * @example\r\n * import { RepoDeck } from '@repodeckhz/react';\r\n *\r\n * <RepoDeck owner=\"your-name\" repo=\"your-repo\" preset=\"standard\" showStats />\r\n */\r\nexport const RepoDeck = React.forwardRef<HTMLElement, RepoDeckProps>(function RepoDeck(\r\n props,\r\n forwardedRef,\r\n) {\r\n const {\r\n owner,\r\n repo,\r\n branch,\r\n ref: refAttr,\r\n preset,\r\n configPath,\r\n theme,\r\n modalSections,\r\n radius,\r\n dataUrl,\r\n showStats,\r\n lazy,\r\n hideBranding,\r\n locale,\r\n debug,\r\n noOptimize,\r\n token,\r\n className,\r\n style,\r\n onLoad,\r\n onError,\r\n onModalOpen,\r\n onModalClose,\r\n } = props as RepoDeckProps & { ref?: string };\r\n\r\n const internalRef = useRef<HTMLElement>(null);\r\n\r\n useEffect(() => {\r\n const el = internalRef.current;\r\n if (!el) return;\r\n\r\n // Set the forwarded ref.\r\n if (typeof forwardedRef === 'function') forwardedRef(el);\r\n else if (forwardedRef) (forwardedRef as React.MutableRefObject<HTMLElement | null>).current = el;\r\n\r\n // The `ref` prop (tag/commit pin, plan §16.7) conflicts with React's `ref`\r\n // for element refs — set it as an attribute imperatively.\r\n if (refAttr) el.setAttribute('ref', refAttr);\r\n\r\n // Wire event listeners.\r\n if (onLoad) {\r\n const handler = (e: Event) => onLoad((e as CustomEvent).detail?.data);\r\n el.addEventListener('repodeck:loaded', handler as EventListener);\r\n }\r\n if (onError) {\r\n const handler = (e: Event) => onError((e as CustomEvent).detail?.error);\r\n el.addEventListener('repodeck:error', handler as EventListener);\r\n }\r\n if (onModalOpen) {\r\n el.addEventListener('repodeck:modal-open', onModalOpen as EventListener);\r\n }\r\n if (onModalClose) {\r\n el.addEventListener('repodeck:modal-close', onModalClose as EventListener);\r\n }\r\n }, [forwardedRef, refAttr, onLoad, onError, onModalOpen, onModalClose]);\r\n\r\n return (\r\n <div className={className} style={style}>\r\n <repo-deck\r\n ref={internalRef}\r\n owner={owner}\r\n repo={repo}\r\n {...(branch ? { branch } : {})}\r\n {...(preset ? { preset } : {})}\r\n {...(configPath ? { 'config-path': configPath } : {})}\r\n {...(theme ? { theme } : {})}\r\n {...(modalSections ? { 'modal-sections': modalSections } : {})}\r\n {...(radius ? { radius } : {})}\r\n {...(dataUrl ? { 'data-url': dataUrl } : {})}\r\n {...(showStats ? { 'show-stats': '' } : {})}\r\n {...(lazy ? { lazy: '' } : {})}\r\n {...(hideBranding ? { 'hide-branding': '' } : {})}\r\n {...(locale ? { locale } : {})}\r\n {...(debug ? { debug: '' } : {})}\r\n {...(noOptimize ? { 'no-optimize': '' } : {})}\r\n {...(token ? { token } : {})}\r\n />\r\n </div>\r\n );\r\n});\r\n\r\nexport interface RepoDeckListProps {\r\n repos: string;\r\n preset?: 'minimal' | 'standard' | 'detailed';\r\n theme?: 'light' | 'dark' | 'auto';\r\n radius?: 'sharp' | 'soft' | 'round' | string;\r\n cols?: string;\r\n gap?: string;\r\n showStats?: boolean;\r\n lazy?: boolean;\r\n locale?: string;\r\n sort?: 'none' | 'order' | 'stars' | 'name';\r\n sortOrder?: 'asc' | 'desc';\r\n filterTag?: string;\r\n batchCheck?: boolean;\r\n dataUrl?: string;\r\n modalSections?: string;\r\n configPath?: string;\r\n /** Disables the default client-side WebP re-encoding of screenshots. */\r\n noOptimize?: boolean;\r\n /** GitHub token forwarded to each card's data endpoint (Authorization header). */\r\n token?: string;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n}\r\n\r\n/**\r\n * React wrapper for the <repodeck-list> Custom Element.\r\n *\r\n * @example\r\n * import { RepoDeckList } from '@repodeckhz/react';\r\n *\r\n * <RepoDeckList\r\n * repos=\"your-name/project-a,your-name/project-b\"\r\n * showStats\r\n * lazy\r\n * sort=\"stars\"\r\n * sort-order=\"desc\"\r\n * />\r\n */\r\nexport const RepoDeckList = React.forwardRef<HTMLElement, RepoDeckListProps>(function RepoDeckList(\r\n props,\r\n forwardedRef,\r\n) {\r\n const {\r\n repos,\r\n preset,\r\n theme,\r\n radius,\r\n cols,\r\n gap,\r\n showStats,\r\n lazy,\r\n locale,\r\n sort,\r\n sortOrder,\r\n filterTag,\r\n batchCheck,\r\n dataUrl,\r\n modalSections,\r\n configPath,\r\n noOptimize,\r\n token,\r\n className,\r\n style,\r\n } = props;\r\n\r\n const internalRef = useRef<HTMLElement>(null);\r\n\r\n useEffect(() => {\r\n const el = internalRef.current;\r\n if (!el) return;\r\n if (typeof forwardedRef === 'function') forwardedRef(el);\r\n else if (forwardedRef) (forwardedRef as React.MutableRefObject<HTMLElement | null>).current = el;\r\n }, [forwardedRef]);\r\n\r\n return (\r\n <div className={className} style={style}>\r\n <repodeck-list\r\n ref={internalRef}\r\n repos={repos}\r\n {...(preset ? { preset } : {})}\r\n {...(theme ? { theme } : {})}\r\n {...(radius ? { radius } : {})}\r\n {...(cols ? { cols } : {})}\r\n {...(gap ? { gap } : {})}\r\n {...(showStats ? { 'show-stats': '' } : {})}\r\n {...(lazy ? { lazy: '' } : {})}\r\n {...(locale ? { locale } : {})}\r\n {...(sort ? { sort } : {})}\r\n {...(sortOrder ? { 'sort-order': sortOrder } : {})}\r\n {...(filterTag ? { 'filter-tag': filterTag } : {})}\r\n {...(batchCheck ? { 'batch-check': '' } : {})}\r\n {...(dataUrl ? { 'data-url': dataUrl } : {})}\r\n {...(modalSections ? { 'modal-sections': modalSections } : {})}\r\n {...(configPath ? { 'config-path': configPath } : {})}\r\n {...(noOptimize ? { 'no-optimize': '' } : {})}\r\n {...(token ? { token } : {})}\r\n />\r\n </div>\r\n );\r\n});\r\n\r\nexport default RepoDeck;\r\n"]}
@@ -0,0 +1,96 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * @repodeckhz/react — thin React wrapper around the <repo-deck> web component.
5
+ *
6
+ * Plan §2: "wrapper fino em cima do web component, opcional/futuro".
7
+ * This gives React users a familiar <RepoDeck /> component instead of
8
+ * dealing with custom-element refs directly.
9
+ *
10
+ * The web component auto-registers on import — this wrapper just provides
11
+ * typed props.
12
+ */
13
+
14
+ interface RepoDeckProps {
15
+ owner: string;
16
+ repo: string;
17
+ branch?: string;
18
+ ref?: string;
19
+ preset?: 'minimal' | 'standard' | 'detailed';
20
+ configPath?: string;
21
+ theme?: 'light' | 'dark' | 'auto';
22
+ modalSections?: string;
23
+ radius?: 'sharp' | 'soft' | 'round' | string;
24
+ dataUrl?: string;
25
+ showStats?: boolean;
26
+ lazy?: boolean;
27
+ hideBranding?: boolean;
28
+ locale?: string;
29
+ debug?: boolean;
30
+ /** Disables the default client-side WebP re-encoding of screenshots. */
31
+ noOptimize?: boolean;
32
+ /** GitHub token forwarded to the data endpoint via the Authorization header. */
33
+ token?: string;
34
+ /** Optional className for the wrapper div. */
35
+ className?: string;
36
+ /** Optional style for the wrapper div. */
37
+ style?: React.CSSProperties;
38
+ /** Called when the card data loads. */
39
+ onLoad?: (data: unknown) => void;
40
+ /** Called when the card errors. */
41
+ onError?: (error: unknown) => void;
42
+ /** Called when the modal opens. */
43
+ onModalOpen?: () => void;
44
+ /** Called when the modal closes. */
45
+ onModalClose?: () => void;
46
+ }
47
+ /**
48
+ * React wrapper for the <repo-deck> Custom Element.
49
+ *
50
+ * @example
51
+ * import { RepoDeck } from '@repodeckhz/react';
52
+ *
53
+ * <RepoDeck owner="your-name" repo="your-repo" preset="standard" showStats />
54
+ */
55
+ declare const RepoDeck: React.ForwardRefExoticComponent<Omit<RepoDeckProps, "ref"> & React.RefAttributes<HTMLElement>>;
56
+ interface RepoDeckListProps {
57
+ repos: string;
58
+ preset?: 'minimal' | 'standard' | 'detailed';
59
+ theme?: 'light' | 'dark' | 'auto';
60
+ radius?: 'sharp' | 'soft' | 'round' | string;
61
+ cols?: string;
62
+ gap?: string;
63
+ showStats?: boolean;
64
+ lazy?: boolean;
65
+ locale?: string;
66
+ sort?: 'none' | 'order' | 'stars' | 'name';
67
+ sortOrder?: 'asc' | 'desc';
68
+ filterTag?: string;
69
+ batchCheck?: boolean;
70
+ dataUrl?: string;
71
+ modalSections?: string;
72
+ configPath?: string;
73
+ /** Disables the default client-side WebP re-encoding of screenshots. */
74
+ noOptimize?: boolean;
75
+ /** GitHub token forwarded to each card's data endpoint (Authorization header). */
76
+ token?: string;
77
+ className?: string;
78
+ style?: React.CSSProperties;
79
+ }
80
+ /**
81
+ * React wrapper for the <repodeck-list> Custom Element.
82
+ *
83
+ * @example
84
+ * import { RepoDeckList } from '@repodeckhz/react';
85
+ *
86
+ * <RepoDeckList
87
+ * repos="your-name/project-a,your-name/project-b"
88
+ * showStats
89
+ * lazy
90
+ * sort="stars"
91
+ * sort-order="desc"
92
+ * />
93
+ */
94
+ declare const RepoDeckList: React.ForwardRefExoticComponent<RepoDeckListProps & React.RefAttributes<HTMLElement>>;
95
+
96
+ export { RepoDeck, RepoDeckList, type RepoDeckListProps, type RepoDeckProps, RepoDeck as default };
@@ -0,0 +1,96 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * @repodeckhz/react — thin React wrapper around the <repo-deck> web component.
5
+ *
6
+ * Plan §2: "wrapper fino em cima do web component, opcional/futuro".
7
+ * This gives React users a familiar <RepoDeck /> component instead of
8
+ * dealing with custom-element refs directly.
9
+ *
10
+ * The web component auto-registers on import — this wrapper just provides
11
+ * typed props.
12
+ */
13
+
14
+ interface RepoDeckProps {
15
+ owner: string;
16
+ repo: string;
17
+ branch?: string;
18
+ ref?: string;
19
+ preset?: 'minimal' | 'standard' | 'detailed';
20
+ configPath?: string;
21
+ theme?: 'light' | 'dark' | 'auto';
22
+ modalSections?: string;
23
+ radius?: 'sharp' | 'soft' | 'round' | string;
24
+ dataUrl?: string;
25
+ showStats?: boolean;
26
+ lazy?: boolean;
27
+ hideBranding?: boolean;
28
+ locale?: string;
29
+ debug?: boolean;
30
+ /** Disables the default client-side WebP re-encoding of screenshots. */
31
+ noOptimize?: boolean;
32
+ /** GitHub token forwarded to the data endpoint via the Authorization header. */
33
+ token?: string;
34
+ /** Optional className for the wrapper div. */
35
+ className?: string;
36
+ /** Optional style for the wrapper div. */
37
+ style?: React.CSSProperties;
38
+ /** Called when the card data loads. */
39
+ onLoad?: (data: unknown) => void;
40
+ /** Called when the card errors. */
41
+ onError?: (error: unknown) => void;
42
+ /** Called when the modal opens. */
43
+ onModalOpen?: () => void;
44
+ /** Called when the modal closes. */
45
+ onModalClose?: () => void;
46
+ }
47
+ /**
48
+ * React wrapper for the <repo-deck> Custom Element.
49
+ *
50
+ * @example
51
+ * import { RepoDeck } from '@repodeckhz/react';
52
+ *
53
+ * <RepoDeck owner="your-name" repo="your-repo" preset="standard" showStats />
54
+ */
55
+ declare const RepoDeck: React.ForwardRefExoticComponent<Omit<RepoDeckProps, "ref"> & React.RefAttributes<HTMLElement>>;
56
+ interface RepoDeckListProps {
57
+ repos: string;
58
+ preset?: 'minimal' | 'standard' | 'detailed';
59
+ theme?: 'light' | 'dark' | 'auto';
60
+ radius?: 'sharp' | 'soft' | 'round' | string;
61
+ cols?: string;
62
+ gap?: string;
63
+ showStats?: boolean;
64
+ lazy?: boolean;
65
+ locale?: string;
66
+ sort?: 'none' | 'order' | 'stars' | 'name';
67
+ sortOrder?: 'asc' | 'desc';
68
+ filterTag?: string;
69
+ batchCheck?: boolean;
70
+ dataUrl?: string;
71
+ modalSections?: string;
72
+ configPath?: string;
73
+ /** Disables the default client-side WebP re-encoding of screenshots. */
74
+ noOptimize?: boolean;
75
+ /** GitHub token forwarded to each card's data endpoint (Authorization header). */
76
+ token?: string;
77
+ className?: string;
78
+ style?: React.CSSProperties;
79
+ }
80
+ /**
81
+ * React wrapper for the <repodeck-list> Custom Element.
82
+ *
83
+ * @example
84
+ * import { RepoDeckList } from '@repodeckhz/react';
85
+ *
86
+ * <RepoDeckList
87
+ * repos="your-name/project-a,your-name/project-b"
88
+ * showStats
89
+ * lazy
90
+ * sort="stars"
91
+ * sort-order="desc"
92
+ * />
93
+ */
94
+ declare const RepoDeckList: React.ForwardRefExoticComponent<RepoDeckListProps & React.RefAttributes<HTMLElement>>;
95
+
96
+ export { RepoDeck, RepoDeckList, type RepoDeckListProps, type RepoDeckProps, RepoDeck as default };
package/dist/index.js ADDED
@@ -0,0 +1,135 @@
1
+ import React, { useRef, useEffect } from 'react';
2
+ import '@repodeckhz/web/auto';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var RepoDeck = React.forwardRef(function RepoDeck2(props, forwardedRef) {
6
+ const {
7
+ owner,
8
+ repo,
9
+ branch,
10
+ ref: refAttr,
11
+ preset,
12
+ configPath,
13
+ theme,
14
+ modalSections,
15
+ radius,
16
+ dataUrl,
17
+ showStats,
18
+ lazy,
19
+ hideBranding,
20
+ locale,
21
+ debug,
22
+ noOptimize,
23
+ token,
24
+ className,
25
+ style,
26
+ onLoad,
27
+ onError,
28
+ onModalOpen,
29
+ onModalClose
30
+ } = props;
31
+ const internalRef = useRef(null);
32
+ useEffect(() => {
33
+ const el = internalRef.current;
34
+ if (!el) return;
35
+ if (typeof forwardedRef === "function") forwardedRef(el);
36
+ else if (forwardedRef) forwardedRef.current = el;
37
+ if (refAttr) el.setAttribute("ref", refAttr);
38
+ if (onLoad) {
39
+ const handler = (e) => onLoad(e.detail?.data);
40
+ el.addEventListener("repodeck:loaded", handler);
41
+ }
42
+ if (onError) {
43
+ const handler = (e) => onError(e.detail?.error);
44
+ el.addEventListener("repodeck:error", handler);
45
+ }
46
+ if (onModalOpen) {
47
+ el.addEventListener("repodeck:modal-open", onModalOpen);
48
+ }
49
+ if (onModalClose) {
50
+ el.addEventListener("repodeck:modal-close", onModalClose);
51
+ }
52
+ }, [forwardedRef, refAttr, onLoad, onError, onModalOpen, onModalClose]);
53
+ return /* @__PURE__ */ jsx("div", { className, style, children: /* @__PURE__ */ jsx(
54
+ "repo-deck",
55
+ {
56
+ ref: internalRef,
57
+ owner,
58
+ repo,
59
+ ...branch ? { branch } : {},
60
+ ...preset ? { preset } : {},
61
+ ...configPath ? { "config-path": configPath } : {},
62
+ ...theme ? { theme } : {},
63
+ ...modalSections ? { "modal-sections": modalSections } : {},
64
+ ...radius ? { radius } : {},
65
+ ...dataUrl ? { "data-url": dataUrl } : {},
66
+ ...showStats ? { "show-stats": "" } : {},
67
+ ...lazy ? { lazy: "" } : {},
68
+ ...hideBranding ? { "hide-branding": "" } : {},
69
+ ...locale ? { locale } : {},
70
+ ...debug ? { debug: "" } : {},
71
+ ...noOptimize ? { "no-optimize": "" } : {},
72
+ ...token ? { token } : {}
73
+ }
74
+ ) });
75
+ });
76
+ var RepoDeckList = React.forwardRef(function RepoDeckList2(props, forwardedRef) {
77
+ const {
78
+ repos,
79
+ preset,
80
+ theme,
81
+ radius,
82
+ cols,
83
+ gap,
84
+ showStats,
85
+ lazy,
86
+ locale,
87
+ sort,
88
+ sortOrder,
89
+ filterTag,
90
+ batchCheck,
91
+ dataUrl,
92
+ modalSections,
93
+ configPath,
94
+ noOptimize,
95
+ token,
96
+ className,
97
+ style
98
+ } = props;
99
+ const internalRef = useRef(null);
100
+ useEffect(() => {
101
+ const el = internalRef.current;
102
+ if (!el) return;
103
+ if (typeof forwardedRef === "function") forwardedRef(el);
104
+ else if (forwardedRef) forwardedRef.current = el;
105
+ }, [forwardedRef]);
106
+ return /* @__PURE__ */ jsx("div", { className, style, children: /* @__PURE__ */ jsx(
107
+ "repodeck-list",
108
+ {
109
+ ref: internalRef,
110
+ repos,
111
+ ...preset ? { preset } : {},
112
+ ...theme ? { theme } : {},
113
+ ...radius ? { radius } : {},
114
+ ...cols ? { cols } : {},
115
+ ...gap ? { gap } : {},
116
+ ...showStats ? { "show-stats": "" } : {},
117
+ ...lazy ? { lazy: "" } : {},
118
+ ...locale ? { locale } : {},
119
+ ...sort ? { sort } : {},
120
+ ...sortOrder ? { "sort-order": sortOrder } : {},
121
+ ...filterTag ? { "filter-tag": filterTag } : {},
122
+ ...batchCheck ? { "batch-check": "" } : {},
123
+ ...dataUrl ? { "data-url": dataUrl } : {},
124
+ ...modalSections ? { "modal-sections": modalSections } : {},
125
+ ...configPath ? { "config-path": configPath } : {},
126
+ ...noOptimize ? { "no-optimize": "" } : {},
127
+ ...token ? { token } : {}
128
+ }
129
+ ) });
130
+ });
131
+ var index_default = RepoDeck;
132
+
133
+ export { RepoDeck, RepoDeckList, index_default as default };
134
+ //# sourceMappingURL=index.js.map
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["RepoDeck","RepoDe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AC;AAAA,MAC3B,GAAI,KAAA,GAAQ,EAAE,KAAA,KAAU,EAAC;AAAA,MACzB,GAAI,MAAA,GAAS,EAAE,MAAA,KAAW,EAAC;AAAA,MAC3B,GAAI,IAAA,GAAO,EAAE,IAAA,KAAS,EAAC;AAAA,MACvB,GAAI,GAAA,GAAM,EAAE,GAAA,KAAQ,EAAC;AAAA,MACrB,GAAI,SAAA,GAAY,EAAE,YAAA,EAAc,EAAA,KAAO,EAAC;AAAA,MACxC,GAAI,IAAA,GAAO,EAAE,IAAA,EAAM,EAAA,KAAO,EAAC;AAAA,MAC3B,GAAI,MAAA,GAAS,EAAE,MAAA,KAAW,EAAC;AAAA,MAC3B,GAAI,IAAA,GAAO,EAAE,IAAA,KAAS,EAAC;AAAA,MACvB,GAAI,SAAA,GAAY,EAAE,YAAA,EAAc,SAAA,KAAc,EAAC;AAAA,MAC/C,GAAI,SAAA,GAAY,EAAE,YAAA,EAAc,SAAA,KAAc,EAAC;AAAA,MAC/C,GAAI,UAAA,GAAa,EAAE,aAAA,EAAe,EAAA,KAAO,EAAC;AAAA,MAC1C,GAAI,OAAA,GAAU,EAAE,UAAA,EAAY,OAAA,KAAY,EAAC;AAAA,MACzC,GAAI,aAAA,GAAgB,EAAE,gBAAA,EAAkB,aAAA,KAAkB,EAAC;AAAA,MAC3D,GAAI,UAAA,GAAa,EAAE,aAAA,EAAe,UAAA,KAAe,EAAC;AAAA,MAClD,GAAI,UAAA,GAAa,EAAE,aAAA,EAAe,EAAA,KAAO,EAAC;AAAA,MAC1C,GAAI,KAAA,GAAQ,EAAE,KAAA,KAAU;AAAC;AAAA,GAC5B,EACF,CAAA;AAEJ,CAAC;AAED,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["/**\r\n * @repodeckhz/react — thin React wrapper around the <repo-deck> web component.\r\n *\r\n * Plan §2: \"wrapper fino em cima do web component, opcional/futuro\".\r\n * This gives React users a familiar <RepoDeck /> component instead of\r\n * dealing with custom-element refs directly.\r\n *\r\n * The web component auto-registers on import — this wrapper just provides\r\n * typed props.\r\n */\r\n\r\n'use client';\r\n\r\nimport React, { useEffect, useRef } from 'react';\r\nimport '@repodeckhz/web/auto';\r\n\r\nexport interface RepoDeckProps {\r\n owner: string;\r\n repo: string;\r\n branch?: string;\r\n ref?: string;\r\n preset?: 'minimal' | 'standard' | 'detailed';\r\n configPath?: string;\r\n theme?: 'light' | 'dark' | 'auto';\r\n modalSections?: string;\r\n radius?: 'sharp' | 'soft' | 'round' | string;\r\n dataUrl?: string;\r\n showStats?: boolean;\r\n lazy?: boolean;\r\n hideBranding?: boolean;\r\n locale?: string;\r\n debug?: boolean;\r\n /** Disables the default client-side WebP re-encoding of screenshots. */\r\n noOptimize?: boolean;\r\n /** GitHub token forwarded to the data endpoint via the Authorization header. */\r\n token?: string;\r\n /** Optional className for the wrapper div. */\r\n className?: string;\r\n /** Optional style for the wrapper div. */\r\n style?: React.CSSProperties;\r\n /** Called when the card data loads. */\r\n onLoad?: (data: unknown) => void;\r\n /** Called when the card errors. */\r\n onError?: (error: unknown) => void;\r\n /** Called when the modal opens. */\r\n onModalOpen?: () => void;\r\n /** Called when the modal closes. */\r\n onModalClose?: () => void;\r\n}\r\n\r\n/**\r\n * React wrapper for the <repo-deck> Custom Element.\r\n *\r\n * @example\r\n * import { RepoDeck } from '@repodeckhz/react';\r\n *\r\n * <RepoDeck owner=\"your-name\" repo=\"your-repo\" preset=\"standard\" showStats />\r\n */\r\nexport const RepoDeck = React.forwardRef<HTMLElement, RepoDeckProps>(function RepoDeck(\r\n props,\r\n forwardedRef,\r\n) {\r\n const {\r\n owner,\r\n repo,\r\n branch,\r\n ref: refAttr,\r\n preset,\r\n configPath,\r\n theme,\r\n modalSections,\r\n radius,\r\n dataUrl,\r\n showStats,\r\n lazy,\r\n hideBranding,\r\n locale,\r\n debug,\r\n noOptimize,\r\n token,\r\n className,\r\n style,\r\n onLoad,\r\n onError,\r\n onModalOpen,\r\n onModalClose,\r\n } = props as RepoDeckProps & { ref?: string };\r\n\r\n const internalRef = useRef<HTMLElement>(null);\r\n\r\n useEffect(() => {\r\n const el = internalRef.current;\r\n if (!el) return;\r\n\r\n // Set the forwarded ref.\r\n if (typeof forwardedRef === 'function') forwardedRef(el);\r\n else if (forwardedRef) (forwardedRef as React.MutableRefObject<HTMLElement | null>).current = el;\r\n\r\n // The `ref` prop (tag/commit pin, plan §16.7) conflicts with React's `ref`\r\n // for element refs — set it as an attribute imperatively.\r\n if (refAttr) el.setAttribute('ref', refAttr);\r\n\r\n // Wire event listeners.\r\n if (onLoad) {\r\n const handler = (e: Event) => onLoad((e as CustomEvent).detail?.data);\r\n el.addEventListener('repodeck:loaded', handler as EventListener);\r\n }\r\n if (onError) {\r\n const handler = (e: Event) => onError((e as CustomEvent).detail?.error);\r\n el.addEventListener('repodeck:error', handler as EventListener);\r\n }\r\n if (onModalOpen) {\r\n el.addEventListener('repodeck:modal-open', onModalOpen as EventListener);\r\n }\r\n if (onModalClose) {\r\n el.addEventListener('repodeck:modal-close', onModalClose as EventListener);\r\n }\r\n }, [forwardedRef, refAttr, onLoad, onError, onModalOpen, onModalClose]);\r\n\r\n return (\r\n <div className={className} style={style}>\r\n <repo-deck\r\n ref={internalRef}\r\n owner={owner}\r\n repo={repo}\r\n {...(branch ? { branch } : {})}\r\n {...(preset ? { preset } : {})}\r\n {...(configPath ? { 'config-path': configPath } : {})}\r\n {...(theme ? { theme } : {})}\r\n {...(modalSections ? { 'modal-sections': modalSections } : {})}\r\n {...(radius ? { radius } : {})}\r\n {...(dataUrl ? { 'data-url': dataUrl } : {})}\r\n {...(showStats ? { 'show-stats': '' } : {})}\r\n {...(lazy ? { lazy: '' } : {})}\r\n {...(hideBranding ? { 'hide-branding': '' } : {})}\r\n {...(locale ? { locale } : {})}\r\n {...(debug ? { debug: '' } : {})}\r\n {...(noOptimize ? { 'no-optimize': '' } : {})}\r\n {...(token ? { token } : {})}\r\n />\r\n </div>\r\n );\r\n});\r\n\r\nexport interface RepoDeckListProps {\r\n repos: string;\r\n preset?: 'minimal' | 'standard' | 'detailed';\r\n theme?: 'light' | 'dark' | 'auto';\r\n radius?: 'sharp' | 'soft' | 'round' | string;\r\n cols?: string;\r\n gap?: string;\r\n showStats?: boolean;\r\n lazy?: boolean;\r\n locale?: string;\r\n sort?: 'none' | 'order' | 'stars' | 'name';\r\n sortOrder?: 'asc' | 'desc';\r\n filterTag?: string;\r\n batchCheck?: boolean;\r\n dataUrl?: string;\r\n modalSections?: string;\r\n configPath?: string;\r\n /** Disables the default client-side WebP re-encoding of screenshots. */\r\n noOptimize?: boolean;\r\n /** GitHub token forwarded to each card's data endpoint (Authorization header). */\r\n token?: string;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n}\r\n\r\n/**\r\n * React wrapper for the <repodeck-list> Custom Element.\r\n *\r\n * @example\r\n * import { RepoDeckList } from '@repodeckhz/react';\r\n *\r\n * <RepoDeckList\r\n * repos=\"your-name/project-a,your-name/project-b\"\r\n * showStats\r\n * lazy\r\n * sort=\"stars\"\r\n * sort-order=\"desc\"\r\n * />\r\n */\r\nexport const RepoDeckList = React.forwardRef<HTMLElement, RepoDeckListProps>(function RepoDeckList(\r\n props,\r\n forwardedRef,\r\n) {\r\n const {\r\n repos,\r\n preset,\r\n theme,\r\n radius,\r\n cols,\r\n gap,\r\n showStats,\r\n lazy,\r\n locale,\r\n sort,\r\n sortOrder,\r\n filterTag,\r\n batchCheck,\r\n dataUrl,\r\n modalSections,\r\n configPath,\r\n noOptimize,\r\n token,\r\n className,\r\n style,\r\n } = props;\r\n\r\n const internalRef = useRef<HTMLElement>(null);\r\n\r\n useEffect(() => {\r\n const el = internalRef.current;\r\n if (!el) return;\r\n if (typeof forwardedRef === 'function') forwardedRef(el);\r\n else if (forwardedRef) (forwardedRef as React.MutableRefObject<HTMLElement | null>).current = el;\r\n }, [forwardedRef]);\r\n\r\n return (\r\n <div className={className} style={style}>\r\n <repodeck-list\r\n ref={internalRef}\r\n repos={repos}\r\n {...(preset ? { preset } : {})}\r\n {...(theme ? { theme } : {})}\r\n {...(radius ? { radius } : {})}\r\n {...(cols ? { cols } : {})}\r\n {...(gap ? { gap } : {})}\r\n {...(showStats ? { 'show-stats': '' } : {})}\r\n {...(lazy ? { lazy: '' } : {})}\r\n {...(locale ? { locale } : {})}\r\n {...(sort ? { sort } : {})}\r\n {...(sortOrder ? { 'sort-order': sortOrder } : {})}\r\n {...(filterTag ? { 'filter-tag': filterTag } : {})}\r\n {...(batchCheck ? { 'batch-check': '' } : {})}\r\n {...(dataUrl ? { 'data-url': dataUrl } : {})}\r\n {...(modalSections ? { 'modal-sections': modalSections } : {})}\r\n {...(configPath ? { 'config-path': configPath } : {})}\r\n {...(noOptimize ? { 'no-optimize': '' } : {})}\r\n {...(token ? { token } : {})}\r\n />\r\n </div>\r\n );\r\n});\r\n\r\nexport default RepoDeck;\r\n"]}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@repodeckhz/react",
3
+ "version": "0.6.0",
4
+ "description": "Thin React wrapper around the repodeck web component. Gives React users a familiar <RepoDeck /> component.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "repodeckhz",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/leibHz/repodeck.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/leibHz/repodeck/issues"
14
+ },
15
+ "keywords": [
16
+ "repodeckhz",
17
+ "react",
18
+ "github",
19
+ "card",
20
+ "embed",
21
+ "portfolio"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "main": "./dist/index.cjs",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "files": [
34
+ "dist",
35
+ "README.md"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch",
40
+ "clean": "rm -rf dist",
41
+ "prepublishOnly": "bun run build"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=18",
48
+ "react-dom": ">=18"
49
+ },
50
+ "dependencies": {
51
+ "@repodeckhz/web": "^0.6.0"
52
+ },
53
+ "tsup": {
54
+ "entry": ["src/index.tsx"],
55
+ "format": ["esm", "cjs"],
56
+ "dts": true,
57
+ "splitting": false,
58
+ "sourcemap": true,
59
+ "clean": true,
60
+ "treeshake": true,
61
+ "external": ["react", "react-dom", "@repodeckhz/web", "@repodeckhz/web/*"]
62
+ }
63
+ }