@mohasinac/appkit 4.21.0 → 4.23.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/_internal/server/features/checkout/locked-lines.js +12 -2
- package/dist/_internal/server/features/stores/adapters.d.ts +1 -1
- package/dist/_internal/server/features/stores/adapters.js +5 -0
- package/dist/_internal/server/jobs/core/auctionSettlement.js +10 -4
- package/dist/_internal/server/jobs/core/offerExpiry.js +10 -2
- package/dist/_internal/server/jobs/core/payoutBatch.js +15 -3
- package/dist/_internal/shared/features/products/schema.d.ts +8 -8
- package/dist/_internal/shared/features/promotions/schema.d.ts +4 -4
- package/dist/_internal/shared/history/index.d.ts +1 -1
- package/dist/_internal/shared/history/types.d.ts +16 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +4 -0
- package/dist/constants/field-names.d.ts +12 -0
- package/dist/constants/field-names.js +12 -0
- package/dist/features/account/components/AddressForm.js +45 -29
- package/dist/features/admin/actions/admin-actions.js +13 -3
- package/dist/features/admin/components/AdminBidsView.js +7 -1
- package/dist/features/admin/components/AdminBundleEditorView.js +3 -0
- package/dist/features/admin/components/AdminScammerEditorView.d.ts +5 -1
- package/dist/features/admin/components/AdminScammerEditorView.js +3 -2
- package/dist/features/admin/components/AdminSupportTicketDetailView.d.ts +5 -1
- package/dist/features/admin/components/AdminSupportTicketDetailView.js +3 -2
- package/dist/features/auctions/components/PlaceBidFormClient.js +3 -1
- package/dist/features/auctions/repository/bid.repository.d.ts +21 -8
- package/dist/features/auctions/repository/bid.repository.js +57 -33
- package/dist/features/auctions/schemas/firestore.d.ts +27 -0
- package/dist/features/auctions/schemas/firestore.js +21 -0
- package/dist/features/auth/schemas/index.d.ts +2 -2
- package/dist/features/catalogue/actions/approve-catalogue-listing.js +7 -6
- package/dist/features/catalogue/actions/list-from-catalogue.js +2 -2
- package/dist/features/catalogue/actions/submit-for-approval.js +1 -4
- package/dist/features/catalogue/components/AdminCatalogueApprovalsView.js +5 -1
- package/dist/features/catalogue/components/CatalogueItemEditorView.js +3 -1
- package/dist/features/catalogue/repository/catalogue.repository.d.ts +23 -0
- package/dist/features/catalogue/repository/catalogue.repository.js +28 -1
- package/dist/features/catalogue/schemas/firestore.d.ts +19 -0
- package/dist/features/catalogue/schemas/firestore.js +12 -0
- package/dist/features/categories/schemas/index.d.ts +2 -2
- package/dist/features/layout/BottomActions.js +18 -1
- package/dist/features/layout/BottomActionsContext.d.ts +19 -0
- package/dist/features/layout/BottomActionsContext.js +37 -0
- package/dist/features/layout/hooks/useBottomActions.d.ts +10 -0
- package/dist/features/layout/hooks/useBottomActions.js +48 -11
- package/dist/features/layout/hooks/useFormBottomActions.d.ts +57 -0
- package/dist/features/layout/hooks/useFormBottomActions.js +89 -0
- package/dist/features/layout/index.d.ts +2 -0
- package/dist/features/layout/index.js +1 -0
- package/dist/features/messages/schemas/index.d.ts +6 -6
- package/dist/features/orders/schemas/index.d.ts +12 -12
- package/dist/features/payments/repository/payout.repository.d.ts +18 -5
- package/dist/features/payments/repository/payout.repository.js +45 -19
- package/dist/features/payments/schemas/firestore.d.ts +33 -1
- package/dist/features/payments/schemas/firestore.js +39 -0
- package/dist/features/payments/schemas/index.d.ts +12 -12
- package/dist/features/products/components/MakeOfferButton.js +5 -3
- package/dist/features/products/schemas/index.d.ts +2 -2
- package/dist/features/promotions/schemas/index.d.ts +12 -12
- package/dist/features/scams/repository/scammer.repository.d.ts +18 -1
- package/dist/features/scams/repository/scammer.repository.js +24 -2
- package/dist/features/scams/schemas/firestore.d.ts +24 -0
- package/dist/features/scams/schemas/firestore.js +30 -0
- package/dist/features/shell/QuickFormDrawer.js +15 -1
- package/dist/features/shell/SectionForm.d.ts +16 -2
- package/dist/features/shell/SectionForm.js +28 -2
- package/dist/features/shipments/components/AdminShipmentEditorView.js +5 -2
- package/dist/features/shipments/repository/shipments.repository.d.ts +18 -0
- package/dist/features/shipments/repository/shipments.repository.js +23 -1
- package/dist/features/shipments/schemas/firestore.d.ts +14 -0
- package/dist/features/shipments/schemas/firestore.js +19 -0
- package/dist/features/status-history/components/RecordStatusTimeline.d.ts +12 -0
- package/dist/features/status-history/components/RecordStatusTimeline.js +90 -0
- package/dist/features/status-history/index.d.ts +2 -0
- package/dist/features/status-history/index.js +1 -0
- package/dist/features/stores/repository/store.repository.d.ts +30 -2
- package/dist/features/stores/repository/store.repository.js +43 -4
- package/dist/features/stores/schemas/firestore.d.ts +29 -0
- package/dist/features/stores/schemas/firestore.js +31 -0
- package/dist/features/support/repository/support.repository.d.ts +47 -3
- package/dist/features/support/repository/support.repository.js +72 -12
- package/dist/features/support/schemas/firestore.d.ts +38 -1
- package/dist/features/support/schemas/firestore.js +34 -0
- package/dist/features/support/schemas/index.d.ts +2 -2
- package/dist/features/tester/seed-data/tester-checklist-seed-data.js +90 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +16 -1
- package/dist/schemas/registry.d.ts +32 -32
- package/dist/seed/bids-seed-data.js +8 -0
- package/dist/ui/components/Form.d.ts +22 -1
- package/dist/ui/components/Form.js +30 -2
- package/dist/ui/components/Modal.js +4 -3
- package/dist/ui/components/SideDrawer.js +5 -4
- package/dist/ui/components/overlay-context.d.ts +21 -0
- package/dist/ui/components/overlay-context.js +25 -0
- package/dist/ui/forms/FormErrorList.d.ts +29 -0
- package/dist/ui/forms/FormErrorList.js +36 -0
- package/dist/ui/forms/FormErrorSummary.d.ts +8 -0
- package/dist/ui/forms/FormErrorSummary.js +15 -8
- package/dist/ui/forms/FormShell.d.ts +25 -1
- package/dist/ui/forms/FormShell.js +39 -4
- package/dist/ui/forms/index.d.ts +2 -0
- package/dist/ui/forms/index.js +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useContext } from "react";
|
|
4
4
|
import { FormShellContext } from "./FormShell";
|
|
5
|
-
import {
|
|
5
|
+
import { FormErrorList } from "./FormErrorList";
|
|
6
6
|
/**
|
|
7
7
|
* Shared, live validation-error summary — supplements (does not replace) the
|
|
8
8
|
* per-field inline errors `FieldInput`/`FieldSelect`/`FormField` already
|
|
@@ -11,6 +11,14 @@ import { Span } from "../components/Typography";
|
|
|
11
11
|
* error immediately as fields change — not gated by `touched`, unlike the
|
|
12
12
|
* inline per-field errors.
|
|
13
13
|
*
|
|
14
|
+
* 🛑 It IS gated on `ctx.submitAttempted`, and must stay that way. The
|
|
15
|
+
* summary speaks about fields the user has not reached yet, so before a
|
|
16
|
+
* submit it reads as a list of accusations rather than of mistakes — and
|
|
17
|
+
* ~20 views run `validate(draft)` in a mount effect, so an untouched empty
|
|
18
|
+
* draft fails every `.min(1)` on first paint. Gate the DISPLAY only: the
|
|
19
|
+
* live validation underneath is what keeps this list shrinking as the user
|
|
20
|
+
* fixes things after a failed submit, which is the whole point of it.
|
|
21
|
+
*
|
|
14
22
|
* For multi-step forms whose step engine populates
|
|
15
23
|
* `FormShellContextValue.fieldToStepIndex`, each entry names its owning step
|
|
16
24
|
* and is clickable to jump there. Falls back to a flat list when no step
|
|
@@ -23,15 +31,14 @@ export function FormErrorSummary({ hideWhenEmpty = true, className, title = "Ple
|
|
|
23
31
|
const ctx = useContext(FormShellContext);
|
|
24
32
|
if (!ctx)
|
|
25
33
|
return null;
|
|
34
|
+
// Nothing to say until they've tried. See the header.
|
|
35
|
+
if (!ctx.submitAttempted)
|
|
36
|
+
return null;
|
|
26
37
|
const entries = Object.entries(ctx.errors);
|
|
38
|
+
// `hideWhenEmpty` is the only reason an empty list would render at all —
|
|
39
|
+
// as an empty titled block confirming there is nothing to fix.
|
|
27
40
|
if (entries.length === 0 && hideWhenEmpty)
|
|
28
41
|
return null;
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
return (_jsxs("div", { role: "alert", "aria-live": "polite", className: ["appkit-formshell__error-summary", className].filter(Boolean).join(" "), children: [_jsx("div", { className: "appkit-formshell__error-summary__title", children: title }), _jsx("ul", { className: "appkit-formshell__error-summary__list", children: entries.map(([key, message]) => {
|
|
32
|
-
const stepIndex = ctx.fieldToStepIndex?.[key];
|
|
33
|
-
const stepLabel = stepIndex != null ? ctx.steps[stepIndex]?.label : undefined;
|
|
34
|
-
return (_jsx("li", { children: stepLabel ? (_jsxs("button", { type: "button", className: "appkit-formshell__error-summary__step-link", onClick: () => ctx.goToStep(stepIndex), children: [_jsxs(Span, { weight: "semibold", children: [stepLabel, ":"] }), " ", message] })) : (_jsx(Span, { children: message })) }, key));
|
|
35
|
-
}) })] }));
|
|
42
|
+
return (_jsxs("div", { role: "alert", "aria-live": "polite", className: ["appkit-formshell__error-summary", className].filter(Boolean).join(" "), children: [_jsx("div", { className: "appkit-formshell__error-summary__title", children: title }), _jsx(FormErrorList, {})] }));
|
|
36
43
|
}
|
|
37
44
|
export default FormErrorSummary;
|
|
@@ -56,6 +56,19 @@ export interface FormShellContextValue {
|
|
|
56
56
|
* treats undefined as "no step context" and renders a flat list.
|
|
57
57
|
*/
|
|
58
58
|
fieldToStepIndex?: Record<string, number>;
|
|
59
|
+
submitAttempted: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* How many times. `submitAttempted` is `submitAttemptCount > 0` — DERIVED
|
|
62
|
+
* at the one place each producer builds this object, never stored twice.
|
|
63
|
+
*
|
|
64
|
+
* The count exists because a boolean cannot express "this is a NEW
|
|
65
|
+
* attempt". The mobile error sheet force-opens on a bumped counter, so
|
|
66
|
+
* pressing Save a second time re-opens a sheet the user had collapsed,
|
|
67
|
+
* while an ordinary re-render does not.
|
|
68
|
+
*/
|
|
69
|
+
submitAttemptCount: number;
|
|
70
|
+
/** Call from a submit handler, before validating. */
|
|
71
|
+
markSubmitAttempted: () => void;
|
|
59
72
|
}
|
|
60
73
|
export declare const FormShellContext: React.Context<FormShellContextValue | null>;
|
|
61
74
|
export declare function useFormShell(): FormShellContextValue;
|
|
@@ -70,6 +83,16 @@ export interface UseFormShellStateResult {
|
|
|
70
83
|
* parsed value on success or null on failure.
|
|
71
84
|
*/
|
|
72
85
|
validate: <T = unknown>(values: unknown) => T | null;
|
|
86
|
+
/** True once the user has actually tried to submit. Gates <FormErrorSummary>. */
|
|
87
|
+
submitAttempted: boolean;
|
|
88
|
+
/** See FormShellContextValue.submitAttemptCount. */
|
|
89
|
+
submitAttemptCount: number;
|
|
90
|
+
/**
|
|
91
|
+
* Record a submit attempt. `<Form>` / `<SectionForm>` / `<QuickFormDrawer>`
|
|
92
|
+
* call this for you; call it directly only when your submit control is a
|
|
93
|
+
* `type="button"` with an `onClick`, so no native submit event fires.
|
|
94
|
+
*/
|
|
95
|
+
markSubmitAttempted: () => void;
|
|
73
96
|
}
|
|
74
97
|
/**
|
|
75
98
|
* `applyZodIssues` — pipe every issue from a Zod safeParse failure into the
|
|
@@ -135,5 +158,6 @@ export interface FormShellProviderProps {
|
|
|
135
158
|
* used to be hardcoded `[]`. Supply alongside `fieldToStepIndex`.
|
|
136
159
|
*/
|
|
137
160
|
sections?: FormShellStep[];
|
|
161
|
+
submitAttempted?: boolean;
|
|
138
162
|
}
|
|
139
|
-
export declare function FormShellProvider({ children, onSaveDraft, isDirty, autoSaveDelayMs, values, schema, fieldToStepIndex, onGoToStep, sections, }: FormShellProviderProps): React.JSX.Element;
|
|
163
|
+
export declare function FormShellProvider({ children, onSaveDraft, isDirty, autoSaveDelayMs, values, schema, fieldToStepIndex, onGoToStep, sections, submitAttempted: submitAttemptedProp, }: FormShellProviderProps): React.JSX.Element;
|
|
@@ -45,6 +45,9 @@ export function applyZodIssues(issues, setFieldError) {
|
|
|
45
45
|
*/
|
|
46
46
|
export function useFormShellState(schema, nav) {
|
|
47
47
|
const [errors, setErrors] = useState({});
|
|
48
|
+
const [submitAttemptCount, setSubmitAttemptCount] = useState(0);
|
|
49
|
+
const markSubmitAttempted = useCallback(() => setSubmitAttemptCount((n) => n + 1), []);
|
|
50
|
+
const submitAttempted = submitAttemptCount > 0;
|
|
48
51
|
const setFieldError = useCallback((name, error) => {
|
|
49
52
|
setErrors((prev) => {
|
|
50
53
|
if (!error) {
|
|
@@ -59,6 +62,19 @@ export function useFormShellState(schema, nav) {
|
|
|
59
62
|
}, []);
|
|
60
63
|
const clearErrors = useCallback(() => setErrors({}), []);
|
|
61
64
|
const validate = useCallback((values) => {
|
|
65
|
+
/*
|
|
66
|
+
* 🛑 validate() does NOT mark the submit attempt, and must not.
|
|
67
|
+
*
|
|
68
|
+
* ELEVEN views call `validate(draft)` from a MOUNT EFFECT to keep the
|
|
69
|
+
* summary and the submit-button state live as the user types — which
|
|
70
|
+
* is the behaviour worth having. Marking here would fire on first
|
|
71
|
+
* paint in exactly those views and defeat the gate entirely.
|
|
72
|
+
*
|
|
73
|
+
* The attempt is marked where an attempt actually happens: <Form>'s
|
|
74
|
+
* native submit handler, <SectionForm>'s submit button, and
|
|
75
|
+
* QuickFormDrawer's. A caller whose submit is an onClick on a
|
|
76
|
+
* type="button" calls markSubmitAttempted() itself.
|
|
77
|
+
*/
|
|
62
78
|
if (!schema)
|
|
63
79
|
return values;
|
|
64
80
|
const parsed = schema.safeParse(values);
|
|
@@ -90,12 +106,28 @@ export function useFormShellState(schema, nav) {
|
|
|
90
106
|
isSubmitting: false,
|
|
91
107
|
stepErrorCounts: [],
|
|
92
108
|
fieldToStepIndex: navFieldMap,
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
submitAttempted,
|
|
110
|
+
submitAttemptCount,
|
|
111
|
+
markSubmitAttempted,
|
|
112
|
+
}), [errors, setFieldError, navSections, navGoTo, navFieldMap, submitAttempted, submitAttemptCount, markSubmitAttempted]);
|
|
113
|
+
return {
|
|
114
|
+
shellCtx,
|
|
115
|
+
setFieldError,
|
|
116
|
+
clearErrors,
|
|
117
|
+
hasErrors: Object.keys(errors).length > 0,
|
|
118
|
+
validate,
|
|
119
|
+
submitAttempted,
|
|
120
|
+
submitAttemptCount,
|
|
121
|
+
markSubmitAttempted,
|
|
122
|
+
};
|
|
95
123
|
}
|
|
96
|
-
export function FormShellProvider({ children, onSaveDraft, isDirty = false, autoSaveDelayMs = 2000, values = {}, schema, fieldToStepIndex, onGoToStep, sections, }) {
|
|
124
|
+
export function FormShellProvider({ children, onSaveDraft, isDirty = false, autoSaveDelayMs = 2000, values = {}, schema, fieldToStepIndex, onGoToStep, sections, submitAttempted: submitAttemptedProp = false, }) {
|
|
97
125
|
const [errors, setErrors] = useState({});
|
|
98
126
|
const [touched, setTouched] = useState({});
|
|
127
|
+
const [ownAttemptCount, setOwnAttemptCount] = useState(0);
|
|
128
|
+
const markSubmitAttempted = useCallback(() => setOwnAttemptCount((n) => n + 1), []);
|
|
129
|
+
const submitAttemptCount = ownAttemptCount + (submitAttemptedProp ? 1 : 0);
|
|
130
|
+
const submitAttempted = submitAttemptCount > 0;
|
|
99
131
|
const autoSaveTimer = useRef(null);
|
|
100
132
|
const valuesRef = useRef(values);
|
|
101
133
|
valuesRef.current = values;
|
|
@@ -169,6 +201,9 @@ export function FormShellProvider({ children, onSaveDraft, isDirty = false, auto
|
|
|
169
201
|
isSubmitting: false,
|
|
170
202
|
stepErrorCounts: [],
|
|
171
203
|
fieldToStepIndex,
|
|
172
|
-
|
|
204
|
+
submitAttempted,
|
|
205
|
+
submitAttemptCount,
|
|
206
|
+
markSubmitAttempted,
|
|
207
|
+
}), [errors, touched, setFieldError, setFieldTouched, clearFieldError, isDirty, onGoToStep, fieldToStepIndex, sections, submitAttempted, submitAttemptCount, markSubmitAttempted]);
|
|
173
208
|
return _jsx(FormShellContext.Provider, { value: ctx, children: children });
|
|
174
209
|
}
|
package/dist/ui/forms/index.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export type { ColorPickerFieldProps } from "./ColorPickerField";
|
|
|
12
12
|
export { ColorPickerField } from "./ColorPickerField";
|
|
13
13
|
export type { FormErrorSummaryProps } from "./FormErrorSummary";
|
|
14
14
|
export { FormErrorSummary } from "./FormErrorSummary";
|
|
15
|
+
export type { FormErrorListProps } from "./FormErrorList";
|
|
16
|
+
export { FormErrorList } from "./FormErrorList";
|
package/dist/ui/forms/index.js
CHANGED