booary 4.0.0 → 5.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/cli.js +68 -1
- package/dist/index.css +1 -0
- package/dist/index.global.js +2 -0
- package/package.json +9 -38
- package/README.md +0 -75
- package/dist/cli.cjs +0 -2
- package/dist/cli.d.cts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/index.cjs +0 -3
- package/dist/index.d.cts +0 -9
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -3
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,69 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// scripts/add-book.ts
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
import axios from "axios";
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import path from "path";
|
|
8
|
+
var DIR_PATH = path.join(process.cwd(), "public/library");
|
|
9
|
+
var FILE_PATH = path.join(process.cwd(), "public/library/card.json");
|
|
10
|
+
async function runCli() {
|
|
11
|
+
var _a;
|
|
12
|
+
await fs.ensureDir(DIR_PATH);
|
|
13
|
+
if (!fs.existsSync(FILE_PATH)) {
|
|
14
|
+
const profile = await inquirer.prompt([
|
|
15
|
+
{
|
|
16
|
+
type: "input",
|
|
17
|
+
name: "borrower",
|
|
18
|
+
message: "Enter borrower name"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "input",
|
|
22
|
+
name: "libName",
|
|
23
|
+
message: "Enter library name",
|
|
24
|
+
default: "Boo Library"
|
|
25
|
+
}
|
|
26
|
+
]);
|
|
27
|
+
const initialData = {
|
|
28
|
+
borrower: profile.borrower,
|
|
29
|
+
library: { name: profile.libName, signature: "\u{1F43E}" },
|
|
30
|
+
books: []
|
|
31
|
+
};
|
|
32
|
+
await fs.writeJson(FILE_PATH, initialData, { spaces: 2 });
|
|
33
|
+
console.log("\u2728 Library card created!");
|
|
34
|
+
}
|
|
35
|
+
const { query } = await inquirer.prompt([
|
|
36
|
+
{ type: "input", name: "query", message: "Search for a book:" }
|
|
37
|
+
]);
|
|
38
|
+
const { data } = await axios.get(
|
|
39
|
+
`https://openlibrary.org/search.json?q=${encodeURIComponent(query)}`
|
|
40
|
+
);
|
|
41
|
+
if (!((_a = data.docs) == null ? void 0 : _a.length)) {
|
|
42
|
+
console.log("No books found.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { selectedBook } = await inquirer.prompt([
|
|
46
|
+
{
|
|
47
|
+
type: "select",
|
|
48
|
+
name: "selectedBook",
|
|
49
|
+
message: "Select a book:",
|
|
50
|
+
choices: data.docs.map((book) => {
|
|
51
|
+
var _a2, _b;
|
|
52
|
+
return {
|
|
53
|
+
name: `${book.title} (${((_a2 = book.author_name) == null ? void 0 : _a2[0]) || "Unknown"})`,
|
|
54
|
+
value: {
|
|
55
|
+
key: book.key,
|
|
56
|
+
name: book.title,
|
|
57
|
+
author: ((_b = book.author_name) == null ? void 0 : _b[0]) || "Unknown",
|
|
58
|
+
finishedDate: (/* @__PURE__ */ new Date()).toLocaleDateString("en-IN")
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
64
|
+
const cardData = await fs.readJson(FILE_PATH);
|
|
65
|
+
cardData.books.push(selectedBook);
|
|
66
|
+
await fs.writeJson(FILE_PATH, cardData, { spaces: 2 });
|
|
67
|
+
console.log(`Added ${selectedBook.name}`);
|
|
68
|
+
}
|
|
69
|
+
runCli();
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:16px;display:flex;top:-4px}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(exports){'use strict';var U,d,fe,H,se,pe,de,he,Z,J,K,F={},me=[],We=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$=Array.isArray;function C(e,t){for(var n in t)e[n]=t[n];return e}function X(e){e&&e.parentNode&&e.parentNode.removeChild(e);}function P(e,t,n){var o,_,r,i={};for(r in t)r=="key"?o=t[r]:r=="ref"?_=t[r]:i[r]=t[r];if(arguments.length>2&&(i.children=arguments.length>3?U.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)i[r]===void 0&&(i[r]=e.defaultProps[r]);return j(e,i,o,_,null)}function j(e,t,n,o,_){var r={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:_??++fe,__i:-1,__u:0};return _==null&&d.vnode!=null&&d.vnode(r),r}function S(e){return e.children}function V(e,t){this.props=e,this.context=t;}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?T(e):null}function ve(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return ve(e)}}function le(e){(!e.__d&&(e.__d=true)&&H.push(e)&&!W.__r++||se!=d.debounceRendering)&&((se=d.debounceRendering)||pe)(W);}function W(){for(var e,t,n,o,_,r,i,l=1;H.length;)H.length>l&&H.sort(de),e=H.shift(),l=H.length,e.__d&&(n=void 0,o=void 0,_=(o=(t=e).__v).__e,r=[],i=[],t.__P&&((n=C({},o)).__v=o.__v+1,d.vnode&&d.vnode(n),Y(t.__P,n,o,t.__n,t.__P.namespaceURI,32&o.__u?[_]:null,r,_??T(o),!!(32&o.__u),i),n.__v=o.__v,n.__.__k[n.__i]=n,be(r,n,i),o.__e=o.__=null,n.__e!=_&&ve(n)));W.__r=0;}function ye(e,t,n,o,_,r,i,l,u,s,c){var a,p,f,b,x,k,m,h=o&&o.__k||me,N=t.length;for(u=$e(n,t,h,u,N),a=0;a<N;a++)(f=n.__k[a])!=null&&(p=f.__i==-1?F:h[f.__i]||F,f.__i=a,k=Y(e,f,p,_,r,i,l,u,s,c),b=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&ee(p.ref,null,f),c.push(f.ref,f.__c||b,f)),x==null&&b!=null&&(x=b),(m=!!(4&f.__u))||p.__k===f.__k?u=ge(f,u,e,m):typeof f.type=="function"&&k!==void 0?u=k:b&&(u=b.nextSibling),f.__u&=-7);return n.__e=x,u}function $e(e,t,n,o,_){var r,i,l,u,s,c=n.length,a=c,p=0;for(e.__k=new Array(_),r=0;r<_;r++)(i=t[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=e.__k[r]=j(null,i,null,null,null):$(i)?i=e.__k[r]=j(S,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=e.__k[r]=j(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):e.__k[r]=i,u=r+p,i.__=e,i.__b=e.__b+1,l=null,(s=i.__i=Be(i,n,u,a))!=-1&&(a--,(l=n[s])&&(l.__u|=2)),l==null||l.__v==null?(s==-1&&(_>c?p--:_<c&&p++),typeof i.type!="function"&&(i.__u|=4)):s!=u&&(s==u-1?p--:s==u+1?p++:(s>u?p--:p++,i.__u|=4))):e.__k[r]=null;if(a)for(r=0;r<c;r++)(l=n[r])!=null&&(2&l.__u)==0&&(l.__e==o&&(o=T(l)),xe(l,l));return o}function ge(e,t,n,o){var _,r;if(typeof e.type=="function"){for(_=e.__k,r=0;_&&r<_.length;r++)_[r]&&(_[r].__=e,t=ge(_[r],t,n,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Be(e,t,n,o){var _,r,i,l=e.key,u=e.type,s=t[n],c=s!=null&&(2&s.__u)==0;if(s===null&&l==null||c&&l==s.key&&u==s.type)return n;if(o>(c?1:0)){for(_=n-1,r=n+1;_>=0||r<t.length;)if((s=t[i=_>=0?_--:r++])!=null&&(2&s.__u)==0&&l==s.key&&u==s.type)return i}return -1}function ue(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||We.test(t)?n:n+"px";}function R(e,t,n,o,_){var r,i;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else {if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||ue(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||ue(e.style,t,n[t]);}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(he,"$1")),i=t.toLowerCase(),t=i in e||t=="onFocusOut"||t=="onFocusIn"?i.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?o?n.u=o.u:(n.u=Z,e.addEventListener(t,r?K:J,r)):e.removeEventListener(t,r?K:J,r);else {if(_=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===false&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n));}}function ce(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Z++;else if(t.t<n.u)return;return n(d.event?d.event(t):t)}}}function Y(e,t,n,o,_,r,i,l,u,s){var c,a,p,f,b,x,k,m,h,N,E,O,A,ae,z,L,G,w=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),r=[l=t.__e=n.__e]),(c=d.__b)&&c(t);e:if(typeof w=="function")try{if(m=t.props,h="prototype"in w&&w.prototype.render,N=(c=w.contextType)&&o[c.__c],E=c?N?N.props.value:c.__:o,n.__c?k=(a=t.__c=n.__c).__=a.__E:(h?t.__c=a=new w(m,E):(t.__c=a=new V(m,E),a.constructor=w,a.render=qe),N&&N.sub(a),a.state||(a.state={}),a.__n=o,p=a.__d=!0,a.__h=[],a._sb=[]),h&&a.__s==null&&(a.__s=a.state),h&&w.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=C({},a.__s)),C(a.__s,w.getDerivedStateFromProps(m,a.__s))),f=a.props,b=a.state,a.__v=t,p)h&&w.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),h&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else {if(h&&w.getDerivedStateFromProps==null&&m!==f&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(m,E),t.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(m,a.__s,E)===!1){for(t.__v!=n.__v&&(a.props=m,a.state=a.__s,a.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(D){D&&(D.__=t);}),O=0;O<a._sb.length;O++)a.__h.push(a._sb[O]);a._sb=[],a.__h.length&&i.push(a);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(m,a.__s,E),h&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(f,b,x);});}if(a.context=E,a.props=m,a.__P=e,a.__e=!1,A=d.__r,ae=0,h){for(a.state=a.__s,a.__d=!1,A&&A(t),c=a.render(a.props,a.state,a.context),z=0;z<a._sb.length;z++)a.__h.push(a._sb[z]);a._sb=[];}else do a.__d=!1,A&&A(t),c=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++ae<25);a.state=a.__s,a.getChildContext!=null&&(o=C(C({},o),a.getChildContext())),h&&!p&&a.getSnapshotBeforeUpdate!=null&&(x=a.getSnapshotBeforeUpdate(f,b)),L=c,c!=null&&c.type===S&&c.key==null&&(L=ke(c.props.children)),l=ye(e,$(L)?L:[L],t,n,o,_,r,i,l,u,s),a.base=t.__e,t.__u&=-161,a.__h.length&&i.push(a),k&&(a.__E=a.__=null);}catch(D){if(t.__v=null,u||r!=null)if(D.then){for(t.__u|=u?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,t.__e=l;}else {for(G=r.length;G--;)X(r[G]);Q(t);}else t.__e=n.__e,t.__k=n.__k,D.then||Q(t);d.__e(D,t,n);}else r==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):l=t.__e=Ie(n.__e,t,n,o,_,r,i,u,s);return (c=d.diffed)&&c(t),128&t.__u?void 0:l}function Q(e){e&&e.__c&&(e.__c.__e=true),e&&e.__k&&e.__k.forEach(Q);}function be(e,t,n){for(var o=0;o<n.length;o++)ee(n[o],n[++o],n[++o]);d.__c&&d.__c(t,e),e.some(function(_){try{e=_.__h,_.__h=[],e.some(function(r){r.call(_);});}catch(r){d.__e(r,_.__v);}});}function ke(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:$(e)?e.map(ke):C({},e)}function Ie(e,t,n,o,_,r,i,l,u){var s,c,a,p,f,b,x,k=n.props||F,m=t.props,h=t.type;if(h=="svg"?_="http://www.w3.org/2000/svg":h=="math"?_="http://www.w3.org/1998/Math/MathML":_||(_="http://www.w3.org/1999/xhtml"),r!=null){for(s=0;s<r.length;s++)if((f=r[s])&&"setAttribute"in f==!!h&&(h?f.localName==h:f.nodeType==3)){e=f,r[s]=null;break}}if(e==null){if(h==null)return document.createTextNode(m);e=document.createElementNS(_,h,m.is&&m),l&&(d.__m&&d.__m(t,r),l=false),r=null;}if(h==null)k===m||l&&e.data==m||(e.data=m);else {if(r=r&&U.call(e.childNodes),!l&&r!=null)for(k={},s=0;s<e.attributes.length;s++)k[(f=e.attributes[s]).name]=f.value;for(s in k)if(f=k[s],s!="children"){if(s=="dangerouslySetInnerHTML")a=f;else if(!(s in m)){if(s=="value"&&"defaultValue"in m||s=="checked"&&"defaultChecked"in m)continue;R(e,s,null,f,_);}}for(s in m)f=m[s],s=="children"?p=f:s=="dangerouslySetInnerHTML"?c=f:s=="value"?b=f:s=="checked"?x=f:l&&typeof f!="function"||k[s]===f||R(e,s,f,k[s],_);if(c)l||a&&(c.__html==a.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(a&&(e.innerHTML=""),ye(t.type=="template"?e.content:e,$(p)?p:[p],t,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":_,r,i,r?r[0]:n.__k&&T(n,0),l,u),r!=null)for(s=r.length;s--;)X(r[s]);l||(s="value",h=="progress"&&b==null?e.removeAttribute("value"):b!=null&&(b!==e[s]||h=="progress"&&!b||h=="option"&&b!=k[s])&&R(e,s,b,k[s],_),s="checked",x!=null&&x!=e[s]&&R(e,s,x,k[s],_));}return e}function ee(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t));}else e.current=t;}catch(_){d.__e(_,n);}}function xe(e,t,n){var o,_;if(d.unmount&&d.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||ee(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount();}catch(r){d.__e(r,t);}o.base=o.__P=null;}if(o=e.__k)for(_=0;_<o.length;_++)o[_]&&xe(o[_],t,n||typeof e.type!="function");n||X(e.__e),e.__c=e.__=e.__e=void 0;}function qe(e,t,n){return this.constructor(e,n)}function M(e,t,n){var o,_,r,i;t==document&&(t=document.documentElement),d.__&&d.__(e,t),_=(o=typeof n=="function")?null:n&&n.__k||t.__k,r=[],i=[],Y(t,e=(!o&&n||t).__k=P(S,null,[e]),_||F,F,t.namespaceURI,!o&&n?[n]:_?null:t.firstChild?U.call(t.childNodes):null,r,!o&&n?n:_?_.__e:t.firstChild,o,i),be(r,e,i);}function te(e,t){M(e,t,te);}function ne(e,t,n){var o,_,r,i,l=C({},e.props);for(r in e.type&&e.type.defaultProps&&(i=e.type.defaultProps),t)r=="key"?o=t[r]:r=="ref"?_=t[r]:l[r]=t[r]===void 0&&i!=null?i[r]:t[r];return arguments.length>2&&(l.children=arguments.length>3?U.call(arguments,2):n),j(e.type,l,o||e.key,_||e.ref,null)}U=me.slice,d={__e:function(e,t,n,o){for(var _,r,i;t=t.__;)if((_=t.__c)&&!_.__)try{if((r=_.constructor)&&r.getDerivedStateFromError!=null&&(_.setState(r.getDerivedStateFromError(e)),i=_.__d),_.componentDidCatch!=null&&(_.componentDidCatch(e,o||{}),i=_.__d),i)return _.__E=_}catch(l){e=l;}throw e}},fe=0,V.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=C({},this.state),typeof e=="function"&&(e=e(C({},n),this.props)),e&&C(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),le(this));},V.prototype.forceUpdate=function(e){this.__v&&(this.__e=true,e&&this.__h.push(e),le(this));},V.prototype.render=S,H=[],pe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,de=function(e,t){return e.__v.__b-t.__v.__b},W.__r=0,he=/(PointerCapture)$|Capture$/i,Z=0,J=ce(false),K=ce(true);var I,y,re,we,oe=0,Te=[],g=d,Ce=g.__b,Ne=g.__r,Se=g.diffed,Ee=g.__c,He=g.unmount,Pe=g.__;function Ae(e,t){g.__h&&g.__h(y,e,oe||t),oe=0;var n=y.__H||(y.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ie(e){return oe=1,Ge(je,e)}function Ge(e,t,n){var o=Ae(I++,2);if(o.t=e,!o.__c&&(o.__=[je(void 0,t),function(l){var u=o.__N?o.__N[0]:o.__[0],s=o.t(u,l);u!==s&&(o.__N=[s,o.__[1]],o.__c.setState({}));}],o.__c=y,!y.__f)){var _=function(l,u,s){if(!o.__c.__H)return true;var c=o.__c.__H.__.filter(function(p){return !!p.__c});if(c.every(function(p){return !p.__N}))return !r||r.call(this,l,u,s);var a=o.__c.props!==l;return c.forEach(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(a=true);}}),r&&r.call(this,l,u,s)||a};y.__f=true;var r=y.shouldComponentUpdate,i=y.componentWillUpdate;y.componentWillUpdate=function(l,u,s){if(this.__e){var c=r;r=void 0,_(l,u,s),r=c;}i&&i.call(this,l,u,s);},y.shouldComponentUpdate=_;}return o.__N||o.__}function Le(e,t){var n=Ae(I++,3);!g.__s&&Qe(n.__H,t)&&(n.__=e,n.u=t,y.__H.__h.push(n));}function Je(){for(var e;e=Te.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(B),e.__H.__h.forEach(_e),e.__H.__h=[];}catch(t){e.__H.__h=[],g.__e(t,e.__v);}}g.__b=function(e){y=null,Ce&&Ce(e);},g.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pe&&Pe(e,t);},g.__r=function(e){Ne&&Ne(e),I=0;var t=(y=e.__c).__H;t&&(re===y?(t.__h=[],y.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0;})):(t.__h.forEach(B),t.__h.forEach(_e),t.__h=[],I=0)),re=y;},g.diffed=function(e){Se&&Se(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Te.push(t)!==1&&we===g.requestAnimationFrame||((we=g.requestAnimationFrame)||Ke)(Je)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0;})),re=y=null;},g.__c=function(e,t){t.some(function(n){try{n.__h.forEach(B),n.__h=n.__h.filter(function(o){return !o.__||_e(o)});}catch(o){t.some(function(_){_.__h&&(_.__h=[]);}),t=[],g.__e(o,n.__v);}}),Ee&&Ee(e,t);},g.unmount=function(e){He&&He(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{B(o);}catch(_){t=_;}}),n.__H=void 0,t&&g.__e(t,n.__v));};var De=typeof requestAnimationFrame=="function";function Ke(e){var t,n=function(){clearTimeout(o),De&&cancelAnimationFrame(t),setTimeout(e);},o=setTimeout(n,35);De&&(t=requestAnimationFrame(n));}function B(e){var t=y,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),y=t;}function _e(e){var t=y;e.__c=e.__(),y=t;}function Qe(e,t){return !e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function je(e,t){return typeof t=="function"?t(e):t}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);}return e},q.apply(this,arguments)}function Ue(e,t){if(e==null)return {};var n,o,_={},r=Object.keys(e);for(o=0;o<r.length;o++)t.indexOf(n=r[o])>=0||(_[n]=e[n]);return _}var Ze=["context","children"],Xe=["useFragment"];function Me(e,t,n,o){function _(){var r,i=Reflect.construct(HTMLElement,[],_);return i._vdomComponent=e,o&&o.shadow?(i._root=i.attachShadow({mode:o.mode||"open",serializable:(r=o.serializable)!=null&&r}),o.adoptedStyleSheets&&(i._root.adoptedStyleSheets=o.adoptedStyleSheets)):i._root=i,i}return (_.prototype=Object.create(HTMLElement.prototype)).constructor=_,_.prototype.connectedCallback=function(){et.call(this,o);},_.prototype.attributeChangedCallback=tt,_.prototype.disconnectedCallback=nt,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),_.observedAttributes=n,e.formAssociated&&(_.formAssociated=true),n.forEach(function(r){Object.defineProperty(_.prototype,r,{get:function(){return this._vdom?this._vdom.props[r]:this._props[r]},set:function(i){this._vdom?this.attributeChangedCallback(r,null,i):(this._props||(this._props={}),this._props[r]=i);var l=typeof i;i!=null&&l!=="string"&&l!=="boolean"&&l!=="number"||this.setAttribute(r,i);}});}),customElements.define(t,_),_}function Ye(e){this.getChildContext=function(){return e.context};var t=e.children,n=Ue(e,Ze);return ne(t,n)}function et(e){var t=new CustomEvent("_preact",{detail:{},bubbles:true,cancelable:true});this.dispatchEvent(t),this._vdom=P(Ye,q({},this._props,{context:t.detail.context}),ze(this,this._vdomComponent,e)),(this.hasAttribute("hydrate")?te:M)(this._vdom,this._root);}function Oe(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function tt(e,t,n){if(this._vdom){var o={};o[e]=n=n??void 0,o[Oe(e)]=n,this._vdom=ne(this._vdom,o),M(this._vdom,this._root);}}function nt(){M(this._vdom=null,this._root);}function Fe(e,t){var n=this,o=e.useFragment,_=Ue(e,Xe);return P(o?S:"slot",q({},_,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(i){i.stopPropagation(),i.detail.context=t;},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener);}}))}function ze(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var o=[],_={},r=0,i=e.attributes,l=e.childNodes;for(r=i.length;r--;)i[r].name!=="slot"&&(_[i[r].name]=i[r].value,_[Oe(i[r].name)]=i[r].value);for(r=l.length;r--;){var u=ze(l[r],null,n),s=l[r].slot;s?_[s]=P(Fe,{name:s},u):o[r]=u;}var c=!(!n||!n.shadow),a=t?P(Fe,{useFragment:!c},o):o;return !c&&t&&(e.innerHTML=""),P(t||e.nodeName.toLowerCase(),_,a)}var rt=0;function v(e,t,n,o,_,r){t||(t={});var i,l,u=t;if("ref"in u)for(l in u={},t)l=="ref"?i=t[l]:u[l]=t[l];var s={type:e,props:u,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rt,__i:-1,__u:0,__source:_,__self:r};if(typeof e=="function"&&(i=e.defaultProps))for(l in i)u[l]===void 0&&(u[l]=i[l]);return d.vnode&&d.vnode(s),s}var ot=({cardlink:e,friends:t=[]})=>{let[n,o]=ie(null),[_,r]=ie([]);return Le(()=>{let i=typeof t=="string"?JSON.parse(t):t;fetch(e).then(l=>l.json()).then(o),Array.isArray(i)&&i.length>0&&Promise.all(i.map(l=>fetch(l).then(u=>u.json()).then(u=>({...u,url:l})))).then(r);},[e,t]),n?v("div",{className:"card",children:v("div",{className:"inner",children:[v("div",{className:"header",children:[v("span",{className:"year",children:"20"}),v("span",{className:"year",children:"26"})]}),v("div",{className:"header",children:v("h2",{className:"libraryTitle",children:n.library.name})}),v("div",{className:"fieldGroup",children:[v("p",{className:"fieldValue nameValue",children:n.borrower}),v("label",{className:"label",children:"Borrower's Name"})]}),v("div",{className:"fieldGroup",children:[v("p",{className:"fieldValue signatureValue",children:n.library.signature}),v("label",{className:"label",children:"Librarian's Signature"})]}),v("div",{className:"bookSection",children:v("ul",{className:"bookList",children:n.books.map((i,l)=>{console.log("friendsData",_,n);let u=_.filter(s=>s.books.some(c=>c.key===i.key));return console.log("readersOfThisBook",u),v("li",{className:"bookRow",children:[v("span",{className:"bookName",children:[i.name," by ",i.author]}),v("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[v("span",{className:"bookDate",children:i.finishedDate}),v("div",{className:"friendSignatures",children:u.length>0&&v("div",{className:"friendSignatures",children:u.map((s,c)=>v("a",{href:s.url?new URL(s.url).origin:"#",className:"signatureLink",title:`${s.borrower} also read this`,target:"_blank",rel:"noopener noreferrer",children:s.library.signature},c))})})]})]},l)})})})]})}):v("div",{className:"loading",children:"Loading library card..."})};Me(ot,"x-library-card",["cardlink","friends"],{shadow:false});
|
|
2
|
+
exports.LibraryCard=ot;return exports;})({});
|
package/package.json
CHANGED
|
@@ -1,59 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "booary",
|
|
3
|
-
"
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "5.1.0",
|
|
4
5
|
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"booary": "./dist/cli.js"
|
|
10
|
-
},
|
|
11
6
|
"files": [
|
|
12
7
|
"dist"
|
|
13
8
|
],
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js",
|
|
18
|
-
"require": "./dist/index.cjs"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"peerDependencies": {
|
|
22
|
-
"react": ">=18",
|
|
23
|
-
"react-dom": ">=18"
|
|
24
|
-
},
|
|
25
9
|
"dependencies": {
|
|
26
|
-
"@
|
|
10
|
+
"@types/fs-extra": "^11.0.4",
|
|
27
11
|
"axios": "^1.13.5",
|
|
28
12
|
"fs-extra": "^11.3.3",
|
|
29
|
-
"inquirer": "^13.2.
|
|
30
|
-
"
|
|
13
|
+
"inquirer": "^13.2.5",
|
|
14
|
+
"preact": "^10.27.2",
|
|
15
|
+
"preact-custom-element": "^4.6.0"
|
|
31
16
|
},
|
|
32
17
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@types/axios": "^0.14.4",
|
|
35
|
-
"@types/fs-extra": "^11.0.4",
|
|
36
|
-
"@types/inquirer": "^9.0.9",
|
|
18
|
+
"@preact/preset-vite": "^2.10.2",
|
|
37
19
|
"@types/node": "^24.10.1",
|
|
38
|
-
"@types/react": "^19.2.7",
|
|
39
|
-
"@types/react-dom": "^19.2.3",
|
|
40
|
-
"@vitejs/plugin-react": "^5.1.1",
|
|
41
|
-
"babel-plugin-react-compiler": "^1.0.0",
|
|
42
|
-
"eslint": "^9.39.1",
|
|
43
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
|
-
"eslint-plugin-react-refresh": "^0.4.24",
|
|
45
|
-
"globals": "^16.5.0",
|
|
46
20
|
"tsup": "^8.5.1",
|
|
47
|
-
"tsx": "^4.21.0",
|
|
48
21
|
"typescript": "~5.9.3",
|
|
49
|
-
"
|
|
50
|
-
"vite": "^8.0.0-beta.13"
|
|
22
|
+
"vite": "^7.3.1"
|
|
51
23
|
},
|
|
52
24
|
"scripts": {
|
|
53
25
|
"dev": "vite",
|
|
54
26
|
"build": "tsup",
|
|
55
|
-
"lint": "eslint .",
|
|
56
27
|
"preview": "vite preview",
|
|
57
|
-
"cli": "
|
|
28
|
+
"cli": "node scripts/add-book.ts"
|
|
58
29
|
}
|
|
59
30
|
}
|
package/README.md
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# React + TypeScript + Vite
|
|
2
|
-
|
|
3
|
-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
-
|
|
5
|
-
Currently, two official plugins are available:
|
|
6
|
-
|
|
7
|
-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
-
|
|
10
|
-
## React Compiler
|
|
11
|
-
|
|
12
|
-
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
|
|
13
|
-
|
|
14
|
-
Note: This will impact Vite dev & build performances.
|
|
15
|
-
|
|
16
|
-
## Expanding the ESLint configuration
|
|
17
|
-
|
|
18
|
-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
export default defineConfig([
|
|
22
|
-
globalIgnores(['dist']),
|
|
23
|
-
{
|
|
24
|
-
files: ['**/*.{ts,tsx}'],
|
|
25
|
-
extends: [
|
|
26
|
-
// Other configs...
|
|
27
|
-
|
|
28
|
-
// Remove tseslint.configs.recommended and replace with this
|
|
29
|
-
tseslint.configs.recommendedTypeChecked,
|
|
30
|
-
// Alternatively, use this for stricter rules
|
|
31
|
-
tseslint.configs.strictTypeChecked,
|
|
32
|
-
// Optionally, add this for stylistic rules
|
|
33
|
-
tseslint.configs.stylisticTypeChecked,
|
|
34
|
-
|
|
35
|
-
// Other configs...
|
|
36
|
-
],
|
|
37
|
-
languageOptions: {
|
|
38
|
-
parserOptions: {
|
|
39
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
40
|
-
tsconfigRootDir: import.meta.dirname,
|
|
41
|
-
},
|
|
42
|
-
// other options...
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
])
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
// eslint.config.js
|
|
52
|
-
import reactX from 'eslint-plugin-react-x'
|
|
53
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
54
|
-
|
|
55
|
-
export default defineConfig([
|
|
56
|
-
globalIgnores(['dist']),
|
|
57
|
-
{
|
|
58
|
-
files: ['**/*.{ts,tsx}'],
|
|
59
|
-
extends: [
|
|
60
|
-
// Other configs...
|
|
61
|
-
// Enable lint rules for React
|
|
62
|
-
reactX.configs['recommended-typescript'],
|
|
63
|
-
// Enable lint rules for React DOM
|
|
64
|
-
reactDom.configs.recommended,
|
|
65
|
-
],
|
|
66
|
-
languageOptions: {
|
|
67
|
-
parserOptions: {
|
|
68
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
69
|
-
tsconfigRootDir: import.meta.dirname,
|
|
70
|
-
},
|
|
71
|
-
// other options...
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
])
|
|
75
|
-
```
|
package/dist/cli.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";var d=Object.create;var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var f=(o,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of y(a))!g.call(o,e)&&e!==t&&p(o,e,{get:()=>a[e],enumerable:!(n=w(a,e))||n.enumerable});return o};var i=(o,a,t)=>(t=o!=null?d(b(o)):{},f(a||!o||!o.__esModule?p(t,"default",{value:o,enumerable:!0}):t,o));var c=i(require("inquirer"),1),l=i(require("axios"),1),r=i(require("fs-extra"),1),m=i(require("path"),1),h=m.default.join(process.cwd(),"public/library"),s=m.default.join(process.cwd(),"public/library/card.json");async function k(){if(await r.default.ensureDir(h),!r.default.existsSync(s)){let e=await c.default.prompt([{type:"input",name:"borrower",message:"Enter borrower name"},{type:"input",name:"libName",message:"Enter library name",default:"Boo Library"}]),u={borrower:e.borrower,library:{name:e.libName,signature:"\u{1F43E}"},books:[]};await r.default.writeJson(s,u,{spaces:2}),console.log("\u2728 Library card created!")}let{query:o}=await c.default.prompt([{type:"input",name:"query",message:"Search for a book:"}]),{data:a}=await l.default.get(`https://openlibrary.org/search.json?q=${encodeURIComponent(o)}`);if(!a.docs?.length){console.log("No books found.");return}let{selectedBook:t}=await c.default.prompt([{type:"select",name:"selectedBook",message:"Select a book:",choices:a.docs.map(e=>({name:`${e.title} (${e.author_name?.[0]||"Unknown"})`,value:{key:e.key,name:e.title,author:e.author_name?.[0]||"Unknown",finishedDate:new Date().toLocaleDateString("en-IN")}}))}]),n=await r.default.readJson(s);n.books.push(t),await r.default.writeJson(s,n,{spaces:2}),console.log(`Added ${t.name}`)}k();
|
package/dist/cli.d.cts
DELETED
package/dist/cli.d.ts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var a in t)p(r,a,{get:t[a],enumerable:!0})},x=(r,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of b(t))!h.call(r,s)&&s!==a&&p(r,s,{get:()=>t[s],enumerable:!(i=u(t,s))||i.enumerable});return r};var v=r=>x(p({},"__esModule",{value:!0}),r);var k={};y(k,{LibraryCard:()=>N});module.exports=v(k);var d=require("react");function c(r,{insertAt:t}={}){if(!r||typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&a.firstChild?a.insertBefore(i,a.firstChild):a.appendChild(i),i.styleSheet?i.styleSheet.cssText=r:i.appendChild(document.createTextNode(r))}c(`.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:16px;display:flex;top:-4px}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
|
|
3
|
-
`);var e=require("react/jsx-runtime"),N=({cardUrl:r,friends:t=[]})=>{let[a,i]=(0,d.useState)(null),[s,g]=(0,d.useState)([]);return(0,d.useEffect)(()=>{fetch(r).then(o=>o.json()).then(i),t.length>0&&Promise.all(t.map(o=>fetch(o).then(l=>l.json()).then(l=>({...l,url:o})))).then(g)},[r,t]),a?(0,e.jsx)("div",{className:"card",children:(0,e.jsxs)("div",{className:"inner",children:[(0,e.jsxs)("div",{className:"header",children:[(0,e.jsx)("span",{className:"year",children:"20"}),(0,e.jsx)("span",{className:"year",children:"26"})]}),(0,e.jsx)("div",{className:"header",children:(0,e.jsx)("h2",{className:"libraryTitle",children:a.library.name})}),(0,e.jsxs)("div",{className:"fieldGroup",children:[(0,e.jsx)("p",{className:"fieldValue nameValue",children:a.borrower}),(0,e.jsx)("label",{className:"label",children:"Borrower's Name"})]}),(0,e.jsxs)("div",{className:"fieldGroup",children:[(0,e.jsx)("p",{className:"fieldValue signatureValue",children:a.library.signature}),(0,e.jsx)("label",{className:"label",children:"Librarian's Signature"})]}),(0,e.jsx)("div",{className:"bookSection",children:(0,e.jsx)("ul",{className:"bookList",children:a.books.map((o,l)=>{console.log("friendsData",s,a);let m=s.filter(n=>n.books.some(f=>f.key===o.key));return console.log("readersOfThisBook",m),(0,e.jsxs)("li",{className:"bookRow",children:[(0,e.jsxs)("span",{className:"bookName",children:[o.name," by ",o.author]}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[(0,e.jsx)("span",{className:"bookDate",children:o.finishedDate}),(0,e.jsx)("div",{className:"friendSignatures",children:m.length>0&&(0,e.jsx)("div",{className:"friendSignatures",children:m.map((n,f)=>(0,e.jsx)("a",{href:n.url?new URL(n.url).origin:"#",className:"signatureLink",title:`${n.borrower} also read this`,target:"_blank",rel:"noopener noreferrer",children:n.library.signature},f))})})]})]},l)})})})]})}):(0,e.jsx)("div",{className:"loading",children:"Loading library card..."})};0&&(module.exports={LibraryCard});
|
package/dist/index.d.cts
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{useState as c,useEffect as u}from"react";function f(o,{insertAt:n}={}){if(!o||typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",n==="top"&&a.firstChild?a.insertBefore(t,a.firstChild):a.appendChild(t),t.styleSheet?t.styleSheet.cssText=o:t.appendChild(document.createTextNode(o))}f(`.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:16px;display:flex;top:-4px}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
|
|
3
|
-
`);import{jsx as e,jsxs as i}from"react/jsx-runtime";var v=({cardUrl:o,friends:n=[]})=>{let[a,t]=c(null),[p,g]=c([]);return u(()=>{fetch(o).then(r=>r.json()).then(t),n.length>0&&Promise.all(n.map(r=>fetch(r).then(l=>l.json()).then(l=>({...l,url:r})))).then(g)},[o,n]),a?e("div",{className:"card",children:i("div",{className:"inner",children:[i("div",{className:"header",children:[e("span",{className:"year",children:"20"}),e("span",{className:"year",children:"26"})]}),e("div",{className:"header",children:e("h2",{className:"libraryTitle",children:a.library.name})}),i("div",{className:"fieldGroup",children:[e("p",{className:"fieldValue nameValue",children:a.borrower}),e("label",{className:"label",children:"Borrower's Name"})]}),i("div",{className:"fieldGroup",children:[e("p",{className:"fieldValue signatureValue",children:a.library.signature}),e("label",{className:"label",children:"Librarian's Signature"})]}),e("div",{className:"bookSection",children:e("ul",{className:"bookList",children:a.books.map((r,l)=>{console.log("friendsData",p,a);let d=p.filter(s=>s.books.some(m=>m.key===r.key));return console.log("readersOfThisBook",d),i("li",{className:"bookRow",children:[i("span",{className:"bookName",children:[r.name," by ",r.author]}),i("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[e("span",{className:"bookDate",children:r.finishedDate}),e("div",{className:"friendSignatures",children:d.length>0&&e("div",{className:"friendSignatures",children:d.map((s,m)=>e("a",{href:s.url?new URL(s.url).origin:"#",className:"signatureLink",title:`${s.borrower} also read this`,target:"_blank",rel:"noopener noreferrer",children:s.library.signature},m))})})]})]},l)})})})]})}):e("div",{className:"loading",children:"Loading library card..."})};export{v as LibraryCard};
|