swf2js 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -14
- package/package.json +11 -7
- package/studio/actionscript-roundtrip.test.js +54 -0
- package/studio/actionscript-scripts.test.js +169 -0
- package/studio/animated-image.test.js +137 -0
- package/studio/arithmetic.test.js +16 -0
- package/studio/as3-import.test.js +110 -0
- package/studio/audio-info.test.js +44 -0
- package/studio/components.test.js +152 -0
- package/studio/document-editing.test.js +92 -0
- package/studio/examples/01-space-mission.json +1628 -0
- package/studio/examples/02-clockwork-vault.json +1079 -0
- package/studio/examples/03-neon-synth.json +1364 -0
- package/studio/examples/04-kinetic-poster.json +923 -0
- package/studio/examples/05-signal-relay.json +1131 -0
- package/studio/examples/06-calculator.json +564 -0
- package/studio/frame-editing.test.js +129 -0
- package/studio/frame-events.test.js +117 -0
- package/studio/groups.test.js +88 -0
- package/studio/index.html +962 -0
- package/studio/interaction-triggers.test.js +37 -0
- package/studio/linked-actions.test.js +48 -0
- package/studio/lottie.test.js +208 -0
- package/studio/masks.test.js +43 -0
- package/studio/media-assets.test.js +62 -0
- package/studio/paint-tools.test.js +60 -0
- package/studio/playback.test.js +17 -0
- package/studio/project-io.test.js +405 -0
- package/studio/project-preview.test.js +475 -0
- package/studio/scene-transition.test.js +32 -0
- package/studio/server/archive-companions.js +27 -0
- package/studio/server/as3-library.js +91 -0
- package/studio/server/assets.js +162 -0
- package/studio/server/audio-info.js +82 -0
- package/studio/server/font-files.js +332 -0
- package/studio/server/http.js +135 -0
- package/studio/server/linked-actions.js +93 -0
- package/studio/server/png-decode.js +1 -0
- package/studio/server/project-movie.js +1164 -0
- package/studio/server/project-preview.js +152 -0
- package/studio/server/projects.js +370 -0
- package/studio/server/report.js +29 -0
- package/studio/server/routes.js +93 -0
- package/studio/server/swf-authoring.js +90 -0
- package/studio/server/swf-control-runtime.as +513 -0
- package/studio/server/swf-controls.js +119 -0
- package/studio/server/swf-export.js +293 -0
- package/studio/server/swf-import.js +1675 -0
- package/studio/server/swf-morphs.js +64 -0
- package/studio/server/swf-routes.js +42 -0
- package/studio/server/swf-streams.js +80 -0
- package/studio/server/swf-transition-runtime.as +52 -0
- package/studio/server/tween-recovery.js +106 -0
- package/studio/server-api.test.js +283 -0
- package/studio/server.js +320 -0
- package/studio/src/animated-image.js +423 -0
- package/studio/src/appearance-inspector.js +63 -0
- package/studio/src/arithmetic.js +50 -0
- package/studio/src/authored-controls.js +42 -0
- package/studio/src/busy.js +41 -0
- package/studio/src/canvas.js +430 -0
- package/studio/src/clipper-browser.js +2 -0
- package/studio/src/color-transform.js +38 -0
- package/studio/src/component-inspector.js +126 -0
- package/studio/src/components.js +268 -0
- package/studio/src/display-frame.js +262 -0
- package/studio/src/document-editing.js +69 -0
- package/studio/src/event-editor.js +150 -0
- package/studio/src/frame-editing.js +150 -0
- package/studio/src/frame-events.js +128 -0
- package/studio/src/frame-image.js +28 -0
- package/studio/src/groups.js +125 -0
- package/studio/src/handler-editor.js +122 -0
- package/studio/src/history.js +83 -0
- package/studio/src/imported-paths.js +99 -0
- package/studio/src/index.js +3582 -0
- package/studio/src/interaction-triggers.js +42 -0
- package/studio/src/json-patch.js +77 -0
- package/studio/src/layer-icons.js +25 -0
- package/studio/src/lottie-export.js +948 -0
- package/studio/src/lottie-import.js +1138 -0
- package/studio/src/masks.js +69 -0
- package/studio/src/media-assets.js +188 -0
- package/studio/src/media-library.js +193 -0
- package/studio/src/model.js +431 -0
- package/studio/src/numeric-fields.js +46 -0
- package/studio/src/object-list.js +57 -0
- package/studio/src/paint-tools.js +76 -0
- package/studio/src/placement-effects.js +74 -0
- package/studio/src/playback.js +10 -0
- package/studio/src/preview-audio.js +64 -0
- package/studio/src/preview-interactions.js +106 -0
- package/studio/src/preview-recorder.js +335 -0
- package/studio/src/preview-surface.js +338 -0
- package/studio/src/project-io.js +905 -0
- package/studio/src/project-session.js +375 -0
- package/studio/src/projects-dialog.js +319 -0
- package/studio/src/scene-transition.js +129 -0
- package/studio/src/script-editor.js +175 -0
- package/studio/src/script-references.js +74 -0
- package/studio/src/scripted-controls.js +146 -0
- package/studio/src/scripts.js +185 -0
- package/studio/src/stage-guides.js +101 -0
- package/studio/src/svg-animation.js +416 -0
- package/studio/src/svg-context.js +522 -0
- package/studio/src/svg-frame.js +413 -0
- package/studio/src/svg-import.js +1208 -0
- package/studio/src/swf-recording.js +104 -0
- package/studio/src/symbol-library.js +39 -0
- package/studio/src/symbols.js +62 -0
- package/studio/src/text-fields.js +58 -0
- package/studio/src/theme.js +43 -0
- package/studio/src/timeline.js +321 -0
- package/studio/src/vector-cut.js +103 -0
- package/studio/src/vector-geometry.js +254 -0
- package/studio/src/vector-style.js +146 -0
- package/studio/src/video-encode.js +84 -0
- package/studio/src/video-export.js +331 -0
- package/studio/src/video-mux.js +339 -0
- package/studio/src/video-playback.js +281 -0
- package/studio/src/workspace.js +344 -0
- package/studio/stroke-style.test.js +119 -0
- package/studio/styles.css +1547 -0
- package/studio/svg-export.test.js +162 -0
- package/studio/svg-import.test.js +318 -0
- package/studio/swf-authoring.test.js +140 -0
- package/studio/swf-export.test.js +324 -0
- package/studio/swf-import.test.js +489 -0
- package/studio/symbols.test.js +68 -0
- package/studio/tests/accessibility-interactions.mjs +138 -0
- package/studio/tests/appearance-interactions.mjs +103 -0
- package/studio/tests/control-interactions.mjs +60 -0
- package/studio/tests/event-interactions.mjs +117 -0
- package/studio/tests/external-resources.mjs +174 -0
- package/studio/tests/frame-image.mjs +71 -0
- package/studio/tests/html-export.mjs +68 -0
- package/studio/tests/import-files.mjs +131 -0
- package/studio/tests/lottie.mjs +125 -0
- package/studio/tests/mask-interactions.mjs +148 -0
- package/studio/tests/media-interactions.mjs +109 -0
- package/studio/tests/paint-interactions.mjs +64 -0
- package/studio/tests/project-interactions.mjs +244 -0
- package/studio/tests/script-interactions.mjs +178 -0
- package/studio/tests/scripted-control-interactions.mjs +107 -0
- package/studio/tests/svg-export.mjs +149 -0
- package/studio/tests/text-field-interactions.mjs +64 -0
- package/studio/tests/theme-interactions.mjs +53 -0
- package/studio/tests/timeline-browser.mjs +507 -0
- package/studio/tests/transition-interactions.mjs +94 -0
- package/studio/tests/trigger-interactions.mjs +93 -0
- package/studio/tests/video-export.mjs +243 -0
- package/studio/tests/workspace-interactions.mjs +226 -0
- package/studio/tween-recovery.test.js +31 -0
- package/studio/vector-style.test.js +56 -0
- package/studio/video-export.test.js +326 -0
- package/studiospec/actionscript.md +88 -0
- package/studiospec/architecture.md +378 -0
- package/studiospec/controls.md +100 -0
- package/studiospec/file-support.md +268 -0
- package/studiospec/lottie.md +69 -0
- package/studiospec/requirements.md +135 -0
- package/studiospec/stroke-style.md +95 -0
- package/studiospec/svg-export.md +83 -0
- package/studiospec/svg-import.md +139 -0
- package/studiospec/swooflib-integration.md +115 -0
- package/studiospec/tasks.md +573 -0
- package/studiospec/video-export.md +127 -0
- package/swf2js/__tests__/actionscript.test.js +1609 -0
- package/swf2js/__tests__/adpcm-audio.test.js +43 -0
- package/swf2js/__tests__/as2-compiler.test.js +153 -0
- package/swf2js/__tests__/as3-mixed-depth.test.js +498 -0
- package/swf2js/__tests__/authored-sprite-hit.test.js +118 -0
- package/swf2js/__tests__/authored-sprite-sizing.test.js +164 -0
- package/swf2js/__tests__/avm1-action-prefix.test.js +134 -0
- package/swf2js/__tests__/avm1-attach-movie.test.js +1151 -0
- package/swf2js/__tests__/avm1-boxhead-budget.test.js +73 -0
- package/swf2js/__tests__/avm1-cfg-bubble-tanks.test.js +101 -0
- package/swf2js/__tests__/avm1-cfg-mario-kart.test.js +184 -0
- package/swf2js/__tests__/avm1-cfg-mario.test.js +31 -0
- package/swf2js/__tests__/avm1-cfg-pacman.test.js +49 -0
- package/swf2js/__tests__/avm1-checkers-gameplay.test.js +122 -0
- package/swf2js/__tests__/avm1-clip-actions.test.js +2002 -0
- package/swf2js/__tests__/avm1-clone-drag.test.js +626 -0
- package/swf2js/__tests__/avm1-decompiler.test.js +102 -0
- package/swf2js/__tests__/avm1-dynamic-locals.test.js +159 -0
- package/swf2js/__tests__/avm1-formal-parameters.test.js +71 -0
- package/swf2js/__tests__/avm1-key-events.test.js +52 -0
- package/swf2js/__tests__/avm1-load-bitmap.test.js +75 -0
- package/swf2js/__tests__/avm1-loading-host-actions.test.js +764 -0
- package/swf2js/__tests__/avm1-multibyte-strings.test.js +63 -0
- package/swf2js/__tests__/avm1-pacman-gameplay.test.js +115 -0
- package/swf2js/__tests__/avm1-shape-hittest.test.js +311 -0
- package/swf2js/__tests__/avm1-shared-bodies.test.js +57 -0
- package/swf2js/__tests__/avm1-shared-runtime.test.js +1364 -0
- package/swf2js/__tests__/avm1-snake-gameplay.test.js +139 -0
- package/swf2js/__tests__/avm1-super.test.js +70 -0
- package/swf2js/__tests__/avm1-target-path.test.js +325 -0
- package/swf2js/__tests__/avm1-try.test.js +229 -0
- package/swf2js/__tests__/avm2-activation-closures.test.js +65 -0
- package/swf2js/__tests__/avm2-applytype.test.js +180 -0
- package/swf2js/__tests__/avm2-call-ops.test.js +232 -0
- package/swf2js/__tests__/avm2-callsuperid.test.js +231 -0
- package/swf2js/__tests__/avm2-class-initializer.test.js +219 -0
- package/swf2js/__tests__/avm2-custom-namespace.test.js +139 -0
- package/swf2js/__tests__/avm2-describe-type.test.js +96 -0
- package/swf2js/__tests__/avm2-dictionary.test.js +96 -0
- package/swf2js/__tests__/avm2-domain-memory.test.js +332 -0
- package/swf2js/__tests__/avm2-e4x.test.js +326 -0
- package/swf2js/__tests__/avm2-exceptions.test.js +81 -0
- package/swf2js/__tests__/avm2-findprop.test.js +110 -0
- package/swf2js/__tests__/avm2-getlex.test.js +166 -0
- package/swf2js/__tests__/avm2-global-slot.test.js +106 -0
- package/swf2js/__tests__/avm2-interface.test.js +95 -0
- package/swf2js/__tests__/avm2-multiname-precedence.test.js +148 -0
- package/swf2js/__tests__/avm2-named-namespace-types.test.js +106 -0
- package/swf2js/__tests__/avm2-optional-args.test.js +100 -0
- package/swf2js/__tests__/avm2-outer-scopes.test.js +101 -0
- package/swf2js/__tests__/avm2-package-internal-class.test.js +106 -0
- package/swf2js/__tests__/avm2-protected-namespace.test.js +105 -0
- package/swf2js/__tests__/avm2-protected.test.js +214 -0
- package/swf2js/__tests__/avm2-qwop-gameplay.test.js +116 -0
- package/swf2js/__tests__/avm2-runtime-namespaces.test.js +159 -0
- package/swf2js/__tests__/avm2-script-traits.test.js +89 -0
- package/swf2js/__tests__/avm2-shared-runtime.test.js +52 -0
- package/swf2js/__tests__/avm2-slot-ops.test.js +117 -0
- package/swf2js/__tests__/avm2-type-ops.test.js +224 -0
- package/swf2js/__tests__/bevel-filter.test.js +116 -0
- package/swf2js/__tests__/bitmap-button-mask.test.js +106 -0
- package/swf2js/__tests__/bitmap-data-draw.test.js +388 -0
- package/swf2js/__tests__/bitmap-decoder.test.js +108 -0
- package/swf2js/__tests__/bitmapdata-color-bounds.test.js +70 -0
- package/swf2js/__tests__/bitmapdata-copy-channel.test.js +91 -0
- package/swf2js/__tests__/bitmapdata-copy-pixels.test.js +136 -0
- package/swf2js/__tests__/bitmapdata-fill-compare.test.js +241 -0
- package/swf2js/__tests__/bitmapdata-filter.test.js +232 -0
- package/swf2js/__tests__/bitmapdata-hit-test.test.js +71 -0
- package/swf2js/__tests__/bitmapdata-merge.test.js +84 -0
- package/swf2js/__tests__/bitmapdata-palette-map.test.js +92 -0
- package/swf2js/__tests__/bitmapdata-pixels-io.test.js +198 -0
- package/swf2js/__tests__/bitmapdata-threshold.test.js +97 -0
- package/swf2js/__tests__/bitmapdata-vector.test.js +82 -0
- package/swf2js/__tests__/blur-filter.test.js +48 -0
- package/swf2js/__tests__/bundle-emitter.test.js +394 -0
- package/swf2js/__tests__/button-actions.test.js +370 -0
- package/swf2js/__tests__/button-color-transform.test.js +48 -0
- package/swf2js/__tests__/button-decoder.test.js +106 -0
- package/swf2js/__tests__/button-hit-test.test.js +825 -0
- package/swf2js/__tests__/button-scaling-grid.test.js +124 -0
- package/swf2js/__tests__/button-sound.test.js +105 -0
- package/swf2js/__tests__/bytearray-coercion.test.js +23 -0
- package/swf2js/__tests__/bytearray-object-serialization.test.js +380 -0
- package/swf2js/__tests__/cfg-switch-loop.test.js +103 -0
- package/swf2js/__tests__/clip-depth-mask.test.js +119 -0
- package/swf2js/__tests__/clipped-bitmap-fill.test.js +118 -0
- package/swf2js/__tests__/companion-swf.test.js +638 -0
- package/swf2js/__tests__/context-menu.test.js +149 -0
- package/swf2js/__tests__/convolution-filter.test.js +74 -0
- package/swf2js/__tests__/definefont4.test.js +280 -0
- package/swf2js/__tests__/display-displacement.test.js +161 -0
- package/swf2js/__tests__/display-list.test.js +80 -0
- package/swf2js/__tests__/display-mask-render.test.js +656 -0
- package/swf2js/__tests__/displayobject-stage.test.js +320 -0
- package/swf2js/__tests__/embedded-script-audio.test.js +131 -0
- package/swf2js/__tests__/embedded-swf.test.js +202 -0
- package/swf2js/__tests__/embedded-textfield.test.js +107 -0
- package/swf2js/__tests__/embedded-timeline-audio.test.js +182 -0
- package/swf2js/__tests__/embedded-timeline-input.test.js +420 -0
- package/swf2js/__tests__/embedded-timer-lifecycle.test.js +145 -0
- package/swf2js/__tests__/event-priority-order.test.js +125 -0
- package/swf2js/__tests__/event-weak-listeners.test.js +53 -0
- package/swf2js/__tests__/event-will-trigger.test.js +43 -0
- package/swf2js/__tests__/flash-text-engine-content.test.js +115 -0
- package/swf2js/__tests__/flash-text-engine-format.test.js +95 -0
- package/swf2js/__tests__/flash-text-engine-line.test.js +314 -0
- package/swf2js/__tests__/font-encoder.test.js +95 -0
- package/swf2js/__tests__/font-outline-text.test.js +659 -0
- package/swf2js/__tests__/glow-shadow-filter.test.js +68 -0
- package/swf2js/__tests__/graphics-bitmap-smoothing.test.js +32 -0
- package/swf2js/__tests__/graphics-fill-lifetime.test.js +36 -0
- package/swf2js/__tests__/graphics-gradient-matrix.test.js +53 -0
- package/swf2js/__tests__/graphics-stroke-hit-test.test.js +457 -0
- package/swf2js/__tests__/hit-test-primitives.test.js +414 -0
- package/swf2js/__tests__/input-events.test.js +714 -0
- package/swf2js/__tests__/integration/corpus.test.js +41 -0
- package/swf2js/__tests__/loader-embedded-swf.test.js +210 -0
- package/swf2js/__tests__/loader-info.test.js +81 -0
- package/swf2js/__tests__/local-connection.test.js +122 -0
- package/swf2js/__tests__/morph-focal-gradient.test.js +51 -0
- package/swf2js/__tests__/morph-topology.test.js +267 -0
- package/swf2js/__tests__/movie-data-codec.test.js +128 -0
- package/swf2js/__tests__/nellymoser-audio.test.js +84 -0
- package/swf2js/__tests__/opaque-background-cache.test.js +352 -0
- package/swf2js/__tests__/path-stream.test.js +81 -0
- package/swf2js/__tests__/place-object-filters.test.js +88 -0
- package/swf2js/__tests__/place-object3-decoder.test.js +116 -0
- package/swf2js/__tests__/place-object3-image.test.js +85 -0
- package/swf2js/__tests__/player-version.test.js +46 -0
- package/swf2js/__tests__/root-textfield.test.js +287 -0
- package/swf2js/__tests__/scaling-grid.test.js +183 -0
- package/swf2js/__tests__/shape-decoder.test.js +361 -0
- package/swf2js/__tests__/shape-line-style2.test.js +138 -0
- package/swf2js/__tests__/shape-nonscaling-stroke.test.js +131 -0
- package/swf2js/__tests__/shape-pixel-hint.test.js +101 -0
- package/swf2js/__tests__/simplebutton-pointer.test.js +1477 -0
- package/swf2js/__tests__/socket-offline.test.js +67 -0
- package/swf2js/__tests__/sound-avm1-stop.test.js +99 -0
- package/swf2js/__tests__/sound-envelope.test.js +110 -0
- package/swf2js/__tests__/sound-extract.test.js +168 -0
- package/swf2js/__tests__/sound-id3.test.js +283 -0
- package/swf2js/__tests__/sound-load.test.js +259 -0
- package/swf2js/__tests__/sound-mixer-spectrum.test.js +261 -0
- package/swf2js/__tests__/sound-stream-sprite.test.js +624 -0
- package/swf2js/__tests__/sound-transform.test.js +104 -0
- package/swf2js/__tests__/speex-audio.test.js +77 -0
- package/swf2js/__tests__/stage-noscale.test.js +45 -0
- package/swf2js/__tests__/swf-encoder.test.js +134 -0
- package/swf2js/__tests__/swflib-assemble.test.js +20 -0
- package/swf2js/__tests__/textfield-html-text.test.js +368 -0
- package/swf2js/__tests__/textfield-line-layout.test.js +339 -0
- package/swf2js/__tests__/textfield-programmatic-overlay.test.js +2506 -0
- package/swf2js/__tests__/textfield-scroll.test.js +79 -0
- package/swf2js/__tests__/textfield-selection.test.js +383 -0
- package/swf2js/__tests__/timeline-effect-surfaces.test.js +295 -0
- package/swf2js/__tests__/timeline-named-anchor.test.js +139 -0
- package/swf2js/__tests__/timeline-scenes.test.js +1723 -0
- package/swf2js/__tests__/urlloader-http-status.test.js +236 -0
- package/{src → swf2js}/cli.js +43 -11
- package/swf2js/compiler/as2-classes.js +156 -0
- package/swf2js/compiler/as2-parser.js +598 -0
- package/swf2js/compiler/avm1-codegen.js +897 -0
- package/swf2js/compiler/index.js +28 -0
- package/{src → swf2js}/decoder/button-decoder.js +3 -1
- package/swf2js/decoder/png.js +114 -0
- package/{src → swf2js}/decoder/shape-decoder.js +20 -10
- package/{src → swf2js}/decoder/tag-decoder.js +5 -3
- package/{src → swf2js}/decoder/tag-types.js +4 -0
- package/swf2js/decompiler/avm1-decompiler.js +1138 -0
- package/{src → swf2js}/emitter/asset-encoder.js +66 -113
- package/{src → swf2js}/emitter/bundle-emitter.js +209 -78
- package/swf2js/emitter/external-resources.js +39 -0
- package/swf2js/emitter/movie-data-codec.js +91 -0
- package/swf2js/encoder/bit-writer.js +182 -0
- package/swf2js/encoder/shape-encoder.js +310 -0
- package/swf2js/encoder/swf-builder.js +639 -0
- package/swf2js/encoder/swf-writer.js +55 -0
- package/{src/runtime/swflib/assemble.js → swf2js/runtime/assemble-swooflib.js} +4 -3
- package/{src → swf2js}/runtime/avm1-runtime.js +102 -63
- package/{src → swf2js}/runtime/index.js +1 -1
- package/{src → swf2js}/runtime/movie-runtime.js +28 -2
- package/{src → swf2js}/transpiler/actionscript.js +82 -19
- package/{src → swf2js}/transpiler/avm1/avm1-opcodes.js +5 -3
- package/{src → swf2js}/transpiler/avm1/avm1-transpiler.js +69 -6
- package/{src → swf2js}/transpiler/avm2/avm2-transpiler.js +1 -1
- package/{src → swf2js}/transpiler/timeline/display-list.js +41 -22
- package/{src → swf2js}/transpiler/timeline/timeline-codegen.js +97 -36
- package/swooflib/README.md +569 -0
- package/swooflib/adpcm.js +147 -0
- package/{src/runtime/swflib → swooflib}/builtins.js +6 -0
- package/{src/runtime/swflib → swooflib}/context-menu.js +7 -1
- package/swooflib/control-definitions.js +42 -0
- package/swooflib/control-widget.js +763 -0
- package/swooflib/controls.js +300 -0
- package/{src/runtime/swflib → swooflib}/display.js +16 -10
- package/{src/runtime/swflib → swooflib}/events.js +11 -0
- package/{src/runtime/swflib → swooflib}/flash.js +6 -5
- package/{src/runtime/swflib → swooflib}/graphics.js +81 -19
- package/{src/runtime/swflib → swooflib}/input.js +12 -14
- package/{src/runtime/swflib → swooflib}/loader.js +52 -22
- package/swooflib/movie-network.js +86 -0
- package/swooflib/path-stream.js +169 -0
- package/{src/runtime/swflib → swooflib}/render.js +3 -13
- package/{src/runtime/swflib → swooflib}/sound.js +25 -2
- package/{src/runtime/swflib → swooflib}/stage.js +3 -3
- package/swooflib/stream-time.js +21 -0
- package/{src/runtime/swflib → swooflib}/system.js +88 -37
- package/{src/runtime/swflib → swooflib}/text-paint.js +14 -3
- package/{src/runtime/swflib → swooflib}/text.js +8 -0
- package/swooflib/xml-node.js +53 -0
- package/src/emitter/timeline-data-codec.js +0 -58
- /package/{src → swf2js}/decoder/symbol-table.js +0 -0
- /package/{src → swf2js}/emitter/embedded-swf.js +0 -0
- /package/{src → swf2js}/emitter/font-encoder.js +0 -0
- /package/{src → swf2js}/model/swf-document.js +0 -0
- /package/{src → swf2js}/model/transpile-result.js +0 -0
- /package/{src → swf2js}/parser/bit-reader.js +0 -0
- /package/{src → swf2js}/parser/decompressor.js +0 -0
- /package/{src → swf2js}/parser/swf-parser.js +0 -0
- /package/{src → swf2js}/pretty-printer/pretty-printer.js +0 -0
- /package/{src → swf2js}/runtime/avm2-runtime.js +0 -0
- /package/{src → swf2js}/runtime/embedded-movie-runtime.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-ir.js +0 -0
- /package/{src → swf2js}/transpiler/avm1/avm1-rewrite.js +0 -0
- /package/{src → swf2js}/transpiler/avm2/abc-reader.js +0 -0
- /package/{src → swf2js}/transpiler/cfg-structurer.js +0 -0
- /package/{src → swf2js}/util/diagnostics.js +0 -0
- /package/{src → swf2js}/util/logger.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap-image.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bitmap.js +0 -0
- /package/{src/runtime/swflib → swooflib}/bytearray.js +0 -0
- /package/{src/runtime/swflib → swooflib}/compiled-swf.js +0 -0
- /package/{src/runtime/swflib → swooflib}/cursor-flag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/dictionary.js +0 -0
- /package/{src/runtime/swflib → swooflib}/filters.js +0 -0
- /package/{src/runtime/swflib → swooflib}/geom.js +0 -0
- /package/{src/runtime/swflib → swooflib}/glyph-metrics.js +0 -0
- /package/{src/runtime/swflib → swooflib}/host.js +0 -0
- /package/{src/runtime/swflib → swooflib}/inherit.js +0 -0
- /package/{src/runtime/swflib → swooflib}/marks.js +0 -0
- /package/{src/runtime/swflib → swooflib}/matrix3d.js +0 -0
- /package/{src/runtime/swflib → swooflib}/pointer-bridge.js +0 -0
- /package/{src/runtime/swflib → swooflib}/projection.js +0 -0
- /package/{src/runtime/swflib → swooflib}/sprite-drag.js +0 -0
- /package/{src/runtime/swflib → swooflib}/stage-ref.js +0 -0
- /package/{src/runtime/swflib → swooflib}/text-field.js +0 -0
- /package/{src/runtime/swflib → swooflib}/transform.js +0 -0
- /package/{src/runtime/swflib → swooflib}/xml.js +0 -0
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
// Native input surfaces for authored Flash components. Hosts own placement, timeline scope,
|
|
2
|
+
// and variable binding. Reuse a widget for the lifetime of one display-list instance.
|
|
3
|
+
const choices = new Set(['ComboBox', 'List', 'DataGrid', 'TileList', 'Menu', 'MenuBar', 'Tree', 'Accordion']);
|
|
4
|
+
const number = (value, fallback) => Number.isFinite(Number(value)) ? Number(value) : fallback;
|
|
5
|
+
const textOf = item =>
|
|
6
|
+
String(item && typeof item === 'object' ? item.label ?? item.name ?? Object.values(item)[0] ?? '' : item ?? '');
|
|
7
|
+
const selectedValue = (p, item, index) => p.data?.[index] ?? item?.data ?? item;
|
|
8
|
+
let nextWidgetId = 0;
|
|
9
|
+
|
|
10
|
+
export function controlValue(kind, p) {
|
|
11
|
+
if (kind === 'RadioButton') return p.selectedData ?? (p.selected ? p.data ?? p.label : undefined);
|
|
12
|
+
if (kind === 'CheckBox' || kind === 'Button') return !!p.selected;
|
|
13
|
+
if (kind === 'TextInput' || kind === 'TextArea' || kind === 'Label') return p.text ?? '';
|
|
14
|
+
if (kind === 'ColorPicker') return p.selectedColor;
|
|
15
|
+
if (kind === 'DateChooser' || kind === 'DateField') return p.selectedDate;
|
|
16
|
+
if (kind === 'ScrollBar' || kind === 'ScrollPane') return p.scrollPosition ?? 0;
|
|
17
|
+
if (kind === 'ProgressBar') return p.percentComplete ?? 0;
|
|
18
|
+
if (kind === 'Loader') return p.percentLoaded ?? 0;
|
|
19
|
+
if (choices.has(kind)) return p.value ?? selectedValue(p, indexedItems(p, kind)[p.selectedIndex], p.selectedIndex);
|
|
20
|
+
return p.value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function controlValueChange(kind, p, value) {
|
|
24
|
+
if (kind === 'RadioButton') return { selected: (p.data ?? p.label) === value };
|
|
25
|
+
if (kind === 'Button' || kind === 'CheckBox') return { selected: !!value };
|
|
26
|
+
if (kind === 'TextInput' || kind === 'TextArea' || kind === 'Label') return { text: String(value ?? '') };
|
|
27
|
+
if (kind === 'ColorPicker') return { selectedColor: value };
|
|
28
|
+
if (kind === 'DateChooser' || kind === 'DateField') return { selectedDate: value };
|
|
29
|
+
if (kind === 'ScrollBar') return { scrollPosition: number(value, 0) };
|
|
30
|
+
if (kind === 'ScrollPane') return { scrollPosition: number(value, 0), verticalScrollPosition: number(value, 0) };
|
|
31
|
+
if (kind === 'ProgressBar') return { percentComplete: number(value, 0) };
|
|
32
|
+
if (kind === 'Loader') return { percentLoaded: number(value, 0) };
|
|
33
|
+
if (choices.has(kind)) {
|
|
34
|
+
const items = indexedItems(p, kind);
|
|
35
|
+
return { selectedIndex: items.findIndex((item, i) => selectedValue(p, item, i) === value), value };
|
|
36
|
+
}
|
|
37
|
+
return { value };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function element(tag, parent, text) {
|
|
41
|
+
const el = document.createElement(tag);
|
|
42
|
+
if (text !== undefined) el.textContent = text;
|
|
43
|
+
parent.append(el);
|
|
44
|
+
return el;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function formattedText(source) {
|
|
48
|
+
// Copy Flash's inline text styles into a fresh fragment. The parsed source stays inert.
|
|
49
|
+
const template = document.createElement('template');
|
|
50
|
+
template.innerHTML = String(source ?? '');
|
|
51
|
+
const fragment = document.createDocumentFragment();
|
|
52
|
+
function append(from, to) {
|
|
53
|
+
for (const child of from.childNodes) {
|
|
54
|
+
if (child.nodeType === Node.TEXT_NODE) to.append(document.createTextNode(child.data));
|
|
55
|
+
if (child.nodeType !== Node.ELEMENT_NODE) continue;
|
|
56
|
+
const tag = child.localName;
|
|
57
|
+
if (['script','style','template'].includes(tag)) continue;
|
|
58
|
+
if (tag === 'br' || tag === 'sbr') {
|
|
59
|
+
to.append(document.createElement('br'));
|
|
60
|
+
// HTML's parser treats Flash's self-closing SBR as a container.
|
|
61
|
+
if (tag === 'sbr') append(child, to);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const target = ['b','i','u','strong','em','p','font'].includes(tag)
|
|
65
|
+
? element(tag === 'font' ? 'span' : tag, to) : to;
|
|
66
|
+
if (tag === 'font') {
|
|
67
|
+
target.style.color = child.getAttribute('color') ?? '';
|
|
68
|
+
target.style.fontFamily = child.getAttribute('face') ?? '';
|
|
69
|
+
const size = Number(child.getAttribute('size'));
|
|
70
|
+
if (size > 0) target.style.fontSize = size + 'px';
|
|
71
|
+
const spacing = child.getAttribute('letterspacing');
|
|
72
|
+
if (spacing?.trim() && Number.isFinite(+spacing)) target.style.letterSpacing = Number(spacing) + 'px';
|
|
73
|
+
const kern = child.getAttribute('kerning');
|
|
74
|
+
if (kern === '0' || kern === '1') target.style.fontKerning = kern === '1' ? 'normal' : 'none';
|
|
75
|
+
} else if (tag === 'p') {
|
|
76
|
+
const align = child.getAttribute('align');
|
|
77
|
+
if (['left', 'right', 'center', 'justify'].includes(align)) target.style.textAlign = align;
|
|
78
|
+
}
|
|
79
|
+
append(child, target);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
append(template.content, fragment);
|
|
83
|
+
return fragment;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Flash TextField.restrict switches between included and excluded ranges at unescaped ^.
|
|
87
|
+
function restrictText(text, restrict) {
|
|
88
|
+
if (!restrict || typeof restrict !== 'string') return text;
|
|
89
|
+
const tokens = [];
|
|
90
|
+
for (let i = 0; i < restrict.length; i++) {
|
|
91
|
+
const escaped = restrict[i] === '\\' && i + 1 < restrict.length;
|
|
92
|
+
tokens.push({ char: escaped ? restrict[++i] : restrict[i], escaped });
|
|
93
|
+
}
|
|
94
|
+
return Array.from(text)
|
|
95
|
+
.filter(char => {
|
|
96
|
+
let allow = tokens[0]?.char === '^' && !tokens[0].escaped;
|
|
97
|
+
let include = true;
|
|
98
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
99
|
+
const from = tokens[i];
|
|
100
|
+
if (from.char === '^' && !from.escaped) {
|
|
101
|
+
include = !include;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let to = from;
|
|
105
|
+
if (tokens[i + 1]?.char === '-' && !tokens[i + 1].escaped && tokens[i + 2]) {
|
|
106
|
+
to = tokens[i + 2];
|
|
107
|
+
i += 2;
|
|
108
|
+
}
|
|
109
|
+
if (char >= from.char && char <= to.char) allow = include;
|
|
110
|
+
}
|
|
111
|
+
return allow;
|
|
112
|
+
})
|
|
113
|
+
.join('');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function choiceItems(p) {
|
|
117
|
+
const source = p.dataProvider?.length ? p.dataProvider : p.labels ?? [];
|
|
118
|
+
if (Array.isArray(source)) return source;
|
|
119
|
+
if (typeof source !== 'string' || !source.trim().startsWith('<') || typeof DOMParser === 'undefined') return [];
|
|
120
|
+
const root = new DOMParser().parseFromString(source, 'application/xml').documentElement;
|
|
121
|
+
const read = el => ({
|
|
122
|
+
label: el.getAttribute('label') ?? el.localName,
|
|
123
|
+
data: el.getAttribute('data'),
|
|
124
|
+
children: [...el.children].map(read)
|
|
125
|
+
});
|
|
126
|
+
return [...root.children].map(read);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function childrenOf(item) {
|
|
130
|
+
const children = item?.children ?? item?.items;
|
|
131
|
+
return Array.isArray(children) ? children : [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function indexedItems(p, kind) {
|
|
135
|
+
const items = choiceItems(p);
|
|
136
|
+
if (!['Tree', 'Accordion', 'Menu', 'MenuBar', 'TileList'].includes(kind)) return items;
|
|
137
|
+
const flatten = list => list.flatMap(item => [item, ...flatten(childrenOf(item))]);
|
|
138
|
+
return flatten(items);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function dateString(date) {
|
|
142
|
+
if (!date) return '';
|
|
143
|
+
if (typeof date === 'string' && /^\d{4}-\d\d-\d\d/.test(date)) return date.slice(0, 10);
|
|
144
|
+
const d = new Date(date);
|
|
145
|
+
return Number.isNaN(d.getTime()) ? '' : dayString(d);
|
|
146
|
+
}
|
|
147
|
+
const dayString =
|
|
148
|
+
d => [d.getFullYear(), String(d.getMonth() + 1).padStart(2, '0'), String(d.getDate()).padStart(2, '0')].join('-');
|
|
149
|
+
|
|
150
|
+
export function createControlWidget(
|
|
151
|
+
kind, parameters = {}, { name = kind, groupScope = '', onEvent = () => { }, resolveContent } = {}) {
|
|
152
|
+
const node = document.createElement('div');
|
|
153
|
+
const uid = 'swoof-control-' + (++nextWidgetId);
|
|
154
|
+
node.dataset.control = kind;
|
|
155
|
+
Object.assign(node.style, {
|
|
156
|
+
position: 'relative',
|
|
157
|
+
width: '100%',
|
|
158
|
+
height: '100%',
|
|
159
|
+
boxSizing: 'border-box',
|
|
160
|
+
font: '13px Arial, sans-serif',
|
|
161
|
+
lineHeight: 'normal',
|
|
162
|
+
colorScheme: 'light',
|
|
163
|
+
color: '#202328',
|
|
164
|
+
pointerEvents: 'auto'
|
|
165
|
+
});
|
|
166
|
+
let p = { ...parameters };
|
|
167
|
+
if (kind === 'Loader') p.percentLoaded ??= 0;
|
|
168
|
+
if (kind === 'ScrollPane') {
|
|
169
|
+
p.verticalScrollPosition ??= p.scrollPosition ?? 0;
|
|
170
|
+
p.scrollPosition = p.verticalScrollPosition;
|
|
171
|
+
p.horizontalScrollPosition ??= 0;
|
|
172
|
+
}
|
|
173
|
+
let input, viewMonth;
|
|
174
|
+
|
|
175
|
+
function changed(type, fields = {}) {
|
|
176
|
+
if (p.enabled === false || p.visible === false) return;
|
|
177
|
+
Object.assign(p, fields);
|
|
178
|
+
onEvent(type, getProperties());
|
|
179
|
+
}
|
|
180
|
+
function getProperties() {
|
|
181
|
+
if (choices.has(kind)) {
|
|
182
|
+
const items = indexedItems(p, kind);
|
|
183
|
+
if (input?.tagName === 'SELECT') p.selectedIndex = input.selectedIndex;
|
|
184
|
+
p.selectedItem = items[p.selectedIndex];
|
|
185
|
+
if (p.selectedItem !== undefined)
|
|
186
|
+
p.value = p.data?.[p.selectedIndex] ?? p.selectedItem?.data ?? p.selectedItem;
|
|
187
|
+
else if (!p.editable)
|
|
188
|
+
p.value = undefined;
|
|
189
|
+
if (input?.multiple) p.selectedIndices = Array.from(input.selectedOptions, opt => opt.index);
|
|
190
|
+
}
|
|
191
|
+
if (kind === 'RadioButton' && input) {
|
|
192
|
+
p.selected = input.checked;
|
|
193
|
+
const group = input.ownerDocument.getElementsByName(input.name);
|
|
194
|
+
const active = Array.from(group).find(other => other.checked);
|
|
195
|
+
return { ...p, selectedData: active?.__swoofRadioData };
|
|
196
|
+
}
|
|
197
|
+
return { ...p };
|
|
198
|
+
}
|
|
199
|
+
function field(tag, parent = node, label = name) {
|
|
200
|
+
const child = element(tag, parent);
|
|
201
|
+
child.setAttribute('aria-label', label);
|
|
202
|
+
Object.assign(child.style, {
|
|
203
|
+
position: 'static',
|
|
204
|
+
boxSizing: 'border-box',
|
|
205
|
+
font: 'inherit',
|
|
206
|
+
color: 'inherit',
|
|
207
|
+
width: '100%',
|
|
208
|
+
height: '100%',
|
|
209
|
+
margin: '0',
|
|
210
|
+
minWidth: '0',
|
|
211
|
+
minHeight: '0'
|
|
212
|
+
});
|
|
213
|
+
if (child.tagName === 'BUTTON') child.type = 'button';
|
|
214
|
+
if ('disabled' in child) child.disabled = p.enabled === false;
|
|
215
|
+
return child;
|
|
216
|
+
}
|
|
217
|
+
function select(i, items, event = 'change', indices = [i]) {
|
|
218
|
+
const value = p.data?.[i] ?? items[i]?.data ?? items[i];
|
|
219
|
+
changed(event, { selectedIndex: i, selectedIndices: indices, selectedItem: items[i], value });
|
|
220
|
+
}
|
|
221
|
+
function media(src, parent) {
|
|
222
|
+
const url = resolveContent?.(src);
|
|
223
|
+
if (!url) return null;
|
|
224
|
+
const img = element('img', parent);
|
|
225
|
+
img.alt = name;
|
|
226
|
+
if (p.scaleContent !== false)
|
|
227
|
+
Object.assign(img.style, { objectFit: 'contain', width: '100%', height: '100%' });
|
|
228
|
+
return { img, url };
|
|
229
|
+
}
|
|
230
|
+
function mountChecks() {
|
|
231
|
+
const label = element('label', node);
|
|
232
|
+
Object.assign(label.style, {
|
|
233
|
+
display: 'flex',
|
|
234
|
+
gap: '4px',
|
|
235
|
+
width: '100%',
|
|
236
|
+
height: '100%',
|
|
237
|
+
alignItems: 'center',
|
|
238
|
+
flexDirection: ({ left: 'row-reverse', top: 'column-reverse', bottom: 'column' })[p.labelPlacement] ?? 'row'
|
|
239
|
+
});
|
|
240
|
+
input = field('input', label, p.label ?? name);
|
|
241
|
+
input.type = kind === 'RadioButton' ? 'radio' : 'checkbox';
|
|
242
|
+
input.style.width = input.style.height = 'auto';
|
|
243
|
+
if (input.type === 'radio') {
|
|
244
|
+
input.name = JSON.stringify([groupScope, p.groupName ?? 'radioGroup']);
|
|
245
|
+
input.__swoofRadioData = p.data ?? p.label;
|
|
246
|
+
}
|
|
247
|
+
input.checked = !!p.selected;
|
|
248
|
+
label.append(document.createTextNode(p.label ?? name));
|
|
249
|
+
input.onclick = () => changed('click', { selected: input.checked });
|
|
250
|
+
}
|
|
251
|
+
function mountText() {
|
|
252
|
+
if (kind === 'TextArea' && p.html) {
|
|
253
|
+
input = field('div');
|
|
254
|
+
input.setAttribute('role','textbox');
|
|
255
|
+
input.setAttribute('aria-multiline','true');
|
|
256
|
+
input.contentEditable = p.editable === false ? 'false' : 'plaintext-only';
|
|
257
|
+
input.tabIndex = p.enabled === false ? -1 : 0;
|
|
258
|
+
Object.assign(input.style,{background:'#fff',overflow:'auto',border:'1px solid #888',padding:'2px',
|
|
259
|
+
whiteSpace:p.wordWrap === false ? 'pre' : 'pre-wrap'});
|
|
260
|
+
input.append(formattedText(p.text));
|
|
261
|
+
input.oninput = () => changed('change',{text:input.innerHTML});
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
input = field(kind === 'TextArea' ? 'textarea' : 'input');
|
|
265
|
+
if (kind === 'TextInput')
|
|
266
|
+
input.type = p.password ? 'password' : 'text';
|
|
267
|
+
else {
|
|
268
|
+
input.wrap = p.wordWrap === false ? 'off' : 'soft';
|
|
269
|
+
input.style.resize = 'none';
|
|
270
|
+
}
|
|
271
|
+
input.value = p.text ?? '';
|
|
272
|
+
input.readOnly = p.editable === false;
|
|
273
|
+
if (number(p.maxChars, 0) > 0) input.maxLength = p.maxChars;
|
|
274
|
+
const update = () => {
|
|
275
|
+
const value = restrictText(input.value, p.restrict);
|
|
276
|
+
if (input.value !== value) input.value = value;
|
|
277
|
+
if (p.text !== value) changed('change', { text: value });
|
|
278
|
+
};
|
|
279
|
+
input.oninput = e => {
|
|
280
|
+
if (!e.isComposing) update();
|
|
281
|
+
};
|
|
282
|
+
input.oncompositionend = update;
|
|
283
|
+
if (kind === 'TextInput')
|
|
284
|
+
input.onkeydown = e => {
|
|
285
|
+
if (e.key === 'Enter' && !e.isComposing) changed('enter', { text: input.value });
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
// The top layer keeps dropdowns usable inside a scaled or clipped movie.
|
|
289
|
+
function popup(anchor, body, role, width) {
|
|
290
|
+
body.popover = 'auto';
|
|
291
|
+
body.id = uid + '-popup';
|
|
292
|
+
body.setAttribute('role', role);
|
|
293
|
+
body.setAttribute('aria-label', name);
|
|
294
|
+
Object.assign(body.style, { position: 'fixed', inset: 'auto', margin: '0', padding: '2px',
|
|
295
|
+
border: '1px solid #888', boxSizing: 'border-box', overflow: 'auto', maxHeight: '95vh' });
|
|
296
|
+
anchor.setAttribute('aria-haspopup', role);
|
|
297
|
+
anchor.setAttribute('aria-controls', body.id);
|
|
298
|
+
anchor.setAttribute('aria-expanded', 'false');
|
|
299
|
+
body.addEventListener('toggle', () => anchor.setAttribute('aria-expanded', String(body.matches(':popover-open'))));
|
|
300
|
+
const open = () => {
|
|
301
|
+
if (p.enabled === false || !node.isConnected) return;
|
|
302
|
+
const rect = node.getBoundingClientRect();
|
|
303
|
+
body.style.width = Math.min(innerWidth, width ?? rect.width) + 'px';
|
|
304
|
+
body.showPopover();
|
|
305
|
+
body.style.left = Math.max(0, Math.min(innerWidth - body.offsetWidth, rect.left)) + 'px';
|
|
306
|
+
body.style.top = (rect.bottom + body.offsetHeight <= innerHeight ? rect.bottom :
|
|
307
|
+
Math.max(0, rect.top - body.offsetHeight)) + 'px';
|
|
308
|
+
};
|
|
309
|
+
const close = () => { body.hidePopover(); anchor.focus(); };
|
|
310
|
+
anchor.onclick = () => body.matches(':popover-open') ? close() : open();
|
|
311
|
+
return { open, close };
|
|
312
|
+
}
|
|
313
|
+
function mountCombo(items) {
|
|
314
|
+
const editable = p.editable;
|
|
315
|
+
input = field(editable ? 'input' : 'button');
|
|
316
|
+
input.setAttribute('role', 'combobox');
|
|
317
|
+
const list = element('select', node);
|
|
318
|
+
list.setAttribute('aria-label', name + ' choices');
|
|
319
|
+
list.size = Math.max(2, Math.min(Number(p.rowCount) || 5, items.length));
|
|
320
|
+
if (p.rowCount === 1 || items.length === 1) list.style.height = '1.7em';
|
|
321
|
+
for (const item of items) element('option', list, textOf(item));
|
|
322
|
+
list.selectedIndex = p.selectedIndex;
|
|
323
|
+
const caption = textOf(items[p.selectedIndex]);
|
|
324
|
+
if (editable) input.value = p.text ?? caption;
|
|
325
|
+
else input.textContent = caption + ' ▾';
|
|
326
|
+
const menu = popup(input, list, 'listbox');
|
|
327
|
+
function choose() {
|
|
328
|
+
const i = list.selectedIndex;
|
|
329
|
+
if (i < 0) return;
|
|
330
|
+
const text = textOf(items[i]);
|
|
331
|
+
if (editable) input.value = text;
|
|
332
|
+
else input.textContent = text + ' ▾';
|
|
333
|
+
menu.close();
|
|
334
|
+
changed('change', { text, selectedIndex: i, selectedItem: items[i], value: selectedValue(p, items[i], i) });
|
|
335
|
+
}
|
|
336
|
+
list.onclick = choose;
|
|
337
|
+
list.onkeydown = e => {
|
|
338
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); choose(); }
|
|
339
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); menu.close(); }
|
|
340
|
+
};
|
|
341
|
+
input.onkeydown = e => {
|
|
342
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
343
|
+
e.preventDefault(); menu.open(); list.focus();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
if (editable) input.oninput = () => {
|
|
347
|
+
const i = items.findIndex(item => textOf(item) === input.value);
|
|
348
|
+
list.selectedIndex = i;
|
|
349
|
+
changed('change', { text: input.value, selectedIndex: i, value: i < 0 ? input.value : selectedValue(p, items[i], i) });
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function mountChoices() {
|
|
353
|
+
const items = choiceItems(p);
|
|
354
|
+
if (kind === 'ComboBox') { mountCombo(items); return; }
|
|
355
|
+
input = field('select');
|
|
356
|
+
if (kind === 'List') {
|
|
357
|
+
input.multiple = !!p.multipleSelection;
|
|
358
|
+
input.size = Math.max(2, p.rowCount || items.length || 2);
|
|
359
|
+
}
|
|
360
|
+
for (const [i, item] of items.entries()) {
|
|
361
|
+
const option = element('option', input, textOf(item));
|
|
362
|
+
option.value = String(i);
|
|
363
|
+
if (p.rowHeight && kind === 'List') option.style.minHeight = number(p.rowHeight, 16) + 'px';
|
|
364
|
+
}
|
|
365
|
+
if (input.multiple && p.selectedIndices?.length)
|
|
366
|
+
for (const option of input.options) option.selected = p.selectedIndices.includes(option.index);
|
|
367
|
+
else
|
|
368
|
+
input.selectedIndex = p.selectedIndex ?? (kind === 'List' ? -1 : 0);
|
|
369
|
+
input.onchange = () =>
|
|
370
|
+
select(input.selectedIndex, items, 'change', Array.from(input.selectedOptions, opt => opt.index));
|
|
371
|
+
}
|
|
372
|
+
function mountRange() {
|
|
373
|
+
input = field('input');
|
|
374
|
+
input.type = kind === 'NumericStepper' ? 'number' : 'range';
|
|
375
|
+
const scroll = kind === 'ScrollBar';
|
|
376
|
+
const min = number(scroll ? p.minScrollPosition ?? p.minimum : p.minimum, 0);
|
|
377
|
+
const max = Math.max(min, number(scroll ? p.maxScrollPosition ?? p.maximum : p.maximum, 100));
|
|
378
|
+
const step = number(p.stepSize ?? p.snapInterval ?? p.lineScrollSize, 1);
|
|
379
|
+
input.min = min;
|
|
380
|
+
input.max = max;
|
|
381
|
+
input.step = step > 0 ? step : 'any';
|
|
382
|
+
const normalize = raw => {
|
|
383
|
+
const bounded = Math.max(min, Math.min(max, number(raw, min)));
|
|
384
|
+
if (step <= 0) return bounded;
|
|
385
|
+
return Math.max(min, Math.min(max, Number((min + step * Math.round((bounded - min) / step)).toFixed(10))));
|
|
386
|
+
};
|
|
387
|
+
const property = scroll ? 'scrollPosition' : 'value';
|
|
388
|
+
input.value = p[property] = normalize(p[property]);
|
|
389
|
+
if (input.type === 'range' && (scroll ? !p.horizontal : p.direction === 'vertical')) {
|
|
390
|
+
input.style.writingMode = 'vertical-lr';
|
|
391
|
+
input.style.direction = scroll ? 'ltr' : 'rtl';
|
|
392
|
+
}
|
|
393
|
+
const update = () => {
|
|
394
|
+
let value = input.valueAsNumber;
|
|
395
|
+
if (!Number.isFinite(value)) return;
|
|
396
|
+
value = normalize(value);
|
|
397
|
+
if (input.valueAsNumber !== value) input.valueAsNumber = value;
|
|
398
|
+
if (p[property] !== value) changed(scroll ? 'scroll' : 'change', { [property]: value });
|
|
399
|
+
};
|
|
400
|
+
input.oninput = input.onchange = update;
|
|
401
|
+
}
|
|
402
|
+
function listKeyboard(parent, selector) {
|
|
403
|
+
parent.addEventListener('keydown', e => {
|
|
404
|
+
const items = [...parent.querySelectorAll(selector)].filter(x => !x.disabled && x.getClientRects().length);
|
|
405
|
+
let i = items.indexOf(e.target);
|
|
406
|
+
if (i < 0) return;
|
|
407
|
+
if (e.key === 'Home')
|
|
408
|
+
i = 0;
|
|
409
|
+
else if (e.key === 'End')
|
|
410
|
+
i = items.length - 1;
|
|
411
|
+
else if (['ArrowDown', 'ArrowRight'].includes(e.key))
|
|
412
|
+
i = Math.min(i + 1, items.length - 1);
|
|
413
|
+
else if (['ArrowUp', 'ArrowLeft'].includes(e.key))
|
|
414
|
+
i = Math.max(i - 1, 0);
|
|
415
|
+
else
|
|
416
|
+
return;
|
|
417
|
+
e.preventDefault();
|
|
418
|
+
items[i]?.focus();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function mountCollection() {
|
|
422
|
+
const items = choiceItems(p);
|
|
423
|
+
const body = element('div', node);
|
|
424
|
+
Object.assign(body.style, {
|
|
425
|
+
height: '100%',
|
|
426
|
+
overflow: 'auto',
|
|
427
|
+
background: '#fff',
|
|
428
|
+
border: '1px solid #888',
|
|
429
|
+
boxSizing: 'border-box'
|
|
430
|
+
});
|
|
431
|
+
if (kind === 'DataGrid') {
|
|
432
|
+
const table = element('table', body);
|
|
433
|
+
table.style.width = '100%';
|
|
434
|
+
table.style.borderCollapse = 'collapse';
|
|
435
|
+
const columns = p.columns?.length ?
|
|
436
|
+
p.columns :
|
|
437
|
+
(typeof items[0] === 'object' && items[0] ? Object.keys(items[0]) : ['label']);
|
|
438
|
+
const header = element('tr', element('thead', table));
|
|
439
|
+
for (const col of columns) element('th', header, col?.headerText ?? col?.label ?? col?.dataField ?? String(col ?? ''));
|
|
440
|
+
const rows = element('tbody', table);
|
|
441
|
+
for (const [i, item] of items.entries()) {
|
|
442
|
+
const row = element('tr', rows);
|
|
443
|
+
row.tabIndex = 0;
|
|
444
|
+
for (const col of columns)
|
|
445
|
+
element('td', row, item?.[col?.dataField ?? col] ?? (columns.length === 1 ? textOf(item) : ''));
|
|
446
|
+
const pick = () => {
|
|
447
|
+
select(i, items);
|
|
448
|
+
for (const tr of rows.children) tr.style.background = tr === row ? '#b8d7fc' : '';
|
|
449
|
+
};
|
|
450
|
+
row.onclick = pick;
|
|
451
|
+
row.onkeydown = e => {
|
|
452
|
+
if (['Enter', ' '].includes(e.key)) {
|
|
453
|
+
e.preventDefault();
|
|
454
|
+
pick();
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
if (p.selectedIndex === i) row.style.background = '#b8d7fc';
|
|
458
|
+
}
|
|
459
|
+
listKeyboard(body, 'tbody tr');
|
|
460
|
+
} else {
|
|
461
|
+
if (kind === 'MenuBar' || kind === 'TileList')
|
|
462
|
+
Object.assign(body.style, { display: 'flex', alignContent: 'start', flexWrap: 'wrap' });
|
|
463
|
+
let index = 0;
|
|
464
|
+
const append = (item, parent) => {
|
|
465
|
+
const i = index++;
|
|
466
|
+
const label = textOf(item);
|
|
467
|
+
const children = childrenOf(item);
|
|
468
|
+
const expandable = children.length || kind === 'Accordion';
|
|
469
|
+
let holder = parent;
|
|
470
|
+
let itemNode;
|
|
471
|
+
if (expandable) {
|
|
472
|
+
const details = element('details', parent);
|
|
473
|
+
if (kind === 'Accordion') details.name = uid;
|
|
474
|
+
itemNode = element('summary', details, label);
|
|
475
|
+
holder = details;
|
|
476
|
+
} else {
|
|
477
|
+
itemNode = field('button', parent, label);
|
|
478
|
+
itemNode.textContent = label;
|
|
479
|
+
}
|
|
480
|
+
Object.assign(itemNode.style, {
|
|
481
|
+
width: ['TileList', 'MenuBar'].includes(kind) ? 'auto' : '100%',
|
|
482
|
+
height: 'auto',
|
|
483
|
+
textAlign: 'left'
|
|
484
|
+
});
|
|
485
|
+
if (i === p.selectedIndex) itemNode.style.background = '#b8d7fc';
|
|
486
|
+
itemNode.onclick = () => {
|
|
487
|
+
for (const old of body.querySelectorAll('[aria-current="true"]')) {
|
|
488
|
+
old.removeAttribute('aria-current');
|
|
489
|
+
old.style.background = '';
|
|
490
|
+
}
|
|
491
|
+
itemNode.setAttribute('aria-current', 'true');
|
|
492
|
+
itemNode.style.background = '#b8d7fc';
|
|
493
|
+
changed('change', { selectedIndex: i, selectedItem: item, value: p.data?.[i] ?? item?.data ?? item });
|
|
494
|
+
};
|
|
495
|
+
if (i === p.selectedIndex) itemNode.setAttribute('aria-current', 'true');
|
|
496
|
+
if (expandable) {
|
|
497
|
+
if (item?.content) element('div', holder, String(item.content));
|
|
498
|
+
for (const child of children) append(child, holder);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
for (const item of items) append(item, body);
|
|
502
|
+
listKeyboard(body, 'button,summary');
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function mountDateChooser(parent = node, onSelect) {
|
|
506
|
+
const date = dateString(p.selectedDate);
|
|
507
|
+
viewMonth ??= date ? new Date(date + 'T12:00:00') : new Date();
|
|
508
|
+
const month = new Date(viewMonth.getFullYear(), viewMonth.getMonth(), 1, 12);
|
|
509
|
+
const wrap = element('div', parent);
|
|
510
|
+
Object.assign(wrap.style, {
|
|
511
|
+
display: 'grid',
|
|
512
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
513
|
+
gridTemplateRows: 'repeat(8, 1fr)',
|
|
514
|
+
height: '100%',
|
|
515
|
+
background: 'white'
|
|
516
|
+
});
|
|
517
|
+
for (const [label, delta] of [['Previous month', -1], ['Next month', 1]]) {
|
|
518
|
+
const btn = field('button', wrap, label);
|
|
519
|
+
btn.textContent = delta < 0 ? '‹' : '›';
|
|
520
|
+
btn.style.gridColumn = delta < 0 ? '1' : '7';
|
|
521
|
+
btn.style.gridRow = '1';
|
|
522
|
+
btn.onclick = () => {
|
|
523
|
+
viewMonth = new Date(month.getFullYear(), month.getMonth() + delta, 1, 12);
|
|
524
|
+
wrap.remove();
|
|
525
|
+
mountDateChooser(parent, onSelect);
|
|
526
|
+
parent.querySelector('[aria-label="' + label + '"]')?.focus();
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
const caption = element('span', wrap, month.toLocaleString(undefined, { month: 'short', year: 'numeric' }));
|
|
530
|
+
Object.assign(caption.style, { gridColumn: '2 / 7', gridRow: '1', textAlign: 'center', alignSelf: 'center' });
|
|
531
|
+
const first = ((Number(p.firstDayOfWeek) || 0) % 7 + 7) % 7;
|
|
532
|
+
for (let i = 0; i < 7; i++) {
|
|
533
|
+
const day = (first + i) % 7;
|
|
534
|
+
const d = element('span', wrap, p.dayNames?.[day] ?? ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'][day]);
|
|
535
|
+
Object.assign(d.style, { gridColumn: String(i + 1), gridRow: '2', textAlign: 'center' });
|
|
536
|
+
}
|
|
537
|
+
const offset = (month.getDay() - first + 7) % 7;
|
|
538
|
+
const days = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();
|
|
539
|
+
for (let day = 1; day <= days; day++) {
|
|
540
|
+
const d = new Date(month.getFullYear(), month.getMonth(), day, 12), key = dayString(d),
|
|
541
|
+
cell = offset + day - 1;
|
|
542
|
+
const btn = field('button', wrap, key);
|
|
543
|
+
btn.textContent = String(day);
|
|
544
|
+
Object.assign(
|
|
545
|
+
btn.style, { gridColumn: String(cell % 7 + 1), gridRow: String(3 + Math.floor(cell / 7)), padding: '0' });
|
|
546
|
+
btn.setAttribute('aria-pressed', String(key === date));
|
|
547
|
+
if (key === date) btn.style.background = '#b8d7fc';
|
|
548
|
+
btn.onclick = () => {
|
|
549
|
+
if (onSelect) onSelect(key);
|
|
550
|
+
changed('change', { selectedDate: key });
|
|
551
|
+
for (const b of wrap.querySelectorAll('[aria-pressed]')) {
|
|
552
|
+
b.setAttribute('aria-pressed', String(b === btn));
|
|
553
|
+
b.style.background = b === btn ? '#b8d7fc' : '';
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
listKeyboard(wrap, 'button');
|
|
558
|
+
}
|
|
559
|
+
function mountPanel() {
|
|
560
|
+
const panel = element('div', node);
|
|
561
|
+
function closePanel() {
|
|
562
|
+
node.hidden = true;
|
|
563
|
+
changed('close', { visible: false });
|
|
564
|
+
}
|
|
565
|
+
Object.assign(panel.style, {
|
|
566
|
+
height: '100%',
|
|
567
|
+
boxSizing: 'border-box',
|
|
568
|
+
background: '#fff',
|
|
569
|
+
border: '1px solid #898989',
|
|
570
|
+
display: 'flex',
|
|
571
|
+
flexDirection: 'column'
|
|
572
|
+
});
|
|
573
|
+
if (kind === 'Window' || kind === 'Alert') {
|
|
574
|
+
const head = element('div', panel), title = element('strong', head, p.title ?? name);
|
|
575
|
+
Object.assign(
|
|
576
|
+
head.style, { display: 'flex', justifyContent: 'space-between', background: '#dbe1e6', padding: '3px' });
|
|
577
|
+
title.style.alignSelf = 'center';
|
|
578
|
+
if (p.closeButton !== false) {
|
|
579
|
+
const close = field('button', head, 'Close');
|
|
580
|
+
close.textContent = '×';
|
|
581
|
+
close.style.width = 'auto';
|
|
582
|
+
close.onclick = e => {
|
|
583
|
+
e.stopPropagation();
|
|
584
|
+
closePanel();
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
panel.onclick = () => changed('click');
|
|
588
|
+
}
|
|
589
|
+
const body = element('div', panel);
|
|
590
|
+
body.dataset.scrollContent = '';
|
|
591
|
+
Object.assign(body.style, { minHeight: '0', flex: '1', overflow: 'auto' });
|
|
592
|
+
const restoreScroll = () => {
|
|
593
|
+
body.scrollLeft = p.horizontalScrollPosition ?? 0;
|
|
594
|
+
body.scrollTop = p.verticalScrollPosition ?? p.scrollPosition ?? 0;
|
|
595
|
+
};
|
|
596
|
+
if (kind === 'ScrollPane') {
|
|
597
|
+
const overflow = policy => ({ on: 'scroll', off: 'hidden' })[policy] ?? 'auto';
|
|
598
|
+
body.style.overflowX = overflow(p.hScrollPolicy);
|
|
599
|
+
body.style.overflowY = overflow(p.vScrollPolicy);
|
|
600
|
+
body.tabIndex = 0;
|
|
601
|
+
queueMicrotask(restoreScroll);
|
|
602
|
+
body.onscroll = () => {
|
|
603
|
+
if (!node.contains(body) ||
|
|
604
|
+
(p.verticalScrollPosition === body.scrollTop && p.horizontalScrollPosition === body.scrollLeft)) return;
|
|
605
|
+
changed('scroll', { scrollPosition: body.scrollTop, verticalScrollPosition: body.scrollTop,
|
|
606
|
+
horizontalScrollPosition: body.scrollLeft });
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (kind === 'Loader' && p.autoLoad === false) return;
|
|
610
|
+
if (p.contentPath) {
|
|
611
|
+
const file = media(p.contentPath, body);
|
|
612
|
+
if (file) {
|
|
613
|
+
if (kind === 'ScrollPane') {
|
|
614
|
+
Object.assign(file.img.style, { width: 'auto', height: 'auto', maxWidth: 'none' });
|
|
615
|
+
file.img.onload = restoreScroll;
|
|
616
|
+
}
|
|
617
|
+
if (kind === 'Loader') file.img.onload = () => {
|
|
618
|
+
if (node.contains(file.img)) changed('complete', { percentLoaded: 100 });
|
|
619
|
+
};
|
|
620
|
+
file.img.src = file.url;
|
|
621
|
+
} else
|
|
622
|
+
element('span', body, String(p.contentPath));
|
|
623
|
+
}
|
|
624
|
+
if (p.text) element('p', body, p.text);
|
|
625
|
+
if (kind === 'Alert') {
|
|
626
|
+
const ok = field('button', panel, p.okLabel ?? 'OK');
|
|
627
|
+
ok.textContent = p.okLabel ?? 'OK';
|
|
628
|
+
ok.style.height = 'auto';
|
|
629
|
+
ok.onclick = e => {
|
|
630
|
+
e.stopPropagation();
|
|
631
|
+
changed('click');
|
|
632
|
+
closePanel();
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function render() {
|
|
637
|
+
node.replaceChildren();
|
|
638
|
+
input = null;
|
|
639
|
+
node.hidden = p.visible === false;
|
|
640
|
+
node.inert = p.enabled === false;
|
|
641
|
+
if (kind === 'CheckBox' || kind === 'RadioButton')
|
|
642
|
+
mountChecks();
|
|
643
|
+
else if (kind === 'Button') {
|
|
644
|
+
input = field('button');
|
|
645
|
+
const icon = p.icon && media(p.icon, input);
|
|
646
|
+
if (icon) {
|
|
647
|
+
Object.assign(input.style, { display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '3px',
|
|
648
|
+
flexDirection: ({ left: 'row-reverse', top: 'column-reverse', bottom: 'column' })[p.labelPlacement] ?? 'row' });
|
|
649
|
+
Object.assign(icon.img.style, { width: 'auto', height: 'auto', maxHeight: '100%', maxWidth: '100%', minHeight: '0', minWidth: '0' });
|
|
650
|
+
icon.img.src = icon.url;
|
|
651
|
+
}
|
|
652
|
+
input.append(document.createTextNode(p.label ?? name));
|
|
653
|
+
if (p.toggle) input.setAttribute('aria-pressed', String(!!p.selected));
|
|
654
|
+
input.onclick = () => {
|
|
655
|
+
const selected = p.toggle ? !p.selected : !!p.selected;
|
|
656
|
+
if (p.toggle) input.setAttribute('aria-pressed', String(selected));
|
|
657
|
+
changed('click', { selected });
|
|
658
|
+
};
|
|
659
|
+
} else if (kind === 'TextInput' || kind === 'TextArea')
|
|
660
|
+
mountText();
|
|
661
|
+
else if (kind === 'ComboBox' || kind === 'List')
|
|
662
|
+
mountChoices();
|
|
663
|
+
else if (['ScrollBar', 'Slider', 'NumericStepper'].includes(kind))
|
|
664
|
+
mountRange();
|
|
665
|
+
else if (kind === 'ProgressBar') {
|
|
666
|
+
const label = element('label', node);
|
|
667
|
+
Object.assign(label.style, { display: 'flex', alignItems: 'center', width: '100%', height: '100%' });
|
|
668
|
+
input = field('progress', label);
|
|
669
|
+
input.max = 100;
|
|
670
|
+
if (p.mode !== 'indeterminate') input.value = number(p.percentComplete, 0);
|
|
671
|
+
if (p.direction === 'left') input.style.direction = 'rtl';
|
|
672
|
+
if (p.label)
|
|
673
|
+
label.append(
|
|
674
|
+
document.createTextNode(String(p.label).replace('%3', String(input.value)).replace('%%', '%')));
|
|
675
|
+
} else if (kind === 'Label') {
|
|
676
|
+
const label = element('span', node);
|
|
677
|
+
label.append(p.html ? formattedText(p.text) : p.text ?? name);
|
|
678
|
+
label.style.whiteSpace = p.autoSize ? 'pre' : 'pre-wrap';
|
|
679
|
+
} else if (kind === 'ColorPicker') {
|
|
680
|
+
input = field('input');
|
|
681
|
+
input.type = 'color';
|
|
682
|
+
input.value = typeof p.selectedColor === 'number' ? '#' + p.selectedColor.toString(16).padStart(6, '0') :
|
|
683
|
+
p.selectedColor ?? '#000000';
|
|
684
|
+
input.oninput = input.onchange = () => {
|
|
685
|
+
const color = typeof p.selectedColor === 'number' ? parseInt(input.value.slice(1), 16) : input.value;
|
|
686
|
+
if (color !== p.selectedColor) changed('change', { selectedColor: color });
|
|
687
|
+
};
|
|
688
|
+
} else if (kind === 'DateField') {
|
|
689
|
+
const row = element('div', node);
|
|
690
|
+
Object.assign(row.style, { display: 'flex', height: '100%' });
|
|
691
|
+
input = field('input', row);
|
|
692
|
+
input.placeholder = 'YYYY-MM-DD';
|
|
693
|
+
input.value = dateString(p.selectedDate);
|
|
694
|
+
input.onchange = () => {
|
|
695
|
+
const value = input.value.trim();
|
|
696
|
+
const parsed = new Date(value + 'T12:00:00');
|
|
697
|
+
if (value && (!/^\d{4}-\d{2}-\d{2}$/.test(value) || dayString(parsed) !== value)) {
|
|
698
|
+
input.value = dateString(p.selectedDate);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
viewMonth = null;
|
|
702
|
+
changed('change', { selectedDate: value });
|
|
703
|
+
calendar.replaceChildren();
|
|
704
|
+
drawCalendar();
|
|
705
|
+
};
|
|
706
|
+
const trigger = field('button', row, 'Choose date');
|
|
707
|
+
trigger.textContent = '▾';
|
|
708
|
+
trigger.style.width = '2em';
|
|
709
|
+
const calendar = element('div', node);
|
|
710
|
+
calendar.style.height = '190px';
|
|
711
|
+
const menu = popup(trigger, calendar, 'dialog', 240);
|
|
712
|
+
const drawCalendar = () => mountDateChooser(calendar, key => { input.value = key; menu.close(); });
|
|
713
|
+
drawCalendar();
|
|
714
|
+
calendar.onkeydown = e => {
|
|
715
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); menu.close(); }
|
|
716
|
+
};
|
|
717
|
+
} else if (kind === 'DateChooser')
|
|
718
|
+
mountDateChooser();
|
|
719
|
+
else if (choices.has(kind))
|
|
720
|
+
mountCollection();
|
|
721
|
+
else
|
|
722
|
+
mountPanel();
|
|
723
|
+
}
|
|
724
|
+
function setParameters(parameters) {
|
|
725
|
+
const old = p;
|
|
726
|
+
if (JSON.stringify(old) === JSON.stringify(parameters)) return;
|
|
727
|
+
const focused = node.contains(document.activeElement),
|
|
728
|
+
selection = focused && input && typeof input.selectionStart === 'number' ?
|
|
729
|
+
[input.selectionStart, input.selectionEnd] :
|
|
730
|
+
null;
|
|
731
|
+
p = { ...parameters };
|
|
732
|
+
if (kind === 'List' && p.multipleSelection && p.selectedIndex !== old.selectedIndex &&
|
|
733
|
+
p.selectedIndices === old.selectedIndices) p.selectedIndices = p.selectedIndex < 0 ? [] : [p.selectedIndex];
|
|
734
|
+
if (kind === 'ScrollPane') {
|
|
735
|
+
if (p.scrollPosition !== old.scrollPosition) p.verticalScrollPosition = p.scrollPosition;
|
|
736
|
+
else p.scrollPosition = p.verticalScrollPosition;
|
|
737
|
+
}
|
|
738
|
+
if (choices.has(kind) && p.selectedIndex === old.selectedIndex && p.value !== old.value) {
|
|
739
|
+
Object.assign(p, controlValueChange(kind, p, p.value));
|
|
740
|
+
if (p.editable) p.text = textOf(choiceItems(p)[p.selectedIndex] ?? p.value);
|
|
741
|
+
} else if (p.editable && choices.has(kind) && p.selectedIndex !== old.selectedIndex) {
|
|
742
|
+
p.text = textOf(choiceItems(p)[p.selectedIndex]);
|
|
743
|
+
}
|
|
744
|
+
if (p.selectedDate !== old.selectedDate) viewMonth = null;
|
|
745
|
+
render();
|
|
746
|
+
if (focused && input) {
|
|
747
|
+
input.focus({ preventScroll: true });
|
|
748
|
+
if (selection && input.setSelectionRange) input.setSelectionRange(...selection);
|
|
749
|
+
}
|
|
750
|
+
if (kind === 'ProgressBar' && old.percentComplete !== p.percentComplete) {
|
|
751
|
+
changed('progress');
|
|
752
|
+
if (number(p.percentComplete, 0) >= 100) changed('complete');
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
render();
|
|
756
|
+
return {
|
|
757
|
+
node,
|
|
758
|
+
getProperties,
|
|
759
|
+
setParameters,
|
|
760
|
+
getValue: () => controlValue(kind, getProperties()),
|
|
761
|
+
setValue: value => setParameters({ ...getProperties(), ...controlValueChange(kind, p, value) })
|
|
762
|
+
};
|
|
763
|
+
}
|