-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnot-found.component.tsx
432 lines (386 loc) · 14.1 KB
/
not-found.component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/* eslint-disable prefer-rest-params */
// https://www.fatalerrors.org/a/embrace-the-jsx-syntax-of-vue-3-series.html
// https://programming.vip/docs/vue-3-props-emit-slot-render-jsx-and-createelement.html
import './not-found.scss';
import {
defineComponent,
onMounted,
ref,
h,
withScopeId,
KeepAlive,
setBlockTracking,
withMemo,
withDirectives as _withDirectives,
resolveDirective,
isVNode,
openBlock
} from 'vue';
import styles from './not-found.styles.scss';
import { RouterLink } from 'vue-router';
import { Header } from '../../shared/components/header/header.component';
import { Gif404 } from '../../shared/components/gif-404/gif-404.component';
import { TextField } from '@/app/shared/components/text-field/text-field.component';
import type { TextFieldRef } from '@/app/shared/components/text-field/text-field.ref';
import { Modifier } from '@/app/shared/utils/modifiers';
// import { withModifiers } from '@/app/shared/utils/with-modifiers';
import { nameOf } from '@/app/shared/utils/name-of';
import { callTernary } from '@/app/shared/utils/call-ternary';
import { generateGuid } from '@/app/shared/utils/guid';
import { Govno } from '@/app/shared/components/gif-404';
import emojiBlinkLeftIcon from './images/emoji-blink-left.icon.svg';
import EmojiBlinkLeftIcon from './images/emoji-blink-left.icon.svg?inline';
import { vFocusDirective } from '@/app/shared/directives/v-focus.directive';
import { vFontDirective } from '@/app/shared/directives/v-font.directive';
import { useForwardRef } from '@/app/shared/composables/use-forward-ref.composable';
import { withDirectives } from '@/app/shared/utils/with-directives';
import { withRenderOnce } from '@/app/shared/utils/with-render-once';
/**
* Writing Vue.js Render Functions in JSX
* https://alligator.io/vuejs/jsx-render-functions/
*/
export const NotFound = defineComponent({
name: 'NotFound',
components: {
// Gif404,
// Header,
// TextField
},
setup(props, context) {
const title = 'Not found page!';
const isGif404Visible = ref(true);
const isRed = true;
const componentId = generateGuid();
const withId = withScopeId(componentId);
const textFieldValue = ref('');
const textFieldValueNumber = ref(0);
const textFieldRef = ref<TextFieldRef>();
const inputRef = ref();
// console.log('context:', context);
const counter = ref(0);
onMounted(() => {
console.log('"TextField" ref value:', textFieldRef.value?.deepObj);
// console.log('input ref value:', inputRef.value);
});
const trimModifier = 'trim';
const s = () => {
console.log('sssssssssss');
};
return {
isGif404Visible,
textFieldValue,
textFieldValueNumber,
textFieldRef,
trimModifier,
inputRef,
s,
counter
};
},
// @ts-ignore
render(ctx, cache, props, setup, data, options) {
// const { } = this;
this;
const trimModifier = 'trim';
const directiveFocus = resolveDirective('focus');
// console.log('"args" of "not-found" component:', arguments);
return (
<div>
{/* <div class="gif404"> */}
<div>
<img src={emojiBlinkLeftIcon} alt="EmojiBlinkLeftIcon." />
<hr />
<div class={styles.emojiBlinkLeftIconContainer} />
<hr />
<EmojiBlinkLeftIcon />
</div>
<form
// {...withModifiers(
// {
// onSubmit: (e) => {
// console.log(e);
// this.s();
// }
// },
// [Modifier.Event.Prevent, Modifier.Event.Once]
// )}
style={{ border: '2px solid green' }}
>
{withDirectives(
<input
// @ts-ignore
// v-focus
placeholder="some shit info"
type="text"
/>,
// [vFocusDirective.use()]
[]
)}
<button type="submit">submit from</button>
</form>
<div>
<>
<fieldset>
<label>aduadaud</label>
<div>
{this.textFieldRef !== undefined && (
<pre>
{JSON.stringify(this.textFieldRef.deepObj, null, 2)}
</pre>
)}
</div>
{/* {withDirectives(
<input
class={1}
about="aduadaud"
type="text"
v-model={[this.textFieldValue, ['trim']]}
ref="inputRef"
/>,
[vFocusDirective.use()]
)} */}
{/* <input
// // @ts-ignore
// v-focus
class={1}
about="aduadaud"
type="text"
// // @ts-ignore
// vModel={[this.textFieldValue, ['trim']]}
v-model={[this.textFieldValue, ['trim']]}
ref="inputRef"
/> */}
</fieldset>
</>
<>
{/* https://sfc.vuejs.org/#__DEV__eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcblxuY29uc3QgbXNnID0gcmVmKCdIZWxsbyBXb3JsZCEnKVxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGgxPnt7IG1zZyB9fTwvaDE+XG4gIDxpbnB1dCB2LW1vZGVsPVwibXNnXCI+XG48L3RlbXBsYXRlPiIsImltcG9ydC1tYXAuanNvbiI6IntcbiAgXCJpbXBvcnRzXCI6IHtcbiAgICBcInZ1ZVwiOiBcImh0dHBzOi8vc2ZjLnZ1ZWpzLm9yZy92dWUucnVudGltZS5lc20tYnJvd3Nlci5qc1wiLFxuICAgIFwidnVlL3NlcnZlci1yZW5kZXJlclwiOiBcImh0dHBzOi8vc2ZjLnZ1ZWpzLm9yZy9zZXJ2ZXItcmVuZGVyZXIuZXNtLWJyb3dzZXIuanNcIlxuICB9XG59In0= */}
{/* https://vue-next-jsx-explorer.netlify.app/#const%20App%20%3D%20()%20%3D%3E%20%3Cdiv%3E%0A%3Cspan%3EHello%20World%3C%2Fspan%3E%0A%3Cdiv%20onClickSelf%3D%7B()%20%3D%3E%20alert(1111)%7D%3E1231231%3C%2Fdiv%3E%0A%3C%2Fdiv%3E */}
{/* https://vue-next-template-explorer.netlify.app/#%7B%22src%22%3A%22%3Cdiv%20class%3D%5C%22counter%5C%22%3E%5Cn%20%20%3Cspan%3E%7B%7B%20count%20%7D%7D%3C%2Fspan%3E%5Cn%20%20%3Cbutton%20%40click.stop%3D%5C%22increment%5C%22%3E%2B%3C%2Fbutton%3E%5Cn%3C%2Fdiv%3E%5Cn%22%2C%22options%22%3A%7B%22mode%22%3A%22module%22%2C%22filename%22%3A%22Foo.vue%22%2C%22prefixIdentifiers%22%3Afalse%2C%22hoistStatic%22%3Afalse%2C%22cacheHandlers%22%3Afalse%2C%22scopeId%22%3Anull%2C%22inline%22%3Afalse%2C%22ssrCssVars%22%3A%22%7B%20color%20%7D%22%2C%22compatConfig%22%3A%7B%22MODE%22%3A3%7D%2C%22whitespace%22%3A%22condense%22%2C%22bindingMetadata%22%3A%7B%22TestComponent%22%3A%22setup-const%22%2C%22setupRef%22%3A%22setup-ref%22%2C%22setupConst%22%3A%22setup-const%22%2C%22setupLet%22%3A%22setup-let%22%2C%22setupMaybeRef%22%3A%22setup-maybe-ref%22%2C%22setupProp%22%3A%22props%22%2C%22vMySetupDir%22%3A%22setup-const%22%7D%7D%7D */}
{/* https://v3.vuejs.org/guide/events.html#event-modifiers */}
{/* https://stackoverflow.com/questions/51198226/vue-v-onclick-native-in-jsx */}
{/* https://github.com/michitaro/vue-menu/issues/20 */}
{/* https://github.com/vuejs/vue-next/blob/2937530beff5c6bb57286c2556307859e37aa809/packages/compiler-core/src/ast.ts#L426 */}
{/* https://v3.vuejs.org/api/global-api.html#withdirectives */}
{withDirectives(
<TextField
// @ts-ignore
contenteditable={true}
// v-show={true}
class="TextField"
style={{ padding: '10px' }}
aria-hidden={false}
v-model={[this.textFieldValue, ['trim', 'capitalize']]}
// ref={(el: any) => {
// console.log(1231313132, el);
// }}
// ref={this.textFieldFunctionRef as any}
color="white"
ref={nameOf(() => this.textFieldRef)}
data-true={true}
data-string="''"
data-number={1}
onClick={() => {
//
}}
v-slots={{
label: () => 'This is "TextField" label'
// text: () => 1
}}
label={{
'aria-label': 'label',
class: 'TextField__Label'
}}
input={{
'aria-label': 'input',
class: 'TextField__Input',
onInput: () => {
console.log('TextField onInput');
}
}}
/>,
[vFocusDirective.use()]
// []
)}
{/* <TextField
class="TextField"
label="Text Field Label"
v-model={[this.textFieldValue, ['trim', 'capitalize']]}
ref={nameOf(() => this.textFieldRef)}
// ref={this.textFieldFunctionalRef}
/> */}
</>
{/* <div>textFieldRef: {`${this.textFieldRef}`}</div> */}
<div>nameOf "textFieldValue": {nameOf(() => this.textFieldRef)}</div>
<div>textFieldValue: {this.textFieldValue}</div>
</div>
<hr />
{/* =================================================================================== */}
<>
{/* "KeepAlive" component does not work with "v-slots" directive */}
<KeepAlive
v-slots={{
default: () => (
<RouterLink to="/">
<h2>to home!</h2>
</RouterLink>
)
}}
/>
</>
{/* =================================================================================== */}
<KeepAlive>
<RouterLink
to="/"
v-slots={{
default: (args) => {
// console.log('"RouterLink" args:', args);
return withDirectives(<h2>to home!</h2>, [
vFontDirective.use({
value: 60,
modifiers: {
oblique: true
}
})
]);
}
}}
/>
</KeepAlive>
<br />
{cache[0] ||
(setBlockTracking(-1),
(cache[0] = (
<div>
<div>
counter: <b>{this.counter}</b> is{' '}
{callTernary({
condition: this.counter % 2 === 0,
onTruthy: () => 'even number!',
onFalsy: () => 'odd number!'
})}
</div>
<button type="button" onClick={() => this.counter++}>
counter + 1
</button>
</div>
)),
setBlockTracking(1),
cache[0])}
{/* {renderOnce(
cache,
0,
<div>
<div>
counter: <b>{this.counter}</b> is{' '}
{callTernary({
condition: this.counter % 2 === 0,
onTruthy: () => 'even number!',
onFalsy: () => 'odd number!'
})}
</div>
<button type="button" onClick={() => this.counter++}>
counter + 1
</button>
</div>
)} */}
<Header title="t45672" />
{/* https://v3.vuejs.org/api/global-api.html#resolvecomponent */}
{/* https://v3.vuejs.org/api/built-in-components.html#component */}
{/* https://github.com/vuejs/babel-plugin-jsx/issues/161 */}
{/* https://liujiangblog.com/course/Vue3/307 */}
{h(Header, { title: '000000' })}
<br />
<Gif404
onClick={(e) => {
console.log(e);
}}
style={{ color: 'red', border: '2px solid green' }}
class="121212112"
text="This is title!"
v-slots={{
default: () => 'hfsjhfskfhs72t3aud',
header: ({ headerTitle, someShittyText }) => (
<div>
<div>
title that came from "header" slot: <b>{headerTitle}</b>
</div>
<div>
Some Shitty Text: <b>{someShittyText}</b>
</div>
</div>
),
footer: (t) => [4444, 2, t]
}}
/>
<hr />
{/* ========================================================= */}
{/* {cache[1] ||
(setBlockTracking(-1),
(cache[1] = (
<Govno.Gif404 text="123131313" class="3434343343" title="11" />
)),
setBlockTracking(1),
cache[1])} */}
{withRenderOnce(
() => (
<Govno.Gif404 text="123131313" class="3434343343" title="11" />
),
cache,
1
)}
{/* ========================================================= */}
<button
type="button"
onClick={() => (this.isGif404Visible = !this.isGif404Visible)}
>
show/hide
</button>
<hr />
{withMemo(
[],
() => (
<div>
<div>
counter: <b>{this.counter}</b> is{' '}
{callTernary({
condition: this.counter % 2 === 0,
onTruthy: () => 'even number!',
onFalsy: () => 'odd number!'
})}
</div>
<button type="button" onClick={() => this.counter++}>
counter + 1
</button>
</div>
),
cache,
2
)}
{withRenderOnce(
() => (
<div>
<div>
counter: <b>{this.counter}</b> is{' '}
{callTernary({
condition: this.counter % 2 === 0,
onTruthy: () => 'even number!',
onFalsy: () => 'odd number!'
})}
</div>
<button type="button" onClick={() => this.counter++}>
counter + 1
</button>
</div>
),
cache,
3
)}
</div>
);
}
});
NotFound.directives = {
...vFocusDirective.register(),
...vFontDirective.register()
};
export default NotFound;