@cloudparker/moldex.js 4.1.11 → 4.1.12
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/views/extra/fields/state-combobox-field.svelte +44 -0
- package/dist/views/extra/fields/state-combobox-field.svelte.d.ts +10 -0
- package/dist/views/extra/index.d.ts +3 -1
- package/dist/views/extra/index.js +3 -1
- package/dist/views/extra/loaders/state-loader.svelte +49 -0
- package/dist/views/extra/loaders/state-loader.svelte.d.ts +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComboboxFieldProps, InputFieldProps } from '../../core';
|
|
3
|
+
import ComboboxField from '../../core/input/components/combobox-field/combobox-field.svelte';
|
|
4
|
+
import StateLoader, { type State } from '../loaders/state-loader.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
value?: State | null;
|
|
8
|
+
countryCode?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
value = $bindable(null),
|
|
13
|
+
countryCode = undefined,
|
|
14
|
+
titleFieldName = 'name',
|
|
15
|
+
displayFieldName = 'name',
|
|
16
|
+
searchFieldName = 'name',
|
|
17
|
+
identityFieldName = '_id',
|
|
18
|
+
hasDropdownHeader = true,
|
|
19
|
+
hasDropdownHeaderSearch = true,
|
|
20
|
+
hasDropdownFooter = true,
|
|
21
|
+
hasDropdownFooterCreateButton = true,
|
|
22
|
+
...props
|
|
23
|
+
}: ComboboxFieldProps & InputFieldProps & Props = $props();
|
|
24
|
+
|
|
25
|
+
let states: State[] = $state([]);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<StateLoader bind:states {countryCode}>
|
|
29
|
+
<ComboboxField
|
|
30
|
+
bind:value
|
|
31
|
+
items={states}
|
|
32
|
+
{titleFieldName}
|
|
33
|
+
{displayFieldName}
|
|
34
|
+
{searchFieldName}
|
|
35
|
+
{identityFieldName}
|
|
36
|
+
{hasDropdownHeader}
|
|
37
|
+
{hasDropdownHeaderSearch}
|
|
38
|
+
{hasDropdownFooter}
|
|
39
|
+
{hasDropdownFooterCreateButton}
|
|
40
|
+
dropdownFooterClassName="border-t"
|
|
41
|
+
createButtonClassName="border-primary text-primary hover:text-primary"
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
</StateLoader>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComboboxFieldProps, InputFieldProps } from '../../core';
|
|
2
|
+
import { type State } from '../loaders/state-loader.svelte';
|
|
3
|
+
type Props = {
|
|
4
|
+
value?: State | null;
|
|
5
|
+
countryCode?: string;
|
|
6
|
+
};
|
|
7
|
+
type $$ComponentProps = ComboboxFieldProps & InputFieldProps & Props;
|
|
8
|
+
declare const StateComboboxField: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
9
|
+
type StateComboboxField = ReturnType<typeof StateComboboxField>;
|
|
10
|
+
export default StateComboboxField;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import CountryComboboxField from "./fields/country-combobox-field.svelte";
|
|
2
|
+
import StateComboboxField from "./fields/state-combobox-field.svelte";
|
|
2
3
|
import TextCountry from "./texts/text-country.svelte";
|
|
3
4
|
import TextCountryState from "./texts/text-country-state.svelte";
|
|
4
5
|
import CountryLoader from "./loaders/country-loader.svelte";
|
|
6
|
+
import StateLoader from "./loaders/state-loader.svelte";
|
|
5
7
|
export * from './types';
|
|
6
|
-
export { CountryComboboxField, TextCountry, CountryLoader, TextCountryState, };
|
|
8
|
+
export { CountryComboboxField, StateComboboxField, TextCountry, CountryLoader, StateLoader, TextCountryState, };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import CountryComboboxField from "./fields/country-combobox-field.svelte";
|
|
2
|
+
import StateComboboxField from "./fields/state-combobox-field.svelte";
|
|
2
3
|
import TextCountry from "./texts/text-country.svelte";
|
|
3
4
|
import TextCountryState from "./texts/text-country-state.svelte";
|
|
4
5
|
import CountryLoader from "./loaders/country-loader.svelte";
|
|
6
|
+
import StateLoader from "./loaders/state-loader.svelte";
|
|
5
7
|
export * from './types';
|
|
6
|
-
export { CountryComboboxField, TextCountry, CountryLoader, TextCountryState, };
|
|
8
|
+
export { CountryComboboxField, StateComboboxField, TextCountry, CountryLoader, StateLoader, TextCountryState, };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export type State = {
|
|
6
|
+
_id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
countryId: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
states?: State[];
|
|
13
|
+
countryCode?: string;
|
|
14
|
+
onLoad?: (states?: State[]) => void;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let { states = $bindable([]), countryCode, onLoad, children }: Props = $props();
|
|
19
|
+
|
|
20
|
+
let EasyCountryStateData: any;
|
|
21
|
+
|
|
22
|
+
export async function loadStates(countryCode?: string) {
|
|
23
|
+
if (EasyCountryStateData) {
|
|
24
|
+
states = EasyCountryStateData.getStates(countryCode || null);
|
|
25
|
+
onLoad && onLoad(states);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function handleStatesLoaded(lib: any) {
|
|
30
|
+
EasyCountryStateData = lib;
|
|
31
|
+
loadStates();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$effect(() => {
|
|
35
|
+
(async () => {
|
|
36
|
+
loadStates(countryCode);
|
|
37
|
+
})();
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<EasyScriptLoader
|
|
42
|
+
scriptUrl="hhttps://cdn.jsdelivr.net/gh/paramanandapradhan/easy-country-state-data@main/dist/index.js"
|
|
43
|
+
scriptName="EasyCountryStateData"
|
|
44
|
+
onLoad={handleStatesLoaded}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
{#if children}
|
|
48
|
+
{@render children()}
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type State = {
|
|
3
|
+
_id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
countryId: string;
|
|
6
|
+
};
|
|
7
|
+
type Props = {
|
|
8
|
+
states?: State[];
|
|
9
|
+
countryCode?: string;
|
|
10
|
+
onLoad?: (states?: State[]) => void;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
};
|
|
13
|
+
declare const StateLoader: import("svelte").Component<Props, {
|
|
14
|
+
loadStates: (countryCode?: string) => Promise<void>;
|
|
15
|
+
}, "states">;
|
|
16
|
+
type StateLoader = ReturnType<typeof StateLoader>;
|
|
17
|
+
export default StateLoader;
|