@lateralus-ai/shipping-ui 1.2.0 → 1.3.1

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.
Binary file
@@ -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.2.0",
3
+ "version": "1.3.1",
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,9 @@
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",
85
88
  "react-hotkeys-hook": "^5.1.0",
86
89
  "react-pdf": "^10.1.0",
87
90
  "react-router": "^7.9.3"