@lavalogic/scoria 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Components/Button.svelte +0 -3
- package/dist/Components/Contexts/ContextMenuOption.svelte +0 -3
- package/dist/Components/DatePicker.svelte +1 -6
- package/dist/Components/DimensionInput.svelte +5 -6
- package/dist/Components/DimensionInput.svelte.d.ts +4 -4
- package/dist/Components/FileUpload.svelte +4 -2
- package/dist/Components/GridInput.svelte +3 -3
- package/dist/Components/MultiSelect.svelte +0 -4
- package/dist/Components/ProgressBubble.svelte +1 -2
- package/dist/Components/Table/Body/QuickSearchCell.svelte +0 -9
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +1 -5
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +2 -2
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +1 -2
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +6 -7
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +2 -5
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +0 -3
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +8 -6
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +12 -19
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +2 -5
- package/dist/Components/Table/Body/Rows/TableRow.svelte +3 -17
- package/dist/Components/Table/Headers/TableHead.svelte +1 -5
- package/dist/Components/Table/Misc/FilterInput.svelte +10 -27
- package/dist/Components/Table/Table.svelte +1 -2
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js +6 -5
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +11 -30
- package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.d.ts +0 -1
- package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.js +3 -16
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +2 -5
- package/dist/Components/Table/Types/Filtering/CustomRemoteFilters.d.ts +1 -2
- package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.js +1 -5
- package/dist/Components/Touch/DateModal.svelte +0 -5
- package/dist/Components/Touch/UtilityButton.svelte +12 -7
- package/dist/Components/Touch/UtilityButton.svelte.d.ts +1 -1
- package/dist/Contexts/UntypedInputContext.svelte.d.ts +2 -1
- package/dist/Contexts/UntypedInputContext.svelte.js +1 -17
- package/dist/Helpers/Helpers.svelte.d.ts +21 -95
- package/dist/Helpers/Helpers.svelte.js +54 -395
- package/dist/Types/Examples/ExampleItem.d.ts +3 -3
- package/dist/Types/Internal/Misc.d.ts +12 -267
- package/dist/Types/Internal/Misc.js +1 -129
- package/dist/index.d.ts +4 -76
- package/dist/index.js +4 -76
- package/package.json +16 -16
- package/dist/Components/Table/Types/DataRepository/RemoteTableDataRepository.svelte.d.ts +0 -74
- package/dist/Components/Table/Types/DataRepository/RemoteTableDataRepository.svelte.js +0 -521
- package/dist/Components/Table/Types/Filtering/CustomProxyFilter.d.ts +0 -10
- package/dist/Components/Table/Types/Filtering/CustomProxyFilter.js +0 -1
- package/dist/Types/Internal/ApplicationIdentifier.d.ts +0 -39
- package/dist/Types/Internal/ApplicationIdentifier.js +0 -2080
- package/dist/Types/Internal/FloService.d.ts +0 -7
- package/dist/Types/Internal/FloService.js +0 -30
- package/dist/Types/Requests/IFillablePodLineDateRequestBody.d.ts +0 -13
- package/dist/Types/Requests/IFillablePodLineDateRequestBody.js +0 -10
- package/dist/Types/Requests/IRequiredPodLineDateRequestBody.d.ts +0 -14
- package/dist/Types/Requests/IRequiredPodLineDateRequestBody.js +0 -8
- package/dist/Types/Requests/IValidatedPodLineDateRequestBody.d.ts +0 -16
- package/dist/Types/Requests/IValidatedPodLineDateRequestBody.js +0 -10
- package/dist/Types/Responses/AddressType.d.ts +0 -3
- package/dist/Types/Responses/AddressType.js +0 -2
- package/dist/Types/Responses/IAddress.d.ts +0 -39
- package/dist/Types/Responses/IAddress.js +0 -30
- package/dist/Types/Responses/IBaseAddress.d.ts +0 -17
- package/dist/Types/Responses/IBaseAddress.js +0 -15
- package/dist/Types/Responses/ICountry.d.ts +0 -16
- package/dist/Types/Responses/ICountry.js +0 -1
- package/dist/Types/Responses/IDBEntry.d.ts +0 -13
- package/dist/Types/Responses/IDBEntry.js +0 -12
- package/dist/Types/Responses/IErrorResponse.d.ts +0 -10
- package/dist/Types/Responses/IErrorResponse.js +0 -1
- package/dist/Types/Responses/ILabelPrinter.d.ts +0 -4
- package/dist/Types/Responses/ILabelPrinter.js +0 -1
- package/dist/Types/Responses/ILaserPrinter.d.ts +0 -4
- package/dist/Types/Responses/ILaserPrinter.js +0 -1
- package/dist/Types/Responses/ILoginResponse.d.ts +0 -8
- package/dist/Types/Responses/ILoginResponse.js +0 -1
- package/dist/Types/Responses/IPaginatedPayload.d.ts +0 -5
- package/dist/Types/Responses/IPaginatedPayload.js +0 -1
- package/dist/Types/Responses/IPaginatedResponse.d.ts +0 -5
- package/dist/Types/Responses/IPaginatedResponse.js +0 -1
- package/dist/Types/Responses/IPagination.d.ts +0 -9
- package/dist/Types/Responses/IPagination.js +0 -1
- package/dist/Types/Responses/IPayload.d.ts +0 -3
- package/dist/Types/Responses/IPayload.js +0 -1
- package/dist/Types/Responses/IPrinter.d.ts +0 -11
- package/dist/Types/Responses/IPrinter.js +0 -1
- package/dist/Types/Responses/IProcessTypeSelectionMethodOutboundType.d.ts +0 -18
- package/dist/Types/Responses/IProcessTypeSelectionMethodOutboundType.js +0 -12
- package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomer.d.ts +0 -20
- package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomer.js +0 -14
- package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomerType.d.ts +0 -20
- package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomerType.js +0 -14
- package/dist/Types/Responses/IProductCategory.d.ts +0 -19
- package/dist/Types/Responses/IProductCategory.js +0 -13
- package/dist/Types/Responses/IProductCategoryDetails.d.ts +0 -33
- package/dist/Types/Responses/IProductCategoryDetails.js +0 -13
- package/dist/Types/Responses/IProductIgnoreOnAllocationOutboundType.d.ts +0 -17
- package/dist/Types/Responses/IProductIgnoreOnAllocationOutboundType.js +0 -11
- package/dist/Types/Responses/IProductLocation.d.ts +0 -23
- package/dist/Types/Responses/IProductLocation.js +0 -17
- package/dist/Types/Responses/IResponse.d.ts +0 -8
- package/dist/Types/Responses/IResponse.js +0 -1
- package/dist/Types/Responses/IStockSortationMethodCustomer.d.ts +0 -18
- package/dist/Types/Responses/IStockSortationMethodCustomer.js +0 -12
- package/dist/Types/Responses/Pods/IAttributeTypeWithAI.d.ts +0 -8
- package/dist/Types/Responses/Pods/IAttributeTypeWithAI.js +0 -1
- package/dist/Types/Responses/Pods/IBatchType.d.ts +0 -5
- package/dist/Types/Responses/Pods/IBatchType.js +0 -1
- package/dist/Types/Responses/Pods/IDateType.d.ts +0 -6
- package/dist/Types/Responses/Pods/IDateType.js +0 -1
- package/dist/Types/Responses/Pods/IFillablePodLineAttribute.d.ts +0 -10
- package/dist/Types/Responses/Pods/IFillablePodLineAttribute.js +0 -9
- package/dist/Types/Responses/Pods/IFillablePodLineBatch.d.ts +0 -18
- package/dist/Types/Responses/Pods/IFillablePodLineBatch.js +0 -12
- package/dist/Types/Responses/Pods/IFillablePodLineDate.d.ts +0 -19
- package/dist/Types/Responses/Pods/IFillablePodLineDate.js +0 -13
- package/dist/Types/Responses/Pods/IFillablePodLinePurchaseOrder.d.ts +0 -18
- package/dist/Types/Responses/Pods/IFillablePodLinePurchaseOrder.js +0 -12
- package/dist/Types/Responses/Pods/IFillablePodLineSerial.d.ts +0 -18
- package/dist/Types/Responses/Pods/IFillablePodLineSerial.js +0 -12
- package/dist/Types/Responses/Pods/IFillablePodLineTag.d.ts +0 -18
- package/dist/Types/Responses/Pods/IFillablePodLineTag.js +0 -12
- package/dist/Types/Responses/Pods/IPurchaseOrderType.d.ts +0 -5
- package/dist/Types/Responses/Pods/IPurchaseOrderType.js +0 -1
- package/dist/Types/Responses/Pods/IRequiredOrValidatedAttribute.d.ts +0 -7
- package/dist/Types/Responses/Pods/IRequiredOrValidatedAttribute.js +0 -7
- package/dist/Types/Responses/Pods/IRequiredPodLineBatch.d.ts +0 -18
- package/dist/Types/Responses/Pods/IRequiredPodLineBatch.js +0 -8
- package/dist/Types/Responses/Pods/IRequiredPodLineDate.d.ts +0 -19
- package/dist/Types/Responses/Pods/IRequiredPodLineDate.js +0 -8
- package/dist/Types/Responses/Pods/IRequiredPodLinePurchaseOrder.d.ts +0 -19
- package/dist/Types/Responses/Pods/IRequiredPodLinePurchaseOrder.js +0 -8
- package/dist/Types/Responses/Pods/IRequiredPodLineSerial.d.ts +0 -19
- package/dist/Types/Responses/Pods/IRequiredPodLineSerial.js +0 -8
- package/dist/Types/Responses/Pods/IRequiredPodLineTag.d.ts +0 -19
- package/dist/Types/Responses/Pods/IRequiredPodLineTag.js +0 -8
- package/dist/Types/Responses/Pods/ISerialType.d.ts +0 -6
- package/dist/Types/Responses/Pods/ISerialType.js +0 -1
- package/dist/Types/Responses/Pods/ITagType.d.ts +0 -6
- package/dist/Types/Responses/Pods/ITagType.js +0 -1
- package/dist/Types/Responses/Pods/IValidatedPodLineAttribute.d.ts +0 -13
- package/dist/Types/Responses/Pods/IValidatedPodLineAttribute.js +0 -10
- package/dist/Types/Responses/Pods/IValidatedPodLineBatch.d.ts +0 -19
- package/dist/Types/Responses/Pods/IValidatedPodLineBatch.js +0 -10
- package/dist/Types/Responses/Pods/IValidatedPodLineDate.d.ts +0 -21
- package/dist/Types/Responses/Pods/IValidatedPodLineDate.js +0 -10
- package/dist/Types/Responses/Pods/IValidatedPodLinePurchaseOrder.d.ts +0 -20
- package/dist/Types/Responses/Pods/IValidatedPodLinePurchaseOrder.js +0 -10
- package/dist/Types/Responses/Pods/IValidatedPodLineSerial.d.ts +0 -20
- package/dist/Types/Responses/Pods/IValidatedPodLineSerial.js +0 -10
- package/dist/Types/Responses/Pods/IValidatedPodLineTag.d.ts +0 -20
- package/dist/Types/Responses/Pods/IValidatedPodLineTag.js +0 -10
- package/dist/Types/Responses/Products/IAttributeRule.d.ts +0 -34
- package/dist/Types/Responses/Products/IAttributeRule.js +0 -28
- package/dist/Types/Responses/Products/IBarcode.d.ts +0 -18
- package/dist/Types/Responses/Products/IBarcode.js +0 -12
- package/dist/Types/Responses/Products/IBatchRule.d.ts +0 -36
- package/dist/Types/Responses/Products/IBatchRule.js +0 -9
- package/dist/Types/Responses/Products/ICustomerRule.d.ts +0 -23
- package/dist/Types/Responses/Products/ICustomerRule.js +0 -17
- package/dist/Types/Responses/Products/IDateRule.d.ts +0 -36
- package/dist/Types/Responses/Products/IDateRule.js +0 -9
- package/dist/Types/Responses/Products/IPrice.d.ts +0 -19
- package/dist/Types/Responses/Products/IPrice.js +0 -12
- package/dist/Types/Responses/Products/IProduct.d.ts +0 -436
- package/dist/Types/Responses/Products/IProduct.js +0 -77
- package/dist/Types/Responses/Products/IProductKit.d.ts +0 -24
- package/dist/Types/Responses/Products/IProductKit.js +0 -18
- package/dist/Types/Responses/Products/IProductKitMatrix.d.ts +0 -13
- package/dist/Types/Responses/Products/IProductKitMatrix.js +0 -1
- package/dist/Types/Responses/Products/IProductSupplier.d.ts +0 -18
- package/dist/Types/Responses/Products/IProductSupplier.js +0 -12
- package/dist/Types/Responses/Products/IProductTag.d.ts +0 -33
- package/dist/Types/Responses/Products/IProductTag.js +0 -14
- package/dist/Types/Responses/Products/IProductTagType.d.ts +0 -18
- package/dist/Types/Responses/Products/IProductTagType.js +0 -12
- package/dist/Types/Responses/Products/IProductUnitOfMeasure.d.ts +0 -97
- package/dist/Types/Responses/Products/IProductUnitOfMeasure.js +0 -35
- package/dist/Types/Responses/Products/IProductUnitOfMeasurePrice.d.ts +0 -36
- package/dist/Types/Responses/Products/IProductUnitOfMeasurePrice.js +0 -17
- package/dist/Types/Responses/Products/IPurchaseOrderRule.d.ts +0 -36
- package/dist/Types/Responses/Products/IPurchaseOrderRule.js +0 -9
- package/dist/Types/Responses/Products/ISerialRule.d.ts +0 -36
- package/dist/Types/Responses/Products/ISerialRule.js +0 -9
- package/dist/Types/Responses/Products/ITagRule.d.ts +0 -36
- package/dist/Types/Responses/Products/ITagRule.js +0 -9
- package/dist/Types/Responses/Products/IUnitOfMeasure.d.ts +0 -18
- package/dist/Types/Responses/Products/IUnitOfMeasure.js +0 -12
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
// TODO move all global stores in here potentially
|
|
2
|
-
import { browser, dev } from '$app/environment';
|
|
3
|
-
import { Validity } from '../Types/Internal/Validity.js';
|
|
4
1
|
import { Value } from '@sinclair/typebox/value';
|
|
5
|
-
export function capitalise(string) {
|
|
6
|
-
return `${string.charAt(0).toLocaleUpperCase()}${string.substring(1)}`;
|
|
7
|
-
}
|
|
8
2
|
export function autoPluralise(text, quantity = 2, { capitalise = false } = {}) {
|
|
9
3
|
if (quantity === 1) {
|
|
10
4
|
return text;
|
|
@@ -32,45 +26,41 @@ export function autoPluralise(text, quantity = 2, { capitalise = false } = {}) {
|
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
timeZone: 'UTC'
|
|
41
|
-
});
|
|
42
|
-
export const local = new Intl.DateTimeFormat('en-GB', {
|
|
43
|
-
hour: '2-digit',
|
|
44
|
-
hourCycle: 'h23',
|
|
45
|
-
minute: '2-digit',
|
|
46
|
-
second: '2-digit',
|
|
47
|
-
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
48
|
-
});
|
|
49
|
-
export function tomorrow() {
|
|
50
|
-
const x = new Date();
|
|
51
|
-
x.setDate(x.getDate() + 1);
|
|
52
|
-
return x;
|
|
29
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
30
|
+
export const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
|
|
31
|
+
// generic is present to bypass floatAlias type requirements and the like
|
|
32
|
+
export function generateShortUUID() {
|
|
33
|
+
return generateUUID().substring(0, 13);
|
|
53
34
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
// taken from https://stackoverflow.com/a/8809472/18712055
|
|
36
|
+
export function generateUUID() {
|
|
37
|
+
let // eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
38
|
+
d = new Date().getTime(), d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;
|
|
39
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
40
|
+
let r = Math.random() * 16;
|
|
41
|
+
if (d > 0) {
|
|
42
|
+
r = (d + r) % 16 | 0;
|
|
43
|
+
d = Math.floor(d / 16);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
r = (d2 + r) % 16 | 0;
|
|
47
|
+
d2 = Math.floor(d2 / 16);
|
|
48
|
+
}
|
|
49
|
+
return (c == 'x' ? r : (r & 0x7) | 0x8).toString(16);
|
|
50
|
+
});
|
|
62
51
|
}
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
export function refWrapper(initial) {
|
|
53
|
+
let value = $state(initial);
|
|
54
|
+
return {
|
|
55
|
+
get value() {
|
|
56
|
+
return value;
|
|
57
|
+
},
|
|
58
|
+
set value(v) {
|
|
59
|
+
value = v;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
72
62
|
}
|
|
73
|
-
export function
|
|
63
|
+
export function SQLFriendly(date) {
|
|
74
64
|
if (typeof date === 'string') {
|
|
75
65
|
date = new Date(date);
|
|
76
66
|
}
|
|
@@ -79,8 +69,7 @@ export function floFriendly(date) {
|
|
|
79
69
|
.toString()
|
|
80
70
|
.padStart(2, '0')} 00:00:00`;
|
|
81
71
|
}
|
|
82
|
-
|
|
83
|
-
export function floFriendlyWithTime(date, timeDate) {
|
|
72
|
+
export function SQLFriendlyWithLocalTime(date, timeDate) {
|
|
84
73
|
if (typeof date === 'string') {
|
|
85
74
|
date = new Date(date);
|
|
86
75
|
}
|
|
@@ -90,63 +79,31 @@ export function floFriendlyWithTime(date, timeDate) {
|
|
|
90
79
|
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date
|
|
91
80
|
.getDate()
|
|
92
81
|
.toString()
|
|
93
|
-
.padStart(2, '0')} ${
|
|
82
|
+
.padStart(2, '0')} ${localTimeFormat.format(timeDate ?? date)}`;
|
|
94
83
|
}
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
export const localTimeFormat = new Intl.DateTimeFormat('en-GB', {
|
|
85
|
+
hour: '2-digit',
|
|
86
|
+
hourCycle: 'h23',
|
|
87
|
+
minute: '2-digit',
|
|
88
|
+
second: '2-digit',
|
|
89
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
90
|
+
});
|
|
91
|
+
export function passthrough(e) {
|
|
92
|
+
if (!e.key.match(/^[a-zA-Z0-9[\]]$/gm)) {
|
|
93
|
+
return;
|
|
101
94
|
}
|
|
102
|
-
|
|
103
|
-
.getDate()
|
|
104
|
-
.toString()
|
|
105
|
-
.padStart(2, '0')} ${local.format(timeDate ?? date)}`;
|
|
95
|
+
e.target.blur();
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
let __canvas;
|
|
98
|
+
export function getCanvasContext() {
|
|
99
|
+
if (!__canvas) {
|
|
100
|
+
__canvas = document.createElement('canvas');
|
|
101
|
+
const canvasContext = __canvas.getContext('2d');
|
|
102
|
+
canvasContext.font = '700 16px LatoWeb';
|
|
103
|
+
return canvasContext;
|
|
104
|
+
}
|
|
105
|
+
return __canvas.getContext('2d');
|
|
111
106
|
}
|
|
112
|
-
// export function tryCatchOnprod: <T>(
|
|
113
|
-
// callback: () => Promise<T | IErrorResponse>
|
|
114
|
-
// ) => Promise<T | IErrorResponse> = async (callback) => {
|
|
115
|
-
// try {
|
|
116
|
-
// return await callback();
|
|
117
|
-
// } catch (e) {
|
|
118
|
-
// if (dev) {
|
|
119
|
-
// console.log('Error response:');
|
|
120
|
-
// console.log(e);
|
|
121
|
-
// } else {
|
|
122
|
-
// console.log("error caught")
|
|
123
|
-
// }
|
|
124
|
-
// if (this.isErrorResponse(e)) {
|
|
125
|
-
// return e;
|
|
126
|
-
// } else if (this.isThrowable(e)) {
|
|
127
|
-
// return {
|
|
128
|
-
// errors: [{ code: 'unknown', message: e.message, originatingService: 'unknown' }],
|
|
129
|
-
// payload: null,
|
|
130
|
-
// statusCode: -1,
|
|
131
|
-
// uuid: null
|
|
132
|
-
// };
|
|
133
|
-
// } else if (typeof e === 'string') {
|
|
134
|
-
// return {
|
|
135
|
-
// errors: [{ code: 'unknown', message: e, originatingService: 'unknown' }],
|
|
136
|
-
// payload: null,
|
|
137
|
-
// statusCode: -1,
|
|
138
|
-
// uuid: null
|
|
139
|
-
// };
|
|
140
|
-
// } else {
|
|
141
|
-
// return {
|
|
142
|
-
// errors: [{ code: 'unknown', message: 'Unknown Error', originatingService: 'unknown' }],
|
|
143
|
-
// payload: null,
|
|
144
|
-
// statusCode: -1,
|
|
145
|
-
// uuid: null
|
|
146
|
-
// };
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
|
-
// };
|
|
150
107
|
export function isErrorResponse(error) {
|
|
151
108
|
return (error != null &&
|
|
152
109
|
typeof error === 'object' &&
|
|
@@ -154,26 +111,7 @@ export function isErrorResponse(error) {
|
|
|
154
111
|
(Array.isArray(error.errors) || typeof error.errors === 'string') &&
|
|
155
112
|
!!error.errors.length);
|
|
156
113
|
}
|
|
157
|
-
export function isMessage(response) {
|
|
158
|
-
return (response != null &&
|
|
159
|
-
typeof response === 'object' &&
|
|
160
|
-
'payload' in response &&
|
|
161
|
-
response.payload != null &&
|
|
162
|
-
typeof response.payload === 'object' &&
|
|
163
|
-
'data' in response.payload &&
|
|
164
|
-
(typeof response.payload.data === 'string' ||
|
|
165
|
-
(Array.isArray(response.payload.data) && typeof response.payload.data[0] === 'string')));
|
|
166
|
-
}
|
|
167
|
-
export function isThrowable(error) {
|
|
168
|
-
return (error != null &&
|
|
169
|
-
typeof error === 'object' &&
|
|
170
|
-
'message' in error &&
|
|
171
|
-
typeof error.message === 'string');
|
|
172
|
-
}
|
|
173
114
|
export function getErrorMessage(error, includeUUID = true) {
|
|
174
|
-
if (dev) {
|
|
175
|
-
console.log(error);
|
|
176
|
-
}
|
|
177
115
|
if (!error) {
|
|
178
116
|
return 'Unknown Error';
|
|
179
117
|
}
|
|
@@ -209,282 +147,3 @@ export function isValidEmailAddress(emailAddress) {
|
|
|
209
147
|
.toLowerCase()
|
|
210
148
|
.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
|
|
211
149
|
}
|
|
212
|
-
export function validateBarcodeCommand(value, allBarcodes, previousValue, hasDynamicParameter = false) {
|
|
213
|
-
const startIndex = value.startsWith('[') ? 1 : 0;
|
|
214
|
-
const endIndex = hasDynamicParameter
|
|
215
|
-
? value.endsWith('-*]')
|
|
216
|
-
? -3
|
|
217
|
-
: undefined
|
|
218
|
-
: value.endsWith(']')
|
|
219
|
-
? -1
|
|
220
|
-
: undefined;
|
|
221
|
-
const inside = value.slice(startIndex, endIndex);
|
|
222
|
-
if ((startIndex == 0 && endIndex != undefined) ||
|
|
223
|
-
(startIndex != 0 && endIndex == undefined) ||
|
|
224
|
-
inside.match(/^[a-z0-9]+$/i) == null) {
|
|
225
|
-
return {
|
|
226
|
-
shouldUpdate: false,
|
|
227
|
-
isError: true,
|
|
228
|
-
reason: {
|
|
229
|
-
result: Validity.Invalid,
|
|
230
|
-
message: 'Command may only include Alphanumeric text in its inner text'
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
const reconstructedValue = (startIndex === 0 ? '[' : '') +
|
|
235
|
-
value +
|
|
236
|
-
(endIndex === undefined ? (hasDynamicParameter ? '-*]' : ']') : '');
|
|
237
|
-
if (reconstructedValue === previousValue) {
|
|
238
|
-
return {
|
|
239
|
-
shouldUpdate: false,
|
|
240
|
-
isError: false,
|
|
241
|
-
reason: { result: Validity.Info, message: `Command ${reconstructedValue} was unchanged` }
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
if (allBarcodes.has(reconstructedValue)) {
|
|
245
|
-
return {
|
|
246
|
-
shouldUpdate: false,
|
|
247
|
-
isError: true,
|
|
248
|
-
reason: {
|
|
249
|
-
result: Validity.Invalid,
|
|
250
|
-
message: `Command ${reconstructedValue} is already in use`
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
return {
|
|
255
|
-
shouldUpdate: true,
|
|
256
|
-
isError: false,
|
|
257
|
-
finalValue: reconstructedValue
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function isValidPrinter(printer) {
|
|
261
|
-
return ('hostname' in printer &&
|
|
262
|
-
typeof printer.hostname === 'string' &&
|
|
263
|
-
'id' in printer &&
|
|
264
|
-
typeof printer.id === 'number' &&
|
|
265
|
-
'ipAddress' in printer &&
|
|
266
|
-
typeof printer.ipAddress === 'string' &&
|
|
267
|
-
'port' in printer &&
|
|
268
|
-
typeof printer.port === 'number' &&
|
|
269
|
-
'printerGroup_id' in printer &&
|
|
270
|
-
typeof printer.printerGroup_id === 'number' &&
|
|
271
|
-
'systemName' in printer &&
|
|
272
|
-
typeof printer.systemName === 'string' &&
|
|
273
|
-
'type' in printer &&
|
|
274
|
-
typeof printer.type === 'string');
|
|
275
|
-
}
|
|
276
|
-
export function isValidLaserPrinter(printer) {
|
|
277
|
-
return isValidPrinter(printer) && printer.type === 'laser';
|
|
278
|
-
}
|
|
279
|
-
export function isValidLabelPrinter(printer) {
|
|
280
|
-
return isValidPrinter(printer) && printer.type === 'label';
|
|
281
|
-
}
|
|
282
|
-
export const getLocalStorageStringOrDefault = (key, defaultValue) => {
|
|
283
|
-
return browser ? (localStorage.getItem(key) ?? defaultValue) : defaultValue;
|
|
284
|
-
};
|
|
285
|
-
export const getLocalStorageIntOrDefault = (key, defaultValue) => {
|
|
286
|
-
if (browser) {
|
|
287
|
-
const value = parseInt(localStorage.getItem(key) ?? '');
|
|
288
|
-
if (!isNaN(value)) {
|
|
289
|
-
return value;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return defaultValue;
|
|
293
|
-
};
|
|
294
|
-
export const getLocalStorageFloatOrDefault = (key, defaultValue) => {
|
|
295
|
-
if (browser) {
|
|
296
|
-
const value = parseFloat(localStorage.getItem(key) ?? '');
|
|
297
|
-
if (!isNaN(value)) {
|
|
298
|
-
return value;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return defaultValue;
|
|
302
|
-
};
|
|
303
|
-
export const getLocalStorageBoolOrDefault = (key, defaultValue) => {
|
|
304
|
-
if (browser) {
|
|
305
|
-
const value = JSON.parse(localStorage.getItem(key) ?? `${defaultValue}`);
|
|
306
|
-
if (typeof value === 'boolean') {
|
|
307
|
-
return value;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return defaultValue;
|
|
311
|
-
};
|
|
312
|
-
// TODO remove pointless redeclaration and make name generic
|
|
313
|
-
export const FormatAccountNames = (accounts) => {
|
|
314
|
-
const firstAcc = accounts[0];
|
|
315
|
-
const secondAcc = accounts[1];
|
|
316
|
-
const extraAccs = accounts.length - 2;
|
|
317
|
-
return `${firstAcc?.name}${secondAcc ? (extraAccs > 0 ? ', ' : ' and ') + secondAcc?.name : ''}${extraAccs > 0 ? `, and ${extraAccs} others` : ''}`;
|
|
318
|
-
};
|
|
319
|
-
export const FormatWarehouseNames = FormatAccountNames;
|
|
320
|
-
let __canvas;
|
|
321
|
-
export function getCanvasContext() {
|
|
322
|
-
if (!__canvas) {
|
|
323
|
-
__canvas = document.createElement('canvas');
|
|
324
|
-
const canvasContext = __canvas.getContext('2d');
|
|
325
|
-
canvasContext.font = '700 16px LatoWeb';
|
|
326
|
-
return canvasContext;
|
|
327
|
-
}
|
|
328
|
-
return __canvas.getContext('2d');
|
|
329
|
-
}
|
|
330
|
-
export function assertIsOnBrowser() {
|
|
331
|
-
if (!browser) {
|
|
332
|
-
throw new Error('Called a browser-only function in server side.');
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
export async function asyncMap(array, asyncCallback) {
|
|
336
|
-
return Promise.all(array.map(asyncCallback));
|
|
337
|
-
}
|
|
338
|
-
export async function asyncForEach(array, asyncCallback) {
|
|
339
|
-
await Promise.all(array.map(asyncCallback));
|
|
340
|
-
}
|
|
341
|
-
export async function asyncFlatMap(array, asyncCallback) {
|
|
342
|
-
return (await Promise.all(array.map(asyncCallback))).flat();
|
|
343
|
-
}
|
|
344
|
-
const emptyPromise = new Promise(() => null);
|
|
345
|
-
export async function asyncSome(array, asyncCallback) {
|
|
346
|
-
const promises = array.map(asyncCallback);
|
|
347
|
-
return Promise.race([
|
|
348
|
-
Promise.race(
|
|
349
|
-
// empty promise is required here
|
|
350
|
-
// because otherwise the first false would immediately end the race without checking the rest of the array
|
|
351
|
-
promises.map(async (p) => !!(await p) || emptyPromise)),
|
|
352
|
-
Promise.all(promises).then((r) => r.some(Boolean))
|
|
353
|
-
]);
|
|
354
|
-
}
|
|
355
|
-
export const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
357
|
-
export function assertUnreachable(_) {
|
|
358
|
-
throw new Error("Didn't expect to get here");
|
|
359
|
-
}
|
|
360
|
-
export function isFocusable(item) {
|
|
361
|
-
if (item.tabIndex < 0) {
|
|
362
|
-
return false;
|
|
363
|
-
}
|
|
364
|
-
switch (item.tagName) {
|
|
365
|
-
case 'A':
|
|
366
|
-
return !!item.href;
|
|
367
|
-
case 'INPUT':
|
|
368
|
-
return item.type !== 'hidden' && !item.disabled;
|
|
369
|
-
case 'SELECT':
|
|
370
|
-
case 'TEXTAREA':
|
|
371
|
-
case 'BUTTON':
|
|
372
|
-
return !item.disabled;
|
|
373
|
-
default:
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
export function focusNextFocusable(element) {
|
|
378
|
-
for (const child of element.children) {
|
|
379
|
-
if (isFocusable(child)) {
|
|
380
|
-
child.focus();
|
|
381
|
-
return true;
|
|
382
|
-
}
|
|
383
|
-
if (focusNextFocusable(child)) {
|
|
384
|
-
return true;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
export const readonly = { readOnly: true };
|
|
390
|
-
export function assert(schema, value) {
|
|
391
|
-
if (dev) {
|
|
392
|
-
try {
|
|
393
|
-
Value.Assert(schema, value);
|
|
394
|
-
}
|
|
395
|
-
catch (e) {
|
|
396
|
-
console.log(e);
|
|
397
|
-
if (e && typeof e === 'object' && 'error' in e) {
|
|
398
|
-
console.log(e?.error);
|
|
399
|
-
}
|
|
400
|
-
// eslint-disable-next-line no-debugger
|
|
401
|
-
debugger;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
export function toFloFriendlyWithLocalTime(date) {
|
|
406
|
-
return {
|
|
407
|
-
...date,
|
|
408
|
-
value: date.value && floFriendlyWithLocalTime(date.value, date.podValue)
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
/** @deprecated Use toFloFriendlyWithLocalTime() instead */
|
|
412
|
-
export function toFloFriendlyWithTime(date) {
|
|
413
|
-
return {
|
|
414
|
-
...date,
|
|
415
|
-
value: date.value && floFriendlyWithTime(date.value, date.podValue)
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
export function saveBlob(blob, fileName) {
|
|
419
|
-
const a = document.createElement('a');
|
|
420
|
-
document.body.appendChild(a);
|
|
421
|
-
a.style.display = 'none';
|
|
422
|
-
const url = window.URL.createObjectURL(blob);
|
|
423
|
-
a.href = url;
|
|
424
|
-
a.download = fileName;
|
|
425
|
-
a.click();
|
|
426
|
-
window.URL.revokeObjectURL(url);
|
|
427
|
-
}
|
|
428
|
-
export function isAttributeMissing(item) {
|
|
429
|
-
return !item.value?.trim();
|
|
430
|
-
}
|
|
431
|
-
export function isAttributeInvalid(item) {
|
|
432
|
-
return item.value?.trim().toLocaleUpperCase() !== item.podValue?.trim().toLocaleUpperCase();
|
|
433
|
-
}
|
|
434
|
-
export function isAttributeDateInvalid(item) {
|
|
435
|
-
return (!item.value ||
|
|
436
|
-
!Date.parse(item.value) ||
|
|
437
|
-
new Date(item.podValue).toLocaleDateString() !== new Date(item.value).toLocaleDateString());
|
|
438
|
-
}
|
|
439
|
-
export async function asyncSleep(delay) {
|
|
440
|
-
await new Promise((r) => setTimeout(r, delay));
|
|
441
|
-
}
|
|
442
|
-
export function getOrCreateDeviceUUID() {
|
|
443
|
-
if (browser) {
|
|
444
|
-
const foundDeviceUuid = localStorage.getItem('device_uuid');
|
|
445
|
-
if (foundDeviceUuid) {
|
|
446
|
-
return foundDeviceUuid;
|
|
447
|
-
}
|
|
448
|
-
const newDeviceUuid = generateUUID();
|
|
449
|
-
localStorage.setItem('device_uuid', newDeviceUuid);
|
|
450
|
-
return newDeviceUuid;
|
|
451
|
-
}
|
|
452
|
-
return 'sveltekit-backend';
|
|
453
|
-
}
|
|
454
|
-
export function passthrough(e) {
|
|
455
|
-
if (!e.key.match(/^[a-zA-Z0-9[\]]$/gm)) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
e.target.blur();
|
|
459
|
-
}
|
|
460
|
-
// taken from https://stackoverflow.com/a/8809472/18712055
|
|
461
|
-
export function generateUUID() {
|
|
462
|
-
let d = new Date().getTime(), d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;
|
|
463
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
464
|
-
let r = Math.random() * 16;
|
|
465
|
-
if (d > 0) {
|
|
466
|
-
r = (d + r) % 16 | 0;
|
|
467
|
-
d = Math.floor(d / 16);
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
r = (d2 + r) % 16 | 0;
|
|
471
|
-
d2 = Math.floor(d2 / 16);
|
|
472
|
-
}
|
|
473
|
-
return (c == 'x' ? r : (r & 0x7) | 0x8).toString(16);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
// generic is present to bypass floatAlias type requirements and the like
|
|
477
|
-
export function generateShortUUID() {
|
|
478
|
-
return generateUUID().substring(0, 13);
|
|
479
|
-
}
|
|
480
|
-
export function refWrapper(initial) {
|
|
481
|
-
let value = $state(initial);
|
|
482
|
-
return {
|
|
483
|
-
get value() {
|
|
484
|
-
return value;
|
|
485
|
-
},
|
|
486
|
-
set value(v) {
|
|
487
|
-
value = v;
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SQLDate } from '../Internal/Misc.js';
|
|
2
2
|
import type { ExampleSelectEnum } from './ExampleSelectEnum.js';
|
|
3
3
|
export interface ExampleItem {
|
|
4
4
|
id: number;
|
|
@@ -8,8 +8,8 @@ export interface ExampleItem {
|
|
|
8
8
|
someNumber: number | null;
|
|
9
9
|
someDate: Date | null;
|
|
10
10
|
someDateWithTime: Date | null;
|
|
11
|
-
floDate:
|
|
12
|
-
floDateWithTime:
|
|
11
|
+
floDate: SQLDate | null;
|
|
12
|
+
floDateWithTime: SQLDate | null;
|
|
13
13
|
someSelect: ExampleSelectEnum | null;
|
|
14
14
|
someBubbles: string[];
|
|
15
15
|
}
|