@wix/himalaya-cli 0.1261.0 → 0.1262.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/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 +45 -7
- package/templates/beauty-salon-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/community-club-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/events-meetups-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/gym-fitness-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/nonprofit-cause-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/owner-lite/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/podcast-creator-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/portfolio-creative-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/restaurant-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/retail-store-owner/tier5-src/_shared/home-service.ts +18 -5
- 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 +45 -7
- package/templates/yoga-studio-owner/tier5-src/_shared/home-service.ts +18 -5
- 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
|
@@ -50536,6 +50536,9 @@ const SCREENS = runtimeSetting({
|
|
|
50536
50536
|
"type": "BottomSheet",
|
|
50537
50537
|
"props": {
|
|
50538
50538
|
"presentedPath": "$service:himiOwnerLiteHome.homeModules.presented",
|
|
50539
|
+
"detents": [
|
|
50540
|
+
0.95
|
|
50541
|
+
],
|
|
50539
50542
|
"dismissible": true,
|
|
50540
50543
|
"showGrabber": true,
|
|
50541
50544
|
"onDismiss": {
|
|
@@ -50637,6 +50640,9 @@ const SCREENS = runtimeSetting({
|
|
|
50637
50640
|
}
|
|
50638
50641
|
}
|
|
50639
50642
|
}
|
|
50643
|
+
},
|
|
50644
|
+
"modifiers": {
|
|
50645
|
+
"accessibilityLabel": "$item.pinA11yLabel"
|
|
50640
50646
|
}
|
|
50641
50647
|
},
|
|
50642
50648
|
{
|
|
@@ -50654,31 +50660,63 @@ const SCREENS = runtimeSetting({
|
|
|
50654
50660
|
}
|
|
50655
50661
|
}
|
|
50656
50662
|
}
|
|
50663
|
+
},
|
|
50664
|
+
"modifiers": {
|
|
50665
|
+
"accessibilityLabel": "$item.visibilityA11yLabel"
|
|
50657
50666
|
}
|
|
50658
|
-
}
|
|
50667
|
+
}
|
|
50668
|
+
]
|
|
50669
|
+
}
|
|
50670
|
+
}
|
|
50671
|
+
},
|
|
50672
|
+
{
|
|
50673
|
+
"id": "",
|
|
50674
|
+
"body": {
|
|
50675
|
+
"package": "himalaya",
|
|
50676
|
+
"type": "HStack",
|
|
50677
|
+
"props": {
|
|
50678
|
+
"spacing": 8,
|
|
50679
|
+
"children": [
|
|
50659
50680
|
{
|
|
50660
|
-
"id": "",
|
|
50681
|
+
"id": "btn_tier5_himiownerlitehome_homemoveup",
|
|
50661
50682
|
"body": {
|
|
50662
50683
|
"package": "himalaya",
|
|
50663
|
-
"type": "
|
|
50664
|
-
"props": {
|
|
50684
|
+
"type": "Button",
|
|
50685
|
+
"props": {
|
|
50686
|
+
"title": "Move up",
|
|
50687
|
+
"style": "plain",
|
|
50688
|
+
"action": {
|
|
50689
|
+
"actionId": "tier5.himiOwnerLiteHome.homeMoveUp",
|
|
50690
|
+
"params": {
|
|
50691
|
+
"id": "$item.id"
|
|
50692
|
+
}
|
|
50693
|
+
}
|
|
50694
|
+
}
|
|
50695
|
+
},
|
|
50696
|
+
"modifiers": {
|
|
50697
|
+
"accessibilityLabel": "$item.moveUpA11yLabel",
|
|
50698
|
+
"hiddenPath": "$item.isFirst"
|
|
50665
50699
|
}
|
|
50666
50700
|
},
|
|
50667
50701
|
{
|
|
50668
|
-
"id": "
|
|
50702
|
+
"id": "btn_tier5_himiownerlitehome_homemovedown",
|
|
50669
50703
|
"body": {
|
|
50670
50704
|
"package": "himalaya",
|
|
50671
50705
|
"type": "Button",
|
|
50672
50706
|
"props": {
|
|
50673
|
-
"title": "Move
|
|
50707
|
+
"title": "Move down",
|
|
50674
50708
|
"style": "plain",
|
|
50675
50709
|
"action": {
|
|
50676
|
-
"actionId": "tier5.himiOwnerLiteHome.
|
|
50710
|
+
"actionId": "tier5.himiOwnerLiteHome.homeMoveDown",
|
|
50677
50711
|
"params": {
|
|
50678
50712
|
"id": "$item.id"
|
|
50679
50713
|
}
|
|
50680
50714
|
}
|
|
50681
50715
|
}
|
|
50716
|
+
},
|
|
50717
|
+
"modifiers": {
|
|
50718
|
+
"accessibilityLabel": "$item.moveDownA11yLabel",
|
|
50719
|
+
"hiddenPath": "$item.isLast"
|
|
50682
50720
|
}
|
|
50683
50721
|
}
|
|
50684
50722
|
]
|
|
@@ -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;
|
|
@@ -268,6 +268,7 @@ const svc = defineService<EventFormState, {
|
|
|
268
268
|
submit: async (s, values): Promise<EventFormState> => settleOverLive(svc, s, await (async (): Promise<EventFormState> => {
|
|
269
269
|
if (isOwnerPreviewDemo() || s.demoNote) return demoRefusal(s);
|
|
270
270
|
const v = values ?? {};
|
|
271
|
+
const targetId = s.id || (typeof v.id === "string" ? v.id : "");
|
|
271
272
|
const title = String(v.title ?? s.title).trim();
|
|
272
273
|
// The description, per record mode. A queue replay boots a FRESH worker and says so with
|
|
273
274
|
// `descriptionEdited`: this bundle's editor items add the document as `descriptionJson`; the
|
|
@@ -299,7 +300,7 @@ const svc = defineService<EventFormState, {
|
|
|
299
300
|
}
|
|
300
301
|
const description = doc ? postBodyText(doc as never) : s.description; // the plain-text mirror
|
|
301
302
|
if (!title) return shape({ ...s, status: "error", error: copyParam("ownerEventForm.titleRequired", "Title is required"), savedMessage: "" });
|
|
302
|
-
if (!
|
|
303
|
+
if (!targetId) return shape({ ...s, status: "error", error: copyParam("ownerEventForm.errorNoEvent", "No event to edit."), savedMessage: "" });
|
|
303
304
|
|
|
304
305
|
// updateEvent(id, event) wraps the body as { event } internally, so pass the event fields
|
|
305
306
|
// directly. Only what the owner edited is written, the description always as a Ricos document
|
|
@@ -315,22 +316,31 @@ const svc = defineService<EventFormState, {
|
|
|
315
316
|
// Plain only when KNOWN plain: a plain row, or a loaded event with no description. Before load
|
|
316
317
|
// lands nothing is known, so the row stays protected (fail closed).
|
|
317
318
|
const knownPlain = s.descriptionMode === "plain" || (s.descriptionMode === "editor" && !s.descriptionPending && s.descriptionJson === "");
|
|
318
|
-
|
|
319
|
+
const cached = replay && !s.id ? await cacheGet(targetId) : null;
|
|
320
|
+
// A queued metadata edit omitted the event body and read-only details. Keep their cached
|
|
321
|
+
// values rather than replacing them with a fresh worker's empty/default state.
|
|
322
|
+
await cachePut({
|
|
323
|
+
...(cached ?? {}), id: targetId, name: title, title,
|
|
324
|
+
description: doc ? description : String(cached?.description ?? description),
|
|
325
|
+
descriptionProtected: doc ? cachedRichVerdict(heldDoc as never, knownPlain) : String(cached?.descriptionProtected ?? cachedRichVerdict(heldDoc as never, knownPlain)),
|
|
326
|
+
...(heldJson ? { descriptionJson: heldJson } : {}),
|
|
327
|
+
when: String(cached?.when ?? s.when), location: String(cached?.location ?? s.location),
|
|
328
|
+
});
|
|
319
329
|
const savedState = (savedMessage: string) => {
|
|
320
330
|
// An edit typed while this save was in flight stays unsaved work ([rico] #3644).
|
|
321
331
|
const after = editorAfterSave("description", s as never, liveState(svc), !!doc);
|
|
322
332
|
return shape({
|
|
323
|
-
...s, mode: "edit", id:
|
|
333
|
+
...s, mode: "edit", id: targetId, heading: copyParam("ownerEventForm.headingEdit", "Edit event"),
|
|
324
334
|
title, description, originalDescription: doc ? description : s.originalDescription,
|
|
325
335
|
...(docRaw ? { descriptionJson: docRaw } : {}),
|
|
326
336
|
descriptionDirty: after.dirty, descriptionEdits: after.edits,
|
|
327
|
-
status: "saved", savedMessage, savedId:
|
|
337
|
+
status: "saved", savedMessage, savedId: targetId,
|
|
328
338
|
...(after.editedDuringSave ? { status: "idle" as const, savedMessage: "" } : {}),
|
|
329
339
|
error: tooLarge ? copyParam("ownerEventForm.descriptionTooLarge", "The description is too long to save, so it was left as it was. Your other changes were saved.") : "",
|
|
330
340
|
});
|
|
331
341
|
};
|
|
332
342
|
try {
|
|
333
|
-
await updateEvent(
|
|
343
|
+
await updateEvent(targetId, event);
|
|
334
344
|
return savedState(copyParam("ownerEventForm.savedMessage", "Event saved."));
|
|
335
345
|
} catch (e) {
|
|
336
346
|
if (shouldQueueOwnerWrite(e)) {
|
|
@@ -342,7 +352,7 @@ const svc = defineService<EventFormState, {
|
|
|
342
352
|
// (WriteQueue, idempotent) when connectivity returns. A document rides as `descriptionJson`
|
|
343
353
|
// with descriptionEdited "false", so a bundle rolled back past this change leaves the
|
|
344
354
|
// description rather than flattening it to text.
|
|
345
|
-
await queueWrite("tier5.himiOwnerLiteEventForm.submit", { id:
|
|
355
|
+
await queueWrite("tier5.himiOwnerLiteEventForm.submit", { id: targetId, title, description,
|
|
346
356
|
...(docRaw ? { descriptionJson: docRaw, descriptionEdited: "false" } : { descriptionEdited: String(doc !== null) }) });
|
|
347
357
|
return savedState(copyParam("ownerEventForm.savedOffline", "Saved offline — will sync when you reconnect."));
|
|
348
358
|
}
|
|
@@ -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,
|
|
@@ -172,13 +172,15 @@ const svc = defineService<ServiceFormState, {
|
|
|
172
172
|
submit: async (s, values) => {
|
|
173
173
|
if (isOwnerPreviewDemo() || s.demoNote) return demoRefusal(s);
|
|
174
174
|
const v = values ?? {};
|
|
175
|
+
const targetId = s.id || (typeof v.id === "string" ? v.id : "");
|
|
175
176
|
const name = String(v.name ?? s.name).trim();
|
|
176
177
|
const description = String(v.description ?? s.description).trim();
|
|
177
178
|
if (!name) return shape({ ...s, status: "error", error: copyParam("ownerServiceForm.nameRequired", "Name is required"), savedMessage: "" });
|
|
178
|
-
if (!
|
|
179
|
+
if (!targetId) return shape({ ...s, status: "error", error: copyParam("ownerServiceForm.errorNoService", "No service to edit."), savedMessage: "" });
|
|
179
180
|
|
|
180
181
|
// Optimistic local write — the detail/list repaint from cache immediately (offline or not).
|
|
181
|
-
const
|
|
182
|
+
const cached = !s.id ? await cacheGet(targetId) : null;
|
|
183
|
+
const localRow: DbEntity = { ...(cached ?? {}), id: targetId, name, title: name, description, category: s.category || String(cached?.category ?? "") };
|
|
182
184
|
await cachePut(localRow);
|
|
183
185
|
try {
|
|
184
186
|
// v2 PATCH is a masked update requiring the current `revision` (optimistic
|
|
@@ -186,13 +188,13 @@ const svc = defineService<ServiceFormState, {
|
|
|
186
188
|
// the UPDATED entity ({ service }) with its bumped revision — carry it
|
|
187
189
|
// into state, or the SECOND consecutive save would send the stale
|
|
188
190
|
// load-time revision and reject.
|
|
189
|
-
const res = await updateService(
|
|
191
|
+
const res = await updateService(targetId, { name, ...(description ? { description } : {}), ...(s.revision ? { revision: s.revision } : {}) });
|
|
190
192
|
const bumped = String((res?.service as { revision?: unknown } | undefined)?.revision ?? "");
|
|
191
193
|
return shape({
|
|
192
|
-
...s, name, description,
|
|
194
|
+
...s, id: targetId, name, description,
|
|
193
195
|
revision: bumped || s.revision,
|
|
194
196
|
status: "saved", error: "", savedMessage: copyParam("ownerServiceForm.savedMessage", "Service saved."),
|
|
195
|
-
savedId:
|
|
197
|
+
savedId: targetId,
|
|
196
198
|
});
|
|
197
199
|
} catch (e) {
|
|
198
200
|
if (shouldQueueOwnerWrite(e)) {
|
|
@@ -202,12 +204,12 @@ const svc = defineService<ServiceFormState, {
|
|
|
202
204
|
if (s.demoNote) return demoRefusal(s);
|
|
203
205
|
// Real device offline: the optimistic cache row already shows; queue the
|
|
204
206
|
// write to replay (WriteQueue, idempotent) when connectivity returns.
|
|
205
|
-
await queueWrite("tier5.himiOwnerLiteServiceForm.submit", { id:
|
|
207
|
+
await queueWrite("tier5.himiOwnerLiteServiceForm.submit", { id: targetId, name, description });
|
|
206
208
|
return shape({
|
|
207
|
-
...s, name, description,
|
|
209
|
+
...s, id: targetId, name, description,
|
|
208
210
|
status: "saved", error: "",
|
|
209
211
|
savedMessage: copyParam("ownerServiceForm.savedOffline", "Saved offline — will sync when you reconnect."),
|
|
210
|
-
savedId:
|
|
212
|
+
savedId: targetId,
|
|
211
213
|
});
|
|
212
214
|
}
|
|
213
215
|
return shape({ ...s, status: "error", error: ownerLoadError(e), savedMessage: "" });
|
|
@@ -1187,6 +1187,9 @@ const SCREENS = runtimeSetting({
|
|
|
1187
1187
|
"type": "BottomSheet",
|
|
1188
1188
|
"props": {
|
|
1189
1189
|
"presentedPath": "$service:himiBrandedHome.homeModules.presented",
|
|
1190
|
+
"detents": [
|
|
1191
|
+
0.95
|
|
1192
|
+
],
|
|
1190
1193
|
"dismissible": true,
|
|
1191
1194
|
"showGrabber": true,
|
|
1192
1195
|
"onDismiss": {
|
|
@@ -1288,6 +1291,9 @@ const SCREENS = runtimeSetting({
|
|
|
1288
1291
|
}
|
|
1289
1292
|
}
|
|
1290
1293
|
}
|
|
1294
|
+
},
|
|
1295
|
+
"modifiers": {
|
|
1296
|
+
"accessibilityLabel": "$item.pinA11yLabel"
|
|
1291
1297
|
}
|
|
1292
1298
|
},
|
|
1293
1299
|
{
|
|
@@ -1305,31 +1311,63 @@ const SCREENS = runtimeSetting({
|
|
|
1305
1311
|
}
|
|
1306
1312
|
}
|
|
1307
1313
|
}
|
|
1314
|
+
},
|
|
1315
|
+
"modifiers": {
|
|
1316
|
+
"accessibilityLabel": "$item.visibilityA11yLabel"
|
|
1308
1317
|
}
|
|
1309
|
-
}
|
|
1318
|
+
}
|
|
1319
|
+
]
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
"id": "",
|
|
1325
|
+
"body": {
|
|
1326
|
+
"package": "himalaya",
|
|
1327
|
+
"type": "HStack",
|
|
1328
|
+
"props": {
|
|
1329
|
+
"spacing": 8,
|
|
1330
|
+
"children": [
|
|
1310
1331
|
{
|
|
1311
|
-
"id": "",
|
|
1332
|
+
"id": "btn_tier5_himibrandedhome_homemoveup",
|
|
1312
1333
|
"body": {
|
|
1313
1334
|
"package": "himalaya",
|
|
1314
|
-
"type": "
|
|
1315
|
-
"props": {
|
|
1335
|
+
"type": "Button",
|
|
1336
|
+
"props": {
|
|
1337
|
+
"title": "Move up",
|
|
1338
|
+
"style": "plain",
|
|
1339
|
+
"action": {
|
|
1340
|
+
"actionId": "tier5.himiBrandedHome.homeMoveUp",
|
|
1341
|
+
"params": {
|
|
1342
|
+
"id": "$item.id"
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
},
|
|
1347
|
+
"modifiers": {
|
|
1348
|
+
"accessibilityLabel": "$item.moveUpA11yLabel",
|
|
1349
|
+
"hiddenPath": "$item.isFirst"
|
|
1316
1350
|
}
|
|
1317
1351
|
},
|
|
1318
1352
|
{
|
|
1319
|
-
"id": "
|
|
1353
|
+
"id": "btn_tier5_himibrandedhome_homemovedown",
|
|
1320
1354
|
"body": {
|
|
1321
1355
|
"package": "himalaya",
|
|
1322
1356
|
"type": "Button",
|
|
1323
1357
|
"props": {
|
|
1324
|
-
"title": "Move
|
|
1358
|
+
"title": "Move down",
|
|
1325
1359
|
"style": "plain",
|
|
1326
1360
|
"action": {
|
|
1327
|
-
"actionId": "tier5.himiBrandedHome.
|
|
1361
|
+
"actionId": "tier5.himiBrandedHome.homeMoveDown",
|
|
1328
1362
|
"params": {
|
|
1329
1363
|
"id": "$item.id"
|
|
1330
1364
|
}
|
|
1331
1365
|
}
|
|
1332
1366
|
}
|
|
1367
|
+
},
|
|
1368
|
+
"modifiers": {
|
|
1369
|
+
"accessibilityLabel": "$item.moveDownA11yLabel",
|
|
1370
|
+
"hiddenPath": "$item.isLast"
|
|
1333
1371
|
}
|
|
1334
1372
|
}
|
|
1335
1373
|
]
|
|
@@ -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;
|
|
@@ -50382,6 +50382,9 @@ const SCREENS = runtimeSetting({
|
|
|
50382
50382
|
"type": "BottomSheet",
|
|
50383
50383
|
"props": {
|
|
50384
50384
|
"presentedPath": "$service:himiOwnerLiteHome.homeModules.presented",
|
|
50385
|
+
"detents": [
|
|
50386
|
+
0.95
|
|
50387
|
+
],
|
|
50385
50388
|
"dismissible": true,
|
|
50386
50389
|
"showGrabber": true,
|
|
50387
50390
|
"onDismiss": {
|
|
@@ -50483,6 +50486,9 @@ const SCREENS = runtimeSetting({
|
|
|
50483
50486
|
}
|
|
50484
50487
|
}
|
|
50485
50488
|
}
|
|
50489
|
+
},
|
|
50490
|
+
"modifiers": {
|
|
50491
|
+
"accessibilityLabel": "$item.pinA11yLabel"
|
|
50486
50492
|
}
|
|
50487
50493
|
},
|
|
50488
50494
|
{
|
|
@@ -50500,31 +50506,63 @@ const SCREENS = runtimeSetting({
|
|
|
50500
50506
|
}
|
|
50501
50507
|
}
|
|
50502
50508
|
}
|
|
50509
|
+
},
|
|
50510
|
+
"modifiers": {
|
|
50511
|
+
"accessibilityLabel": "$item.visibilityA11yLabel"
|
|
50503
50512
|
}
|
|
50504
|
-
}
|
|
50513
|
+
}
|
|
50514
|
+
]
|
|
50515
|
+
}
|
|
50516
|
+
}
|
|
50517
|
+
},
|
|
50518
|
+
{
|
|
50519
|
+
"id": "",
|
|
50520
|
+
"body": {
|
|
50521
|
+
"package": "himalaya",
|
|
50522
|
+
"type": "HStack",
|
|
50523
|
+
"props": {
|
|
50524
|
+
"spacing": 8,
|
|
50525
|
+
"children": [
|
|
50505
50526
|
{
|
|
50506
|
-
"id": "",
|
|
50527
|
+
"id": "btn_tier5_himiownerlitehome_homemoveup",
|
|
50507
50528
|
"body": {
|
|
50508
50529
|
"package": "himalaya",
|
|
50509
|
-
"type": "
|
|
50510
|
-
"props": {
|
|
50530
|
+
"type": "Button",
|
|
50531
|
+
"props": {
|
|
50532
|
+
"title": "Move up",
|
|
50533
|
+
"style": "plain",
|
|
50534
|
+
"action": {
|
|
50535
|
+
"actionId": "tier5.himiOwnerLiteHome.homeMoveUp",
|
|
50536
|
+
"params": {
|
|
50537
|
+
"id": "$item.id"
|
|
50538
|
+
}
|
|
50539
|
+
}
|
|
50540
|
+
}
|
|
50541
|
+
},
|
|
50542
|
+
"modifiers": {
|
|
50543
|
+
"accessibilityLabel": "$item.moveUpA11yLabel",
|
|
50544
|
+
"hiddenPath": "$item.isFirst"
|
|
50511
50545
|
}
|
|
50512
50546
|
},
|
|
50513
50547
|
{
|
|
50514
|
-
"id": "
|
|
50548
|
+
"id": "btn_tier5_himiownerlitehome_homemovedown",
|
|
50515
50549
|
"body": {
|
|
50516
50550
|
"package": "himalaya",
|
|
50517
50551
|
"type": "Button",
|
|
50518
50552
|
"props": {
|
|
50519
|
-
"title": "Move
|
|
50553
|
+
"title": "Move down",
|
|
50520
50554
|
"style": "plain",
|
|
50521
50555
|
"action": {
|
|
50522
|
-
"actionId": "tier5.himiOwnerLiteHome.
|
|
50556
|
+
"actionId": "tier5.himiOwnerLiteHome.homeMoveDown",
|
|
50523
50557
|
"params": {
|
|
50524
50558
|
"id": "$item.id"
|
|
50525
50559
|
}
|
|
50526
50560
|
}
|
|
50527
50561
|
}
|
|
50562
|
+
},
|
|
50563
|
+
"modifiers": {
|
|
50564
|
+
"accessibilityLabel": "$item.moveDownA11yLabel",
|
|
50565
|
+
"hiddenPath": "$item.isLast"
|
|
50528
50566
|
}
|
|
50529
50567
|
}
|
|
50530
50568
|
]
|
|
@@ -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;
|