@cloudparker/moldex.js 0.0.28 → 0.0.30
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 +16 -0
- package/dist/services/dialog/dialog-service.js +23 -1
- package/dist/services/utils/utils-service.d.ts +3 -0
- package/dist/services/utils/utils-service.js +26 -0
- package/dist/tailwind.css +1 -1
- package/dist/views/core/button/components/button/button.svelte +57 -34
- package/dist/views/core/button/components/button/button.svelte.d.ts +19 -18
- package/dist/views/core/button/components/button-back/button-back.svelte +44 -0
- package/dist/views/core/button/components/button-back/button-back.svelte.d.ts +24 -0
- package/dist/views/core/button/components/button-close/button-close.svelte +7 -0
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +19 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +47 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte.d.ts +25 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +94 -42
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +11 -11
- package/dist/views/core/button/components/button-menu/button-menu.svelte +155 -103
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +7 -7
- package/dist/views/core/button/components/button-ok/button-ok.svelte +7 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +19 -0
- package/dist/views/core/button/index.d.ts +5 -1
- package/dist/views/core/button/index.js +10 -1
- package/dist/views/core/dialog/components/dialog/dialog.svelte +328 -231
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +6 -10
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +189 -0
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte.d.ts +41 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +22 -13
- package/dist/views/core/dialog/index.d.ts +4 -2
- package/dist/views/core/dialog/index.js +2 -2
- package/dist/views/core/drawer/components/drawer/drawer.svelte +52 -34
- package/dist/views/core/icon/components/icon/icon.svelte +25 -12
- package/dist/views/core/icon/components/icon/icon.svelte.d.ts +1 -0
- package/dist/views/core/icon/services/icon-path-service.d.ts +6 -0
- package/dist/views/core/icon/services/icon-path-service.js +6 -0
- package/dist/views/core/index.d.ts +2 -0
- package/dist/views/core/index.js +2 -0
- package/dist/views/core/input/components/color-field/color-field.svelte +114 -0
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +23 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +467 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +63 -0
- package/dist/views/core/input/components/date-field/date-field.svelte +13 -0
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +13 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/email-field/email-field.svelte +12 -0
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/file-field/file-field.svelte +92 -0
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +25 -0
- package/dist/views/core/input/components/input-field/input-field.svelte +382 -0
- package/dist/views/core/{form → input}/components/input-field/input-field.svelte.d.ts +51 -35
- package/dist/views/core/input/components/label/label.svelte +46 -0
- package/dist/views/core/input/components/number-field/number-field.svelte +13 -0
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/password-field/password-field.svelte +83 -0
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte +90 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +72 -0
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +31 -0
- package/dist/views/core/input/components/search-field/search-field.svelte +67 -0
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/text-field/text-field.svelte +12 -0
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +12 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/time-field/time-field.svelte +12 -0
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +21 -0
- package/dist/views/core/input/index.d.ts +19 -0
- package/dist/views/core/input/index.js +19 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte +71 -39
- package/dist/views/core/navbar/components/navbar/navbar.svelte.d.ts +3 -3
- package/dist/views/core/no-data/components/no-data/no-data.svelte +51 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +27 -0
- package/dist/views/core/no-data/index.d.ts +2 -0
- package/dist/views/core/no-data/index.js +2 -0
- package/dist/views/core/pagination/components/pagination/pagination.svelte +100 -71
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +37 -23
- package/dist/views/core/referrer/components/referrer.svelte +15 -13
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +6 -2
- package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
- package/dist/views/core/spinner/components/spinner/spinner.svelte +7 -2
- package/dist/views/core/text/components/text-await/text-await.svelte +8 -2
- package/dist/views/core/text/components/text-copy/text-copy.svelte +28 -17
- package/dist/views/core/text/components/text-country/text-country.svelte +42 -29
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +38 -30
- package/dist/views/core/text/components/text-currency/text-currency.svelte +21 -10
- package/dist/views/core/text/components/text-date/text-date.svelte +33 -21
- package/dist/views/core/text/components/text-email/text-email.svelte +13 -4
- package/dist/views/core/text/components/text-html/text-html.svelte +3 -2
- package/dist/views/core/text/components/text-phone/text-phone.svelte +13 -4
- package/dist/views/core/toast/components/toast/toast.svelte +44 -21
- package/package.json +2 -2
- package/dist/views/core/form/components/input-field/input-field.svelte +0 -233
- package/dist/views/core/form/components/label/label.svelte +0 -32
- package/dist/views/core/form/index.d.ts +0 -3
- package/dist/views/core/form/index.js +0 -3
- /package/dist/views/core/{form → input}/components/label/label.svelte.d.ts +0 -0
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../../../../../tailwind.css';
|
|
3
|
+
import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
|
|
4
|
+
import { BROWSER } from 'esm-env';
|
|
5
|
+
|
|
6
|
+
type PropsType = {
|
|
7
|
+
input?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let { input }: PropsType = $props();
|
|
11
|
+
|
|
12
|
+
let countries: any[] = $state([]);
|
|
13
|
+
let country: any | null = $state(null);
|
|
14
|
+
|
|
15
|
+
let EasyCountryData: any;
|
|
16
|
+
|
|
17
|
+
async function init() {
|
|
18
|
+
if (EasyCountryData) {
|
|
19
|
+
countries = EasyCountryData.getCountries();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function handleScriptLoad(lib: CustomEvent) {
|
|
24
|
+
EasyCountryData = lib;
|
|
25
|
+
console.log('EasyCountryData', EasyCountryData);
|
|
26
|
+
init();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function prepare(..._: any) {
|
|
30
|
+
if (input) {
|
|
31
|
+
if (countries?.length) {
|
|
32
|
+
country = countries.find((o) => o.isoCode == input);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
country = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
$effect(() => {
|
|
40
|
+
BROWSER && prepare(input, countries);
|
|
41
|
+
});
|
|
29
42
|
</script>
|
|
30
43
|
|
|
31
44
|
<EasyScriptLoader
|
|
32
45
|
scriptName="EasyCountryData"
|
|
33
46
|
scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-countrydata@main/dist/index.js"
|
|
34
|
-
|
|
47
|
+
onLoad={handleScriptLoad}
|
|
35
48
|
/>
|
|
36
49
|
{#if country}
|
|
37
50
|
<span> {country?.name || ''} </span>
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
async function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../../../../../tailwind.css';
|
|
3
|
+
import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
|
|
4
|
+
import { BROWSER } from 'esm-env';
|
|
5
|
+
|
|
6
|
+
let { input }: { input: string } = $props();
|
|
7
|
+
|
|
8
|
+
let states: any[] = $state([]);
|
|
9
|
+
let state: any | null = $state(null);
|
|
10
|
+
|
|
11
|
+
let EasyCountryStateData: any;
|
|
12
|
+
|
|
13
|
+
async function init() {
|
|
14
|
+
if (EasyCountryStateData) {
|
|
15
|
+
states = EasyCountryStateData.getStates() || [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function prepare(..._: any) {
|
|
20
|
+
if (input) {
|
|
21
|
+
await init();
|
|
22
|
+
if (states?.length) {
|
|
23
|
+
state = states.find((o) => o._id == input);
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
state = null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function handleScriptLoad(ev: CustomEvent) {
|
|
31
|
+
EasyCountryStateData = ev.detail;
|
|
32
|
+
init();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$effect(() => {
|
|
36
|
+
BROWSER && prepare(input, states);
|
|
37
|
+
});
|
|
30
38
|
</script>
|
|
31
39
|
|
|
32
40
|
<EasyScriptLoader
|
|
33
41
|
scriptName="EasyCountryStateData"
|
|
34
42
|
scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-country-state-data@main/dist/index.js"
|
|
35
|
-
|
|
43
|
+
onLoad={handleScriptLoad}
|
|
36
44
|
/>
|
|
37
45
|
|
|
38
46
|
{#if state}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../../../../../tailwind.css';
|
|
3
|
+
import { BROWSER } from 'esm-env';
|
|
4
|
+
|
|
5
|
+
type PropsType = {
|
|
6
|
+
input: number;
|
|
7
|
+
symbol: string;
|
|
8
|
+
hasSymbol: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { input, symbol = '$', hasSymbol = true }: PropsType = $props();
|
|
12
|
+
|
|
13
|
+
let value: string = $state('');
|
|
14
|
+
|
|
15
|
+
function prepare(..._: any) {
|
|
16
|
+
value = Math.abs(input || 0).toFixed(2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
BROWSER && prepare(input);
|
|
21
|
+
});
|
|
11
22
|
</script>
|
|
12
23
|
|
|
13
24
|
<span>
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../../../../../tailwind.css';
|
|
3
|
+
import { dateFormat, dateToAgo, toDate } from '../../../../../services';
|
|
4
|
+
|
|
5
|
+
import { BROWSER } from 'esm-env';
|
|
6
|
+
|
|
7
|
+
type PropsType = {
|
|
8
|
+
input: Date | number | string | { seconds: number; nanoseconds: number };
|
|
9
|
+
format?: 'ago' | string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let { input, format = 'DD-MM-YYYY hh:mm a' }: PropsType = $props();
|
|
13
|
+
|
|
14
|
+
let dateString: string = $state('');
|
|
15
|
+
|
|
16
|
+
function prepareDate(..._: any) {
|
|
17
|
+
// console.log('date data', data);
|
|
18
|
+
let date: Date | undefined;
|
|
19
|
+
if (input) {
|
|
20
|
+
date = toDate(input);
|
|
21
|
+
}
|
|
22
|
+
if (date) {
|
|
23
|
+
if (format == 'ago') {
|
|
24
|
+
dateString = dateToAgo(date)!;
|
|
25
|
+
} else {
|
|
26
|
+
dateString = dateFormat(date, format)!;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
$effect(() => {
|
|
32
|
+
BROWSER && prepareDate(input);
|
|
33
|
+
});
|
|
22
34
|
</script>
|
|
23
35
|
|
|
24
36
|
<span>
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../../../../../tailwind.css';
|
|
3
|
+
import { ripple } from '../../../../../actions';
|
|
4
|
+
import { Icon, mdiEmailOutline } from '../../../icon';
|
|
5
|
+
|
|
6
|
+
type PropsType = {
|
|
7
|
+
input: string;
|
|
8
|
+
buttonClassName?: string;
|
|
9
|
+
iconPath?: string;
|
|
10
|
+
iconClassName?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { input, buttonClassName, iconClassName, iconPath = mdiEmailOutline }: PropsType = $props();
|
|
5
14
|
</script>
|
|
6
15
|
|
|
7
16
|
<span class="flex items-center">
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mdiPhone } from '../../../icon';
|
|
3
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
4
|
+
import '../../../../../tailwind.css';
|
|
5
|
+
|
|
6
|
+
type PropsType = {
|
|
7
|
+
input: string;
|
|
8
|
+
buttonClassName?: string;
|
|
9
|
+
iconPath?: string;
|
|
10
|
+
iconClassName?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { input, buttonClassName, iconClassName, iconPath = mdiPhone }: PropsType = $props();
|
|
5
14
|
</script>
|
|
6
15
|
|
|
7
16
|
<span class="flex items-center">
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type ToastPropsType = {
|
|
5
|
+
id?: string;
|
|
6
|
+
msg: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import '../../../../../tailwind.css';
|
|
15
|
+
|
|
16
|
+
let isPlaced: boolean = $state(false);
|
|
17
|
+
let isOpened: boolean = $state(false);
|
|
18
|
+
|
|
19
|
+
let { id, msg, duration = 3000, className, children }: ToastPropsType = $props();
|
|
20
|
+
|
|
21
|
+
// export function toggleDialog() {
|
|
22
|
+
// if (isOpened) {
|
|
23
|
+
// closeDialog();
|
|
24
|
+
// } else {
|
|
25
|
+
// openDialog();
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
export function openToast() {
|
|
30
|
+
isPlaced = true;
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
isOpened = true;
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
closeClose();
|
|
35
|
+
}, duration);
|
|
36
|
+
}, 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function closeClose() {
|
|
40
|
+
isOpened = false;
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
isPlaced = false;
|
|
43
|
+
}, 300);
|
|
44
|
+
}
|
|
22
45
|
</script>
|
|
23
46
|
|
|
24
47
|
{#if isPlaced}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudparker/moldex.js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"author": "cloudparker.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"repository": "https://github.com/paramanandapradhan/moldex.js",
|
|
28
28
|
"homepage": "https://cloudparker.com",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@cloudparker/easy-script-loader-svelte": "^
|
|
30
|
+
"@cloudparker/easy-script-loader-svelte": "^4.0.0",
|
|
31
31
|
"esm-env": "^1.0.0",
|
|
32
32
|
"moment": "^2.30.1"
|
|
33
33
|
},
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts"></script>
|
|
2
|
-
|
|
3
|
-
<script lang="ts">import Icon from "../../../icon/components/icon/icon.svelte";
|
|
4
|
-
import Label from "../label/label.svelte";
|
|
5
|
-
let {
|
|
6
|
-
id = "",
|
|
7
|
-
name = "",
|
|
8
|
-
value = $bindable(""),
|
|
9
|
-
className = "",
|
|
10
|
-
label = "",
|
|
11
|
-
type = "text",
|
|
12
|
-
labelClassName = "",
|
|
13
|
-
containerClassName = "",
|
|
14
|
-
placeholder = "",
|
|
15
|
-
required = false,
|
|
16
|
-
requiredSymbolColor = "red",
|
|
17
|
-
requiredSymbol = "*",
|
|
18
|
-
hasRequiredSymbol = true,
|
|
19
|
-
disabled = false,
|
|
20
|
-
autofocus = false,
|
|
21
|
-
readonly = false,
|
|
22
|
-
maxlength,
|
|
23
|
-
minlength,
|
|
24
|
-
min,
|
|
25
|
-
max,
|
|
26
|
-
step,
|
|
27
|
-
size = "md",
|
|
28
|
-
appearance = "normal",
|
|
29
|
-
floatingLabel = false,
|
|
30
|
-
pattern = "",
|
|
31
|
-
multiple = false,
|
|
32
|
-
iconPath,
|
|
33
|
-
iconClassName = "",
|
|
34
|
-
onchange,
|
|
35
|
-
oninput,
|
|
36
|
-
onfocus,
|
|
37
|
-
onblur,
|
|
38
|
-
ondblclick,
|
|
39
|
-
onclick,
|
|
40
|
-
onmousedown,
|
|
41
|
-
onmouseup,
|
|
42
|
-
onkeydown,
|
|
43
|
-
onkeyup,
|
|
44
|
-
onkeypress,
|
|
45
|
-
ondrop,
|
|
46
|
-
ondrag,
|
|
47
|
-
ondragover
|
|
48
|
-
} = $props();
|
|
49
|
-
let inputRef = $state(null);
|
|
50
|
-
let sizeClassName = $state("");
|
|
51
|
-
let appearanceClassName = $state("");
|
|
52
|
-
let floatingLabelClassName = $state("");
|
|
53
|
-
let floatingLabelPaddingClassName = $state("");
|
|
54
|
-
let floatingLabelTextClassName = $state("");
|
|
55
|
-
let iconPaddingClassName = $state();
|
|
56
|
-
let iconSizeClassName = $state();
|
|
57
|
-
let floatingLabelIconTextPaddingClassName = $state("");
|
|
58
|
-
$effect(() => {
|
|
59
|
-
if (iconPath || floatingLabel) {
|
|
60
|
-
containerClassName = (containerClassName || "") + " relative";
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
$effect(() => {
|
|
64
|
-
if (iconPath) {
|
|
65
|
-
let flpcn;
|
|
66
|
-
switch (size) {
|
|
67
|
-
case "lg":
|
|
68
|
-
iconPaddingClassName = "ps-12";
|
|
69
|
-
flpcn = ` peer-placeholder-shown:ps-12 `;
|
|
70
|
-
iconSizeClassName = "!w-8 !h-8";
|
|
71
|
-
break;
|
|
72
|
-
case "md":
|
|
73
|
-
iconPaddingClassName = "ps-10";
|
|
74
|
-
flpcn = ` peer-placeholder-shown:ps-10 `;
|
|
75
|
-
iconSizeClassName = "!w-6 !h-6";
|
|
76
|
-
break;
|
|
77
|
-
case "sm":
|
|
78
|
-
iconPaddingClassName = "ps-9";
|
|
79
|
-
flpcn = ` peer-placeholder-shown:ps-9 `;
|
|
80
|
-
iconSizeClassName = "!w-5 !h-5";
|
|
81
|
-
break;
|
|
82
|
-
case "xs":
|
|
83
|
-
iconPaddingClassName = "ps-7";
|
|
84
|
-
flpcn = ` peer-placeholder-shown:ps-7 `;
|
|
85
|
-
iconSizeClassName = "!w-3 !h-3";
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
floatingLabelIconTextPaddingClassName = flpcn;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
$effect(() => {
|
|
92
|
-
if (floatingLabel) {
|
|
93
|
-
if (size) {
|
|
94
|
-
let flpcn = "";
|
|
95
|
-
switch (size) {
|
|
96
|
-
case "lg":
|
|
97
|
-
flpcn = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
|
|
98
|
-
floatingLabelTextClassName = "text-base";
|
|
99
|
-
break;
|
|
100
|
-
case "md":
|
|
101
|
-
flpcn = " px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ";
|
|
102
|
-
floatingLabelTextClassName = "text-sm";
|
|
103
|
-
break;
|
|
104
|
-
case "sm":
|
|
105
|
-
flpcn = " px-1 peer-focus:px-1 peer-placeholder-shown:px-2";
|
|
106
|
-
floatingLabelTextClassName = "text-xs";
|
|
107
|
-
break;
|
|
108
|
-
case "xs":
|
|
109
|
-
flpcn = " px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ";
|
|
110
|
-
floatingLabelTextClassName = "text-xs";
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
floatingLabelPaddingClassName = floatingLabelIconTextPaddingClassName + flpcn;
|
|
114
|
-
}
|
|
115
|
-
labelClassName = (labelClassName || "") + `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-transparent peer-placeholder-shown:bg-transparent peer-focus:bg-white start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
$effect(() => {
|
|
119
|
-
if (appearance) {
|
|
120
|
-
switch (appearance) {
|
|
121
|
-
case "normal":
|
|
122
|
-
appearanceClassName = "bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-700 ";
|
|
123
|
-
break;
|
|
124
|
-
case "box":
|
|
125
|
-
appearanceClassName = "bg-gray-50 border border-gray-300 text-gray-900 focus:ring-indigo-500 focus:border-indigo-500 ";
|
|
126
|
-
break;
|
|
127
|
-
case "fill":
|
|
128
|
-
appearanceClassName = "bg-gray-100 border-0 appearance-none focus:bg-gray-200 focus:outline-none focus:ring-0";
|
|
129
|
-
break;
|
|
130
|
-
case "underline":
|
|
131
|
-
appearanceClassName = "bg-transparent border-0 border-b-2 border-gray-300 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600";
|
|
132
|
-
break;
|
|
133
|
-
case "fill-underline":
|
|
134
|
-
appearanceClassName = "bg-gray-100 border-0 border-b-2 border-gray-300 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600";
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
$effect(() => {
|
|
140
|
-
if (size) {
|
|
141
|
-
switch (size) {
|
|
142
|
-
case "lg":
|
|
143
|
-
sizeClassName = "p-4 text-base";
|
|
144
|
-
break;
|
|
145
|
-
case "md":
|
|
146
|
-
sizeClassName = "p-2.5 text-sm";
|
|
147
|
-
break;
|
|
148
|
-
case "sm":
|
|
149
|
-
sizeClassName = "p-2 text-xs";
|
|
150
|
-
break;
|
|
151
|
-
case "xs":
|
|
152
|
-
sizeClassName = "p-1 text-xs";
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
$effect(() => {
|
|
158
|
-
if (name && !id) {
|
|
159
|
-
id = name;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
$effect(() => {
|
|
163
|
-
if (inputRef && autofocus) {
|
|
164
|
-
inputRef.focus();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
</script>
|
|
168
|
-
|
|
169
|
-
{#snippet labelSnippet()}
|
|
170
|
-
<Label
|
|
171
|
-
forName={id}
|
|
172
|
-
{label}
|
|
173
|
-
className={labelClassName}
|
|
174
|
-
{required}
|
|
175
|
-
{requiredSymbolColor}
|
|
176
|
-
{requiredSymbol}
|
|
177
|
-
{hasRequiredSymbol}
|
|
178
|
-
></Label>
|
|
179
|
-
{/snippet}
|
|
180
|
-
|
|
181
|
-
{#snippet createIcon()}
|
|
182
|
-
<div class="absolute inset-y-0 start-0 flex items-center ps-2.5 pointer-events-none {className}">
|
|
183
|
-
<Icon path={iconPath!} className="text-gray-500 {iconSizeClassName} {iconClassName}" />
|
|
184
|
-
</div>
|
|
185
|
-
{/snippet}
|
|
186
|
-
|
|
187
|
-
{#if !floatingLabel && (label || iconPath)}
|
|
188
|
-
{@render labelSnippet()}
|
|
189
|
-
{/if}
|
|
190
|
-
<div class={containerClassName}>
|
|
191
|
-
{#if iconPath}
|
|
192
|
-
{@render createIcon()}
|
|
193
|
-
{/if}
|
|
194
|
-
<input
|
|
195
|
-
bind:this={inputRef}
|
|
196
|
-
bind:value
|
|
197
|
-
{type}
|
|
198
|
-
{id}
|
|
199
|
-
{name}
|
|
200
|
-
class="block w-full peer ps- {iconPaddingClassName} {appearanceClassName} {floatingLabelClassName} {sizeClassName} {className}"
|
|
201
|
-
{placeholder}
|
|
202
|
-
{required}
|
|
203
|
-
{disabled}
|
|
204
|
-
{readonly}
|
|
205
|
-
{maxlength}
|
|
206
|
-
{minlength}
|
|
207
|
-
{min}
|
|
208
|
-
{max}
|
|
209
|
-
{step}
|
|
210
|
-
{pattern}
|
|
211
|
-
{onchange}
|
|
212
|
-
{oninput}
|
|
213
|
-
{onfocus}
|
|
214
|
-
{onblur}
|
|
215
|
-
{ondblclick}
|
|
216
|
-
{onclick}
|
|
217
|
-
{onmousedown}
|
|
218
|
-
{onmouseup}
|
|
219
|
-
{onkeydown}
|
|
220
|
-
{onkeyup}
|
|
221
|
-
{onkeypress}
|
|
222
|
-
{ondrop}
|
|
223
|
-
{ondrag}
|
|
224
|
-
{ondragover}
|
|
225
|
-
/>
|
|
226
|
-
|
|
227
|
-
{#if label && floatingLabel}
|
|
228
|
-
{@render labelSnippet()}
|
|
229
|
-
{/if}
|
|
230
|
-
</div>
|
|
231
|
-
|
|
232
|
-
<style>
|
|
233
|
-
</style>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<script lang="ts">let {
|
|
2
|
-
forName,
|
|
3
|
-
label = "",
|
|
4
|
-
className = "",
|
|
5
|
-
required = false,
|
|
6
|
-
requiredSymbolColor = "red",
|
|
7
|
-
requiredSymbol = "*",
|
|
8
|
-
hasRequiredSymbol = true,
|
|
9
|
-
children
|
|
10
|
-
} = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<label
|
|
14
|
-
for={forName || ''}
|
|
15
|
-
class="block text-sm text-gray-500 {hasRequiredSymbol && required ? 'required' : ''} {className}"
|
|
16
|
-
style="--requiredSymbolColor:{requiredSymbolColor}; --requiredSymbol: '{requiredSymbol}'; "
|
|
17
|
-
>
|
|
18
|
-
{#if children}
|
|
19
|
-
{@render children()}
|
|
20
|
-
{:else}
|
|
21
|
-
{label || ''}
|
|
22
|
-
{/if}
|
|
23
|
-
</label>
|
|
24
|
-
|
|
25
|
-
<style>
|
|
26
|
-
.required::after {
|
|
27
|
-
content: var(--requiredSymbol);
|
|
28
|
-
color: var(--requiredSymbolColor);
|
|
29
|
-
font-weight: bold;
|
|
30
|
-
margin-left: 4px;
|
|
31
|
-
}
|
|
32
|
-
</style>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import InputField, { type InputFieldAppearanceType, type InputFieldPropsType, type InputFieldSizeType, type InputFieldTypesType } from "./components/input-field/input-field.svelte";
|
|
2
|
-
import Label from "./components/label/label.svelte";
|
|
3
|
-
export { InputField, Label, type InputFieldAppearanceType, type InputFieldPropsType, type InputFieldSizeType, type InputFieldTypesType };
|
|
File without changes
|