@cloudparker/moldex.js 0.0.79 → 0.0.81

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.
@@ -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,
@@ -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;
@@ -1,10 +1,8 @@
1
1
  import TextAwait from "./components/text-await/text-await.svelte";
2
2
  import TextCopy from "./components/text-copy/text-copy.svelte";
3
- import TextCountry from "./components/text-country/text-country.svelte";
4
- import TextCountryState from "./components/text-country-state/text-country-state.svelte";
5
3
  import TextCurrency from "./components/text-currency/text-currency.svelte";
6
4
  import TextDate from "./components/text-date/text-date.svelte";
7
5
  import TextEmail from "./components/text-email/text-email.svelte";
8
6
  import TextHtml from "./components/text-html/text-html.svelte";
9
7
  import TextPhone from "./components/text-phone/text-phone.svelte";
10
- export { TextAwait, TextCopy, TextCountry, TextCountryState, TextCurrency, TextDate, TextEmail, TextHtml, TextPhone, };
8
+ export { TextAwait, TextCopy, TextCurrency, TextDate, TextEmail, TextHtml, TextPhone, };
@@ -1,10 +1,8 @@
1
1
  import TextAwait from "./components/text-await/text-await.svelte";
2
2
  import TextCopy from "./components/text-copy/text-copy.svelte";
3
- import TextCountry from "./components/text-country/text-country.svelte";
4
- import TextCountryState from "./components/text-country-state/text-country-state.svelte";
5
3
  import TextCurrency from "./components/text-currency/text-currency.svelte";
6
4
  import TextDate from "./components/text-date/text-date.svelte";
7
5
  import TextEmail from "./components/text-email/text-email.svelte";
8
6
  import TextHtml from "./components/text-html/text-html.svelte";
9
7
  import TextPhone from "./components/text-phone/text-phone.svelte";
10
- export { TextAwait, TextCopy, TextCountry, TextCountryState, TextCurrency, TextDate, TextEmail, TextHtml, TextPhone, };
8
+ export { TextAwait, TextCopy, TextCurrency, TextDate, TextEmail, TextHtml, TextPhone, };
@@ -0,0 +1,34 @@
1
+ <script lang="ts">import ComboboxField from "../../core/input/components/combobox-field/combobox-field.svelte";
2
+ import CountryLoader from "../loaders/country-loader.svelte";
3
+ let {
4
+ value = $bindable(null),
5
+ titleFieldName = "name",
6
+ displayFieldName = "name",
7
+ searchFieldName = "name",
8
+ identityFieldName = "isoCode",
9
+ hasDropdownHeader = true,
10
+ hasDropdownHeaderSearch = true,
11
+ hasDropdownFooter = true,
12
+ hasDropdownFooterCreateButton = true,
13
+ ...props
14
+ } = $props();
15
+ let countries = $state([]);
16
+ </script>
17
+
18
+ <CountryLoader bind:countries>
19
+ <ComboboxField
20
+ bind:value
21
+ items={countries}
22
+ {titleFieldName}
23
+ {displayFieldName}
24
+ {searchFieldName}
25
+ {identityFieldName}
26
+ {hasDropdownHeader}
27
+ {hasDropdownHeaderSearch}
28
+ {hasDropdownFooter}
29
+ {hasDropdownFooterCreateButton}
30
+ dropdownFooterClassName="border-t"
31
+ createButtonClassName="border-primary text-primary hover:text-primary"
32
+ {...props}
33
+ />
34
+ </CountryLoader>
@@ -0,0 +1,21 @@
1
+ import type { ComboboxFieldProps, InputFieldProps } from '../../core';
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 CountryComboboxField: $$__sveltets_2_IsomorphicComponent<ComboboxFieldProps & InputFieldProps & {
16
+ value?: any;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, "value">;
20
+ type CountryComboboxField = InstanceType<typeof CountryComboboxField>;
21
+ export default CountryComboboxField;
@@ -0,0 +1,6 @@
1
+ import CountryComboboxField from "./fields/country-combobox-field.svelte";
2
+ import TextCountry from "./texts/text-country.svelte";
3
+ import TextCountryState from "./texts/text-country-state.svelte";
4
+ import CountryLoader, { type Country } from "./loaders/country-loader.svelte";
5
+ export type { Country };
6
+ export { CountryComboboxField, TextCountry, CountryLoader, TextCountryState };
@@ -0,0 +1,5 @@
1
+ import CountryComboboxField from "./fields/country-combobox-field.svelte";
2
+ import TextCountry from "./texts/text-country.svelte";
3
+ import TextCountryState from "./texts/text-country-state.svelte";
4
+ import CountryLoader, {} from "./loaders/country-loader.svelte";
5
+ export { CountryComboboxField, TextCountry, CountryLoader, TextCountryState };
@@ -0,0 +1,26 @@
1
+ <script lang="ts" module></script>
2
+
3
+ <script lang="ts">import EasyScriptLoader from "@cloudparker/easy-script-loader-svelte";
4
+ let { countries = $bindable([]), onLoad, children } = $props();
5
+ let EasyCountryData;
6
+ export async function loadCountries() {
7
+ if (EasyCountryData) {
8
+ countries = EasyCountryData.getCountries();
9
+ onLoad && onLoad(countries);
10
+ }
11
+ }
12
+ function handleCountriesLoaded(lib) {
13
+ EasyCountryData = lib;
14
+ loadCountries();
15
+ }
16
+ </script>
17
+
18
+ <EasyScriptLoader
19
+ scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-countrydata@main/dist/index.js"
20
+ scriptName="EasyCountryData"
21
+ onLoad={handleCountriesLoaded}
22
+ />
23
+
24
+ {#if children}
25
+ {@render children()}
26
+ {/if}
@@ -0,0 +1,30 @@
1
+ export type Country = {
2
+ isoCode: string;
3
+ dialCode: string;
4
+ name: string;
5
+ };
6
+ import type { Snippet } from 'svelte';
7
+ 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> {
8
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
9
+ $$bindings?: Bindings;
10
+ } & Exports;
11
+ (internal: unknown, props: Props & {
12
+ $$events?: Events;
13
+ $$slots?: Slots;
14
+ }): Exports & {
15
+ $set?: any;
16
+ $on?: any;
17
+ };
18
+ z_$$bindings?: Bindings;
19
+ }
20
+ declare const CountryLoader: $$__sveltets_2_IsomorphicComponent<{
21
+ countries?: Country[];
22
+ onLoad?: (countries?: Country[]) => void;
23
+ children?: Snippet;
24
+ }, {
25
+ [evt: string]: CustomEvent<any>;
26
+ }, {}, {
27
+ loadCountries: () => Promise<void>;
28
+ }, "countries">;
29
+ type CountryLoader = InstanceType<typeof CountryLoader>;
30
+ export default CountryLoader;
@@ -1,5 +1,4 @@
1
- <script lang="ts">import "../../../../../tailwind.css";
2
- import EasyScriptLoader from "@cloudparker/easy-script-loader-svelte";
1
+ <script lang="ts">import EasyScriptLoader from "@cloudparker/easy-script-loader-svelte";
3
2
  import { BROWSER } from "esm-env";
4
3
  let { input } = $props();
5
4
  let states = $state([]);
@@ -1,4 +1,3 @@
1
- import '../../../../../tailwind.css';
2
1
  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
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
3
  $$bindings?: Bindings;
@@ -0,0 +1,13 @@
1
+ <script lang="ts">import CountryLoader, {} from "../loaders/country-loader.svelte";
2
+ let { input } = $props();
3
+ let countries = $state([]);
4
+ let country = $derived.by(() => {
5
+ if (input && countries?.length) {
6
+ return countries.find((c) => c.isoCode == input);
7
+ }
8
+ });
9
+ </script>
10
+
11
+ <CountryLoader bind:countries>
12
+ {country?.name || ''}
13
+ </CountryLoader>
@@ -1,4 +1,3 @@
1
- import '../../../../../tailwind.css';
2
1
  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
2
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
3
  $$bindings?: Bindings;
@@ -1 +1,2 @@
1
1
  export * from './core/index.js';
2
+ export * from './extra/index.js';
@@ -1 +1,2 @@
1
1
  export * from './core/index.js';
2
+ export * from './extra/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudparker/moldex.js",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "author": "cloudparker.com",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -1,39 +0,0 @@
1
- <script lang="ts">import "../../../../../tailwind.css";
2
- import EasyScriptLoader from "@cloudparker/easy-script-loader-svelte";
3
- import { BROWSER } from "esm-env";
4
- let { input } = $props();
5
- let countries = $state([]);
6
- let country = $state(null);
7
- let EasyCountryData;
8
- async function init() {
9
- if (EasyCountryData) {
10
- countries = EasyCountryData.getCountries();
11
- }
12
- }
13
- function handleScriptLoad(lib) {
14
- EasyCountryData = lib;
15
- console.log("EasyCountryData", EasyCountryData);
16
- init();
17
- }
18
- async function prepare(..._) {
19
- if (input) {
20
- if (countries?.length) {
21
- country = countries.find((o) => o.isoCode == input);
22
- }
23
- } else {
24
- country = null;
25
- }
26
- }
27
- $effect(() => {
28
- BROWSER && prepare(input, countries);
29
- });
30
- </script>
31
-
32
- <EasyScriptLoader
33
- scriptName="EasyCountryData"
34
- scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-countrydata@main/dist/index.js"
35
- onLoad={handleScriptLoad}
36
- />
37
- {#if country}
38
- <span> {country?.name || ''} </span>
39
- {/if}