@cloudparker/moldex.js 0.0.80 → 0.0.82
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/services/dialog/dialog-service.d.ts +3 -0
- package/dist/services/dialog/dialog-service.js +19 -0
- package/dist/services/utils/utils-service.d.ts +1 -0
- package/dist/services/utils/utils-service.js +9 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +42 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte.d.ts +27 -0
- package/package.json +1 -1
|
@@ -27,6 +27,9 @@ export declare function openDeleteConfirmDialog({ msg, title, footerOkButtonLabl
|
|
|
27
27
|
msg?: string;
|
|
28
28
|
}): Promise<unknown>;
|
|
29
29
|
export declare function openPickerDialog<R>({ items, value, multiple, hasCheckbox, hasArrow, maxlength, maxlengthMsg, identityFieldName, titleFieldName, searchFieldName, subtitleFieldName, ...params }: DialogProps & PickerDialogProps): Promise<R>;
|
|
30
|
+
export declare function openNumberFieldDialog({ title, value, label, name, maxlength, fieldClassName, autofocus, required, appearance, size, floatingLabel, ...params }?: DialogProps & InputFieldProps & {
|
|
31
|
+
fieldClassName?: string;
|
|
32
|
+
}): Promise<unknown>;
|
|
30
33
|
export declare function openTextFieldDialog({ title, value, label, name, maxlength, fieldClassName, autofocus, required, appearance, size, floatingLabel, ...params }?: DialogProps & InputFieldProps & {
|
|
31
34
|
fieldClassName?: string;
|
|
32
35
|
}): Promise<unknown>;
|
|
@@ -8,6 +8,7 @@ import { isMobileScreen } from '../screen/screen-service';
|
|
|
8
8
|
import CropperDialog, {} from '../../views/core/dialog/components/cropper-dialog/cropper-dialog.svelte';
|
|
9
9
|
import { processImageFile } from '../utils/image-service';
|
|
10
10
|
import PickerDialog from '../../views/core/dialog/components/picker-dialog/picker-dialog.svelte';
|
|
11
|
+
import NumberFieldDialog from '../../views/core/dialog/components/number-field-dialog/number-field-dialog.svelte';
|
|
11
12
|
function addDialog(props) {
|
|
12
13
|
const dialog = mount(Dialog, { target: document.getElementsByTagName('body')[0], props });
|
|
13
14
|
return dialog;
|
|
@@ -104,6 +105,24 @@ export async function openPickerDialog({ items, value, multiple, hasCheckbox = t
|
|
|
104
105
|
hasFooterCloseButton: multiple,
|
|
105
106
|
});
|
|
106
107
|
}
|
|
108
|
+
export async function openNumberFieldDialog({ title, value, label, name, maxlength, fieldClassName, autofocus, required, appearance, size, floatingLabel, ...params } = {}) {
|
|
109
|
+
return await openDialog({
|
|
110
|
+
bodyComponent: NumberFieldDialog,
|
|
111
|
+
props: { value, label, name, maxlength, className: fieldClassName, autofocus, required, appearance, size, floatingLabel, },
|
|
112
|
+
...params,
|
|
113
|
+
hasHeader: true,
|
|
114
|
+
hasHeaderBack: isMobileScreen(),
|
|
115
|
+
hasHeaderClose: !isMobileScreen(),
|
|
116
|
+
size: isMobileScreen() ? 'full' : 'sm',
|
|
117
|
+
hasTitle: true,
|
|
118
|
+
title: title || 'Prompt',
|
|
119
|
+
hasFooter: true,
|
|
120
|
+
hasFooterCloseButton: true,
|
|
121
|
+
hasFooterOkButton: true,
|
|
122
|
+
footerOkButtonType: 'submit',
|
|
123
|
+
targetFormId: 'number-field-dialog-form'
|
|
124
|
+
});
|
|
125
|
+
}
|
|
107
126
|
export async function openTextFieldDialog({ title, value, label, name, maxlength, fieldClassName, autofocus, required, appearance, size, floatingLabel, ...params } = {}) {
|
|
108
127
|
return await openDialog({
|
|
109
128
|
bodyComponent: TextFieldDialog,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toDate } from '../date/date-service';
|
|
2
|
+
import { customAlphabet } from 'nanoid';
|
|
2
3
|
/**
|
|
3
4
|
* Generates a random number between the specified minimum and maximum values (inclusive of the minimum and exclusive of the maximum).
|
|
4
5
|
*
|
|
@@ -394,3 +395,11 @@ export function pixelToInch(pixels) {
|
|
|
394
395
|
const DPI = 96; // Default DPI for screen resolution
|
|
395
396
|
return pixels / DPI;
|
|
396
397
|
}
|
|
398
|
+
export function alphabetNanoid(length = 10, lowercase = false) {
|
|
399
|
+
let alphabet = Array.from({ length: 26 }, (_, i) => String.fromCharCode(65 + i)).join('');
|
|
400
|
+
if (lowercase) {
|
|
401
|
+
alphabet = alphabet.toLowerCase();
|
|
402
|
+
}
|
|
403
|
+
const nanoid = customAlphabet(alphabet, length);
|
|
404
|
+
return nanoid();
|
|
405
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">import { showToast } from "../../../../../services";
|
|
2
|
+
import NumberField from "../../../input/components/number-field/number-field.svelte";
|
|
3
|
+
let {
|
|
4
|
+
value = $bindable(0),
|
|
5
|
+
label,
|
|
6
|
+
name,
|
|
7
|
+
maxlength,
|
|
8
|
+
className,
|
|
9
|
+
autofocus,
|
|
10
|
+
required,
|
|
11
|
+
setOnOkClick,
|
|
12
|
+
setResult,
|
|
13
|
+
closeDialog,
|
|
14
|
+
...props
|
|
15
|
+
} = $props();
|
|
16
|
+
let _value = $state(value || 0);
|
|
17
|
+
function handleSubmit(ev) {
|
|
18
|
+
ev?.preventDefault();
|
|
19
|
+
_value = _value || 0;
|
|
20
|
+
if (required) {
|
|
21
|
+
showToast({ msg: "This is a required field!" });
|
|
22
|
+
} else {
|
|
23
|
+
setResult(_value);
|
|
24
|
+
closeDialog();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="p-6">
|
|
30
|
+
<form id="number-field-dialog-form" onsubmit={handleSubmit}>
|
|
31
|
+
<NumberField
|
|
32
|
+
{...props}
|
|
33
|
+
{label}
|
|
34
|
+
{name}
|
|
35
|
+
{maxlength}
|
|
36
|
+
{className}
|
|
37
|
+
{autofocus}
|
|
38
|
+
{required}
|
|
39
|
+
bind:value={_value}
|
|
40
|
+
/>
|
|
41
|
+
</form>
|
|
42
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DialogExports } from '../dialog/dialog.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const NumberFieldDialog: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
value?: number;
|
|
17
|
+
label?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
maxlength?: number;
|
|
20
|
+
className?: string;
|
|
21
|
+
autofocus?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
} & DialogExports, {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
}, {}, {}, "value">;
|
|
26
|
+
type NumberFieldDialog = InstanceType<typeof NumberFieldDialog>;
|
|
27
|
+
export default NumberFieldDialog;
|