-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.svelte
178 lines (132 loc) · 5.2 KB
/
main.svelte
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
<script>
export let OLSKCollectionSortFunction;
export let _OLSKCollectionDispatchKey;
export let OLSKCollectionChunkFunction = null;
export let OLSKCollectionChunkKeySortFunction = null;
export let OLSKCollectionItemClass = '';
export let OLSKNarrowFilterText;
export let OLSKCollectionItems;
export let OLSKCollectionItemsLocus = null;
export let OLSKCollectionItemAccessibilitySummaryFunction;
export let OLSKCollectionDispatchClick;
export let OLSKCollectionDispatchArrow;
export let OLSKCollectionDispatchStash = null;
export let OLSKNarrowDispatchFilter;
export let OLSKNarrowDispatchSubmit = null;
export let OLSKMobileViewInactive = false;
export let OLSKNarrowClass = '';
export let OLSKNarrowFilterFieldClass = '';
export let OLSKNarrowFilterFieldPlaceholderText = '';
export let OLSKNarrowFilterFieldClearButton = true;
export let OLSKNarrowFilterFieldAutofocus = false;
import { OLSKLocalized } from 'OLSKInternational';
import { OLSK_SPEC_UI } from 'OLSKSpec';
export const modPublic = {};
const mod = {
// VALUE
_ValueFilterFieldFocused: false,
// DATA
DataIsFocused () {
return document.activeElement === document.querySelector('.OLSKNarrowFilterField');
},
DataIsMobile () {
return window.innerWidth <= 760;
},
// INTERFACE
InterfaceFilterFieldDidInput (event) {
OLSKNarrowDispatchFilter(this.value);
},
InterfaceFormDidSubmit (event) {
event.preventDefault();
OLSKNarrowDispatchSubmit && OLSKNarrowDispatchSubmit();
},
// MESSAGE
OLSKInputWrapperDispatchClear () {
OLSKNarrowDispatchFilter('');
},
// SETUP
SetupEverything () {
mod.SetupFilterFieldEventListeners();
},
SetupFilterFieldEventListeners () {
document.querySelector('.OLSKNarrowFilterField').addEventListener('focus', function () {
mod._ValueFilterFieldFocused = true;
});
document.querySelector('.OLSKNarrowFilterField').addEventListener('blur', function () {
mod._ValueFilterFieldFocused = false;
});
},
// LIFECYCLE
LifecycleComponentDidMount () {
mod.SetupEverything();
},
LifecycleComponentDidUpdate () {
if (OLSK_SPEC_UI()) {
return;
}
if (mod.DataIsMobile()) {
return;
}
const element = document.querySelector('.OLSKCollectionItemLocus');
if (!element) {
return;
}
element.scrollIntoView({
block: 'nearest',
inline: 'nearest',
});
},
};
import { onMount } from 'svelte';
onMount(mod.LifecycleComponentDidMount);
import { afterUpdate } from 'svelte';
afterUpdate(mod.LifecycleComponentDidUpdate);
import OLSKInputWrapper from 'OLSKInputWrapper';
import OLSKCollection from 'OLSKCollection';
</script>
<div class="OLSKNarrow OLSKViewportMaster OLSKCommonEdgeRight { OLSKNarrowClass }" class:OLSKMobileViewInactive={ OLSKMobileViewInactive } class:OLSKNarrowFocused={ mod._ValueFilterFieldFocused } aria-hidden={ OLSKMobileViewInactive ? true : null }>
<header class="OLSKNarrowToolbar OLSKMobileViewHeader OLSKToolbar OLSKCommonEdgeBottom">
<slot name="OLSKNarrowToolbarHead"></slot>
{#if OLSKNarrowFilterFieldClearButton }
<form class="OLSKNarrowForm OLSKToolbarFlexible" on:submit={ mod.InterfaceFormDidSubmit }>
<OLSKInputWrapper OLSKInputWrapperValue={ OLSKNarrowFilterFieldClearButton ? OLSKNarrowFilterText : '' } OLSKInputWrapperDispatchClear={ mod.OLSKInputWrapperDispatchClear } >
<input class="OLSKNarrowFilterField { OLSKNarrowFilterFieldClass } OLSKDecorInput" placeholder={ OLSKNarrowFilterFieldPlaceholderText || OLSKLocalized('OLSKNarrowFilterFieldText') } autofocus={ OLSKNarrowFilterFieldAutofocus } bind:value={ OLSKNarrowFilterText } on:input={ mod.InterfaceFilterFieldDidInput } />
</OLSKInputWrapper>
</form>
{:else}
<input class="OLSKNarrowFilterField { OLSKNarrowFilterFieldClass } OLSKDecorInput" placeholder={ OLSKNarrowFilterFieldPlaceholderText || OLSKLocalized('OLSKNarrowFilterFieldText') } autofocus={ OLSKNarrowFilterFieldAutofocus } bind:value={ OLSKNarrowFilterText } on:input={ mod.InterfaceFilterFieldDidInput } />
{/if}
<slot name="OLSKNarrowToolbarTail"></slot>
</header>
<section class="OLSKNarrowBody">
<slot></slot>
<OLSKCollection
bind:this={ modPublic._OLSKCollection }
OLSKCollectionItems={ OLSKCollectionItems }
OLSKCollectionItemsLocus={ OLSKCollectionItemsLocus }
OLSKCollectionIgnoreKeyboard={ !mod.DataIsFocused() }
OLSKCollectionItemClass={ OLSKCollectionItemClass }
OLSKCollectionSortFunction={ OLSKCollectionSortFunction }
_OLSKCollectionDispatchKey={ _OLSKCollectionDispatchKey }
OLSKCollectionChunkFunction={ OLSKCollectionChunkFunction }
OLSKCollectionChunkKeySortFunction={ OLSKCollectionChunkKeySortFunction }
OLSKCollectionItemAccessibilitySummaryFunction={ OLSKCollectionItemAccessibilitySummaryFunction }
OLSKCollectionDispatchClick={ OLSKCollectionDispatchClick }
OLSKCollectionDispatchArrow={ OLSKCollectionDispatchArrow }
OLSKCollectionDispatchStash={ OLSKCollectionDispatchStash }
let:OLSKCollectionItem={ item }
>
<div slot="OLSKCollectionItem">
{#if $$slots.OLSKCollectionItem}
<slot name="OLSKCollectionItem" OLSKCollectionItem={ item }></slot>
{/if}
</div>
<div slot="OLSKCollectionEmpty">
{#if $$slots.OLSKCollectionEmpty}
<slot name="OLSKCollectionEmpty"></slot>
{/if}
</div>
</OLSKCollection>
<slot name="OLSKNarrowBodyTail"></slot>
</section>
</div>