@lateralus-ai/shipping-ui 1.1.2 → 1.3.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/components/DocumentEditor/DocumentEditor.d.ts +4 -0
- package/dist/components/DocumentEditor/index.d.ts +1 -0
- package/dist/components/ModalPanel.d.ts +4 -0
- package/dist/components/PdfViewer/ImageViewer.d.ts +1 -1
- package/dist/components/PdfViewer/PdfViewer.d.ts +1 -1
- package/dist/components/PdfViewer/usePageManagement.d.ts +5 -1
- package/dist/components/SearchModal.d.ts +24 -0
- package/dist/components/Tabs.d.ts +13 -0
- package/dist/components/icons/SettingsIcon.d.ts +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/defect-report.pdf +0 -0
- package/dist/example.pdf +0 -0
- package/dist/index.cjs +272 -10
- package/dist/index.esm.js +35960 -1124
- package/dist/material-theme.d.ts +26 -0
- package/dist/sample-document.docx +0 -0
- package/dist/stories/SearchModal.d.ts +1 -0
- package/dist/style.css +1 -0
- package/dist/tailwind-theme.d.ts +12 -0
- package/dist/types/documentEditor.d.ts +47 -0
- package/dist/utils/checkboxModule.d.ts +54 -0
- package/package.json +5 -1
- package/src/components/DocumentEditor/DocumentEditor.tsx +872 -0
- package/src/components/DocumentEditor/index.ts +1 -0
- package/src/components/ModalPanel.tsx +13 -0
- package/src/components/PdfViewer/ImageViewer.tsx +8 -3
- package/src/components/PdfViewer/PdfViewer.tsx +138 -17
- package/src/components/PdfViewer/usePageManagement.ts +22 -7
- package/src/components/SearchModal.tsx +320 -0
- package/src/components/Tabs.tsx +43 -0
- package/src/components/icons/SettingsIcon.tsx +33 -0
- package/src/components/index.ts +2 -0
- package/src/material-theme.ts +30 -0
- package/src/stories/DocumentEditor.stories.tsx +287 -0
- package/src/stories/ModalHeader.stories.tsx +36 -0
- package/src/stories/PDFViewer.stories.tsx +1 -1
- package/src/stories/SearchModal.stories.tsx +132 -0
- package/src/stories/SearchModal.tsx +82 -0
- package/src/stories/Tabs.stories.tsx +51 -0
- package/src/styles/tabs.css +55 -0
- package/src/tailwind-theme.ts +12 -0
- package/src/types/documentEditor.ts +56 -0
- package/src/utils/checkboxModule.ts +242 -0
package/dist/material-theme.d.ts
CHANGED
|
@@ -413,4 +413,30 @@ export declare const materialTheme: {
|
|
|
413
413
|
};
|
|
414
414
|
};
|
|
415
415
|
};
|
|
416
|
+
tabsHeader: {
|
|
417
|
+
defaultProps: {
|
|
418
|
+
className: string;
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
tab: {
|
|
422
|
+
defaultProps: {
|
|
423
|
+
className: string;
|
|
424
|
+
};
|
|
425
|
+
styles: {
|
|
426
|
+
base: {
|
|
427
|
+
indicator: {
|
|
428
|
+
bg: string;
|
|
429
|
+
borderRadius: string;
|
|
430
|
+
boxShadow: string;
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
tabPanel: {
|
|
436
|
+
styles: {
|
|
437
|
+
base: {
|
|
438
|
+
p: string;
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
};
|
|
416
442
|
};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SearchModals: () => import("react/jsx-runtime").JSX.Element;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--react-pdf-annotation-layer: 1;--annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");--input-focus-border-color: Highlight;--input-focus-outline: 1px solid Canvas;--input-unfocused-border-color: transparent;--input-disabled-border-color: transparent;--input-hover-border-color: black;--link-outline: none}@media screen and (forced-colors: active){:root{--input-focus-border-color: CanvasText;--input-unfocused-border-color: ActiveText;--input-disabled-border-color: GrayText;--input-hover-border-color: Highlight;--link-outline: 1.5px solid LinkText}.annotationLayer .textWidgetAnnotation :is(input,textarea):required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required{outline:1.5px solid selectedItem}.annotationLayer .linkAnnotation:hover{-webkit-backdrop-filter:invert(100%);backdrop-filter:invert(100%)}}.annotationLayer{position:absolute;top:0;left:0;pointer-events:none;transform-origin:0 0;z-index:3}.annotationLayer[data-main-rotation="90"] .norotate{transform:rotate(270deg) translate(-100%)}.annotationLayer[data-main-rotation="180"] .norotate{transform:rotate(180deg) translate(-100%,-100%)}.annotationLayer[data-main-rotation="270"] .norotate{transform:rotate(90deg) translateY(-100%)}.annotationLayer canvas{position:absolute;width:100%;height:100%}.annotationLayer section{position:absolute;text-align:initial;pointer-events:auto;box-sizing:border-box;margin:0;transform-origin:0 0}.annotationLayer .linkAnnotation{outline:var(--link-outline)}.textLayer.selecting~.annotationLayer section{pointer-events:none}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a{position:absolute;font-size:1em;top:0;left:0;width:100%;height:100%}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a:hover{opacity:.2;background:#ff0;box-shadow:0 2px 10px #ff0}.annotationLayer .textAnnotation img{position:absolute;cursor:pointer;width:100%;height:100%;top:0;left:0}.annotationLayer .textWidgetAnnotation :is(input,textarea),.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px * var(--total-scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}.annotationLayer .textWidgetAnnotation :is(input,textarea):required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .textWidgetAnnotation :is(input,textarea)[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input[disabled]{background:none;border:2px solid var(--input-disabled-border-color);cursor:not-allowed}.annotationLayer .textWidgetAnnotation :is(input,textarea):hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .textWidgetAnnotation :is(input,textarea):hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation.checkBox input:hover{border-radius:2px}.annotationLayer .textWidgetAnnotation :is(input,textarea):focus,.annotationLayer .choiceWidgetAnnotation select:focus{background:none;border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) :focus{background-image:none;background-color:transparent}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{height:80%;left:45%;width:1px}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:30%;top:20%;width:50%}.annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none}.annotationLayer .popupTriggerArea{height:100%;width:100%}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{position:absolute}.annotationLayer .popupWrapper{position:absolute;font-size:calc(9px * var(--total-scale-factor));width:100%;min-width:calc(180px * var(--total-scale-factor));pointer-events:none}.annotationLayer .popup{position:absolute;max-width:calc(180px * var(--total-scale-factor));background-color:#ff9;box-shadow:0 calc(2px * var(--total-scale-factor)) calc(5px * var(--total-scale-factor)) #888;border-radius:calc(2px * var(--total-scale-factor));padding:calc(6px * var(--total-scale-factor));margin-left:calc(5px * var(--total-scale-factor));cursor:pointer;font:message-box;white-space:normal;word-wrap:break-word;pointer-events:auto}.annotationLayer .popup>*{font-size:calc(9px * var(--total-scale-factor))}.annotationLayer .popup h1{display:inline-block}.annotationLayer .popupDate{display:inline-block;margin-left:calc(5px * var(--total-scale-factor))}.annotationLayer .popupContent{border-top:1px solid rgba(51,51,51,1);margin-top:calc(2px * var(--total-scale-factor));padding-top:calc(2px * var(--total-scale-factor))}.annotationLayer .richText>*{white-space:pre-wrap;font-size:calc(9px * var(--total-scale-factor))}.annotationLayer .highlightAnnotation,.annotationLayer .underlineAnnotation,.annotationLayer .squigglyAnnotation,.annotationLayer .strikeoutAnnotation,.annotationLayer .freeTextAnnotation,.annotationLayer .lineAnnotation svg line,.annotationLayer .squareAnnotation svg rect,.annotationLayer .circleAnnotation svg ellipse,.annotationLayer .polylineAnnotation svg polyline,.annotationLayer .polygonAnnotation svg polygon,.annotationLayer .caretAnnotation,.annotationLayer .inkAnnotation svg polyline,.annotationLayer .stampAnnotation,.annotationLayer .fileAttachmentAnnotation{cursor:pointer}.annotationLayer section svg{position:absolute;width:100%;height:100%;top:0;left:0}.annotationLayer .annotationTextContent{position:absolute;width:100%;height:100%;opacity:0;color:transparent;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}.annotationLayer .annotationTextContent span{width:100%;display:inline-block}:root{--react-pdf-text-layer: 1;--highlight-bg-color: rgba(180, 0, 170, 1);--highlight-selected-bg-color: rgba(0, 100, 0, 1)}@media screen and (forced-colors: active){:root{--highlight-bg-color: Highlight;--highlight-selected-bg-color: ButtonText}}[data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg) translate(-100%)}.textLayer{position:absolute;text-align:initial;top:0;right:0;bottom:0;left:0;overflow:hidden;line-height:1;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;z-index:2}.textLayer :is(span,br){color:transparent;position:absolute;white-space:pre;cursor:text;margin:0;transform-origin:0 0}.textLayer span.markedContent{top:0;height:0}.textLayer .highlight{margin:-1px;padding:1px;background-color:var(--highlight-bg-color);border-radius:4px}.textLayer .highlight.appended{position:initial}.textLayer .highlight.begin{border-radius:4px 0 0 4px}.textLayer .highlight.end{border-radius:0 4px 4px 0}.textLayer .highlight.middle{border-radius:0}.textLayer .highlight.selected{background-color:var(--highlight-selected-bg-color)}.textLayer br::-moz-selection{background:transparent}.textLayer br::selection{background:transparent}.textLayer .endOfContent{display:block;position:absolute;top:100%;right:0;bottom:0;left:0;z-index:-1;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer.selecting .endOfContent{top:0}.hiddenCanvasElement{position:absolute;top:0;left:0;width:0;height:0;display:none}.tabs-container{width:100%;min-width:400px}.tabs-header{display:flex;border-bottom:2px solid #e5e7eb;margin-bottom:16px}.tab-button{padding:12px 24px;background:none;border:none;cursor:pointer;font-size:14px;font-weight:500;color:#6b7280;position:relative;transition:color .2s}.tab-button:hover{color:#374151}.tab-button.active{color:#3b82f6}.tab-button.active:after{content:"";position:absolute;bottom:-2px;left:0;right:0;height:2px;background-color:#3b82f6}.tab-content{animation:fadeIn .3s ease-in-out}@keyframes fadeIn{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
|
package/dist/tailwind-theme.d.ts
CHANGED
|
@@ -71,6 +71,18 @@ export declare const theme: {
|
|
|
71
71
|
"accordion-up": string;
|
|
72
72
|
};
|
|
73
73
|
colors: {
|
|
74
|
+
brand: {
|
|
75
|
+
50: string;
|
|
76
|
+
100: string;
|
|
77
|
+
200: string;
|
|
78
|
+
300: string;
|
|
79
|
+
400: string;
|
|
80
|
+
500: string;
|
|
81
|
+
600: string;
|
|
82
|
+
700: string;
|
|
83
|
+
800: string;
|
|
84
|
+
900: string;
|
|
85
|
+
};
|
|
74
86
|
gray: {
|
|
75
87
|
50: string;
|
|
76
88
|
100: string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface SchemaProperty {
|
|
2
|
+
type: "string" | "boolean" | "number" | "integer";
|
|
3
|
+
enum?: string[];
|
|
4
|
+
format?: "date" | "date-time" | string;
|
|
5
|
+
description?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
"ui:widget"?: string;
|
|
8
|
+
"ui:rows"?: number;
|
|
9
|
+
docx_mapping?: DocxMapping;
|
|
10
|
+
}
|
|
11
|
+
export interface DocxMapping {
|
|
12
|
+
type: "checkbox" | "radio" | "text";
|
|
13
|
+
name?: string;
|
|
14
|
+
true_name?: string;
|
|
15
|
+
false_name?: string;
|
|
16
|
+
mapping?: RadioMapping[];
|
|
17
|
+
}
|
|
18
|
+
export interface RadioMapping {
|
|
19
|
+
name: string;
|
|
20
|
+
value: string | boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Schema {
|
|
23
|
+
type: string;
|
|
24
|
+
properties: Record<string, SchemaProperty>;
|
|
25
|
+
required?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface CheckboxModuleOptions {
|
|
28
|
+
checkboxData?: Record<string, boolean>;
|
|
29
|
+
schema?: Schema;
|
|
30
|
+
finalGeneration?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface DocumentEditorProps {
|
|
33
|
+
docxUrl: string;
|
|
34
|
+
schema: Schema;
|
|
35
|
+
onDataChange?: (data: Record<string, any>) => void;
|
|
36
|
+
initialData?: Record<string, any>;
|
|
37
|
+
onSaveRef?: React.MutableRefObject<(() => void) | null>;
|
|
38
|
+
readonly?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface DocxtemplaterPart {
|
|
41
|
+
value?: string;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
export interface DocxtemplaterOptions {
|
|
45
|
+
contentType?: string;
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CheckboxModuleOptions, DocxtemplaterPart, DocxtemplaterOptions } from '../types/documentEditor';
|
|
2
|
+
/**
|
|
3
|
+
* CheckboxModule for docxtemplater
|
|
4
|
+
*
|
|
5
|
+
* This module handles three distinct checkbox patterns in DOCX documents:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Single Checkbox Pattern**: A field maps to a single checkbox
|
|
8
|
+
* - Schema: `docx_mapping: { type: "checkbox", name: "Check1" }`
|
|
9
|
+
* - Maps boolean field value directly to checkbox state
|
|
10
|
+
*
|
|
11
|
+
* 2. **Dual Checkbox Pattern**: Yes/No checkboxes for a single field
|
|
12
|
+
* - Schema: `docx_mapping: { type: "checkbox", true_name: "Check1", false_name: "Check2" }`
|
|
13
|
+
* - true_name checkbox checked when field is true
|
|
14
|
+
* - false_name checkbox checked when field is false
|
|
15
|
+
* - Used for Yes/No questions where both options have checkboxes
|
|
16
|
+
*
|
|
17
|
+
* 3. **Radio Button Pattern**: Multiple checkboxes acting as radio buttons
|
|
18
|
+
* - Schema: `docx_mapping: { type: "radio", mapping: [{ name: "Check1", value: "option1" }, ...] }`
|
|
19
|
+
* - Only the checkbox corresponding to the field's value is checked
|
|
20
|
+
* - Used for multiple choice questions
|
|
21
|
+
*
|
|
22
|
+
* The module operates in two modes:
|
|
23
|
+
* - **Preview Mode** (finalGeneration: false): Creates visual markers for inline editing
|
|
24
|
+
* - **Final Generation Mode** (finalGeneration: true): Updates actual Word form fields
|
|
25
|
+
*/
|
|
26
|
+
declare class CheckboxModule {
|
|
27
|
+
private checkboxData;
|
|
28
|
+
private schema?;
|
|
29
|
+
private finalGeneration;
|
|
30
|
+
constructor(options?: CheckboxModuleOptions);
|
|
31
|
+
name: string;
|
|
32
|
+
parse(placeHolderContent: string): null;
|
|
33
|
+
postparse(parsed: any): any;
|
|
34
|
+
render(part: any, options: any): any;
|
|
35
|
+
postrender(parts: DocxtemplaterPart[], options: DocxtemplaterOptions): string[] | DocxtemplaterPart[];
|
|
36
|
+
/**
|
|
37
|
+
* Process checkbox patterns in the document XML
|
|
38
|
+
* Identifies Word form field checkboxes by their bookmark names (Check1, Check2, etc.)
|
|
39
|
+
* and either updates their values or replaces them with visual markers
|
|
40
|
+
*/
|
|
41
|
+
private processCheckboxPatterns;
|
|
42
|
+
/**
|
|
43
|
+
* Determine the state of a checkbox based on field mappings and data
|
|
44
|
+
* @param checkboxName - The name of the checkbox (e.g., "Check1")
|
|
45
|
+
* @returns true if checkbox should be checked, false otherwise
|
|
46
|
+
*/
|
|
47
|
+
private getCheckboxState;
|
|
48
|
+
/**
|
|
49
|
+
* Update checkbox data (can be called to change checkbox states)
|
|
50
|
+
* @param checkboxData - New checkbox data to merge with existing data
|
|
51
|
+
*/
|
|
52
|
+
updateCheckboxData(checkboxData: Record<string, boolean>): void;
|
|
53
|
+
}
|
|
54
|
+
export default CheckboxModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lateralus-ai/shipping-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shared UI theme and components for Lateralus shipping applications",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@iconify/react": "^6.0.2",
|
|
84
84
|
"@react-hooks-library/core": "^0.6.2",
|
|
85
|
+
"docx-preview": "^0.3.7",
|
|
86
|
+
"docxtemplater": "^3.66.6",
|
|
87
|
+
"pizzip": "^3.2.0",
|
|
88
|
+
"react-hotkeys-hook": "^5.1.0",
|
|
85
89
|
"react-pdf": "^10.1.0",
|
|
86
90
|
"react-router": "^7.9.3"
|
|
87
91
|
}
|