@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.2
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/arrow-caps.d.ts +35 -14
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +286 -55
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +62 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +43 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +48 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +156 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +228 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +86 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/spec.js +6 -29
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +26 -0
- package/dist/bindings.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +42 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +249 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +17 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/{chunks/color → color}/contrast.js +2 -24
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/document.js +2 -1
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/merge.js +1 -1
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/properties.d.ts +32 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +180 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +33 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +58 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +47 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +156 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +208 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +11 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +94 -2
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +268 -1
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +49 -2
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +264 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/{chunks/css → css}/grid.js +2 -33
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +7 -0
- package/dist/css/index.js +7 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +25 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +47 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +64 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +270 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +439 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +70 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +95 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +44 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +27 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +43 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +135 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +233 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +89 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +306 -2
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +13 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +178 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +625 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +21 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +5 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +48 -2
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +75 -57
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/{chunks/icons → icons}/glyph.js +2 -40
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -2
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +67 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -23
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +161 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +90 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +38 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +180 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +13 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +50 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +51 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +158 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/swap.js +288 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +327 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/{layout.js → layout/index.js} +4 -3
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +59 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -2
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +119 -1
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/node-defaults.d.ts +22 -2
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +254 -2
- package/dist/node-defaults.js.map +1 -0
- package/dist/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +77 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +56 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +9 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +39 -2
- package/dist/parse-path.js.map +1 -1
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +73 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +143 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +168 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +3 -0
- package/dist/plugin-data/index.js +3 -0
- package/dist/polygon.d.ts +4 -2
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +17 -2
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +12 -2
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +62 -1
- package/dist/preview.js.map +1 -0
- package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.js +24 -1
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +6 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +287 -2
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +148 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +7 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +47 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.js +4 -0
- package/dist/shaders/model.d.ts +41 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +71 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +41 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +36 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +51 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +186 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +77 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +105 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +40 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +118 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +21 -2
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +109 -1
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.js +10 -1
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/{text-direction.js → text/direction.js} +1 -1
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +24 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +49 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/{text-picture.d.ts → text/picture.d.ts} +3 -4
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +38 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +8 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +78 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +195 -2007
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +89 -2
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -2
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +235 -1
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +83 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +314 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +43 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +104 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +238 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +16 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +49 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/vector-network.d.ts +65 -2
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +375 -2
- package/dist/vector-network.js.map +1 -0
- package/package.json +303 -137
- package/src/arrow-caps.ts +279 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +5 -3
- package/src/behaviours/model.ts +25 -22
- package/src/behaviours/schema.ts +64 -13
- package/src/behaviours/spec.ts +11 -50
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +252 -5
- package/src/clipping.ts +112 -0
- package/src/color/index.ts +1 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +1 -1
- package/src/comments/index.ts +5 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +1 -1
- package/src/components/exposure.ts +1 -1
- package/src/components/index.ts +8 -0
- package/src/components/properties.ts +94 -4
- package/src/components/variants.ts +52 -31
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +49 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +141 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +203 -0
- package/src/coordinate.ts +10 -3
- package/src/copy.ts +71 -31
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +2 -0
- package/src/css/text.ts +84 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +30 -1
- package/src/fields/appearance.ts +35 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +32 -1
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +473 -0
- package/src/figjam/text.ts +83 -0
- package/src/font-style.ts +58 -14
- package/src/generated/index.ts +76 -0
- package/src/generated/kind.ts +24 -0
- package/src/generated/shape-with-text.ts +157 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +102 -312
- package/src/gradient.ts +14 -0
- package/src/graph.ts +849 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +6 -1
- package/src/hit-test.ts +118 -74
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +9 -0
- package/src/icons/schema.ts +19 -3
- package/src/ids.ts +34 -0
- package/src/images.ts +71 -8
- package/src/index.ts +2 -976
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +23 -2
- package/src/instances/copies.ts +7 -10
- package/src/instances/cycles.ts +1 -1
- package/src/instances/fields.ts +47 -92
- package/src/{instances.ts → instances/index.ts} +69 -44
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +55 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/swap.ts +451 -0
- package/src/instances/sync.ts +166 -177
- package/src/instances/vector-geometry.ts +3 -3
- package/src/layout/aspect-ratio.ts +1 -1
- package/src/layout/sizing.ts +1 -1
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +1 -1
- package/src/mutation-impact.ts +1 -1
- package/src/node-defaults.ts +43 -3
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +67 -0
- package/src/parse-path.ts +49 -4
- package/src/plugin-data/fields.ts +69 -77
- package/src/plugin-data/index.ts +2 -0
- package/src/polygon.ts +17 -0
- package/src/preview.ts +1 -1
- package/src/{primitives.ts → primitives/index.ts} +2 -0
- package/src/primitives/schema.ts +14 -0
- package/src/resize.ts +32 -6
- package/src/scaling/node.ts +10 -6
- package/src/scaling/tree.ts +2 -1
- package/src/shaders/index.ts +3 -0
- package/src/shaders/schema.ts +3 -3
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +169 -17
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +10 -5
- package/src/slots/frames.ts +12 -10
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +1 -1
- package/src/snap.ts +3 -1
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/index.ts +3 -0
- package/src/text/lengths.ts +44 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/picture.ts +0 -4
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +1 -1
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/history.ts +1 -1
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +18 -19
- package/src/transfer/plan.ts +1 -1
- package/src/transfer/remove.ts +1 -1
- package/src/transfer/validation.ts +1 -1
- package/src/transfer/variables.ts +7 -6
- package/src/types.ts +246 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +166 -66
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +83 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/{variables.ts → variables/index.ts} +86 -146
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +51 -0
- package/src/variables/token.ts +27 -1
- package/src/variables/value.ts +92 -0
- package/src/vector-network.ts +263 -22
- package/dist/chunks/asset-keys.js.map +0 -1
- package/dist/chunks/behaviours/kinds.js.map +0 -1
- package/dist/chunks/behaviours/layers.js +0 -611
- package/dist/chunks/behaviours/layers.js.map +0 -1
- package/dist/chunks/behaviours/spec.js.map +0 -1
- package/dist/chunks/bindings.js +0 -18
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js +0 -78
- package/dist/chunks/checkpoint.js.map +0 -1
- package/dist/chunks/color/contrast.js.map +0 -1
- package/dist/chunks/color/index.js +0 -1662
- package/dist/chunks/color/index.js.map +0 -1
- package/dist/chunks/comments/document.js.map +0 -1
- package/dist/chunks/comments/list.js.map +0 -1
- package/dist/chunks/comments/merge.js.map +0 -1
- package/dist/chunks/components/exposure.js +0 -2291
- package/dist/chunks/components/exposure.js.map +0 -1
- package/dist/chunks/components/variants.js +0 -32
- package/dist/chunks/components/variants.js.map +0 -1
- package/dist/chunks/coordinate.js +0 -385
- package/dist/chunks/coordinate.js.map +0 -1
- package/dist/chunks/css/grid.js.map +0 -1
- package/dist/chunks/css/index.js +0 -160
- package/dist/chunks/css/index.js.map +0 -1
- package/dist/chunks/events.js.map +0 -1
- package/dist/chunks/fields/geometry.js.map +0 -1
- package/dist/chunks/font-style.js +0 -96
- package/dist/chunks/font-style.js.map +0 -1
- package/dist/chunks/group-bounds.js.map +0 -1
- package/dist/chunks/icons/glyph.js.map +0 -1
- package/dist/chunks/index.js +0 -2430
- package/dist/chunks/index.js.map +0 -1
- package/dist/color.d.ts +0 -78
- package/dist/color.d.ts.map +0 -1
- package/dist/color.js +0 -3
- package/dist/constants2.d.ts +0 -11
- package/dist/constants2.d.ts.map +0 -1
- package/dist/css.d.ts +0 -39
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -3
- package/dist/images2.d.ts +0 -16
- package/dist/images2.d.ts.map +0 -1
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +0 -2
- package/dist/layout.d.ts +0 -2
- package/dist/matrix2.d.ts +0 -16
- package/dist/matrix2.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -2
- package/dist/primitives.js +0 -0
- package/dist/primitives2.d.ts.map +0 -1
- package/dist/text-direction.d.ts.map +0 -1
- package/dist/text-direction.js.map +0 -1
- package/dist/text-picture.d.ts.map +0 -1
- package/dist/text-picture.js +0 -2
- package/dist/text.d.ts +0 -2
- package/dist/text.js +0 -3
- package/dist/types2.d.ts +0 -2
- package/dist/undo2.d.ts +0 -73
- package/dist/undo2.d.ts.map +0 -1
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -2
- /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
- /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
|
@@ -14,20 +14,34 @@ const BEHAVIOUR_KINDS = [
|
|
|
14
14
|
"slider",
|
|
15
15
|
"progress",
|
|
16
16
|
"tabs",
|
|
17
|
+
"tab",
|
|
17
18
|
"collapsible",
|
|
18
19
|
"accordion"
|
|
19
20
|
];
|
|
20
21
|
/**
|
|
21
22
|
* The interaction states a control can show, each drawn as a value of one variant property:
|
|
22
|
-
* at rest, under the pointer, while pressed, focused from the keyboard, and
|
|
23
|
+
* at rest, under the pointer, while pressed, focused from the keyboard, disabled, and invalid. Only
|
|
24
|
+
* a form control has an invalid state (`hasInvalidState`), shown while its value fails validation.
|
|
23
25
|
*/
|
|
24
26
|
const INTERACTION_STATES = [
|
|
25
27
|
"rest",
|
|
26
28
|
"hover",
|
|
27
29
|
"pressed",
|
|
28
30
|
"focus",
|
|
29
|
-
"disabled"
|
|
31
|
+
"disabled",
|
|
32
|
+
"invalid"
|
|
30
33
|
];
|
|
34
|
+
const DISABLED = {
|
|
35
|
+
id: "disabled",
|
|
36
|
+
type: "boolean",
|
|
37
|
+
required: false
|
|
38
|
+
};
|
|
39
|
+
/** Whether a form control's value fails validation, which code marks with `aria-invalid`. */
|
|
40
|
+
const INVALID = {
|
|
41
|
+
id: "invalid",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
required: false
|
|
44
|
+
};
|
|
31
45
|
/**
|
|
32
46
|
* A text field or textarea: its text is a text property, and `filled`, when bound, draws the
|
|
33
47
|
* empty field with its placeholder.
|
|
@@ -44,11 +58,8 @@ const TEXT_INPUT = {
|
|
|
44
58
|
type: "boolean",
|
|
45
59
|
required: false
|
|
46
60
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type: "boolean",
|
|
50
|
-
required: false
|
|
51
|
-
}
|
|
61
|
+
DISABLED,
|
|
62
|
+
INVALID
|
|
52
63
|
],
|
|
53
64
|
parts: []
|
|
54
65
|
};
|
|
@@ -59,11 +70,7 @@ const TEXT_INPUT = {
|
|
|
59
70
|
*/
|
|
60
71
|
const BEHAVIOUR_CONTRACTS = {
|
|
61
72
|
button: {
|
|
62
|
-
values: [
|
|
63
|
-
id: "disabled",
|
|
64
|
-
type: "boolean",
|
|
65
|
-
required: false
|
|
66
|
-
}],
|
|
73
|
+
values: [DISABLED],
|
|
67
74
|
parts: []
|
|
68
75
|
},
|
|
69
76
|
textField: TEXT_INPUT,
|
|
@@ -80,11 +87,8 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
80
87
|
type: "text",
|
|
81
88
|
required: true
|
|
82
89
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
type: "boolean",
|
|
86
|
-
required: false
|
|
87
|
-
}
|
|
90
|
+
DISABLED,
|
|
91
|
+
INVALID
|
|
88
92
|
],
|
|
89
93
|
parts: [{
|
|
90
94
|
id: "increment",
|
|
@@ -99,64 +103,56 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
99
103
|
id: "value",
|
|
100
104
|
type: "boolean",
|
|
101
105
|
required: true
|
|
102
|
-
},
|
|
103
|
-
id: "disabled",
|
|
104
|
-
type: "boolean",
|
|
105
|
-
required: false
|
|
106
|
-
}],
|
|
106
|
+
}, DISABLED],
|
|
107
107
|
parts: []
|
|
108
108
|
},
|
|
109
109
|
switch: {
|
|
110
|
-
values: [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
values: [
|
|
111
|
+
{
|
|
112
|
+
id: "value",
|
|
113
|
+
type: "boolean",
|
|
114
|
+
required: true
|
|
115
|
+
},
|
|
116
|
+
DISABLED,
|
|
117
|
+
INVALID
|
|
118
|
+
],
|
|
119
119
|
parts: [{
|
|
120
120
|
id: "thumb",
|
|
121
121
|
required: false
|
|
122
122
|
}]
|
|
123
123
|
},
|
|
124
124
|
checkbox: {
|
|
125
|
-
values: [
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
values: [
|
|
126
|
+
{
|
|
127
|
+
id: "value",
|
|
128
|
+
type: "boolean",
|
|
129
|
+
required: true
|
|
130
|
+
},
|
|
131
|
+
DISABLED,
|
|
132
|
+
INVALID
|
|
133
|
+
],
|
|
134
134
|
parts: [{
|
|
135
135
|
id: "indicator",
|
|
136
136
|
required: false
|
|
137
137
|
}]
|
|
138
138
|
},
|
|
139
139
|
radio: {
|
|
140
|
-
values: [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
values: [
|
|
141
|
+
{
|
|
142
|
+
id: "value",
|
|
143
|
+
type: "boolean",
|
|
144
|
+
required: true
|
|
145
|
+
},
|
|
146
|
+
DISABLED,
|
|
147
|
+
INVALID
|
|
148
|
+
],
|
|
149
149
|
parts: [{
|
|
150
150
|
id: "indicator",
|
|
151
151
|
required: false
|
|
152
152
|
}]
|
|
153
153
|
},
|
|
154
154
|
radioGroup: {
|
|
155
|
-
values: [
|
|
156
|
-
id: "disabled",
|
|
157
|
-
type: "boolean",
|
|
158
|
-
required: false
|
|
159
|
-
}],
|
|
155
|
+
values: [DISABLED, INVALID],
|
|
160
156
|
parts: [{
|
|
161
157
|
id: "items",
|
|
162
158
|
required: true,
|
|
@@ -165,11 +161,7 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
165
161
|
}]
|
|
166
162
|
},
|
|
167
163
|
toggleGroup: {
|
|
168
|
-
values: [
|
|
169
|
-
id: "disabled",
|
|
170
|
-
type: "boolean",
|
|
171
|
-
required: false
|
|
172
|
-
}],
|
|
164
|
+
values: [DISABLED],
|
|
173
165
|
parts: [{
|
|
174
166
|
id: "items",
|
|
175
167
|
required: true,
|
|
@@ -182,11 +174,7 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
182
174
|
id: "value",
|
|
183
175
|
type: "number",
|
|
184
176
|
required: false
|
|
185
|
-
},
|
|
186
|
-
id: "disabled",
|
|
187
|
-
type: "boolean",
|
|
188
|
-
required: false
|
|
189
|
-
}],
|
|
177
|
+
}, DISABLED],
|
|
190
178
|
parts: [
|
|
191
179
|
{
|
|
192
180
|
id: "track",
|
|
@@ -211,6 +199,7 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
211
199
|
parts: [{
|
|
212
200
|
id: "list",
|
|
213
201
|
required: true,
|
|
202
|
+
items: true,
|
|
214
203
|
children: "trigger"
|
|
215
204
|
}, {
|
|
216
205
|
id: "panels",
|
|
@@ -218,6 +207,18 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
218
207
|
children: "content"
|
|
219
208
|
}]
|
|
220
209
|
},
|
|
210
|
+
tab: {
|
|
211
|
+
values: [{
|
|
212
|
+
id: "value",
|
|
213
|
+
type: "boolean",
|
|
214
|
+
required: true
|
|
215
|
+
}, {
|
|
216
|
+
id: "disabled",
|
|
217
|
+
type: "boolean",
|
|
218
|
+
required: false
|
|
219
|
+
}],
|
|
220
|
+
parts: []
|
|
221
|
+
},
|
|
221
222
|
progress: {
|
|
222
223
|
values: [{
|
|
223
224
|
id: "value",
|
|
@@ -237,11 +238,7 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
237
238
|
id: "open",
|
|
238
239
|
type: "boolean",
|
|
239
240
|
required: false
|
|
240
|
-
},
|
|
241
|
-
id: "disabled",
|
|
242
|
-
type: "boolean",
|
|
243
|
-
required: false
|
|
244
|
-
}],
|
|
241
|
+
}, DISABLED],
|
|
245
242
|
parts: [{
|
|
246
243
|
id: "trigger",
|
|
247
244
|
required: true
|
|
@@ -251,11 +248,7 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
251
248
|
}]
|
|
252
249
|
},
|
|
253
250
|
accordion: {
|
|
254
|
-
values: [
|
|
255
|
-
id: "disabled",
|
|
256
|
-
type: "boolean",
|
|
257
|
-
required: false
|
|
258
|
-
}],
|
|
251
|
+
values: [DISABLED],
|
|
259
252
|
parts: [{
|
|
260
253
|
id: "items",
|
|
261
254
|
required: true,
|
|
@@ -267,7 +260,15 @@ const BEHAVIOUR_CONTRACTS = {
|
|
|
267
260
|
function behaviourContract(kind) {
|
|
268
261
|
return BEHAVIOUR_CONTRACTS[kind];
|
|
269
262
|
}
|
|
263
|
+
/** Whether a kind of control can be invalid: a form control, whose contract has `invalid`. */
|
|
264
|
+
function hasInvalidState(kind) {
|
|
265
|
+
return BEHAVIOUR_CONTRACTS[kind].values.some((value) => value.id === "invalid");
|
|
266
|
+
}
|
|
267
|
+
/** The interaction states a kind of control can show. */
|
|
268
|
+
function interactionStatesOf(kind) {
|
|
269
|
+
return INTERACTION_STATES.filter((state) => state !== "invalid" || hasInvalidState(kind));
|
|
270
|
+
}
|
|
270
271
|
//#endregion
|
|
271
|
-
export { BEHAVIOUR_CONTRACTS, BEHAVIOUR_KINDS, INTERACTION_STATES, behaviourContract };
|
|
272
|
+
export { BEHAVIOUR_CONTRACTS, BEHAVIOUR_KINDS, INTERACTION_STATES, behaviourContract, hasInvalidState, interactionStatesOf };
|
|
272
273
|
|
|
273
274
|
//# sourceMappingURL=kinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kinds.js","names":[],"sources":["../../src/behaviours/kinds.ts"],"sourcesContent":["/** The controls a main component can behave as, in the order the picker lists them. */\nexport const BEHAVIOUR_KINDS = [\n 'button',\n 'textField',\n 'textarea',\n 'numberField',\n 'toggle',\n 'switch',\n 'checkbox',\n 'radio',\n 'radioGroup',\n 'toggleGroup',\n 'slider',\n 'progress',\n 'tabs',\n 'tab',\n 'collapsible',\n 'accordion'\n] as const\n\nexport type BehaviourKind = (typeof BEHAVIOUR_KINDS)[number]\n\n/**\n * The interaction states a control can show, each drawn as a value of one variant property:\n * at rest, under the pointer, while pressed, focused from the keyboard, disabled, and invalid. Only\n * a form control has an invalid state (`hasInvalidState`), shown while its value fails validation.\n */\nexport const INTERACTION_STATES = [\n 'rest',\n 'hover',\n 'pressed',\n 'focus',\n 'disabled',\n 'invalid'\n] as const\n\nexport type InteractionState = (typeof INTERACTION_STATES)[number]\n\n/**\n * How a behaviour value is held. A boolean is a variant or boolean property of the component,\n * and text is a text property. Figma has no number property, so a number is the behaviour's\n * own (min, max, step, default); a choice is which item of a slot is active, the first by\n * default.\n */\nexport type BehaviourValueType = 'boolean' | 'text' | 'number' | 'choice'\n\n/** A value of the control: its state, which preview reads and changes. */\nexport interface BehaviourValueContract {\n id: string\n type: BehaviourValueType\n /** Whether a boolean or text value must be bound before the behaviour is complete. */\n required: boolean\n}\n\n/**\n * A Reka UI subcomponent of the control, which is a slot of the component: the behaviour binds\n * it to one of the component's slot properties, never to a layer found by name.\n */\nexport interface BehaviourPartContract {\n id: string\n required: boolean\n /**\n * Whether the slot holds the control's items, each an instance with its own behaviour (a\n * radio, a toggle, a collapsible, a tab), which the control turns on and off. A tab list's\n * triggers may also be plain layers, which have no state of their own.\n */\n items?: boolean\n /**\n * The Reka UI part each child of the slot is, when the slot holds repeated parts: a tab list's\n * triggers, the tabs' content panels, or a group's items.\n */\n children?: string\n}\n\nexport interface BehaviourContract {\n values: BehaviourValueContract[]\n parts: BehaviourPartContract[]\n}\n\nconst DISABLED: BehaviourValueContract = { id: 'disabled', type: 'boolean', required: false }\n\n/** Whether a form control's value fails validation, which code marks with `aria-invalid`. */\nconst INVALID: BehaviourValueContract = { id: 'invalid', type: 'boolean', required: false }\n\n/**\n * A text field or textarea: its text is a text property, and `filled`, when bound, draws the\n * empty field with its placeholder.\n */\nconst TEXT_INPUT: BehaviourContract = {\n values: [\n { id: 'value', type: 'text', required: true },\n { id: 'filled', type: 'boolean', required: false },\n DISABLED,\n INVALID\n ],\n parts: []\n}\n\n/**\n * The behaviours OpenPencil knows, after Reka UI's primitives. Their states are drawn as the\n * component's variants and properties; their subcomponents (thumb, range, trigger, …) are the\n * component's slots, and the component itself is the control's root.\n */\nexport const BEHAVIOUR_CONTRACTS: Readonly<Record<BehaviourKind, BehaviourContract>> = {\n button: {\n values: [DISABLED],\n parts: []\n },\n textField: TEXT_INPUT,\n textarea: TEXT_INPUT,\n numberField: {\n values: [\n { id: 'value', type: 'number', required: false },\n { id: 'text', type: 'text', required: true },\n DISABLED,\n INVALID\n ],\n parts: [\n { id: 'increment', required: false },\n { id: 'decrement', required: false }\n ]\n },\n toggle: {\n values: [{ id: 'value', type: 'boolean', required: true }, DISABLED],\n parts: []\n },\n switch: {\n values: [{ id: 'value', type: 'boolean', required: true }, DISABLED, INVALID],\n parts: [{ id: 'thumb', required: false }]\n },\n checkbox: {\n values: [{ id: 'value', type: 'boolean', required: true }, DISABLED, INVALID],\n parts: [{ id: 'indicator', required: false }]\n },\n radio: {\n values: [{ id: 'value', type: 'boolean', required: true }, DISABLED, INVALID],\n parts: [{ id: 'indicator', required: false }]\n },\n radioGroup: {\n values: [DISABLED, INVALID],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n },\n toggleGroup: {\n values: [DISABLED],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n },\n slider: {\n values: [{ id: 'value', type: 'number', required: false }, DISABLED],\n parts: [\n { id: 'track', required: true },\n { id: 'range', required: false },\n { id: 'thumb', required: true }\n ]\n },\n tabs: {\n values: [{ id: 'value', type: 'choice', required: false }],\n parts: [\n { id: 'list', required: true, items: true, children: 'trigger' },\n { id: 'panels', required: false, children: 'content' }\n ]\n },\n // A tab list's trigger, after Reka's TabsTrigger: on while its tab is the chosen one.\n tab: {\n values: [\n { id: 'value', type: 'boolean', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: []\n },\n progress: {\n values: [{ id: 'value', type: 'number', required: false }],\n parts: [\n { id: 'track', required: true },\n { id: 'indicator', required: true }\n ]\n },\n collapsible: {\n values: [{ id: 'open', type: 'boolean', required: false }, DISABLED],\n parts: [\n { id: 'trigger', required: true },\n { id: 'content', required: true }\n ]\n },\n accordion: {\n values: [DISABLED],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n }\n}\n\nexport function behaviourContract(kind: BehaviourKind): BehaviourContract {\n return BEHAVIOUR_CONTRACTS[kind]\n}\n\n/** Whether a kind of control can be invalid: a form control, whose contract has `invalid`. */\nexport function hasInvalidState(kind: BehaviourKind): boolean {\n return BEHAVIOUR_CONTRACTS[kind].values.some((value) => value.id === 'invalid')\n}\n\n/** The interaction states a kind of control can show. */\nexport function interactionStatesOf(kind: BehaviourKind): InteractionState[] {\n return INTERACTION_STATES.filter((state) => state !== 'invalid' || hasInvalidState(kind))\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
3
|
+
//#region src/behaviours/layers.d.ts
|
|
4
|
+
/** Whether an instance's main component, or its set, has a behaviour. */
|
|
5
|
+
declare function hasBehaviour(graph: SceneGraph, node: SceneNode): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* A layer's path below a root: the names of the layers down to it, with the position among
|
|
8
|
+
* same-named siblings when names repeat. It stays the same when a variant switch rebuilds an
|
|
9
|
+
* instance's layers, so it identifies controls and keeps their DOM in place.
|
|
10
|
+
*/
|
|
11
|
+
declare function layerPath(graph: SceneGraph, rootId: string, nodeId: string): string;
|
|
12
|
+
/** The layer at `path` below a root, the inverse of `layerPath`. */
|
|
13
|
+
declare function findLayerByPath(graph: SceneGraph, rootId: string, path: string): SceneNode | undefined;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { findLayerByPath, hasBehaviour, layerPath };
|
|
16
|
+
//# sourceMappingURL=layers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers.d.ts","names":[],"sources":["../../src/behaviours/layers.ts"],"mappings":";;;;iBAMgB,aAAa,OAAO,YAAY,MAAM;;;;;;iBAgBtC,UAAU,OAAO,YAAY,gBAAgB;;iBAgB7C,gBACd,OAAO,YACP,gBACA,eACC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { instanceMainComponent } from "../instances/main-component.js";
|
|
2
|
+
import { behaviourOwner, readBehaviour } from "./model.js";
|
|
3
|
+
//#region src/behaviours/layers.ts
|
|
4
|
+
/** Whether an instance's main component, or its set, has a behaviour. */
|
|
5
|
+
function hasBehaviour(graph, node) {
|
|
6
|
+
if (node.type !== "INSTANCE") return false;
|
|
7
|
+
const component = instanceMainComponent(graph, node);
|
|
8
|
+
const owner = component && behaviourOwner(graph, component);
|
|
9
|
+
return !!owner && !!readBehaviour(owner);
|
|
10
|
+
}
|
|
11
|
+
/** A name as a path segment: `/` separates segments and `#` the twin index, so both are escaped. */
|
|
12
|
+
const pathName = (name) => name.replace(/[%/#]/g, (char) => encodeURIComponent(char));
|
|
13
|
+
/**
|
|
14
|
+
* A layer's path below a root: the names of the layers down to it, with the position among
|
|
15
|
+
* same-named siblings when names repeat. It stays the same when a variant switch rebuilds an
|
|
16
|
+
* instance's layers, so it identifies controls and keeps their DOM in place.
|
|
17
|
+
*/
|
|
18
|
+
function layerPath(graph, rootId, nodeId) {
|
|
19
|
+
const segments = [];
|
|
20
|
+
graph.closest(nodeId, (node) => {
|
|
21
|
+
if (node.id === rootId) return true;
|
|
22
|
+
const twins = node.parentId ? graph.getChildren(node.parentId).filter((child) => child.name === node.name) : [];
|
|
23
|
+
const index = twins.findIndex((child) => child.id === node.id);
|
|
24
|
+
segments.unshift(twins.length > 1 ? `${pathName(node.name)}#${index}` : pathName(node.name));
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
return segments.join("/");
|
|
28
|
+
}
|
|
29
|
+
/** The layer at `path` below a root, the inverse of `layerPath`. */
|
|
30
|
+
function findLayerByPath(graph, rootId, path) {
|
|
31
|
+
let current = graph.getNode(rootId);
|
|
32
|
+
for (const segment of path ? path.split("/") : []) {
|
|
33
|
+
if (!current) return void 0;
|
|
34
|
+
const hash = segment.lastIndexOf("#");
|
|
35
|
+
const name = hash === -1 ? segment : segment.slice(0, hash);
|
|
36
|
+
current = graph.getChildren(current.id).filter((child) => pathName(child.name) === name).at(hash === -1 ? 0 : Number(segment.slice(hash + 1)));
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { findLayerByPath, hasBehaviour, layerPath };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=layers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers.js","names":[],"sources":["../../src/behaviours/layers.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport { instanceMainComponent } from '../instances/main-component'\nimport type { SceneNode } from '../types'\nimport { behaviourOwner, readBehaviour } from './model'\n\n/** Whether an instance's main component, or its set, has a behaviour. */\nexport function hasBehaviour(graph: SceneGraph, node: SceneNode): boolean {\n if (node.type !== 'INSTANCE') return false\n // A copy of a nested instance names the instance it copies, so follow it to the component.\n const component = instanceMainComponent(graph, node)\n const owner = component && behaviourOwner(graph, component)\n return !!owner && !!readBehaviour(owner)\n}\n\n/** A name as a path segment: `/` separates segments and `#` the twin index, so both are escaped. */\nconst pathName = (name: string) => name.replace(/[%/#]/g, (char) => encodeURIComponent(char))\n\n/**\n * A layer's path below a root: the names of the layers down to it, with the position among\n * same-named siblings when names repeat. It stays the same when a variant switch rebuilds an\n * instance's layers, so it identifies controls and keeps their DOM in place.\n */\nexport function layerPath(graph: SceneGraph, rootId: string, nodeId: string): string {\n const segments: string[] = []\n // `closest` stops on a parent cycle in bad data, where a hand-written walk would not.\n graph.closest(nodeId, (node) => {\n if (node.id === rootId) return true\n const twins = node.parentId\n ? graph.getChildren(node.parentId).filter((child) => child.name === node.name)\n : []\n const index = twins.findIndex((child) => child.id === node.id)\n segments.unshift(twins.length > 1 ? `${pathName(node.name)}#${index}` : pathName(node.name))\n return false\n })\n return segments.join('/')\n}\n\n/** The layer at `path` below a root, the inverse of `layerPath`. */\nexport function findLayerByPath(\n graph: SceneGraph,\n rootId: string,\n path: string\n): SceneNode | undefined {\n let current = graph.getNode(rootId)\n for (const segment of path ? path.split('/') : []) {\n if (!current) return undefined\n const hash = segment.lastIndexOf('#')\n const name = hash === -1 ? segment : segment.slice(0, hash)\n const twins = graph.getChildren(current.id).filter((child) => pathName(child.name) === name)\n current = twins.at(hash === -1 ? 0 : Number(segment.slice(hash + 1)))\n }\n return current\n}\n"],"mappings":";;;;AAMA,SAAgB,aAAa,OAAmB,MAA0B;CACxE,IAAI,KAAK,SAAS,YAAY,OAAO;CAErC,MAAM,YAAY,sBAAsB,OAAO,IAAI;CACnD,MAAM,QAAQ,aAAa,eAAe,OAAO,SAAS;CAC1D,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,KAAK;AACzC;;AAGA,MAAM,YAAY,SAAiB,KAAK,QAAQ,WAAW,SAAS,mBAAmB,IAAI,CAAC;;;;;;AAO5F,SAAgB,UAAU,OAAmB,QAAgB,QAAwB;CACnF,MAAM,WAAqB,CAAC;CAE5B,MAAM,QAAQ,SAAS,SAAS;EAC9B,IAAI,KAAK,OAAO,QAAQ,OAAO;EAC/B,MAAM,QAAQ,KAAK,WACf,MAAM,YAAY,KAAK,QAAQ,CAAC,CAAC,QAAQ,UAAU,MAAM,SAAS,KAAK,IAAI,IAC3E,CAAC;EACL,MAAM,QAAQ,MAAM,WAAW,UAAU,MAAM,OAAO,KAAK,EAAE;EAC7D,SAAS,QAAQ,MAAM,SAAS,IAAI,GAAG,SAAS,KAAK,IAAI,EAAE,GAAG,UAAU,SAAS,KAAK,IAAI,CAAC;EAC3F,OAAO;CACT,CAAC;CACD,OAAO,SAAS,KAAK,GAAG;AAC1B;;AAGA,SAAgB,gBACd,OACA,QACA,MACuB;CACvB,IAAI,UAAU,MAAM,QAAQ,MAAM;CAClC,KAAK,MAAM,WAAW,OAAO,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG;EACjD,IAAI,CAAC,SAAS,OAAO,KAAA;EACrB,MAAM,OAAO,QAAQ,YAAY,GAAG;EACpC,MAAM,OAAO,SAAS,KAAK,UAAU,QAAQ,MAAM,GAAG,IAAI;EAE1D,UADc,MAAM,YAAY,QAAQ,EAAE,CAAC,CAAC,QAAQ,UAAU,SAAS,MAAM,IAAI,MAAM,IACzE,CAAC,CAAC,GAAG,SAAS,KAAK,IAAI,OAAO,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC;CACtE;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { ComponentPropertyDefinition, SceneNode } from "../types.js";
|
|
3
|
+
import { BehaviourKind } from "./kinds.js";
|
|
4
|
+
import { Behaviour, BehaviourBooleanBinding, BehaviourInteractionStates, BehaviourNumberSettings } from "./schema.js";
|
|
5
|
+
//#region src/behaviours/model.d.ts
|
|
6
|
+
declare const DEFAULT_NUMBER_SETTINGS: BehaviourNumberSettings;
|
|
7
|
+
/** A boolean value's binding, if the behaviour has one. */
|
|
8
|
+
declare function booleanBinding(behaviour: Behaviour, valueId: string): BehaviourBooleanBinding | undefined;
|
|
9
|
+
/** The slot property a part is bound to, if any. */
|
|
10
|
+
declare function partBinding(behaviour: Behaviour, partId: string): string | undefined;
|
|
11
|
+
/** The text property a text value is bound to, if any. */
|
|
12
|
+
declare function textBinding(behaviour: Behaviour, valueId: string): string | undefined;
|
|
13
|
+
/** A number value's range, if the behaviour has one. */
|
|
14
|
+
declare function numberSettings(behaviour: Behaviour, valueId: string): BehaviourNumberSettings | undefined;
|
|
15
|
+
/** A new behaviour of a kind, its number values at their defaults and nothing bound. */
|
|
16
|
+
declare function emptyBehaviour(kind: BehaviourKind): Behaviour;
|
|
17
|
+
/**
|
|
18
|
+
* The node that keeps the behaviour: a component set for its variants, otherwise the main
|
|
19
|
+
* component itself.
|
|
20
|
+
*/
|
|
21
|
+
declare function behaviourOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
22
|
+
/** The behaviour a component or component set keeps, or null when it has none or it is unreadable. */
|
|
23
|
+
declare function readBehaviour(owner: SceneNode): Behaviour | null;
|
|
24
|
+
/** The owner's plugin data with the behaviour set, or removed when null. */
|
|
25
|
+
declare function withBehaviour(owner: SceneNode, behaviour: Behaviour | null): SceneNode['pluginData'];
|
|
26
|
+
/**
|
|
27
|
+
* Component properties the behaviour can bind to: the owner's, with a set's variant values and
|
|
28
|
+
* defaults read from its variants, and a set's variants' own.
|
|
29
|
+
*/
|
|
30
|
+
declare function behaviourProperties(graph: SceneGraph, owner: SceneNode): ComponentPropertyDefinition[];
|
|
31
|
+
/**
|
|
32
|
+
* Required values and parts that are unbound, or bound to a property the component no longer
|
|
33
|
+
* has, by value or part id; `states` when the interaction states lost their variant property.
|
|
34
|
+
*/
|
|
35
|
+
declare function missingBindings(graph: SceneGraph, owner: SceneNode, behaviour: Behaviour): string[];
|
|
36
|
+
/**
|
|
37
|
+
* A kind of control's interaction states for a variant property, each mapped to the value whose
|
|
38
|
+
* name means it, such as `Hover` or `Pressed`; states without such a value are left unset.
|
|
39
|
+
*/
|
|
40
|
+
declare function guessInteractionStates(kind: BehaviourKind, propertyId: string, values: readonly string[]): BehaviourInteractionStates;
|
|
41
|
+
/**
|
|
42
|
+
* The behaviour with every component property id it binds renamed by `rename`, for formats that
|
|
43
|
+
* give properties new ids on write, such as `.fig` with its GUIDs.
|
|
44
|
+
*/
|
|
45
|
+
declare function renameBehaviourProperties(behaviour: Behaviour, rename: (propertyId: string) => string): Behaviour;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { DEFAULT_NUMBER_SETTINGS, behaviourOwner, behaviourProperties, booleanBinding, emptyBehaviour, guessInteractionStates, missingBindings, numberSettings, partBinding, readBehaviour, renameBehaviourProperties, textBinding, withBehaviour };
|
|
48
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","names":[],"sources":["../../src/behaviours/model.ts"],"mappings":";;;;;cAoBa,yBAAyB;;iBAQtB,eACd,WAAW,WACX,kBACC;;iBAKa,YAAY,WAAW,WAAW;;iBAKlC,YAAY,WAAW,WAAW;;iBAKlC,eACd,WAAW,WACX,kBACC;;iBAKa,eAAe,MAAM,gBAAgB;;;;;iBAcrC,eAAe,OAAO,YAAY,MAAM,YAAY;;iBAQpD,cAAc,OAAO,YAAY;;iBAKjC,cACd,OAAO,WACP,WAAW,mBACV;;;;;iBAQa,oBACd,OAAO,YACP,OAAO,YACN;;;;;iBAsBa,gBACd,OAAO,YACP,OAAO,WACP,WAAW;;;;;iBAyCG,uBACd,MAAM,eACN,oBACA,4BACC;;;;;iBAaa,0BACd,WAAW,WACX,SAAS,gCACR"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { readPluginData, withPluginData } from "../plugin-data/field.js";
|
|
2
|
+
import { behaviourContract, interactionStatesOf } from "./kinds.js";
|
|
3
|
+
import { OPEN_PENCIL_PLUGIN_DATA } from "../plugin-data/fields.js";
|
|
4
|
+
import { resolvedVariantDefinition } from "../components/variants.js";
|
|
5
|
+
import { mapValues } from "es-toolkit";
|
|
6
|
+
//#region src/behaviours/model.ts
|
|
7
|
+
const DEFAULT_NUMBER_SETTINGS = {
|
|
8
|
+
min: 0,
|
|
9
|
+
max: 100,
|
|
10
|
+
step: 1,
|
|
11
|
+
default: 50
|
|
12
|
+
};
|
|
13
|
+
/** A boolean value's binding, if the behaviour has one. */
|
|
14
|
+
function booleanBinding(behaviour, valueId) {
|
|
15
|
+
return Object.hasOwn(behaviour.booleans, valueId) ? behaviour.booleans[valueId] : void 0;
|
|
16
|
+
}
|
|
17
|
+
/** The slot property a part is bound to, if any. */
|
|
18
|
+
function partBinding(behaviour, partId) {
|
|
19
|
+
return Object.hasOwn(behaviour.parts, partId) ? behaviour.parts[partId] : void 0;
|
|
20
|
+
}
|
|
21
|
+
/** The text property a text value is bound to, if any. */
|
|
22
|
+
function textBinding(behaviour, valueId) {
|
|
23
|
+
return Object.hasOwn(behaviour.texts, valueId) ? behaviour.texts[valueId].propertyId : void 0;
|
|
24
|
+
}
|
|
25
|
+
/** A number value's range, if the behaviour has one. */
|
|
26
|
+
function numberSettings(behaviour, valueId) {
|
|
27
|
+
return Object.hasOwn(behaviour.numbers, valueId) ? behaviour.numbers[valueId] : void 0;
|
|
28
|
+
}
|
|
29
|
+
/** A new behaviour of a kind, its number values at their defaults and nothing bound. */
|
|
30
|
+
function emptyBehaviour(kind) {
|
|
31
|
+
const contract = behaviourContract(kind);
|
|
32
|
+
return {
|
|
33
|
+
kind,
|
|
34
|
+
booleans: {},
|
|
35
|
+
texts: {},
|
|
36
|
+
numbers: Object.fromEntries(contract.values.filter((value) => value.type === "number").map((value) => [value.id, { ...DEFAULT_NUMBER_SETTINGS }])),
|
|
37
|
+
parts: {}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The node that keeps the behaviour: a component set for its variants, otherwise the main
|
|
42
|
+
* component itself.
|
|
43
|
+
*/
|
|
44
|
+
function behaviourOwner(graph, node) {
|
|
45
|
+
if (node.type === "COMPONENT_SET") return node;
|
|
46
|
+
if (node.type !== "COMPONENT") return void 0;
|
|
47
|
+
const parent = node.parentId ? graph.getNode(node.parentId) : void 0;
|
|
48
|
+
return parent?.type === "COMPONENT_SET" ? parent : node;
|
|
49
|
+
}
|
|
50
|
+
/** The behaviour a component or component set keeps, or null when it has none or it is unreadable. */
|
|
51
|
+
function readBehaviour(owner) {
|
|
52
|
+
return readPluginData(owner.pluginData, OPEN_PENCIL_PLUGIN_DATA.behaviour) ?? null;
|
|
53
|
+
}
|
|
54
|
+
/** The owner's plugin data with the behaviour set, or removed when null. */
|
|
55
|
+
function withBehaviour(owner, behaviour) {
|
|
56
|
+
return withPluginData(owner.pluginData, OPEN_PENCIL_PLUGIN_DATA.behaviour, behaviour ?? void 0);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Component properties the behaviour can bind to: the owner's, with a set's variant values and
|
|
60
|
+
* defaults read from its variants, and a set's variants' own.
|
|
61
|
+
*/
|
|
62
|
+
function behaviourProperties(graph, owner) {
|
|
63
|
+
const isSet = owner.type === "COMPONENT_SET";
|
|
64
|
+
const own = isSet ? owner.componentPropertyDefinitions.map((definition) => resolvedVariantDefinition(graph, owner, definition)) : owner.componentPropertyDefinitions;
|
|
65
|
+
const variants = isSet ? owner.childIds.flatMap((id) => graph.getNode(id)?.componentPropertyDefinitions ?? []) : [];
|
|
66
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67
|
+
return [...own, ...variants].filter((definition) => {
|
|
68
|
+
if (seen.has(definition.id)) return false;
|
|
69
|
+
seen.add(definition.id);
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Required values and parts that are unbound, or bound to a property the component no longer
|
|
75
|
+
* has, by value or part id; `states` when the interaction states lost their variant property.
|
|
76
|
+
*/
|
|
77
|
+
function missingBindings(graph, owner, behaviour) {
|
|
78
|
+
const contract = behaviourContract(behaviour.kind);
|
|
79
|
+
const properties = new Map(behaviourProperties(graph, owner).map((definition) => [definition.id, definition]));
|
|
80
|
+
const bound = (propertyId, type) => {
|
|
81
|
+
const definition = propertyId ? properties.get(propertyId) : void 0;
|
|
82
|
+
return !!definition && type.includes(definition.type);
|
|
83
|
+
};
|
|
84
|
+
const values = contract.values.filter((value) => value.required).filter((value) => value.type === "text" ? !bound(textBinding(behaviour, value.id), ["TEXT"]) : value.type === "boolean" && !bound(booleanBinding(behaviour, value.id)?.propertyId, ["VARIANT", "BOOLEAN"])).map((value) => value.id);
|
|
85
|
+
const parts = contract.parts.filter((part) => part.required && !bound(partBinding(behaviour, part.id), ["SLOT"])).map((part) => part.id);
|
|
86
|
+
const states = behaviour.states && !bound(behaviour.states.propertyId, ["VARIANT"]) ? ["states"] : [];
|
|
87
|
+
return [
|
|
88
|
+
...values,
|
|
89
|
+
...parts,
|
|
90
|
+
...states
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
/** Variant value names that usually mean each interaction state, compared case-insensitively. */
|
|
94
|
+
const STATE_NAMES = {
|
|
95
|
+
rest: [
|
|
96
|
+
"default",
|
|
97
|
+
"rest",
|
|
98
|
+
"idle",
|
|
99
|
+
"normal",
|
|
100
|
+
"enabled"
|
|
101
|
+
],
|
|
102
|
+
hover: [
|
|
103
|
+
"hover",
|
|
104
|
+
"hovered",
|
|
105
|
+
"hovering"
|
|
106
|
+
],
|
|
107
|
+
pressed: [
|
|
108
|
+
"pressed",
|
|
109
|
+
"active",
|
|
110
|
+
"down",
|
|
111
|
+
"pressing"
|
|
112
|
+
],
|
|
113
|
+
focus: [
|
|
114
|
+
"focus",
|
|
115
|
+
"focused",
|
|
116
|
+
"focus visible",
|
|
117
|
+
"focus-visible"
|
|
118
|
+
],
|
|
119
|
+
disabled: ["disabled", "inactive"],
|
|
120
|
+
invalid: ["invalid", "error"]
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* A kind of control's interaction states for a variant property, each mapped to the value whose
|
|
124
|
+
* name means it, such as `Hover` or `Pressed`; states without such a value are left unset.
|
|
125
|
+
*/
|
|
126
|
+
function guessInteractionStates(kind, propertyId, values) {
|
|
127
|
+
const states = { propertyId };
|
|
128
|
+
for (const state of interactionStatesOf(kind)) {
|
|
129
|
+
const match = values.find((value) => STATE_NAMES[state].includes(value.trim().toLowerCase()));
|
|
130
|
+
if (match) states[state] = match;
|
|
131
|
+
}
|
|
132
|
+
return states;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The behaviour with every component property id it binds renamed by `rename`, for formats that
|
|
136
|
+
* give properties new ids on write, such as `.fig` with its GUIDs.
|
|
137
|
+
*/
|
|
138
|
+
function renameBehaviourProperties(behaviour, rename) {
|
|
139
|
+
return {
|
|
140
|
+
...behaviour,
|
|
141
|
+
booleans: mapValues(behaviour.booleans, (binding) => ({
|
|
142
|
+
...binding,
|
|
143
|
+
propertyId: rename(binding.propertyId)
|
|
144
|
+
})),
|
|
145
|
+
texts: mapValues(behaviour.texts, (binding) => ({ propertyId: rename(binding.propertyId) })),
|
|
146
|
+
parts: mapValues(behaviour.parts, rename),
|
|
147
|
+
...behaviour.states ? { states: {
|
|
148
|
+
...behaviour.states,
|
|
149
|
+
propertyId: rename(behaviour.states.propertyId)
|
|
150
|
+
} } : {}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { DEFAULT_NUMBER_SETTINGS, behaviourOwner, behaviourProperties, booleanBinding, emptyBehaviour, guessInteractionStates, missingBindings, numberSettings, partBinding, readBehaviour, renameBehaviourProperties, textBinding, withBehaviour };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","names":[],"sources":["../../src/behaviours/model.ts"],"sourcesContent":["import { mapValues } from 'es-toolkit'\n\nimport { resolvedVariantDefinition } from '../components/variants'\nimport type { SceneGraph } from '../graph'\nimport { readPluginData, withPluginData } from '../plugin-data/field'\nimport { OPEN_PENCIL_PLUGIN_DATA } from '../plugin-data/fields'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\nimport {\n behaviourContract,\n interactionStatesOf,\n type BehaviourKind,\n type InteractionState\n} from './kinds'\nimport type {\n Behaviour,\n BehaviourBooleanBinding,\n BehaviourInteractionStates,\n BehaviourNumberSettings\n} from './schema'\n\nexport const DEFAULT_NUMBER_SETTINGS: BehaviourNumberSettings = {\n min: 0,\n max: 100,\n step: 1,\n default: 50\n}\n\n/** A boolean value's binding, if the behaviour has one. */\nexport function booleanBinding(\n behaviour: Behaviour,\n valueId: string\n): BehaviourBooleanBinding | undefined {\n return Object.hasOwn(behaviour.booleans, valueId) ? behaviour.booleans[valueId] : undefined\n}\n\n/** The slot property a part is bound to, if any. */\nexport function partBinding(behaviour: Behaviour, partId: string): string | undefined {\n return Object.hasOwn(behaviour.parts, partId) ? behaviour.parts[partId] : undefined\n}\n\n/** The text property a text value is bound to, if any. */\nexport function textBinding(behaviour: Behaviour, valueId: string): string | undefined {\n return Object.hasOwn(behaviour.texts, valueId) ? behaviour.texts[valueId].propertyId : undefined\n}\n\n/** A number value's range, if the behaviour has one. */\nexport function numberSettings(\n behaviour: Behaviour,\n valueId: string\n): BehaviourNumberSettings | undefined {\n return Object.hasOwn(behaviour.numbers, valueId) ? behaviour.numbers[valueId] : undefined\n}\n\n/** A new behaviour of a kind, its number values at their defaults and nothing bound. */\nexport function emptyBehaviour(kind: BehaviourKind): Behaviour {\n const contract = behaviourContract(kind)\n const numbers = Object.fromEntries(\n contract.values\n .filter((value) => value.type === 'number')\n .map((value) => [value.id, { ...DEFAULT_NUMBER_SETTINGS }])\n )\n return { kind, booleans: {}, texts: {}, numbers, parts: {} }\n}\n\n/**\n * The node that keeps the behaviour: a component set for its variants, otherwise the main\n * component itself.\n */\nexport function behaviourOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n if (node.type === 'COMPONENT_SET') return node\n if (node.type !== 'COMPONENT') return undefined\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n return parent?.type === 'COMPONENT_SET' ? parent : node\n}\n\n/** The behaviour a component or component set keeps, or null when it has none or it is unreadable. */\nexport function readBehaviour(owner: SceneNode): Behaviour | null {\n return readPluginData(owner.pluginData, OPEN_PENCIL_PLUGIN_DATA.behaviour) ?? null\n}\n\n/** The owner's plugin data with the behaviour set, or removed when null. */\nexport function withBehaviour(\n owner: SceneNode,\n behaviour: Behaviour | null\n): SceneNode['pluginData'] {\n return withPluginData(owner.pluginData, OPEN_PENCIL_PLUGIN_DATA.behaviour, behaviour ?? undefined)\n}\n\n/**\n * Component properties the behaviour can bind to: the owner's, with a set's variant values and\n * defaults read from its variants, and a set's variants' own.\n */\nexport function behaviourProperties(\n graph: SceneGraph,\n owner: SceneNode\n): ComponentPropertyDefinition[] {\n const isSet = owner.type === 'COMPONENT_SET'\n const own = isSet\n ? owner.componentPropertyDefinitions.map((definition) =>\n resolvedVariantDefinition(graph, owner, definition)\n )\n : owner.componentPropertyDefinitions\n const variants = isSet\n ? owner.childIds.flatMap((id) => graph.getNode(id)?.componentPropertyDefinitions ?? [])\n : []\n const seen = new Set<string>()\n return [...own, ...variants].filter((definition) => {\n if (seen.has(definition.id)) return false\n seen.add(definition.id)\n return true\n })\n}\n\n/**\n * Required values and parts that are unbound, or bound to a property the component no longer\n * has, by value or part id; `states` when the interaction states lost their variant property.\n */\nexport function missingBindings(\n graph: SceneGraph,\n owner: SceneNode,\n behaviour: Behaviour\n): string[] {\n const contract = behaviourContract(behaviour.kind)\n const properties = new Map(\n behaviourProperties(graph, owner).map((definition) => [definition.id, definition])\n )\n const bound = (propertyId: string | undefined, type: ComponentPropertyDefinition['type'][]) => {\n const definition = propertyId ? properties.get(propertyId) : undefined\n return !!definition && type.includes(definition.type)\n }\n const values = contract.values\n .filter((value) => value.required)\n .filter((value) =>\n value.type === 'text'\n ? !bound(textBinding(behaviour, value.id), ['TEXT'])\n : value.type === 'boolean' &&\n !bound(booleanBinding(behaviour, value.id)?.propertyId, ['VARIANT', 'BOOLEAN'])\n )\n .map((value) => value.id)\n const parts = contract.parts\n .filter((part) => part.required && !bound(partBinding(behaviour, part.id), ['SLOT']))\n .map((part) => part.id)\n const states =\n behaviour.states && !bound(behaviour.states.propertyId, ['VARIANT']) ? ['states'] : []\n return [...values, ...parts, ...states]\n}\n\n/** Variant value names that usually mean each interaction state, compared case-insensitively. */\nconst STATE_NAMES: Record<InteractionState, readonly string[]> = {\n rest: ['default', 'rest', 'idle', 'normal', 'enabled'],\n hover: ['hover', 'hovered', 'hovering'],\n pressed: ['pressed', 'active', 'down', 'pressing'],\n focus: ['focus', 'focused', 'focus visible', 'focus-visible'],\n disabled: ['disabled', 'inactive'],\n invalid: ['invalid', 'error']\n}\n\n/**\n * A kind of control's interaction states for a variant property, each mapped to the value whose\n * name means it, such as `Hover` or `Pressed`; states without such a value are left unset.\n */\nexport function guessInteractionStates(\n kind: BehaviourKind,\n propertyId: string,\n values: readonly string[]\n): BehaviourInteractionStates {\n const states: BehaviourInteractionStates = { propertyId }\n for (const state of interactionStatesOf(kind)) {\n const match = values.find((value) => STATE_NAMES[state].includes(value.trim().toLowerCase()))\n if (match) states[state] = match\n }\n return states\n}\n\n/**\n * The behaviour with every component property id it binds renamed by `rename`, for formats that\n * give properties new ids on write, such as `.fig` with its GUIDs.\n */\nexport function renameBehaviourProperties(\n behaviour: Behaviour,\n rename: (propertyId: string) => string\n): Behaviour {\n return {\n ...behaviour,\n booleans: mapValues(behaviour.booleans, (binding) => ({\n ...binding,\n propertyId: rename(binding.propertyId)\n })),\n texts: mapValues(behaviour.texts, (binding) => ({ propertyId: rename(binding.propertyId) })),\n parts: mapValues(behaviour.parts, rename),\n ...(behaviour.states\n ? { states: { ...behaviour.states, propertyId: rename(behaviour.states.propertyId) } }\n : {})\n }\n}\n"],"mappings":"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"}
|