@develemit/commerce-admin 0.6.0 → 0.8.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/README.md +88 -9
  3. package/dist/client/admin-client.d.ts +4 -2
  4. package/dist/client/errors.d.ts +9 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-ClTCzt-p.js +190 -0
  7. package/dist/client-ClTCzt-p.js.map +1 -0
  8. package/dist/components/admin-layout/admin-layout.d.ts +6 -6
  9. package/dist/components/admin-layout/current-item.d.ts +1 -0
  10. package/dist/components/admin-layout/nav-icons.d.ts +9 -0
  11. package/dist/components/admin-layout/nav-items.d.ts +39 -0
  12. package/dist/components/admin-layout/use-current-href.d.ts +1 -0
  13. package/dist/components/admin-layout/use-more-sheet.d.ts +5 -0
  14. package/dist/components/empty-state/empty-state.d.ts +10 -0
  15. package/dist/components/notice/notice.d.ts +5 -1
  16. package/dist/components/page-header/admin-page-header.d.ts +8 -0
  17. package/dist/components/setup-checklist/setup-checklist.d.ts +15 -0
  18. package/dist/components/switch/switch.d.ts +7 -0
  19. package/dist/index.d.ts +12 -0
  20. package/dist/index.js +3758 -1276
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/admin-labels.d.ts +5 -0
  23. package/dist/lib/currency-symbol.d.ts +1 -0
  24. package/dist/lib/discount-labels.d.ts +1 -0
  25. package/dist/lib/fill-alts.d.ts +3 -0
  26. package/dist/lib/order-action-labels.d.ts +2 -0
  27. package/dist/lib/order-labels.d.ts +1 -0
  28. package/dist/lib/product-draft.d.ts +14 -0
  29. package/dist/lib/product-flow-labels.d.ts +63 -0
  30. package/dist/lib/product-labels.d.ts +61 -0
  31. package/dist/lib/product-missing.d.ts +4 -0
  32. package/dist/lib/product-sheet-actions.d.ts +13 -0
  33. package/dist/lib/provider.d.ts +2 -0
  34. package/dist/lib/shipping-labels.d.ts +2 -0
  35. package/dist/lib/stock-labels.d.ts +43 -0
  36. package/dist/lib/use-batch-upload.d.ts +39 -0
  37. package/dist/lib/use-focus-trap.d.ts +2 -0
  38. package/dist/lib/use-image-upload.d.ts +3 -2
  39. package/dist/lib/use-product-autosave.d.ts +99 -0
  40. package/dist/lib/use-product-pages.d.ts +3 -2
  41. package/dist/styles.css +1743 -57
  42. package/dist/views/orders/admin-order-detail.d.ts +2 -1
  43. package/dist/views/orders/order-actions.d.ts +2 -1
  44. package/dist/views/orders/resolve-button.d.ts +3 -1
  45. package/dist/views/orders/ship-form.d.ts +4 -1
  46. package/dist/views/products/add-several/admin-add-several.d.ts +5 -0
  47. package/dist/views/products/add-several/photo-picker.d.ts +9 -0
  48. package/dist/views/products/admin-product-editor.d.ts +3 -1
  49. package/dist/views/products/admin-product-images.d.ts +2 -0
  50. package/dist/views/products/admin-product-list.d.ts +13 -1
  51. package/dist/views/products/finish-drafts/admin-finish-drafts.d.ts +7 -0
  52. package/dist/views/products/finish-drafts/piece-card.d.ts +10 -0
  53. package/dist/views/products/finish-drafts/piece-fields.d.ts +7 -0
  54. package/dist/views/products/finish-drafts/piece-summary.d.ts +11 -0
  55. package/dist/views/products/finish-drafts/use-publish-pieces.d.ts +54 -0
  56. package/dist/views/products/product-card.d.ts +6 -0
  57. package/dist/views/products/product-flow/admin-product-flow.d.ts +15 -0
  58. package/dist/views/products/product-flow/basics-section.d.ts +6 -0
  59. package/dist/views/products/product-flow/flow-actions.d.ts +13 -0
  60. package/dist/views/products/product-flow/flow-frame.d.ts +30 -0
  61. package/dist/views/products/product-flow/flow-images.d.ts +7 -0
  62. package/dist/views/products/product-flow/flow-section-props.d.ts +5 -0
  63. package/dist/views/products/product-flow/flow-success.d.ts +8 -0
  64. package/dist/views/products/product-flow/flow-test-helpers.d.ts +12 -0
  65. package/dist/views/products/product-flow/materials-field.d.ts +6 -0
  66. package/dist/views/products/product-flow/photos-section.d.ts +9 -0
  67. package/dist/views/products/product-flow/preview-section.d.ts +10 -0
  68. package/dist/views/products/product-flow/story-section.d.ts +8 -0
  69. package/dist/views/products/product-flow/use-product-flow.d.ts +143 -0
  70. package/dist/views/products/product-sheet/admin-product-sheet.d.ts +8 -0
  71. package/dist/views/products/product-sheet/delete-draft-button.d.ts +9 -0
  72. package/dist/views/products/product-sheet/sheet-carousel.d.ts +4 -0
  73. package/dist/views/products/product-sheet/sheet-edit-link.d.ts +14 -0
  74. package/dist/views/products/product-sheet/use-product-change.d.ts +16 -0
  75. package/dist/views/products/product-toolbar.d.ts +10 -0
  76. package/dist/views/products/product-welcome.d.ts +8 -0
  77. package/dist/views/shipping/admin-shipping-rates.d.ts +6 -1
  78. package/dist/views/shipping/shipping-rate-row.d.ts +2 -1
  79. package/package.json +11 -3
  80. package/dist/client-CSjuKdIE.js +0 -178
  81. package/dist/client-CSjuKdIE.js.map +0 -1
@@ -15,6 +15,11 @@ export interface AdminLabels {
15
15
  products: string;
16
16
  orders: string;
17
17
  shippingRates: string;
18
+ more: string;
19
+ closeMore: string;
20
+ viewShop: string;
21
+ badge: (count: number | string) => string;
22
+ productsBadge: (count: number | string) => string;
18
23
  };
19
24
  statuses: Record<string, string>;
20
25
  errors: Record<AdminErrorKey, string>;
@@ -0,0 +1 @@
1
+ export declare function currencySymbol(currency: string, locale: string): string;
@@ -7,6 +7,7 @@ export interface DiscountLabels {
7
7
  tabs: Record<DiscountTab, string>;
8
8
  empty: Record<DiscountTab, string>;
9
9
  noMatches: string;
10
+ emptyHint: string;
10
11
  loadMore: string;
11
12
  columns: {
12
13
  code: string;
@@ -0,0 +1,3 @@
1
+ import { AdminProduct } from '@develemit/commerce-contracts';
2
+ import { AdminClient } from '../client';
3
+ export declare function fillBlankAlts(client: AdminClient, product: AdminProduct, template: string): Promise<AdminProduct>;
@@ -7,6 +7,8 @@ export interface OrderActionLabels {
7
7
  trackingUrl: string;
8
8
  trackingUrlInvalid: string;
9
9
  shipped: string;
10
+ shipWithoutTracking: string;
11
+ trackingRequired: string;
10
12
  refund: string;
11
13
  refundTitle: string;
12
14
  refundAmount: string;
@@ -6,6 +6,7 @@ export interface OrderLabels {
6
6
  searchPlaceholder: string;
7
7
  tabs: Record<OrderTab, string>;
8
8
  empty: Record<OrderTab, string>;
9
+ emptyHint: string;
9
10
  noMatches: string;
10
11
  loadMore: string;
11
12
  columns: {
@@ -0,0 +1,14 @@
1
+ import { AdminProduct, AdminProductInput, AdminProductPatch } from '@develemit/commerce-contracts';
2
+ import { ProductForm } from './product-form';
3
+ export declare function hasDraftContent(form: ProductForm): boolean;
4
+ export declare function draftInput(form: ProductForm, currency?: string): AdminProductInput;
5
+ export declare function draftPatch(base: AdminProduct, form: ProductForm): AdminProductPatch;
6
+ export declare function basicsReady(form: ProductForm): boolean;
7
+ export declare function basicsMissing(form: ProductForm): Array<'name' | 'price' | 'category'>;
8
+ export declare function titleCase(value: string): string;
9
+ export declare function splitMaterials(value: string): string[];
10
+ export declare function toggleMaterial(value: string, material: string): string;
11
+ export declare function mergeMaterials(picked: string[], custom: string): string;
12
+ export declare function appendPrompt(description: string, prompt: string): string;
13
+ export declare function currencySymbol(locale: string, currency: string): string;
14
+ export declare function fillText(template: string, values: Record<string, string>): string;
@@ -0,0 +1,63 @@
1
+ export type ProductFlowStep = 'photos' | 'basics' | 'story' | 'preview';
2
+ export declare const PRODUCT_FLOW_STEPS: ProductFlowStep[];
3
+ export interface ProductFlowLabels {
4
+ newTitle: string;
5
+ editTitle: string;
6
+ back: string;
7
+ close: string;
8
+ stepsLabel: string;
9
+ steps: Record<ProductFlowStep, string>;
10
+ headings: Record<ProductFlowStep, string>;
11
+ ledes: Record<ProductFlowStep, string>;
12
+ addPhotos: string;
13
+ addMorePhotos: string;
14
+ photoHint: string;
15
+ photoTip: string;
16
+ photoN: string;
17
+ cover: string;
18
+ makeCover: string;
19
+ removePhoto: string;
20
+ uploading: string;
21
+ pricePlaceholder: string;
22
+ otherCategory: string;
23
+ newCategory: string;
24
+ oneOfAKind: string;
25
+ howMany: string;
26
+ descriptionPrompts: string[];
27
+ descriptionPlaceholder: string;
28
+ sizePlaceholder: string;
29
+ altPlaceholder: string;
30
+ previewHeadingLive: string;
31
+ saveChanges: string;
32
+ seeInShop: string;
33
+ continueNeeds: string;
34
+ addPhotoTile: string;
35
+ stepCount: string;
36
+ materialsOther: string;
37
+ size: string;
38
+ altTitle: string;
39
+ altHelp: string;
40
+ altFallback: string;
41
+ inTheShop: string;
42
+ untitled: string;
43
+ noPhoto: string;
44
+ needs: string;
45
+ featured: string;
46
+ continue: string;
47
+ photosLater: string;
48
+ skip: string;
49
+ saveDraft: string;
50
+ publish: string;
51
+ done: string;
52
+ saving: string;
53
+ savedNew: string;
54
+ savedEdit: string;
55
+ saveFailed: string;
56
+ retry: string;
57
+ savedAsDraft: string;
58
+ success: string;
59
+ successFirst: string;
60
+ addAnother: string;
61
+ backToList: string;
62
+ }
63
+ export declare const defaultProductFlowLabels: ProductFlowLabels;
@@ -1,4 +1,6 @@
1
+ import { StockLabels } from './stock-labels';
1
2
  import { ImageLabels } from './image-labels';
3
+ import { ProductFlowLabels } from './product-flow-labels';
2
4
  export type ProductFilter = 'all' | 'live' | 'sold' | 'draft' | 'archived';
3
5
  export interface ProductLabels {
4
6
  title: string;
@@ -8,7 +10,64 @@ export interface ProductLabels {
8
10
  filters: Record<ProductFilter, string>;
9
11
  empty: Record<ProductFilter, string>;
10
12
  noMatches: string;
13
+ emptyActions: {
14
+ start: string;
15
+ clearSearch: string;
16
+ };
11
17
  loadMore: string;
18
+ welcome: {
19
+ title: string;
20
+ body: string;
21
+ addFirst: string;
22
+ addMany: string;
23
+ };
24
+ card: {
25
+ needsPrice: string;
26
+ needsCategory: string;
27
+ needsPhoto: string;
28
+ featured: string;
29
+ noPhoto: string;
30
+ };
31
+ draftsBanner: {
32
+ one: string;
33
+ many: string;
34
+ finish: string;
35
+ };
36
+ sheet: {
37
+ close: string;
38
+ photoOf: string;
39
+ previousPhoto: string;
40
+ nextPhoto: string;
41
+ noPhoto: string;
42
+ category: string;
43
+ noCategory: string;
44
+ primary: Record<'finish' | 'publish' | 'sold' | 'restock' | 'restore', string>;
45
+ edit: string;
46
+ photos: string;
47
+ featureOn: string;
48
+ featureOff: string;
49
+ hide: string;
50
+ copyLink: string;
51
+ linkCopied: string;
52
+ archive: string;
53
+ deleteDraft: string;
54
+ deleteTitle: string;
55
+ deleteBody: string;
56
+ deleteConfirm: string;
57
+ undo: string;
58
+ missingTitle: string;
59
+ missing: Record<string, string>;
60
+ done: Record<'publish' | 'sold' | 'restock' | 'restore' | 'hide' | 'archive' | 'feature', string>;
61
+ };
62
+ openSearch: string;
63
+ closeSearch: string;
64
+ setup: {
65
+ title: string;
66
+ progress: string;
67
+ show: string;
68
+ hide: string;
69
+ locked: string;
70
+ };
12
71
  columns: {
13
72
  image: string;
14
73
  name: string;
@@ -41,6 +100,8 @@ export interface ProductLabels {
41
100
  featured: string;
42
101
  };
43
102
  images: ImageLabels;
103
+ flow: ProductFlowLabels;
104
+ stock: StockLabels;
44
105
  statusHelp: string;
45
106
  priceHelp: string;
46
107
  validation: {
@@ -0,0 +1,4 @@
1
+ import { AdminProduct } from '@develemit/commerce-contracts';
2
+ import { ProductLabels } from './product-labels';
3
+ export declare function missingDetail(product: AdminProduct, copy: ProductLabels['card']): string | null;
4
+ export declare function fillCount(template: string, values: Record<string, number>): string;
@@ -0,0 +1,13 @@
1
+ import { AdminProduct, AdminProductPatch } from '@develemit/commerce-contracts';
2
+ export type PrimaryKind = 'finish' | 'publish' | 'sold' | 'restock' | 'restore';
3
+ export interface ProductChange {
4
+ patch: AdminProductPatch;
5
+ undo: AdminProductPatch;
6
+ }
7
+ export declare function isDraftComplete(product: AdminProduct): boolean;
8
+ export declare function primaryKind(product: AdminProduct): PrimaryKind;
9
+ export declare function primaryChange(product: AdminProduct, kind: PrimaryKind): ProductChange | null;
10
+ export declare const hideChange: ProductChange;
11
+ export declare function archiveChange(product: AdminProduct): ProductChange;
12
+ export declare function featureChange(product: AdminProduct): ProductChange;
13
+ export declare const canFeature: (product: AdminProduct) => boolean;
@@ -7,6 +7,7 @@ export interface LinkProps {
7
7
  href: string;
8
8
  children: ReactNode;
9
9
  className?: string;
10
+ 'aria-current'?: 'page';
10
11
  }
11
12
  export interface AdminImageProps {
12
13
  src: string;
@@ -31,6 +32,7 @@ export interface AdminConfig {
31
32
  discount: (id: string) => string;
32
33
  newDiscount: string;
33
34
  storefrontProduct?: (slug: string) => string;
35
+ storefront?: string;
34
36
  };
35
37
  client: AdminClient | null;
36
38
  labels: AdminLabels;
@@ -1,7 +1,9 @@
1
1
  export interface ShippingLabels {
2
2
  title: string;
3
3
  loading: string;
4
+ emptyTitle: string;
4
5
  empty: string;
6
+ addOption: string;
5
7
  add: string;
6
8
  save: string;
7
9
  saved: string;
@@ -0,0 +1,43 @@
1
+ export interface StockLabels {
2
+ addSeveral: {
3
+ title: string;
4
+ introTitle: string;
5
+ introBody: string;
6
+ choose: string;
7
+ dropHint: string;
8
+ progress: string;
9
+ failedTitle: string;
10
+ retry: string;
11
+ continueWithout: string;
12
+ doneTitle: string;
13
+ doneBody: string;
14
+ next: string;
15
+ };
16
+ queue: {
17
+ title: string;
18
+ pieceOf: string;
19
+ addPhoto: string;
20
+ coverAlt: string;
21
+ skip: string;
22
+ next: string;
23
+ review: string;
24
+ back: string;
25
+ loading: string;
26
+ nothingToFinish: string;
27
+ done: string;
28
+ };
29
+ summary: {
30
+ title: string;
31
+ lede: string;
32
+ needsDetails: string;
33
+ openPiece: string;
34
+ untitled: string;
35
+ publish: string;
36
+ keepDrafts: string;
37
+ stillIncomplete: string;
38
+ publishedTitle: string;
39
+ publishedBody: string;
40
+ allSkipped: string;
41
+ };
42
+ }
43
+ export declare const defaultStockLabels: StockLabels;
@@ -0,0 +1,39 @@
1
+ import { AdminProduct } from '@develemit/commerce-contracts';
2
+ export interface BatchItem {
3
+ id: number;
4
+ file: File;
5
+ status: 'queued' | 'uploading' | 'done' | 'error';
6
+ productId?: string;
7
+ product?: AdminProduct;
8
+ reason?: string;
9
+ error?: unknown;
10
+ }
11
+ export declare function useBatchUpload(): {
12
+ items: BatchItem[];
13
+ add: (files: File[]) => void;
14
+ retry: () => void;
15
+ done: BatchItem[];
16
+ failed: BatchItem[];
17
+ settled: boolean;
18
+ products: {
19
+ id: string;
20
+ slug: string;
21
+ name: string;
22
+ description: string;
23
+ materials: string | null;
24
+ dimensions: string | null;
25
+ priceCents: number | null;
26
+ currency: string;
27
+ category: string | null;
28
+ quantity: number;
29
+ status: "draft" | "active" | "archived";
30
+ featured: boolean;
31
+ everPublished: boolean;
32
+ images: {
33
+ id: string;
34
+ url: string;
35
+ alt: string;
36
+ position: number;
37
+ }[];
38
+ }[];
39
+ };
@@ -0,0 +1,2 @@
1
+ import { KeyboardEvent, RefObject } from 'react';
2
+ export declare function useFocusTrap(ref: RefObject<HTMLElement | null>, active: boolean, onEscape: () => void): (event: KeyboardEvent) => void;
@@ -7,10 +7,11 @@ export interface UploadEntry {
7
7
  error?: unknown;
8
8
  }
9
9
  interface Options {
10
- productId: string;
10
+ productId?: string;
11
+ resolveProductId?: () => Promise<string>;
11
12
  onUploaded: (product: AdminProduct) => void;
12
13
  }
13
- export declare function useImageUpload({ productId, onUploaded }: Options): {
14
+ export declare function useImageUpload({ productId, resolveProductId, onUploaded, }: Options): {
14
15
  entries: UploadEntry[];
15
16
  upload: (files: File[], alt: string) => void;
16
17
  dismiss: (id: number) => void;
@@ -0,0 +1,99 @@
1
+ import { AdminProduct } from '@develemit/commerce-contracts';
2
+ import { ProductForm } from './product-form';
3
+ export type AutosaveState = 'idle' | 'saving' | 'saved' | 'error';
4
+ interface Options {
5
+ initial: AdminProduct | null;
6
+ form: ProductForm;
7
+ currency?: string;
8
+ delayMs?: number;
9
+ }
10
+ export declare function useProductAutosave({ initial, form, currency, delayMs, }: Options): {
11
+ product: {
12
+ id: string;
13
+ slug: string;
14
+ name: string;
15
+ description: string;
16
+ materials: string | null;
17
+ dimensions: string | null;
18
+ priceCents: number | null;
19
+ currency: string;
20
+ category: string | null;
21
+ quantity: number;
22
+ status: "draft" | "active" | "archived";
23
+ featured: boolean;
24
+ everPublished: boolean;
25
+ images: {
26
+ id: string;
27
+ url: string;
28
+ alt: string;
29
+ position: number;
30
+ }[];
31
+ } | null;
32
+ setProduct: (next: AdminProduct) => void;
33
+ state: AutosaveState;
34
+ error: unknown;
35
+ flush: () => Promise<{
36
+ id: string;
37
+ slug: string;
38
+ name: string;
39
+ description: string;
40
+ materials: string | null;
41
+ dimensions: string | null;
42
+ priceCents: number | null;
43
+ currency: string;
44
+ category: string | null;
45
+ quantity: number;
46
+ status: "draft" | "active" | "archived";
47
+ featured: boolean;
48
+ everPublished: boolean;
49
+ images: {
50
+ id: string;
51
+ url: string;
52
+ alt: string;
53
+ position: number;
54
+ }[];
55
+ } | null>;
56
+ ensureProduct: () => Promise<{
57
+ id: string;
58
+ slug: string;
59
+ name: string;
60
+ description: string;
61
+ materials: string | null;
62
+ dimensions: string | null;
63
+ priceCents: number | null;
64
+ currency: string;
65
+ category: string | null;
66
+ quantity: number;
67
+ status: "draft" | "active" | "archived";
68
+ featured: boolean;
69
+ everPublished: boolean;
70
+ images: {
71
+ id: string;
72
+ url: string;
73
+ alt: string;
74
+ position: number;
75
+ }[];
76
+ }>;
77
+ retry: () => Promise<{
78
+ id: string;
79
+ slug: string;
80
+ name: string;
81
+ description: string;
82
+ materials: string | null;
83
+ dimensions: string | null;
84
+ priceCents: number | null;
85
+ currency: string;
86
+ category: string | null;
87
+ quantity: number;
88
+ status: "draft" | "active" | "archived";
89
+ featured: boolean;
90
+ everPublished: boolean;
91
+ images: {
92
+ id: string;
93
+ url: string;
94
+ alt: string;
95
+ position: number;
96
+ }[];
97
+ } | null>;
98
+ };
99
+ export {};
@@ -7,12 +7,13 @@ export declare function useProductPages(query: Omit<AdminProductQuery, 'cursor'>
7
7
  description: string;
8
8
  materials: string | null;
9
9
  dimensions: string | null;
10
- priceCents: number;
10
+ priceCents: number | null;
11
11
  currency: string;
12
- category: string;
12
+ category: string | null;
13
13
  quantity: number;
14
14
  status: "draft" | "active" | "archived";
15
15
  featured: boolean;
16
+ everPublished: boolean;
16
17
  images: {
17
18
  id: string;
18
19
  url: string;