|
7 | 7 |
|
8 | 8 | export let data; |
9 | 9 |
|
10 | | - const bigSForm = superForm(data.bigForm); |
| 10 | + const bigSForm = superForm(data.bigForm, { taintedMessage: null }); |
11 | 11 | const bigForm = bigSForm.form; |
12 | | - $bigForm.full_name = |
13 | | - 'Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr.'; |
| 12 | + const { form } = superForm(data.form, { taintedMessage: null }); |
14 | 13 |
|
15 | | - const { form } = superForm(data.form); |
16 | | -
|
17 | | - $form.full_name = 'Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr.'; |
| 14 | + const name = 'Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr.'; |
| 15 | + $bigForm.full_name = name; |
| 16 | + $form.full_name = name; |
18 | 17 |
|
19 | 18 | /** @type {unknown} */ |
20 | 19 | let someUnknownData; |
21 | 20 | const emptyObject = {}; |
22 | 21 |
|
23 | | - const someObject = { |
24 | | - full_name: 'Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr.' |
25 | | - }; |
26 | 22 | const promiseNeverCameTrue = new Promise((_, reject) => { |
27 | | - setTimeout(() => reject('Rejected'), 5000); |
| 23 | + setTimeout(() => reject(new Error('Broken promise')), 1000); |
28 | 24 | }); |
29 | 25 |
|
30 | 26 | /** @type {() => Promise<unknown>} */ |
|
79 | 75 |
|
80 | 76 | <main class="space-y-4"> |
81 | 77 | <section> |
82 | | - <h4>Super Debug with label</h4> |
83 | | - <p>Label is useful when using multiple instance of SuperDebug.</p> |
84 | | - <SuperDebug label="Sample User" data={$form} /> |
85 | | - </section> |
86 | | - <section> |
87 | | - <h4>Super Debug without status</h4> |
88 | | - <SuperDebug label="Sample User" status={false} data={$form} /> |
| 78 | + <h3>SuperDebug demonstrations</h3> |
| 79 | + <b>Change name: <input bind:value={$form.full_name} /></b> |
89 | 80 | </section> |
90 | 81 | <section> |
91 | | - <h4>Super Debug without label</h4> |
| 82 | + <h4>SuperDebug without label</h4> |
92 | 83 | <p> |
93 | 84 | This is SuperDebug's classic layout. Make sure we don't have weird |
94 | 85 | spaces when there is no label. |
95 | 86 | </p> |
96 | 87 | <SuperDebug data={$form} /> |
97 | 88 | </section> |
98 | 89 | <section> |
99 | | - <h4>Super Debug without label and status</h4> |
| 90 | + <h4>SuperDebug with label</h4> |
| 91 | + <p>Label is useful when using multiple instance of SuperDebug.</p> |
| 92 | + <SuperDebug label="Sample User" data={$form} /> |
| 93 | + </section> |
| 94 | + <section> |
| 95 | + <h4>SuperDebug without status</h4> |
| 96 | + <SuperDebug label="Sample User" status={false} data={$form} /> |
| 97 | + </section> |
| 98 | + <section> |
| 99 | + <h4>SuperDebug without label and status</h4> |
100 | 100 | <SuperDebug data={$form} status={false} /> |
101 | 101 | </section> |
102 | 102 | <section> |
103 | | - <h4>Super Debug with label and undefined data</h4> |
| 103 | + <h4>SuperDebug with label and undefined data</h4> |
104 | 104 | <p> |
105 | | - Do not hide output from <code>syntaxHighlight</code> even when the result |
106 | | - is undefined. In JavaScript it is a crucial piece of information. |
| 105 | + Do not hide output when the result is undefined. In JavaScript it is a |
| 106 | + crucial piece of information. |
107 | 107 | </p> |
108 | 108 | <SuperDebug label="Data not ready" data={someUnknownData} /> |
109 | 109 | </section> |
110 | 110 | <section> |
111 | | - <h4>Super Debug without label and undefined data</h4> |
| 111 | + <h4>SuperDebug without label and undefined data</h4> |
112 | 112 | <p> |
113 | 113 | There are cases when the data is not readily available on page load. |
114 | 114 | Make sure SuperDebug layout does not break on itself. |
115 | 115 | </p> |
116 | 116 | <SuperDebug data={someUnknownData} /> |
117 | 117 | </section> |
118 | 118 | <section> |
119 | | - <h4>Super Debug with empty object</h4> |
| 119 | + <h4>SuperDebug with empty object</h4> |
120 | 120 | <SuperDebug data={emptyObject} /> |
121 | 121 | </section> |
122 | 122 | <section class="space-y-4"> |
123 | | - <h4>Super Debug promise support</h4> |
| 123 | + <h4>SuperDebug promise support</h4> |
124 | 124 | <p> |
125 | | - Fancy way of loading things for fancy people. Try reloading the page to |
126 | | - see it in action. Right now when waiting for promise a message that |
127 | | - says "Loading data" appears. Having a named slot for customization is |
128 | | - nice but it is trivial. |
| 125 | + To see this in action, slightly scroll above near Dummyjson product and |
| 126 | + hit refresh. |
129 | 127 | </p> |
130 | | - <pre><code |
131 | | - >{@html `let promiseNeverCameTrue = new Promise((resolve, reject) => { |
132 | | - setTimeout(() => resolve({}), 5000) |
133 | | -})`} |
134 | | -{@html '<SuperDebug promise={true} data={promiseNeverCameTrue} />'}</code |
135 | | - ></pre> |
136 | | - <SuperDebug promise={true} data={promiseNeverCameTrue} /> |
137 | 128 | <pre><code |
138 | 129 | >{@html `let promiseProduct = async () => { |
139 | 130 | const response = await fetch('https://dummyjson.com/products/1') |
140 | 131 | const body = await response.json() |
141 | 132 | return body |
142 | 133 | }`} |
143 | | -{@html `<SuperDebug label="Dummyjson product" promise={true} data={promiseProduct()} />`}</code |
| 134 | +{@html `<SuperDebug label="Dummyjson product" data={promiseProduct()} />`}</code |
144 | 135 | ></pre> |
145 | 136 | <SuperDebug |
146 | 137 | label="Dummyjson product" |
147 | 138 | promise={true} |
148 | 139 | data={promiseProduct()} |
149 | 140 | /> |
150 | | - </section> |
151 | | - <section class="space-y-4"> |
152 | | - <h4>Super Debug using promise on non-promise related data</h4> |
153 | | - <p> |
154 | | - To see this in action, slightly scroll above near Dummyjson product and |
155 | | - hit refresh. |
156 | | - </p> |
157 | | - <ul style="list-style-type: none;"> |
158 | | - <li> |
159 | | - ChadDev: <b |
160 | | - >No one can stop me from enabling promise because I can't read.</b |
161 | | - > |
162 | | - </li> |
163 | | - <li>SuperForm: Hey, that's illegal!</li> |
164 | | - <li>ChadDev: It works!</li> |
165 | | - </ul> |
166 | | - <SuperDebug label="Promisify $form" promise={true} data={someObject} /> |
| 141 | + <pre><code |
| 142 | + >{@html `let promiseNeverCameTrue = new Promise((resolve, reject) => { |
| 143 | + setTimeout(() => resolve({}), 5000) |
| 144 | +})`} |
| 145 | +{@html '<SuperDebug data={promiseNeverCameTrue} />'}</code |
| 146 | + ></pre> |
| 147 | + <h4>SuperDebug rejected promises</h4> |
| 148 | + <p>To see this in action, hit refresh. The promise is rejected with</p> |
| 149 | + <pre><code>new Error("Broken promise")</code></pre> |
| 150 | + |
| 151 | + <SuperDebug data={promiseNeverCameTrue} /> |
167 | 152 | </section> |
168 | 153 | <section> |
169 | | - <h4>Super Debug displaying $page data</h4> |
| 154 | + <h4>SuperDebug displaying $page data</h4> |
170 | 155 | <p>Svelte's <code>$page</code> data in all its glory.</p> |
171 | 156 | <SuperDebug label="$page data" data={$page} /> |
172 | 157 | </section> |
173 | 158 |
|
174 | 159 | <section> |
175 | | - <h4>Super Debug loves stores</h4> |
| 160 | + <h4>SuperDebug loves stores</h4> |
176 | 161 | <p>Why not to pass a store directly.</p> |
177 | 162 | <label for="form_full_name"> |
178 | 163 | <span>Full Name</span> |
|
195 | 180 | </section> |
196 | 181 |
|
197 | 182 | <section> |
198 | | - <h4>Super Debug loves stores x2</h4> |
| 183 | + <h4>SuperDebug loves stores x2</h4> |
199 | 184 | <p>Does superform handle stores of promises?, Yep its cool.</p> |
200 | 185 | <SuperDebug data={promiseStore} label="Store of promises" /> |
201 | 186 | </section> |
202 | 187 |
|
203 | 188 | <section> |
204 | | - <h4>Super Debug custom styling 😎</h4> |
| 189 | + <h4>SuperDebug custom styling 😎</h4> |
205 | 190 | <p>Bugs are easier to solve if they look familiar.</p> |
206 | 191 | <SuperDebug data={$form} label="VS Code like theme" theme="vscode" /> |
207 | 192 | <p |
|
0 commit comments