@wix/himalaya-cli 0.1261.0 → 0.1263.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/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/tokens.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +26 -0
- package/dist/cli.mjs +155 -38
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +2 -0
- package/package.json +2 -2
- package/templates/beauty-salon/dev/index.ts +45 -7
- package/templates/beauty-salon/tier5-src/_shared/home-service.ts +18 -5
- package/templates/beauty-salon-owner/dev/index.ts +301 -94
- package/templates/beauty-salon-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/branded-lite/dev/index.ts +45 -7
- package/templates/branded-lite/tier5-src/_shared/home-service.ts +18 -5
- package/templates/community-club/dev/index.ts +45 -7
- package/templates/community-club/tier5-src/_shared/home-service.ts +18 -5
- package/templates/community-club-owner/dev/index.ts +237 -78
- package/templates/community-club-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/community-club-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/community-club-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/community-club-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/community-club-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/events-meetups/dev/index.ts +45 -7
- package/templates/events-meetups/tier5-src/_shared/home-service.ts +18 -5
- package/templates/events-meetups-owner/dev/index.ts +141 -54
- package/templates/events-meetups-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/gym-fitness/dev/index.ts +45 -7
- package/templates/gym-fitness/tier5-src/_shared/home-service.ts +18 -5
- package/templates/gym-fitness-owner/dev/index.ts +333 -102
- package/templates/gym-fitness-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/nonprofit-cause/dev/index.ts +45 -7
- package/templates/nonprofit-cause/tier5-src/_shared/home-service.ts +18 -5
- package/templates/nonprofit-cause-owner/dev/index.ts +237 -78
- package/templates/nonprofit-cause-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/owner-lite/dev/index.ts +333 -102
- package/templates/owner-lite/tier5-src/_shared/home-service.ts +18 -5
- package/templates/owner-lite/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/owner-lite/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/owner-lite/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/owner-lite/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/owner-lite/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/podcast-creator/dev/index.ts +45 -7
- package/templates/podcast-creator/tier5-src/_shared/home-service.ts +18 -5
- package/templates/podcast-creator-owner/dev/index.ts +237 -78
- package/templates/podcast-creator-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/portfolio-creative/dev/index.ts +45 -7
- package/templates/portfolio-creative/tier5-src/_shared/home-service.ts +18 -5
- package/templates/portfolio-creative-owner/dev/index.ts +301 -94
- package/templates/portfolio-creative-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/restaurant/dev/index.ts +45 -7
- package/templates/restaurant/tier5-src/_shared/home-service.ts +18 -5
- package/templates/restaurant-owner/dev/index.ts +333 -102
- package/templates/restaurant-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
- package/templates/retail-store/dev/index.ts +45 -7
- package/templates/retail-store/tier5-src/_shared/home-service.ts +18 -5
- package/templates/retail-store-owner/dev/index.ts +205 -70
- package/templates/retail-store-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
- package/templates/yoga-studio/dev/index.ts +45 -7
- package/templates/yoga-studio/tier5-src/_shared/home-service.ts +18 -5
- package/templates/yoga-studio-owner/dev/index.ts +237 -78
- package/templates/yoga-studio-owner/tier5-src/_shared/home-service.ts +18 -5
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-ask/index.ts +5 -0
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-drawer/logic.ts +3 -0
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineService as register, type ServiceDefinition } from '@himalaya/state';
|
|
2
2
|
import { normalizeHome, visibleHome, moduleIsEmpty, type HomeModule, type HomePreferences } from './home-modules.js';
|
|
3
|
-
import { copyParam, stashCopy } from './himi-copy.js';
|
|
3
|
+
import { copyParam, copyTemplate, stashCopy } from './himi-copy.js';
|
|
4
4
|
import { localPreferences } from './local-preferences.js';
|
|
5
5
|
type State = Record<string, unknown>;
|
|
6
6
|
type Action = (s: State, ...args: unknown[]) => State | undefined | Promise<State | undefined>;
|
|
@@ -32,10 +32,22 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
|
|
|
32
32
|
return { ...s, homeModules: { presented, visible: painted.map(id => ({ id })),
|
|
33
33
|
persistenceLabel: persisted.available ? copyParam('homeModules.onDevice', 'Saved on this device') : copyParam('homeModules.sessionOnly', 'Choices last for this session'),
|
|
34
34
|
slots: Object.fromEntries(modules.map((_, i) => [`slot${i}`, order[i] ?? 'empty'])),
|
|
35
|
-
choices: prefs.order.map(id =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
choices: prefs.order.map((id, index) => {
|
|
36
|
+
const module = modules.find(candidate => candidate.id === id);
|
|
37
|
+
const name = module?.label ?? id;
|
|
38
|
+
const isHidden = prefs.hidden.includes(id);
|
|
39
|
+
const isPinned = prefs.pinned.includes(id);
|
|
40
|
+
return { ...module,
|
|
41
|
+
isFirst: index === 0,
|
|
42
|
+
isLast: index === prefs.order.length - 1,
|
|
43
|
+
visibility: isHidden ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
|
|
44
|
+
pinLabel: isPinned ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
|
|
45
|
+
visibilityA11yLabel: copyTemplate(isHidden ? 'homeModules.showA11y' : 'homeModules.hideA11y', isHidden ? 'Show {module}' : 'Hide {module}', { module: name }),
|
|
46
|
+
pinA11yLabel: copyTemplate(isPinned ? 'homeModules.unpinA11y' : 'homeModules.pinA11y', isPinned ? 'Unpin {module}' : 'Pin {module}', { module: name }),
|
|
47
|
+
moveUpA11yLabel: copyTemplate('homeModules.moveUpA11y', 'Move {module} up', { module: name }),
|
|
48
|
+
moveDownA11yLabel: copyTemplate('homeModules.moveDownA11y', 'Move {module} down', { module: name }),
|
|
49
|
+
};
|
|
50
|
+
}) } };
|
|
39
51
|
};
|
|
40
52
|
const actions: Record<string, Action> = {};
|
|
41
53
|
for (const [name, action] of Object.entries(def.actions ?? {})) actions[name] = (s, ...args) => {
|
|
@@ -72,6 +84,7 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
|
|
|
72
84
|
actions.homeToggle = change(id => { if (modules.some(m => m.id === id)) prefs.hidden = prefs.hidden.includes(id) ? prefs.hidden.filter(x => x !== id) : [...prefs.hidden, id]; });
|
|
73
85
|
actions.homePin = change(id => { if (modules.some(m => m.id === id)) { prefs.pinned = prefs.pinned.includes(id) ? prefs.pinned.filter(x => x !== id) : [...prefs.pinned, id]; prefs.hidden = prefs.hidden.filter(x => x !== id); } });
|
|
74
86
|
actions.homeMoveUp = change(id => { const index = prefs.order.indexOf(id); if (index > 0) [prefs.order[index - 1], prefs.order[index]] = [prefs.order[index], prefs.order[index - 1]]; });
|
|
87
|
+
actions.homeMoveDown = change(id => { const index = prefs.order.indexOf(id); if (index >= 0 && index < prefs.order.length - 1) [prefs.order[index], prefs.order[index + 1]] = [prefs.order[index + 1], prefs.order[index]]; });
|
|
75
88
|
return { state: derive(def.state), actions };
|
|
76
89
|
}
|
|
77
90
|
export const defineService: typeof register = ((name: string, def: ServiceDefinition<unknown>) => register(name, decorateHome(def as unknown as { state: State; actions?: Record<string, Action> }))) as typeof register;
|
|
@@ -74,6 +74,8 @@ interface AskState {
|
|
|
74
74
|
noRecents: boolean;
|
|
75
75
|
hasAnswer: boolean;
|
|
76
76
|
noAnswer: boolean;
|
|
77
|
+
/** Hide the authored answer controls when neither an answer nor recents exist. */
|
|
78
|
+
noAfterAnswer: boolean;
|
|
77
79
|
|
|
78
80
|
// --- Proposed write (Phase 6) -------------------------------------------
|
|
79
81
|
// A generated row can PROPOSE a change; it can never make one. `proposeWrite`
|
|
@@ -145,6 +147,7 @@ const initialState: AskState = {
|
|
|
145
147
|
noRecents: true,
|
|
146
148
|
hasAnswer: false,
|
|
147
149
|
noAnswer: true,
|
|
150
|
+
noAfterAnswer: true,
|
|
148
151
|
proposalVerb: "",
|
|
149
152
|
proposalEntity: "",
|
|
150
153
|
proposalId: "",
|
|
@@ -436,6 +439,7 @@ async function runTurn(state: AskState, rawIntent: string, options: TurnOptions
|
|
|
436
439
|
savedScreenId: options.remember ? savedScreenId(intent) : state.savedScreenId,
|
|
437
440
|
hasAnswer: true,
|
|
438
441
|
noAnswer: false,
|
|
442
|
+
noAfterAnswer: false,
|
|
439
443
|
...NO_PROPOSAL,
|
|
440
444
|
};
|
|
441
445
|
}
|
|
@@ -499,6 +503,7 @@ const ask = defineService<AskState, {
|
|
|
499
503
|
...state, recents,
|
|
500
504
|
hasRecents: recents.length > 0,
|
|
501
505
|
noRecents: recents.length === 0,
|
|
506
|
+
noAfterAnswer: state.noAnswer && recents.length === 0,
|
|
502
507
|
// A saved link whose question has aged out of the recents list can't
|
|
503
508
|
// be replayed — say so rather than opening a blank screen.
|
|
504
509
|
...(id ? { headline: "That saved answer is gone", note: "Ask the question again to bring it back." } : {}),
|
|
@@ -40,6 +40,8 @@ export interface DrawerCore {
|
|
|
40
40
|
|
|
41
41
|
export interface DrawerState extends DrawerCore {
|
|
42
42
|
siteInitials: string;
|
|
43
|
+
/** Hide the name completely when unavailable so the site row has no empty gap. */
|
|
44
|
+
noSiteName: boolean;
|
|
43
45
|
attentionTotal: number;
|
|
44
46
|
attentionLabel: string;
|
|
45
47
|
/** TRUE when there is nothing to chase. Feeds `hiddenPath`, which hides on a
|
|
@@ -85,6 +87,7 @@ export function withDerived(core: DrawerCore): DrawerState {
|
|
|
85
87
|
attention,
|
|
86
88
|
confirmingClear,
|
|
87
89
|
siteInitials: initialsOf(core.siteName),
|
|
90
|
+
noSiteName: core.siteName.trim().length === 0,
|
|
88
91
|
attentionTotal: total,
|
|
89
92
|
attentionLabel: total === 0
|
|
90
93
|
? "All caught up"
|
|
@@ -289,6 +289,10 @@ const svc = defineService<ProductFormState, {
|
|
|
289
289
|
submit: async (s, values): Promise<ProductFormState> => settleOverLive(svc, s, await (async (): Promise<ProductFormState> => {
|
|
290
290
|
if (isOwnerPreviewDemo() || s.demoNote) return demoRefusal(s);
|
|
291
291
|
const v = values ?? {};
|
|
292
|
+
// Queue replay boots a fresh worker without navigation input. Keep a live form's
|
|
293
|
+
// target authoritative, and use the queued mode only for a queued target.
|
|
294
|
+
const targetId = s.id || (typeof v.id === "string" ? v.id : "");
|
|
295
|
+
const mode: Mode = !s.id && targetId && v.mode === "edit" ? "edit" : s.mode;
|
|
292
296
|
const name = String(v.name ?? s.name).trim();
|
|
293
297
|
const rawPrice = String(v.price ?? s.price).trim();
|
|
294
298
|
// "12,50" (comma-decimal keypad) is accepted and written as 12.50.
|
|
@@ -340,7 +344,7 @@ const svc = defineService<ProductFormState, {
|
|
|
340
344
|
...(sku ? { sku } : {}),
|
|
341
345
|
...(descriptionEdited ? { description } : {}),
|
|
342
346
|
...(richDescription ? { richDescription } : {}),
|
|
343
|
-
...(
|
|
347
|
+
...(mode === "edit" && targetId ? {} : { productType: "physical" }),
|
|
344
348
|
};
|
|
345
349
|
// The document the record now holds, when known: an offline reopen seeds the editor with it.
|
|
346
350
|
const loadedJson = s.descriptionMode === "editor" && !s.descriptionPending ? s.descriptionJson : "";
|
|
@@ -353,7 +357,17 @@ const svc = defineService<ProductFormState, {
|
|
|
353
357
|
const descriptionProtected = cachedRichVerdict(heldDoc as never, knownPlain);
|
|
354
358
|
|
|
355
359
|
// Optimistic local write — the list repaints from cache immediately (offline or not).
|
|
356
|
-
|
|
360
|
+
// Replay starts with default worker state. An untouched description was omitted from the
|
|
361
|
+
// queued PATCH, so retain its cached mirror/document/verdict when replacing the local row.
|
|
362
|
+
const cached = replay && targetId ? await cacheGet(targetId) : null;
|
|
363
|
+
const keepCachedDescription = cached !== null && !descriptionEdited && richDescription === null;
|
|
364
|
+
const localRow = (id: string): DbEntity => ({
|
|
365
|
+
...(cached ?? {}), id, name, price, sku,
|
|
366
|
+
description: keepCachedDescription ? String(cached.description ?? "") : description,
|
|
367
|
+
descriptionProtected: keepCachedDescription ? String(cached.descriptionProtected ?? descriptionProtected) : descriptionProtected,
|
|
368
|
+
...(heldJson ? { descriptionJson: heldJson } : descriptionEdited ? { descriptionJson: "" } : {}),
|
|
369
|
+
visible: visible ? "true" : "false", statusLabel: visible ? "Visible" : "Hidden",
|
|
370
|
+
});
|
|
357
371
|
const wrote = richDescription !== null;
|
|
358
372
|
const savedDescription = {
|
|
359
373
|
description, originalDescription: descriptionEdited || wrote ? description : s.originalDescription,
|
|
@@ -365,12 +379,12 @@ const svc = defineService<ProductFormState, {
|
|
|
365
379
|
const a = editorAfterSave("description", s as never, liveState(svc), wrote);
|
|
366
380
|
return { descriptionDirty: a.dirty, descriptionEdits: a.edits, ...(a.editedDuringSave ? { status: "idle" as const, savedMessage: "" } : {}) };
|
|
367
381
|
};
|
|
368
|
-
const localId =
|
|
382
|
+
const localId = mode === "edit" && targetId ? targetId : `local-${Date.now()}`;
|
|
369
383
|
await cachePut(localRow(localId));
|
|
370
384
|
try {
|
|
371
|
-
let id =
|
|
372
|
-
if (
|
|
373
|
-
await updateProduct(
|
|
385
|
+
let id = targetId;
|
|
386
|
+
if (mode === "edit" && targetId) {
|
|
387
|
+
await updateProduct(targetId, write as WixProductWrite);
|
|
374
388
|
} else {
|
|
375
389
|
const r = await createProduct(write);
|
|
376
390
|
id = r.product?.id || localId;
|
|
@@ -402,7 +416,7 @@ const svc = defineService<ProductFormState, {
|
|
|
402
416
|
// write to replay (WriteQueue, idempotent) when connectivity returns.
|
|
403
417
|
// A document rides as `descriptionJson` with descriptionEdited "false", so a bundle rolled back
|
|
404
418
|
// past this change leaves the description rather than flattening it to text.
|
|
405
|
-
await queueWrite("tier5.himiOwnerLiteProductForm.submit", { id:
|
|
419
|
+
await queueWrite("tier5.himiOwnerLiteProductForm.submit", { id: targetId, name, price, sku, description, visible: String(visible), mode,
|
|
406
420
|
...(docRaw ? { descriptionJson: docRaw, descriptionEdited: "false" } : { descriptionEdited: String(descriptionEdited) }) });
|
|
407
421
|
return shape({
|
|
408
422
|
...s, mode: "edit", id: localId, name, price, sku, ...savedDescription,
|
|
@@ -2117,6 +2117,9 @@ const SCREENS = runtimeSetting({
|
|
|
2117
2117
|
"type": "BottomSheet",
|
|
2118
2118
|
"props": {
|
|
2119
2119
|
"presentedPath": "$service:himiBrandedHome.homeModules.presented",
|
|
2120
|
+
"detents": [
|
|
2121
|
+
0.95
|
|
2122
|
+
],
|
|
2120
2123
|
"dismissible": true,
|
|
2121
2124
|
"showGrabber": true,
|
|
2122
2125
|
"onDismiss": {
|
|
@@ -2218,6 +2221,9 @@ const SCREENS = runtimeSetting({
|
|
|
2218
2221
|
}
|
|
2219
2222
|
}
|
|
2220
2223
|
}
|
|
2224
|
+
},
|
|
2225
|
+
"modifiers": {
|
|
2226
|
+
"accessibilityLabel": "$item.pinA11yLabel"
|
|
2221
2227
|
}
|
|
2222
2228
|
},
|
|
2223
2229
|
{
|
|
@@ -2235,31 +2241,63 @@ const SCREENS = runtimeSetting({
|
|
|
2235
2241
|
}
|
|
2236
2242
|
}
|
|
2237
2243
|
}
|
|
2244
|
+
},
|
|
2245
|
+
"modifiers": {
|
|
2246
|
+
"accessibilityLabel": "$item.visibilityA11yLabel"
|
|
2238
2247
|
}
|
|
2239
|
-
}
|
|
2248
|
+
}
|
|
2249
|
+
]
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
"id": "",
|
|
2255
|
+
"body": {
|
|
2256
|
+
"package": "himalaya",
|
|
2257
|
+
"type": "HStack",
|
|
2258
|
+
"props": {
|
|
2259
|
+
"spacing": 8,
|
|
2260
|
+
"children": [
|
|
2240
2261
|
{
|
|
2241
|
-
"id": "",
|
|
2262
|
+
"id": "btn_tier5_himibrandedhome_homemoveup",
|
|
2242
2263
|
"body": {
|
|
2243
2264
|
"package": "himalaya",
|
|
2244
|
-
"type": "
|
|
2245
|
-
"props": {
|
|
2265
|
+
"type": "Button",
|
|
2266
|
+
"props": {
|
|
2267
|
+
"title": "Move up",
|
|
2268
|
+
"style": "plain",
|
|
2269
|
+
"action": {
|
|
2270
|
+
"actionId": "tier5.himiBrandedHome.homeMoveUp",
|
|
2271
|
+
"params": {
|
|
2272
|
+
"id": "$item.id"
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
},
|
|
2277
|
+
"modifiers": {
|
|
2278
|
+
"accessibilityLabel": "$item.moveUpA11yLabel",
|
|
2279
|
+
"hiddenPath": "$item.isFirst"
|
|
2246
2280
|
}
|
|
2247
2281
|
},
|
|
2248
2282
|
{
|
|
2249
|
-
"id": "
|
|
2283
|
+
"id": "btn_tier5_himibrandedhome_homemovedown",
|
|
2250
2284
|
"body": {
|
|
2251
2285
|
"package": "himalaya",
|
|
2252
2286
|
"type": "Button",
|
|
2253
2287
|
"props": {
|
|
2254
|
-
"title": "Move
|
|
2288
|
+
"title": "Move down",
|
|
2255
2289
|
"style": "plain",
|
|
2256
2290
|
"action": {
|
|
2257
|
-
"actionId": "tier5.himiBrandedHome.
|
|
2291
|
+
"actionId": "tier5.himiBrandedHome.homeMoveDown",
|
|
2258
2292
|
"params": {
|
|
2259
2293
|
"id": "$item.id"
|
|
2260
2294
|
}
|
|
2261
2295
|
}
|
|
2262
2296
|
}
|
|
2297
|
+
},
|
|
2298
|
+
"modifiers": {
|
|
2299
|
+
"accessibilityLabel": "$item.moveDownA11yLabel",
|
|
2300
|
+
"hiddenPath": "$item.isLast"
|
|
2263
2301
|
}
|
|
2264
2302
|
}
|
|
2265
2303
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineService as register, type ServiceDefinition } from '@himalaya/state';
|
|
2
2
|
import { normalizeHome, visibleHome, moduleIsEmpty, type HomeModule, type HomePreferences } from './home-modules.js';
|
|
3
|
-
import { copyParam, stashCopy } from './himi-copy.js';
|
|
3
|
+
import { copyParam, copyTemplate, stashCopy } from './himi-copy.js';
|
|
4
4
|
import { localPreferences } from './local-preferences.js';
|
|
5
5
|
type State = Record<string, unknown>;
|
|
6
6
|
type Action = (s: State, ...args: unknown[]) => State | undefined | Promise<State | undefined>;
|
|
@@ -32,10 +32,22 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
|
|
|
32
32
|
return { ...s, homeModules: { presented, visible: painted.map(id => ({ id })),
|
|
33
33
|
persistenceLabel: persisted.available ? copyParam('homeModules.onDevice', 'Saved on this device') : copyParam('homeModules.sessionOnly', 'Choices last for this session'),
|
|
34
34
|
slots: Object.fromEntries(modules.map((_, i) => [`slot${i}`, order[i] ?? 'empty'])),
|
|
35
|
-
choices: prefs.order.map(id =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
choices: prefs.order.map((id, index) => {
|
|
36
|
+
const module = modules.find(candidate => candidate.id === id);
|
|
37
|
+
const name = module?.label ?? id;
|
|
38
|
+
const isHidden = prefs.hidden.includes(id);
|
|
39
|
+
const isPinned = prefs.pinned.includes(id);
|
|
40
|
+
return { ...module,
|
|
41
|
+
isFirst: index === 0,
|
|
42
|
+
isLast: index === prefs.order.length - 1,
|
|
43
|
+
visibility: isHidden ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
|
|
44
|
+
pinLabel: isPinned ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
|
|
45
|
+
visibilityA11yLabel: copyTemplate(isHidden ? 'homeModules.showA11y' : 'homeModules.hideA11y', isHidden ? 'Show {module}' : 'Hide {module}', { module: name }),
|
|
46
|
+
pinA11yLabel: copyTemplate(isPinned ? 'homeModules.unpinA11y' : 'homeModules.pinA11y', isPinned ? 'Unpin {module}' : 'Pin {module}', { module: name }),
|
|
47
|
+
moveUpA11yLabel: copyTemplate('homeModules.moveUpA11y', 'Move {module} up', { module: name }),
|
|
48
|
+
moveDownA11yLabel: copyTemplate('homeModules.moveDownA11y', 'Move {module} down', { module: name }),
|
|
49
|
+
};
|
|
50
|
+
}) } };
|
|
39
51
|
};
|
|
40
52
|
const actions: Record<string, Action> = {};
|
|
41
53
|
for (const [name, action] of Object.entries(def.actions ?? {})) actions[name] = (s, ...args) => {
|
|
@@ -72,6 +84,7 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
|
|
|
72
84
|
actions.homeToggle = change(id => { if (modules.some(m => m.id === id)) prefs.hidden = prefs.hidden.includes(id) ? prefs.hidden.filter(x => x !== id) : [...prefs.hidden, id]; });
|
|
73
85
|
actions.homePin = change(id => { if (modules.some(m => m.id === id)) { prefs.pinned = prefs.pinned.includes(id) ? prefs.pinned.filter(x => x !== id) : [...prefs.pinned, id]; prefs.hidden = prefs.hidden.filter(x => x !== id); } });
|
|
74
86
|
actions.homeMoveUp = change(id => { const index = prefs.order.indexOf(id); if (index > 0) [prefs.order[index - 1], prefs.order[index]] = [prefs.order[index], prefs.order[index - 1]]; });
|
|
87
|
+
actions.homeMoveDown = change(id => { const index = prefs.order.indexOf(id); if (index >= 0 && index < prefs.order.length - 1) [prefs.order[index], prefs.order[index + 1]] = [prefs.order[index + 1], prefs.order[index]]; });
|
|
75
88
|
return { state: derive(def.state), actions };
|
|
76
89
|
}
|
|
77
90
|
export const defineService: typeof register = ((name: string, def: ServiceDefinition<unknown>) => register(name, decorateHome(def as unknown as { state: State; actions?: Record<string, Action> }))) as typeof register;
|