@betterinternship/core 2.23.1 → 2.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -26
- package/dist/lib/forms/field-preset-templates.js +8 -8
- package/dist/lib/pdf-viewer/BasePdfViewer.d.ts +2 -1
- package/dist/lib/pdf-viewer/BasePdfViewer.js +3 -3
- package/dist/lib/pdf-viewer/BasePdfViewer.js.map +1 -1
- package/dist/lib/pdf-viewer/form-previewer-rendering.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -86
package/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# Package.Core
|
|
2
|
-
|
|
3
|
-
Contains dependencies shared between the different services of the site.
|
|
4
|
-
|
|
5
|
-
## How to update
|
|
6
|
-
|
|
7
|
-
1. Build the package:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm run build
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
2. Commit the build:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
git add .
|
|
17
|
-
git commit -m "<follow conventional commits, k thanks>"
|
|
18
|
-
git push
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
3. Update the version and publish the package to NPM:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm version <patch|minor|major>
|
|
25
|
-
npm publish
|
|
26
|
-
```
|
|
1
|
+
# Package.Core
|
|
2
|
+
|
|
3
|
+
Contains dependencies shared between the different services of the site.
|
|
4
|
+
|
|
5
|
+
## How to update
|
|
6
|
+
|
|
7
|
+
1. Build the package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Commit the build:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git add .
|
|
17
|
+
git commit -m "<follow conventional commits, k thanks>"
|
|
18
|
+
git push
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
3. Update the version and publish the package to NPM:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm version <patch|minor|major>
|
|
25
|
+
npm publish
|
|
26
|
+
```
|
|
@@ -5,14 +5,14 @@ const LONG_TEXT_VALIDATOR = `${TEXT_PREPROCESS}z.string().describe("textarea"))`
|
|
|
5
5
|
const NUMBER_VALIDATOR = 'z.number()';
|
|
6
6
|
const SIGNATURE_VALIDATOR = `${TEXT_PREPROCESS}z.string().nonempty({ message: "This field is required." }))`;
|
|
7
7
|
const DROPDOWN_VALIDATOR = `z.enum(["Option 1", "Option 2"], {message:"This field is required."})`;
|
|
8
|
-
const MULTISELECT_VALIDATOR = `z.array(
|
|
9
|
-
z.enum(
|
|
10
|
-
[
|
|
11
|
-
"Option 1",
|
|
12
|
-
"Option 2"
|
|
13
|
-
],
|
|
14
|
-
{ message: "This field is required." }
|
|
15
|
-
)
|
|
8
|
+
const MULTISELECT_VALIDATOR = `z.array(
|
|
9
|
+
z.enum(
|
|
10
|
+
[
|
|
11
|
+
"Option 1",
|
|
12
|
+
"Option 2"
|
|
13
|
+
],
|
|
14
|
+
{ message: "This field is required." }
|
|
15
|
+
)
|
|
16
16
|
).describe("multiselect")`;
|
|
17
17
|
const DATE_VALIDATOR = 'z.coerce.date()';
|
|
18
18
|
const TIME_VALIDATOR = 'z.string().describe("time")';
|
|
@@ -8,6 +8,7 @@ type BasePdfViewerProps = {
|
|
|
8
8
|
onVisiblePageChange: (page: number) => void;
|
|
9
9
|
showToolbar?: boolean;
|
|
10
10
|
squareFrame?: boolean;
|
|
11
|
+
minScale?: number;
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
renderPage: (pageNumber: number) => React.ReactNode;
|
|
13
14
|
pageRefs?: React.MutableRefObject<Map<number, HTMLDivElement | null>>;
|
|
@@ -17,5 +18,5 @@ type BasePdfViewerProps = {
|
|
|
17
18
|
onDragLeave?: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
18
19
|
onDrop?: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
19
20
|
};
|
|
20
|
-
export declare function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visiblePage, onVisiblePageChange, showToolbar, squareFrame, children, renderPage, registerScrollContainer, onFileChange, pageRefs: externalPageRefs, onDragOver, onDragLeave, onDrop, }: BasePdfViewerProps): import("react").JSX.Element;
|
|
21
|
+
export declare function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visiblePage, onVisiblePageChange, showToolbar, squareFrame, minScale, children, renderPage, registerScrollContainer, onFileChange, pageRefs: externalPageRefs, onDragOver, onDragLeave, onDrop, }: BasePdfViewerProps): import("react").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { FileUp, ZoomIn, ZoomOut } from 'lucide-react';
|
|
5
5
|
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
6
|
-
export function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visiblePage, onVisiblePageChange, showToolbar = true, squareFrame = false, children, renderPage, registerScrollContainer, onFileChange, pageRefs: externalPageRefs, onDragOver, onDragLeave, onDrop, }) {
|
|
6
|
+
export function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visiblePage, onVisiblePageChange, showToolbar = true, squareFrame = false, minScale = 0.2, children, renderPage, registerScrollContainer, onFileChange, pageRefs: externalPageRefs, onDragOver, onDragLeave, onDrop, }) {
|
|
7
7
|
const internalPageRefs = useRef(new Map());
|
|
8
8
|
const pageRefs = externalPageRefs ?? internalPageRefs;
|
|
9
9
|
const registerPageRef = useCallback((page, node) => {
|
|
@@ -11,7 +11,7 @@ export function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visible
|
|
|
11
11
|
}, []);
|
|
12
12
|
const handleZoom = (direction) => {
|
|
13
13
|
const delta = direction === 'in' ? 0.1 : -0.1;
|
|
14
|
-
onScaleChange(clamp(parseFloat((scale + delta).toFixed(2)),
|
|
14
|
+
onScaleChange(clamp(parseFloat((scale + delta).toFixed(2)), minScale, 3));
|
|
15
15
|
};
|
|
16
16
|
const pagesArray = useMemo(() => Array.from({ length: pageCount }, (_, idx) => idx + 1), [pageCount]);
|
|
17
17
|
const handleScroll = useCallback((e) => {
|
|
@@ -37,6 +37,6 @@ export function BasePdfViewer({ pdfDoc, pageCount, scale, onScaleChange, visible
|
|
|
37
37
|
const containerClass = squareFrame
|
|
38
38
|
? 'relative flex h-full flex-col overflow-hidden bg-slate-50'
|
|
39
39
|
: 'relative flex h-full flex-col overflow-hidden rounded-[0.33em] bg-slate-50';
|
|
40
|
-
return (_jsxs("div", { className: containerClass, children: [showToolbar && (_jsx("div", { className: "relative flex h-12 flex-shrink-0 items-center border-b border-slate-300 bg-white px-3", children: _jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [_jsx("div", { className: "flex items-center gap-1", children: children }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-xs font-medium text-slate-700", children: [visiblePage, "/", pageCount || 1] }), _jsxs("div", { className: "ml-1 inline-flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => handleZoom('out'), disabled: scale <=
|
|
40
|
+
return (_jsxs("div", { className: containerClass, children: [showToolbar && (_jsx("div", { className: "relative flex h-12 flex-shrink-0 items-center border-b border-slate-300 bg-white px-3", children: _jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [_jsx("div", { className: "flex items-center gap-1", children: children }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-xs font-medium text-slate-700", children: [visiblePage, "/", pageCount || 1] }), _jsxs("div", { className: "ml-1 inline-flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => handleZoom('out'), disabled: scale <= minScale, className: "rounded p-1.5 hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-30", title: "Zoom out", "aria-label": "Zoom out", children: _jsx(ZoomOut, { className: "h-3.5 w-3.5" }) }), _jsx("button", { type: "button", onClick: () => handleZoom('in'), disabled: scale >= 3, className: "rounded p-1.5 hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-30", title: "Zoom in", "aria-label": "Zoom in", children: _jsx(ZoomIn, { className: "h-3.5 w-3.5" }) })] }), _jsxs("span", { className: "w-10 text-center text-[11px] font-medium text-slate-700", children: [Math.round(scale * 100), "%"] }), onFileChange && (_jsxs("label", { className: "flex cursor-pointer items-center rounded p-1.5 text-sm transition-colors hover:bg-slate-100", title: "Upload PDF", "aria-label": "Upload PDF", children: [_jsx(FileUp, { className: "h-4 w-4" }), _jsx("input", { type: "file", accept: "application/pdf", className: "hidden", onChange: onFileChange })] }))] })] }) })), _jsx("div", { className: "relative flex-1 overflow-hidden bg-slate-100", children: _jsx("div", { className: "flex h-full min-w-0", children: _jsx("div", { ref: registerScrollContainer, className: "relative min-w-0 flex-1 overflow-auto p-4", onScroll: handleScroll, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, children: _jsx("div", { className: "w-full space-y-4", children: pagesArray.map((page) => (_jsx("div", { className: "mx-auto w-fit", children: _jsx("div", { ref: (node) => registerPageRef(page, node), children: renderPage(page) }) }, page))) }) }) }) })] }));
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=BasePdfViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePdfViewer.js","sourceRoot":"","sources":["../../../lib/pdf-viewer/BasePdfViewer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAY,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,EAAE,CACxD,IAAI,CAAC,GA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C9B,gBACE,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,iBAAiB,EACxB,SAAS,EAAC,QAAQ,EAClB,QAAQ,EAAE,YAAY,GACtB,IACI,CACT,IACG,IACF,GACF,CACP,EACD,cAAK,SAAS,EAAC,8CAA8C,YAC3D,cAAK,SAAS,EAAC,qBAAqB,YAClC,cACE,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAC,2CAA2C,EACrD,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,YAEd,cAAK,SAAS,EAAC,kBAAkB,YAC9B,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACxB,cAAgB,SAAS,EAAC,eAAe,YACvC,cAAK,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,YAC5C,UAAU,CAAC,IAAI,CAAC,GACb,IAHE,IAAI,CAIR,CACP,CAAC,GACE,GACF,GACF,GACF,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -77,13 +77,13 @@ export const ensurePreviewFontsLoaded = () => {
|
|
|
77
77
|
if (!document.getElementById(PREVIEW_FONT_STYLE_ID)) {
|
|
78
78
|
const style = document.createElement("style");
|
|
79
79
|
style.id = PREVIEW_FONT_STYLE_ID;
|
|
80
|
-
style.textContent = `
|
|
81
|
-
@font-face {
|
|
82
|
-
font-family: "MegastinaPreview";
|
|
83
|
-
src: url("/fonts/megastina.regular.ttf") format("truetype");
|
|
84
|
-
font-weight: 400;
|
|
85
|
-
font-style: normal;
|
|
86
|
-
font-display: block;
|
|
80
|
+
style.textContent = `
|
|
81
|
+
@font-face {
|
|
82
|
+
font-family: "MegastinaPreview";
|
|
83
|
+
src: url("/fonts/megastina.regular.ttf") format("truetype");
|
|
84
|
+
font-weight: 400;
|
|
85
|
+
font-style: normal;
|
|
86
|
+
font-display: block;
|
|
87
87
|
}`;
|
|
88
88
|
document.head.appendChild(style);
|
|
89
89
|
}
|