@novely/dynamic-character 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -37
- package/dist/actions.d.ts +7 -0
- package/dist/components/Picker.d.ts +19 -0
- package/dist/components/Slider.d.ts +12 -0
- package/dist/emotions.d.ts +1 -1
- package/dist/index.css +10 -26
- package/dist/index.d.ts +1 -6
- package/dist/index.jsx +332 -1293
- package/dist/picker.d.ts +2 -2
- package/dist/show.d.ts +2 -2
- package/dist/types.d.ts +65 -20
- package/dist/utils.d.ts +2 -1
- package/package.json +3 -3
- package/dist/slider.d.ts +0 -3
package/dist/index.jsx
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
// src/utils.ts
|
|
2
|
+
var once = (fn) => {
|
|
3
|
+
let called = false;
|
|
4
|
+
return () => {
|
|
5
|
+
if (!called) {
|
|
6
|
+
called = true;
|
|
7
|
+
fn();
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
2
11
|
var getEntries = (object) => {
|
|
3
12
|
return Object.entries(object);
|
|
4
13
|
};
|
|
@@ -49,1321 +58,287 @@ var saveEmotion = (state, character, emotion) => {
|
|
|
49
58
|
state({ [`$$emotion_${character}`]: emotion });
|
|
50
59
|
};
|
|
51
60
|
|
|
52
|
-
// src/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
attributes
|
|
56
|
-
}) => {
|
|
57
|
-
const emotions = {};
|
|
58
|
-
const combineBaseWithAttributes = (baseEmotion, baseAssets, currentAttributes, attributesLeft) => {
|
|
59
|
-
if (attributesLeft.length === 0) {
|
|
60
|
-
const key = `${baseEmotion}@${currentAttributes.join("__")}`;
|
|
61
|
-
emotions[key] = baseAssets;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const [attribute, variants] = attributesLeft[0];
|
|
65
|
-
const remainingAttributes = attributesLeft.slice(1);
|
|
66
|
-
for (const [variant, emotions2] of Object.entries(variants)) {
|
|
67
|
-
const attributeAssets = emotions2[baseEmotion];
|
|
68
|
-
combineBaseWithAttributes(
|
|
69
|
-
baseEmotion,
|
|
70
|
-
[...baseAssets, ...toArray(attributeAssets)],
|
|
71
|
-
[...currentAttributes, `${attribute}_${variant}`],
|
|
72
|
-
remainingAttributes
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
for (const [baseEmotion, baseAssets] of getEntries(base)) {
|
|
77
|
-
for (const _permutation of permutation(getEntries(attributes))) {
|
|
78
|
-
combineBaseWithAttributes(baseEmotion, toArray(baseAssets), [], _permutation);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const clothingData = {
|
|
82
|
-
base: getKeys(base),
|
|
83
|
-
attributes: Object.fromEntries(getEntries(attributes).map(([name, value]) => [name, getKeys(value)]))
|
|
84
|
-
};
|
|
85
|
-
return {
|
|
86
|
-
emotions,
|
|
87
|
-
clothingData
|
|
88
|
-
};
|
|
89
|
-
};
|
|
61
|
+
// src/picker.ts
|
|
62
|
+
import { createComponent } from "solid-js";
|
|
63
|
+
import { render } from "solid-js/web";
|
|
90
64
|
|
|
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
|
-
var equalFn = (a, b) => a === b;
|
|
119
|
-
var $PROXY = Symbol("solid-proxy");
|
|
120
|
-
var $TRACK = Symbol("solid-track");
|
|
121
|
-
var $DEVCOMP = Symbol("solid-dev-component");
|
|
122
|
-
var signalOptions = {
|
|
123
|
-
equals: equalFn
|
|
124
|
-
};
|
|
125
|
-
var ERROR = null;
|
|
126
|
-
var runEffects = runQueue;
|
|
127
|
-
var STALE = 1;
|
|
128
|
-
var PENDING = 2;
|
|
129
|
-
var UNOWNED = {
|
|
130
|
-
owned: null,
|
|
131
|
-
cleanups: null,
|
|
132
|
-
context: null,
|
|
133
|
-
owner: null
|
|
134
|
-
};
|
|
135
|
-
var Owner = null;
|
|
136
|
-
var Transition = null;
|
|
137
|
-
var Scheduler = null;
|
|
138
|
-
var ExternalSourceConfig = null;
|
|
139
|
-
var Listener = null;
|
|
140
|
-
var Updates = null;
|
|
141
|
-
var Effects = null;
|
|
142
|
-
var ExecCount = 0;
|
|
143
|
-
function createRoot(fn, detachedOwner) {
|
|
144
|
-
const listener = Listener, owner = Owner, unowned = fn.length === 0, current = detachedOwner === void 0 ? owner : detachedOwner, root = unowned ? UNOWNED : {
|
|
145
|
-
owned: null,
|
|
146
|
-
cleanups: null,
|
|
147
|
-
context: current ? current.context : null,
|
|
148
|
-
owner: current
|
|
149
|
-
}, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
150
|
-
Owner = root;
|
|
151
|
-
Listener = null;
|
|
152
|
-
try {
|
|
153
|
-
return runUpdates(updateFn, true);
|
|
154
|
-
} finally {
|
|
155
|
-
Listener = listener;
|
|
156
|
-
Owner = owner;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function createSignal(value, options) {
|
|
160
|
-
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
161
|
-
const s = {
|
|
162
|
-
value,
|
|
163
|
-
observers: null,
|
|
164
|
-
observerSlots: null,
|
|
165
|
-
comparator: options.equals || void 0
|
|
166
|
-
};
|
|
167
|
-
const setter = (value2) => {
|
|
168
|
-
if (typeof value2 === "function") {
|
|
169
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value2 = value2(s.tValue);
|
|
170
|
-
else value2 = value2(s.value);
|
|
171
|
-
}
|
|
172
|
-
return writeSignal(s, value2);
|
|
173
|
-
};
|
|
174
|
-
return [readSignal.bind(s), setter];
|
|
175
|
-
}
|
|
176
|
-
function createRenderEffect(fn, value, options) {
|
|
177
|
-
const c = createComputation(fn, value, false, STALE);
|
|
178
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
179
|
-
else updateComputation(c);
|
|
180
|
-
}
|
|
181
|
-
function createEffect(fn, value, options) {
|
|
182
|
-
runEffects = runUserEffects;
|
|
183
|
-
const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
|
|
184
|
-
if (s) c.suspense = s;
|
|
185
|
-
if (!options || !options.render) c.user = true;
|
|
186
|
-
Effects ? Effects.push(c) : updateComputation(c);
|
|
187
|
-
}
|
|
188
|
-
function createMemo(fn, value, options) {
|
|
189
|
-
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
190
|
-
const c = createComputation(fn, value, true, 0);
|
|
191
|
-
c.observers = null;
|
|
192
|
-
c.observerSlots = null;
|
|
193
|
-
c.comparator = options.equals || void 0;
|
|
194
|
-
if (Scheduler && Transition && Transition.running) {
|
|
195
|
-
c.tState = STALE;
|
|
196
|
-
Updates.push(c);
|
|
197
|
-
} else updateComputation(c);
|
|
198
|
-
return readSignal.bind(c);
|
|
199
|
-
}
|
|
200
|
-
function untrack(fn) {
|
|
201
|
-
if (!ExternalSourceConfig && Listener === null) return fn();
|
|
202
|
-
const listener = Listener;
|
|
203
|
-
Listener = null;
|
|
204
|
-
try {
|
|
205
|
-
if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
|
|
206
|
-
return fn();
|
|
207
|
-
} finally {
|
|
208
|
-
Listener = listener;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function onCleanup(fn) {
|
|
212
|
-
if (Owner === null) ;
|
|
213
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
214
|
-
else Owner.cleanups.push(fn);
|
|
215
|
-
return fn;
|
|
216
|
-
}
|
|
217
|
-
function startTransition(fn) {
|
|
218
|
-
if (Transition && Transition.running) {
|
|
219
|
-
fn();
|
|
220
|
-
return Transition.done;
|
|
221
|
-
}
|
|
222
|
-
const l = Listener;
|
|
223
|
-
const o = Owner;
|
|
224
|
-
return Promise.resolve().then(() => {
|
|
225
|
-
Listener = l;
|
|
226
|
-
Owner = o;
|
|
227
|
-
let t;
|
|
228
|
-
if (Scheduler || SuspenseContext) {
|
|
229
|
-
t = Transition || (Transition = {
|
|
230
|
-
sources: /* @__PURE__ */ new Set(),
|
|
231
|
-
effects: [],
|
|
232
|
-
promises: /* @__PURE__ */ new Set(),
|
|
233
|
-
disposed: /* @__PURE__ */ new Set(),
|
|
234
|
-
queue: /* @__PURE__ */ new Set(),
|
|
235
|
-
running: true
|
|
236
|
-
});
|
|
237
|
-
t.done || (t.done = new Promise((res) => t.resolve = res));
|
|
238
|
-
t.running = true;
|
|
239
|
-
}
|
|
240
|
-
runUpdates(fn, false);
|
|
241
|
-
Listener = Owner = null;
|
|
242
|
-
return t ? t.done : void 0;
|
|
65
|
+
// src/components/Picker.tsx
|
|
66
|
+
import { template as _$template2 } from "solid-js/web";
|
|
67
|
+
import { delegateEvents as _$delegateEvents2 } from "solid-js/web";
|
|
68
|
+
import { memo as _$memo } from "solid-js/web";
|
|
69
|
+
import { effect as _$effect2 } from "solid-js/web";
|
|
70
|
+
import { createComponent as _$createComponent2 } from "solid-js/web";
|
|
71
|
+
import { insert as _$insert2 } from "solid-js/web";
|
|
72
|
+
import { createSignal as createSignal2, Show } from "solid-js";
|
|
73
|
+
|
|
74
|
+
// src/components/Slider.tsx
|
|
75
|
+
import { template as _$template } from "solid-js/web";
|
|
76
|
+
import { delegateEvents as _$delegateEvents } from "solid-js/web";
|
|
77
|
+
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
78
|
+
import { effect as _$effect } from "solid-js/web";
|
|
79
|
+
import { insert as _$insert } from "solid-js/web";
|
|
80
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
81
|
+
import { createSignal, createEffect, untrack, createSelector, For } from "solid-js";
|
|
82
|
+
var _tmpl$ = /* @__PURE__ */ _$template(`<div role="region" class="ndc-slider"><div role="group" class="ndc-controls"><button type="button" class="ndc-button-nav ndc-button-nav-prev"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="M165.66 202.34a8 8 0 0 1-11.32 11.32l-80-80a8 8 0 0 1 0-11.32l80-80a8 8 0 0 1 11.32 11.32L91.31 128Z"></path></svg></button><button type="button" class="ndc-button-nav ndc-button-nav-next"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="m181.66 133.66-80 80a8 8 0 0 1-11.32-11.32L164.69 128 90.34 53.66a8 8 0 0 1 11.32-11.32l80 80a8 8 0 0 1 0 11.32Z"></path></svg></button></div><div class="ndc-slides" aria-live="polite">`);
|
|
83
|
+
var _tmpl$2 = /* @__PURE__ */ _$template(`<div role="group" class="ndc-slide">`);
|
|
84
|
+
var Slider = (props) => {
|
|
85
|
+
const [currentSlide, setCurrentSlide] = createSignal(props.initialSlideIndex);
|
|
86
|
+
const isSelected = createSelector(currentSlide);
|
|
87
|
+
createEffect(() => {
|
|
88
|
+
const currentIndex = currentSlide();
|
|
89
|
+
untrack(() => props.onIndexChange(currentIndex));
|
|
243
90
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function readSignal() {
|
|
252
|
-
const runningTransition = Transition && Transition.running;
|
|
253
|
-
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
254
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
255
|
-
else {
|
|
256
|
-
const updates = Updates;
|
|
257
|
-
Updates = null;
|
|
258
|
-
runUpdates(() => lookUpstream(this), false);
|
|
259
|
-
Updates = updates;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (Listener) {
|
|
263
|
-
const sSlot = this.observers ? this.observers.length : 0;
|
|
264
|
-
if (!Listener.sources) {
|
|
265
|
-
Listener.sources = [this];
|
|
266
|
-
Listener.sourceSlots = [sSlot];
|
|
267
|
-
} else {
|
|
268
|
-
Listener.sources.push(this);
|
|
269
|
-
Listener.sourceSlots.push(sSlot);
|
|
270
|
-
}
|
|
271
|
-
if (!this.observers) {
|
|
272
|
-
this.observers = [Listener];
|
|
273
|
-
this.observerSlots = [Listener.sources.length - 1];
|
|
274
|
-
} else {
|
|
275
|
-
this.observers.push(Listener);
|
|
276
|
-
this.observerSlots.push(Listener.sources.length - 1);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (runningTransition && Transition.sources.has(this)) return this.tValue;
|
|
280
|
-
return this.value;
|
|
281
|
-
}
|
|
282
|
-
function writeSignal(node, value, isComp) {
|
|
283
|
-
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
284
|
-
if (!node.comparator || !node.comparator(current, value)) {
|
|
285
|
-
if (Transition) {
|
|
286
|
-
const TransitionRunning = Transition.running;
|
|
287
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
288
|
-
Transition.sources.add(node);
|
|
289
|
-
node.tValue = value;
|
|
91
|
+
return (() => {
|
|
92
|
+
const _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$2.nextSibling;
|
|
93
|
+
_el$.$$keydown = (event) => {
|
|
94
|
+
if (event.key === "ArrowLeft") {
|
|
95
|
+
setCurrentSlide((value) => value > 0 ? value - 1 : props.slides.length - 1);
|
|
96
|
+
} else if (event.key === "ArrowRight") {
|
|
97
|
+
setCurrentSlide((value) => value < props.slides.length - 1 ? value + 1 : 0);
|
|
290
98
|
}
|
|
291
|
-
if (!TransitionRunning) node.value = value;
|
|
292
|
-
} else node.value = value;
|
|
293
|
-
if (node.observers && node.observers.length) {
|
|
294
|
-
runUpdates(() => {
|
|
295
|
-
for (let i = 0; i < node.observers.length; i += 1) {
|
|
296
|
-
const o = node.observers[i];
|
|
297
|
-
const TransitionRunning = Transition && Transition.running;
|
|
298
|
-
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
299
|
-
if (TransitionRunning ? !o.tState : !o.state) {
|
|
300
|
-
if (o.pure) Updates.push(o);
|
|
301
|
-
else Effects.push(o);
|
|
302
|
-
if (o.observers) markDownstream(o);
|
|
303
|
-
}
|
|
304
|
-
if (!TransitionRunning) o.state = STALE;
|
|
305
|
-
else o.tState = STALE;
|
|
306
|
-
}
|
|
307
|
-
if (Updates.length > 1e6) {
|
|
308
|
-
Updates = [];
|
|
309
|
-
if (false) ;
|
|
310
|
-
throw new Error();
|
|
311
|
-
}
|
|
312
|
-
}, false);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return value;
|
|
316
|
-
}
|
|
317
|
-
function updateComputation(node) {
|
|
318
|
-
if (!node.fn) return;
|
|
319
|
-
cleanNode(node);
|
|
320
|
-
const time = ExecCount;
|
|
321
|
-
runComputation(
|
|
322
|
-
node,
|
|
323
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
324
|
-
time
|
|
325
|
-
);
|
|
326
|
-
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
327
|
-
queueMicrotask(() => {
|
|
328
|
-
runUpdates(() => {
|
|
329
|
-
Transition && (Transition.running = true);
|
|
330
|
-
Listener = Owner = node;
|
|
331
|
-
runComputation(node, node.tValue, time);
|
|
332
|
-
Listener = Owner = null;
|
|
333
|
-
}, false);
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
function runComputation(node, value, time) {
|
|
338
|
-
let nextValue;
|
|
339
|
-
const owner = Owner, listener = Listener;
|
|
340
|
-
Listener = Owner = node;
|
|
341
|
-
try {
|
|
342
|
-
nextValue = node.fn(value);
|
|
343
|
-
} catch (err) {
|
|
344
|
-
if (node.pure) {
|
|
345
|
-
if (Transition && Transition.running) {
|
|
346
|
-
node.tState = STALE;
|
|
347
|
-
node.tOwned && node.tOwned.forEach(cleanNode);
|
|
348
|
-
node.tOwned = void 0;
|
|
349
|
-
} else {
|
|
350
|
-
node.state = STALE;
|
|
351
|
-
node.owned && node.owned.forEach(cleanNode);
|
|
352
|
-
node.owned = null;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
node.updatedAt = time + 1;
|
|
356
|
-
return handleError(err);
|
|
357
|
-
} finally {
|
|
358
|
-
Listener = listener;
|
|
359
|
-
Owner = owner;
|
|
360
|
-
}
|
|
361
|
-
if (!node.updatedAt || node.updatedAt <= time) {
|
|
362
|
-
if (node.updatedAt != null && "observers" in node) {
|
|
363
|
-
writeSignal(node, nextValue, true);
|
|
364
|
-
} else if (Transition && Transition.running && node.pure) {
|
|
365
|
-
Transition.sources.add(node);
|
|
366
|
-
node.tValue = nextValue;
|
|
367
|
-
} else node.value = nextValue;
|
|
368
|
-
node.updatedAt = time;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function createComputation(fn, init, pure, state = STALE, options) {
|
|
372
|
-
const c = {
|
|
373
|
-
fn,
|
|
374
|
-
state,
|
|
375
|
-
updatedAt: null,
|
|
376
|
-
owned: null,
|
|
377
|
-
sources: null,
|
|
378
|
-
sourceSlots: null,
|
|
379
|
-
cleanups: null,
|
|
380
|
-
value: init,
|
|
381
|
-
owner: Owner,
|
|
382
|
-
context: Owner ? Owner.context : null,
|
|
383
|
-
pure
|
|
384
|
-
};
|
|
385
|
-
if (Transition && Transition.running) {
|
|
386
|
-
c.state = 0;
|
|
387
|
-
c.tState = state;
|
|
388
|
-
}
|
|
389
|
-
if (Owner === null) ;
|
|
390
|
-
else if (Owner !== UNOWNED) {
|
|
391
|
-
if (Transition && Transition.running && Owner.pure) {
|
|
392
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
393
|
-
else Owner.tOwned.push(c);
|
|
394
|
-
} else {
|
|
395
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
396
|
-
else Owner.owned.push(c);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (ExternalSourceConfig && c.fn) {
|
|
400
|
-
const [track, trigger] = createSignal(void 0, {
|
|
401
|
-
equals: false
|
|
402
|
-
});
|
|
403
|
-
const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
|
|
404
|
-
onCleanup(() => ordinary.dispose());
|
|
405
|
-
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
406
|
-
const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
|
|
407
|
-
c.fn = (x) => {
|
|
408
|
-
track();
|
|
409
|
-
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
410
99
|
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const runningTransition = Transition && Transition.running;
|
|
416
|
-
if ((runningTransition ? node.tState : node.state) === 0) return;
|
|
417
|
-
if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
|
|
418
|
-
if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
|
|
419
|
-
const ancestors = [node];
|
|
420
|
-
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
|
|
421
|
-
if (runningTransition && Transition.disposed.has(node)) return;
|
|
422
|
-
if (runningTransition ? node.tState : node.state) ancestors.push(node);
|
|
423
|
-
}
|
|
424
|
-
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
425
|
-
node = ancestors[i];
|
|
426
|
-
if (runningTransition) {
|
|
427
|
-
let top = node, prev = ancestors[i + 1];
|
|
428
|
-
while ((top = top.owner) && top !== prev) {
|
|
429
|
-
if (Transition.disposed.has(top)) return;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if ((runningTransition ? node.tState : node.state) === STALE) {
|
|
433
|
-
updateComputation(node);
|
|
434
|
-
} else if ((runningTransition ? node.tState : node.state) === PENDING) {
|
|
435
|
-
const updates = Updates;
|
|
436
|
-
Updates = null;
|
|
437
|
-
runUpdates(() => lookUpstream(node, ancestors[0]), false);
|
|
438
|
-
Updates = updates;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function runUpdates(fn, init) {
|
|
443
|
-
if (Updates) return fn();
|
|
444
|
-
let wait = false;
|
|
445
|
-
if (!init) Updates = [];
|
|
446
|
-
if (Effects) wait = true;
|
|
447
|
-
else Effects = [];
|
|
448
|
-
ExecCount++;
|
|
449
|
-
try {
|
|
450
|
-
const res = fn();
|
|
451
|
-
completeUpdates(wait);
|
|
452
|
-
return res;
|
|
453
|
-
} catch (err) {
|
|
454
|
-
if (!wait) Effects = null;
|
|
455
|
-
Updates = null;
|
|
456
|
-
handleError(err);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
function completeUpdates(wait) {
|
|
460
|
-
if (Updates) {
|
|
461
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
462
|
-
else runQueue(Updates);
|
|
463
|
-
Updates = null;
|
|
464
|
-
}
|
|
465
|
-
if (wait) return;
|
|
466
|
-
let res;
|
|
467
|
-
if (Transition) {
|
|
468
|
-
if (!Transition.promises.size && !Transition.queue.size) {
|
|
469
|
-
const sources = Transition.sources;
|
|
470
|
-
const disposed = Transition.disposed;
|
|
471
|
-
Effects.push.apply(Effects, Transition.effects);
|
|
472
|
-
res = Transition.resolve;
|
|
473
|
-
for (const e2 of Effects) {
|
|
474
|
-
"tState" in e2 && (e2.state = e2.tState);
|
|
475
|
-
delete e2.tState;
|
|
476
|
-
}
|
|
477
|
-
Transition = null;
|
|
478
|
-
runUpdates(() => {
|
|
479
|
-
for (const d of disposed) cleanNode(d);
|
|
480
|
-
for (const v of sources) {
|
|
481
|
-
v.value = v.tValue;
|
|
482
|
-
if (v.owned) {
|
|
483
|
-
for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]);
|
|
484
|
-
}
|
|
485
|
-
if (v.tOwned) v.owned = v.tOwned;
|
|
486
|
-
delete v.tValue;
|
|
487
|
-
delete v.tOwned;
|
|
488
|
-
v.tState = 0;
|
|
100
|
+
_el$3.$$click = () => {
|
|
101
|
+
setCurrentSlide((slide) => {
|
|
102
|
+
if (slide > 0) {
|
|
103
|
+
return slide - 1;
|
|
489
104
|
}
|
|
490
|
-
|
|
491
|
-
}, false);
|
|
492
|
-
} else if (Transition.running) {
|
|
493
|
-
Transition.running = false;
|
|
494
|
-
Transition.effects.push.apply(Transition.effects, Effects);
|
|
495
|
-
Effects = null;
|
|
496
|
-
setTransPending(true);
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
const e = Effects;
|
|
501
|
-
Effects = null;
|
|
502
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
503
|
-
if (res) res();
|
|
504
|
-
}
|
|
505
|
-
function runQueue(queue) {
|
|
506
|
-
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
507
|
-
}
|
|
508
|
-
function scheduleQueue(queue) {
|
|
509
|
-
for (let i = 0; i < queue.length; i++) {
|
|
510
|
-
const item = queue[i];
|
|
511
|
-
const tasks = Transition.queue;
|
|
512
|
-
if (!tasks.has(item)) {
|
|
513
|
-
tasks.add(item);
|
|
514
|
-
Scheduler(() => {
|
|
515
|
-
tasks.delete(item);
|
|
516
|
-
runUpdates(() => {
|
|
517
|
-
Transition.running = true;
|
|
518
|
-
runTop(item);
|
|
519
|
-
}, false);
|
|
520
|
-
Transition && (Transition.running = false);
|
|
105
|
+
return props.slides.length - 1;
|
|
521
106
|
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
for (i = 0; i < queue.length; i++) {
|
|
528
|
-
const e = queue[i];
|
|
529
|
-
if (!e.user) runTop(e);
|
|
530
|
-
else queue[userLength++] = e;
|
|
531
|
-
}
|
|
532
|
-
if (sharedConfig.context) {
|
|
533
|
-
if (sharedConfig.count) {
|
|
534
|
-
sharedConfig.effects || (sharedConfig.effects = []);
|
|
535
|
-
sharedConfig.effects.push(...queue.slice(0, userLength));
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
setHydrateContext();
|
|
539
|
-
}
|
|
540
|
-
if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
|
|
541
|
-
queue = [...sharedConfig.effects, ...queue];
|
|
542
|
-
userLength += sharedConfig.effects.length;
|
|
543
|
-
delete sharedConfig.effects;
|
|
544
|
-
}
|
|
545
|
-
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
546
|
-
}
|
|
547
|
-
function lookUpstream(node, ignore) {
|
|
548
|
-
const runningTransition = Transition && Transition.running;
|
|
549
|
-
if (runningTransition) node.tState = 0;
|
|
550
|
-
else node.state = 0;
|
|
551
|
-
for (let i = 0; i < node.sources.length; i += 1) {
|
|
552
|
-
const source = node.sources[i];
|
|
553
|
-
if (source.sources) {
|
|
554
|
-
const state = runningTransition ? source.tState : source.state;
|
|
555
|
-
if (state === STALE) {
|
|
556
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
557
|
-
runTop(source);
|
|
558
|
-
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function markDownstream(node) {
|
|
563
|
-
const runningTransition = Transition && Transition.running;
|
|
564
|
-
for (let i = 0; i < node.observers.length; i += 1) {
|
|
565
|
-
const o = node.observers[i];
|
|
566
|
-
if (runningTransition ? !o.tState : !o.state) {
|
|
567
|
-
if (runningTransition) o.tState = PENDING;
|
|
568
|
-
else o.state = PENDING;
|
|
569
|
-
if (o.pure) Updates.push(o);
|
|
570
|
-
else Effects.push(o);
|
|
571
|
-
o.observers && markDownstream(o);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
function cleanNode(node) {
|
|
576
|
-
let i;
|
|
577
|
-
if (node.sources) {
|
|
578
|
-
while (node.sources.length) {
|
|
579
|
-
const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
|
|
580
|
-
if (obs && obs.length) {
|
|
581
|
-
const n = obs.pop(), s = source.observerSlots.pop();
|
|
582
|
-
if (index < obs.length) {
|
|
583
|
-
n.sourceSlots[s] = index;
|
|
584
|
-
obs[index] = n;
|
|
585
|
-
source.observerSlots[index] = s;
|
|
107
|
+
};
|
|
108
|
+
_el$4.$$click = () => {
|
|
109
|
+
setCurrentSlide((slide) => {
|
|
110
|
+
if (slide < props.slides.length - 1) {
|
|
111
|
+
return slide + 1;
|
|
586
112
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
if (Transition && Transition.running && node.pure) {
|
|
595
|
-
reset(node, true);
|
|
596
|
-
} else if (node.owned) {
|
|
597
|
-
for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
|
|
598
|
-
node.owned = null;
|
|
599
|
-
}
|
|
600
|
-
if (node.cleanups) {
|
|
601
|
-
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
602
|
-
node.cleanups = null;
|
|
603
|
-
}
|
|
604
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
605
|
-
else node.state = 0;
|
|
606
|
-
}
|
|
607
|
-
function reset(node, top) {
|
|
608
|
-
if (!top) {
|
|
609
|
-
node.tState = 0;
|
|
610
|
-
Transition.disposed.add(node);
|
|
611
|
-
}
|
|
612
|
-
if (node.owned) {
|
|
613
|
-
for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
function castError(err) {
|
|
617
|
-
if (err instanceof Error) return err;
|
|
618
|
-
return new Error(typeof err === "string" ? err : "Unknown error", {
|
|
619
|
-
cause: err
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
function runErrors(err, fns, owner) {
|
|
623
|
-
try {
|
|
624
|
-
for (const f of fns) f(err);
|
|
625
|
-
} catch (e) {
|
|
626
|
-
handleError(e, owner && owner.owner || null);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
function handleError(err, owner = Owner) {
|
|
630
|
-
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
631
|
-
const error = castError(err);
|
|
632
|
-
if (!fns) throw error;
|
|
633
|
-
if (Effects)
|
|
634
|
-
Effects.push({
|
|
635
|
-
fn() {
|
|
636
|
-
runErrors(error, fns, owner);
|
|
113
|
+
return 0;
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
_$insert(_el$5, _$createComponent(For, {
|
|
117
|
+
get each() {
|
|
118
|
+
return props.slides;
|
|
637
119
|
},
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
function mapArray(list, mapFn, options = {}) {
|
|
647
|
-
let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
|
|
648
|
-
onCleanup(() => dispose(disposers));
|
|
649
|
-
return () => {
|
|
650
|
-
let newItems = list() || [], newLen = newItems.length, i, j;
|
|
651
|
-
newItems[$TRACK];
|
|
652
|
-
return untrack(() => {
|
|
653
|
-
let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
|
|
654
|
-
if (newLen === 0) {
|
|
655
|
-
if (len !== 0) {
|
|
656
|
-
dispose(disposers);
|
|
657
|
-
disposers = [];
|
|
658
|
-
items = [];
|
|
659
|
-
mapped = [];
|
|
660
|
-
len = 0;
|
|
661
|
-
indexes && (indexes = []);
|
|
662
|
-
}
|
|
663
|
-
if (options.fallback) {
|
|
664
|
-
items = [FALLBACK];
|
|
665
|
-
mapped[0] = createRoot((disposer) => {
|
|
666
|
-
disposers[0] = disposer;
|
|
667
|
-
return options.fallback();
|
|
668
|
-
});
|
|
669
|
-
len = 1;
|
|
670
|
-
}
|
|
671
|
-
} else if (len === 0) {
|
|
672
|
-
mapped = new Array(newLen);
|
|
673
|
-
for (j = 0; j < newLen; j++) {
|
|
674
|
-
items[j] = newItems[j];
|
|
675
|
-
mapped[j] = createRoot(mapper);
|
|
676
|
-
}
|
|
677
|
-
len = newLen;
|
|
678
|
-
} else {
|
|
679
|
-
temp = new Array(newLen);
|
|
680
|
-
tempdisposers = new Array(newLen);
|
|
681
|
-
indexes && (tempIndexes = new Array(newLen));
|
|
682
|
-
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++) ;
|
|
683
|
-
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
684
|
-
temp[newEnd] = mapped[end];
|
|
685
|
-
tempdisposers[newEnd] = disposers[end];
|
|
686
|
-
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
687
|
-
}
|
|
688
|
-
newIndices = /* @__PURE__ */ new Map();
|
|
689
|
-
newIndicesNext = new Array(newEnd + 1);
|
|
690
|
-
for (j = newEnd; j >= start; j--) {
|
|
691
|
-
item = newItems[j];
|
|
692
|
-
i = newIndices.get(item);
|
|
693
|
-
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
694
|
-
newIndices.set(item, j);
|
|
695
|
-
}
|
|
696
|
-
for (i = start; i <= end; i++) {
|
|
697
|
-
item = items[i];
|
|
698
|
-
j = newIndices.get(item);
|
|
699
|
-
if (j !== void 0 && j !== -1) {
|
|
700
|
-
temp[j] = mapped[i];
|
|
701
|
-
tempdisposers[j] = disposers[i];
|
|
702
|
-
indexes && (tempIndexes[j] = indexes[i]);
|
|
703
|
-
j = newIndicesNext[j];
|
|
704
|
-
newIndices.set(item, j);
|
|
705
|
-
} else disposers[i]();
|
|
706
|
-
}
|
|
707
|
-
for (j = start; j < newLen; j++) {
|
|
708
|
-
if (j in temp) {
|
|
709
|
-
mapped[j] = temp[j];
|
|
710
|
-
disposers[j] = tempdisposers[j];
|
|
711
|
-
if (indexes) {
|
|
712
|
-
indexes[j] = tempIndexes[j];
|
|
713
|
-
indexes[j](j);
|
|
714
|
-
}
|
|
715
|
-
} else mapped[j] = createRoot(mapper);
|
|
716
|
-
}
|
|
717
|
-
mapped = mapped.slice(0, len = newLen);
|
|
718
|
-
items = newItems.slice(0);
|
|
120
|
+
children: (variant, i) => {
|
|
121
|
+
return (() => {
|
|
122
|
+
const _el$6 = _tmpl$2();
|
|
123
|
+
_$insert(_el$6, () => props.children(variant, i));
|
|
124
|
+
_$effect(() => _el$6.classList.toggle("ndc-slide-active", !!isSelected(i())));
|
|
125
|
+
return _el$6;
|
|
126
|
+
})();
|
|
719
127
|
}
|
|
720
|
-
|
|
128
|
+
}));
|
|
129
|
+
_$effect((_p$) => {
|
|
130
|
+
const _v$ = props.translation.ui.variants, _v$2 = !props.expanded, _v$3 = props.translation.ui.slidesControl, _v$4 = props.translation.ui.prevSlide, _v$5 = props.translation.ui.nextSlide;
|
|
131
|
+
_v$ !== _p$._v$ && _$setAttribute(_el$, "aria-label", _p$._v$ = _v$);
|
|
132
|
+
_v$2 !== _p$._v$2 && _el$.classList.toggle("ndc-slider-picker-collapsed", _p$._v$2 = _v$2);
|
|
133
|
+
_v$3 !== _p$._v$3 && _$setAttribute(_el$2, "aria-label", _p$._v$3 = _v$3);
|
|
134
|
+
_v$4 !== _p$._v$4 && _$setAttribute(_el$3, "aria-label", _p$._v$4 = _v$4);
|
|
135
|
+
_v$5 !== _p$._v$5 && _$setAttribute(_el$4, "aria-label", _p$._v$5 = _v$5);
|
|
136
|
+
return _p$;
|
|
137
|
+
}, {
|
|
138
|
+
_v$: void 0,
|
|
139
|
+
_v$2: void 0,
|
|
140
|
+
_v$3: void 0,
|
|
141
|
+
_v$4: void 0,
|
|
142
|
+
_v$5: void 0
|
|
721
143
|
});
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
indexes[j] = set;
|
|
727
|
-
return mapFn(newItems[j], s);
|
|
728
|
-
}
|
|
729
|
-
return mapFn(newItems[j]);
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
var hydrationEnabled = false;
|
|
734
|
-
function createComponent(Comp, props) {
|
|
735
|
-
if (hydrationEnabled) {
|
|
736
|
-
if (sharedConfig.context) {
|
|
737
|
-
const c = sharedConfig.context;
|
|
738
|
-
setHydrateContext(nextHydrateContext());
|
|
739
|
-
const r = untrack(() => Comp(props || {}));
|
|
740
|
-
setHydrateContext(c);
|
|
741
|
-
return r;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return untrack(() => Comp(props || {}));
|
|
745
|
-
}
|
|
746
|
-
var counter = 0;
|
|
747
|
-
function createUniqueId() {
|
|
748
|
-
const ctx = sharedConfig.context;
|
|
749
|
-
return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
750
|
-
}
|
|
751
|
-
function For(props) {
|
|
752
|
-
const fallback = "fallback" in props && {
|
|
753
|
-
fallback: () => props.fallback
|
|
754
|
-
};
|
|
755
|
-
return createMemo(mapArray(() => props.each, props.children, fallback || void 0));
|
|
756
|
-
}
|
|
144
|
+
return _el$;
|
|
145
|
+
})();
|
|
146
|
+
};
|
|
147
|
+
_$delegateEvents(["keydown", "click"]);
|
|
757
148
|
|
|
758
|
-
//
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (!map) {
|
|
823
|
-
map = /* @__PURE__ */ new Map();
|
|
824
|
-
let i = bStart;
|
|
825
|
-
while (i < bEnd) map.set(b[i], i++);
|
|
826
|
-
}
|
|
827
|
-
const index = map.get(a[aStart]);
|
|
828
|
-
if (index != null) {
|
|
829
|
-
if (bStart < index && index < bEnd) {
|
|
830
|
-
let i = aStart, sequence = 1, t;
|
|
831
|
-
while (++i < aEnd && i < bEnd) {
|
|
832
|
-
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
|
|
833
|
-
sequence++;
|
|
834
|
-
}
|
|
835
|
-
if (sequence > index - bStart) {
|
|
836
|
-
const node = a[aStart];
|
|
837
|
-
while (bStart < index) parentNode.insertBefore(b[bStart++], node);
|
|
838
|
-
} else parentNode.replaceChild(b[bStart++], a[aStart++]);
|
|
839
|
-
} else aStart++;
|
|
840
|
-
} else a[aStart++].remove();
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
var $$EVENTS = "_$DX_DELEGATE";
|
|
845
|
-
function render(code, element, init, options = {}) {
|
|
846
|
-
let disposer;
|
|
847
|
-
createRoot((dispose2) => {
|
|
848
|
-
disposer = dispose2;
|
|
849
|
-
element === document ? code() : insert(element, code(), element.firstChild ? null : void 0, init);
|
|
850
|
-
}, options.owner);
|
|
851
|
-
return () => {
|
|
852
|
-
disposer();
|
|
853
|
-
element.textContent = "";
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
function template(html, isImportNode, isSVG) {
|
|
857
|
-
let node;
|
|
858
|
-
const create = () => {
|
|
859
|
-
const t = document.createElement("template");
|
|
860
|
-
t.innerHTML = html;
|
|
861
|
-
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
862
|
-
};
|
|
863
|
-
const fn = isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
864
|
-
fn.cloneNode = fn;
|
|
865
|
-
return fn;
|
|
866
|
-
}
|
|
867
|
-
function delegateEvents(eventNames, document2 = window.document) {
|
|
868
|
-
const e = document2[$$EVENTS] || (document2[$$EVENTS] = /* @__PURE__ */ new Set());
|
|
869
|
-
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
870
|
-
const name = eventNames[i];
|
|
871
|
-
if (!e.has(name)) {
|
|
872
|
-
e.add(name);
|
|
873
|
-
document2.addEventListener(name, eventHandler);
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
function setAttribute(node, name, value) {
|
|
878
|
-
if (isHydrating(node)) return;
|
|
879
|
-
if (value == null) node.removeAttribute(name);
|
|
880
|
-
else node.setAttribute(name, value);
|
|
881
|
-
}
|
|
882
|
-
function use(fn, element, arg) {
|
|
883
|
-
return untrack(() => fn(element, arg));
|
|
884
|
-
}
|
|
885
|
-
function insert(parent, accessor, marker, initial) {
|
|
886
|
-
if (marker !== void 0 && !initial) initial = [];
|
|
887
|
-
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
888
|
-
createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
|
|
889
|
-
}
|
|
890
|
-
function isHydrating(node) {
|
|
891
|
-
return !!sharedConfig.context && !sharedConfig.done && (!node || node.isConnected);
|
|
892
|
-
}
|
|
893
|
-
function eventHandler(e) {
|
|
894
|
-
if (sharedConfig.registry && sharedConfig.events) {
|
|
895
|
-
if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
896
|
-
}
|
|
897
|
-
let node = e.target;
|
|
898
|
-
const key = `$$${e.type}`;
|
|
899
|
-
const oriTarget = e.target;
|
|
900
|
-
const oriCurrentTarget = e.currentTarget;
|
|
901
|
-
const retarget = (value) => Object.defineProperty(e, "target", {
|
|
902
|
-
configurable: true,
|
|
903
|
-
value
|
|
904
|
-
});
|
|
905
|
-
const handleNode = () => {
|
|
906
|
-
const handler = node[key];
|
|
907
|
-
if (handler && !node.disabled) {
|
|
908
|
-
const data = node[`${key}Data`];
|
|
909
|
-
data !== void 0 ? handler.call(node, data, e) : handler.call(node, e);
|
|
910
|
-
if (e.cancelBubble) return;
|
|
911
|
-
}
|
|
912
|
-
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
|
|
913
|
-
return true;
|
|
914
|
-
};
|
|
915
|
-
const walkUpTree = () => {
|
|
916
|
-
while (handleNode() && (node = node._$host || node.parentNode || node.host)) ;
|
|
917
|
-
};
|
|
918
|
-
Object.defineProperty(e, "currentTarget", {
|
|
919
|
-
configurable: true,
|
|
920
|
-
get() {
|
|
921
|
-
return node || document;
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
|
|
925
|
-
if (e.composedPath) {
|
|
926
|
-
const path = e.composedPath();
|
|
927
|
-
retarget(path[0]);
|
|
928
|
-
for (let i = 0; i < path.length - 2; i++) {
|
|
929
|
-
node = path[i];
|
|
930
|
-
if (!handleNode()) break;
|
|
931
|
-
if (node._$host) {
|
|
932
|
-
node = node._$host;
|
|
933
|
-
walkUpTree();
|
|
934
|
-
break;
|
|
935
|
-
}
|
|
936
|
-
if (node.parentNode === oriCurrentTarget) {
|
|
937
|
-
break;
|
|
149
|
+
// src/components/Picker.tsx
|
|
150
|
+
import pLimit from "p-limit";
|
|
151
|
+
var _tmpl$3 = /* @__PURE__ */ _$template2(`<div class="ndc-picker-root"><button type="button" class="ndc-collapse-button"><svg data-icon fill="#fefefe" width="3rem" height="3rem" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path></svg></button><div class="ndc-heading">`);
|
|
152
|
+
var _tmpl$22 = /* @__PURE__ */ _$template2(`<p class="ndc-variant-name">`);
|
|
153
|
+
var _tmpl$32 = /* @__PURE__ */ _$template2(`<div class="ndc-control-buttons"><button type="button" class="button">`);
|
|
154
|
+
var limitClick = pLimit(1);
|
|
155
|
+
var Picker = (props) => {
|
|
156
|
+
const [expanded, setExpanded] = createSignal2(props.initialExpanded);
|
|
157
|
+
const [appearance, setAppearance] = createSignal2(props.initialEmotion);
|
|
158
|
+
const initialSlideIndex = props.getInitialSlideIndex(appearance());
|
|
159
|
+
return (() => {
|
|
160
|
+
const _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
|
|
161
|
+
_el$2.$$click = () => {
|
|
162
|
+
setExpanded((value) => !value);
|
|
163
|
+
};
|
|
164
|
+
_$insert2(_el$4, () => props.title);
|
|
165
|
+
_$insert2(_el$, _$createComponent2(Slider, {
|
|
166
|
+
get expanded() {
|
|
167
|
+
return expanded();
|
|
168
|
+
},
|
|
169
|
+
initialSlideIndex,
|
|
170
|
+
get slides() {
|
|
171
|
+
return props.slides;
|
|
172
|
+
},
|
|
173
|
+
get translation() {
|
|
174
|
+
return props.translation;
|
|
175
|
+
},
|
|
176
|
+
onIndexChange: (index) => props.onIndexChange(appearance(), setAppearance, index),
|
|
177
|
+
children: (variant, i) => {
|
|
178
|
+
const price = props.pricing[i()];
|
|
179
|
+
const apply = once(() => {
|
|
180
|
+
props.sumbit();
|
|
181
|
+
props.saveEmotion(appearance());
|
|
182
|
+
});
|
|
183
|
+
const onClick = () => {
|
|
184
|
+
limitClick(async () => {
|
|
185
|
+
if (!price || props.isBought(variant)) {
|
|
186
|
+
return apply();
|
|
187
|
+
}
|
|
188
|
+
if (await props.buy(variant)) {
|
|
189
|
+
apply();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
return [(() => {
|
|
194
|
+
const _el$5 = _tmpl$22();
|
|
195
|
+
_$insert2(_el$5, () => props.translationGroup[variant]);
|
|
196
|
+
return _el$5;
|
|
197
|
+
})(), (() => {
|
|
198
|
+
const _el$6 = _tmpl$32(), _el$7 = _el$6.firstChild;
|
|
199
|
+
_el$7.$$click = onClick;
|
|
200
|
+
_$insert2(_el$7, _$createComponent2(Show, {
|
|
201
|
+
get when() {
|
|
202
|
+
return price && !props.isBought(variant);
|
|
203
|
+
},
|
|
204
|
+
get children() {
|
|
205
|
+
return [_$memo(() => props.translation.ui.buy), " ", price];
|
|
206
|
+
},
|
|
207
|
+
get fallback() {
|
|
208
|
+
return props.translation.ui.sumbit;
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
return _el$6;
|
|
212
|
+
})()];
|
|
938
213
|
}
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
if (node.nodeType === 8 && node.data.slice(0, 2) === "!$") node.remove();
|
|
951
|
-
else cleaned.push(node);
|
|
952
|
-
}
|
|
953
|
-
current = cleaned;
|
|
954
|
-
}
|
|
955
|
-
while (typeof current === "function") current = current();
|
|
956
|
-
if (value === current) return current;
|
|
957
|
-
const t = typeof value, multi = marker !== void 0;
|
|
958
|
-
parent = multi && current[0] && current[0].parentNode || parent;
|
|
959
|
-
if (t === "string" || t === "number") {
|
|
960
|
-
if (hydrating) return current;
|
|
961
|
-
if (t === "number") {
|
|
962
|
-
value = value.toString();
|
|
963
|
-
if (value === current) return current;
|
|
964
|
-
}
|
|
965
|
-
if (multi) {
|
|
966
|
-
let node = current[0];
|
|
967
|
-
if (node && node.nodeType === 3) {
|
|
968
|
-
node.data !== value && (node.data = value);
|
|
969
|
-
} else node = document.createTextNode(value);
|
|
970
|
-
current = cleanChildren(parent, current, marker, node);
|
|
971
|
-
} else {
|
|
972
|
-
if (current !== "" && typeof current === "string") {
|
|
973
|
-
current = parent.firstChild.data = value;
|
|
974
|
-
} else current = parent.textContent = value;
|
|
975
|
-
}
|
|
976
|
-
} else if (value == null || t === "boolean") {
|
|
977
|
-
if (hydrating) return current;
|
|
978
|
-
current = cleanChildren(parent, current, marker);
|
|
979
|
-
} else if (t === "function") {
|
|
980
|
-
createRenderEffect(() => {
|
|
981
|
-
let v = value();
|
|
982
|
-
while (typeof v === "function") v = v();
|
|
983
|
-
current = insertExpression(parent, v, current, marker);
|
|
214
|
+
}), null);
|
|
215
|
+
_$effect2((_p$) => {
|
|
216
|
+
const _v$ = !expanded(), _v$2 = !expanded(), _v$3 = !expanded();
|
|
217
|
+
_v$ !== _p$._v$ && _el$.classList.toggle("ndc-picker-root-collapsed", _p$._v$ = _v$);
|
|
218
|
+
_v$2 !== _p$._v$2 && _el$3.classList.toggle("ndc-collapse-button-icon-collapsed", _p$._v$2 = _v$2);
|
|
219
|
+
_v$3 !== _p$._v$3 && _el$4.classList.toggle("ndc-heading-picker-collapsed", _p$._v$3 = _v$3);
|
|
220
|
+
return _p$;
|
|
221
|
+
}, {
|
|
222
|
+
_v$: void 0,
|
|
223
|
+
_v$2: void 0,
|
|
224
|
+
_v$3: void 0
|
|
984
225
|
});
|
|
985
|
-
return
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (normalizeIncomingArray(array, value, current, unwrapArray)) {
|
|
990
|
-
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
991
|
-
return () => current;
|
|
992
|
-
}
|
|
993
|
-
if (hydrating) {
|
|
994
|
-
if (!array.length) return current;
|
|
995
|
-
if (marker === void 0) return current = [...parent.childNodes];
|
|
996
|
-
let node = array[0];
|
|
997
|
-
if (node.parentNode !== parent) return current;
|
|
998
|
-
const nodes = [node];
|
|
999
|
-
while ((node = node.nextSibling) !== marker) nodes.push(node);
|
|
1000
|
-
return current = nodes;
|
|
1001
|
-
}
|
|
1002
|
-
if (array.length === 0) {
|
|
1003
|
-
current = cleanChildren(parent, current, marker);
|
|
1004
|
-
if (multi) return current;
|
|
1005
|
-
} else if (currentArray) {
|
|
1006
|
-
if (current.length === 0) {
|
|
1007
|
-
appendNodes(parent, array, marker);
|
|
1008
|
-
} else reconcileArrays(parent, current, array);
|
|
1009
|
-
} else {
|
|
1010
|
-
current && cleanChildren(parent);
|
|
1011
|
-
appendNodes(parent, array);
|
|
1012
|
-
}
|
|
1013
|
-
current = array;
|
|
1014
|
-
} else if (value.nodeType) {
|
|
1015
|
-
if (hydrating && value.parentNode) return current = multi ? [value] : value;
|
|
1016
|
-
if (Array.isArray(current)) {
|
|
1017
|
-
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
1018
|
-
cleanChildren(parent, current, null, value);
|
|
1019
|
-
} else if (current == null || current === "" || !parent.firstChild) {
|
|
1020
|
-
parent.appendChild(value);
|
|
1021
|
-
} else parent.replaceChild(value, parent.firstChild);
|
|
1022
|
-
current = value;
|
|
1023
|
-
} else ;
|
|
1024
|
-
return current;
|
|
1025
|
-
}
|
|
1026
|
-
function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
1027
|
-
let dynamic = false;
|
|
1028
|
-
for (let i = 0, len = array.length; i < len; i++) {
|
|
1029
|
-
let item = array[i], prev = current && current[normalized.length], t;
|
|
1030
|
-
if (item == null || item === true || item === false) ;
|
|
1031
|
-
else if ((t = typeof item) === "object" && item.nodeType) {
|
|
1032
|
-
normalized.push(item);
|
|
1033
|
-
} else if (Array.isArray(item)) {
|
|
1034
|
-
dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
|
|
1035
|
-
} else if (t === "function") {
|
|
1036
|
-
if (unwrap) {
|
|
1037
|
-
while (typeof item === "function") item = item();
|
|
1038
|
-
dynamic = normalizeIncomingArray(
|
|
1039
|
-
normalized,
|
|
1040
|
-
Array.isArray(item) ? item : [item],
|
|
1041
|
-
Array.isArray(prev) ? prev : [prev]
|
|
1042
|
-
) || dynamic;
|
|
1043
|
-
} else {
|
|
1044
|
-
normalized.push(item);
|
|
1045
|
-
dynamic = true;
|
|
1046
|
-
}
|
|
1047
|
-
} else {
|
|
1048
|
-
const value = String(item);
|
|
1049
|
-
if (prev && prev.nodeType === 3 && prev.data === value) normalized.push(prev);
|
|
1050
|
-
else normalized.push(document.createTextNode(value));
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
return dynamic;
|
|
1054
|
-
}
|
|
1055
|
-
function appendNodes(parent, array, marker = null) {
|
|
1056
|
-
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
1057
|
-
}
|
|
1058
|
-
function cleanChildren(parent, current, marker, replacement) {
|
|
1059
|
-
if (marker === void 0) return parent.textContent = "";
|
|
1060
|
-
const node = replacement || document.createTextNode("");
|
|
1061
|
-
if (current.length) {
|
|
1062
|
-
let inserted = false;
|
|
1063
|
-
for (let i = current.length - 1; i >= 0; i--) {
|
|
1064
|
-
const el = current[i];
|
|
1065
|
-
if (node !== el) {
|
|
1066
|
-
const isParent = el.parentNode === parent;
|
|
1067
|
-
if (!inserted && !i)
|
|
1068
|
-
isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);
|
|
1069
|
-
else isParent && el.remove();
|
|
1070
|
-
} else inserted = true;
|
|
1071
|
-
}
|
|
1072
|
-
} else parent.insertBefore(node, marker);
|
|
1073
|
-
return [node];
|
|
1074
|
-
}
|
|
1075
|
-
var RequestContext = Symbol();
|
|
226
|
+
return _el$;
|
|
227
|
+
})();
|
|
228
|
+
};
|
|
229
|
+
_$delegateEvents2(["click"]);
|
|
1076
230
|
|
|
1077
|
-
// src/picker.
|
|
1078
|
-
import { slidy } from "@slidy/core";
|
|
1079
|
-
var _tmpl$ = /* @__PURE__ */ template(`<div class="ndc-picker-root"><button type="button" class="ndc-collapse-button"><svg data-icon fill="#fefefe" width="3rem" height="3rem" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path></svg></button><div role="tablist" class="ndc-tablist">`);
|
|
1080
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<button role="tab" class="ndc-tab-button">`);
|
|
1081
|
-
var _tmpl$3 = /* @__PURE__ */ template(`<div role="tabpanel" tabindex="0"><div role="region" class="ndc-slider"><div role="group" class="ndc-controls"><button type="button" class="ndc-button-nav ndc-button-nav-prev"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="M165.66 202.34a8 8 0 0 1-11.32 11.32l-80-80a8 8 0 0 1 0-11.32l80-80a8 8 0 0 1 11.32 11.32L91.31 128Z"></path></svg></button><button type="button" class="ndc-button-nav ndc-button-nav-next"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="m181.66 133.66-80 80a8 8 0 0 1-11.32-11.32L164.69 128 90.34 53.66a8 8 0 0 1 11.32-11.32l80 80a8 8 0 0 1 0 11.32Z"></path></svg></button></div><div class="ndc-slides" aria-live="polite">`);
|
|
1082
|
-
var _tmpl$4 = /* @__PURE__ */ template(`<div role="group" class="ndc-slide"><p class="ndc-variant-name"></p><div class="ndc-control-buttons"><button type="button" class="button">`);
|
|
231
|
+
// src/picker.ts
|
|
1083
232
|
var CHARACTER_STYLE_PICKER = Symbol();
|
|
1084
233
|
var PRELOADED_EMOTIONS = /* @__PURE__ */ new Set();
|
|
1085
|
-
var
|
|
1086
|
-
base,
|
|
1087
|
-
attributes,
|
|
1088
|
-
excludeAttributes
|
|
1089
|
-
}) => {
|
|
1090
|
-
const tabs = [];
|
|
1091
|
-
if (base.length >= 2) {
|
|
1092
|
-
tabs.push({
|
|
1093
|
-
type: "base",
|
|
1094
|
-
value: "",
|
|
1095
|
-
tab: createUniqueId(),
|
|
1096
|
-
panel: createUniqueId()
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
const attributesKeys = excludeAttributes ? getKeys(attributes).filter((name) => excludeAttributes.includes(name)) : getKeys(attributes);
|
|
1100
|
-
const attributesTabs = attributesKeys.map((name) => {
|
|
1101
|
-
return {
|
|
1102
|
-
type: "attribute",
|
|
1103
|
-
value: name,
|
|
1104
|
-
tab: createUniqueId(),
|
|
1105
|
-
panel: createUniqueId()
|
|
1106
|
-
};
|
|
1107
|
-
});
|
|
1108
|
-
tabs.push(...attributesTabs);
|
|
1109
|
-
return tabs;
|
|
1110
|
-
};
|
|
1111
|
-
var showPicker = function() {
|
|
234
|
+
var showPicker = function(options) {
|
|
1112
235
|
const {
|
|
1113
236
|
clothingData,
|
|
1114
|
-
options: {
|
|
1115
|
-
character: characterId,
|
|
1116
|
-
defaultAttributes,
|
|
1117
|
-
defaultBase,
|
|
1118
|
-
excludeAttributes,
|
|
1119
|
-
translation: translations
|
|
1120
|
-
}
|
|
237
|
+
options: { character: characterId, defaultAttributes, defaultBase, translation: translations }
|
|
1121
238
|
} = this;
|
|
1122
|
-
const {
|
|
1123
|
-
|
|
1124
|
-
attributes
|
|
1125
|
-
} = clothingData;
|
|
1126
|
-
const handler = ({
|
|
1127
|
-
clear,
|
|
1128
|
-
flags,
|
|
1129
|
-
getDomNodes,
|
|
1130
|
-
rendererContext,
|
|
1131
|
-
lang,
|
|
1132
|
-
state
|
|
1133
|
-
}) => {
|
|
239
|
+
const { base, attributes } = clothingData;
|
|
240
|
+
const handler = ({ clear, flags, getDomNodes, rendererContext, lang, state }) => {
|
|
1134
241
|
const translation = translations[lang];
|
|
1135
242
|
const initialEmotion = getSavedEmotion(state, characterId, clothingData, {
|
|
1136
243
|
base: defaultBase,
|
|
1137
244
|
attributes: defaultAttributes
|
|
1138
245
|
});
|
|
1139
|
-
const {
|
|
1140
|
-
|
|
1141
|
-
resolve
|
|
1142
|
-
} = Promise.withResolvers();
|
|
1143
|
-
const {
|
|
1144
|
-
element
|
|
1145
|
-
} = getDomNodes(true);
|
|
246
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
247
|
+
const { element } = getDomNodes(true);
|
|
1146
248
|
const character = rendererContext.character(characterId);
|
|
1147
249
|
character.emotion(getEmotionString(initialEmotion), true);
|
|
1148
250
|
character.append();
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
character.emotion(getEmotionString(appearance()), true);
|
|
1161
|
-
saveEmotion(state, characterId, appearance());
|
|
1162
|
-
});
|
|
1163
|
-
return (() => {
|
|
1164
|
-
const _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
|
|
1165
|
-
_el$2.$$click = () => {
|
|
1166
|
-
setExpanded((value) => !value);
|
|
1167
|
-
};
|
|
1168
|
-
use((element2) => onCleanup(slidy(element2, {
|
|
1169
|
-
axis: "x"
|
|
1170
|
-
}).destroy), _el$4);
|
|
1171
|
-
insert(_el$4, createComponent(For, {
|
|
1172
|
-
each: tabs,
|
|
1173
|
-
children: (tab, i) => (() => {
|
|
1174
|
-
const _el$5 = _tmpl$2();
|
|
1175
|
-
use((element2) => {
|
|
1176
|
-
setTabElements((elements) => {
|
|
1177
|
-
elements[i()] = element2;
|
|
1178
|
-
return elements;
|
|
1179
|
-
});
|
|
1180
|
-
}, _el$5);
|
|
1181
|
-
_el$5.$$keydown = (event) => {
|
|
1182
|
-
const change = event.key === "ArrowLeft" ? -1 : event.key === "ArrowRight" ? 1 : 0;
|
|
1183
|
-
if (change === 0) {
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
event.stopPropagation();
|
|
1187
|
-
event.preventDefault();
|
|
1188
|
-
const nextTab = activeTab() + change;
|
|
1189
|
-
if (nextTab < 0) {
|
|
1190
|
-
setActiveTab(tabs.length - 1);
|
|
1191
|
-
} else if (nextTab > tabs.length - 1) {
|
|
1192
|
-
setActiveTab(0);
|
|
1193
|
-
} else {
|
|
1194
|
-
setActiveTab(nextTab);
|
|
1195
|
-
}
|
|
1196
|
-
const activeTabElement = tabElements()[activeTab()];
|
|
1197
|
-
if (activeTabElement) {
|
|
1198
|
-
activeTabElement.focus();
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
_el$5.$$click = () => {
|
|
1202
|
-
setActiveTab(i());
|
|
1203
|
-
};
|
|
1204
|
-
insert(_el$5, () => tab.type === "attribute" ? translation.tabs.attributes[tab.value] : translation.tabs.base);
|
|
1205
|
-
createRenderEffect((_p$) => {
|
|
1206
|
-
const _v$5 = tab.tab, _v$6 = tab.panel, _v$7 = i() === activeTab(), _v$8 = i() === activeTab() ? void 0 : -1;
|
|
1207
|
-
_v$5 !== _p$._v$5 && setAttribute(_el$5, "id", _p$._v$5 = _v$5);
|
|
1208
|
-
_v$6 !== _p$._v$6 && setAttribute(_el$5, "aria-controls", _p$._v$6 = _v$6);
|
|
1209
|
-
_v$7 !== _p$._v$7 && setAttribute(_el$5, "aria-selected", _p$._v$7 = _v$7);
|
|
1210
|
-
_v$8 !== _p$._v$8 && setAttribute(_el$5, "tabindex", _p$._v$8 = _v$8);
|
|
1211
|
-
return _p$;
|
|
1212
|
-
}, {
|
|
1213
|
-
_v$5: void 0,
|
|
1214
|
-
_v$6: void 0,
|
|
1215
|
-
_v$7: void 0,
|
|
1216
|
-
_v$8: void 0
|
|
1217
|
-
});
|
|
1218
|
-
return _el$5;
|
|
1219
|
-
})()
|
|
1220
|
-
}));
|
|
1221
|
-
insert(_el$, createComponent(For, {
|
|
1222
|
-
each: tabs,
|
|
1223
|
-
children: (tab, i) => {
|
|
1224
|
-
const variants = tab.type === "attribute" ? attributes[tab.value] : base;
|
|
1225
|
-
const translationGroup = tab.type === "attribute" ? translation.attributes[tab.value] : translation.base;
|
|
1226
|
-
const initialSlideIndex = (() => {
|
|
1227
|
-
const currentAppearance = untrack(appearance);
|
|
1228
|
-
if (tab.type === "base") {
|
|
1229
|
-
return base.indexOf(currentAppearance.base);
|
|
1230
|
-
}
|
|
1231
|
-
return variants.indexOf(currentAppearance.attributes[tab.value]);
|
|
1232
|
-
})();
|
|
1233
|
-
const [currentSlide, setCurrentSlide] = createSignal(initialSlideIndex);
|
|
1234
|
-
createEffect(() => {
|
|
1235
|
-
if (activeTab() !== i()) {
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
const currentAppearance = untrack(appearance);
|
|
1239
|
-
const slide = currentSlide();
|
|
1240
|
-
const currentVariant = variants[slide];
|
|
1241
|
-
if (tab.type === "base") {
|
|
1242
|
-
const emotion = getEmotionString(setAppearance({
|
|
1243
|
-
base: currentVariant,
|
|
1244
|
-
attributes: currentAppearance.attributes
|
|
1245
|
-
}));
|
|
1246
|
-
character.emotion(emotion, true);
|
|
1247
|
-
PRELOADED_EMOTIONS.add(emotion);
|
|
1248
|
-
} else {
|
|
1249
|
-
const emotion = getEmotionString(setAppearance({
|
|
1250
|
-
base: currentAppearance.base,
|
|
1251
|
-
attributes: {
|
|
1252
|
-
...currentAppearance.attributes,
|
|
1253
|
-
[tab.value]: currentVariant
|
|
1254
|
-
}
|
|
1255
|
-
}));
|
|
1256
|
-
character.emotion(emotion, true);
|
|
1257
|
-
PRELOADED_EMOTIONS.add(emotion);
|
|
1258
|
-
}
|
|
1259
|
-
const nextIndex = slide < variants.length ? slide : 0;
|
|
1260
|
-
const prevIndex = slide > 0 ? slide - 1 : variants.length - 1;
|
|
1261
|
-
for (const index of [nextIndex, prevIndex]) {
|
|
1262
|
-
const emotion = tab.type === "base" ? getEmotionString({
|
|
1263
|
-
base: variants[index],
|
|
1264
|
-
attributes: currentAppearance.attributes
|
|
1265
|
-
}) : getEmotionString({
|
|
1266
|
-
base: currentAppearance.base,
|
|
1267
|
-
attributes: {
|
|
1268
|
-
...currentAppearance.attributes,
|
|
1269
|
-
[tab.value]: variants[index]
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
if (PRELOADED_EMOTIONS.has(emotion)) {
|
|
1273
|
-
continue;
|
|
1274
|
-
} else {
|
|
1275
|
-
PRELOADED_EMOTIONS.add(emotion);
|
|
1276
|
-
}
|
|
1277
|
-
character.emotion(emotion, false);
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
return (() => {
|
|
1281
|
-
const _el$6 = _tmpl$3(), _el$7 = _el$6.firstChild, _el$8 = _el$7.firstChild, _el$9 = _el$8.firstChild, _el$10 = _el$9.nextSibling, _el$11 = _el$8.nextSibling;
|
|
1282
|
-
_el$7.$$keydown = (event) => {
|
|
1283
|
-
if (event.key === "ArrowLeft") {
|
|
1284
|
-
setCurrentSlide((value) => value > 0 ? value - 1 : variants.length - 1);
|
|
1285
|
-
} else if (event.key === "ArrowRight") {
|
|
1286
|
-
setCurrentSlide((value) => value < variants.length - 1 ? value + 1 : 0);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
_el$9.$$click = () => {
|
|
1290
|
-
setCurrentSlide((slide) => {
|
|
1291
|
-
if (slide > 0) {
|
|
1292
|
-
return slide - 1;
|
|
1293
|
-
}
|
|
1294
|
-
return variants.length - 1;
|
|
1295
|
-
});
|
|
1296
|
-
};
|
|
1297
|
-
_el$10.$$click = () => {
|
|
1298
|
-
setCurrentSlide((slide) => {
|
|
1299
|
-
if (slide < variants.length - 1) {
|
|
1300
|
-
return slide + 1;
|
|
1301
|
-
}
|
|
1302
|
-
return 0;
|
|
1303
|
-
});
|
|
1304
|
-
};
|
|
1305
|
-
insert(_el$11, createComponent(For, {
|
|
1306
|
-
each: variants,
|
|
1307
|
-
children: (variant, i2) => {
|
|
1308
|
-
const titleId = createUniqueId();
|
|
1309
|
-
return (() => {
|
|
1310
|
-
const _el$12 = _tmpl$4(), _el$13 = _el$12.firstChild, _el$14 = _el$13.nextSibling, _el$15 = _el$14.firstChild;
|
|
1311
|
-
setAttribute(_el$12, "aria-labelledby", titleId);
|
|
1312
|
-
setAttribute(_el$13, "id", titleId);
|
|
1313
|
-
insert(_el$13, () => translationGroup[variant]);
|
|
1314
|
-
_el$15.$$click = () => {
|
|
1315
|
-
resolve();
|
|
1316
|
-
};
|
|
1317
|
-
insert(_el$15, () => translation.ui.sumbit);
|
|
1318
|
-
createRenderEffect(() => _el$12.classList.toggle("ndc-slide-active", !!(i2() == currentSlide())));
|
|
1319
|
-
return _el$12;
|
|
1320
|
-
})();
|
|
1321
|
-
}
|
|
1322
|
-
}));
|
|
1323
|
-
createRenderEffect((_p$) => {
|
|
1324
|
-
const _v$9 = tab.tab, _v$10 = tab.panel, _v$11 = !!(activeTab() !== i()), _v$12 = translation.ui.variants, _v$13 = !expanded(), _v$14 = translation.ui.slidesControl, _v$15 = translation.ui.prevSlide, _v$16 = translation.ui.nextSlide;
|
|
1325
|
-
_v$9 !== _p$._v$9 && setAttribute(_el$6, "aria-labelledby", _p$._v$9 = _v$9);
|
|
1326
|
-
_v$10 !== _p$._v$10 && setAttribute(_el$6, "id", _p$._v$10 = _v$10);
|
|
1327
|
-
_v$11 !== _p$._v$11 && _el$6.classList.toggle("ndc-tabpanel-hidden", _p$._v$11 = _v$11);
|
|
1328
|
-
_v$12 !== _p$._v$12 && setAttribute(_el$7, "aria-label", _p$._v$12 = _v$12);
|
|
1329
|
-
_v$13 !== _p$._v$13 && _el$7.classList.toggle("ndc-slider-picker-collapsed", _p$._v$13 = _v$13);
|
|
1330
|
-
_v$14 !== _p$._v$14 && setAttribute(_el$8, "aria-label", _p$._v$14 = _v$14);
|
|
1331
|
-
_v$15 !== _p$._v$15 && setAttribute(_el$9, "aria-label", _p$._v$15 = _v$15);
|
|
1332
|
-
_v$16 !== _p$._v$16 && setAttribute(_el$10, "aria-label", _p$._v$16 = _v$16);
|
|
1333
|
-
return _p$;
|
|
1334
|
-
}, {
|
|
1335
|
-
_v$9: void 0,
|
|
1336
|
-
_v$10: void 0,
|
|
1337
|
-
_v$11: void 0,
|
|
1338
|
-
_v$12: void 0,
|
|
1339
|
-
_v$13: void 0,
|
|
1340
|
-
_v$14: void 0,
|
|
1341
|
-
_v$15: void 0,
|
|
1342
|
-
_v$16: void 0
|
|
1343
|
-
});
|
|
1344
|
-
return _el$6;
|
|
1345
|
-
})();
|
|
251
|
+
const { title, slides, translationGroup, pricing, getInitialSlideIndex } = (() => {
|
|
252
|
+
const { pricing: pricing2 } = clothingData;
|
|
253
|
+
if (options.type === "attribute") {
|
|
254
|
+
const slides2 = attributes[options.name];
|
|
255
|
+
return {
|
|
256
|
+
title: translation.title.attributes[options.name],
|
|
257
|
+
slides: attributes[options.name],
|
|
258
|
+
translationGroup: translation.attributes[options.name],
|
|
259
|
+
pricing: pricing2 ? slides2.map((s) => pricing2.attributes[options.name][s]) : Array(slides2.length).fill(0),
|
|
260
|
+
getInitialSlideIndex: (appearance) => {
|
|
261
|
+
return slides2.indexOf(appearance.attributes[options.name]);
|
|
1346
262
|
}
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
title: translation.title.base,
|
|
267
|
+
slides: base,
|
|
268
|
+
translationGroup: translation.base,
|
|
269
|
+
pricing: pricing2 ? base.map((s) => pricing2.base[s]) : Array(base.length).fill(0),
|
|
270
|
+
getInitialSlideIndex: (appearance) => {
|
|
271
|
+
return base.indexOf(appearance.base);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
})();
|
|
275
|
+
const onIndexChange = (appearance, setAppearance, slide) => {
|
|
276
|
+
const updated = slides[slide];
|
|
277
|
+
let emotion = "";
|
|
278
|
+
if (options.type === "base") {
|
|
279
|
+
emotion = getEmotionString(
|
|
280
|
+
setAppearance({
|
|
281
|
+
base: updated,
|
|
282
|
+
attributes: appearance.attributes
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
} else {
|
|
286
|
+
emotion = getEmotionString(
|
|
287
|
+
setAppearance({
|
|
288
|
+
base: appearance.base,
|
|
289
|
+
attributes: {
|
|
290
|
+
...appearance.attributes,
|
|
291
|
+
[options.name]: updated
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
character.emotion(emotion, true);
|
|
297
|
+
PRELOADED_EMOTIONS.add(emotion);
|
|
298
|
+
const nextIndex = slide < slides.length - 1 ? slide + 1 : 0;
|
|
299
|
+
const prevIndex = slide > 0 ? slide - 1 : slides.length - 1;
|
|
300
|
+
for (const index of [nextIndex, prevIndex]) {
|
|
301
|
+
let emotion2 = "";
|
|
302
|
+
if (options.type === "base") {
|
|
303
|
+
emotion2 = getEmotionString({ base: slides[index], attributes: appearance.attributes });
|
|
304
|
+
} else {
|
|
305
|
+
emotion2 = getEmotionString({
|
|
306
|
+
base: appearance.base,
|
|
307
|
+
attributes: { ...appearance.attributes, [options.name]: slides[index] }
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (PRELOADED_EMOTIONS.has(emotion2)) {
|
|
311
|
+
continue;
|
|
312
|
+
} else {
|
|
313
|
+
PRELOADED_EMOTIONS.add(emotion2);
|
|
314
|
+
}
|
|
315
|
+
character.emotion(emotion2, false);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const saveEmotionWrapper = (appearance) => {
|
|
319
|
+
saveEmotion(state, characterId, appearance);
|
|
1363
320
|
};
|
|
1364
|
-
const cleanup = render(
|
|
1365
|
-
|
|
1366
|
-
|
|
321
|
+
const cleanup = render(
|
|
322
|
+
() => createComponent(Picker, {
|
|
323
|
+
title,
|
|
324
|
+
initialExpanded: !flags.preview,
|
|
325
|
+
initialEmotion,
|
|
326
|
+
slides,
|
|
327
|
+
pricing,
|
|
328
|
+
translation,
|
|
329
|
+
translationGroup,
|
|
330
|
+
getInitialSlideIndex,
|
|
331
|
+
onIndexChange,
|
|
332
|
+
saveEmotion: saveEmotionWrapper,
|
|
333
|
+
sumbit: resolve,
|
|
334
|
+
buy: options.buy,
|
|
335
|
+
isBought: options.isBought
|
|
336
|
+
}),
|
|
337
|
+
element
|
|
338
|
+
);
|
|
339
|
+
const cleanupOnce = once(cleanup);
|
|
340
|
+
clear(cleanupOnce);
|
|
341
|
+
promise.then(cleanupOnce);
|
|
1367
342
|
return promise;
|
|
1368
343
|
};
|
|
1369
344
|
handler.id = CHARACTER_STYLE_PICKER;
|
|
@@ -1372,7 +347,6 @@ var showPicker = function() {
|
|
|
1372
347
|
handler.requireUserAction = true;
|
|
1373
348
|
return handler;
|
|
1374
349
|
};
|
|
1375
|
-
delegateEvents(["click", "keydown"]);
|
|
1376
350
|
|
|
1377
351
|
// src/show.ts
|
|
1378
352
|
var SHOW_CHARACTER = Symbol();
|
|
@@ -1393,18 +367,83 @@ var showCharacter = function() {
|
|
|
1393
367
|
return handler;
|
|
1394
368
|
};
|
|
1395
369
|
|
|
1396
|
-
// src/
|
|
1397
|
-
var
|
|
370
|
+
// src/actions.ts
|
|
371
|
+
var DEFAULT_SHOW_BASE_OPTIONS = {
|
|
372
|
+
type: "base",
|
|
373
|
+
buy: async () => true,
|
|
374
|
+
isBought: () => true
|
|
375
|
+
};
|
|
376
|
+
var DEFAULT_SHOW_ATTRIBUTE_OPTIONS = {
|
|
377
|
+
type: "attribute",
|
|
378
|
+
buy: async () => true,
|
|
379
|
+
isBought: () => true
|
|
380
|
+
};
|
|
381
|
+
var createActions = function(engine, options) {
|
|
1398
382
|
const that = {
|
|
1399
|
-
clothingData,
|
|
383
|
+
clothingData: this,
|
|
1400
384
|
options
|
|
1401
385
|
};
|
|
1402
386
|
return {
|
|
1403
|
-
|
|
1404
|
-
|
|
387
|
+
showBasePicker: (options2 = {}) => {
|
|
388
|
+
const handler = showPicker.call(that, {
|
|
389
|
+
...DEFAULT_SHOW_BASE_OPTIONS,
|
|
390
|
+
...options2
|
|
391
|
+
});
|
|
392
|
+
return engine.action.custom(handler);
|
|
393
|
+
},
|
|
394
|
+
showAttributePicker: (options2) => {
|
|
395
|
+
const handler = showPicker.call(that, {
|
|
396
|
+
...DEFAULT_SHOW_ATTRIBUTE_OPTIONS,
|
|
397
|
+
...options2
|
|
398
|
+
});
|
|
399
|
+
return engine.action.custom(handler);
|
|
400
|
+
},
|
|
401
|
+
showCharacter: () => {
|
|
402
|
+
return engine.action.custom(showCharacter.call(that));
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/emotions.ts
|
|
408
|
+
var generateEmotions = ({
|
|
409
|
+
base,
|
|
410
|
+
attributes,
|
|
411
|
+
pricing
|
|
412
|
+
}) => {
|
|
413
|
+
const emotions = {};
|
|
414
|
+
const combineBaseWithAttributes = (baseEmotion, baseAssets, currentAttributes, attributesLeft) => {
|
|
415
|
+
if (attributesLeft.length === 0) {
|
|
416
|
+
const key = `${baseEmotion}@${currentAttributes.join("__")}`;
|
|
417
|
+
emotions[key] = baseAssets;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const [attribute, variants] = attributesLeft[0];
|
|
421
|
+
const remainingAttributes = attributesLeft.slice(1);
|
|
422
|
+
for (const [variant, emotions2] of Object.entries(variants)) {
|
|
423
|
+
const attributeAssets = emotions2[baseEmotion];
|
|
424
|
+
combineBaseWithAttributes(
|
|
425
|
+
baseEmotion,
|
|
426
|
+
[...baseAssets, ...toArray(attributeAssets)],
|
|
427
|
+
[...currentAttributes, `${attribute}_${variant}`],
|
|
428
|
+
remainingAttributes
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
for (const [baseEmotion, baseAssets] of getEntries(base)) {
|
|
433
|
+
for (const _permutation of permutation(getEntries(attributes))) {
|
|
434
|
+
combineBaseWithAttributes(baseEmotion, toArray(baseAssets), [], _permutation);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const clothingData = {
|
|
438
|
+
base: getKeys(base),
|
|
439
|
+
attributes: Object.fromEntries(getEntries(attributes).map(([name, value]) => [name, getKeys(value)])),
|
|
440
|
+
pricing
|
|
441
|
+
};
|
|
442
|
+
return {
|
|
443
|
+
emotions,
|
|
444
|
+
createActions: createActions.bind(clothingData)
|
|
1405
445
|
};
|
|
1406
446
|
};
|
|
1407
447
|
export {
|
|
1408
|
-
createDynamicCharacter,
|
|
1409
448
|
generateEmotions
|
|
1410
449
|
};
|