pict-section-form 1.3.6 → 1.3.8

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.
@@ -45,7 +45,8 @@ pict.addProvider(
45
45
  "InputType": "Diagram",
46
46
  "Diagram": {
47
47
  "ThemeColors": true,
48
- "Height": "480px",
48
+ "Height": "640px",
49
+ "FormFactor": "pointer",
49
50
  "EditorImplementation": "react"
50
51
  }
51
52
  }
@@ -72,7 +73,37 @@ so the SVG re-opens cleanly in any Excalidraw-aware viewer.
72
73
 
73
74
  ### Height
74
75
 
75
- CSS string applied to the slot when the field is in edit mode.
76
+ Starting height of the canvas while the field is in **edit mode**. A CSS length
77
+ (`"640px"`, `"40rem"`) or a bare number, which is read as pixels (`640` and
78
+ `"640"` both mean `640px`). Defaults to `560px`.
79
+
80
+ Height is worth setting deliberately, because Excalidraw scales its own UI to
81
+ the box it is given: below roughly 500px it decides it is on a phone and folds
82
+ the shape properties away behind a popover, and the left-hand properties island
83
+ starts to clip into a scrolling sliver. `560px` is the smallest height that
84
+ avoids both.
85
+
86
+ Users can also drag the bottom-right grip to resize the canvas (the same
87
+ affordance a `textarea` has). A height they drag to is remembered per field in
88
+ `localStorage` and wins over `Height` on the next open; the field falls back to
89
+ `Height` wherever storage is unavailable. Read and Print themes are unaffected —
90
+ they render the static SVG at its natural size.
91
+
92
+ ### FormFactor
93
+
94
+ How Excalidraw should classify the editor when picking how dense its UI is.
95
+
96
+ | Value | Behaviour |
97
+ |---|---|
98
+ | `"pointer"` *(default)* | Desktop chrome on a mouse; Excalidraw's own answer on a touch screen. |
99
+ | `"auto"` | Excalidraw decides, from the size of the container. |
100
+ | `"desktop"` / `"tablet"` / `"phone"` | Pin it. |
101
+
102
+ Excalidraw's own detection reads the **container's** box — right for
103
+ excalidraw.com, where the container is the viewport, and wrong for a form field,
104
+ where a 560px-tall box on a 27" monitor is not a phone. `"pointer"` classifies
105
+ by input device instead, so the full properties island stays put at any field
106
+ width. Set `"auto"` to opt back out.
76
107
 
77
108
  ### EditorImplementation
78
109
 
@@ -44,6 +44,13 @@ A more complex tabular form example that uses the fruit data again
44
44
  and performs mathematical solves across each row, and aggregation
45
45
  functions down. Single file, all configuration, no code.
46
46
 
47
+ ### Section Visibility
48
+
49
+ A regression harness for solver-driven section and group visibility. Renaming
50
+ a product re-renders every table whose columns are generated from it; the hide
51
+ class lives on an element that render regenerates, so it used to be dropped.
52
+ Single file, all configuration.
53
+
47
54
  ## Advanced
48
55
 
49
56
  ### Postcard
@@ -66,6 +73,7 @@ gradebook
66
73
  manifest_testbed
67
74
  manyfest_editor
68
75
  postcard_example
76
+ section_visibility
69
77
  simple_form
70
78
  simple_table
71
79
  simple_table_from_object
@@ -0,0 +1,9 @@
1
+ {
2
+ "GulpExecutions": [
3
+ {
4
+ "Hash": "default",
5
+ "Name": "Default standard build.",
6
+ "BuildFileLabel": "",
7
+ "BrowsersListRC": "since 2022"
8
+ }]
9
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "Workflow":
3
+ {
4
+ "ShowGradation": 0
5
+ },
6
+
7
+ "Products":
8
+ [
9
+ { "IDProduct": 1, "ProductName": "Limestone 3/4\"" },
10
+ { "IDProduct": 2, "ProductName": "Natural Sand" },
11
+ { "IDProduct": 3, "ProductName": "RAP" }
12
+ ],
13
+
14
+ "Gradation":
15
+ [
16
+ { "SieveSize": "1/2\"", "Passing": { "1": 100, "2": 100, "3": 98 } },
17
+ { "SieveSize": "#4", "Passing": { "1": 42, "2": 96, "3": 71 } },
18
+ { "SieveSize": "#8", "Passing": { "1": 22, "2": 84, "3": 55 } },
19
+ { "SieveSize": "#200", "Passing": { "1": 1.8, "2": 4.2, "3": 6.1 } }
20
+ ]
21
+ }
@@ -0,0 +1,43 @@
1
+ # Section Visibility
2
+
3
+ A regression harness for solver-driven section and group visibility surviving a re-render.
4
+
5
+ ## What it demonstrates
6
+
7
+ `setsectionvisibility` and `setgroupvisibility` apply a CSS class to `#SECTION-<formID>` and
8
+ `#GROUP-<formID>-<hash>`. Both of those elements are emitted **by the section template**, so a
9
+ `render()` repaints them carrying only their manifest `CSSClass` — and the hide is silently dropped.
10
+
11
+ Nothing used to put it back. Solvers run in the SOLVE phase; the renders that destroy the class
12
+ happen later in the MARSHAL, so a hidden section stayed wrongly visible until some later solve
13
+ happened to run. Adding another `SetSectionVisibility` call in a PostSolver does not help — that is
14
+ still solve-phase, still before the render.
15
+
16
+ The `Average Gradation` table here generates one column per `Products` row, labeled from that row's
17
+ name. Renaming a product is a **label-only** change: the column set is identical, so the Tabular
18
+ layout takes its `namesChanged` path — a `render()` with no template rebuild. That render is what
19
+ destroys the hide.
20
+
21
+ ## Reproducing
22
+
23
+ ```shell
24
+ npx quack examples
25
+ ```
26
+
27
+ 1. On load, `Average Gradation` is hidden (`Show Gradation` unchecked).
28
+ 2. Rename a product in `Aggregate Products` and tab out.
29
+ 3. Before the fix the section reappears with the box still unchecked. After it, the section stays
30
+ hidden and its headers still relabel — tick the box to see the updated column names.
31
+
32
+ `Show Notes` toggles the **Gradation Notes** group inside that same section, which fails and passes the
33
+ same way — tick `Show Gradation` first so the section is visible, then rename a product. The group has to
34
+ live inside a section that actually re-renders; a group in an untouched section is never regenerated.
35
+
36
+ `Flag the #200 Row` covers the same defect one layer down. `highlighttabularrow` puts a class on a `<tr>`
37
+ that the same render regenerates, so the highlight was dropped too. Every DOM-decorating solver — the
38
+ highlight pair, the tabular row/column colors, and the section/group/input background colors — shares this
39
+ and is restored by the same replay. `MI-BatchSheetCombined` calls `highlighttabularrow(…, "is-hidden")` to
40
+ hide rows inside its CSB tables, so there the symptom is a hidden row coming back.
41
+
42
+ Reported against a Headlight combined form (`MI-BatchSheetCombined`), where picking a Source/Name on
43
+ the Aggregate Products table un-hid every CSB worksheet generated from it.
@@ -0,0 +1,201 @@
1
+ /*
2
+ Regression harness for solver-driven SECTION and GROUP visibility.
3
+
4
+ The hide class that setsectionvisibility / setgroupvisibility applies lives on
5
+ #SECTION-<formID> / #GROUP-<formID>-<hash> -- and BOTH of those elements are emitted by the
6
+ section template. So any render() repaints them carrying only their manifest CSSClass and the
7
+ hide is dropped. Renaming a product below is exactly that: it changes a generated column LABEL,
8
+ which re-renders every table whose DynamicColumns are sourced from the Products table.
9
+
10
+ Repro (see html/index.html for the same steps in the page):
11
+ 1. Load. "Average Gradation" is hidden -- Show Gradation is unchecked.
12
+ 2. Rename any product in the Products table and tab out.
13
+ 3. BEFORE the fix: "Average Gradation" reappears, still unchecked.
14
+ AFTER the fix: it stays hidden, and its column headers still relabel.
15
+
16
+ The "Gradation Notes" group inside that section is the group-level equivalent: tick Show
17
+ Gradation so the section is visible, leave Show Notes unchecked, then rename a product.
18
+
19
+ "Flag the #200 Row" covers the same defect one layer down: highlighttabularrow puts a class on
20
+ a <tr> that the very same render regenerates. MI-BatchSheetCombined uses that solver with
21
+ "is-hidden" to hide rows inside its CSB tables, so there the symptom is a hidden row coming back.
22
+ */
23
+ const libPictSectionForm = require('../../source/Pict-Section-Form.js');
24
+
25
+ module.exports = libPictSectionForm.PictFormApplication;
26
+
27
+ module.exports.default_configuration = libPictSectionForm.PictFormApplication.default_configuration;
28
+ module.exports.default_configuration.pict_configuration = (
29
+ {
30
+ "Product": "SectionVisibility",
31
+
32
+ "DefaultAppData": require('./ProductData.json'),
33
+
34
+ "DefaultFormManifest":
35
+ {
36
+ "Scope": "SectionVisibilityForm",
37
+
38
+ "Sections":
39
+ [
40
+ {
41
+ "Hash": "Workflow",
42
+ "Name": "Worksheet Selection",
43
+
44
+ "Solvers":
45
+ [
46
+ "SetSectionVisibility(\"Gradation\", IF(ShowGradation, \"==\", 1, 1, 0))",
47
+ "SetGroupVisibility(\"Gradation\", \"GradationNotes\", IF(ShowNotes, \"==\", 1, 1, 0))",
48
+ "highlighttabularrow(\"Gradation\", \"Gradation\", 3, IF(FlagFinesRow, \"==\", 1, 1, 0))"
49
+ ],
50
+
51
+ "Groups": [ { "Hash": "Workflow", "Name": "Show / Hide Worksheets" } ]
52
+ },
53
+ {
54
+ "Hash": "Products",
55
+ "Name": "Aggregate Products",
56
+
57
+ "Groups":
58
+ [
59
+ {
60
+ "Hash": "Products",
61
+ "Name": "Products",
62
+
63
+ "Layout": "Tabular",
64
+
65
+ "RecordSetAddress": "Products",
66
+ "RecordManifest": "ProductEditor"
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ "Hash": "Gradation",
72
+ "Name": "Average Gradation",
73
+
74
+ "Groups":
75
+ [
76
+ {
77
+ "Hash": "Gradation",
78
+ "Name": "Percent Passing",
79
+
80
+ "Layout": "Tabular",
81
+
82
+ "RecordSetAddress": "Gradation",
83
+ "RecordManifest": "GradationRowEditor",
84
+
85
+ // One generated column per Products row, labeled from that row's name.
86
+ // Renaming a product is a label-only change: the column SET is identical,
87
+ // so this takes the Tabular layout's namesChanged render() path.
88
+ "DynamicColumns":
89
+ [
90
+ {
91
+ "SourceAddress": "Products",
92
+ "HashTemplate": "PassingCol_{~D:Record.IDProduct~}",
93
+ "NameTemplate": "{~D:Record.ProductName~}",
94
+ "InformaryDataAddressTemplate": "Passing.{~D:Record.IDProduct~}",
95
+ "DataType": "Number",
96
+ "PictForm": { "InputType": "Number" }
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ "Hash": "GradationNotes",
102
+ "Name": "Gradation Notes"
103
+ }
104
+ ]
105
+ }
106
+ ],
107
+
108
+ "Descriptors":
109
+ {
110
+ "Workflow.ShowGradation":
111
+ {
112
+ "Name": "Show Gradation",
113
+ "Hash": "ShowGradation",
114
+ "DataType": "Boolean",
115
+ "Default": 0,
116
+ "PictForm": { "InputType": "Boolean", "Section": "Workflow", "Group": "Workflow", "Row": 1 }
117
+ },
118
+ "Workflow.FlagFinesRow":
119
+ {
120
+ "Name": "Flag the #200 Row",
121
+ "Hash": "FlagFinesRow",
122
+ "DataType": "Boolean",
123
+ "Default": 0,
124
+ "PictForm": { "InputType": "Boolean", "Section": "Workflow", "Group": "Workflow", "Row": 2 }
125
+ },
126
+ "Workflow.ShowNotes":
127
+ {
128
+ "Name": "Show Product Notes",
129
+ "Hash": "ShowNotes",
130
+ "DataType": "Boolean",
131
+ "Default": 0,
132
+ "PictForm": { "InputType": "Boolean", "Section": "Workflow", "Group": "Workflow", "Row": 1 }
133
+ },
134
+
135
+ "Products":
136
+ {
137
+ "Name": "Aggregate Products",
138
+ "Hash": "ProductGrid",
139
+ "DataType": "Array",
140
+ "Default": [],
141
+ "PictForm": { "Section": "Products", "Group": "Products" }
142
+ },
143
+ "Gradation":
144
+ {
145
+ "Name": "Average Gradation",
146
+ "Hash": "GradationGrid",
147
+ "DataType": "Array",
148
+ "Default": [],
149
+ "PictForm": { "Section": "Gradation", "Group": "Gradation" }
150
+ },
151
+ "Workflow.GradationNote":
152
+ {
153
+ "Name": "Note",
154
+ "Hash": "GradationNote",
155
+ "DataType": "String",
156
+ "PictForm": { "Section": "Gradation", "Group": "GradationNotes", "Row": 1 }
157
+ }
158
+ },
159
+
160
+ "ReferenceManifests":
161
+ {
162
+ "ProductEditor":
163
+ {
164
+ "Scope": "ProductEditor",
165
+ "Descriptors":
166
+ {
167
+ "IDProduct":
168
+ {
169
+ "Name": "ID",
170
+ "Hash": "IDProduct",
171
+ "DataType": "Number",
172
+ "PictForm": { "Section": "Products", "Group": "Products" }
173
+ },
174
+ "ProductName":
175
+ {
176
+ "Name": "Product Name",
177
+ "Hash": "ProductName",
178
+ "DataType": "String",
179
+ "Default": "(unnamed product)",
180
+ "PictForm": { "Section": "Products", "Group": "Products" }
181
+ }
182
+ }
183
+ },
184
+
185
+ "GradationRowEditor":
186
+ {
187
+ "Scope": "GradationRowEditor",
188
+ "Descriptors":
189
+ {
190
+ "SieveSize":
191
+ {
192
+ "Name": "Sieve",
193
+ "Hash": "SieveSize",
194
+ "DataType": "String",
195
+ "PictForm": { "Section": "Gradation", "Group": "Gradation" }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ }
201
+ });
@@ -0,0 +1,73 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Section Visibility - Pict Example</title>
7
+ <!-- PICT Dynamic View CSS Container -->
8
+ <style id="PICT-CSS"></style>
9
+ <style>
10
+ *, *::before, *::after { box-sizing: border-box; }
11
+ body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: #FAEDCD; color: #264653; }
12
+
13
+ .pict-example-header { display: flex; align-items: stretch; background: #264653; border-bottom: 3px solid #E76F51; }
14
+ .pict-example-badge { background: #E76F51; color: #fff; padding: 0.6rem 1rem; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; display: flex; align-items: center; gap: 0.5rem; }
15
+ .pict-example-badge svg { width: 14px; height: 14px; fill: #fff; flex-shrink: 0; }
16
+ .pict-example-app-name { padding: 0.6rem 1rem; color: #FAEDCD; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; }
17
+ .pict-example-module { margin-left: auto; padding: 0.6rem 1rem; color: #D4A373; font-size: 0.75rem; display: flex; align-items: center; letter-spacing: 0.03em; }
18
+
19
+ .pict-example-content { padding: 1.5rem; }
20
+
21
+ .pict-example-steps { background: #fff; border: 1px solid #D4A373; border-left: 4px solid #264653; border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; font-size: 0.9rem; line-height: 1.5; }
22
+ .pict-example-steps h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
23
+ .pict-example-steps ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
24
+ .pict-example-steps code { background: #FFF3E4; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
25
+ .pict-example-steps .pict-example-expect { margin: 0; padding-top: 0.6rem; border-top: 1px dashed #E8D9C0; }
26
+ .pict-example-steps .pict-example-bad { color: #B23A24; font-weight: 600; }
27
+ .pict-example-steps .pict-example-good { color: #2A7F5F; font-weight: 600; }
28
+
29
+ #Pict-Form-Container { background: #fff; border: 1px solid #D4A373; border-top: 4px solid #E76F51; border-radius: 6px; padding: 1.25rem; box-shadow: 0 2px 8px rgba(38,70,83,0.08); }
30
+
31
+ #Pict-Form-Container input[type="text"],
32
+ #Pict-Form-Container input[type="number"],
33
+ #Pict-Form-Container select { border: 1px solid #D4C4A8; background: #FFFCF7; padding: 0.45rem 0.6rem; border-radius: 4px; font-size: 0.9rem; color: #264653; width: 100%; }
34
+ #Pict-Form-Container input[type="checkbox"] { width: auto; }
35
+ #Pict-Form-Container input:focus, #Pict-Form-Container select:focus { outline: none; border-color: #E76F51; box-shadow: 0 0 0 2px rgba(231,111,81,0.15); }
36
+ #Pict-Form-Container label { color: #264653; font-weight: 600; font-size: 0.85rem; }
37
+ #Pict-Form-Container h2, #Pict-Form-Container h3 { color: #264653; }
38
+ #Pict-Form-Container table { width: 100%; border-collapse: collapse; }
39
+ #Pict-Form-Container th { background: #264653; color: #FAEDCD; padding: 0.5rem 0.75rem; text-align: left; font-size: 0.8rem; }
40
+ #Pict-Form-Container td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #E8D9C0; font-size: 0.85rem; }
41
+ #Pict-Form-Container tr:nth-child(even) td { background: #FFF9F0; }
42
+ </style>
43
+ <script src="./pict.min.js" type="text/javascript"></script>
44
+ <script type="text/javascript">Pict.safeOnDocumentReady(() => { Pict.safeLoadPictApplication(SectionVisibilityApplication, 3)});</script>
45
+ </head>
46
+ <body>
47
+ <div class="pict-example-header">
48
+ <div class="pict-example-badge">
49
+ <svg viewBox="0 0 16 16"><polygon points="8,1 10,6 16,6 11,9.5 13,15 8,11.5 3,15 5,9.5 0,6 6,6"/></svg>
50
+ Pict Example
51
+ </div>
52
+ <div class="pict-example-app-name">Section Visibility</div>
53
+ <div class="pict-example-module">pict-section-form</div>
54
+ </div>
55
+ <div class="pict-example-content">
56
+ <div class="pict-example-steps">
57
+ <h3>Does solver-driven visibility survive a re-render?</h3>
58
+ <ol>
59
+ <li>On load, <strong>Average Gradation</strong> is hidden &mdash; <code>Show Gradation</code> is unchecked and the section solver hid it.</li>
60
+ <li>Rename any product in <strong>Aggregate Products</strong> and tab out. That changes a generated column <em>label</em>, so every section whose columns come from Products re-renders.</li>
61
+ <li>For the <em>group</em> equivalent: tick <code>Show Gradation</code> so the section is visible, leave <code>Show Notes</code> unchecked, and rename a product again &mdash; the hidden <strong>Gradation Notes</strong> group inside it behaves the same way.</li>
62
+ <li>For the <em>row</em> equivalent: with Gradation visible, tick <code>Flag the #200 Row</code> to highlight it, then rename a product once more.</li>
63
+ </ol>
64
+ <p class="pict-example-expect">
65
+ <span class="pict-example-bad">Broken:</span> Average Gradation (or the Gradation Notes group) reappears with its box still unchecked, and the row highlight vanishes.<br>
66
+ <span class="pict-example-good">Fixed:</span> everything stays as you left it &mdash; hidden stays hidden, the flagged row stays flagged &mdash; and the column headers still pick up the new product name.
67
+ </p>
68
+ </div>
69
+ <div id="Pict-Form-Container"></div>
70
+ </div>
71
+ <script src="./section_visibility_application.min.js" type="text/javascript"></script>
72
+ </body>
73
+ </html>
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "section_visibility_application",
3
+ "version": "1.0.0",
4
+ "description": "Section visibility survives a DynamicColumns re-render.",
5
+ "main": "Section-Visibility-Application.js",
6
+ "scripts": {
7
+ "start": "node Section-Visibility-Application.js",
8
+ "build": "npx quack build && npx quack copy"
9
+ },
10
+ "author": "steven",
11
+ "license": "MIT",
12
+ "devDependencies": {},
13
+ "copyFilesSettings": {
14
+ "whenFileExists": "overwrite"
15
+ },
16
+ "copyFiles": [
17
+ {
18
+ "from": "./html/*",
19
+ "to": "./dist/"
20
+ },
21
+ {
22
+ "from": "../../node_modules/pict/dist/*",
23
+ "to": "./dist/"
24
+ }
25
+ ],
26
+ "retold": {
27
+ "ExampleApplication": {
28
+ "Stage": true,
29
+ "Title": "Section Visibility",
30
+ "Summary": "A regression harness for solver-driven section and group visibility surviving a DynamicColumns re-render. Renaming a source row re-renders every dependent table; the hide class lives on an element that render regenerates, so it used to be silently dropped.",
31
+ "Complexity": "Basic"
32
+ }
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Pict dynamic forms",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {