formlift 0.1.0 → 0.2.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.
@@ -0,0 +1,201 @@
1
+ import { F as FieldDef, A as AnswerValue, b as Answers, a as FieldType } from './form-logic-DT9Bfwfz.js';
2
+
3
+ /** What each layout tool draws when dropped. */
4
+ declare const ELEMENT_TOOLS: {
5
+ readonly text: {
6
+ readonly label: "Text";
7
+ readonly size: [0.3, 0.025];
8
+ readonly make: {
9
+ readonly type: "text";
10
+ readonly text: "New text";
11
+ readonly fontSize: 11;
12
+ };
13
+ };
14
+ readonly box: {
15
+ readonly label: "Box";
16
+ readonly size: [0.3, 0.08];
17
+ readonly make: {
18
+ readonly type: "box";
19
+ readonly stroke: "#000000";
20
+ readonly strokeWidth: 1;
21
+ };
22
+ };
23
+ readonly whiteout: {
24
+ readonly label: "White-out (hide)";
25
+ readonly size: [0.2, 0.03];
26
+ readonly make: {
27
+ readonly type: "box";
28
+ readonly fill: "#ffffff";
29
+ };
30
+ };
31
+ readonly line: {
32
+ readonly label: "Line";
33
+ readonly size: [0.3, 0];
34
+ readonly make: {
35
+ readonly type: "line";
36
+ readonly stroke: "#000000";
37
+ readonly strokeWidth: 1;
38
+ };
39
+ };
40
+ };
41
+ type ElementTool = keyof typeof ELEMENT_TOOLS;
42
+ /** One line (or column cell) of original text, in page fractions; fontSize in points. */
43
+ interface TextLine {
44
+ text: string;
45
+ x: number;
46
+ y: number;
47
+ width: number;
48
+ height: number;
49
+ fontSize: number;
50
+ bold?: boolean;
51
+ italic?: boolean;
52
+ }
53
+ /** pdf.js text item: transform = [a, b, c, d, e, f] in PDF space, width in PDF units. */
54
+ interface PdfTextItem {
55
+ str: string;
56
+ transform: number[];
57
+ width: number;
58
+ fontName?: string;
59
+ }
60
+ /**
61
+ * Groups pdf.js text items into lines. Items on the same baseline join when the gap between them is small (a
62
+ * space); a wide gap (another column, a table cell) starts a new line. `viewBox` = [x0, y0, x1, y1] of the page.
63
+ */
64
+ declare function toLines(items: PdfTextItem[], viewBox: number[],
65
+ /** The real font name of a pdf.js font id ('ABCDEF+Arial-BoldMT'), to tell bold / italic text. */
66
+ fontOf?: (id: string) => string | undefined): TextLine[];
67
+
68
+ interface Question {
69
+ id: string;
70
+ title: string;
71
+ page: number;
72
+ parts: {
73
+ field: FieldDef;
74
+ name: string;
75
+ }[];
76
+ /** Option grid or table: parts per line of the document, to lay them out in the same rows. */
77
+ rows?: number[];
78
+ /** Table: its column names (parts are row by row, left to right), and each row's own name when rows have one. */
79
+ columns?: string[];
80
+ rowNames?: string[];
81
+ /** The category heading the question sits under (e.g. "HW", "PR", "HF" in inspection checklists), when the form has them. */
82
+ category?: string;
83
+ /** The numbered question heading it answers ("2.1.1 Maintenance of statutory Certificates"), when written above. */
84
+ section?: string;
85
+ /** A column of boxes named by the text block left of it (its options come first). */
86
+ block?: boolean;
87
+ /** "Classification: Core , Risk: H , Assigned to: MASTER" written in its numbered question: filters. */
88
+ tags?: Record<string, string>;
89
+ /** What a run of rows with the same choices asks ("Evaluation of the level of compliance…"), shown over them. */
90
+ intro?: string;
91
+ }
92
+ /** Text lines of a form page (page fractions, top-left origin, as field positions), when known. */
93
+ type PageText = (page: number) => TextLine[] | undefined;
94
+ /** Questions in document order: page, then top to bottom. */
95
+ interface ToQuestionsOptions {
96
+ /**
97
+ * Category headings: a line that is only a code like this ("HW", "PR", "HF") marks the questions under it, when
98
+ * two codes or more come back. Default /^[A-Z]{2,4}$/. false = no categories (set Question.category yourself).
99
+ */
100
+ categoryCode?: RegExp | false;
101
+ }
102
+ declare function toQuestions(fields: FieldDef[], textOf?: PageText, { categoryCode }?: ToQuestionsOptions): Question[];
103
+ declare const isFilled: (v: AnswerValue | undefined) => boolean;
104
+ /** A question's answer choices ("Yes", "No", "NA"), from its boxes or its radio buttons. */
105
+ declare function choicesOf(q: Question): string[];
106
+ /** The choices ticked in a question's answers. */
107
+ declare function pickedOf(q: Question, answers: Answers): string[];
108
+
109
+ interface FilterOption {
110
+ value: string;
111
+ label: string;
112
+ /** How many questions have it. */
113
+ count?: number;
114
+ }
115
+ interface QuestionFilterDef {
116
+ /** Unique key: the filter's value is stored under it. */
117
+ id: string;
118
+ title: string;
119
+ /** Where a UI may put it, e.g. a heading to group it under ("Progress") or "bar" for always visible. A hint only. */
120
+ section?: string;
121
+ /** What can be picked in these questions. Counts may follow the answers. */
122
+ options: (questions: Question[], answers: Answers) => FilterOption[];
123
+ /** Whether a question passes when `value` is picked. */
124
+ test: (q: Question, value: string, answers: Answers) => boolean;
125
+ }
126
+ /** A filter, or a function making several from the questions (one per tag key, …). */
127
+ type FilterSource = QuestionFilterDef | ((questions: Question[]) => QuestionFilterDef[]);
128
+ /** Picked value per filter id (absent / null = not filtering on it). */
129
+ type FilterValues = Record<string, string | null | undefined>;
130
+ /** Answered / not answered (any part of the question). */
131
+ declare const answeredFilter: ({ id, title, yes, no, section, }?: {
132
+ id?: string | undefined;
133
+ title?: string | undefined;
134
+ yes?: string | undefined;
135
+ no?: string | undefined;
136
+ section?: string | undefined;
137
+ }) => QuestionFilterDef;
138
+ /**
139
+ * Written / empty for the parts whose name or label matches `match` ("Remarks", "Comments", "Finding"…).
140
+ * Offers nothing for a form without such parts.
141
+ */
142
+ declare function partFilter({ id, title, match, yes, no, section, }: {
143
+ id: string;
144
+ title: string;
145
+ match: RegExp;
146
+ yes?: string;
147
+ no?: string;
148
+ section?: string;
149
+ }): QuestionFilterDef;
150
+ /** Questions that offer an answer choice ("Yes", "NA", "As Expected"): choices offered by `min`+ questions. */
151
+ declare const choiceFilter: ({ id, title, section, min, max, }?: {
152
+ id?: string | undefined;
153
+ title?: string | undefined;
154
+ section?: string | undefined;
155
+ min?: number | undefined;
156
+ max?: number | undefined;
157
+ }) => QuestionFilterDef;
158
+ /** Questions answered with a choice (counts follow the answers). */
159
+ declare const pickedFilter: ({ id, title, section, min, max, }?: {
160
+ id?: string | undefined;
161
+ title?: string | undefined;
162
+ section?: string | undefined;
163
+ min?: number | undefined;
164
+ max?: number | undefined;
165
+ }) => QuestionFilterDef;
166
+ /** By the category heading a question sits under (Question.category). */
167
+ declare const categoryFilter: ({ id, title, section }?: {
168
+ id?: string | undefined;
169
+ title?: string | undefined;
170
+ section?: string | undefined;
171
+ }) => QuestionFilterDef;
172
+ /** By answer type (a question with any part of that type). */
173
+ declare const typeFilter: ({ id, title, section, label, }?: {
174
+ id?: string | undefined;
175
+ title?: string | undefined;
176
+ section?: string | undefined;
177
+ label?: ((t: FieldType) => string) | undefined;
178
+ }) => QuestionFilterDef;
179
+ /** One filter on a tag key ("Risk": H / M / L) of Question.tags. */
180
+ declare const tagFilter: (key: string, { title, section }?: {
181
+ title?: string | undefined;
182
+ section?: string | undefined;
183
+ }) => QuestionFilterDef;
184
+ /** A tagFilter for every tag key in the questions. */
185
+ declare const tagFilters: ({ section }?: {
186
+ section?: string | undefined;
187
+ }) => (qs: Question[]) => QuestionFilterDef[];
188
+ /** Your own filter in one line: `customFilter('deck', 'Deck', (q) => q.page <= 3 ? ['Upper'] : ['Lower'])`. */
189
+ declare const customFilter: (id: string, title: string, valuesOf: (q: Question, answers: Answers) => string[], section?: string) => QuestionFilterDef;
190
+ /** The built-in presets, in the built-in UI's order. Start from it, filter it, or ignore it. */
191
+ declare const builtinFilters: (labels?: {
192
+ type?: (t: FieldType) => string;
193
+ }) => FilterSource[];
194
+ /** The filter objects for these questions (functions expanded). */
195
+ declare const resolveFilters: (sources: FilterSource[], questions: Question[]) => QuestionFilterDef[];
196
+ /** The text search looks in: section, intro, title and the parts' labels. */
197
+ declare const searchText: (q: Question) => string;
198
+ /** The questions that pass the search and every picked filter value. */
199
+ declare function filterQuestions(questions: Question[], answers: Answers, filters: QuestionFilterDef[], values: FilterValues, search?: string): Question[];
200
+
201
+ export { type ElementTool as E, type FilterOption as F, type PageText as P, type Question as Q, type TextLine as T, type FilterSource as a, type FilterValues as b, type PdfTextItem as c, type QuestionFilterDef as d, type ToQuestionsOptions as e, answeredFilter as f, builtinFilters as g, categoryFilter as h, choiceFilter as i, choicesOf as j, customFilter as k, filterQuestions as l, isFilled as m, pickedFilter as n, pickedOf as o, partFilter as p, tagFilters as q, resolveFilters as r, searchText as s, tagFilter as t, toLines as u, toQuestions as v, typeFilter as w };
@@ -0,0 +1,201 @@
1
+ import { F as FieldDef, A as AnswerValue, b as Answers, a as FieldType } from './form-logic-DT9Bfwfz.cjs';
2
+
3
+ /** What each layout tool draws when dropped. */
4
+ declare const ELEMENT_TOOLS: {
5
+ readonly text: {
6
+ readonly label: "Text";
7
+ readonly size: [0.3, 0.025];
8
+ readonly make: {
9
+ readonly type: "text";
10
+ readonly text: "New text";
11
+ readonly fontSize: 11;
12
+ };
13
+ };
14
+ readonly box: {
15
+ readonly label: "Box";
16
+ readonly size: [0.3, 0.08];
17
+ readonly make: {
18
+ readonly type: "box";
19
+ readonly stroke: "#000000";
20
+ readonly strokeWidth: 1;
21
+ };
22
+ };
23
+ readonly whiteout: {
24
+ readonly label: "White-out (hide)";
25
+ readonly size: [0.2, 0.03];
26
+ readonly make: {
27
+ readonly type: "box";
28
+ readonly fill: "#ffffff";
29
+ };
30
+ };
31
+ readonly line: {
32
+ readonly label: "Line";
33
+ readonly size: [0.3, 0];
34
+ readonly make: {
35
+ readonly type: "line";
36
+ readonly stroke: "#000000";
37
+ readonly strokeWidth: 1;
38
+ };
39
+ };
40
+ };
41
+ type ElementTool = keyof typeof ELEMENT_TOOLS;
42
+ /** One line (or column cell) of original text, in page fractions; fontSize in points. */
43
+ interface TextLine {
44
+ text: string;
45
+ x: number;
46
+ y: number;
47
+ width: number;
48
+ height: number;
49
+ fontSize: number;
50
+ bold?: boolean;
51
+ italic?: boolean;
52
+ }
53
+ /** pdf.js text item: transform = [a, b, c, d, e, f] in PDF space, width in PDF units. */
54
+ interface PdfTextItem {
55
+ str: string;
56
+ transform: number[];
57
+ width: number;
58
+ fontName?: string;
59
+ }
60
+ /**
61
+ * Groups pdf.js text items into lines. Items on the same baseline join when the gap between them is small (a
62
+ * space); a wide gap (another column, a table cell) starts a new line. `viewBox` = [x0, y0, x1, y1] of the page.
63
+ */
64
+ declare function toLines(items: PdfTextItem[], viewBox: number[],
65
+ /** The real font name of a pdf.js font id ('ABCDEF+Arial-BoldMT'), to tell bold / italic text. */
66
+ fontOf?: (id: string) => string | undefined): TextLine[];
67
+
68
+ interface Question {
69
+ id: string;
70
+ title: string;
71
+ page: number;
72
+ parts: {
73
+ field: FieldDef;
74
+ name: string;
75
+ }[];
76
+ /** Option grid or table: parts per line of the document, to lay them out in the same rows. */
77
+ rows?: number[];
78
+ /** Table: its column names (parts are row by row, left to right), and each row's own name when rows have one. */
79
+ columns?: string[];
80
+ rowNames?: string[];
81
+ /** The category heading the question sits under (e.g. "HW", "PR", "HF" in inspection checklists), when the form has them. */
82
+ category?: string;
83
+ /** The numbered question heading it answers ("2.1.1 Maintenance of statutory Certificates"), when written above. */
84
+ section?: string;
85
+ /** A column of boxes named by the text block left of it (its options come first). */
86
+ block?: boolean;
87
+ /** "Classification: Core , Risk: H , Assigned to: MASTER" written in its numbered question: filters. */
88
+ tags?: Record<string, string>;
89
+ /** What a run of rows with the same choices asks ("Evaluation of the level of compliance…"), shown over them. */
90
+ intro?: string;
91
+ }
92
+ /** Text lines of a form page (page fractions, top-left origin, as field positions), when known. */
93
+ type PageText = (page: number) => TextLine[] | undefined;
94
+ /** Questions in document order: page, then top to bottom. */
95
+ interface ToQuestionsOptions {
96
+ /**
97
+ * Category headings: a line that is only a code like this ("HW", "PR", "HF") marks the questions under it, when
98
+ * two codes or more come back. Default /^[A-Z]{2,4}$/. false = no categories (set Question.category yourself).
99
+ */
100
+ categoryCode?: RegExp | false;
101
+ }
102
+ declare function toQuestions(fields: FieldDef[], textOf?: PageText, { categoryCode }?: ToQuestionsOptions): Question[];
103
+ declare const isFilled: (v: AnswerValue | undefined) => boolean;
104
+ /** A question's answer choices ("Yes", "No", "NA"), from its boxes or its radio buttons. */
105
+ declare function choicesOf(q: Question): string[];
106
+ /** The choices ticked in a question's answers. */
107
+ declare function pickedOf(q: Question, answers: Answers): string[];
108
+
109
+ interface FilterOption {
110
+ value: string;
111
+ label: string;
112
+ /** How many questions have it. */
113
+ count?: number;
114
+ }
115
+ interface QuestionFilterDef {
116
+ /** Unique key: the filter's value is stored under it. */
117
+ id: string;
118
+ title: string;
119
+ /** Where a UI may put it, e.g. a heading to group it under ("Progress") or "bar" for always visible. A hint only. */
120
+ section?: string;
121
+ /** What can be picked in these questions. Counts may follow the answers. */
122
+ options: (questions: Question[], answers: Answers) => FilterOption[];
123
+ /** Whether a question passes when `value` is picked. */
124
+ test: (q: Question, value: string, answers: Answers) => boolean;
125
+ }
126
+ /** A filter, or a function making several from the questions (one per tag key, …). */
127
+ type FilterSource = QuestionFilterDef | ((questions: Question[]) => QuestionFilterDef[]);
128
+ /** Picked value per filter id (absent / null = not filtering on it). */
129
+ type FilterValues = Record<string, string | null | undefined>;
130
+ /** Answered / not answered (any part of the question). */
131
+ declare const answeredFilter: ({ id, title, yes, no, section, }?: {
132
+ id?: string | undefined;
133
+ title?: string | undefined;
134
+ yes?: string | undefined;
135
+ no?: string | undefined;
136
+ section?: string | undefined;
137
+ }) => QuestionFilterDef;
138
+ /**
139
+ * Written / empty for the parts whose name or label matches `match` ("Remarks", "Comments", "Finding"…).
140
+ * Offers nothing for a form without such parts.
141
+ */
142
+ declare function partFilter({ id, title, match, yes, no, section, }: {
143
+ id: string;
144
+ title: string;
145
+ match: RegExp;
146
+ yes?: string;
147
+ no?: string;
148
+ section?: string;
149
+ }): QuestionFilterDef;
150
+ /** Questions that offer an answer choice ("Yes", "NA", "As Expected"): choices offered by `min`+ questions. */
151
+ declare const choiceFilter: ({ id, title, section, min, max, }?: {
152
+ id?: string | undefined;
153
+ title?: string | undefined;
154
+ section?: string | undefined;
155
+ min?: number | undefined;
156
+ max?: number | undefined;
157
+ }) => QuestionFilterDef;
158
+ /** Questions answered with a choice (counts follow the answers). */
159
+ declare const pickedFilter: ({ id, title, section, min, max, }?: {
160
+ id?: string | undefined;
161
+ title?: string | undefined;
162
+ section?: string | undefined;
163
+ min?: number | undefined;
164
+ max?: number | undefined;
165
+ }) => QuestionFilterDef;
166
+ /** By the category heading a question sits under (Question.category). */
167
+ declare const categoryFilter: ({ id, title, section }?: {
168
+ id?: string | undefined;
169
+ title?: string | undefined;
170
+ section?: string | undefined;
171
+ }) => QuestionFilterDef;
172
+ /** By answer type (a question with any part of that type). */
173
+ declare const typeFilter: ({ id, title, section, label, }?: {
174
+ id?: string | undefined;
175
+ title?: string | undefined;
176
+ section?: string | undefined;
177
+ label?: ((t: FieldType) => string) | undefined;
178
+ }) => QuestionFilterDef;
179
+ /** One filter on a tag key ("Risk": H / M / L) of Question.tags. */
180
+ declare const tagFilter: (key: string, { title, section }?: {
181
+ title?: string | undefined;
182
+ section?: string | undefined;
183
+ }) => QuestionFilterDef;
184
+ /** A tagFilter for every tag key in the questions. */
185
+ declare const tagFilters: ({ section }?: {
186
+ section?: string | undefined;
187
+ }) => (qs: Question[]) => QuestionFilterDef[];
188
+ /** Your own filter in one line: `customFilter('deck', 'Deck', (q) => q.page <= 3 ? ['Upper'] : ['Lower'])`. */
189
+ declare const customFilter: (id: string, title: string, valuesOf: (q: Question, answers: Answers) => string[], section?: string) => QuestionFilterDef;
190
+ /** The built-in presets, in the built-in UI's order. Start from it, filter it, or ignore it. */
191
+ declare const builtinFilters: (labels?: {
192
+ type?: (t: FieldType) => string;
193
+ }) => FilterSource[];
194
+ /** The filter objects for these questions (functions expanded). */
195
+ declare const resolveFilters: (sources: FilterSource[], questions: Question[]) => QuestionFilterDef[];
196
+ /** The text search looks in: section, intro, title and the parts' labels. */
197
+ declare const searchText: (q: Question) => string;
198
+ /** The questions that pass the search and every picked filter value. */
199
+ declare function filterQuestions(questions: Question[], answers: Answers, filters: QuestionFilterDef[], values: FilterValues, search?: string): Question[];
200
+
201
+ export { type ElementTool as E, type FilterOption as F, type PageText as P, type Question as Q, type TextLine as T, type FilterSource as a, type FilterValues as b, type PdfTextItem as c, type QuestionFilterDef as d, type ToQuestionsOptions as e, answeredFilter as f, builtinFilters as g, categoryFilter as h, choiceFilter as i, choicesOf as j, customFilter as k, filterQuestions as l, isFilled as m, pickedFilter as n, pickedOf as o, partFilter as p, tagFilters as q, resolveFilters as r, searchText as s, tagFilter as t, toLines as u, toQuestions as v, typeFilter as w };
package/dist/index.cjs CHANGED
@@ -19,7 +19,18 @@
19
19
 
20
20
 
21
21
 
22
- var _chunk5VHPTLLVcjs = require('./chunk-5VHPTLLV.cjs');
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ var _chunk33XWO4KBcjs = require('./chunk-33XWO4KB.cjs');
23
34
 
24
35
 
25
36
 
@@ -75,5 +86,16 @@ var _chunk7NZPYWL3cjs = require('./chunk-7NZPYWL3.cjs');
75
86
 
76
87
 
77
88
 
78
- exports.FIELD_TYPES = _chunk7NZPYWL3cjs.FIELD_TYPES; exports.FONTS = _chunk7NZPYWL3cjs.FONTS; exports.MAX_ELEMENTS = _chunk7NZPYWL3cjs.MAX_ELEMENTS; exports.MAX_FIELDS = _chunk7NZPYWL3cjs.MAX_FIELDS; exports.MAX_PAGES = _chunk7NZPYWL3cjs.MAX_PAGES; exports.MAX_SIGNATURE_CHARS = _chunk7NZPYWL3cjs.MAX_SIGNATURE_CHARS; exports.NO_FILTER = _chunk5VHPTLLVcjs.NO_FILTER; exports.OPERATORS = _chunk7NZPYWL3cjs.OPERATORS; exports.checkAnswer = _chunk7NZPYWL3cjs.checkAnswer; exports.choicesOf = _chunk5VHPTLLVcjs.choicesOf; exports.cleanAnswers = _chunk7NZPYWL3cjs.cleanAnswers; exports.defaultAnswers = _chunk7NZPYWL3cjs.defaultAnswers; exports.defaultLayout = _chunk7NZPYWL3cjs.defaultLayout; exports.detectDocument = _chunk5VHPTLLVcjs.detectDocument; exports.detectFields = _chunk5VHPTLLVcjs.detectFields; exports.duplicate = _chunk5VHPTLLVcjs.duplicate; exports.evaluate = _chunk7NZPYWL3cjs.evaluate; exports.extractShapes = _chunk5VHPTLLVcjs.extractShapes; exports.fieldStates = _chunk7NZPYWL3cjs.fieldStates; exports.fitInPage = _chunk5VHPTLLVcjs.fitInPage; exports.isFilled = _chunk5VHPTLLVcjs.isFilled; exports.keyFor = _chunk5VHPTLLVcjs.keyFor; exports.matches = _chunk5VHPTLLVcjs.matches; exports.moveBy = _chunk5VHPTLLVcjs.moveBy; exports.newField = _chunk5VHPTLLVcjs.newField; exports.pickedOf = _chunk5VHPTLLVcjs.pickedOf; exports.reorder = _chunk5VHPTLLVcjs.reorder; exports.resizeBy = _chunk5VHPTLLVcjs.resizeBy; exports.snap = _chunk5VHPTLLVcjs.snap; exports.toLines = _chunk5VHPTLLVcjs.toLines; exports.toQuestions = _chunk5VHPTLLVcjs.toQuestions; exports.uniqueKey = _chunk5VHPTLLVcjs.uniqueKey; exports.validateAnswers = _chunk7NZPYWL3cjs.validateAnswers; exports.validateFields = _chunk7NZPYWL3cjs.validateFields; exports.validateLayout = _chunk7NZPYWL3cjs.validateLayout; exports.withField = _chunk5VHPTLLVcjs.withField;
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ exports.FIELD_TYPES = _chunk7NZPYWL3cjs.FIELD_TYPES; exports.FONTS = _chunk7NZPYWL3cjs.FONTS; exports.MAX_ELEMENTS = _chunk7NZPYWL3cjs.MAX_ELEMENTS; exports.MAX_FIELDS = _chunk7NZPYWL3cjs.MAX_FIELDS; exports.MAX_PAGES = _chunk7NZPYWL3cjs.MAX_PAGES; exports.MAX_SIGNATURE_CHARS = _chunk7NZPYWL3cjs.MAX_SIGNATURE_CHARS; exports.OPERATORS = _chunk7NZPYWL3cjs.OPERATORS; exports.answeredFilter = _chunk33XWO4KBcjs.answeredFilter; exports.builtinFilters = _chunk33XWO4KBcjs.builtinFilters; exports.categoryFilter = _chunk33XWO4KBcjs.categoryFilter; exports.checkAnswer = _chunk7NZPYWL3cjs.checkAnswer; exports.choiceFilter = _chunk33XWO4KBcjs.choiceFilter; exports.choicesOf = _chunk33XWO4KBcjs.choicesOf; exports.cleanAnswers = _chunk7NZPYWL3cjs.cleanAnswers; exports.customFilter = _chunk33XWO4KBcjs.customFilter; exports.defaultAnswers = _chunk7NZPYWL3cjs.defaultAnswers; exports.defaultLayout = _chunk7NZPYWL3cjs.defaultLayout; exports.detectDocument = _chunk33XWO4KBcjs.detectDocument; exports.detectFields = _chunk33XWO4KBcjs.detectFields; exports.duplicate = _chunk33XWO4KBcjs.duplicate; exports.evaluate = _chunk7NZPYWL3cjs.evaluate; exports.extractShapes = _chunk33XWO4KBcjs.extractShapes; exports.fieldStates = _chunk7NZPYWL3cjs.fieldStates; exports.filterQuestions = _chunk33XWO4KBcjs.filterQuestions; exports.fitInPage = _chunk33XWO4KBcjs.fitInPage; exports.isFilled = _chunk33XWO4KBcjs.isFilled; exports.keyFor = _chunk33XWO4KBcjs.keyFor; exports.moveBy = _chunk33XWO4KBcjs.moveBy; exports.newField = _chunk33XWO4KBcjs.newField; exports.partFilter = _chunk33XWO4KBcjs.partFilter; exports.pickedFilter = _chunk33XWO4KBcjs.pickedFilter; exports.pickedOf = _chunk33XWO4KBcjs.pickedOf; exports.reorder = _chunk33XWO4KBcjs.reorder; exports.resizeBy = _chunk33XWO4KBcjs.resizeBy; exports.resolveFilters = _chunk33XWO4KBcjs.resolveFilters; exports.searchText = _chunk33XWO4KBcjs.searchText; exports.snap = _chunk33XWO4KBcjs.snap; exports.tagFilter = _chunk33XWO4KBcjs.tagFilter; exports.tagFilters = _chunk33XWO4KBcjs.tagFilters; exports.toLines = _chunk33XWO4KBcjs.toLines; exports.toQuestions = _chunk33XWO4KBcjs.toQuestions; exports.typeFilter = _chunk33XWO4KBcjs.typeFilter; exports.uniqueKey = _chunk33XWO4KBcjs.uniqueKey; exports.validateAnswers = _chunk7NZPYWL3cjs.validateAnswers; exports.validateFields = _chunk7NZPYWL3cjs.validateFields; exports.validateLayout = _chunk7NZPYWL3cjs.validateLayout; exports.withField = _chunk33XWO4KBcjs.withField;
79
101
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/harendra/Desktop/project/formlift/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2yDAAC","file":"/home/harendra/Desktop/project/formlift/dist/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/formlift/formlift/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,w5EAAC","file":"/home/runner/work/formlift/formlift/dist/index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { F as FieldDef, a as FieldType, A as AnswerValue, b as Answers, P as Position } from './form-logic-DT9Bfwfz.cjs';
2
- export { C as Condition, c as FIELD_TYPES, d as FONTS, e as FontName, L as Layout, f as LayoutElement, g as LayoutPage, M as MAX_ELEMENTS, h as MAX_FIELDS, i as MAX_PAGES, j as MAX_SIGNATURE_CHARS, O as OPERATORS, k as Operator, R as Rule, l as checkAnswer, m as cleanAnswers, n as defaultAnswers, o as defaultLayout, p as evaluate, q as fieldStates, v as validateAnswers, r as validateFields, s as validateLayout } from './form-logic-DT9Bfwfz.cjs';
3
- import { T as TextLine } from './layout-ExhBeO6b.cjs';
4
- export { P as PdfTextItem, t as toLines } from './layout-ExhBeO6b.cjs';
1
+ import { F as FieldDef, a as FieldType, P as Position } from './form-logic-DT9Bfwfz.cjs';
2
+ export { A as AnswerValue, b as Answers, C as Condition, c as FIELD_TYPES, d as FONTS, e as FontName, L as Layout, f as LayoutElement, g as LayoutPage, M as MAX_ELEMENTS, h as MAX_FIELDS, i as MAX_PAGES, j as MAX_SIGNATURE_CHARS, O as OPERATORS, k as Operator, R as Rule, l as checkAnswer, m as cleanAnswers, n as defaultAnswers, o as defaultLayout, p as evaluate, q as fieldStates, v as validateAnswers, r as validateFields, s as validateLayout } from './form-logic-DT9Bfwfz.cjs';
3
+ import { T as TextLine } from './filters-q6gqilzw.cjs';
4
+ export { F as FilterOption, a as FilterSource, b as FilterValues, P as PageText, c as PdfTextItem, Q as Question, d as QuestionFilterDef, e as ToQuestionsOptions, f as answeredFilter, g as builtinFilters, h as categoryFilter, i as choiceFilter, j as choicesOf, k as customFilter, l as filterQuestions, m as isFilled, p as partFilter, n as pickedFilter, o as pickedOf, r as resolveFilters, s as searchText, t as tagFilter, q as tagFilters, u as toLines, v as toQuestions, w as typeFilter } from './filters-q6gqilzw.cjs';
5
5
 
6
6
  /** A key not used yet: text_1, text_2… */
7
7
  declare function uniqueKey(base: string, fields: FieldDef[]): string;
@@ -101,57 +101,6 @@ declare function detectDocument(pdf: PdfDoc, OPS: Ops, pages: {
101
101
  height: number;
102
102
  }[], existing: FieldDef[], onProgress?: (done: number, total: number) => void, signal?: AbortSignal): Promise<FieldDef[]>;
103
103
 
104
- interface Question {
105
- id: string;
106
- title: string;
107
- page: number;
108
- parts: {
109
- field: FieldDef;
110
- name: string;
111
- }[];
112
- /** Option grid or table: parts per line of the document, to lay them out in the same rows. */
113
- rows?: number[];
114
- /** Table: its column names (parts are row by row, left to right), and each row's own name when rows have one. */
115
- columns?: string[];
116
- rowNames?: string[];
117
- /** The category heading the question sits under (e.g. "HW", "PR", "HF" in inspection checklists), when the form has them. */
118
- category?: string;
119
- /** The numbered question heading it answers ("2.1.1 Maintenance of statutory Certificates"), when written above. */
120
- section?: string;
121
- /** A column of boxes named by the text block left of it (its options come first). */
122
- block?: boolean;
123
- /** "Classification: Core , Risk: H , Assigned to: MASTER" written in its numbered question: filters. */
124
- tags?: Record<string, string>;
125
- /** What a run of rows with the same choices asks ("Evaluation of the level of compliance…"), shown over them. */
126
- intro?: string;
127
- }
128
- /** Text lines of a form page (page fractions, top-left origin, as field positions), when known. */
129
- type PageText = (page: number) => TextLine[] | undefined;
130
- /** Questions in document order: page, then top to bottom. */
131
- declare function toQuestions(fields: FieldDef[], textOf?: PageText): Question[];
132
- type Filled = 'all' | 'filled' | 'empty';
133
- interface QuestionFilter {
134
- search: string;
135
- answered: Filled;
136
- remarks: Filled;
137
- comments: Filled;
138
- type: FieldType | 'all';
139
- category: string;
140
- /** Tag key → value ("Risk" → "H"). */
141
- tags: Record<string, string>;
142
- /** Questions that offer this answer choice ("Yes", "As Expected"). */
143
- choices: string;
144
- /** Questions answered with this choice ("Not as Expected"). */
145
- picked: string;
146
- }
147
- declare const NO_FILTER: QuestionFilter;
148
- declare const isFilled: (v: AnswerValue | undefined) => boolean;
149
- /** A question's answer choices ("Yes", "No", "NA"), from its boxes or its radio buttons. */
150
- declare function choicesOf(q: Question): string[];
151
- /** The choices ticked in a question's answers. */
152
- declare function pickedOf(q: Question, answers: Answers): string[];
153
- declare function matches(q: Question, answers: Answers, f: QuestionFilter): boolean;
154
-
155
104
  /** Snaps a fraction to the grid (`grid` = step as a fraction of the page, 0 = off). */
156
105
  declare const snap: (n: number, grid: number) => number;
157
106
  /** Keeps a box inside its page and at least MIN_SIZE big. */
@@ -161,4 +110,4 @@ declare function moveBy(p: Position, dx: number, dy: number, grid?: number): Pos
161
110
  /** Resizes from the bottom-right corner by a fraction delta, snapped, kept inside the page. */
162
111
  declare function resizeBy(p: Position, dw: number, dh: number, grid?: number): Position;
163
112
 
164
- export { AnswerValue, Answers, FieldDef, FieldType, type Filled, NO_FILTER, type Ops, type PageText, Position, type Question, type QuestionFilter, type Rect, type Seg, type Shapes, TextLine, choicesOf, detectDocument, detectFields, duplicate, extractShapes, fitInPage, isFilled, keyFor, matches, moveBy, newField, pickedOf, reorder, resizeBy, snap, toQuestions, uniqueKey, withField };
113
+ export { FieldDef, FieldType, type Ops, Position, type Rect, type Seg, type Shapes, TextLine, detectDocument, detectFields, duplicate, extractShapes, fitInPage, keyFor, moveBy, newField, reorder, resizeBy, snap, uniqueKey, withField };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { F as FieldDef, a as FieldType, A as AnswerValue, b as Answers, P as Position } from './form-logic-DT9Bfwfz.js';
2
- export { C as Condition, c as FIELD_TYPES, d as FONTS, e as FontName, L as Layout, f as LayoutElement, g as LayoutPage, M as MAX_ELEMENTS, h as MAX_FIELDS, i as MAX_PAGES, j as MAX_SIGNATURE_CHARS, O as OPERATORS, k as Operator, R as Rule, l as checkAnswer, m as cleanAnswers, n as defaultAnswers, o as defaultLayout, p as evaluate, q as fieldStates, v as validateAnswers, r as validateFields, s as validateLayout } from './form-logic-DT9Bfwfz.js';
3
- import { T as TextLine } from './layout-ExhBeO6b.js';
4
- export { P as PdfTextItem, t as toLines } from './layout-ExhBeO6b.js';
1
+ import { F as FieldDef, a as FieldType, P as Position } from './form-logic-DT9Bfwfz.js';
2
+ export { A as AnswerValue, b as Answers, C as Condition, c as FIELD_TYPES, d as FONTS, e as FontName, L as Layout, f as LayoutElement, g as LayoutPage, M as MAX_ELEMENTS, h as MAX_FIELDS, i as MAX_PAGES, j as MAX_SIGNATURE_CHARS, O as OPERATORS, k as Operator, R as Rule, l as checkAnswer, m as cleanAnswers, n as defaultAnswers, o as defaultLayout, p as evaluate, q as fieldStates, v as validateAnswers, r as validateFields, s as validateLayout } from './form-logic-DT9Bfwfz.js';
3
+ import { T as TextLine } from './filters-Yzd4tG8r.js';
4
+ export { F as FilterOption, a as FilterSource, b as FilterValues, P as PageText, c as PdfTextItem, Q as Question, d as QuestionFilterDef, e as ToQuestionsOptions, f as answeredFilter, g as builtinFilters, h as categoryFilter, i as choiceFilter, j as choicesOf, k as customFilter, l as filterQuestions, m as isFilled, p as partFilter, n as pickedFilter, o as pickedOf, r as resolveFilters, s as searchText, t as tagFilter, q as tagFilters, u as toLines, v as toQuestions, w as typeFilter } from './filters-Yzd4tG8r.js';
5
5
 
6
6
  /** A key not used yet: text_1, text_2… */
7
7
  declare function uniqueKey(base: string, fields: FieldDef[]): string;
@@ -101,57 +101,6 @@ declare function detectDocument(pdf: PdfDoc, OPS: Ops, pages: {
101
101
  height: number;
102
102
  }[], existing: FieldDef[], onProgress?: (done: number, total: number) => void, signal?: AbortSignal): Promise<FieldDef[]>;
103
103
 
104
- interface Question {
105
- id: string;
106
- title: string;
107
- page: number;
108
- parts: {
109
- field: FieldDef;
110
- name: string;
111
- }[];
112
- /** Option grid or table: parts per line of the document, to lay them out in the same rows. */
113
- rows?: number[];
114
- /** Table: its column names (parts are row by row, left to right), and each row's own name when rows have one. */
115
- columns?: string[];
116
- rowNames?: string[];
117
- /** The category heading the question sits under (e.g. "HW", "PR", "HF" in inspection checklists), when the form has them. */
118
- category?: string;
119
- /** The numbered question heading it answers ("2.1.1 Maintenance of statutory Certificates"), when written above. */
120
- section?: string;
121
- /** A column of boxes named by the text block left of it (its options come first). */
122
- block?: boolean;
123
- /** "Classification: Core , Risk: H , Assigned to: MASTER" written in its numbered question: filters. */
124
- tags?: Record<string, string>;
125
- /** What a run of rows with the same choices asks ("Evaluation of the level of compliance…"), shown over them. */
126
- intro?: string;
127
- }
128
- /** Text lines of a form page (page fractions, top-left origin, as field positions), when known. */
129
- type PageText = (page: number) => TextLine[] | undefined;
130
- /** Questions in document order: page, then top to bottom. */
131
- declare function toQuestions(fields: FieldDef[], textOf?: PageText): Question[];
132
- type Filled = 'all' | 'filled' | 'empty';
133
- interface QuestionFilter {
134
- search: string;
135
- answered: Filled;
136
- remarks: Filled;
137
- comments: Filled;
138
- type: FieldType | 'all';
139
- category: string;
140
- /** Tag key → value ("Risk" → "H"). */
141
- tags: Record<string, string>;
142
- /** Questions that offer this answer choice ("Yes", "As Expected"). */
143
- choices: string;
144
- /** Questions answered with this choice ("Not as Expected"). */
145
- picked: string;
146
- }
147
- declare const NO_FILTER: QuestionFilter;
148
- declare const isFilled: (v: AnswerValue | undefined) => boolean;
149
- /** A question's answer choices ("Yes", "No", "NA"), from its boxes or its radio buttons. */
150
- declare function choicesOf(q: Question): string[];
151
- /** The choices ticked in a question's answers. */
152
- declare function pickedOf(q: Question, answers: Answers): string[];
153
- declare function matches(q: Question, answers: Answers, f: QuestionFilter): boolean;
154
-
155
104
  /** Snaps a fraction to the grid (`grid` = step as a fraction of the page, 0 = off). */
156
105
  declare const snap: (n: number, grid: number) => number;
157
106
  /** Keeps a box inside its page and at least MIN_SIZE big. */
@@ -161,4 +110,4 @@ declare function moveBy(p: Position, dx: number, dy: number, grid?: number): Pos
161
110
  /** Resizes from the bottom-right corner by a fraction delta, snapped, kept inside the page. */
162
111
  declare function resizeBy(p: Position, dw: number, dh: number, grid?: number): Position;
163
112
 
164
- export { AnswerValue, Answers, FieldDef, FieldType, type Filled, NO_FILTER, type Ops, type PageText, Position, type Question, type QuestionFilter, type Rect, type Seg, type Shapes, TextLine, choicesOf, detectDocument, detectFields, duplicate, extractShapes, fitInPage, isFilled, keyFor, matches, moveBy, newField, pickedOf, reorder, resizeBy, snap, toQuestions, uniqueKey, withField };
113
+ export { FieldDef, FieldType, type Ops, Position, type Rect, type Seg, type Shapes, TextLine, detectDocument, detectFields, duplicate, extractShapes, fitInPage, keyFor, moveBy, newField, reorder, resizeBy, snap, uniqueKey, withField };