@happyvertical/smrt-commerce 0.55.6 → 0.55.8
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/AGENTS.md +4 -0
- package/README.md +34 -0
- package/agents/customer-vendor-ui.md +31 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +642 -240
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1473 -109
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/ContractLineItem.d.ts.map +1 -1
- package/dist/models/Customer.d.ts.map +1 -1
- package/dist/models/Fulfillment.d.ts.map +1 -1
- package/dist/models/FulfillmentLineItem.d.ts.map +1 -1
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/InvoiceLineItem.d.ts.map +1 -1
- package/dist/models/Payment.d.ts.map +1 -1
- package/dist/models/PaymentAllocation.d.ts.map +1 -1
- package/dist/models/Vendor.d.ts.map +1 -1
- package/dist/playground.js +19 -0
- package/dist/playground.js.map +1 -1
- package/dist/recipes.d.ts +733 -19
- package/dist/recipes.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +1171 -123
- package/dist/svelte/components/CustomerSelect.svelte +53 -0
- package/dist/svelte/components/CustomerSelect.svelte.d.ts +47 -0
- package/dist/svelte/components/CustomerSelect.svelte.d.ts.map +1 -0
- package/dist/svelte/components/PartySelect.svelte +138 -0
- package/dist/svelte/components/PartySelect.svelte.d.ts +70 -0
- package/dist/svelte/components/PartySelect.svelte.d.ts.map +1 -0
- package/dist/svelte/components/VendorSelect.svelte +53 -0
- package/dist/svelte/components/VendorSelect.svelte.d.ts +47 -0
- package/dist/svelte/components/VendorSelect.svelte.d.ts.map +1 -0
- package/dist/svelte/i18n.d.ts +8 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +8 -0
- package/dist/svelte/index.d.ts +6 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +6 -0
- package/dist/svelte/playground/PartySelectPreview.svelte +108 -0
- package/dist/svelte/playground/PartySelectPreview.svelte.d.ts +8 -0
- package/dist/svelte/playground/PartySelectPreview.svelte.d.ts.map +1 -0
- package/dist/svelte/playground.d.ts.map +1 -1
- package/dist/svelte/playground.js +19 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +20 -0
- package/dist/ui.js.map +1 -1
- package/package.json +16 -12
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ControlInteractionOptions } from '@happyvertical/smrt-ui/forms';
|
|
3
|
+
import type { CustomerDisplayData } from '../party-types.js';
|
|
4
|
+
import PartySelect from './PartySelect.svelte';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Searchable customer picker for a relation field. Presentation only: the
|
|
8
|
+
* caller owns `search` and `resolve` (returning the customer DTO, whose
|
|
9
|
+
* `profile.name` is the label) and the "New customer" action. Registered as
|
|
10
|
+
* the selector for `@happyvertical/smrt-commerce:Customer`.
|
|
11
|
+
*/
|
|
12
|
+
export interface Props {
|
|
13
|
+
/** Field name; the selected customer id posts under it. */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Selected customer id (bindable). Empty string means no selection. */
|
|
16
|
+
value?: string;
|
|
17
|
+
/** Visible label. Defaults to the localized "Customer". */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Required field: hides the clear button. */
|
|
20
|
+
required?: boolean;
|
|
21
|
+
/** Disabled state. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Validation error shown below the field. */
|
|
24
|
+
error?: string;
|
|
25
|
+
/** Placeholder shown while nothing is selected. */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** Hint announced with the field. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
30
|
+
search: (query: string) => Promise<CustomerDisplayData[]>;
|
|
31
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
32
|
+
resolve?: (id: string) => Promise<CustomerDisplayData | null>;
|
|
33
|
+
/**
|
|
34
|
+
* "New customer" action, offered only when supplied. Receives the text most
|
|
35
|
+
* recently searched for; a returned customer is selected.
|
|
36
|
+
*/
|
|
37
|
+
onCreate?: (
|
|
38
|
+
query: string,
|
|
39
|
+
) => void | CustomerDisplayData | Promise<void | CustomerDisplayData>;
|
|
40
|
+
/** Text for the "New customer" button. */
|
|
41
|
+
createLabel?: string;
|
|
42
|
+
/** Milliseconds to wait after typing before searching. */
|
|
43
|
+
debounceMs?: number;
|
|
44
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
45
|
+
interaction?: ControlInteractionOptions | false;
|
|
46
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
47
|
+
onchange?: (id: string) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let { value = $bindable(''), ...rest }: Props = $props();
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<PartySelect kind="customer" bind:value {...rest} />
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ControlInteractionOptions } from '@happyvertical/smrt-ui/forms';
|
|
2
|
+
import type { CustomerDisplayData } from '../party-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Searchable customer picker for a relation field. Presentation only: the
|
|
5
|
+
* caller owns `search` and `resolve` (returning the customer DTO, whose
|
|
6
|
+
* `profile.name` is the label) and the "New customer" action. Registered as
|
|
7
|
+
* the selector for `@happyvertical/smrt-commerce:Customer`.
|
|
8
|
+
*/
|
|
9
|
+
export interface Props {
|
|
10
|
+
/** Field name; the selected customer id posts under it. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Selected customer id (bindable). Empty string means no selection. */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** Visible label. Defaults to the localized "Customer". */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Required field: hides the clear button. */
|
|
17
|
+
required?: boolean;
|
|
18
|
+
/** Disabled state. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Validation error shown below the field. */
|
|
21
|
+
error?: string;
|
|
22
|
+
/** Placeholder shown while nothing is selected. */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** Hint announced with the field. */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
27
|
+
search: (query: string) => Promise<CustomerDisplayData[]>;
|
|
28
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
29
|
+
resolve?: (id: string) => Promise<CustomerDisplayData | null>;
|
|
30
|
+
/**
|
|
31
|
+
* "New customer" action, offered only when supplied. Receives the text most
|
|
32
|
+
* recently searched for; a returned customer is selected.
|
|
33
|
+
*/
|
|
34
|
+
onCreate?: (query: string) => void | CustomerDisplayData | Promise<void | CustomerDisplayData>;
|
|
35
|
+
/** Text for the "New customer" button. */
|
|
36
|
+
createLabel?: string;
|
|
37
|
+
/** Milliseconds to wait after typing before searching. */
|
|
38
|
+
debounceMs?: number;
|
|
39
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
40
|
+
interaction?: ControlInteractionOptions | false;
|
|
41
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
42
|
+
onchange?: (id: string) => void;
|
|
43
|
+
}
|
|
44
|
+
declare const CustomerSelect: import("svelte").Component<Props, {}, "value">;
|
|
45
|
+
type CustomerSelect = ReturnType<typeof CustomerSelect>;
|
|
46
|
+
export default CustomerSelect;
|
|
47
|
+
//# sourceMappingURL=CustomerSelect.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomerSelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/CustomerSelect.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI7D;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,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
3
|
+
type ControlInteractionOptions,
|
|
4
|
+
RelationInput,
|
|
5
|
+
type RelationOption,
|
|
6
|
+
} from '@happyvertical/smrt-ui/forms';
|
|
7
|
+
import { useI18n } from '@happyvertical/smrt-ui/i18n';
|
|
8
|
+
import { M } from '../i18n.js';
|
|
9
|
+
import type { CustomerDisplayData, VendorDisplayData } from '../party-types.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shared adapter behind `CustomerSelect` and `VendorSelect`: maps party DTOs to
|
|
13
|
+
* the smrt-ui `RelationInput` and localizes its text. Presentation only: the
|
|
14
|
+
* caller owns `search`, `resolve` and `onCreate`, so the lookup an assistant
|
|
15
|
+
* uses to turn a name into a record id also backs the field.
|
|
16
|
+
*/
|
|
17
|
+
export interface Props<Party> {
|
|
18
|
+
/** Which party this picks; selects the default label, hints and detail line. */
|
|
19
|
+
kind: 'customer' | 'vendor';
|
|
20
|
+
/** Field name; the selected id posts under it. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Selected record id (bindable). Empty string means no selection. */
|
|
23
|
+
value?: string;
|
|
24
|
+
/** Visible label. Defaults to the localized party name. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Required field: hides the clear button. */
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** Disabled state. */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Validation error shown below the field. */
|
|
31
|
+
error?: string;
|
|
32
|
+
/** Placeholder shown while nothing is selected. */
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
/** Hint announced with the field. */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
37
|
+
search: (query: string) => Promise<Party[]>;
|
|
38
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
39
|
+
resolve?: (id: string) => Promise<Party | null>;
|
|
40
|
+
/**
|
|
41
|
+
* "New ..." action, offered only when supplied. Receives the text most
|
|
42
|
+
* recently searched for; a returned record is selected.
|
|
43
|
+
*/
|
|
44
|
+
onCreate?: (query: string) => void | Party | Promise<void | Party>;
|
|
45
|
+
/** Text for the "New ..." button. */
|
|
46
|
+
createLabel?: string;
|
|
47
|
+
/** Milliseconds to wait after typing before searching. */
|
|
48
|
+
debounceMs?: number;
|
|
49
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
50
|
+
interaction?: ControlInteractionOptions | false;
|
|
51
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
52
|
+
onchange?: (id: string) => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
kind,
|
|
57
|
+
value = $bindable(''),
|
|
58
|
+
label,
|
|
59
|
+
placeholder,
|
|
60
|
+
createLabel,
|
|
61
|
+
search,
|
|
62
|
+
resolve,
|
|
63
|
+
onCreate,
|
|
64
|
+
...rest
|
|
65
|
+
}: Props<T> = $props();
|
|
66
|
+
|
|
67
|
+
const { t } = useI18n();
|
|
68
|
+
|
|
69
|
+
const singular = $derived(
|
|
70
|
+
t(
|
|
71
|
+
kind === 'customer'
|
|
72
|
+
? M['commerce.customer.singular']
|
|
73
|
+
: M['commerce.vendor.singular'],
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
const fieldLabel = $derived(label ?? singular);
|
|
77
|
+
|
|
78
|
+
function statusLabel(status: string): string {
|
|
79
|
+
if (status === 'active') return t(M['commerce.party.status_active']);
|
|
80
|
+
if (status === 'inactive') return t(M['commerce.party.status_inactive']);
|
|
81
|
+
if (status === 'suspended') return t(M['commerce.party.status_suspended']);
|
|
82
|
+
return status;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function typeLabel(type: string): string {
|
|
86
|
+
if (type === 'dtc') return t(M['commerce.customer.type_dtc']);
|
|
87
|
+
if (type === 'wholesale') return t(M['commerce.customer.type_wholesale']);
|
|
88
|
+
if (type === 'retail') return t(M['commerce.customer.type_retail']);
|
|
89
|
+
return type;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A party as a list row: the profile name, with status (and type) beneath. */
|
|
93
|
+
function toOption(
|
|
94
|
+
party: CustomerDisplayData | VendorDisplayData,
|
|
95
|
+
): RelationOption {
|
|
96
|
+
const type = 'customerType' in party ? party.customerType : undefined;
|
|
97
|
+
const detail = [
|
|
98
|
+
party.status ? statusLabel(party.status) : '',
|
|
99
|
+
type ? typeLabel(type) : '',
|
|
100
|
+
]
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.join(' · ');
|
|
103
|
+
return {
|
|
104
|
+
id: party.id,
|
|
105
|
+
label: party.profile.name,
|
|
106
|
+
...(detail ? { detail } : {}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<RelationInput
|
|
112
|
+
{...rest}
|
|
113
|
+
bind:value
|
|
114
|
+
label={fieldLabel}
|
|
115
|
+
placeholder={placeholder ??
|
|
116
|
+
t(kind === 'customer' ? M['commerce.customer.search'] : M['commerce.vendor.search'])}
|
|
117
|
+
createLabel={createLabel ??
|
|
118
|
+
t(kind === 'customer' ? M['commerce.select.new_customer'] : M['commerce.select.new_vendor'])}
|
|
119
|
+
clearLabel={t(M['commerce.select.clear'], { label: fieldLabel })}
|
|
120
|
+
loadingText={t(M['commerce.select.searching'])}
|
|
121
|
+
emptyText={t(M['commerce.select.no_matches'])}
|
|
122
|
+
errorText={t(M['commerce.select.search_failed'])}
|
|
123
|
+
resultsText={(count) =>
|
|
124
|
+
t(count === 1 ? M['commerce.select.results_one'] : M['commerce.select.results_other'], { count })}
|
|
125
|
+
search={async (query) => (await search(query)).map(toOption)}
|
|
126
|
+
resolve={resolve
|
|
127
|
+
? async (id) => {
|
|
128
|
+
const found = await resolve(id);
|
|
129
|
+
return found ? { id: found.id, label: found.profile.name } : null;
|
|
130
|
+
}
|
|
131
|
+
: undefined}
|
|
132
|
+
onCreate={onCreate
|
|
133
|
+
? async (query) => {
|
|
134
|
+
const made = await onCreate(query);
|
|
135
|
+
return made && typeof made === 'object' ? toOption(made) : undefined;
|
|
136
|
+
}
|
|
137
|
+
: undefined}
|
|
138
|
+
/>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ControlInteractionOptions } from '@happyvertical/smrt-ui/forms';
|
|
2
|
+
import type { CustomerDisplayData, VendorDisplayData } from '../party-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared adapter behind `CustomerSelect` and `VendorSelect`: maps party DTOs to
|
|
5
|
+
* the smrt-ui `RelationInput` and localizes its text. Presentation only: the
|
|
6
|
+
* caller owns `search`, `resolve` and `onCreate`, so the lookup an assistant
|
|
7
|
+
* uses to turn a name into a record id also backs the field.
|
|
8
|
+
*/
|
|
9
|
+
export interface Props<Party> {
|
|
10
|
+
/** Which party this picks; selects the default label, hints and detail line. */
|
|
11
|
+
kind: 'customer' | 'vendor';
|
|
12
|
+
/** Field name; the selected id posts under it. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Selected record id (bindable). Empty string means no selection. */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Visible label. Defaults to the localized party name. */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Required field: hides the clear button. */
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/** Disabled state. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Validation error shown below the field. */
|
|
23
|
+
error?: string;
|
|
24
|
+
/** Placeholder shown while nothing is selected. */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** Hint announced with the field. */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
29
|
+
search: (query: string) => Promise<Party[]>;
|
|
30
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
31
|
+
resolve?: (id: string) => Promise<Party | null>;
|
|
32
|
+
/**
|
|
33
|
+
* "New ..." action, offered only when supplied. Receives the text most
|
|
34
|
+
* recently searched for; a returned record is selected.
|
|
35
|
+
*/
|
|
36
|
+
onCreate?: (query: string) => void | Party | Promise<void | Party>;
|
|
37
|
+
/** Text for the "New ..." button. */
|
|
38
|
+
createLabel?: string;
|
|
39
|
+
/** Milliseconds to wait after typing before searching. */
|
|
40
|
+
debounceMs?: number;
|
|
41
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
42
|
+
interaction?: ControlInteractionOptions | false;
|
|
43
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
44
|
+
onchange?: (id: string) => void;
|
|
45
|
+
}
|
|
46
|
+
declare function $$render<T extends CustomerDisplayData | VendorDisplayData>(): {
|
|
47
|
+
props: Props<T>;
|
|
48
|
+
exports: {};
|
|
49
|
+
bindings: "value";
|
|
50
|
+
slots: {};
|
|
51
|
+
events: {};
|
|
52
|
+
};
|
|
53
|
+
declare class __sveltets_Render<T extends CustomerDisplayData | VendorDisplayData> {
|
|
54
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
55
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
56
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
57
|
+
bindings(): "value";
|
|
58
|
+
exports(): {};
|
|
59
|
+
}
|
|
60
|
+
interface $$IsomorphicComponent {
|
|
61
|
+
new <T extends CustomerDisplayData | VendorDisplayData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
62
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
63
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
64
|
+
<T extends CustomerDisplayData | VendorDisplayData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
65
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
66
|
+
}
|
|
67
|
+
declare const PartySelect: $$IsomorphicComponent;
|
|
68
|
+
type PartySelect<T extends CustomerDisplayData | VendorDisplayData> = InstanceType<typeof PartySelect<T>>;
|
|
69
|
+
export default PartySelect;
|
|
70
|
+
//# sourceMappingURL=PartySelect.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartySelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/PartySelect.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,yBAAyB,EAG/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGhF;;;;;GAKG;AACH,MAAM,WAAW,KAAK,CAAC,KAAK;IAC1B,gFAAgF;IAChF,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5C,gFAAgF;IAChF,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC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AC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5a,CAAC,CAAC,SAAS,mBAAmB,GAAG,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3K,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,WAAW,EAAE,qBAAmC,CAAC;AACrC,KAAK,WAAW,CAAC,CAAC,SAAS,mBAAmB,GAAG,iBAAiB,IAAI,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5G,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ControlInteractionOptions } from '@happyvertical/smrt-ui/forms';
|
|
3
|
+
import type { VendorDisplayData } from '../party-types.js';
|
|
4
|
+
import PartySelect from './PartySelect.svelte';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Searchable vendor picker for a relation field. Presentation only: the
|
|
8
|
+
* caller owns `search` and `resolve` (returning the vendor DTO, whose
|
|
9
|
+
* `profile.name` is the label) and the "New vendor" action. Registered as
|
|
10
|
+
* the selector for `@happyvertical/smrt-commerce:Vendor`.
|
|
11
|
+
*/
|
|
12
|
+
export interface Props {
|
|
13
|
+
/** Field name; the selected vendor id posts under it. */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Selected vendor id (bindable). Empty string means no selection. */
|
|
16
|
+
value?: string;
|
|
17
|
+
/** Visible label. Defaults to the localized "Vendor". */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Required field: hides the clear button. */
|
|
20
|
+
required?: boolean;
|
|
21
|
+
/** Disabled state. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Validation error shown below the field. */
|
|
24
|
+
error?: string;
|
|
25
|
+
/** Placeholder shown while nothing is selected. */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** Hint announced with the field. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
30
|
+
search: (query: string) => Promise<VendorDisplayData[]>;
|
|
31
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
32
|
+
resolve?: (id: string) => Promise<VendorDisplayData | null>;
|
|
33
|
+
/**
|
|
34
|
+
* "New vendor" action, offered only when supplied. Receives the text most
|
|
35
|
+
* recently searched for; a returned vendor is selected.
|
|
36
|
+
*/
|
|
37
|
+
onCreate?: (
|
|
38
|
+
query: string,
|
|
39
|
+
) => void | VendorDisplayData | Promise<void | VendorDisplayData>;
|
|
40
|
+
/** Text for the "New vendor" button. */
|
|
41
|
+
createLabel?: string;
|
|
42
|
+
/** Milliseconds to wait after typing before searching. */
|
|
43
|
+
debounceMs?: number;
|
|
44
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
45
|
+
interaction?: ControlInteractionOptions | false;
|
|
46
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
47
|
+
onchange?: (id: string) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let { value = $bindable(''), ...rest }: Props = $props();
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<PartySelect kind="vendor" bind:value {...rest} />
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ControlInteractionOptions } from '@happyvertical/smrt-ui/forms';
|
|
2
|
+
import type { VendorDisplayData } from '../party-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Searchable vendor picker for a relation field. Presentation only: the
|
|
5
|
+
* caller owns `search` and `resolve` (returning the vendor DTO, whose
|
|
6
|
+
* `profile.name` is the label) and the "New vendor" action. Registered as
|
|
7
|
+
* the selector for `@happyvertical/smrt-commerce:Vendor`.
|
|
8
|
+
*/
|
|
9
|
+
export interface Props {
|
|
10
|
+
/** Field name; the selected vendor id posts under it. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Selected vendor id (bindable). Empty string means no selection. */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** Visible label. Defaults to the localized "Vendor". */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Required field: hides the clear button. */
|
|
17
|
+
required?: boolean;
|
|
18
|
+
/** Disabled state. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Validation error shown below the field. */
|
|
21
|
+
error?: string;
|
|
22
|
+
/** Placeholder shown while nothing is selected. */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** Hint announced with the field. */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Caller-owned lookup; called with '' when the list opens. */
|
|
27
|
+
search: (query: string) => Promise<VendorDisplayData[]>;
|
|
28
|
+
/** Caller-owned lookup of the current value when it has not been listed yet. */
|
|
29
|
+
resolve?: (id: string) => Promise<VendorDisplayData | null>;
|
|
30
|
+
/**
|
|
31
|
+
* "New vendor" action, offered only when supplied. Receives the text most
|
|
32
|
+
* recently searched for; a returned vendor is selected.
|
|
33
|
+
*/
|
|
34
|
+
onCreate?: (query: string) => void | VendorDisplayData | Promise<void | VendorDisplayData>;
|
|
35
|
+
/** Text for the "New vendor" button. */
|
|
36
|
+
createLabel?: string;
|
|
37
|
+
/** Milliseconds to wait after typing before searching. */
|
|
38
|
+
debounceMs?: number;
|
|
39
|
+
/** Combobox interaction options for agents, or false to opt out. */
|
|
40
|
+
interaction?: ControlInteractionOptions | false;
|
|
41
|
+
/** Called when the selected id changes ('' when cleared). */
|
|
42
|
+
onchange?: (id: string) => void;
|
|
43
|
+
}
|
|
44
|
+
declare const VendorSelect: import("svelte").Component<Props, {}, "value">;
|
|
45
|
+
type VendorSelect = ReturnType<typeof VendorSelect>;
|
|
46
|
+
export default VendorSelect;
|
|
47
|
+
//# sourceMappingURL=VendorSelect.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VendorSelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/VendorSelect.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxD,gFAAgF;IAChF,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC5D;;;OAGG;IACH,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,MAAM,KACV,IAAI,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,GAAG,iBAAiB,CAAC,CAAC;IAClE,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,WAAW,CAAC,EAAE,yBAAyB,GAAG,KAAK,CAAC;IAChD,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAcD,QAAA,MAAM,YAAY,gDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
package/dist/svelte/i18n.d.ts
CHANGED
|
@@ -103,6 +103,14 @@ export declare const M: {
|
|
|
103
103
|
readonly 'commerce.vendor.no_results': "commerce.vendor.no_results";
|
|
104
104
|
readonly 'commerce.vendor.loading': "commerce.vendor.loading";
|
|
105
105
|
readonly 'commerce.vendor.details': "commerce.vendor.details";
|
|
106
|
+
readonly 'commerce.select.new_customer': "commerce.select.new_customer";
|
|
107
|
+
readonly 'commerce.select.new_vendor': "commerce.select.new_vendor";
|
|
108
|
+
readonly 'commerce.select.searching': "commerce.select.searching";
|
|
109
|
+
readonly 'commerce.select.no_matches': "commerce.select.no_matches";
|
|
110
|
+
readonly 'commerce.select.search_failed': "commerce.select.search_failed";
|
|
111
|
+
readonly 'commerce.select.results_one': "commerce.select.results_one";
|
|
112
|
+
readonly 'commerce.select.results_other': "commerce.select.results_other";
|
|
113
|
+
readonly 'commerce.select.clear': "commerce.select.clear";
|
|
106
114
|
readonly 'commerce.invoice_actions.send_invoice': "commerce.invoice_actions.send_invoice";
|
|
107
115
|
readonly 'commerce.invoice_actions.mark_as_paid': "commerce.invoice_actions.mark_as_paid";
|
|
108
116
|
readonly 'commerce.invoice_header.issue_date': "commerce.invoice_header.issue_date";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIZ,CAAC"}
|
package/dist/svelte/i18n.js
CHANGED
|
@@ -104,6 +104,14 @@ export const M = defineMessages({
|
|
|
104
104
|
'commerce.vendor.no_results': 'No vendors found',
|
|
105
105
|
'commerce.vendor.loading': 'Loading vendors',
|
|
106
106
|
'commerce.vendor.details': 'Vendor details',
|
|
107
|
+
'commerce.select.new_customer': 'New customer',
|
|
108
|
+
'commerce.select.new_vendor': 'New vendor',
|
|
109
|
+
'commerce.select.searching': 'Searching…',
|
|
110
|
+
'commerce.select.no_matches': 'No matches',
|
|
111
|
+
'commerce.select.search_failed': 'Search failed. Try again.',
|
|
112
|
+
'commerce.select.results_one': '{count} result available',
|
|
113
|
+
'commerce.select.results_other': '{count} results available',
|
|
114
|
+
'commerce.select.clear': 'Clear {label}',
|
|
107
115
|
'commerce.invoice_actions.send_invoice': 'Send Invoice',
|
|
108
116
|
'commerce.invoice_actions.mark_as_paid': 'Mark as Paid',
|
|
109
117
|
'commerce.invoice_header.issue_date': 'Issue Date',
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { ComponentProps } from 'svelte';
|
|
|
21
21
|
import CustomerDetail from './components/CustomerDetail.svelte';
|
|
22
22
|
import CustomerDirectory from './components/CustomerDirectory.svelte';
|
|
23
23
|
import CustomerForm from './components/CustomerForm.svelte';
|
|
24
|
+
import CustomerSelect from './components/CustomerSelect.svelte';
|
|
24
25
|
import InvoiceActions from './components/InvoiceActions.svelte';
|
|
25
26
|
import InvoiceCard from './components/InvoiceCard.svelte';
|
|
26
27
|
import InvoiceHeader from './components/InvoiceHeader.svelte';
|
|
@@ -31,12 +32,17 @@ import UnbilledItems from './components/UnbilledItems.svelte';
|
|
|
31
32
|
import VendorDetail from './components/VendorDetail.svelte';
|
|
32
33
|
import VendorDirectory from './components/VendorDirectory.svelte';
|
|
33
34
|
import VendorForm from './components/VendorForm.svelte';
|
|
35
|
+
import VendorSelect from './components/VendorSelect.svelte';
|
|
34
36
|
export type CustomerDetailProps = ComponentProps<typeof CustomerDetail>;
|
|
35
37
|
export { default as CustomerDetail } from './components/CustomerDetail.svelte';
|
|
36
38
|
export type CustomerDirectoryProps = ComponentProps<typeof CustomerDirectory>;
|
|
37
39
|
export { default as CustomerDirectory } from './components/CustomerDirectory.svelte';
|
|
38
40
|
export type CustomerFormProps = ComponentProps<typeof CustomerForm>;
|
|
39
41
|
export { default as CustomerForm } from './components/CustomerForm.svelte';
|
|
42
|
+
export type CustomerSelectProps = ComponentProps<typeof CustomerSelect>;
|
|
43
|
+
export { default as CustomerSelect } from './components/CustomerSelect.svelte';
|
|
44
|
+
export type VendorSelectProps = ComponentProps<typeof VendorSelect>;
|
|
45
|
+
export { default as VendorSelect } from './components/VendorSelect.svelte';
|
|
40
46
|
export type InvoiceActionsProps = ComponentProps<typeof InvoiceActions>;
|
|
41
47
|
export { default as InvoiceActions } from './components/InvoiceActions.svelte';
|
|
42
48
|
export type InvoiceCardProps = ComponentProps<typeof InvoiceCard>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAI7C,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,YAAY,MAAM,kCAAkC,CAAC;AAC5D,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAC9D,OAAO,gBAAgB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GAAG,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AACtE,YAAY,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAa7B,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,sBAAsB,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;AACvD,MAAM,MAAM,wBAAwB,GAAG,cAAc,CACnD,OAAO,mBAAmB,CAC3B,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,cAAc,CACtD,OAAO,sBAAsB,CAC9B,CAAC;AACF,YAAY,EACV,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/svelte/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { COMMERCE_MODULE_META } from '../ui.js';
|
|
|
23
23
|
import CustomerDetail from './components/CustomerDetail.svelte';
|
|
24
24
|
import CustomerDirectory from './components/CustomerDirectory.svelte';
|
|
25
25
|
import CustomerForm from './components/CustomerForm.svelte';
|
|
26
|
+
import CustomerSelect from './components/CustomerSelect.svelte';
|
|
26
27
|
import InvoiceActions from './components/InvoiceActions.svelte';
|
|
27
28
|
import InvoiceCard from './components/InvoiceCard.svelte';
|
|
28
29
|
import InvoiceHeader from './components/InvoiceHeader.svelte';
|
|
@@ -33,9 +34,12 @@ import UnbilledItems from './components/UnbilledItems.svelte';
|
|
|
33
34
|
import VendorDetail from './components/VendorDetail.svelte';
|
|
34
35
|
import VendorDirectory from './components/VendorDirectory.svelte';
|
|
35
36
|
import VendorForm from './components/VendorForm.svelte';
|
|
37
|
+
import VendorSelect from './components/VendorSelect.svelte';
|
|
36
38
|
export { default as CustomerDetail } from './components/CustomerDetail.svelte';
|
|
37
39
|
export { default as CustomerDirectory } from './components/CustomerDirectory.svelte';
|
|
38
40
|
export { default as CustomerForm } from './components/CustomerForm.svelte';
|
|
41
|
+
export { default as CustomerSelect } from './components/CustomerSelect.svelte';
|
|
42
|
+
export { default as VendorSelect } from './components/VendorSelect.svelte';
|
|
39
43
|
// Export components
|
|
40
44
|
export { default as InvoiceActions } from './components/InvoiceActions.svelte';
|
|
41
45
|
export { default as InvoiceCard } from './components/InvoiceCard.svelte';
|
|
@@ -91,3 +95,5 @@ export { PurchaseOrderEditor, PurchaseSourceSelector };
|
|
|
91
95
|
export { purchaseFieldNames } from './purchasing-types.js';
|
|
92
96
|
ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'purchase-order-editor', PurchaseOrderEditor);
|
|
93
97
|
ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'purchase-source-selector', PurchaseSourceSelector);
|
|
98
|
+
ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'customer-select', CustomerSelect);
|
|
99
|
+
ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'vendor-select', VendorSelect);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useI18n } from '@happyvertical/smrt-ui/i18n';
|
|
3
|
+
import CustomerSelect from '../components/CustomerSelect.svelte';
|
|
4
|
+
import VendorSelect from '../components/VendorSelect.svelte';
|
|
5
|
+
import { M } from '../i18n.js';
|
|
6
|
+
import type { CustomerDisplayData, VendorDisplayData } from '../party-types.js';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
/** Selects the in-memory customer or vendor selector demonstration. */
|
|
10
|
+
kind: 'customer' | 'vendor';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { kind }: Props = $props();
|
|
14
|
+
const { t } = useI18n();
|
|
15
|
+
|
|
16
|
+
const customers: CustomerDisplayData[] = [
|
|
17
|
+
{
|
|
18
|
+
id: 'customer-riverstone',
|
|
19
|
+
profile: { name: 'Riverstone Newsroom' },
|
|
20
|
+
status: 'active',
|
|
21
|
+
customerType: 'wholesale',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'customer-harbour',
|
|
25
|
+
profile: { name: 'Harbour Books' },
|
|
26
|
+
status: 'active',
|
|
27
|
+
customerType: 'retail',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'customer-maple',
|
|
31
|
+
profile: { name: 'Maple Direct' },
|
|
32
|
+
status: 'suspended',
|
|
33
|
+
customerType: 'dtc',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const vendors: VendorDisplayData[] = [
|
|
37
|
+
{
|
|
38
|
+
id: 'vendor-northstar',
|
|
39
|
+
profile: { name: 'Northstar Supply' },
|
|
40
|
+
status: 'active',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'vendor-cedar',
|
|
44
|
+
profile: { name: 'Cedar Paper Co.' },
|
|
45
|
+
status: 'active',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'vendor-delta',
|
|
49
|
+
profile: { name: 'Delta Freight' },
|
|
50
|
+
status: 'inactive',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
let customerId = $state('customer-riverstone');
|
|
55
|
+
let vendorId = $state('');
|
|
56
|
+
let added = 0;
|
|
57
|
+
|
|
58
|
+
const match = <T extends { profile: { name: string } }>(
|
|
59
|
+
rows: T[],
|
|
60
|
+
query: string,
|
|
61
|
+
) =>
|
|
62
|
+
rows.filter((row) =>
|
|
63
|
+
row.profile.name.toLowerCase().includes(query.toLowerCase()),
|
|
64
|
+
);
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<div class="preview">
|
|
68
|
+
{#if kind === 'customer'}
|
|
69
|
+
<CustomerSelect
|
|
70
|
+
name="customerId"
|
|
71
|
+
bind:value={customerId}
|
|
72
|
+
search={async (query) => match(customers, query)}
|
|
73
|
+
resolve={async (id) => customers.find((row) => row.id === id) ?? null}
|
|
74
|
+
onCreate={async (query) => {
|
|
75
|
+
added += 1;
|
|
76
|
+
const made: CustomerDisplayData = {
|
|
77
|
+
id: `customer-new-${added}`,
|
|
78
|
+
profile: { name: query || `${t(M['commerce.customer.singular'])} ${added}` },
|
|
79
|
+
status: 'active',
|
|
80
|
+
customerType: 'dtc',
|
|
81
|
+
};
|
|
82
|
+
customers.push(made);
|
|
83
|
+
return made;
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
<p>Posts <code>customerId={customerId || '(empty)'}</code></p>
|
|
87
|
+
{:else}
|
|
88
|
+
<VendorSelect
|
|
89
|
+
name="vendorId"
|
|
90
|
+
bind:value={vendorId}
|
|
91
|
+
search={async (query) => match(vendors, query)}
|
|
92
|
+
resolve={async (id) => vendors.find((row) => row.id === id) ?? null}
|
|
93
|
+
/>
|
|
94
|
+
<p>Posts <code>vendorId={vendorId || '(empty)'}</code></p>
|
|
95
|
+
{/if}
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
.preview {
|
|
100
|
+
display: grid;
|
|
101
|
+
gap: var(--smrt-spacing-2, 8px);
|
|
102
|
+
max-width: 28rem;
|
|
103
|
+
color: var(--smrt-color-on-surface);
|
|
104
|
+
}
|
|
105
|
+
p {
|
|
106
|
+
margin: 0;
|
|
107
|
+
}
|
|
108
|
+
</style>
|