@gramlot/gramlot 0.3.24 → 0.3.27
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/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +21 -20
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/modules/chunk-74O4WKIV.js +1 -0
- package/dist/components/editors/assets/modules/{code-mirror-engine-QX4A5FVO.js → code-mirror-engine-RWQTR5G5.js} +29 -29
- package/dist/components/editors/assets/modules/{jodit-engine-MMSPIWM7.js → jodit-engine-MTSA4GZ3.js} +292 -292
- package/dist/components/editors/assets/modules/markdown-document-VFC23FAY.js +1 -0
- package/dist/components/editors/assets/modules/{prose-mirror-engine-IXTRTG6B.js → prose-mirror-engine-GMZPJPNN.js} +13 -13
- package/dist/components/grid/__init__.py +3 -2
- package/dist/components/grid/assets/collection.js +77 -17
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +78 -1
- package/dist/components/grouplets/__init__.py +2 -2
- package/dist/components/grouplets/assets/collection.js +3 -20
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/grouplets/assets/modules/chunk-BLMUM44K.js +1 -0
- package/dist/components/grouplets/assets/modules/markdown-document-YWNZTOKK.js +1 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +59 -34
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +64 -0
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +67 -57
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +35 -0
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/selection_trial/grammar.json +35 -0
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +26 -23
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +341 -1
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +13 -0
- package/dist/components/uploads/assets/collection.js +67 -0
- package/dist/components/uploads/assets/index.js +3 -0
- package/dist/components/uploads/commands.json +7 -0
- package/dist/components/uploads/grammar.json +789 -0
- package/dist/{components/editors/assets/modules/chunk-OCFLP2K4.js → gramlot-markdown.js} +12 -12
- package/dist/gramlot.js +5455 -573
- package/dist/gramlot.min.js +1588 -43
- package/dist/runtime-notices.json +28 -0
- package/package.json +4 -2
- package/src/binding/grid-struct.js +1 -1
- package/src/binding/providers.js +4 -1
- package/src/binding/remote-resolver.js +1 -8
- package/src/binding/runtime.js +40 -1
- package/src/binding/validation-context.js +41 -0
- package/src/browser-camera-provider.d.ts +8 -0
- package/src/browser-camera-provider.js +104 -0
- package/src/builder/source.js +13 -2
- package/src/components/attachment-manager.js +160 -0
- package/src/components/bases.js +19 -6
- package/src/components/border-container.js +86 -8
- package/src/components/buttons.js +11 -1
- package/src/components/choice-editor.js +44 -16
- package/src/components/database-choices.js +13 -8
- package/src/components/editing-status-styles.js +26 -0
- package/src/components/editing-status.js +115 -0
- package/src/components/field-state.js +44 -58
- package/src/components/grid-cell-editor.js +245 -0
- package/src/components/grid-grammar.json +42 -0
- package/src/components/grid-structure.js +5 -1
- package/src/components/grid-styles.js +60 -1
- package/src/components/grid.js +103 -11
- package/src/components/grouplet-card.js +11 -3
- package/src/components/html-preview.js +17 -4
- package/src/components/image-crop-dialog.js +272 -0
- package/src/components/image-crop.js +79 -0
- package/src/components/image-uploader.js +252 -0
- package/src/components/inputs.js +4 -3
- package/src/components/jodit-engine.js +1 -1
- package/src/components/markdown-document.js +2 -2
- package/src/components/parameters.js +6 -2
- package/src/components/screen-capture.js +43 -0
- package/src/components/selected-container.js +6 -2
- package/src/components/tree.js +417 -17
- package/src/components/typed-editor.js +19 -9
- package/src/components/upload-engine.js +156 -0
- package/src/components/uploader.js +208 -0
- package/src/components/uploads.js +7 -0
- package/src/components/validation.js +1 -1
- package/src/editing-session.d.ts +26 -0
- package/src/editing-session.js +494 -0
- package/src/editor-values.js +57 -0
- package/src/experiments/selection-trial.js +18 -2
- package/src/format.js +22 -7
- package/src/gramlot.d.ts +3 -0
- package/src/gramlot.js +9 -5
- package/src/handlers/device-handler.d.ts +2 -1
- package/src/handlers/rpc-handler.d.ts +3 -3
- package/src/index-page-styles.js +1 -0
- package/src/index.d.ts +14 -1
- package/src/index.js +13 -0
- package/src/inout.d.ts +2 -0
- package/src/inout.js +6 -0
- package/src/markdown-loader.d.ts +1 -0
- package/src/markdown-loader.js +4 -0
- package/src/markdown.d.ts +1 -0
- package/src/markdown.js +2 -0
- package/src/media-frame.js +9 -0
- package/src/renderer/attributes.js +7 -1
- package/src/renderer/gramlot-renderer.d.ts +3 -0
- package/src/renderer/gramlot-renderer.js +42 -2
- package/src/server/assets.d.ts +1 -1
- package/src/server/assets.js +1 -1
- package/src/server/gramlot-server.d.ts +8 -1
- package/src/server/gramlot-server.js +83 -7
- package/src/server/index.d.ts +2 -0
- package/src/server/index.js +2 -0
- package/src/server/page-base.js +17 -4
- package/src/server/page.d.ts +13 -1
- package/src/server/page.js +6 -0
- package/src/server/source-import.d.ts +2 -0
- package/src/server/source-import.js +35 -0
- package/src/server/upload.d.ts +20 -0
- package/src/server/upload.js +142 -0
- package/src/server/visual-editor.d.ts +11 -0
- package/src/server/visual-editor.js +159 -0
- package/src/source-picker.d.ts +9 -0
- package/src/source-picker.js +56 -0
- package/src/tree-store.d.ts +24 -0
- package/src/tree-store.js +193 -0
- package/src/validation-run.js +50 -0
- package/src/view/button.js +8 -5
- package/src/view/controls.js +9 -42
- package/src/view/html.js +10 -2
- package/src/visual-editor-canvas.js +29 -0
- package/src/visual-editor-catalogue.js +34 -0
- package/src/visual-editor-icons.js +10 -0
- package/src/visual-editor.d.ts +61 -0
- package/src/visual-editor.js +1062 -0
- package/themes/gramlot-base/theme.css +141 -0
- package/tools/gramlot-tools-inspector.js +1 -1
- package/tools/inspector-agent.js +1 -1
- package/dist/components/editors/assets/modules/chunk-MMJXUHRQ.js +0 -3
- package/src/form-state.d.ts +0 -20
- package/src/form-state.js +0 -198
|
@@ -331,3 +331,144 @@
|
|
|
331
331
|
--gramlot-grid-column-min-width: 40px;
|
|
332
332
|
--gramlot-grid-column-width: 10rem;
|
|
333
333
|
}
|
|
334
|
+
|
|
335
|
+
/* Chat controls reserve focus paint inside their measured composer regions. */
|
|
336
|
+
.gramlot-chat-editor:focus-visible { outline:2px solid var(--gramlot-focus-ring);outline-offset:-2px; }
|
|
337
|
+
.gramlot-chat-send-icon { display:block;flex:none;width:16px;height:16px;background:currentColor;
|
|
338
|
+
mask:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
|
|
339
|
+
|
|
340
|
+
/* Reusable VisualEditor composition. */
|
|
341
|
+
.visual-search-toolbar { flex:none;min-width:0;padding:2px 4px 3px;box-sizing:border-box; }
|
|
342
|
+
.visual-search-field { display:flex;align-items:center;gap:4px;width:100%;min-width:0;box-sizing:border-box;
|
|
343
|
+
min-height:24px;padding:0 6px;border:1px solid transparent;
|
|
344
|
+
border-radius:999px;background:var(--gramlot-field-background,var(--gramlot-surface));color:var(--gramlot-ink); }
|
|
345
|
+
.visual-search-field:focus-within { border-color:var(--gramlot-action);box-shadow:inset 0 0 0 1px var(--gramlot-action); }
|
|
346
|
+
.visual-search-icon { flex:none;display:block;width:13px;height:13px;background:currentColor;opacity:.6;
|
|
347
|
+
mask:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6.5' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m15 15 6 6' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
|
|
348
|
+
.visual-search-field input[type=search] { flex:1;width:100%;min-width:0;box-sizing:border-box;min-height:0;
|
|
349
|
+
margin:0;padding:1px 0;border:0;border-radius:0;outline:0;box-shadow:none;background:transparent;color:inherit;font:inherit; }
|
|
350
|
+
.visual-search-field input[type=search]:focus,
|
|
351
|
+
.visual-search-field input[type=search]:focus-visible { outline:none;box-shadow:none;background:transparent; }
|
|
352
|
+
.visual-search-field input[type=search]::-webkit-search-cancel-button,
|
|
353
|
+
.visual-search-field input[type=search]::-webkit-search-decoration { -webkit-appearance:none; }
|
|
354
|
+
.visual-search-field .visual-search-clear { display:grid;place-items:center;flex:none;width:20px;min-width:20px;height:20px;min-height:20px;
|
|
355
|
+
padding:0;margin:0;border:0;border-radius:50%;background:transparent;color:inherit;box-shadow:none;cursor:pointer; }
|
|
356
|
+
.visual-search-clear::before { content:'';width:14px;height:14px;background:currentColor;opacity:.6;
|
|
357
|
+
mask:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M10 1a9 9 0 1 0 0 18a9 9 0 0 0 0-18z M6 7.2L7.2 6L10 8.8L12.8 6L14 7.2L11.2 10L14 12.8L12.8 14L10 11.2L7.2 14L6 12.8L8.8 10z'/%3E%3C/svg%3E"); }
|
|
358
|
+
.visual-search-clear:hover { background:var(--gramlot-selected); }
|
|
359
|
+
.visual-search-clear:focus-visible { outline:2px solid var(--gramlot-action);outline-offset:1px; }
|
|
360
|
+
.visual-search-clear[hidden] { display:none; }
|
|
361
|
+
|
|
362
|
+
.visual-editor-fields {
|
|
363
|
+
--gramlot-field-padding:1px 5px;
|
|
364
|
+
--gramlot-formlet-gap:4px;
|
|
365
|
+
--gramlot-label-size:12px;
|
|
366
|
+
--gramlot-label-gap:2px;
|
|
367
|
+
font-size:12px;
|
|
368
|
+
}
|
|
369
|
+
.visual-editor-destination { margin:8px 10px 2px; font-size:12px; overflow-wrap:anywhere; }
|
|
370
|
+
.visual-editor-widget { margin:0 10px 8px; font-size:14px; }
|
|
371
|
+
.visual-editor-hint { margin:0 0 8px; font-size:12px; color:var(--gramlot-text-secondary); }
|
|
372
|
+
.visual-parameter-field { display:grid;gap:2px;min-width:0; }
|
|
373
|
+
.visual-validation-advanced { margin-top:6px; }
|
|
374
|
+
.visual-validation-advanced summary { cursor:pointer; margin-bottom:4px; font-weight:600; }
|
|
375
|
+
.visual-editor-fields select { min-height:24px;padding:1px 5px;font:inherit; }
|
|
376
|
+
.visual-editor-fields .label-box label { margin:0;font-size:12px;font-weight:500;line-height:1.35; }
|
|
377
|
+
.visual-editor-fields .visual-editor-hint { margin:0;line-height:1.5; }
|
|
378
|
+
.visual-editor-fields .visual-labelbox-heading { align-items:end; }
|
|
379
|
+
.visual-editor-fields .visual-labelbox-heading > gramlot-button { margin-bottom:2px; }
|
|
380
|
+
.visual-editor-fields .label-box label { overflow-wrap:anywhere; }
|
|
381
|
+
|
|
382
|
+
/* Inspector-like property table; the value cell contains its row commands. */
|
|
383
|
+
.visual-editor-attribute-list { border:1px solid var(--gramlot-border);border-radius:0;overflow:hidden;font-size:12px; }
|
|
384
|
+
.visual-editor-attribute-row { display:grid;grid-template-columns:minmax(90px,38%) minmax(0,1fr);min-height:24px;
|
|
385
|
+
border-bottom:1px solid var(--gramlot-border); }
|
|
386
|
+
.visual-editor-attribute-row:last-child { border-bottom:0; }
|
|
387
|
+
.visual-editor-attribute-row[hidden] { display:none; }
|
|
388
|
+
.visual-editor-attribute-name { display:flex;align-items:center;min-width:0;padding:1px 5px;overflow-wrap:anywhere;
|
|
389
|
+
background:var(--gramlot-surface-subtle);border-right:1px solid var(--gramlot-border); }
|
|
390
|
+
.visual-editor-attribute-value { display:flex;align-items:center;min-width:0; }
|
|
391
|
+
.visual-editor-attribute-heading { font-weight:600;color:var(--gramlot-text-secondary);background:var(--gramlot-surface-subtle); }
|
|
392
|
+
.visual-editor-attribute-heading .visual-editor-attribute-value { padding-left:5px; }
|
|
393
|
+
.visual-editor-attribute-row input { flex:1;min-width:0;width:100%;height:23px;box-sizing:border-box;border:0;border-radius:0;
|
|
394
|
+
padding:1px 5px;font:inherit;background:transparent;color:var(--gramlot-ink); }
|
|
395
|
+
.visual-editor-attribute-name:has(input) { padding:0; }
|
|
396
|
+
.visual-editor-fields .visual-editor-attribute-value select { flex:none;width:60px;max-width:25%;height:23px;min-height:0;
|
|
397
|
+
padding:0 2px;border:0;border-left:1px solid var(--gramlot-border);border-radius:0;font:inherit;background:var(--gramlot-surface-subtle);color:var(--gramlot-ink); }
|
|
398
|
+
.visual-editor-attribute-command { flex:none;margin-left:auto;width:22px;min-width:22px;height:23px;
|
|
399
|
+
--gramlot-button-padding:0 5px;--gramlot-field-height:23px;
|
|
400
|
+
--gramlot-button-background:transparent;--gramlot-border-control:transparent; }
|
|
401
|
+
.visual-editor-attribute-row input:focus-visible,.visual-editor-attribute-row select:focus-visible { outline:1px solid var(--gramlot-focus-ring);outline-offset:-1px; }
|
|
402
|
+
|
|
403
|
+
/* Tool density is local: authored widgets in the canvas retain their own sizing. */
|
|
404
|
+
.visual-editor-sidebar,.visual-editor-popup,.visual-editor-fields,.visual-editor-chat,
|
|
405
|
+
.visual-editor-toolbar,.visual-editor-rail,.visual-editor-code {
|
|
406
|
+
font-size:12px;line-height:1.3;
|
|
407
|
+
--gramlot-field-height:24px;--gramlot-field-font-size:12px;--gramlot-field-padding:1px 5px;
|
|
408
|
+
--gramlot-field-line-height:1.3;--gramlot-button-padding:1px 5px;
|
|
409
|
+
--gramlot-tree-row-height:24px;--gramlot-tab-height:24px;--gramlot-tab-padding:1px 6px;
|
|
410
|
+
--gramlot-tab-strip-padding:0;--gramlot-tab-gap:0;--gramlot-label-size:12px;--gramlot-label-gap:2px;
|
|
411
|
+
--gramlot-region-header-padding:0 5px;
|
|
412
|
+
}
|
|
413
|
+
:is(.visual-editor-sidebar,.visual-editor-popup) gramlot-tree::part(row) { min-height:24px;border-radius:1px; }
|
|
414
|
+
:is(.visual-editor-sidebar,.visual-editor-popup) gramlot-tree::part(expander) { width:16px;height:20px; }
|
|
415
|
+
:is(.visual-editor-sidebar,.visual-editor-popup) gramlot-tree::part(spacer) { width:16px;height:20px; }
|
|
416
|
+
:is(.visual-editor-sidebar,.visual-editor-popup) gramlot-tree::part(icon) { width:14px;height:14px; }
|
|
417
|
+
:is(.visual-editor-sidebar,.visual-editor-popup) gramlot-tree::part(group) { padding-inline-start:16px; }
|
|
418
|
+
|
|
419
|
+
/* Workbench chrome uses the selected canonical palette and density. */
|
|
420
|
+
.visual-editor-shell { position:relative;min-width:0;isolation:isolate;background:var(--gramlot-background);color:var(--gramlot-ink);
|
|
421
|
+
font-size:var(--gramlot-field-font-size,13px);line-height:1.4;
|
|
422
|
+
--gramlot-region-header-background:transparent;--gramlot-region-header-padding:0 8px;
|
|
423
|
+
--gramlot-region-header-border:transparent;--gramlot-region-title-size:11px;
|
|
424
|
+
--gramlot-splitter-background:color-mix(in srgb,var(--gramlot-border) 60%,transparent); }
|
|
425
|
+
.visual-editor-layout { width:calc(100% - 32px);margin-left:32px; }
|
|
426
|
+
.visual-editor-rail { position:absolute;inset:0 auto 0 0;width:32px;padding:3px 2px;gap:3px;
|
|
427
|
+
background:var(--gramlot-background);border-right:1px solid var(--gramlot-splitter-background); }
|
|
428
|
+
.visual-editor-tool { --gramlot-button-padding:3px;--gramlot-button-gap:0px; }
|
|
429
|
+
.visual-tool-icon { width:15px;height:15px;display:block;flex:none;background:currentColor;mask-position:center;mask-repeat:no-repeat;mask-size:contain; }
|
|
430
|
+
.visual-editor-rail .visual-tool-icon { width:16px;height:16px; }
|
|
431
|
+
.visual-editor-rail .visual-editor-tool { --gramlot-button-padding:4px; }
|
|
432
|
+
.visual-editor-rail,.visual-editor-toolbar { --gramlot-action:var(--gramlot-text-secondary);--gramlot-action-hover:var(--gramlot-ink); }
|
|
433
|
+
.visual-editor-toolbar { height:30px;box-sizing:border-box;padding:1px 6px;gap:2px;border-bottom:1px solid var(--gramlot-splitter-background);
|
|
434
|
+
background:var(--gramlot-background); --gramlot-button-padding:2px 4px; --gramlot-button-gap:2px; }
|
|
435
|
+
.visual-editor-brand { font-size:12px;font-weight:600;letter-spacing:-.02em;white-space:nowrap;margin-right:4px; }
|
|
436
|
+
.visual-toolbar-divider { width:1px;height:16px;background:var(--gramlot-border);margin:0 3px; }
|
|
437
|
+
.visual-editor-filename { font-size:12px;color:var(--gramlot-text-secondary);padding:0 4px;white-space:nowrap; }
|
|
438
|
+
.visual-editor-sidebar,.visual-editor-chat { background:color-mix(in srgb,var(--gramlot-background) 65%,var(--gramlot-surface)); }
|
|
439
|
+
.visual-editor-sidebar .visual-search-field { background:color-mix(in srgb,var(--gramlot-surface) 65%,transparent); }
|
|
440
|
+
.visual-editor-workspace { background:var(--gramlot-surface); }
|
|
441
|
+
.visual-editor-canvas { box-sizing:border-box;min-height:100%;padding:2px;display:flex;flex-direction:column; }
|
|
442
|
+
.visual-editor-canvas > div { flex:1;min-height:180px;box-sizing:border-box;background:var(--gramlot-surface); }
|
|
443
|
+
.visual-editor-canvas > div.gramlot-source-selected { outline:1px dashed color-mix(in srgb,var(--gramlot-action) 35%,transparent)!important;outline-offset:-1px!important; }
|
|
444
|
+
.visual-editor-file-status { margin:0;padding:0 6px;font-size:12px;color:var(--gramlot-text-secondary);max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
|
|
445
|
+
.visual-editor-destination { margin:2px 10px 4px;opacity:.65;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
|
|
446
|
+
.visual-editor-error { position:absolute;bottom:8px;left:320px;max-width:calc(100% - 340px);margin:0;padding:6px 10px;background:var(--gramlot-error-background);color:var(--gramlot-error);border-radius:4px; }
|
|
447
|
+
.visual-editor-chat select { height:22px;min-height:24px;padding:1px 4px;border-color:transparent;background:transparent;font-size:12px;text-overflow:ellipsis; }
|
|
448
|
+
.visual-editor-chat select { flex-shrink:0; }
|
|
449
|
+
.visual-editor-chat .gramlot-chat-editor { border-color:var(--gramlot-border);background:var(--gramlot-surface);font-size:12px; }
|
|
450
|
+
@media (max-width:900px) { .visual-editor-brand { display:none; }.visual-editor-file-status{max-width:110px;} }
|
|
451
|
+
|
|
452
|
+
.visual-labelbox-section { display:grid;gap:3px;min-width:0; }
|
|
453
|
+
.visual-labelbox-heading { display:grid;grid-template-columns:minmax(0,1fr) 22px;align-items:center;gap:3px; }
|
|
454
|
+
.visual-labelbox-heading > gramlot-button { --gramlot-button-padding:2px;font-size:13px; }
|
|
455
|
+
.visual-labelbox-title { font-weight:600;color:var(--gramlot-text-secondary); }
|
|
456
|
+
.visual-labelbox-attribute { display:grid;grid-template-columns:minmax(80px,40%) minmax(0,1fr);align-items:start;gap:4px;
|
|
457
|
+
padding:3px;border:1px solid var(--gramlot-border);border-radius:2px; }
|
|
458
|
+
.visual-labelbox-attribute[hidden] { display:none; }
|
|
459
|
+
|
|
460
|
+
/* Selection is a view-only decoration: no border, padding, size or Source writes. */
|
|
461
|
+
.visual-editor-canvas .gramlot-source-selected {
|
|
462
|
+
outline:2px solid var(--gramlot-action, #456bc4) !important;
|
|
463
|
+
outline-offset:-2px !important;
|
|
464
|
+
}
|
|
465
|
+
.visual-source-tree::part(selected-row),
|
|
466
|
+
.visual-clipboard-tree::part(selected-row) {
|
|
467
|
+
color:var(--gramlot-ink);
|
|
468
|
+
background:var(--gramlot-selected);
|
|
469
|
+
box-shadow:inset 3px 0 var(--gramlot-action, #456bc4);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.visual-clipboard { padding:3px; gap:2px; border-top:1px solid var(--gramlot-border); }
|
|
473
|
+
.visual-clipboard-title { font-weight:600; }
|
|
474
|
+
.visual-clipboard .visual-editor-hint { font-size:11px; }
|
|
@@ -4,7 +4,7 @@ import { Bag as Bag3, Gramlot, GramlotBuilder } from "@gramlot/gramlot";
|
|
|
4
4
|
// ../tools/gramlot-tools-inspector/src/inspector-bridge.js
|
|
5
5
|
import { Bag } from "@gramlot/gramlot";
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// src/editor-values.js
|
|
8
8
|
var editorTypes = ["string", "number", "integer", "boolean", "date", "time", "datetime", "null"];
|
|
9
9
|
function scalarType(value) {
|
|
10
10
|
if (value === null) return "null";
|
package/tools/inspector-agent.js
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function so(r,s){this.v=r,this.k=s}function rn(r,s){(s==null||s>r.length)&&(s=r.length);for(var a=0,c=Array(s);a<s;a++)c[a]=r[a];return c}function ao(r){if(Array.isArray(r))return r}function lo(r,s){var a=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(a!=null){var c,f,m,h,z=[],E=!0,F=!1;try{if(m=(a=a.call(r)).next,s===0){if(Object(a)!==a)return;E=!1}else for(;!(E=(c=m.call(a)).done)&&(z.push(c.value),z.length!==s);E=!0);}catch(D){F=!0,f=D}finally{try{if(!E&&a.return!=null&&(h=a.return(),Object(h)!==h))return}finally{if(F)throw f}}return z}}function co(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function uo(r,s){return ao(r)||lo(r,s)||fo(r,s)||co()}function fo(r,s){if(r){if(typeof r=="string")return rn(r,s);var a={}.toString.call(r).slice(8,-1);return a==="Object"&&r.constructor&&(a=r.constructor.name),a==="Map"||a==="Set"?Array.from(r):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?rn(r,s):void 0}}function Ut(r){var s,a;function c(m,h){try{var z=r[m](h),E=z.value,F=E instanceof so;Promise.resolve(F?E.v:E).then(function(D){if(F){var P=m==="return"&&E.k?m:"next";if(!E.k||D.done)return c(P,D);D=r[P](D).value}f(!!z.done,D)},function(D){c("throw",D)})}catch(D){f(2,D)}}function f(m,h){m===2?s.reject(h):s.resolve({value:h,done:m}),(s=s.next)?c(s.key,s.arg):a=null}this._invoke=function(m,h){return new Promise(function(z,E){var F={key:m,arg:h,resolve:z,reject:E,next:null};a?a=a.next=F:(s=a=F,c(m,h))})},typeof r.return!="function"&&(this.return=void 0)}Ut.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Ut.prototype.next=function(r){return this._invoke("next",r)},Ut.prototype.throw=function(r){return this._invoke("throw",r)},Ut.prototype.return=function(r){return this._invoke("return",r)};var En=Object.entries,sn=Object.setPrototypeOf,po=Object.isFrozen,yn=Object.getPrototypeOf,Sn=Object.getOwnPropertyDescriptor,O=Object.freeze,w=Object.seal,mt=Object.create,bn=typeof Reflect<"u"&&Reflect,Se=bn.apply,be=bn.construct;O||(O=function(s){return s});w||(w=function(s){return s});Se||(Se=function(s,a){for(var c=arguments.length,f=new Array(c>2?c-2:0),m=2;m<c;m++)f[m-2]=arguments[m];return s.apply(a,f)});be||(be=function(s){for(var a=arguments.length,c=new Array(a>1?a-1:0),f=1;f<a;f++)c[f-1]=arguments[f];return new s(...c)});var Y=A(Array.prototype.forEach);Array.prototype.indexOf;var mo=A(Array.prototype.lastIndexOf),an=A(Array.prototype.pop),St=A(Array.prototype.push),ho=A(Array.prototype.slice),_o=A(Array.prototype.splice),dt=Array.isArray,me=On(Set),de=A(Set.prototype.add),bt=A(Set.prototype.has),nt=A(String.prototype.toLowerCase),he=A(String.prototype.toString),ln=A(String.prototype.match),Ot=A(String.prototype.replace),cn=A(String.prototype.indexOf),To=A(String.prototype.trim),go=A(Number.prototype.toString),Ao=A(Boolean.prototype.toString),un=typeof BigInt>"u"?null:A(BigInt.prototype.toString),fn=typeof Symbol>"u"?null:A(Symbol.prototype.toString),C=A(Object.prototype.hasOwnProperty),Rt=A(Object.prototype.toString),R=A(RegExp.prototype.test),j=On(TypeError);function A(r){return function(s){s instanceof RegExp&&(s.lastIndex=0);for(var a=arguments.length,c=new Array(a>1?a-1:0),f=1;f<a;f++)c[f-1]=arguments[f];return Se(r,s,c)}}function On(r){return function(){for(var s=arguments.length,a=new Array(s),c=0;c<s;c++)a[c]=arguments[c];return be(r,a)}}function d(r,s){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nt;if(sn&&sn(r,null),!dt(s))return r;let c=s.length;for(;c--;){let f=s[c];if(typeof f=="string"){let m=a(f);m!==f&&(po(s)||(s[c]=m),f=m)}r[f]=!0}return r}function Eo(r){for(let s=0;s<r.length;s++)C(r,s)||(r[s]=null);return r}function M(r){let s=mt(null);for(let c of En(r)){var a=uo(c,2);let f=a[0],m=a[1];C(r,f)&&(dt(m)?s[f]=Eo(m):m&&typeof m=="object"&&m.constructor===Object?s[f]=M(m):s[f]=m)}return s}function yo(r){switch(typeof r){case"string":return r;case"number":return go(r);case"boolean":return Ao(r);case"bigint":return un?un(r):"0";case"symbol":return fn?fn(r):"Symbol()";case"undefined":return Rt(r);case"function":case"object":{if(r===null)return Rt(r);let s=r,a=k(s,"toString");if(typeof a=="function"){let c=a(s);return typeof c=="string"?c:Rt(c)}return Rt(r)}default:return Rt(r)}}function k(r,s){for(;r!==null;){let c=Sn(r,s);if(c){if(c.get)return A(c.get);if(typeof c.value=="function")return A(c.value)}r=yn(r)}function a(){return null}return a}function So(r,s){for(;r!==null;){let a=Sn(r,s);if(a)return a.get?A(a.get):null;r=yn(r)}return null}function bo(r){try{return R(r,""),!0}catch{return!1}}var pn=O(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),_e=O(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Te=O(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Oo=O(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ge=O(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ro=O(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mn=O(["#text"]),dn=O(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ae=O(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),hn=O(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zt=O(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),wo=w(/{{[\w\W]*|^[\w\W]*}}/g),Do=w(/<%[\w\W]*|^[\w\W]*%>/g),Lo=w(/\${[\w\W]*/g),Io=w(/^data-[\-\w.\u00B7-\uFFFF]+$/),No=w(/^aria-[\-\w]+$/),_n=w(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vo=w(/^(?:\w+script|data):/i),Co=w(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Mo=w(/^html$/i),Po=w(/^[a-z][.\w]*(-[.\w]+)+$/i),Ee=w(/<[/\w!]/g),Tn=w(/<[/\w]/g),xo=w(/<\/no(script|embed|frames)/i),gn=w(/\/>/i),S={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ko=O(d({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),Uo=function(){return typeof window>"u"?null:window},zo=function(s,a){if(typeof s!="object"||typeof s.createPolicy!="function")return null;let c=null,f="data-tt-policy-suffix";a&&a.hasAttribute(f)&&(c=a.getAttribute(f));let m="dompurify"+(c?"#"+c:"");try{return s.createPolicy(m,{createHTML(h){return h},createScriptURL(h){return h}})}catch{return console.warn("TrustedTypes policy "+m+" could not be created."),null}},An=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},q=function(s,a,c,f){return C(s,a)&&dt(s[a])?d(f.base?M(f.base):{},s[a],f.transform):c},ye=function(s,a,c){let f=C(s,a)?s[a]:void 0;return f&&typeof f=="object"?M(f):c()};function Rn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uo(),s=i=>Rn(i);if(s.version="3.4.17",s.removed=[],!r||!r.document||r.document.nodeType!==S.document||!r.Element)return s.isSupported=!1,s;let a=r.document,c=a,f=c.currentScript;r.DocumentFragment;let m=r.HTMLTemplateElement,h=r.Node,z=r.Element,E=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;let F=r.DOMParser,D=r.trustedTypes,P=z.prototype,wn=k(P,"cloneNode"),Ft=k(P,"remove"),Oe=k(P,"removeAttributeNode"),Dn=k(P,"nextSibling"),ht=k(P,"childNodes"),ot=k(P,"parentNode"),Ht=k(P,"shadowRoot"),Gt=k(P,"attributes"),K=h&&h.prototype?k(h.prototype,"nodeType"):null,rt=h&&h.prototype?k(h.prototype,"nodeName"):null,wt=h&&h.prototype?k(h.prototype,"ownerDocument"):null,x=function(t){return K?K(t):t.nodeType},_t=function(t){return rt?rt(t):t.nodeName},Re=So(P,"namespaceURI"),Wt=function(t){return Re?Re(t):t.namespaceURI};if(typeof m=="function"){let i=a.createElement("template");i.content&&i.content.ownerDocument&&(a=i.content.ownerDocument)}let I,Z="",Bt,we=!1,Tt=0,De=function(){if(Tt>0)throw j('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},it=function(t){De(),Tt++;try{return I.createHTML(t)}finally{Tt--}},Ln=function(t){De(),Tt++;try{return I.createScriptURL(t)}finally{Tt--}},In=function(){return we||(Bt=zo(D,f),we=!0),Bt},Dt=a,Yt=Dt.implementation,Le=Dt.createNodeIterator,Nn=Dt.createDocumentFragment,vn=Dt.getElementsByTagName,Cn=c.importNode,_=An();s.isSupported=typeof En=="function"&&typeof ot=="function"&&Yt&&Yt.createHTMLDocument!==void 0;let Mn=wo,Pn=Do,xn=Lo,kn=Io,Un=No,zn=vo,Ie=Co,Fn=Po,Ne=_n,T=null,jt=d({},[...pn,..._e,...Te,...ge,...mn]),g=null,Vt=d({},[...dn,...Ae,...hn,...zt]),H=Object.seal(mt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),gt=null,ve=null,V=Object.seal(mt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ce=!0,$t=!0,Me=!1,Xt=!0,B=!1,J=!0,Q=!1,qt=!1,Lt=null,It=null,Kt=!1,st=!1,Nt=!1,vt=!1,Pe=!0,xe=!1,ke="user-content-",Zt=!0,Jt=!1,tt=null,at={},et=null,Ue=d({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),ze=null,Fe=d({},["audio","video","img","source","image","track"]),He=null,Ge=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ct="http://www.w3.org/1998/Math/MathML",Mt="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml",lt=G,Qt=!1,te=null,Hn=d({},[Ct,Mt,G],he),We=O(["mi","mo","mn","ms","mtext"]),ee=d({},We),Be=O(["annotation-xml"]),ne=d({},Be),Gn=d({},["title","style","font","a","script"]),At=null,Wn=["application/xhtml+xml","text/html"],Bn="text/html",y=null,ct=null,Yn=a.createElement("form"),Ye=function(t){return t instanceof RegExp||t instanceof Function},oe=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ct&&ct===t)return;(!t||typeof t!="object")&&(t={}),t=M(t),At=Wn.indexOf(t.PARSER_MEDIA_TYPE)===-1?Bn:t.PARSER_MEDIA_TYPE,y=At==="application/xhtml+xml"?he:nt,T=q(t,"ALLOWED_TAGS",jt,{transform:y}),g=q(t,"ALLOWED_ATTR",Vt,{transform:y}),te=q(t,"ALLOWED_NAMESPACES",Hn,{transform:he}),He=q(t,"ADD_URI_SAFE_ATTR",Ge,{transform:y,base:Ge}),ze=q(t,"ADD_DATA_URI_TAGS",Fe,{transform:y,base:Fe}),et=q(t,"FORBID_CONTENTS",Ue,{transform:y}),gt=q(t,"FORBID_TAGS",M({}),{transform:y}),ve=q(t,"FORBID_ATTR",M({}),{transform:y}),at=C(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?M(t.USE_PROFILES):t.USE_PROFILES:!1,Ce=t.ALLOW_ARIA_ATTR!==!1,$t=t.ALLOW_DATA_ATTR!==!1,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Xt=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,B=t.SAFE_FOR_TEMPLATES||!1,J=t.SAFE_FOR_XML!==!1,Q=t.WHOLE_DOCUMENT||!1,st=t.RETURN_DOM||!1,Nt=t.RETURN_DOM_FRAGMENT||!1,vt=t.RETURN_TRUSTED_TYPE||!1,Kt=t.FORCE_BODY||!1,Pe=t.SANITIZE_DOM!==!1,xe=t.SANITIZE_NAMED_PROPS||!1,Zt=t.KEEP_CONTENT!==!1,Jt=t.IN_PLACE||!1,Ne=bo(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:_n,lt=typeof t.NAMESPACE=="string"?t.NAMESPACE:G,ee=ye(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>d({},We)),ne=ye(t,"HTML_INTEGRATION_POINTS",()=>d({},Be));let e=ye(t,"CUSTOM_ELEMENT_HANDLING",()=>mt(null));if(H=mt(null),C(e,"tagNameCheck")&&Ye(e.tagNameCheck)&&(H.tagNameCheck=e.tagNameCheck),C(e,"attributeNameCheck")&&Ye(e.attributeNameCheck)&&(H.attributeNameCheck=e.attributeNameCheck),C(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),w(H),B&&($t=!1),Nt&&(st=!0),at&&(T=d({},mn),g=mt(null),at.html===!0&&(d(T,pn),d(g,dn)),at.svg===!0&&(d(T,_e),d(g,Ae),d(g,zt)),at.svgFilters===!0&&(d(T,Te),d(g,Ae),d(g,zt)),at.mathMl===!0&&(d(T,ge),d(g,hn),d(g,zt))),V.tagCheck=null,V.attributeCheck=null,C(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?V.tagCheck=t.ADD_TAGS:dt(t.ADD_TAGS)&&(T===jt&&(T=M(T)),d(T,t.ADD_TAGS,y))),C(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?V.attributeCheck=t.ADD_ATTR:dt(t.ADD_ATTR)&&(g===Vt&&(g=M(g)),d(g,t.ADD_ATTR,y))),C(t,"ADD_FORBID_CONTENTS")&&dt(t.ADD_FORBID_CONTENTS)&&(et===Ue&&(et=M(et)),d(et,t.ADD_FORBID_CONTENTS,y)),Zt&&(T["#text"]=!0),Q&&d(T,["html","head","body"]),T.table&&(d(T,["tbody"]),delete gt.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let n=I;I=t.TRUSTED_TYPES_POLICY;try{Z=it("")}catch(o){throw I=n,o}}else t.TRUSTED_TYPES_POLICY===null?(I=void 0,Z=""):(I===void 0&&(I=In()),I&&typeof Z=="string"&&(Z=it("")));O&&O(t),ct=t},je=d({},[..._e,...Te,...Oo]),Ve=d({},[...ge,...Ro]),jn=function(t,e,n){return e.namespaceURI===G?t==="svg":e.namespaceURI===Ct?t==="svg"&&(n==="annotation-xml"||ee[n]):!!je[t]},Vn=function(t,e,n){return e.namespaceURI===G?t==="math":e.namespaceURI===Mt?t==="math"&&ne[n]:!!Ve[t]},$n=function(t,e,n){return e.namespaceURI===Mt&&!ne[n]||e.namespaceURI===Ct&&!ee[n]?!1:!Ve[t]&&(Gn[t]||!je[t])},Xn=function(t){let e=Wt(t),n=nt(_t(t)),o=ot(t),l,u;return o&&x(o)===S.element?(l={namespaceURI:Wt(o)},u=nt(_t(o))):(l={namespaceURI:lt},u="template"),te[e]?e===Mt?jn(n,l,u):e===Ct?Vn(n,l,u):e===G?$n(n,l,u):!!(At==="application/xhtml+xml"&&te[e]):!1},$=function(t){St(s.removed,{element:t});try{ot(t).removeChild(t)}catch{if(Ft(t),!ot(t))throw j("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},$e=function(t,e,n){try{Oe(t,e)}catch{try{t.removeAttribute(n)}catch{}}},re=function(t){se(t);let e=ht(t);e&&Y(ho(e),o=>{try{Ft(o)}catch{}});let n=x(t)===S.element?Gt(t):null;if(n)for(let o=n.length-1;o>=0;--o){let l=n[o],u=l&&l.name;typeof u=="string"&&$e(t,l,u)}},ut=function(t,e,n){if(!n)try{n=e.getAttributeNode(t)}catch{n=null}St(s.removed,{attribute:n||null,from:e});try{n?Oe(e,n):e.removeAttribute(t)}catch{try{e.removeAttribute(t)}catch{}}if(t==="is")if(st||Nt)try{$(e)}catch{}else try{e.setAttribute(t,"")}catch{}},Xe=function(t){let e=Gt(t);if(e)for(let n=e.length-1;n>=0;--n){let o=e[n],l=o&&o.name;typeof l!="string"||g[y(l)]||$e(t,o,l)}},ie=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,o=[t];for(;o.length>0;){let l=o.pop();if(e(l)===!1)continue;if(n&&x(l)===S.element){let p=Ht(l);X(p)&&o.push(p)}let u=ht(l);if(u)for(let p=u.length-1;p>=0;--p)o.push(u[p])}},se=function(t){ie(t,e=>{x(e)===S.element&&Xe(e)})},ae=function(t){let e=[];return ie(t,n=>{e.push(n)},!0),e},qn=function(t,e){let n=me();Y(ae(t),o=>{x(o)===S.element&&de(n,o)}),Y(e,o=>{x(o)===S.element&&!bt(n,o)&&Xe(o)})},qe=function(t,e){let n=!1;return Y(s.removed,o=>{o.element&&(n=n||o.element===t,se(o.element))}),qn(t,e),n},Kn=8,Zn=function(t,e){let n=tt,o=null,l=()=>(o||(o=me(),Y(e,u=>{de(o,u)})),o);for(let u=0;;u++){let p=ae(t),b=[t],W=!1;if(Y(p,L=>{x(L)===S.documentFragment?St(b,L):!W&&!bt(n,L)&&(W=bt(l(),L))}),!W)return;if(u>=Kn)throw j("the tree kept changing during in-place sanitization; refusing to return it");Y(b,(L,N)=>{Jn(L,N>0,t,l())})}},Jn=function(t,e,n,o){let l=le(t),u;for(;u=l.nextNode();)!bt(o,u)||bt(tt,u)||(e&&U(_.uponSanitizeShadowNode,u,null),ue(u,n),fe(u,n),X(u.content)&&yt(u.content))},Qn=function(t){tt&&de(tt,t)},Ke=function(t,e){return J?t==="patchsrc"?!0:t==="for"&&e!=="label"&&e!=="output":!1},to=function(t){J&&ie(t,e=>{let n=x(e);if(n===S.processingInstruction||n===S.comment&&R(Tn,e.data)){try{Ft(e)}catch{}return!1}if(n===S.element){let o=e,l=y(_t(e));try{o.hasAttribute&&o.hasAttribute("patchsrc")&&o.removeAttribute("patchsrc"),o.hasAttribute&&o.hasAttribute("for")&&Ke("for",l)&&o.removeAttribute("for")}catch{}}return!0})},Ze=function(t){let e=null,n=null;if(Kt)t="<remove></remove>"+t;else{let u=ln(t,/^[\r\n\t ]+/);n=u&&u[0]}At==="application/xhtml+xml"&<===G&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");let o=I?it(t):t;if(lt===G)try{e=new F().parseFromString(o,At)}catch{}if(!e||!e.documentElement){e=Yt.createDocument(lt,"template",null);try{e.documentElement.innerHTML=Qt?Z:o}catch{}}let l=e.body||e.documentElement;return t&&n&&l.insertBefore(a.createTextNode(n),l.childNodes[0]||null),lt===G?vn.call(e,Q?"html":"body")[0]:Q?e.documentElement:l},le=function(t){let e=wt?wt(t):t.ownerDocument;return Le.call(e||t,t,E.SHOW_ELEMENT|E.SHOW_COMMENT|E.SHOW_TEXT|E.SHOW_PROCESSING_INSTRUCTION|E.SHOW_CDATA_SECTION,null)},Pt=function(t){return t=Ot(t,Mn," "),t=Ot(t,Pn," "),t=Ot(t,xn," "),t},ce=function(t){var e;Je(t);let n=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");n&&Y(n,o=>{X(o.content)&&ce(o.content)})},Je=function(t){t.normalize();let e=wt?wt(t):t.ownerDocument,n=Le.call(e||t,t,E.SHOW_TEXT|E.SHOW_COMMENT|E.SHOW_CDATA_SECTION|E.SHOW_PROCESSING_INSTRUCTION,null),o=n.nextNode();for(;o;)o.data=Pt(o.data),o=n.nextNode()},xt=function(t){let e=rt?rt(t):null;return typeof e!="string"||y(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==Gt(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==K(t)||t.childNodes!==ht(t)},X=function(t){if(!K||typeof t!="object"||t===null)return!1;try{return K(t)===S.documentFragment}catch{return!1}},Et=function(t){if(!K||typeof t!="object"||t===null)return!1;try{return typeof K(t)=="number"}catch{return!1}};function U(i,t,e){i.length!==0&&Y(i,n=>{n.call(s,t,e,ct)})}let eo=function(t,e){return!!(J&&t.hasChildNodes()&&!Et(t.firstElementChild)&&R(Ee,t.textContent)&&R(Ee,t.innerHTML)||J&&ko[e]&&x(t)===S.element&&Wt(t)===G&&(Et(t.firstElementChild)||typeof t.textContent=="string"&&R(Ee,t.textContent))||t.nodeType===S.processingInstruction||J&&t.nodeType===S.comment&&R(Tn,t.data))},kt=function(t,e){if(t instanceof RegExp)return R(t,e);if(t instanceof Function){for(var n=arguments.length,o=new Array(n>2?n-2:0),l=2;l<n;l++)o[l-2]=arguments[l];return!!t(e,...o)}return!1},no=function(t,e,n){if(!gt[e]&&en(e)&&kt(H.tagNameCheck,e))return!1;if(Zt&&!et[e]&&!et[nt(e)]){let o=ot(t),l=ht(t);if(l&&o){let u=l.length;for(let p=u-1;p>=0;--p){let b=t===n?wn(l[p],!0):l[p];o.insertBefore(b,Dn(t))}}}return $(t),!0},Qe=function(t,e,n,o){return t.length===0?e:e===n||e===o?M(e):e},ft=function(t,e){return t===e||ot(t)!==null?!1:(Jt&&se(t),!0)},ue=function(t,e){if(Qn(t),U(_.beforeSanitizeElements,t,null),ft(t,e))return!0;if(xt(t))return $(t),!0;let n=y(_t(t));if(T=Qe(_.uponSanitizeElement,T,jt,Lt),U(_.uponSanitizeElement,t,{tagName:n,allowedTags:T}),ft(t,e))return!0;if(eo(t,n))return $(t),!0;if(gt[n]||!(V.tagCheck instanceof Function&&V.tagCheck(n))&&!T[n]){let o=no(t,n,e);return o===!1&&(U(_.afterSanitizeElements,t,null),ft(t,e))?!0:o}if(x(t)===S.element&&!Xn(t)||(n==="noscript"||n==="noembed"||n==="noframes")&&R(xo,t.innerHTML))return $(t),!0;if(B&&t.nodeType===S.text){let o=Pt(t.textContent);t.textContent!==o&&(St(s.removed,{element:t.cloneNode()}),t.textContent=o)}return U(_.afterSanitizeElements,t,null),ft(t,e)},tn=function(t,e,n){if(ve[e]||Ke(e,t)||Pe&&(e==="id"||e==="name")&&(n in a||n in Yn))return!1;let o=g[e]||V.attributeCheck instanceof Function&&V.attributeCheck(e,t);return $t&&R(kn,e)||Ce&&R(Un,e)?!0:o?He[e]||R(Ne,Ot(n,Ie,""))||(e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&cn(n,"data:")===0&&ze[t]||Me&&!R(zn,Ot(n,Ie,""))?!0:!n:en(t)&&kt(H.tagNameCheck,t)&&kt(H.attributeNameCheck,e,t)||e==="is"&&H.allowCustomizedBuiltInElements&&kt(H.tagNameCheck,n)},oo=d({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),en=function(t){return!oo[nt(t)]&&R(Fn,t)},ro=function(t,e,n,o){if(I&&typeof D=="object"&&typeof D.getAttributeType=="function"&&!n)switch(D.getAttributeType(t,e)){case"TrustedHTML":return it(o);case"TrustedScriptURL":return Ln(o)}return o},io=function(t,e,n,o){try{return n?t.setAttributeNS(n,e,o):t.setAttribute(e,o),xt(t)?($(t),!1):!0}catch{return ut(e,t),!1}},nn=function(t,e){return J&&R(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e)?!0:nt(t)==="attributename"&&ln(e,"href")!==null},fe=function(t,e){if(U(_.beforeSanitizeAttributes,t,null),ft(t,e))return;let n=t.attributes;if(!n||xt(t))return;g=Qe(_.uponSanitizeAttribute,g,Vt,It);let o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:g,forceKeepAttr:void 0},l=n.length,u=y(t.nodeName);for(;l--;){let p=n[l],b=p.name,W=p.namespaceURI,L=p.value,N=y(b),pt=L,v=b==="value"?pt:To(pt),on=!1;if(o.attrName=N,o.attrValue=v,o.keepAttr=!0,o.forceKeepAttr=void 0,U(_.uponSanitizeAttribute,t,o),v=o.attrValue,xe&&(N==="id"||N==="name")&&cn(v,ke)!==0&&(ut(b,t,p),v=ke+v,on=!0),nn(b,v)){ut(b,t,p);continue}if(!o.forceKeepAttr){if(!o.keepAttr){ut(b,t,p);continue}if(!Xt&&R(gn,v)){ut(b,t,p);continue}if(B&&(v=Pt(v)),!tn(u,N,v)){ut(b,t,p);continue}v=ro(u,N,W,v),v!==pt&&io(t,b,W,v)&&on&&an(s.removed)}}U(_.afterSanitizeAttributes,t,null),ft(t,e)},yt=function(t){let e=null,n=le(t);for(U(_.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)if(U(_.uponSanitizeShadowNode,e,null),ue(e,t),fe(e,t),X(e.content)&&yt(e.content),x(e)===S.element){let o=Ht(e);X(o)&&(pe(o),yt(o))}B&&Je(t),U(_.afterSanitizeShadowDOM,t,null)},pe=function(t){let e=[{node:t,shadow:null}];for(;e.length>0;){let n=e.pop();if(n.shadow){yt(n.shadow);continue}let o=n.node,l=x(o)===S.element,u=ht(o);if(u)for(let p=u.length-1;p>=0;--p)e.push({node:u[p],shadow:null});if(l){let p=rt?rt(o):null;if(typeof p=="string"&&y(p)==="template"){let b=o.content;X(b)&&e.push({node:b,shadow:null})}}if(l){let p=Ht(o);X(p)&&e.push({node:null,shadow:p},{node:p,shadow:null})}}};return s.sanitize=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,n=null,o=null,l=null;if(Qt=!i,Qt&&(i="<!-->"),typeof i!="string"&&!Et(i)&&(i=yo(i),typeof i!="string"))throw j("dirty is not a string, aborting");if(!s.isSupported)return i;qt?(T=Lt,g=It):oe(t),(_.uponSanitizeElement.length>0||_.uponSanitizeAttribute.length>0)&&(T=M(T)),_.uponSanitizeAttribute.length>0&&(g=M(g)),s.removed=[];let u=Jt&&typeof i!="string"&&Et(i),p=[],b=tt;if(u){to(i);let N=_t(i);if(typeof N=="string"){let pt=y(N);if(!T[pt]||gt[pt])throw re(i),j("root node is forbidden and cannot be sanitized in-place")}if(xt(i))throw re(i),j("root node is clobbered and cannot be sanitized in-place");p=ae(i),tt=me()}else if(Et(i))e=Ze("<!---->"),n=e.ownerDocument.importNode(i,!0),n.nodeType===S.element&&n.nodeName==="BODY"||n.nodeName==="HTML"?e=n:e.appendChild(n),pe(e);else{if(!st&&!B&&!Q&&i.indexOf("<")===-1)return I&&vt?it(i):i;if(e=Ze(i),!e)return st?null:vt?Z:""}e&&Kt&&$(e.firstChild);let W=u?i:e;try{u&&pe(i);let N=le(W);for(;o=N.nextNode();)ue(o,W),fe(o,W),X(o.content)&&yt(o.content);u&&Zn(i,p)}catch(N){throw u&&(re(i),qe(i,p)),N}finally{tt=b}if(u){if(qe(i,p))throw j("a node selected for removal could not be safely returned; refusing to sanitize in place");return B&&ce(i),i}if(st){if(B&&ce(e),Nt)for(l=Nn.call(e.ownerDocument);e.firstChild;)l.appendChild(e.firstChild);else l=e;return(g.shadowroot||g.shadowrootmode)&&(l=Cn.call(c,l,!0)),l}let L=Q?e.outerHTML:e.innerHTML;return Q&&T["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&R(Mo,e.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
|
|
3
|
-
`+L),B&&(L=Pt(L)),I&&vt?it(L):L},s.setConfig=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};oe(i),qt=!0,Lt=T,It=g},s.clearConfig=function(){ct=null,qt=!1,Lt=null,It=null,I=Bt,Z=""},s.isValidAttribute=function(i,t,e){ct||oe({});let n=y(i),o=y(t);return typeof e=="string"&&(nn(t,e)||!Xt&&R(gn,e))?!1:tn(n,o,e)},s.addHook=function(i,t){typeof t=="function"&&C(_,i)&&St(_[i],t)},s.removeHook=function(i,t){if(C(_,i)){if(t!==void 0){let e=mo(_[i],t);return e===-1?void 0:_o(_[i],e,1)[0]}return an(_[i])}},s.removeHooks=function(i){C(_,i)&&(_[i]=[])},s.removeAllHooks=function(){_=An()},s}var Fo=Rn();export{Fo as a};
|
package/src/form-state.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type {Bag} from '@genrojs/bag';
|
|
2
|
-
import type {SourceBagNode} from '@genrojs/builders';
|
|
3
|
-
|
|
4
|
-
export interface FormStatus {
|
|
5
|
-
dirty: boolean;
|
|
6
|
-
pending: boolean;
|
|
7
|
-
valid: boolean;
|
|
8
|
-
canSave: boolean;
|
|
9
|
-
status: 'ok' | 'changed' | 'error' | 'pending';
|
|
10
|
-
}
|
|
11
|
-
/** Local form state owned by a Source node, never a server persistence service. */
|
|
12
|
-
export class FormState {
|
|
13
|
-
readonly node: SourceBagNode;
|
|
14
|
-
readonly registers: Bag;
|
|
15
|
-
readonly data: Bag;
|
|
16
|
-
readonly status: FormStatus;
|
|
17
|
-
readonly disposed: boolean;
|
|
18
|
-
accept(): boolean;
|
|
19
|
-
restore(): void;
|
|
20
|
-
}
|
package/src/form-state.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./form-state.d.ts" */
|
|
2
|
-
import {Bag} from '@genrojs/bag';
|
|
3
|
-
import {fromTytx, toTytx} from '@genrojs/tytx';
|
|
4
|
-
|
|
5
|
-
// TYTX is the existing typed snapshot format (dates, Decimal and nested Bags included).
|
|
6
|
-
const copy = value => fromTytx(toTytx(value));
|
|
7
|
-
const same = (a, b) => toTytx(a) === toTytx(b);
|
|
8
|
-
const key = node => encodeURIComponent(node.fullpath).replaceAll('.', '%2E');
|
|
9
|
-
|
|
10
|
-
/** Source-owned local form lifecycle. Logic and DOM never own the registers. */
|
|
11
|
-
export class FormState {
|
|
12
|
-
constructor(node, runtime) {
|
|
13
|
-
this.node = node;
|
|
14
|
-
this.runtime = runtime;
|
|
15
|
-
this.registers = new Bag();
|
|
16
|
-
this.validationQueue = new Set();
|
|
17
|
-
this.fields = new Map(); // mounted control resources, not application values
|
|
18
|
-
this.disposed = false;
|
|
19
|
-
this.scheduled = false;
|
|
20
|
-
this.writing = 0;
|
|
21
|
-
this.path = node.absDatapath('.');
|
|
22
|
-
if (!(this.data instanceof Bag)) throw new TypeError('A form requires a Bag at its datapath.');
|
|
23
|
-
this.registers.setItem('baseline', copy(this.data));
|
|
24
|
-
for (const name of ['changes', 'errors', 'pending', 'drafts']) this.registers.setItem(name, new Bag());
|
|
25
|
-
this.subscription = runtime.router.register({path:this.path, recipient:this, subtree:true});
|
|
26
|
-
runtime.bindingFor(node).track(() => this.dispose());
|
|
27
|
-
}
|
|
28
|
-
rebind() {
|
|
29
|
-
const path = this.node.absDatapath('.');
|
|
30
|
-
if (path === this.path) return;
|
|
31
|
-
if (!(this.data instanceof Bag)) throw new TypeError('A form requires a Bag at its datapath.');
|
|
32
|
-
this.subscription.close();
|
|
33
|
-
this.path = path;
|
|
34
|
-
this.subscription = this.runtime.router.register({path, recipient:this, subtree:true});
|
|
35
|
-
this.updateChanges();
|
|
36
|
-
for (const adapter of this.fields.values()) {
|
|
37
|
-
adapter.element.cancelValidation();
|
|
38
|
-
this.clearDraft(adapter.node);
|
|
39
|
-
this.scheduleValidation(adapter);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
get data() { return this.node.getRelativeData('.'); }
|
|
43
|
-
get status() {
|
|
44
|
-
const dirty = this.registers.getItem('changes').length > 0;
|
|
45
|
-
const pending = this.registers.getItem('pending').length > 0;
|
|
46
|
-
const invalid = this.registers.getItem('errors').length > 0;
|
|
47
|
-
const incomplete = this.registers.getItem('drafts').length > 0;
|
|
48
|
-
return {dirty, pending, valid:!invalid && !incomplete, canSave:dirty && !invalid && !incomplete && !pending,
|
|
49
|
-
status:invalid ? 'error' : pending || incomplete ? 'pending' : dirty ? 'changed' : 'ok'};
|
|
50
|
-
}
|
|
51
|
-
register(adapter) {
|
|
52
|
-
const node = adapter.node;
|
|
53
|
-
this.fields.set(node, adapter);
|
|
54
|
-
this.scheduleValidation(adapter);
|
|
55
|
-
return () => {
|
|
56
|
-
this.fields.delete(node);
|
|
57
|
-
for (const name of ['errors','pending','drafts']) this.remove(name,node);
|
|
58
|
-
delete node.formDraft;
|
|
59
|
-
this.notify();
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
remove(name, node) {
|
|
63
|
-
const bag = this.registers.getItem(name), label = key(node);
|
|
64
|
-
if (bag.getNode(label)) bag.popNode(label);
|
|
65
|
-
}
|
|
66
|
-
set(name, node, value) {
|
|
67
|
-
if (value == null) this.remove(name,node);
|
|
68
|
-
else this.registers.getItem(name).setItem(key(node), value);
|
|
69
|
-
this.notify();
|
|
70
|
-
}
|
|
71
|
-
draft(node, text) {
|
|
72
|
-
node.formDraft = text;
|
|
73
|
-
this.set('drafts',node,text);
|
|
74
|
-
}
|
|
75
|
-
clearDraft(node) {
|
|
76
|
-
delete node.formDraft;
|
|
77
|
-
this.set('drafts',node,null);
|
|
78
|
-
this.issue(node,'parse',null);
|
|
79
|
-
}
|
|
80
|
-
candidate(adapter, value) {
|
|
81
|
-
this.clearDraft(adapter.node);
|
|
82
|
-
this.writing++;
|
|
83
|
-
try { adapter.commitFormValue(value); }
|
|
84
|
-
finally { this.writing--; }
|
|
85
|
-
}
|
|
86
|
-
result(node, result) {
|
|
87
|
-
this.pendingPart(node,'validation',null);
|
|
88
|
-
this.issue(node,'validation',result.error || null);
|
|
89
|
-
}
|
|
90
|
-
part(register, node, kind, value) {
|
|
91
|
-
const bag = this.registers.getItem(register), label = key(node);
|
|
92
|
-
let row = bag.getItem(label);
|
|
93
|
-
if (!row && value != null) { row = new Bag(); bag.setItem(label,row); }
|
|
94
|
-
if (row) {
|
|
95
|
-
if (value == null) { if (row.getNode(kind)) row.popNode(kind); }
|
|
96
|
-
else row.setItem(kind,value);
|
|
97
|
-
if (!row.length) this.remove(register,node);
|
|
98
|
-
}
|
|
99
|
-
this.notify();
|
|
100
|
-
}
|
|
101
|
-
issue(node, kind, message) { this.part('errors',node,kind,message || null); }
|
|
102
|
-
pendingPart(node, kind, value) { this.part('pending',node,kind,value); }
|
|
103
|
-
parseError(node, message) { this.issue(node,'parse',message); }
|
|
104
|
-
pending(adapter, active) {
|
|
105
|
-
const bag = this.registers.getItem('pending'), node = adapter.node;
|
|
106
|
-
if (active) this.pendingPart(node,'validation','active');
|
|
107
|
-
else if (bag.getItem(key(node) + '.validation') === 'active') this.pendingPart(node,'validation','cancelled');
|
|
108
|
-
}
|
|
109
|
-
scheduleValidation(adapter) {
|
|
110
|
-
if (this.disposed || !this.fields.has(adapter.node)) return;
|
|
111
|
-
if (this.validationQueue.has(adapter)) return;
|
|
112
|
-
this.validationQueue.add(adapter);
|
|
113
|
-
this.pendingPart(adapter.node,'validation','scheduled');
|
|
114
|
-
this.schedule(() => { this.validationQueue.delete(adapter); this.validate(adapter); });
|
|
115
|
-
}
|
|
116
|
-
validate(adapter) {
|
|
117
|
-
if (this.disposed || !this.fields.has(adapter.node) || adapter.binding.closed) return;
|
|
118
|
-
if (Object.hasOwn(adapter.node,'formDraft')) { this.pendingPart(adapter.node,'validation',null); return; }
|
|
119
|
-
if (!adapter.element.isConnected) return;
|
|
120
|
-
if (this.registers.getItem('pending').getItem(key(adapter.node) + '.selection')) return;
|
|
121
|
-
// Validation uses the existing field engine, epoch, callbacks and cancellation.
|
|
122
|
-
adapter.validateForm();
|
|
123
|
-
}
|
|
124
|
-
schedule(callback) {
|
|
125
|
-
queueMicrotask(() => { if (!this.disposed) callback(); });
|
|
126
|
-
}
|
|
127
|
-
receive(change) {
|
|
128
|
-
if (this.disposed) return;
|
|
129
|
-
this.updateChanges();
|
|
130
|
-
if (this.writing) return;
|
|
131
|
-
for (const adapter of this.fields.values()) {
|
|
132
|
-
const path = adapter.node.absDatapath(adapter.node.getAttr('value'));
|
|
133
|
-
if (change.path === path || path.startsWith(change.path + '.')) {
|
|
134
|
-
this.clearDraft(adapter.node);
|
|
135
|
-
this.scheduleValidation(adapter);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
updateChanges() {
|
|
140
|
-
const changes = new Bag();
|
|
141
|
-
const visit = (before, after, prefix = '') => {
|
|
142
|
-
const labels = new Set([...before.getNodes(), ...after.getNodes()].map(node => node.label));
|
|
143
|
-
for (const label of labels) {
|
|
144
|
-
const a = before.getNode(label), b = after.getNode(label), path = prefix + label;
|
|
145
|
-
if (a && b && a.value instanceof Bag && b.value instanceof Bag && same(a.attr,b.attr)) {
|
|
146
|
-
visit(a.value,b.value,path + '.');
|
|
147
|
-
} else if (!a || !b || !same([a.value,a.attr],[b.value,b.attr])) {
|
|
148
|
-
changes.setItem(encodeURIComponent(path).replaceAll('.', '%2E'), new Bag({path,
|
|
149
|
-
existed:Boolean(a), exists:Boolean(b), previous:a ? copy(a.value) : null,
|
|
150
|
-
current:b ? copy(b.value) : null}));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
visit(this.registers.getItem('baseline'),this.data);
|
|
155
|
-
this.registers.setItem('changes',changes);
|
|
156
|
-
this.notify();
|
|
157
|
-
}
|
|
158
|
-
notify() {
|
|
159
|
-
if (this.disposed || this.scheduled) return;
|
|
160
|
-
this.scheduled = true;
|
|
161
|
-
this.schedule(() => { this.scheduled = false; const status = this.status;
|
|
162
|
-
const previous = this.registers.getItem('status');
|
|
163
|
-
if (!previous || !same(previous,new Bag(status))) {
|
|
164
|
-
this.registers.setItem('status',new Bag(status));
|
|
165
|
-
this.node.publish('formStatus',status);
|
|
166
|
-
} });
|
|
167
|
-
}
|
|
168
|
-
/** Flush active drafts. Refuse errors/pending checks; accept only a valid local snapshot. */
|
|
169
|
-
accept() {
|
|
170
|
-
if (this.disposed) return false;
|
|
171
|
-
for (const adapter of this.fields.values()) {
|
|
172
|
-
if (Object.hasOwn(adapter.node,'formDraft')) adapter.commit();
|
|
173
|
-
}
|
|
174
|
-
if (!this.status.valid || this.status.pending) return false;
|
|
175
|
-
this.registers.setItem('baseline',copy(this.data));
|
|
176
|
-
this.updateChanges();
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
restore() {
|
|
180
|
-
if (this.disposed) return;
|
|
181
|
-
for (const adapter of this.fields.values()) {
|
|
182
|
-
adapter.element.cancelValidation();
|
|
183
|
-
this.clearDraft(adapter.node);
|
|
184
|
-
adapter.element.restoreFormValue(this.registers.getItem('baseline').getItem(
|
|
185
|
-
adapter.node.absDatapath(adapter.node.getAttr('value')).slice(this.path ? this.path.length + 1 : 0)));
|
|
186
|
-
}
|
|
187
|
-
this.node.setRelativeData('.',copy(this.registers.getItem('baseline')));
|
|
188
|
-
this.updateChanges();
|
|
189
|
-
for (const adapter of this.fields.values()) this.scheduleValidation(adapter);
|
|
190
|
-
}
|
|
191
|
-
dispose() {
|
|
192
|
-
if (this.disposed) return;
|
|
193
|
-
this.disposed = true;
|
|
194
|
-
this.subscription.close();
|
|
195
|
-
this.fields.clear();
|
|
196
|
-
this.validationQueue.clear();
|
|
197
|
-
}
|
|
198
|
-
}
|