UNPKG

svelte-parse

Version:

An increidbly relaxed svelte-parser

1,123 lines (1,122 loc) 25.3 kB
{ "type": "root", "children": [ { "type": "svelteScript", "tagName": "script", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n import { onDestroy, onMount } from 'svelte'\n import { chooseAnimation, isEscKey } from '../../utils'\n\n export let active = true\n export let animation = 'scale'\n export let animProps = { start: 1.2 }\n export let size = ''\n export let showClose = true\n export let subComponent = null\n export let onBody = true\n\n let modal\n\n $: _animation = chooseAnimation(animation)\n $: {\n if (modal && active && onBody) {\n modal.parentNode.removeChild(modal)\n document.body.appendChild(modal)\n }\n }\n\n onMount(() => {\n \n })\n\n function close() {\n active = false\n }\n\n function keydown(e) {\n if (active && isEscKey(e)) {\n close()\n }\n }\n", "position": { "start": { "line": 1, "column": 9, "offset": 8 }, "end": { "line": 36, "column": 1, "offset": 677 } } } ], "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 36, "column": 10, "offset": 686 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 36, "column": 10, "offset": 686 }, "end": { "line": 38, "column": 1, "offset": 688 } } }, { "type": "svelteMeta", "tagName": "window", "properties": [ { "type": "svelteDirective", "name": "on", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 38, "column": 27, "offset": 714 }, "end": { "line": 38, "column": 36, "offset": 723 } }, "expression": { "type": "svelteExpression", "value": "keydown", "position": { "start": { "line": 38, "column": 28, "offset": 715 }, "end": { "line": 38, "column": 35, "offset": 722 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 38, "column": 16, "offset": 703 }, "end": { "line": 38, "column": 36, "offset": 723 } }, "specifier": "keydown" } ], "selfClosing": false, "children": [], "position": { "start": { "line": 38, "column": 1, "offset": 688 }, "end": { "line": 38, "column": 53, "offset": 740 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 38, "column": 53, "offset": 740 }, "end": { "line": 40, "column": 1, "offset": 742 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "active", "position": { "start": { "line": 40, "column": 6, "offset": 747 }, "end": { "line": 40, "column": 12, "offset": 753 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 40, "column": 13, "offset": 754 }, "end": { "line": 41, "column": 3, "offset": 757 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "modal", "position": { "start": { "line": 41, "column": 15, "offset": 769 }, "end": {} } }, { "type": "text", "value": " ", "position": { "start": { "line": 41, "column": 20, "offset": 774 }, "end": { "line": 41, "column": 21, "offset": 775 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 41, "column": 21, "offset": 775 }, "end": { "line": 41, "column": 27, "offset": 781 } }, "expression": { "type": "svelteExpression", "value": "size", "position": { "start": { "line": 41, "column": 22, "offset": 776 }, "end": { "line": 41, "column": 26, "offset": 780 } } } }, { "type": "text", "value": " ", "position": { "start": { "line": 41, "column": 27, "offset": 781 }, "end": {} } }, { "type": "text", "value": "is-active", "position": { "start": { "line": 41, "column": 28, "offset": 782 }, "end": { "line": 41, "column": 38, "offset": 792 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 41, "column": 8, "offset": 762 }, "end": { "line": 41, "column": 38, "offset": 792 } } }, { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 41, "column": 49, "offset": 803 }, "end": { "line": 41, "column": 56, "offset": 810 } }, "expression": { "type": "svelteExpression", "value": "modal", "position": { "start": { "line": 41, "column": 50, "offset": 804 }, "end": { "line": 41, "column": 55, "offset": 809 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 41, "column": 39, "offset": 793 }, "end": { "line": 41, "column": 56, "offset": 810 } }, "specifier": "this" } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 41, "column": 57, "offset": 811 }, "end": { "line": 42, "column": 5, "offset": 816 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "modal-background", "position": { "start": { "line": 42, "column": 17, "offset": 828 }, "end": { "line": 42, "column": 34, "offset": 845 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 42, "column": 10, "offset": 821 }, "end": { "line": 42, "column": 34, "offset": 845 } } }, { "type": "svelteDirective", "name": "on", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 42, "column": 44, "offset": 855 }, "end": { "line": 42, "column": 51, "offset": 862 } }, "expression": { "type": "svelteExpression", "value": "close", "position": { "start": { "line": 42, "column": 45, "offset": 856 }, "end": { "line": 42, "column": 50, "offset": 861 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 42, "column": 35, "offset": 846 }, "end": { "line": 42, "column": 51, "offset": 862 } }, "specifier": "click" } ], "selfClosing": false, "children": [], "position": { "start": { "line": 42, "column": 5, "offset": 816 }, "end": { "line": 42, "column": 58, "offset": 869 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 42, "column": 58, "offset": 869 }, "end": { "line": 43, "column": 5, "offset": 874 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "modal-content", "position": { "start": { "line": 43, "column": 17, "offset": 886 }, "end": { "line": 43, "column": 31, "offset": 900 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 43, "column": 10, "offset": 879 }, "end": { "line": 43, "column": 31, "offset": 900 } } }, { "type": "svelteDirective", "name": "transition", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 43, "column": 60, "offset": 929 }, "end": { "line": 43, "column": 71, "offset": 940 } }, "expression": { "type": "svelteExpression", "value": "animProps", "position": { "start": { "line": 43, "column": 61, "offset": 930 }, "end": { "line": 43, "column": 70, "offset": 939 } } } } ], "modifiers": [ { "value": "local", "type": "modifier", "position": { "start": { "line": 43, "column": 53, "offset": 922 }, "end": {} } } ], "shorthand": "none", "position": { "start": { "line": 43, "column": 32, "offset": 901 }, "end": { "line": 43, "column": 71, "offset": 940 } }, "specifier": "_animation" } ], "selfClosing": false, "children": [ { "type": "text", "value": " ", "position": { "start": { "line": 43, "column": 72, "offset": 941 }, "end": { "line": 43, "column": 73, "offset": 942 } } }, { "type": "comment", "value": " transition:_animation|local ", "position": { "start": { "line": 43, "column": 73, "offset": 942 }, "end": { "line": 43, "column": 109, "offset": 978 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 43, "column": 109, "offset": 978 }, "end": { "line": 44, "column": 7, "offset": 985 } } }, { "type": "svelteElement", "tagName": "slot", "properties": [], "selfClosing": true, "children": [], "position": { "start": { "line": 44, "column": 7, "offset": 985 }, "end": { "line": 44, "column": 15, "offset": 993 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 44, "column": 15, "offset": 993 }, "end": { "line": 45, "column": 7, "offset": 1000 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "sub-component", "position": { "start": { "line": 45, "column": 19, "offset": 1012 }, "end": { "line": 45, "column": 33, "offset": 1026 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 45, "column": 12, "offset": 1005 }, "end": { "line": 45, "column": 33, "offset": 1026 } } } ], "selfClosing": false, "children": [], "position": { "start": { "line": 45, "column": 7, "offset": 1000 }, "end": { "line": 45, "column": 40, "offset": 1033 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 45, "column": 40, "offset": 1033 }, "end": { "line": 46, "column": 5, "offset": 1038 } } } ], "position": { "start": { "line": 43, "column": 5, "offset": 874 }, "end": { "line": 46, "column": 11, "offset": 1044 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 46, "column": 11, "offset": 1044 }, "end": { "line": 47, "column": 5, "offset": 1049 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "showClose", "position": { "start": { "line": 47, "column": 10, "offset": 1054 }, "end": { "line": 47, "column": 19, "offset": 1063 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 47, "column": 20, "offset": 1064 }, "end": { "line": 48, "column": 7, "offset": 1071 } } }, { "type": "svelteElement", "tagName": "button", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "modal-close", "position": { "start": { "line": 48, "column": 22, "offset": 1086 }, "end": {} } }, { "type": "text", "value": " ", "position": { "start": { "line": 48, "column": 33, "offset": 1097 }, "end": {} } }, { "type": "text", "value": "is-large", "position": { "start": { "line": 48, "column": 34, "offset": 1098 }, "end": { "line": 48, "column": 43, "offset": 1107 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 48, "column": 15, "offset": 1079 }, "end": { "line": 48, "column": 43, "offset": 1107 } } }, { "type": "svelteProperty", "name": "aria-label", "value": [ { "type": "text", "value": "close", "position": { "start": { "line": 48, "column": 56, "offset": 1120 }, "end": { "line": 48, "column": 62, "offset": 1126 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 48, "column": 44, "offset": 1108 }, "end": { "line": 48, "column": 62, "offset": 1126 } } }, { "type": "svelteDirective", "name": "on", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 48, "column": 72, "offset": 1136 }, "end": { "line": 48, "column": 79, "offset": 1143 } }, "expression": { "type": "svelteExpression", "value": "close", "position": { "start": { "line": 48, "column": 73, "offset": 1137 }, "end": { "line": 48, "column": 78, "offset": 1142 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 48, "column": 63, "offset": 1127 }, "end": { "line": 48, "column": 79, "offset": 1143 } }, "specifier": "click" } ], "selfClosing": false, "children": [], "position": { "start": { "line": 48, "column": 7, "offset": 1071 }, "end": { "line": 48, "column": 89, "offset": 1153 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 48, "column": 89, "offset": 1153 }, "end": { "line": 49, "column": 5, "offset": 1158 } } } ], "position": { "start": { "line": 47, "column": 5, "offset": 1049 }, "end": { "line": 49, "column": 5, "offset": 1158 } } } ], "position": { "start": { "line": 47, "column": 5, "offset": 1049 }, "end": { "line": 49, "column": 10, "offset": 1163 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 49, "column": 10, "offset": 1163 }, "end": { "line": 50, "column": 3, "offset": 1166 } } } ], "position": { "start": { "line": 41, "column": 3, "offset": 757 }, "end": { "line": 50, "column": 9, "offset": 1172 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 50, "column": 9, "offset": 1172 }, "end": { "line": 51, "column": 1, "offset": 1173 } } } ], "position": { "start": { "line": 40, "column": 1, "offset": 742 }, "end": { "line": 51, "column": 1, "offset": 1173 } } } ], "position": { "start": { "line": 40, "column": 1, "offset": 742 }, "end": { "line": 51, "column": 6, "offset": 1178 } } } ], "position": { "start": { "column": 1, "line": 1, "offset": 0 }, "end": { "line": 51, "column": 6, "offset": 1178 } } }