svelte-parse
Version:
An increidbly relaxed svelte-parser
986 lines (985 loc) • 20.4 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n import { createEventDispatcher } from 'svelte';\n import dayjs from 'dayjs';\n import Select from 'svelte-select/Select';\n\n import ClockIcon from '../Icons/Clock.svelte';\n\n const dispatch = createEventDispatcher();\n\n export let selected = undefined;\n export let format = 'h:mma';\n export let increment = 30;\n export let containerStyles = 'padding-left:43px;';\n export let inputStyles = 'padding-left:43px;';\n export let isClearable = true;\n export let isDisabled = false;\n export let placeholder = 'Select a time';\n export let getOptionLabel = (option) => {\n return option.value;\n };\n export let getSelectionLabel = (option) => {\n return option.value;\n };\n\n let selectedValue = undefined;\n\n $: {\n selectedValue = selected ? { value: selected } : undefined;\n }\n\n export let items;\n\n $: {\n const options = [];\n let day = dayjs().set('minute', 0).set('hour', 0);\n const dayEnd = day.add(1, 'day');\n\n while (day.isBefore(dayEnd, 'day')) {\n options.push({\n value: day.format(format),\n label: day.format(format)\n });\n\n day = day.add(increment, 'minute');\n }\n\n items = options;\n }\n\n function onClear() {\n selected = undefined;\n\n dispatch('clear');\n }\n\n function onSelect(event) {\n selected = event.detail.value;\n dispatch('select', selected);\n }\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 60,
"column": 1,
"offset": 1342
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 60,
"column": 10,
"offset": 1351
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 60,
"column": 10,
"offset": 1351
},
"end": {
"line": 62,
"column": 1,
"offset": 1353
}
}
},
{
"type": "svelteStyle",
"tagName": "style",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n .timeSelect {\n color: #2c3e50;\n position: relative;\n }\n\n .icon {\n height: 20px;\n width: 20px;\n position: absolute;\n top: 12px;\n left: 12px;\n z-index: 1;\n }\n",
"position": {
"start": {
"line": 62,
"column": 8,
"offset": 1360
},
"end": {
"line": 76,
"column": 1,
"offset": 1546
}
}
}
],
"position": {
"start": {
"line": 62,
"column": 1,
"offset": 1353
},
"end": {
"line": 76,
"column": 9,
"offset": 1554
}
}
},
{
"type": "text",
"value": "\n\n\n",
"position": {
"start": {
"line": 76,
"column": 9,
"offset": 1554
},
"end": {
"line": 79,
"column": 1,
"offset": 1557
}
}
},
{
"type": "svelteElement",
"tagName": "div",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "timeSelect",
"position": {
"start": {
"line": 79,
"column": 13,
"offset": 1569
},
"end": {
"line": 79,
"column": 24,
"offset": 1580
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 79,
"column": 6,
"offset": 1562
},
"end": {
"line": 79,
"column": 24,
"offset": 1580
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 79,
"column": 25,
"offset": 1581
},
"end": {
"line": 80,
"column": 3,
"offset": 1584
}
}
},
{
"type": "svelteElement",
"tagName": "div",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "icon",
"position": {
"start": {
"line": 80,
"column": 15,
"offset": 1596
},
"end": {
"line": 80,
"column": 20,
"offset": 1601
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 80,
"column": 8,
"offset": 1589
},
"end": {
"line": 80,
"column": 20,
"offset": 1601
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 80,
"column": 21,
"offset": 1602
},
"end": {
"line": 81,
"column": 5,
"offset": 1607
}
}
},
{
"type": "svelteComponent",
"tagName": "ClockIcon",
"properties": [],
"selfClosing": true,
"children": [],
"position": {
"start": {
"line": 81,
"column": 5,
"offset": 1607
},
"end": {
"line": 81,
"column": 18,
"offset": 1620
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 81,
"column": 18,
"offset": 1620
},
"end": {
"line": 82,
"column": 3,
"offset": 1623
}
}
}
],
"position": {
"start": {
"line": 80,
"column": 3,
"offset": 1584
},
"end": {
"line": 82,
"column": 9,
"offset": 1629
}
}
},
{
"type": "text",
"value": "\n\n ",
"position": {
"start": {
"line": 82,
"column": 9,
"offset": 1629
},
"end": {
"line": 84,
"column": 3,
"offset": 1633
}
}
},
{
"type": "svelteComponent",
"tagName": "Select",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 85,
"column": 16,
"offset": 1657
},
"end": {
"line": 85,
"column": 26,
"offset": 1667
}
},
"expression": {
"type": "svelteExpression",
"value": "onSelect",
"position": {
"start": {
"line": 85,
"column": 17,
"offset": 1658
},
"end": {
"line": 85,
"column": 25,
"offset": 1666
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 85,
"column": 5,
"offset": 1646
},
"end": {
"line": 85,
"column": 27,
"offset": 1668
}
},
"specifier": "select"
},
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 86,
"column": 15,
"offset": 1684
},
"end": {
"line": 86,
"column": 24,
"offset": 1693
}
},
"expression": {
"type": "svelteExpression",
"value": "onClear",
"position": {
"start": {
"line": 86,
"column": 16,
"offset": 1685
},
"end": {
"line": 86,
"column": 23,
"offset": 1692
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 86,
"column": 5,
"offset": 1674
},
"end": {
"line": 86,
"column": 25,
"offset": 1694
}
},
"specifier": "clear"
},
{
"type": "svelteProperty",
"name": "isSearchable",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 87,
"column": 19,
"offset": 1714
},
"end": {
"line": 87,
"column": 28,
"offset": 1723
}
},
"expression": {
"type": "svelteExpression",
"value": " false ",
"position": {
"start": {
"line": 87,
"column": 20,
"offset": 1715
},
"end": {
"line": 87,
"column": 27,
"offset": 1722
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 87,
"column": 5,
"offset": 1700
},
"end": {
"line": 87,
"column": 29,
"offset": 1724
}
}
},
{
"type": "svelteProperty",
"name": " selectedValue ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " selectedValue ",
"position": {
"start": {
"line": 88,
"column": 6,
"offset": 1730
},
"end": {
"line": 88,
"column": 21,
"offset": 1745
}
}
},
"position": {
"start": {
"line": 88,
"column": 5,
"offset": 1729
},
"end": {
"line": 88,
"column": 21,
"offset": 1745
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 88,
"column": 5,
"offset": 1729
},
"end": {
"line": 88,
"column": 21,
"offset": 1745
}
}
},
{
"type": "svelteProperty",
"name": " containerStyles ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " containerStyles ",
"position": {
"start": {
"line": 89,
"column": 6,
"offset": 1753
},
"end": {
"line": 89,
"column": 23,
"offset": 1770
}
}
},
"position": {
"start": {
"line": 89,
"column": 5,
"offset": 1752
},
"end": {
"line": 89,
"column": 23,
"offset": 1770
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 89,
"column": 5,
"offset": 1752
},
"end": {
"line": 89,
"column": 23,
"offset": 1770
}
}
},
{
"type": "svelteProperty",
"name": " inputStyles ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " inputStyles ",
"position": {
"start": {
"line": 90,
"column": 6,
"offset": 1778
},
"end": {
"line": 90,
"column": 19,
"offset": 1791
}
}
},
"position": {
"start": {
"line": 90,
"column": 5,
"offset": 1777
},
"end": {
"line": 90,
"column": 19,
"offset": 1791
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 90,
"column": 5,
"offset": 1777
},
"end": {
"line": 90,
"column": 19,
"offset": 1791
}
}
},
{
"type": "svelteProperty",
"name": " isClearable ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " isClearable ",
"position": {
"start": {
"line": 91,
"column": 6,
"offset": 1799
},
"end": {
"line": 91,
"column": 19,
"offset": 1812
}
}
},
"position": {
"start": {
"line": 91,
"column": 5,
"offset": 1798
},
"end": {
"line": 91,
"column": 19,
"offset": 1812
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 91,
"column": 5,
"offset": 1798
},
"end": {
"line": 91,
"column": 19,
"offset": 1812
}
}
},
{
"type": "svelteProperty",
"name": " isDisabled ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " isDisabled ",
"position": {
"start": {
"line": 92,
"column": 6,
"offset": 1820
},
"end": {
"line": 92,
"column": 18,
"offset": 1832
}
}
},
"position": {
"start": {
"line": 92,
"column": 5,
"offset": 1819
},
"end": {
"line": 92,
"column": 18,
"offset": 1832
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 92,
"column": 5,
"offset": 1819
},
"end": {
"line": 92,
"column": 18,
"offset": 1832
}
}
},
{
"type": "svelteProperty",
"name": " placeholder ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " placeholder ",
"position": {
"start": {
"line": 93,
"column": 6,
"offset": 1840
},
"end": {
"line": 93,
"column": 19,
"offset": 1853
}
}
},
"position": {
"start": {
"line": 93,
"column": 5,
"offset": 1839
},
"end": {
"line": 93,
"column": 19,
"offset": 1853
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 93,
"column": 5,
"offset": 1839
},
"end": {
"line": 93,
"column": 19,
"offset": 1853
}
}
},
{
"type": "svelteProperty",
"name": " items ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " items ",
"position": {
"start": {
"line": 94,
"column": 6,
"offset": 1861
},
"end": {
"line": 94,
"column": 13,
"offset": 1868
}
}
},
"position": {
"start": {
"line": 94,
"column": 5,
"offset": 1860
},
"end": {
"line": 94,
"column": 13,
"offset": 1868
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 94,
"column": 5,
"offset": 1860
},
"end": {
"line": 94,
"column": 13,
"offset": 1868
}
}
},
{
"type": "svelteProperty",
"name": " getOptionLabel ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " getOptionLabel ",
"position": {
"start": {
"line": 95,
"column": 6,
"offset": 1876
},
"end": {
"line": 95,
"column": 22,
"offset": 1892
}
}
},
"position": {
"start": {
"line": 95,
"column": 5,
"offset": 1875
},
"end": {
"line": 95,
"column": 22,
"offset": 1892
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 95,
"column": 5,
"offset": 1875
},
"end": {
"line": 95,
"column": 22,
"offset": 1892
}
}
},
{
"type": "svelteProperty",
"name": " getSelectionLabel ",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": " getSelectionLabel ",
"position": {
"start": {
"line": 96,
"column": 6,
"offset": 1900
},
"end": {
"line": 96,
"column": 25,
"offset": 1919
}
}
},
"position": {
"start": {
"line": 96,
"column": 5,
"offset": 1899
},
"end": {
"line": 96,
"column": 25,
"offset": 1919
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 96,
"column": 5,
"offset": 1899
},
"end": {
"line": 96,
"column": 25,
"offset": 1919
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 97,
"column": 4,
"offset": 1924
},
"end": {
"line": 98,
"column": 3,
"offset": 1927
}
}
}
],
"position": {
"start": {
"line": 84,
"column": 3,
"offset": 1633
},
"end": {
"line": 98,
"column": 12,
"offset": 1936
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 98,
"column": 12,
"offset": 1936
},
"end": {
"line": 99,
"column": 1,
"offset": 1937
}
}
}
],
"position": {
"start": {
"line": 79,
"column": 1,
"offset": 1557
},
"end": {
"line": 99,
"column": 7,
"offset": 1943
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 99,
"column": 7,
"offset": 1943
}
}
}