@happyvertical/smrt-manufacturing 0.53.3 → 0.53.5
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 +45 -6
- package/README.md +161 -3
- package/dist/collections/AssemblyCollection.d.ts +15 -0
- package/dist/collections/AssemblyCollection.d.ts.map +1 -0
- package/dist/collections/OperationCollection.d.ts +20 -0
- package/dist/collections/OperationCollection.d.ts.map +1 -0
- package/dist/collections/RoutingStepCollection.d.ts +15 -0
- package/dist/collections/RoutingStepCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +3 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +756 -29
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1248 -128
- package/dist/models/Assembly.d.ts +62 -0
- package/dist/models/Assembly.d.ts.map +1 -0
- package/dist/models/BillOfMaterials.d.ts +12 -4
- package/dist/models/BillOfMaterials.d.ts.map +1 -1
- package/dist/models/BomLine.d.ts +11 -5
- package/dist/models/BomLine.d.ts.map +1 -1
- package/dist/models/Operation.d.ts +59 -0
- package/dist/models/Operation.d.ts.map +1 -0
- package/dist/models/RoutingStep.d.ts +46 -0
- package/dist/models/RoutingStep.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/operation-types.d.ts +99 -0
- package/dist/operation-types.d.ts.map +1 -0
- package/dist/services/AssemblyService.d.ts +217 -0
- package/dist/services/AssemblyService.d.ts.map +1 -0
- package/dist/services/BomService.d.ts +25 -1
- package/dist/services/BomService.d.ts.map +1 -1
- package/dist/services/OperationService.d.ts +48 -0
- package/dist/services/OperationService.d.ts.map +1 -0
- package/dist/services/RoutingService.d.ts +50 -0
- package/dist/services/RoutingService.d.ts.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +1138 -81
- package/dist/svelte/components/AssemblyForm.svelte +69 -0
- package/dist/svelte/components/AssemblyForm.svelte.d.ts +38 -0
- package/dist/svelte/components/AssemblyForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AssemblyList.svelte +229 -0
- package/dist/svelte/components/AssemblyList.svelte.d.ts +28 -0
- package/dist/svelte/components/AssemblyList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/BomEditor.svelte +575 -0
- package/dist/svelte/components/BomEditor.svelte.d.ts +29 -0
- package/dist/svelte/components/BomEditor.svelte.d.ts.map +1 -0
- package/dist/svelte/components/BomStructureTree.svelte +164 -0
- package/dist/svelte/components/BomStructureTree.svelte.d.ts +16 -0
- package/dist/svelte/components/BomStructureTree.svelte.d.ts.map +1 -0
- package/dist/svelte/components/OperationForm.svelte +258 -0
- package/dist/svelte/components/OperationForm.svelte.d.ts +17 -0
- package/dist/svelte/components/OperationForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/OperationList.svelte +170 -0
- package/dist/svelte/components/OperationList.svelte.d.ts +17 -0
- package/dist/svelte/components/OperationList.svelte.d.ts.map +1 -0
- package/dist/svelte/i18n.d.ts +87 -0
- package/dist/svelte/i18n.d.ts.map +1 -0
- package/dist/svelte/i18n.js +87 -0
- package/dist/svelte/index.d.ts +28 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +29 -0
- package/dist/svelte/types.d.ts +170 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +126 -0
- package/dist/ui.d.ts +17 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +72 -0
- package/dist/ui.js.map +1 -0
- package/package.json +39 -10
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message catalog for the manufacturing components. Keys are
|
|
3
|
+
* `manufacturing.<component>.<key>`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const M: {
|
|
6
|
+
readonly 'manufacturing.operation_list.caption': "manufacturing.operation_list.caption";
|
|
7
|
+
readonly 'manufacturing.operation_list.empty': "manufacturing.operation_list.empty";
|
|
8
|
+
readonly 'manufacturing.operation_list.code': "manufacturing.operation_list.code";
|
|
9
|
+
readonly 'manufacturing.operation_list.name': "manufacturing.operation_list.name";
|
|
10
|
+
readonly 'manufacturing.operation_list.category': "manufacturing.operation_list.category";
|
|
11
|
+
readonly 'manufacturing.operation_list.status': "manufacturing.operation_list.status";
|
|
12
|
+
readonly 'manufacturing.operation_list.actions': "manufacturing.operation_list.actions";
|
|
13
|
+
readonly 'manufacturing.operation_list.active': "manufacturing.operation_list.active";
|
|
14
|
+
readonly 'manufacturing.operation_list.retired': "manufacturing.operation_list.retired";
|
|
15
|
+
readonly 'manufacturing.operation_list.none': "manufacturing.operation_list.none";
|
|
16
|
+
readonly 'manufacturing.operation_list.select_aria': "manufacturing.operation_list.select_aria";
|
|
17
|
+
readonly 'manufacturing.operation_list.retire': "manufacturing.operation_list.retire";
|
|
18
|
+
readonly 'manufacturing.operation_list.retire_aria': "manufacturing.operation_list.retire_aria";
|
|
19
|
+
readonly 'manufacturing.operation_list.reinstate': "manufacturing.operation_list.reinstate";
|
|
20
|
+
readonly 'manufacturing.operation_list.reinstate_aria': "manufacturing.operation_list.reinstate_aria";
|
|
21
|
+
readonly 'manufacturing.operation_form.code': "manufacturing.operation_form.code";
|
|
22
|
+
readonly 'manufacturing.operation_form.code_edit_help': "manufacturing.operation_form.code_edit_help";
|
|
23
|
+
readonly 'manufacturing.operation_form.name': "manufacturing.operation_form.name";
|
|
24
|
+
readonly 'manufacturing.operation_form.category': "manufacturing.operation_form.category";
|
|
25
|
+
readonly 'manufacturing.operation_form.category_help': "manufacturing.operation_form.category_help";
|
|
26
|
+
readonly 'manufacturing.operation_form.qualification': "manufacturing.operation_form.qualification";
|
|
27
|
+
readonly 'manufacturing.operation_form.qualification_help': "manufacturing.operation_form.qualification_help";
|
|
28
|
+
readonly 'manufacturing.operation_form.submit_add': "manufacturing.operation_form.submit_add";
|
|
29
|
+
readonly 'manufacturing.operation_form.submit_edit': "manufacturing.operation_form.submit_edit";
|
|
30
|
+
readonly 'manufacturing.operation_form.saving': "manufacturing.operation_form.saving";
|
|
31
|
+
readonly 'manufacturing.operation_form.cancel': "manufacturing.operation_form.cancel";
|
|
32
|
+
readonly 'manufacturing.operation_form.error_code': "manufacturing.operation_form.error_code";
|
|
33
|
+
readonly 'manufacturing.operation_form.error_name': "manufacturing.operation_form.error_name";
|
|
34
|
+
readonly 'manufacturing.assembly_list.caption': "manufacturing.assembly_list.caption";
|
|
35
|
+
readonly 'manufacturing.assembly_list.empty': "manufacturing.assembly_list.empty";
|
|
36
|
+
readonly 'manufacturing.assembly_list.name': "manufacturing.assembly_list.name";
|
|
37
|
+
readonly 'manufacturing.assembly_list.assembly': "manufacturing.assembly_list.assembly";
|
|
38
|
+
readonly 'manufacturing.assembly_list.unnamed': "manufacturing.assembly_list.unnamed";
|
|
39
|
+
readonly 'manufacturing.assembly_list.part_reference': "manufacturing.assembly_list.part_reference";
|
|
40
|
+
readonly 'manufacturing.assembly_list.sku': "manufacturing.assembly_list.sku";
|
|
41
|
+
readonly 'manufacturing.assembly_list.price': "manufacturing.assembly_list.price";
|
|
42
|
+
readonly 'manufacturing.assembly_list.labour': "manufacturing.assembly_list.labour";
|
|
43
|
+
readonly 'manufacturing.assembly_list.bill': "manufacturing.assembly_list.bill";
|
|
44
|
+
readonly 'manufacturing.assembly_list.select_aria': "manufacturing.assembly_list.select_aria";
|
|
45
|
+
readonly 'manufacturing.assembly_list.none': "manufacturing.assembly_list.none";
|
|
46
|
+
readonly 'manufacturing.assembly_list.bill_active': "manufacturing.assembly_list.bill_active";
|
|
47
|
+
readonly 'manufacturing.assembly_list.bill_missing': "manufacturing.assembly_list.bill_missing";
|
|
48
|
+
readonly 'manufacturing.labour.minutes': "manufacturing.labour.minutes";
|
|
49
|
+
readonly 'manufacturing.labour.hours_minutes': "manufacturing.labour.hours_minutes";
|
|
50
|
+
readonly 'manufacturing.labour.not_estimated': "manufacturing.labour.not_estimated";
|
|
51
|
+
readonly 'manufacturing.kind.assembly': "manufacturing.kind.assembly";
|
|
52
|
+
readonly 'manufacturing.kind.material': "manufacturing.kind.material";
|
|
53
|
+
readonly 'manufacturing.kind.bought': "manufacturing.kind.bought";
|
|
54
|
+
readonly 'manufacturing.kind.missing': "manufacturing.kind.missing";
|
|
55
|
+
readonly 'manufacturing.bom_editor.caption': "manufacturing.bom_editor.caption";
|
|
56
|
+
readonly 'manufacturing.bom_editor.empty': "manufacturing.bom_editor.empty";
|
|
57
|
+
readonly 'manufacturing.bom_editor.component': "manufacturing.bom_editor.component";
|
|
58
|
+
readonly 'manufacturing.bom_editor.kind': "manufacturing.bom_editor.kind";
|
|
59
|
+
readonly 'manufacturing.bom_editor.qty_per_unit': "manufacturing.bom_editor.qty_per_unit";
|
|
60
|
+
readonly 'manufacturing.bom_editor.uom': "manufacturing.bom_editor.uom";
|
|
61
|
+
readonly 'manufacturing.bom_editor.waste_percent': "manufacturing.bom_editor.waste_percent";
|
|
62
|
+
readonly 'manufacturing.bom_editor.actions': "manufacturing.bom_editor.actions";
|
|
63
|
+
readonly 'manufacturing.bom_editor.qty_aria': "manufacturing.bom_editor.qty_aria";
|
|
64
|
+
readonly 'manufacturing.bom_editor.uom_aria': "manufacturing.bom_editor.uom_aria";
|
|
65
|
+
readonly 'manufacturing.bom_editor.waste_aria': "manufacturing.bom_editor.waste_aria";
|
|
66
|
+
readonly 'manufacturing.bom_editor.save': "manufacturing.bom_editor.save";
|
|
67
|
+
readonly 'manufacturing.bom_editor.save_aria': "manufacturing.bom_editor.save_aria";
|
|
68
|
+
readonly 'manufacturing.bom_editor.remove': "manufacturing.bom_editor.remove";
|
|
69
|
+
readonly 'manufacturing.bom_editor.remove_aria': "manufacturing.bom_editor.remove_aria";
|
|
70
|
+
readonly 'manufacturing.bom_editor.has_bill': "manufacturing.bom_editor.has_bill";
|
|
71
|
+
readonly 'manufacturing.bom_editor.no_bill': "manufacturing.bom_editor.no_bill";
|
|
72
|
+
readonly 'manufacturing.bom_editor.show_bill': "manufacturing.bom_editor.show_bill";
|
|
73
|
+
readonly 'manufacturing.bom_editor.hide_bill': "manufacturing.bom_editor.hide_bill";
|
|
74
|
+
readonly 'manufacturing.bom_editor.show_bill_aria': "manufacturing.bom_editor.show_bill_aria";
|
|
75
|
+
readonly 'manufacturing.bom_editor.hide_bill_aria': "manufacturing.bom_editor.hide_bill_aria";
|
|
76
|
+
readonly 'manufacturing.bom_editor.sub_bill_label': "manufacturing.bom_editor.sub_bill_label";
|
|
77
|
+
readonly 'manufacturing.bom_editor.loading': "manufacturing.bom_editor.loading";
|
|
78
|
+
readonly 'manufacturing.bom_editor.load_failed': "manufacturing.bom_editor.load_failed";
|
|
79
|
+
readonly 'manufacturing.bom_editor.add_heading': "manufacturing.bom_editor.add_heading";
|
|
80
|
+
readonly 'manufacturing.bom_editor.choose_component': "manufacturing.bom_editor.choose_component";
|
|
81
|
+
readonly 'manufacturing.bom_editor.add': "manufacturing.bom_editor.add";
|
|
82
|
+
readonly 'manufacturing.bom_editor.error_component': "manufacturing.bom_editor.error_component";
|
|
83
|
+
readonly 'manufacturing.bom_editor.error_qty': "manufacturing.bom_editor.error_qty";
|
|
84
|
+
readonly 'manufacturing.bom_editor.error_uom': "manufacturing.bom_editor.error_uom";
|
|
85
|
+
readonly 'manufacturing.bom_editor.error_waste': "manufacturing.bom_editor.error_waste";
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFZ,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { defineMessages } from '@happyvertical/smrt-ui/i18n';
|
|
2
|
+
/**
|
|
3
|
+
* Message catalog for the manufacturing components. Keys are
|
|
4
|
+
* `manufacturing.<component>.<key>`.
|
|
5
|
+
*/
|
|
6
|
+
export const M = defineMessages({
|
|
7
|
+
'manufacturing.operation_list.caption': 'Operations',
|
|
8
|
+
'manufacturing.operation_list.empty': 'No operations',
|
|
9
|
+
'manufacturing.operation_list.code': 'Code',
|
|
10
|
+
'manufacturing.operation_list.name': 'Name',
|
|
11
|
+
'manufacturing.operation_list.category': 'Category',
|
|
12
|
+
'manufacturing.operation_list.status': 'Status',
|
|
13
|
+
'manufacturing.operation_list.actions': 'Actions',
|
|
14
|
+
'manufacturing.operation_list.active': 'Active',
|
|
15
|
+
'manufacturing.operation_list.retired': 'Retired',
|
|
16
|
+
'manufacturing.operation_list.none': 'None',
|
|
17
|
+
'manufacturing.operation_list.select_aria': 'Edit operation: {name}',
|
|
18
|
+
'manufacturing.operation_list.retire': 'Retire',
|
|
19
|
+
'manufacturing.operation_list.retire_aria': 'Retire operation: {name}',
|
|
20
|
+
'manufacturing.operation_list.reinstate': 'Reinstate',
|
|
21
|
+
'manufacturing.operation_list.reinstate_aria': 'Reinstate operation: {name}',
|
|
22
|
+
'manufacturing.operation_form.code': 'Code',
|
|
23
|
+
'manufacturing.operation_form.code_edit_help': 'The code cannot be changed.',
|
|
24
|
+
'manufacturing.operation_form.name': 'Name',
|
|
25
|
+
'manufacturing.operation_form.category': 'Category',
|
|
26
|
+
'manufacturing.operation_form.category_help': 'Optional. Groups operations in lists.',
|
|
27
|
+
'manufacturing.operation_form.qualification': 'Required qualification',
|
|
28
|
+
'manufacturing.operation_form.qualification_help': 'Optional. The id of the qualification a worker needs to start this operation.',
|
|
29
|
+
'manufacturing.operation_form.submit_add': 'Add operation',
|
|
30
|
+
'manufacturing.operation_form.submit_edit': 'Save changes',
|
|
31
|
+
'manufacturing.operation_form.saving': 'Saving...',
|
|
32
|
+
'manufacturing.operation_form.cancel': 'Cancel',
|
|
33
|
+
'manufacturing.operation_form.error_code': 'Enter a code.',
|
|
34
|
+
'manufacturing.operation_form.error_name': 'Enter a name.',
|
|
35
|
+
'manufacturing.assembly_list.caption': 'Assemblies',
|
|
36
|
+
'manufacturing.assembly_list.empty': 'No assemblies',
|
|
37
|
+
'manufacturing.assembly_list.name': 'Name',
|
|
38
|
+
'manufacturing.assembly_list.assembly': 'Assembly',
|
|
39
|
+
'manufacturing.assembly_list.unnamed': 'Unnamed assembly',
|
|
40
|
+
'manufacturing.assembly_list.part_reference': 'Part reference',
|
|
41
|
+
'manufacturing.assembly_list.sku': 'SKU',
|
|
42
|
+
'manufacturing.assembly_list.price': 'Price',
|
|
43
|
+
'manufacturing.assembly_list.labour': 'Labour',
|
|
44
|
+
'manufacturing.assembly_list.bill': 'Bill of materials',
|
|
45
|
+
'manufacturing.assembly_list.select_aria': 'Open assembly: {name}',
|
|
46
|
+
'manufacturing.assembly_list.none': 'None',
|
|
47
|
+
'manufacturing.assembly_list.bill_active': 'Version {version}',
|
|
48
|
+
'manufacturing.assembly_list.bill_missing': 'No active bill',
|
|
49
|
+
'manufacturing.labour.minutes': '{minutes} min',
|
|
50
|
+
'manufacturing.labour.hours_minutes': '{hours} h {minutes} min',
|
|
51
|
+
'manufacturing.labour.not_estimated': 'Not estimated',
|
|
52
|
+
'manufacturing.kind.assembly': 'Sub-assembly',
|
|
53
|
+
'manufacturing.kind.material': 'Material',
|
|
54
|
+
'manufacturing.kind.bought': 'Bought item',
|
|
55
|
+
'manufacturing.kind.missing': 'Missing',
|
|
56
|
+
'manufacturing.bom_editor.caption': 'Bill of materials',
|
|
57
|
+
'manufacturing.bom_editor.empty': 'This bill has no lines yet',
|
|
58
|
+
'manufacturing.bom_editor.component': 'Component',
|
|
59
|
+
'manufacturing.bom_editor.kind': 'Kind',
|
|
60
|
+
'manufacturing.bom_editor.qty_per_unit': 'Quantity per unit',
|
|
61
|
+
'manufacturing.bom_editor.uom': 'Unit',
|
|
62
|
+
'manufacturing.bom_editor.waste_percent': 'Waste %',
|
|
63
|
+
'manufacturing.bom_editor.actions': 'Actions',
|
|
64
|
+
'manufacturing.bom_editor.qty_aria': 'Quantity per unit for {component}',
|
|
65
|
+
'manufacturing.bom_editor.uom_aria': 'Unit for {component}',
|
|
66
|
+
'manufacturing.bom_editor.waste_aria': 'Waste percent for {component}',
|
|
67
|
+
'manufacturing.bom_editor.save': 'Save',
|
|
68
|
+
'manufacturing.bom_editor.save_aria': 'Save line: {component}',
|
|
69
|
+
'manufacturing.bom_editor.remove': 'Remove',
|
|
70
|
+
'manufacturing.bom_editor.remove_aria': 'Remove line: {component}',
|
|
71
|
+
'manufacturing.bom_editor.has_bill': 'Has its own bill',
|
|
72
|
+
'manufacturing.bom_editor.no_bill': 'No active bill',
|
|
73
|
+
'manufacturing.bom_editor.show_bill': 'Show bill',
|
|
74
|
+
'manufacturing.bom_editor.hide_bill': 'Hide bill',
|
|
75
|
+
'manufacturing.bom_editor.show_bill_aria': 'Show the bill of {component}',
|
|
76
|
+
'manufacturing.bom_editor.hide_bill_aria': 'Hide the bill of {component}',
|
|
77
|
+
'manufacturing.bom_editor.sub_bill_label': 'Bill of {component}',
|
|
78
|
+
'manufacturing.bom_editor.loading': 'Loading bill…',
|
|
79
|
+
'manufacturing.bom_editor.load_failed': 'The bill could not be loaded',
|
|
80
|
+
'manufacturing.bom_editor.add_heading': 'Add a line',
|
|
81
|
+
'manufacturing.bom_editor.choose_component': 'Choose a component',
|
|
82
|
+
'manufacturing.bom_editor.add': 'Add line',
|
|
83
|
+
'manufacturing.bom_editor.error_component': 'Choose a component.',
|
|
84
|
+
'manufacturing.bom_editor.error_qty': 'Enter a quantity greater than zero.',
|
|
85
|
+
'manufacturing.bom_editor.error_uom': 'Enter a unit.',
|
|
86
|
+
'manufacturing.bom_editor.error_waste': 'Enter a waste percent of zero or more.',
|
|
87
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @happyvertical/smrt-manufacturing/svelte
|
|
3
|
+
*
|
|
4
|
+
* Props-driven Svelte 5 surfaces: the managed list of operations (a list with
|
|
5
|
+
* retire and reinstate, and a form), and assemblies (a list, a policy-driven
|
|
6
|
+
* form, and a bill-of-materials editor whose sub-assemblies expand to their own
|
|
7
|
+
* bills). Hosts load data through the package services and collections and
|
|
8
|
+
* pass plain view objects.
|
|
9
|
+
* Auto-registers components with ModuleUIRegistry on import.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import type { ComponentProps } from 'svelte';
|
|
14
|
+
import AssemblyForm from './components/AssemblyForm.svelte';
|
|
15
|
+
import AssemblyList from './components/AssemblyList.svelte';
|
|
16
|
+
import BomEditor from './components/BomEditor.svelte';
|
|
17
|
+
import BomStructureTree from './components/BomStructureTree.svelte';
|
|
18
|
+
import OperationForm from './components/OperationForm.svelte';
|
|
19
|
+
import OperationList from './components/OperationList.svelte';
|
|
20
|
+
export { AssemblyForm, AssemblyList, BomEditor, BomStructureTree, OperationForm, OperationList, };
|
|
21
|
+
export type AssemblyFormProps = ComponentProps<typeof AssemblyForm>;
|
|
22
|
+
export type AssemblyListProps = ComponentProps<typeof AssemblyList>;
|
|
23
|
+
export type BomEditorProps = ComponentProps<typeof BomEditor>;
|
|
24
|
+
export type BomStructureTreeProps = ComponentProps<typeof BomStructureTree>;
|
|
25
|
+
export type OperationFormProps = ComponentProps<typeof OperationForm>;
|
|
26
|
+
export type OperationListProps = ComponentProps<typeof OperationList>;
|
|
27
|
+
export { type AssemblyView, type BomComponentOption, type BomEditorLine, type BomLineDraft, type BomLineDraftField, type BomLineInput, type BomLineValidation, type ComponentKind, componentKindLabelKey, type OperationFormDraft, type OperationFormField, type OperationFormInitial, type OperationFormValidation, type OperationFormValues, type OperationView, operationStatusBadgeKey, splitLabourMinutes, toAssemblyView, toBomEditorLine, toBomEditorLines, validateBomLineInput, validateOperationForm, } from './types.js';
|
|
28
|
+
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B,EACxB,KAAK,aAAa,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @happyvertical/smrt-manufacturing/svelte
|
|
3
|
+
*
|
|
4
|
+
* Props-driven Svelte 5 surfaces: the managed list of operations (a list with
|
|
5
|
+
* retire and reinstate, and a form), and assemblies (a list, a policy-driven
|
|
6
|
+
* form, and a bill-of-materials editor whose sub-assemblies expand to their own
|
|
7
|
+
* bills). Hosts load data through the package services and collections and
|
|
8
|
+
* pass plain view objects.
|
|
9
|
+
* Auto-registers components with ModuleUIRegistry on import.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { ModuleUIRegistry } from '@happyvertical/smrt-ui/registry';
|
|
14
|
+
import { MANUFACTURING_MODULE_META } from '../ui.js';
|
|
15
|
+
import AssemblyForm from './components/AssemblyForm.svelte';
|
|
16
|
+
import AssemblyList from './components/AssemblyList.svelte';
|
|
17
|
+
import BomEditor from './components/BomEditor.svelte';
|
|
18
|
+
import BomStructureTree from './components/BomStructureTree.svelte';
|
|
19
|
+
import OperationForm from './components/OperationForm.svelte';
|
|
20
|
+
import OperationList from './components/OperationList.svelte';
|
|
21
|
+
export { AssemblyForm, AssemblyList, BomEditor, BomStructureTree, OperationForm, OperationList, };
|
|
22
|
+
export { componentKindLabelKey, operationStatusBadgeKey, splitLabourMinutes, toAssemblyView, toBomEditorLine, toBomEditorLines, validateBomLineInput, validateOperationForm, } from './types.js';
|
|
23
|
+
// Auto-register with ModuleUIRegistry
|
|
24
|
+
ModuleUIRegistry.registerModule(MANUFACTURING_MODULE_META);
|
|
25
|
+
ModuleUIRegistry.register('@happyvertical/smrt-manufacturing', 'operation-list', OperationList);
|
|
26
|
+
ModuleUIRegistry.register('@happyvertical/smrt-manufacturing', 'operation-form', OperationForm);
|
|
27
|
+
ModuleUIRegistry.register('@happyvertical/smrt-manufacturing', 'assembly-list', AssemblyList);
|
|
28
|
+
ModuleUIRegistry.register('@happyvertical/smrt-manufacturing', 'assembly-form', AssemblyForm);
|
|
29
|
+
ModuleUIRegistry.register('@happyvertical/smrt-manufacturing', 'bom-editor', BomEditor);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializable view types and pure helpers for the manufacturing components.
|
|
3
|
+
*
|
|
4
|
+
* Components take plain view objects (not model instances) so hosts can pass
|
|
5
|
+
* data across the server/client boundary.
|
|
6
|
+
*/
|
|
7
|
+
import type { Assembly } from '../models/Assembly.js';
|
|
8
|
+
import type { BillStructure, BillStructureLine, ComponentKind } from '../services/AssemblyService.js';
|
|
9
|
+
/** One row of `OperationList`; an `Operation` satisfies it. */
|
|
10
|
+
export interface OperationView {
|
|
11
|
+
/** The `Operation` id. */
|
|
12
|
+
id: string;
|
|
13
|
+
code: string;
|
|
14
|
+
name: string;
|
|
15
|
+
category: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
/** Plain string id of the required qualification; empty or omitted for none. */
|
|
18
|
+
requiredQualificationId?: string | null;
|
|
19
|
+
}
|
|
20
|
+
/** Existing values passed to `OperationForm` when editing. */
|
|
21
|
+
export interface OperationFormInitial {
|
|
22
|
+
code: string;
|
|
23
|
+
name: string;
|
|
24
|
+
category: string;
|
|
25
|
+
requiredQualificationId: string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What `OperationForm` hands to `onsubmit`; values are trimmed. A host maps a
|
|
29
|
+
* new operation onto `OperationService.define`, and an edit onto `rename` and
|
|
30
|
+
* `update` for the values that differ (the code never changes).
|
|
31
|
+
*/
|
|
32
|
+
export interface OperationFormValues {
|
|
33
|
+
code: string;
|
|
34
|
+
name: string;
|
|
35
|
+
category: string;
|
|
36
|
+
requiredQualificationId: string;
|
|
37
|
+
}
|
|
38
|
+
/** A field `validateOperationForm` can reject. */
|
|
39
|
+
export type OperationFormField = 'code' | 'name';
|
|
40
|
+
/** Result of {@link validateOperationForm}. */
|
|
41
|
+
export type OperationFormValidation = {
|
|
42
|
+
ok: true;
|
|
43
|
+
values: OperationFormValues;
|
|
44
|
+
} | {
|
|
45
|
+
ok: false;
|
|
46
|
+
invalid: OperationFormField[];
|
|
47
|
+
};
|
|
48
|
+
/** The raw text `OperationForm` collects, before trimming and checks. */
|
|
49
|
+
export interface OperationFormDraft {
|
|
50
|
+
code: string;
|
|
51
|
+
name: string;
|
|
52
|
+
category: string;
|
|
53
|
+
requiredQualificationId: string;
|
|
54
|
+
}
|
|
55
|
+
/** Map an operation's state onto `StatusBadge` default color-scheme keys. */
|
|
56
|
+
export declare function operationStatusBadgeKey(isActive: boolean): string;
|
|
57
|
+
/** Trim a form draft and check the required fields: code and name. */
|
|
58
|
+
export declare function validateOperationForm(draft: Readonly<Partial<OperationFormDraft>>): OperationFormValidation;
|
|
59
|
+
export type { ComponentKind };
|
|
60
|
+
/** One row of {@link AssemblyList}. */
|
|
61
|
+
export interface AssemblyView {
|
|
62
|
+
/** The assembly id. */
|
|
63
|
+
id: string;
|
|
64
|
+
/** Display name. */
|
|
65
|
+
name: string;
|
|
66
|
+
/** The organization's drawing or part number; empty when none. */
|
|
67
|
+
partReference: string;
|
|
68
|
+
/** Codes of the assembly's SKUs, in the host's order. */
|
|
69
|
+
skuCodes: string[];
|
|
70
|
+
/** Catalog price in integer minor units (cents). */
|
|
71
|
+
price: number;
|
|
72
|
+
/** Labour to build one unit, in minutes; `0` when not estimated. */
|
|
73
|
+
estimatedLabourMinutes: number;
|
|
74
|
+
/** Version of the active bill, or `null` when the assembly has none. */
|
|
75
|
+
activeBomVersion: number | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build an {@link AssemblyView} from an `Assembly` plus the facts the list
|
|
79
|
+
* shows that live on its neighbours: its SKU codes and its active bill.
|
|
80
|
+
*/
|
|
81
|
+
export declare function toAssemblyView(assembly: Pick<Assembly, 'id' | 'name' | 'partReference' | 'price' | 'estimatedLabourMinutes'>, related?: {
|
|
82
|
+
skuCodes?: readonly string[];
|
|
83
|
+
activeBomVersion?: number | null;
|
|
84
|
+
}): AssemblyView;
|
|
85
|
+
/** One line of {@link BomEditor}. */
|
|
86
|
+
export interface BomEditorLine {
|
|
87
|
+
/** The bill line id. */
|
|
88
|
+
id: string;
|
|
89
|
+
/** The component SKU the line consumes. */
|
|
90
|
+
componentSkuId: string;
|
|
91
|
+
/** The component's product name, or its SKU code when that is unknown. */
|
|
92
|
+
componentName: string;
|
|
93
|
+
/** The component's SKU code; empty when the SKU is missing. */
|
|
94
|
+
skuCode: string;
|
|
95
|
+
/** What the component is. */
|
|
96
|
+
kind: ComponentKind;
|
|
97
|
+
/** Quantity per produced unit, before waste. */
|
|
98
|
+
qtyPerUnit: number;
|
|
99
|
+
/** Unit of measure. */
|
|
100
|
+
uom: string;
|
|
101
|
+
/** Expected waste, in percent. */
|
|
102
|
+
wastePercent: number;
|
|
103
|
+
/** Free-form notes. */
|
|
104
|
+
notes: string;
|
|
105
|
+
/**
|
|
106
|
+
* For a sub-assembly, the id of its own active bill; `null` when it has
|
|
107
|
+
* none, and for every other kind.
|
|
108
|
+
*/
|
|
109
|
+
subBomId: string | null;
|
|
110
|
+
}
|
|
111
|
+
/** Adapt one resolved bill line for {@link BomEditor}. */
|
|
112
|
+
export declare function toBomEditorLine(entry: BillStructureLine): BomEditorLine;
|
|
113
|
+
/**
|
|
114
|
+
* Adapt a whole bill from `AssemblyService.getBillStructure` for
|
|
115
|
+
* {@link BomEditor}, keeping its line order.
|
|
116
|
+
*/
|
|
117
|
+
export declare function toBomEditorLines(structure: BillStructure): BomEditorLine[];
|
|
118
|
+
/** A component the editor offers when adding a line. */
|
|
119
|
+
export interface BomComponentOption {
|
|
120
|
+
/** The component SKU id. */
|
|
121
|
+
skuId: string;
|
|
122
|
+
/** Text shown in the chooser, e.g. `Side panel (SP-100)`. */
|
|
123
|
+
label: string;
|
|
124
|
+
}
|
|
125
|
+
/** A bill line as the editor submits it, checked and trimmed. */
|
|
126
|
+
export interface BomLineDraft {
|
|
127
|
+
/** The component SKU id. */
|
|
128
|
+
componentSkuId: string;
|
|
129
|
+
/** Quantity per produced unit, greater than zero. */
|
|
130
|
+
qtyPerUnit: number;
|
|
131
|
+
/** Unit of measure, never empty. */
|
|
132
|
+
uom: string;
|
|
133
|
+
/** Expected waste in percent, zero or more. */
|
|
134
|
+
wastePercent: number;
|
|
135
|
+
}
|
|
136
|
+
/** A field of {@link BomLineDraft} that can fail validation. */
|
|
137
|
+
export type BomLineDraftField = keyof BomLineDraft;
|
|
138
|
+
/** The editor's raw input for one line, before validation. */
|
|
139
|
+
export interface BomLineInput {
|
|
140
|
+
/** Chosen component SKU id; empty when none is chosen. */
|
|
141
|
+
componentSkuId: string;
|
|
142
|
+
/** Quantity as typed. */
|
|
143
|
+
qtyPerUnit: string | number;
|
|
144
|
+
/** Unit as typed. */
|
|
145
|
+
uom: string;
|
|
146
|
+
/** Waste percent as typed; empty means zero. */
|
|
147
|
+
wastePercent: string | number;
|
|
148
|
+
}
|
|
149
|
+
/** The outcome of {@link validateBomLineInput}. */
|
|
150
|
+
export type BomLineValidation = {
|
|
151
|
+
ok: true;
|
|
152
|
+
value: BomLineDraft;
|
|
153
|
+
} | {
|
|
154
|
+
ok: false;
|
|
155
|
+
invalid: BomLineDraftField[];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Check one line's input: a component must be chosen, the quantity must be a
|
|
159
|
+
* number greater than zero, the unit must not be empty, and the waste percent
|
|
160
|
+
* must be a number of zero or more (empty counts as zero).
|
|
161
|
+
*/
|
|
162
|
+
export declare function validateBomLineInput(input: BomLineInput): BomLineValidation;
|
|
163
|
+
/** The message key naming a {@link ComponentKind} in words. */
|
|
164
|
+
export declare function componentKindLabelKey(kind: ComponentKind): "manufacturing.kind.assembly" | "manufacturing.kind.material" | "manufacturing.kind.bought" | "manufacturing.kind.missing";
|
|
165
|
+
/** Split a labour estimate into whole hours and the remaining minutes. */
|
|
166
|
+
export declare function splitLabourMinutes(minutes: number): {
|
|
167
|
+
hours: number;
|
|
168
|
+
minutes: number;
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/svelte/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACd,MAAM,gCAAgC,CAAC;AAGxC,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,gFAAgF;IAChF,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,+CAA+C;AAC/C,MAAM,MAAM,uBAAuB,GAC/B;IAAE,EAAE,EAAE,IAAI,CAAC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AE,MAAM,CAAC;IACZ,gDAAgD;IAChD,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GACjC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAAC;AAQhD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAqB3E;AAED,+DAA+D;AAC/D,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,8HAWxD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAGA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializable view types and pure helpers for the manufacturing components.
|
|
3
|
+
*
|
|
4
|
+
* Components take plain view objects (not model instances) so hosts can pass
|
|
5
|
+
* data across the server/client boundary.
|
|
6
|
+
*/
|
|
7
|
+
import { M } from './i18n.js';
|
|
8
|
+
function textOf(value) {
|
|
9
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
10
|
+
}
|
|
11
|
+
/** Map an operation's state onto `StatusBadge` default color-scheme keys. */
|
|
12
|
+
export function operationStatusBadgeKey(isActive) {
|
|
13
|
+
return isActive ? 'active' : 'inactive';
|
|
14
|
+
}
|
|
15
|
+
/** Trim a form draft and check the required fields: code and name. */
|
|
16
|
+
export function validateOperationForm(draft) {
|
|
17
|
+
const code = textOf(draft.code);
|
|
18
|
+
const name = textOf(draft.name);
|
|
19
|
+
const invalid = [];
|
|
20
|
+
if (!code)
|
|
21
|
+
invalid.push('code');
|
|
22
|
+
if (!name)
|
|
23
|
+
invalid.push('name');
|
|
24
|
+
if (invalid.length > 0)
|
|
25
|
+
return { ok: false, invalid };
|
|
26
|
+
return {
|
|
27
|
+
ok: true,
|
|
28
|
+
values: {
|
|
29
|
+
code,
|
|
30
|
+
name,
|
|
31
|
+
category: textOf(draft.category),
|
|
32
|
+
requiredQualificationId: textOf(draft.requiredQualificationId),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build an {@link AssemblyView} from an `Assembly` plus the facts the list
|
|
38
|
+
* shows that live on its neighbours: its SKU codes and its active bill.
|
|
39
|
+
*/
|
|
40
|
+
export function toAssemblyView(assembly, related = {}) {
|
|
41
|
+
return {
|
|
42
|
+
id: assembly.id ?? '',
|
|
43
|
+
name: assembly.name,
|
|
44
|
+
partReference: assembly.partReference ?? '',
|
|
45
|
+
skuCodes: [...(related.skuCodes ?? [])],
|
|
46
|
+
price: Number(assembly.price ?? 0),
|
|
47
|
+
estimatedLabourMinutes: Number(assembly.estimatedLabourMinutes ?? 0),
|
|
48
|
+
activeBomVersion: related.activeBomVersion ?? null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Adapt one resolved bill line for {@link BomEditor}. */
|
|
52
|
+
export function toBomEditorLine(entry) {
|
|
53
|
+
const { line, component } = entry;
|
|
54
|
+
const skuCode = component.sku?.code ?? '';
|
|
55
|
+
return {
|
|
56
|
+
id: line.id ?? '',
|
|
57
|
+
componentSkuId: line.componentSkuId,
|
|
58
|
+
componentName: component.product?.name || skuCode || line.componentSkuId,
|
|
59
|
+
skuCode,
|
|
60
|
+
kind: component.kind,
|
|
61
|
+
qtyPerUnit: Number(line.qtyPerUnit ?? 0),
|
|
62
|
+
uom: line.uom,
|
|
63
|
+
wastePercent: Number(line.wastePercent ?? 0),
|
|
64
|
+
notes: line.notes ?? '',
|
|
65
|
+
subBomId: component.activeBom?.id ?? null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Adapt a whole bill from `AssemblyService.getBillStructure` for
|
|
70
|
+
* {@link BomEditor}, keeping its line order.
|
|
71
|
+
*/
|
|
72
|
+
export function toBomEditorLines(structure) {
|
|
73
|
+
return structure.lines.map(toBomEditorLine);
|
|
74
|
+
}
|
|
75
|
+
function toNumber(raw) {
|
|
76
|
+
if (typeof raw === 'number')
|
|
77
|
+
return raw;
|
|
78
|
+
const trimmed = raw.trim();
|
|
79
|
+
return trimmed === '' ? Number.NaN : Number(trimmed);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Check one line's input: a component must be chosen, the quantity must be a
|
|
83
|
+
* number greater than zero, the unit must not be empty, and the waste percent
|
|
84
|
+
* must be a number of zero or more (empty counts as zero).
|
|
85
|
+
*/
|
|
86
|
+
export function validateBomLineInput(input) {
|
|
87
|
+
const invalid = [];
|
|
88
|
+
const componentSkuId = input.componentSkuId.trim();
|
|
89
|
+
const qtyPerUnit = toNumber(input.qtyPerUnit);
|
|
90
|
+
const uom = input.uom.trim();
|
|
91
|
+
const wasteRaw = typeof input.wastePercent === 'string' && input.wastePercent.trim() === ''
|
|
92
|
+
? 0
|
|
93
|
+
: toNumber(input.wastePercent);
|
|
94
|
+
if (!componentSkuId)
|
|
95
|
+
invalid.push('componentSkuId');
|
|
96
|
+
if (!Number.isFinite(qtyPerUnit) || qtyPerUnit <= 0)
|
|
97
|
+
invalid.push('qtyPerUnit');
|
|
98
|
+
if (!uom)
|
|
99
|
+
invalid.push('uom');
|
|
100
|
+
if (!Number.isFinite(wasteRaw) || wasteRaw < 0)
|
|
101
|
+
invalid.push('wastePercent');
|
|
102
|
+
if (invalid.length > 0)
|
|
103
|
+
return { ok: false, invalid };
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
value: { componentSkuId, qtyPerUnit, uom, wastePercent: wasteRaw },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** The message key naming a {@link ComponentKind} in words. */
|
|
110
|
+
export function componentKindLabelKey(kind) {
|
|
111
|
+
switch (kind) {
|
|
112
|
+
case 'assembly':
|
|
113
|
+
return M['manufacturing.kind.assembly'];
|
|
114
|
+
case 'material':
|
|
115
|
+
return M['manufacturing.kind.material'];
|
|
116
|
+
case 'bought':
|
|
117
|
+
return M['manufacturing.kind.bought'];
|
|
118
|
+
default:
|
|
119
|
+
return M['manufacturing.kind.missing'];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** Split a labour estimate into whole hours and the remaining minutes. */
|
|
123
|
+
export function splitLabourMinutes(minutes) {
|
|
124
|
+
const whole = Math.max(0, Math.round(minutes));
|
|
125
|
+
return { hours: Math.floor(whole / 60), minutes: whole % 60 };
|
|
126
|
+
}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manufacturing Module UI Slot Declarations
|
|
3
|
+
*
|
|
4
|
+
* UI extension points for the manufacturing module. Components live in the
|
|
5
|
+
* ./svelte subpath and are props-driven: hosts load records through the
|
|
6
|
+
* services and pass plain view objects.
|
|
7
|
+
*/
|
|
8
|
+
import type { ModuleUISlot, SmrtModuleMeta } from '@happyvertical/smrt-types';
|
|
9
|
+
/**
|
|
10
|
+
* Manufacturing module UI slots
|
|
11
|
+
*/
|
|
12
|
+
export declare const MANUFACTURING_UI_SLOTS: Record<string, ModuleUISlot>;
|
|
13
|
+
/**
|
|
14
|
+
* Manufacturing module metadata
|
|
15
|
+
*/
|
|
16
|
+
export declare const MANUFACTURING_MODULE_META: SmrtModuleMeta;
|
|
17
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAgD/D,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,cAoBvC,CAAC"}
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/ui.ts
|
|
2
|
+
var MANUFACTURING_UI_SLOTS = {
|
|
3
|
+
"operation-list": {
|
|
4
|
+
id: "operation-list",
|
|
5
|
+
label: "Operation List",
|
|
6
|
+
description: "Table of operations with category, status and retire or reinstate actions",
|
|
7
|
+
icon: "list",
|
|
8
|
+
category: "list",
|
|
9
|
+
order: 1,
|
|
10
|
+
propsInterface: "OperationListProps"
|
|
11
|
+
},
|
|
12
|
+
"operation-form": {
|
|
13
|
+
id: "operation-form",
|
|
14
|
+
label: "Operation Form",
|
|
15
|
+
description: "Add an operation, or rename and recategorize an existing one",
|
|
16
|
+
icon: "edit",
|
|
17
|
+
category: "form",
|
|
18
|
+
order: 2,
|
|
19
|
+
propsInterface: "OperationFormProps"
|
|
20
|
+
},
|
|
21
|
+
"assembly-list": {
|
|
22
|
+
id: "assembly-list",
|
|
23
|
+
label: "Assembly List",
|
|
24
|
+
description: "Table of assemblies with part reference, SKU, price and bill",
|
|
25
|
+
icon: "list",
|
|
26
|
+
category: "list",
|
|
27
|
+
order: 3,
|
|
28
|
+
propsInterface: "AssemblyListProps"
|
|
29
|
+
},
|
|
30
|
+
"assembly-form": {
|
|
31
|
+
id: "assembly-form",
|
|
32
|
+
label: "Assembly Form",
|
|
33
|
+
description: "Policy-driven create and edit form for an assembly",
|
|
34
|
+
icon: "edit",
|
|
35
|
+
category: "form",
|
|
36
|
+
order: 4,
|
|
37
|
+
propsInterface: "AssemblyFormProps"
|
|
38
|
+
},
|
|
39
|
+
"bom-editor": {
|
|
40
|
+
id: "bom-editor",
|
|
41
|
+
label: "Bill of Materials Editor",
|
|
42
|
+
description: "Edits an assembly's bill: materials and sub-assemblies, each sub-assembly expandable to its own bill",
|
|
43
|
+
icon: "tree",
|
|
44
|
+
category: "form",
|
|
45
|
+
order: 5,
|
|
46
|
+
propsInterface: "BomEditorProps"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var MANUFACTURING_MODULE_META = {
|
|
50
|
+
name: "@happyvertical/smrt-manufacturing",
|
|
51
|
+
displayName: "Manufacturing",
|
|
52
|
+
description: "Assemblies, bills of materials, routing operations, cost and labour rollup, and production-order stock movement",
|
|
53
|
+
uiSlots: MANUFACTURING_UI_SLOTS,
|
|
54
|
+
models: [
|
|
55
|
+
"Assembly",
|
|
56
|
+
"BillOfMaterials",
|
|
57
|
+
"BomLine",
|
|
58
|
+
"Operation",
|
|
59
|
+
"RoutingStep"
|
|
60
|
+
],
|
|
61
|
+
collections: [
|
|
62
|
+
"AssemblyCollection",
|
|
63
|
+
"BillOfMaterialsCollection",
|
|
64
|
+
"BomLineCollection",
|
|
65
|
+
"OperationCollection",
|
|
66
|
+
"RoutingStepCollection"
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { MANUFACTURING_MODULE_META, MANUFACTURING_UI_SLOTS };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=ui.js.map
|