UNPKG

svelte-parse

Version:

An increidbly relaxed svelte-parser

1,876 lines 50.1 kB
{ "type": "root", "children": [ { "type": "svelteScript", "tagName": "script", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n import inlinestyles from '../../helpers/inlineStyles';\n import { createEventDispatcher } from 'svelte';\n\n import Card from '../Card/Card.svelte';\n import cardOptions from '../Card/options';\n\n import Checkbox from '../Checkbox/Checkbox.svelte';\n import Search from '../Search/Search.svelte';\n\n import DropdownMenuDivider from './_DropdownMenuDivider.svelte';\n import DropdownMenuItem from './_DropdownMenuItem.svelte';\n\n import arrayHasItem from '../../helpers/arrayHasItem';\n\n\n const dispatch = createEventDispatcher();\n\n export let dropdownMenu = null;\n export let width = null;\n export let search = null;\n export let items = [];\n export let selectedItem = null;\n export let itemKey = 'label';\n export let isMulti = false;\n export let maxHeight = null;\n export let searchText = '';\n export let isSearchable = null;\n\n function onClick(selected) {\n if (isMulti && arrayHasItem(selectedItem, selected)) {\n dispatch('clearSelect', { selected, itemKey });\n } else {\n const data = isMulti ? { selected, itemKey } : selected;\n dispatch('select', data);\n }\n }\n\n let FilteredItems;\n $: {\n if (!items) FilteredItems = [];\n else if (!isSearchable || !searchText) FilteredItems = items;\n else {\n const reg = new RegExp(searchText, \"i\");\n FilteredItems = items.filter(item => { return reg.test(item[itemKey]); });\n }\n }\n\n let Styles;\n $: {\n Styles = inlinestyles(\n {\n 'max-height': maxHeight ? `${maxHeight}px` : '',\n 'overflow-y': maxHeight ? 'auto' : ''\n }\n );\n }\n\n function matchSearchResult(itemLabel, searchText) {\n if (searchText && searchText.length === 0) return itemLabel;\n\n const reg = new RegExp(searchText, \"i\");\n return itemLabel.replace(reg, '<strong>$&</strong>');\n };\n\n\n", "position": { "start": { "line": 1, "column": 9, "offset": 8 }, "end": { "line": 67, "column": 1, "offset": 1800 } } } ], "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 67, "column": 10, "offset": 1809 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 67, "column": 10, "offset": 1809 }, "end": { "line": 69, "column": 1, "offset": 1811 } } }, { "type": "svelteStyle", "tagName": "style", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n .dropdownMenu {\n overflow: hidden;\n }\n .checkbox {\n margin-right: 12px;\n }\n", "position": { "start": { "line": 69, "column": 8, "offset": 1818 }, "end": { "line": 76, "column": 1, "offset": 1905 } } } ], "position": { "start": { "line": 69, "column": 1, "offset": 1811 }, "end": { "line": 76, "column": 9, "offset": 1913 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 76, "column": 9, "offset": 1913 }, "end": { "line": 78, "column": 1, "offset": 1915 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 78, "column": 16, "offset": 1930 }, "end": { "line": 78, "column": 30, "offset": 1944 } }, "expression": { "type": "svelteExpression", "value": "dropdownMenu", "position": { "start": { "line": 78, "column": 17, "offset": 1931 }, "end": { "line": 78, "column": 29, "offset": 1943 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 78, "column": 6, "offset": 1920 }, "end": { "line": 78, "column": 30, "offset": 1944 } }, "specifier": "this" }, { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "dropdownMenu", "position": { "start": { "line": 78, "column": 38, "offset": 1952 }, "end": { "line": 78, "column": 51, "offset": 1965 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 78, "column": 31, "offset": 1945 }, "end": { "line": 78, "column": 51, "offset": 1965 } } }, { "type": "svelteProperty", "name": "style", "value": [ { "type": "text", "value": "width:", "position": { "start": { "line": 78, "column": 59, "offset": 1973 }, "end": { "line": 78, "column": 65, "offset": 1979 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 78, "column": 65, "offset": 1979 }, "end": { "line": 78, "column": 72, "offset": 1986 } }, "expression": { "type": "svelteExpression", "value": "width", "position": { "start": { "line": 78, "column": 66, "offset": 1980 }, "end": { "line": 78, "column": 71, "offset": 1985 } } } }, { "type": "text", "value": ";", "position": { "start": { "line": 78, "column": 72, "offset": 1986 }, "end": { "line": 78, "column": 74, "offset": 1988 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 78, "column": 52, "offset": 1966 }, "end": { "line": 78, "column": 74, "offset": 1988 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 78, "column": 75, "offset": 1989 }, "end": { "line": 79, "column": 3, "offset": 1992 } } }, { "type": "svelteComponent", "tagName": "Card", "properties": [ { "type": "svelteProperty", "name": "level", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 79, "column": 16, "offset": 2005 }, "end": { "line": 79, "column": 39, "offset": 2028 } }, "expression": { "type": "svelteExpression", "value": "cardOptions.level.TWO", "position": { "start": { "line": 79, "column": 17, "offset": 2006 }, "end": { "line": 79, "column": 38, "offset": 2027 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 79, "column": 9, "offset": 1998 }, "end": { "line": 79, "column": 40, "offset": 2029 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 79, "column": 41, "offset": 2030 }, "end": { "line": 80, "column": 5, "offset": 2035 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "isSearchable", "position": { "start": { "line": 80, "column": 10, "offset": 2040 }, "end": { "line": 80, "column": 22, "offset": 2052 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 80, "column": 23, "offset": 2053 }, "end": { "line": 81, "column": 7, "offset": 2060 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 81, "column": 22, "offset": 2075 }, "end": { "line": 81, "column": 30, "offset": 2083 } }, "expression": { "type": "svelteExpression", "value": "search", "position": { "start": { "line": 81, "column": 23, "offset": 2076 }, "end": { "line": 81, "column": 29, "offset": 2082 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 81, "column": 12, "offset": 2065 }, "end": { "line": 81, "column": 30, "offset": 2083 } }, "specifier": "this" }, { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "search", "position": { "start": { "line": 81, "column": 38, "offset": 2091 }, "end": { "line": 81, "column": 45, "offset": 2098 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 81, "column": 31, "offset": 2084 }, "end": { "line": 81, "column": 45, "offset": 2098 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 81, "column": 46, "offset": 2099 }, "end": { "line": 82, "column": 9, "offset": 2108 } } }, { "type": "svelteComponent", "tagName": "Search", "properties": [ { "type": "svelteDirective", "name": "bind", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 82, "column": 29, "offset": 2128 }, "end": { "line": 82, "column": 41, "offset": 2140 } }, "expression": { "type": "svelteExpression", "value": "searchText", "position": { "start": { "line": 82, "column": 30, "offset": 2129 }, "end": { "line": 82, "column": 40, "offset": 2139 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 82, "column": 17, "offset": 2116 }, "end": { "line": 82, "column": 42, "offset": 2141 } }, "specifier": "value" }, { "type": "svelteDirective", "name": "on", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 82, "column": 53, "offset": 2152 }, "end": { "line": 82, "column": 86, "offset": 2185 } }, "expression": { "type": "svelteExpression", "value": " () => dispatch('searchClear') ", "position": { "start": { "line": 82, "column": 54, "offset": 2153 }, "end": { "line": 82, "column": 85, "offset": 2184 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 82, "column": 43, "offset": 2142 }, "end": { "line": 82, "column": 87, "offset": 2186 } }, "specifier": "clear" } ], "selfClosing": true, "children": [], "position": { "start": { "line": 82, "column": 9, "offset": 2108 }, "end": { "line": 82, "column": 89, "offset": 2188 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 82, "column": 89, "offset": 2188 }, "end": { "line": 83, "column": 7, "offset": 2195 } } } ], "position": { "start": { "line": 81, "column": 7, "offset": 2060 }, "end": { "line": 83, "column": 13, "offset": 2201 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 83, "column": 13, "offset": 2201 }, "end": { "line": 84, "column": 5, "offset": 2206 } } } ], "position": { "start": { "line": 80, "column": 5, "offset": 2035 }, "end": { "line": 84, "column": 5, "offset": 2206 } } } ], "position": { "start": { "line": 80, "column": 5, "offset": 2035 }, "end": { "line": 84, "column": 10, "offset": 2211 } } }, { "type": "text", "value": "\n\n ", "position": { "start": { "line": 84, "column": 10, "offset": 2211 }, "end": { "line": 86, "column": 5, "offset": 2217 } } }, { "type": "svelteElement", "tagName": "slot", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 86, "column": 11, "offset": 2223 }, "end": { "line": 87, "column": 9, "offset": 2232 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "style", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 87, "column": 21, "offset": 2244 }, "end": { "line": 87, "column": 29, "offset": 2252 } }, "expression": { "type": "svelteExpression", "value": "Styles", "position": { "start": { "line": 87, "column": 22, "offset": 2245 }, "end": { "line": 87, "column": 28, "offset": 2251 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 87, "column": 14, "offset": 2237 }, "end": { "line": 87, "column": 30, "offset": 2253 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 87, "column": 31, "offset": 2254 }, "end": { "line": 88, "column": 11, "offset": 2265 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "isSearchable", "position": { "start": { "line": 88, "column": 16, "offset": 2270 }, "end": { "line": 88, "column": 28, "offset": 2282 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 88, "column": 29, "offset": 2283 }, "end": { "line": 89, "column": 11, "offset": 2294 } } }, { "type": "svelteComponent", "tagName": "DropdownMenuDivider", "properties": [ { "type": "svelteProperty", "name": "noMargin", "value": [], "modifiers": [], "shorthand": "boolean", "position": { "start": { "line": 89, "column": 32, "offset": 2315 }, "end": { "line": 89, "column": 40, "offset": 2323 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 89, "column": 11, "offset": 2294 }, "end": { "line": 89, "column": 43, "offset": 2326 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 89, "column": 43, "offset": 2326 }, "end": { "line": 90, "column": 11, "offset": 2337 } } } ], "position": { "start": { "line": 88, "column": 11, "offset": 2265 }, "end": { "line": 90, "column": 11, "offset": 2337 } } } ], "position": { "start": { "line": 88, "column": 11, "offset": 2265 }, "end": { "line": 90, "column": 16, "offset": 2342 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 90, "column": 16, "offset": 2342 }, "end": { "line": 91, "column": 11, "offset": 2353 } } }, { "type": "svelteBranchingBlock", "name": "each", "branches": [ { "type": "svelteBranch", "name": "each", "expression": { "type": "svelteExpression", "value": "FilteredItems as item", "position": { "start": { "line": 91, "column": 18, "offset": 2360 }, "end": { "line": 91, "column": 39, "offset": 2381 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 91, "column": 40, "offset": 2382 }, "end": { "line": 92, "column": 13, "offset": 2395 } } }, { "type": "svelteComponent", "tagName": "DropdownMenuItem", "properties": [ { "type": "svelteProperty", "name": "isMulti", "value": [ { "type": "svelteDynamicContent", "expression": { "type": "svelteExpression", "value": "isMulti", "position": { "start": { "line": 93, "column": 16, "offset": 2428 }, "end": { "line": 93, "column": 23, "offset": 2435 } } }, "position": { "start": { "line": 93, "column": 15, "offset": 2427 }, "end": { "line": 93, "column": 23, "offset": 2435 } } } ], "modifiers": [], "shorthand": "expression", "position": { "start": { "line": 93, "column": 15, "offset": 2427 }, "end": { "line": 93, "column": 23, "offset": 2435 } } }, { "type": "svelteProperty", "name": "isSelected", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 94, "column": 27, "offset": 2463 }, "end": { "line": 94, "column": 97, "offset": 2533 } }, "expression": { "type": "svelteExpression", "value": " isMulti ? arrayHasItem(selectedItem, item) : item === selectedItem ", "position": { "start": { "line": 94, "column": 28, "offset": 2464 }, "end": { "line": 94, "column": 96, "offset": 2532 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 94, "column": 15, "offset": 2451 }, "end": { "line": 94, "column": 98, "offset": 2534 } } }, { "type": "svelteDirective", "name": "on", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 95, "column": 25, "offset": 2559 }, "end": { "line": 95, "column": 48, "offset": 2582 } }, "expression": { "type": "svelteExpression", "value": " () => onClick(item) ", "position": { "start": { "line": 95, "column": 26, "offset": 2560 }, "end": { "line": 95, "column": 47, "offset": 2581 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 95, "column": 15, "offset": 2549 }, "end": { "line": 95, "column": 49, "offset": 2583 } }, "specifier": "click" } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 96, "column": 14, "offset": 2597 }, "end": { "line": 97, "column": 15, "offset": 2612 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "isMulti", "position": { "start": { "line": 97, "column": 20, "offset": 2617 }, "end": { "line": 97, "column": 27, "offset": 2624 } } }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 97, "column": 28, "offset": 2625 }, "end": { "line": 98, "column": 15, "offset": 2640 } } }, { "type": "svelteElement", "tagName": "div", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "checkbox", "position": { "start": { "line": 98, "column": 27, "offset": 2652 }, "end": { "line": 98, "column": 36, "offset": 2661 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 98, "column": 20, "offset": 2645 }, "end": { "line": 98, "column": 36, "offset": 2661 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 98, "column": 37, "offset": 2662 }, "end": { "line": 99, "column": 17, "offset": 2679 } } }, { "type": "svelteComponent", "tagName": "Checkbox", "properties": [ { "type": "svelteProperty", "name": "isChecked", "value": [ { "type": "svelteDynamicContent", "position": { "start": { "line": 99, "column": 38, "offset": 2700 }, "end": { "line": 99, "column": 72, "offset": 2734 } }, "expression": { "type": "svelteExpression", "value": "arrayHasItem(selectedItem, item)", "position": { "start": { "line": 99, "column": 39, "offset": 2701 }, "end": { "line": 99, "column": 71, "offset": 2733 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 99, "column": 27, "offset": 2689 }, "end": { "line": 99, "column": 73, "offset": 2735 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 99, "column": 17, "offset": 2679 }, "end": { "line": 99, "column": 76, "offset": 2738 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 99, "column": 76, "offset": 2738 }, "end": { "line": 100, "column": 15, "offset": 2753 } } } ], "position": { "start": { "line": 98, "column": 15, "offset": 2640 }, "end": { "line": 100, "column": 21, "offset": 2759 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 100, "column": 21, "offset": 2759 }, "end": { "line": 101, "column": 15, "offset": 2774 } } }, { "type": "svelteElement", "tagName": "div", "properties": [], "selfClosing": false, "children": [ { "type": "svelteVoidBlock", "name": "html", "expression": { "type": "svelteExpression", "value": "matchSearchResult(item[itemKey], searchText) ", "position": { "start": { "line": 101, "column": 28, "offset": 2787 }, "end": { "line": 101, "column": 73, "offset": 2832 } } }, "position": { "start": { "line": 101, "column": 20, "offset": 2779 }, "end": { "line": 101, "column": 74, "offset": 2833 } } } ], "position": { "start": { "line": 101, "column": 15, "offset": 2774 }, "end": { "line": 101, "column": 80, "offset": 2839 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 101, "column": 80, "offset": 2839 }, "end": { "line": 102, "column": 15, "offset": 2854 } } } ], "position": { "start": { "line": 97, "column": 15, "offset": 2612 }, "end": { "line": 102, "column": 15, "offset": 2854 } } }, { "type": "svelteBranch", "name": "else", "expression": { "type": "svelteExpression", "value": "" }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 102, "column": 22, "offset": 2861 }, "end": { "line": 103, "column": 15, "offset": 2876 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 103, "column": 15, "offset": 2876 }, "end": { "line": 103, "column": 30, "offset": 2891 } }, "expression": { "type": "svelteExpression", "value": "item[itemKey]", "position": { "start": { "line": 103, "column": 16, "offset": 2877 }, "end": { "line": 103, "column": 29, "offset": 2890 } } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 103, "column": 30, "offset": 2891 }, "end": { "line": 104, "column": 15, "offset": 2906 } } } ], "position": { "start": { "line": 102, "column": 15, "offset": 2854 }, "end": { "line": 104, "column": 15, "offset": 2906 } } } ], "position": { "start": { "line": 97, "column": 15, "offset": 2612 }, "end": { "line": 104, "column": 20, "offset": 2911 } } }, { "type": "text", "value": "\n \n ", "position": { "start": { "line": 104, "column": 20, "offset": 2911 }, "end": { "line": 106, "column": 13, "offset": 2939 } } } ], "position": { "start": { "line": 92, "column": 13, "offset": 2395 }, "end": { "line": 106, "column": 32, "offset": 2958 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 106, "column": 32, "offset": 2958 }, "end": { "line": 107, "column": 11, "offset": 2969 } } } ], "position": { "start": { "line": 91, "column": 11, "offset": 2353 }, "end": { "line": 107, "column": 11, "offset": 2969 } } }, { "type": "svelteBranch", "name": "else", "expression": { "type": "svelteExpression", "value": "" }, "children": [ { "type": "text", "value": "\n ", "position": { "start": { "line": 107, "column": 18, "offset": 2976 }, "end": { "line": 108, "column": 13, "offset": 2989 } } }, { "type": "svelteComponent", "tagName": "DropdownMenuItem", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "No results", "position": { "start": { "line": 108, "column": 31, "offset": 3007 }, "end": { "line": 108, "column": 41, "offset": 3017 } } } ], "position": { "start": { "line": 108, "column": 13, "offset": 2989 }, "end": { "line": 108, "column": 60, "offset": 3036 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 108, "column": 60, "offset": 3036 }, "end": { "line": 109, "column": 9, "offset": 3045 } } } ], "position": { "start": { "line": 107, "column": 11, "offset": 2969 }, "end": { "line": 109, "column": 9, "offset": 3045 } } } ], "position": { "start": { "line": 91, "column": 11, "offset": 2353 }, "end": { "line": 109, "column": 16, "offset": 3052 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 109, "column": 16, "offset": 3052 }, "end": { "line": 110, "column": 7, "offset": 3059 } } } ], "position": { "start": { "line": 87, "column": 9, "offset": 2232 }, "end": { "line": 110, "column": 13, "offset": 3065 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 110, "column": 13, "offset": 3065 }, "end": { "line": 111, "column": 5, "offset": 3070 } } } ], "position": { "start": { "line": 86, "column": 5, "offset": 2217 }, "end": { "line": 111, "column": 12, "offset": 3077 } } }, { "type": "text", "value": "\n ", "position": { "start": { "line": 111, "column": 12, "offset": 3077 }, "end": { "line": 112, "column": 3, "offset": 3080 } } } ], "position": { "start": { "line": 79, "column": 3, "offset": 1992 }, "end": { "line": 112, "column": 10, "offset": 3087 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 112, "column": 10, "offset": 3087 }, "end": { "line": 113, "column": 1, "offset": 3088 } } } ], "position": { "start": { "line": 78, "column": 1, "offset": 1915 }, "end": { "line": 113, "column": 7, "offset": 3094 } } } ], "position": { "sta