@wilshop/dashboard 3.5.5 → 3.5.7
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/plugin/dashboard.plugin.d.ts +1 -1
- package/dist/plugin/dashboard.plugin.js +1 -1
- package/dist/vite/utils/compiler.js +50 -24
- package/dist/vite/utils/path-transformer.d.ts +20 -0
- package/dist/vite/utils/path-transformer.js +116 -0
- package/dist/vite/utils/plugin-discovery.js +3 -2
- package/dist/vite/utils/ui-config.js +15 -1
- package/dist/vite/vite-plugin-lingui-babel.d.ts +15 -2
- package/dist/vite/vite-plugin-lingui-babel.js +92 -17
- package/dist/vite/vite-plugin-translations.js +2 -2
- package/dist/vite/vite-plugin-ui-config.d.ts +31 -0
- package/package.json +10 -6
- package/src/app/common/delete-bulk-action.tsx +1 -1
- package/src/app/common/duplicate-bulk-action.tsx +1 -1
- package/src/app/routes/_authenticated/_collections/collections.graphql.ts +1 -3
- package/src/app/routes/_authenticated/_collections/collections.tsx +169 -48
- package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +36 -5
- package/src/app/routes/_authenticated/_collections/components/collection-bulk-actions.tsx +1 -1
- package/src/app/routes/_authenticated/_collections/components/collection-filters-selector.tsx +7 -1
- package/src/app/routes/_authenticated/_customers/components/customer-history/default-customer-history-components.tsx +31 -29
- package/src/app/routes/_authenticated/_customers/customers.graphql.ts +1 -0
- package/src/app/routes/_authenticated/_customers/customers.tsx +3 -0
- package/src/app/routes/_authenticated/_global-settings/global-settings.tsx +1 -1
- package/src/app/routes/_authenticated/_orders/components/draft-order-status.tsx +48 -0
- package/src/app/routes/_authenticated/_orders/components/fulfill-order-dialog.tsx +8 -5
- package/src/app/routes/_authenticated/_orders/components/order-detail-shared.tsx +79 -54
- package/src/app/routes/_authenticated/_orders/components/order-history/default-order-history-components.tsx +43 -3
- package/src/app/routes/_authenticated/_orders/components/order-history/order-history-utils.tsx +19 -3
- package/src/app/routes/_authenticated/_orders/components/order-table.tsx +1 -0
- package/src/app/routes/_authenticated/_orders/components/refund-order-dialog.tsx +372 -0
- package/src/app/routes/_authenticated/_orders/hooks/use-refund-order.ts +345 -0
- package/src/app/routes/_authenticated/_orders/orders.graphql.ts +41 -0
- package/src/app/routes/_authenticated/_orders/orders_.draft.$id.tsx +22 -6
- package/src/app/routes/_authenticated/_orders/utils/order-utils.ts +51 -0
- package/src/app/routes/_authenticated/_orders/utils/refund-utils.ts +100 -0
- package/src/app/routes/_authenticated/_orders/utils/use-modify-order.ts +1 -1
- package/src/app/routes/_authenticated/_payment-methods/components/payment-eligibility-checker-selector.tsx +4 -1
- package/src/app/routes/_authenticated/_payment-methods/components/payment-handler-selector.tsx +7 -1
- package/src/app/routes/_authenticated/_payment-methods/payment-methods_.$id.tsx +18 -2
- package/src/app/routes/_authenticated/_product-variants/components/product-variant-bulk-actions.tsx +1 -1
- package/src/app/routes/_authenticated/_product-variants/components/variant-price-detail.tsx +6 -2
- package/src/app/routes/_authenticated/_product-variants/product-variants.graphql.ts +9 -3
- package/src/app/routes/_authenticated/_product-variants/product-variants_.$id.tsx +49 -30
- package/src/app/routes/_authenticated/_products/components/product-bulk-actions.tsx +1 -1
- package/src/app/routes/_authenticated/_profile/profile.graphql.ts +7 -0
- package/src/app/routes/_authenticated/_profile/profile.tsx +25 -1
- package/src/app/routes/_authenticated/_promotions/components/promotion-actions-selector.tsx +7 -1
- package/src/app/routes/_authenticated/_promotions/components/promotion-conditions-selector.tsx +7 -1
- package/src/app/routes/_authenticated/_promotions/promotions_.$id.tsx +18 -2
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-calculator-selector.tsx +7 -1
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-eligibility-checker-selector.tsx +4 -1
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods_.$id.tsx +14 -2
- package/src/i18n/common-strings.ts +7 -0
- package/src/i18n/locales/ar.po +669 -399
- package/src/i18n/locales/bg.po +1889 -46
- package/src/i18n/locales/cs.po +676 -406
- package/src/i18n/locales/de.po +676 -406
- package/src/i18n/locales/en.po +669 -399
- package/src/i18n/locales/es.po +676 -406
- package/src/i18n/locales/fa.po +676 -406
- package/src/i18n/locales/fr.po +676 -406
- package/src/i18n/locales/he.po +676 -406
- package/src/i18n/locales/hr.po +676 -406
- package/src/i18n/locales/it.po +676 -406
- package/src/i18n/locales/ja.po +676 -406
- package/src/i18n/locales/nb.po +676 -406
- package/src/i18n/locales/ne.po +676 -406
- package/src/i18n/locales/pl.po +676 -406
- package/src/i18n/locales/pt_BR.po +676 -406
- package/src/i18n/locales/pt_PT.po +676 -406
- package/src/i18n/locales/ru.po +676 -406
- package/src/i18n/locales/sv.po +676 -406
- package/src/i18n/locales/tr.po +676 -406
- package/src/i18n/locales/uk.po +676 -406
- package/src/i18n/locales/zh_Hans.po +676 -406
- package/src/i18n/locales/zh_Hant.po +676 -406
- package/src/lib/components/data-input/facet-value-input.tsx +2 -2
- package/src/lib/components/data-input/index.ts +1 -0
- package/src/lib/components/data-input/select-with-options.tsx +23 -7
- package/src/lib/components/data-input/struct-form-input.tsx +53 -21
- package/src/lib/components/data-input/text-input.tsx +1 -1
- package/src/lib/components/data-table/data-table-bulk-actions.tsx +2 -1
- package/src/lib/components/data-table/data-table-context.tsx +2 -10
- package/src/lib/components/data-table/data-table-utils.ts +34 -12
- package/src/lib/components/data-table/data-table.tsx +68 -30
- package/src/lib/components/data-table/global-views-bar.tsx +1 -1
- package/src/lib/components/data-table/my-views-button.tsx +1 -1
- package/src/lib/components/data-table/save-view-button.tsx +1 -1
- package/src/lib/components/data-table/use-generated-columns.tsx +9 -2
- package/src/lib/components/data-table/views-sheet.tsx +1 -1
- package/src/lib/components/layout/channel-switcher.tsx +16 -17
- package/src/lib/components/layout/manage-languages-dialog.tsx +1 -1
- package/src/lib/components/shared/assign-to-channel-bulk-action.tsx +1 -1
- package/src/lib/components/shared/configurable-operation-input.tsx +23 -0
- package/src/lib/components/shared/configurable-operation-multi-selector.tsx +45 -0
- package/src/lib/components/shared/configurable-operation-selector.tsx +5 -0
- package/src/lib/components/shared/paginated-list-context.ts +10 -0
- package/src/lib/components/shared/paginated-list-data-table.tsx +6 -32
- package/src/lib/components/shared/remove-from-channel-bulk-action.tsx +1 -1
- package/src/lib/components/ui/alert.tsx +2 -0
- package/src/lib/constants.ts +7 -319
- package/src/lib/framework/dashboard-widget/base-widget.tsx +3 -12
- package/src/lib/framework/dashboard-widget/latest-orders-widget/index.tsx +1 -1
- package/src/lib/framework/dashboard-widget/metrics-widget/chart.tsx +1 -1
- package/src/lib/framework/dashboard-widget/metrics-widget/index.tsx +1 -1
- package/src/lib/framework/dashboard-widget/orders-summary/index.tsx +1 -1
- package/src/lib/framework/dashboard-widget/widget-filters-context.tsx +2 -20
- package/src/lib/framework/extension-api/input-component-extensions.tsx +4 -0
- package/src/lib/framework/form-engine/custom-form-component.tsx +13 -3
- package/src/lib/framework/form-engine/form-engine-types.ts +3 -5
- package/src/lib/framework/form-engine/form-schema-tools.ts +4 -1
- package/src/lib/framework/form-engine/use-generated-form.tsx +6 -2
- package/src/lib/framework/form-engine/utils.spec.ts +129 -2
- package/src/lib/framework/form-engine/utils.ts +36 -9
- package/src/lib/framework/form-engine/value-transformers.ts +6 -0
- package/src/lib/framework/page/detail-page-route-loader.tsx +6 -4
- package/src/lib/framework/page/detail-page.tsx +22 -37
- package/src/lib/framework/page/list-page.stories.tsx +41 -2
- package/src/lib/framework/page/list-page.tsx +8 -0
- package/src/lib/graphql/graphql-env.d.ts +33 -16
- package/src/lib/graphql/schema-enums.ts +13 -0
- package/src/lib/hooks/use-alerts-context.ts +10 -0
- package/src/lib/hooks/use-alerts.ts +1 -1
- package/src/lib/hooks/use-data-table-context.ts +11 -0
- package/src/lib/hooks/use-dynamic-translations.ts +7 -0
- package/src/lib/hooks/use-job-queue-polling.ts +160 -0
- package/src/lib/hooks/use-paginated-list.ts +28 -0
- package/src/lib/hooks/use-widget-dimensions.ts +12 -0
- package/src/lib/hooks/use-widget-filters.ts +21 -0
- package/src/lib/index.ts +12 -0
- package/src/lib/providers/alerts-provider.tsx +3 -11
- package/src/lib/virtual.d.ts +5 -0
- package/src/lib/utils/global-languages.ts +0 -268
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { schemaInfo } from 'virtual:admin-api-schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* Runtime access to the LanguageCode enum values defined in the GraphQL schema.
|
|
6
|
+
*/
|
|
7
|
+
export const schemaLanguageCodes = schemaInfo.enums.LanguageCode ?? [];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* Runtime access to the CurrencyCode enum values defined in the GraphQL schema.
|
|
12
|
+
*/
|
|
13
|
+
export const schemaCurrencyCodes = schemaInfo.enums.CurrencyCode ?? [];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AlertsContext } from '@/vdb/providers/alerts-provider.js';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useAlertsContext() {
|
|
5
|
+
const context = useContext(AlertsContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useAlertsContext must be used within AlertsProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AlertSeverity, DashboardAlertDefinition } from '@/vdb/framework/extension-api/types/alerts.js';
|
|
2
|
-
import { useAlertsContext } from '@/vdb/
|
|
2
|
+
import { useAlertsContext } from '@/vdb/hooks/use-alerts-context.js';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { DataTableContext } from '@/vdb/components/data-table/data-table-context.js';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
export function useDataTableContext() {
|
|
6
|
+
const context = useContext(DataTableContext);
|
|
7
|
+
if (context === undefined) {
|
|
8
|
+
throw new Error('useDataTableContext must be used within a DataTableProvider');
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
@@ -36,11 +36,18 @@ export function useDynamicTranslations() {
|
|
|
36
36
|
return translatedDisplay !== stateTranslationId ? translatedDisplay : camelCaseToTitleCase(state);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const getTranslatedRefundReason = (reason: string) => {
|
|
40
|
+
const reasonTranslationId = `refundReason.${reason}`;
|
|
41
|
+
const translatedDisplay = i18n.t(reasonTranslationId);
|
|
42
|
+
return translatedDisplay === reasonTranslationId ? camelCaseToTitleCase(reason) : translatedDisplay;
|
|
43
|
+
};
|
|
44
|
+
|
|
39
45
|
return {
|
|
40
46
|
getTranslatedFieldName,
|
|
41
47
|
getTranslatedOrderState,
|
|
42
48
|
getTranslatedFulfillmentState,
|
|
43
49
|
getTranslatedPaymentState,
|
|
44
50
|
getTranslatedRefundState,
|
|
51
|
+
getTranslatedRefundReason,
|
|
45
52
|
};
|
|
46
53
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { api } from '@/vdb/graphql/api.js';
|
|
2
|
+
import { graphql } from '@/vdb/graphql/graphql.js';
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const JOB_LOOKBACK_MS = 5000; // Look back 5 seconds to catch jobs created before mutation returned
|
|
7
|
+
const MAX_POLLING_TIMEOUT_MS = 30000;
|
|
8
|
+
const INITIAL_POLL_INTERVAL_MS = 500;
|
|
9
|
+
const MAX_POLL_INTERVAL_MS = 4000;
|
|
10
|
+
const STORAGE_KEY_PREFIX = 'job-queue-polling:';
|
|
11
|
+
|
|
12
|
+
interface StoredPollingState {
|
|
13
|
+
startTime: string;
|
|
14
|
+
expiresAt: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const jobListForPollingDocument = graphql(`
|
|
18
|
+
query JobListForPolling($options: JobListOptions) {
|
|
19
|
+
jobs(options: $options) {
|
|
20
|
+
items {
|
|
21
|
+
id
|
|
22
|
+
createdAt
|
|
23
|
+
state
|
|
24
|
+
}
|
|
25
|
+
totalItems
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
const getStorageKey = (queueName: string) => `${STORAGE_KEY_PREFIX}${queueName}`;
|
|
31
|
+
const getStoredState = (queueName: string) => {
|
|
32
|
+
try {
|
|
33
|
+
const stored = sessionStorage.getItem(getStorageKey(queueName));
|
|
34
|
+
if (stored) {
|
|
35
|
+
return JSON.parse(stored) as StoredPollingState;
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// Ignore parsing errors
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
const setStoredState = (queueName: string, state: StoredPollingState) =>
|
|
43
|
+
sessionStorage.setItem(getStorageKey(queueName), JSON.stringify(state));
|
|
44
|
+
const clearStoredState = (queueName: string) => sessionStorage.removeItem(getStorageKey(queueName));
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Hook to poll a job queue until jobs complete.
|
|
48
|
+
* Waits for jobs created after polling starts to settle before calling onComplete.
|
|
49
|
+
*
|
|
50
|
+
* Polling state is persisted in sessionStorage, allowing it to survive navigation
|
|
51
|
+
* (e.g., after creating an entity) and page refresh while maintaining the correct
|
|
52
|
+
* time window for finding relevant jobs.
|
|
53
|
+
*/
|
|
54
|
+
export function useJobQueuePolling(queueName: string, onComplete: () => void) {
|
|
55
|
+
const [isPolling, setIsPolling] = useState(false);
|
|
56
|
+
const [pollCount, setPollCount] = useState(0);
|
|
57
|
+
const startTimeRef = useRef<string | null>(null);
|
|
58
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
59
|
+
const onCompleteRef = useRef(onComplete);
|
|
60
|
+
const hasResumedRef = useRef(false);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
onCompleteRef.current = onComplete;
|
|
64
|
+
}, [onComplete]);
|
|
65
|
+
|
|
66
|
+
// On mount, check for pending polling state
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (hasResumedRef.current) return;
|
|
69
|
+
hasResumedRef.current = true;
|
|
70
|
+
|
|
71
|
+
const stored = getStoredState(queueName);
|
|
72
|
+
if (stored && Date.now() < stored.expiresAt) {
|
|
73
|
+
startTimeRef.current = stored.startTime;
|
|
74
|
+
setPollCount(0);
|
|
75
|
+
setIsPolling(true);
|
|
76
|
+
|
|
77
|
+
const remainingTime = stored.expiresAt - Date.now();
|
|
78
|
+
timeoutRef.current = setTimeout(() => {
|
|
79
|
+
setIsPolling(false);
|
|
80
|
+
startTimeRef.current = null;
|
|
81
|
+
clearStoredState(queueName);
|
|
82
|
+
onCompleteRef.current();
|
|
83
|
+
}, remainingTime);
|
|
84
|
+
} else if (stored) {
|
|
85
|
+
clearStoredState(queueName);
|
|
86
|
+
}
|
|
87
|
+
}, [queueName]);
|
|
88
|
+
|
|
89
|
+
// Calculate exponential backoff interval
|
|
90
|
+
const pollInterval = isPolling
|
|
91
|
+
? Math.min(INITIAL_POLL_INTERVAL_MS * Math.pow(1.75, pollCount), MAX_POLL_INTERVAL_MS)
|
|
92
|
+
: false;
|
|
93
|
+
|
|
94
|
+
const { data: jobsData } = useQuery({
|
|
95
|
+
queryKey: ['jobQueuePolling', queueName],
|
|
96
|
+
queryFn: () => {
|
|
97
|
+
setPollCount(c => c + 1);
|
|
98
|
+
return api.query(jobListForPollingDocument, {
|
|
99
|
+
options: {
|
|
100
|
+
filter: { queueName: { eq: queueName } },
|
|
101
|
+
sort: { createdAt: 'DESC' as const },
|
|
102
|
+
take: 10,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
enabled: isPolling,
|
|
107
|
+
refetchInterval: pollInterval,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Detect job completion
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
const startTime = startTimeRef.current;
|
|
113
|
+
if (!isPolling || !startTime) return;
|
|
114
|
+
|
|
115
|
+
const relevantJobs = jobsData?.jobs.items.filter(j => j.createdAt >= startTime) ?? [];
|
|
116
|
+
const hasSettledJob =
|
|
117
|
+
relevantJobs.length > 0 &&
|
|
118
|
+
relevantJobs.every(j => j.state !== 'PENDING' && j.state !== 'RUNNING' && j.state !== 'RETRYING');
|
|
119
|
+
|
|
120
|
+
if (hasSettledJob) {
|
|
121
|
+
setIsPolling(false);
|
|
122
|
+
startTimeRef.current = null;
|
|
123
|
+
clearStoredState(queueName);
|
|
124
|
+
if (timeoutRef.current) {
|
|
125
|
+
clearTimeout(timeoutRef.current);
|
|
126
|
+
timeoutRef.current = null;
|
|
127
|
+
}
|
|
128
|
+
onCompleteRef.current();
|
|
129
|
+
}
|
|
130
|
+
}, [jobsData, isPolling, queueName]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
return () => {
|
|
134
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
135
|
+
};
|
|
136
|
+
}, []);
|
|
137
|
+
|
|
138
|
+
const startPolling = useCallback(() => {
|
|
139
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
140
|
+
|
|
141
|
+
const startTime = new Date(Date.now() - JOB_LOOKBACK_MS).toISOString();
|
|
142
|
+
const expiresAt = Date.now() + MAX_POLLING_TIMEOUT_MS;
|
|
143
|
+
|
|
144
|
+
// Store in sessionStorage so polling can resume after navigation
|
|
145
|
+
setStoredState(queueName, { startTime, expiresAt });
|
|
146
|
+
|
|
147
|
+
startTimeRef.current = startTime;
|
|
148
|
+
setPollCount(0);
|
|
149
|
+
setIsPolling(true);
|
|
150
|
+
|
|
151
|
+
timeoutRef.current = setTimeout(() => {
|
|
152
|
+
setIsPolling(false);
|
|
153
|
+
startTimeRef.current = null;
|
|
154
|
+
clearStoredState(queueName);
|
|
155
|
+
onCompleteRef.current();
|
|
156
|
+
}, MAX_POLLING_TIMEOUT_MS);
|
|
157
|
+
}, [queueName]);
|
|
158
|
+
|
|
159
|
+
return { isPolling, startPolling };
|
|
160
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PaginatedListContext } from '@/vdb/components/shared/paginated-list-context.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* Returns the context for the paginated list data table. Must be used within a PaginatedListDataTable.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const { refetchPaginatedList } = usePaginatedList();
|
|
11
|
+
*
|
|
12
|
+
* const mutation = useMutation({
|
|
13
|
+
* mutationFn: api.mutate(updateFacetValueDocument),
|
|
14
|
+
* onSuccess: () => {
|
|
15
|
+
* refetchPaginatedList();
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
* @docsCategory hooks
|
|
20
|
+
* @since 3.4.0
|
|
21
|
+
*/
|
|
22
|
+
export function usePaginatedList() {
|
|
23
|
+
const context = React.useContext(PaginatedListContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error('usePaginatedList must be used within a PaginatedListDataTable');
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WidgetContentContext } from '@/vdb/framework/dashboard-widget/base-widget.js';
|
|
2
|
+
import { useLingui } from '@lingui/react/macro';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
export const useWidgetDimensions = () => {
|
|
6
|
+
const { t } = useLingui();
|
|
7
|
+
const context = useContext(WidgetContentContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error(t`useWidgetDimensions must be used within a DashboardBaseWidget`);
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { WidgetFiltersContext } from '@/vdb/framework/dashboard-widget/widget-filters-context.js';
|
|
3
|
+
import { useLingui } from '@lingui/react/macro';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* Exposes a context object for use in building Insights page widgets.
|
|
9
|
+
*
|
|
10
|
+
* @docsCategory hooks
|
|
11
|
+
* @docsPage useWidgetFilters
|
|
12
|
+
* @since 3.5.0
|
|
13
|
+
*/
|
|
14
|
+
export function useWidgetFilters() {
|
|
15
|
+
const { t } = useLingui();
|
|
16
|
+
const context = useContext(WidgetFiltersContext);
|
|
17
|
+
if (context === undefined) {
|
|
18
|
+
throw new Error(t`useWidgetFilters must be used within a WidgetFiltersProvider`);
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
package/src/lib/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './components/data-input/relation-selector.js';
|
|
|
23
23
|
export * from './components/data-input/rich-text-input.js';
|
|
24
24
|
export * from './components/data-input/select-with-options.js';
|
|
25
25
|
export * from './components/data-input/slug-input.js';
|
|
26
|
+
export * from './components/data-input/string-list-input.js';
|
|
26
27
|
export * from './components/data-input/struct-form-input.js';
|
|
27
28
|
export * from './components/data-input/text-input.js';
|
|
28
29
|
export * from './components/data-input/textarea-input.js';
|
|
@@ -85,7 +86,9 @@ export * from './components/shared/asset/asset-preview.js';
|
|
|
85
86
|
export * from './components/shared/asset/asset-properties.js';
|
|
86
87
|
export * from './components/shared/assign-to-channel-bulk-action.js';
|
|
87
88
|
export * from './components/shared/assign-to-channel-dialog.js';
|
|
89
|
+
export * from './components/shared/assigned-channels.js';
|
|
88
90
|
export * from './components/shared/assigned-facet-values.js';
|
|
91
|
+
export * from './components/shared/channel-chip.js';
|
|
89
92
|
export * from './components/shared/channel-code-label.js';
|
|
90
93
|
export * from './components/shared/channel-selector.js';
|
|
91
94
|
export * from './components/shared/configurable-operation-arg-input.js';
|
|
@@ -121,6 +124,7 @@ export * from './components/shared/logo-mark.js';
|
|
|
121
124
|
export * from './components/shared/multi-select.js';
|
|
122
125
|
export * from './components/shared/navigation-confirmation.js';
|
|
123
126
|
export * from './components/shared/option-value-input.js';
|
|
127
|
+
export * from './components/shared/paginated-list-context.js';
|
|
124
128
|
export * from './components/shared/paginated-list-data-table.js';
|
|
125
129
|
export * from './components/shared/permission-guard.js';
|
|
126
130
|
export * from './components/shared/product-variant-selector.js';
|
|
@@ -267,12 +271,16 @@ export * from './graphql/api.js';
|
|
|
267
271
|
export * from './graphql/common-operations.js';
|
|
268
272
|
export * from './graphql/fragments.js';
|
|
269
273
|
export * from './graphql/graphql.js';
|
|
274
|
+
export * from './graphql/schema-enums.js';
|
|
270
275
|
export * from './graphql/settings-store-operations.js';
|
|
276
|
+
export * from './hooks/use-alerts-context.js';
|
|
271
277
|
export * from './hooks/use-alerts.js';
|
|
272
278
|
export * from './hooks/use-auth.js';
|
|
273
279
|
export * from './hooks/use-channel.js';
|
|
274
280
|
export * from './hooks/use-custom-field-config.js';
|
|
281
|
+
export * from './hooks/use-data-table-context.js';
|
|
275
282
|
export * from './hooks/use-display-locale.js';
|
|
283
|
+
export * from './hooks/use-drag-and-drop.js';
|
|
276
284
|
export * from './hooks/use-dynamic-translations.js';
|
|
277
285
|
export * from './hooks/use-extended-detail-query.js';
|
|
278
286
|
export * from './hooks/use-extended-list-query.js';
|
|
@@ -282,12 +290,16 @@ export * from './hooks/use-local-format.js';
|
|
|
282
290
|
export * from './hooks/use-mobile.js';
|
|
283
291
|
export * from './hooks/use-page-block.js';
|
|
284
292
|
export * from './hooks/use-page.js';
|
|
293
|
+
export * from './hooks/use-paginated-list.js';
|
|
285
294
|
export * from './hooks/use-permissions.js';
|
|
286
295
|
export * from './hooks/use-saved-views.js';
|
|
287
296
|
export * from './hooks/use-server-config.js';
|
|
297
|
+
export * from './hooks/use-sorted-languages.js';
|
|
288
298
|
export * from './hooks/use-theme.js';
|
|
289
299
|
export * from './hooks/use-ui-language-loader.js';
|
|
290
300
|
export * from './hooks/use-user-settings.js';
|
|
301
|
+
export * from './hooks/use-widget-dimensions.js';
|
|
302
|
+
export * from './hooks/use-widget-filters.js';
|
|
291
303
|
export * from './lib/load-i18n-messages.js';
|
|
292
304
|
export * from './lib/trans.js';
|
|
293
305
|
export * from './lib/utils.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getAlertRegistry } from '@/vdb/framework/alert/alert-extensions.js';
|
|
2
2
|
import { DashboardAlertDefinition } from '@/vdb/framework/extension-api/types/alerts.js';
|
|
3
3
|
import { useQueries, UseQueryOptions } from '@tanstack/react-query';
|
|
4
|
-
import { createContext, ReactNode,
|
|
4
|
+
import { createContext, ReactNode, useEffect, useState } from 'react';
|
|
5
5
|
|
|
6
|
-
interface AlertsContextValue {
|
|
6
|
+
export interface AlertsContextValue {
|
|
7
7
|
alertDefs: DashboardAlertDefinition[];
|
|
8
8
|
rawResults: any[];
|
|
9
9
|
dismissedAlerts: Map<string, number>;
|
|
@@ -11,7 +11,7 @@ interface AlertsContextValue {
|
|
|
11
11
|
enabledQueries: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const AlertsContext = createContext<AlertsContextValue | undefined>(undefined);
|
|
14
|
+
export const AlertsContext = createContext<AlertsContextValue | undefined>(undefined);
|
|
15
15
|
|
|
16
16
|
export function AlertsProvider({ children }: { children: ReactNode }) {
|
|
17
17
|
const initialDelayMs = 5_000;
|
|
@@ -50,11 +50,3 @@ export function AlertsProvider({ children }: { children: ReactNode }) {
|
|
|
50
50
|
</AlertsContext.Provider>
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
export function useAlertsContext() {
|
|
55
|
-
const context = useContext(AlertsContext);
|
|
56
|
-
if (!context) {
|
|
57
|
-
throw new Error('useAlertsContext must be used within AlertsProvider');
|
|
58
|
-
}
|
|
59
|
-
return context;
|
|
60
|
-
}
|
package/src/lib/virtual.d.ts
CHANGED
|
@@ -30,9 +30,14 @@ declare module 'virtual:vendure-ui-config' {
|
|
|
30
30
|
availableLocales: string[];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
interface ResolvedOrdersConfig {
|
|
34
|
+
refundReasons: Array<{ value: string; label: string }>;
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
interface ResolvedUiConfig {
|
|
34
38
|
api: ResolvedApiConfig;
|
|
35
39
|
i18n: ResolvedI18nConfig;
|
|
40
|
+
orders: ResolvedOrdersConfig;
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export const uiConfig: ResolvedUiConfig;
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
export const globalLanguageCodes = [
|
|
2
|
-
/** Afrikaans */
|
|
3
|
-
'af',
|
|
4
|
-
/** Akan */
|
|
5
|
-
'ak',
|
|
6
|
-
/** Amharic */
|
|
7
|
-
'am',
|
|
8
|
-
/** Arabic */
|
|
9
|
-
'ar',
|
|
10
|
-
/** Assamese */
|
|
11
|
-
'as',
|
|
12
|
-
/** Azerbaijani */
|
|
13
|
-
'az',
|
|
14
|
-
/** Belarusian */
|
|
15
|
-
'be',
|
|
16
|
-
/** Bulgarian */
|
|
17
|
-
'bg',
|
|
18
|
-
/** Bambara */
|
|
19
|
-
'bm',
|
|
20
|
-
/** Bangla */
|
|
21
|
-
'bn',
|
|
22
|
-
/** Breton */
|
|
23
|
-
'br',
|
|
24
|
-
/** Bosnian */
|
|
25
|
-
'bs',
|
|
26
|
-
/** Catalan */
|
|
27
|
-
'ca',
|
|
28
|
-
/** Chechen */
|
|
29
|
-
'co',
|
|
30
|
-
/** Czech */
|
|
31
|
-
'cs',
|
|
32
|
-
/** Welsh */
|
|
33
|
-
'cy',
|
|
34
|
-
/** Danish */
|
|
35
|
-
'da',
|
|
36
|
-
/** German */
|
|
37
|
-
'de',
|
|
38
|
-
/** Ewe */
|
|
39
|
-
'ee',
|
|
40
|
-
/** Greek */
|
|
41
|
-
'el',
|
|
42
|
-
/** English */
|
|
43
|
-
'en',
|
|
44
|
-
/** Esperanto */
|
|
45
|
-
'eo',
|
|
46
|
-
/** Spanish */
|
|
47
|
-
'es',
|
|
48
|
-
/** European Spanish */
|
|
49
|
-
'es_ES',
|
|
50
|
-
/** Mexican Spanish */
|
|
51
|
-
'es_MX',
|
|
52
|
-
/** Estonian */
|
|
53
|
-
'et',
|
|
54
|
-
/** Basque */
|
|
55
|
-
'eu',
|
|
56
|
-
/** Persian */
|
|
57
|
-
'fa',
|
|
58
|
-
/** Dari */
|
|
59
|
-
'fa_AF',
|
|
60
|
-
/** Finnish */
|
|
61
|
-
'fi',
|
|
62
|
-
/** Faroese */
|
|
63
|
-
'fo',
|
|
64
|
-
/** French */
|
|
65
|
-
'fr',
|
|
66
|
-
/** Canadian French */
|
|
67
|
-
'fr_CA',
|
|
68
|
-
/** Swiss French */
|
|
69
|
-
'fr_CH',
|
|
70
|
-
/** Western Frisian */
|
|
71
|
-
'fy',
|
|
72
|
-
/** Irish */
|
|
73
|
-
'ga',
|
|
74
|
-
/** Scottish Gaelic */
|
|
75
|
-
'gd',
|
|
76
|
-
/** Galician */
|
|
77
|
-
'gl',
|
|
78
|
-
/** Gujarati */
|
|
79
|
-
'gu',
|
|
80
|
-
/** Hausa */
|
|
81
|
-
'ha',
|
|
82
|
-
/** Hebrew */
|
|
83
|
-
'he',
|
|
84
|
-
/** Hindi */
|
|
85
|
-
'hi',
|
|
86
|
-
/** Croatian */
|
|
87
|
-
'hr',
|
|
88
|
-
/** Haitian Creole */
|
|
89
|
-
'ht',
|
|
90
|
-
/** Hungarian */
|
|
91
|
-
'hu',
|
|
92
|
-
/** Armenian */
|
|
93
|
-
'hy',
|
|
94
|
-
/** Interlingua */
|
|
95
|
-
'ia',
|
|
96
|
-
/** Indonesian */
|
|
97
|
-
'id',
|
|
98
|
-
/** Igbo */
|
|
99
|
-
'ig',
|
|
100
|
-
/** Icelandic */
|
|
101
|
-
'is',
|
|
102
|
-
/** Italian */
|
|
103
|
-
'it',
|
|
104
|
-
/** Japanese */
|
|
105
|
-
'ja',
|
|
106
|
-
/** Javanese */
|
|
107
|
-
'jv',
|
|
108
|
-
/** Georgian */
|
|
109
|
-
'ka',
|
|
110
|
-
/** Kazakh */
|
|
111
|
-
'kk',
|
|
112
|
-
/** Khmer */
|
|
113
|
-
'km',
|
|
114
|
-
/** Kannada */
|
|
115
|
-
'kn',
|
|
116
|
-
/** Korean */
|
|
117
|
-
'ko',
|
|
118
|
-
/** Kurdish */
|
|
119
|
-
'ku',
|
|
120
|
-
/** Kyrgyz */
|
|
121
|
-
'ky',
|
|
122
|
-
/** Latin */
|
|
123
|
-
'la',
|
|
124
|
-
/** Luxembourgish */
|
|
125
|
-
'lb',
|
|
126
|
-
/** Ganda */
|
|
127
|
-
'lg',
|
|
128
|
-
/** Lingala */
|
|
129
|
-
'ln',
|
|
130
|
-
/** Lao */
|
|
131
|
-
'lo',
|
|
132
|
-
/** Lithuanian */
|
|
133
|
-
'lt',
|
|
134
|
-
/** Latvian */
|
|
135
|
-
'lv',
|
|
136
|
-
/** Malagasy */
|
|
137
|
-
'mg',
|
|
138
|
-
/** Maori */
|
|
139
|
-
'mi',
|
|
140
|
-
/** Macedonian */
|
|
141
|
-
'mk',
|
|
142
|
-
/** Malayalam */
|
|
143
|
-
'ml',
|
|
144
|
-
/** Mongolian */
|
|
145
|
-
'mn',
|
|
146
|
-
/** Marathi */
|
|
147
|
-
'mr',
|
|
148
|
-
/** Malay */
|
|
149
|
-
'ms',
|
|
150
|
-
/** Maltese */
|
|
151
|
-
'mt',
|
|
152
|
-
/** Burmese */
|
|
153
|
-
'my',
|
|
154
|
-
/** Norwegian Bokmål */
|
|
155
|
-
'nb',
|
|
156
|
-
/** Nepali */
|
|
157
|
-
'ne',
|
|
158
|
-
/** Dutch */
|
|
159
|
-
'nl',
|
|
160
|
-
/** Flemish */
|
|
161
|
-
'nl_BE',
|
|
162
|
-
/** Norwegian Nynorsk */
|
|
163
|
-
'nn',
|
|
164
|
-
/** Nyanja */
|
|
165
|
-
'ny',
|
|
166
|
-
/** Oromo */
|
|
167
|
-
'om',
|
|
168
|
-
/** Odia */
|
|
169
|
-
'or',
|
|
170
|
-
/** Punjabi */
|
|
171
|
-
'pa',
|
|
172
|
-
/** Polish */
|
|
173
|
-
'pl',
|
|
174
|
-
/** Pashto */
|
|
175
|
-
'ps',
|
|
176
|
-
/** Portuguese */
|
|
177
|
-
'pt',
|
|
178
|
-
/** Brazilian Portuguese */
|
|
179
|
-
'pt_BR',
|
|
180
|
-
/** European Portuguese */
|
|
181
|
-
'pt_PT',
|
|
182
|
-
/** Quechua */
|
|
183
|
-
'qu',
|
|
184
|
-
/** Romansh */
|
|
185
|
-
'rm',
|
|
186
|
-
/** Romanian */
|
|
187
|
-
'ro',
|
|
188
|
-
/** Moldavian */
|
|
189
|
-
'ro_MD',
|
|
190
|
-
/** Russian */
|
|
191
|
-
'ru',
|
|
192
|
-
/** Kinyarwanda */
|
|
193
|
-
'rw',
|
|
194
|
-
/** Sanskrit */
|
|
195
|
-
'sa',
|
|
196
|
-
/** Sindhi */
|
|
197
|
-
'sd',
|
|
198
|
-
/** Sinhala */
|
|
199
|
-
'si',
|
|
200
|
-
/** Slovak */
|
|
201
|
-
'sk',
|
|
202
|
-
/** Slovenian */
|
|
203
|
-
'sl',
|
|
204
|
-
/** Samoan */
|
|
205
|
-
'sm',
|
|
206
|
-
/** Shona */
|
|
207
|
-
'sn',
|
|
208
|
-
/** Somali */
|
|
209
|
-
'so',
|
|
210
|
-
/** Albanian */
|
|
211
|
-
'sq',
|
|
212
|
-
/** Serbian */
|
|
213
|
-
'sr',
|
|
214
|
-
/** Southern Sotho */
|
|
215
|
-
'st',
|
|
216
|
-
/** Sundanese */
|
|
217
|
-
'su',
|
|
218
|
-
/** Swedish */
|
|
219
|
-
'sv',
|
|
220
|
-
/** Swahili */
|
|
221
|
-
'sw',
|
|
222
|
-
/** Congo Swahili */
|
|
223
|
-
'sw_CD',
|
|
224
|
-
/** Tamil */
|
|
225
|
-
'ta',
|
|
226
|
-
/** Telugu */
|
|
227
|
-
'te',
|
|
228
|
-
/** Tajik */
|
|
229
|
-
'tg',
|
|
230
|
-
/** Thai */
|
|
231
|
-
'th',
|
|
232
|
-
/** Tigrinya */
|
|
233
|
-
'ti',
|
|
234
|
-
/** Turkmen */
|
|
235
|
-
'tk',
|
|
236
|
-
/** Tongan */
|
|
237
|
-
'to',
|
|
238
|
-
/** Turkish */
|
|
239
|
-
'tr',
|
|
240
|
-
/** Tatar */
|
|
241
|
-
'tt',
|
|
242
|
-
/** Uyghur */
|
|
243
|
-
'ug',
|
|
244
|
-
/** Ukrainian */
|
|
245
|
-
'uk',
|
|
246
|
-
/** Urdu */
|
|
247
|
-
'ur',
|
|
248
|
-
/** Uzbek */
|
|
249
|
-
'uz',
|
|
250
|
-
/** Vietnamese */
|
|
251
|
-
'vi',
|
|
252
|
-
/** Wolof */
|
|
253
|
-
'wo',
|
|
254
|
-
/** Xhosa */
|
|
255
|
-
'xh',
|
|
256
|
-
/** Yiddish */
|
|
257
|
-
'yi',
|
|
258
|
-
/** Yoruba */
|
|
259
|
-
'yo',
|
|
260
|
-
/** Chinese */
|
|
261
|
-
'zh',
|
|
262
|
-
/** Simplified Chinese */
|
|
263
|
-
'zh_Hans',
|
|
264
|
-
/** Traditional Chinese */
|
|
265
|
-
'zh_Hant',
|
|
266
|
-
/** Zulu */
|
|
267
|
-
'zu',
|
|
268
|
-
];
|