@cloudparker/moldex.js 0.0.27 → 0.0.29
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 +5 -3
- package/dist/views/core/button/components/button/button.svelte.d.ts +19 -18
- package/dist/views/core/button/components/button-back/button-back.svelte +32 -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 +5 -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 +33 -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 +28 -24
- 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 +19 -20
- 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 +5 -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 +94 -84
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +4 -3
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +145 -0
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte.d.ts +41 -0
- package/dist/views/core/icon/components/icon/icon.svelte +5 -3
- 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 +104 -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 +385 -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 +9 -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 +9 -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 +9 -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 +80 -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 +282 -0
- package/dist/views/core/input/components/input-field/input-field.svelte.d.ts +81 -0
- package/dist/views/core/{form → input}/components/label/label.svelte +1 -3
- package/dist/views/core/input/components/number-field/number-field.svelte +9 -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 +72 -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 +76 -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 +53 -0
- package/dist/views/core/{form/components/input-field/input-field.svelte.d.ts → input/components/range-field/range-field.svelte.d.ts} +16 -29
- package/dist/views/core/input/components/search-field/search-field.svelte +53 -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 +9 -0
- package/dist/views/core/{form → input}/components/text-field/text-field.svelte.d.ts +5 -12
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +9 -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 +9 -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 +11 -11
- 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 +34 -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/text/components/text-country/text-country.svelte +2 -1
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +1 -1
- package/dist/views/core/toast/components/toast/toast.svelte +1 -1
- package/package.json +2 -2
- package/dist/views/core/form/components/input-field/input-field.svelte +0 -85
- package/dist/views/core/form/components/text-field/text-field.svelte +0 -26
- package/dist/views/core/form/index.d.ts +0 -0
- package/dist/views/core/form/index.js +0 -1
- /package/dist/views/core/{form → input}/components/label/label.svelte.d.ts +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// MDI
|
|
2
2
|
export const mdiArrowLeft = "M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z";
|
|
3
|
+
export const mdiAttachment = "M7.5,18A5.5,5.5 0 0,1 2,12.5A5.5,5.5 0 0,1 7.5,7H18A4,4 0 0,1 22,11A4,4 0 0,1 18,15H9.5A2.5,2.5 0 0,1 7,12.5A2.5,2.5 0 0,1 9.5,10H17V11.5H9.5A1,1 0 0,0 8.5,12.5A1,1 0 0,0 9.5,13.5H18A2.5,2.5 0 0,0 20.5,11A2.5,2.5 0 0,0 18,8.5H7.5A4,4 0 0,0 3.5,12.5A4,4 0 0,0 7.5,16.5H17V18H7.5Z";
|
|
3
4
|
export const mdiBellOutline = 'M10 21H14C14 22.1 13.1 23 12 23S10 22.1 10 21M21 19V20H3V19L5 17V11C5 7.9 7 5.2 10 4.3V4C10 2.9 10.9 2 12 2S14 2.9 14 4V4.3C17 5.2 19 7.9 19 11V17L21 19M17 11C17 8.2 14.8 6 12 6S7 8.2 7 11V18H17V11Z';
|
|
4
5
|
export const mdiCheckCircle = "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z";
|
|
5
6
|
export const mdiCheckCircleOutline = "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z";
|
|
@@ -9,8 +10,13 @@ export const mdiChevronRight = "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L
|
|
|
9
10
|
export const mdiClose = "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
|
|
10
11
|
export const mdiContentCopy = "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z";
|
|
11
12
|
export const mdiEmailOutline = "M22 6C22 4.9 21.1 4 20 4H4C2.9 4 2 4.9 2 6V18C2 19.1 2.9 20 4 20H20C21.1 20 22 19.1 22 18V6M20 6L12 11L4 6H20M20 18H4V8L12 13L20 8V18Z";
|
|
13
|
+
export const mdiEyeOffOutline = "M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z";
|
|
14
|
+
export const mdiEyeOutline = "M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9M12,4.5C17,4.5 21.27,7.61 23,12C21.27,16.39 17,19.5 12,19.5C7,19.5 2.73,16.39 1,12C2.73,7.61 7,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C15.76,17.5 19.17,15.36 20.82,12C19.17,8.64 15.76,6.5 12,6.5C8.24,6.5 4.83,8.64 3.18,12Z";
|
|
12
15
|
export const mdiFlowerTulip = "M3,13A9,9 0 0,0 12,22A9,9 0 0,0 3,13M12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,22M18,3V8A6,6 0 0,1 12,14A6,6 0 0,1 6,8V3C6.74,3 7.47,3.12 8.16,3.39C8.71,3.62 9.2,3.96 9.61,4.39L12,2L14.39,4.39C14.8,3.96 15.29,3.62 15.84,3.39C16.53,3.12 17.26,3 18,3Z";
|
|
16
|
+
export const mdiMagnify = "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z";
|
|
13
17
|
export const mdiMenu = "M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z";
|
|
14
18
|
export const mdiPageFirst = "M18.41,16.59L13.82,12L18.41,7.41L17,6L11,12L17,18L18.41,16.59M6,6H8V18H6V6Z";
|
|
15
19
|
export const mdiPageLast = "M5.59,7.41L10.18,12L5.59,16.59L7,18L13,12L7,6L5.59,7.41M16,6H18V18H16V6Z";
|
|
16
20
|
export const mdiPhone = "M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z";
|
|
21
|
+
export const mdiSquare = "M3,3V21H21V3";
|
|
22
|
+
export const mdiUnfoldMoreHorizontal = "M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z";
|
package/dist/views/core/index.js
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script lang="ts">import { ripple } from "../../../../../actions";
|
|
2
|
+
import { colorToHex, isValidHexColor } from "../../../../../services";
|
|
3
|
+
import { mdiSquare } from "../../../icon";
|
|
4
|
+
import Icon from "../../../icon/components/icon/icon.svelte";
|
|
5
|
+
import InputField, {} from "../input-field/input-field.svelte";
|
|
6
|
+
let {
|
|
7
|
+
size,
|
|
8
|
+
appearance,
|
|
9
|
+
value = $bindable("#000000"),
|
|
10
|
+
...props
|
|
11
|
+
} = $props();
|
|
12
|
+
let colorRef;
|
|
13
|
+
let btnIconSizeClassName = $state("");
|
|
14
|
+
let btnRoundedClassName = $state("");
|
|
15
|
+
let colorValue = $state("#000000");
|
|
16
|
+
let inputFieldRef = $state(null);
|
|
17
|
+
export function focus() {
|
|
18
|
+
inputFieldRef?.focus();
|
|
19
|
+
}
|
|
20
|
+
function handleColorBtnClick() {
|
|
21
|
+
if (colorRef) {
|
|
22
|
+
colorRef.click();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function handleColorPickerChange(ev) {
|
|
26
|
+
let input = ev?.target;
|
|
27
|
+
if (input) {
|
|
28
|
+
value = input.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
$effect(() => {
|
|
32
|
+
if (isValidHexColor(value)) {
|
|
33
|
+
colorValue = value;
|
|
34
|
+
if (colorRef) {
|
|
35
|
+
colorRef.value = colorToHex(value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (size) {
|
|
41
|
+
switch (size) {
|
|
42
|
+
case "lg":
|
|
43
|
+
btnIconSizeClassName = "!h-7 !w-7";
|
|
44
|
+
break;
|
|
45
|
+
case "md":
|
|
46
|
+
btnIconSizeClassName = "!h-6 !w-6";
|
|
47
|
+
break;
|
|
48
|
+
case "sm":
|
|
49
|
+
btnIconSizeClassName = "!h-5 !w-5";
|
|
50
|
+
break;
|
|
51
|
+
case "xs":
|
|
52
|
+
btnIconSizeClassName = "!h-4 !w-4";
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (!appearance || appearance == "normal") {
|
|
59
|
+
btnRoundedClassName = "rounded-tr-lg rounded-br-lg";
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
{#snippet colorButton()}
|
|
65
|
+
<button
|
|
66
|
+
class="px-2 h-full hover:bg-gray-100 {btnRoundedClassName}"
|
|
67
|
+
use:ripple
|
|
68
|
+
onclick={handleColorBtnClick}
|
|
69
|
+
>
|
|
70
|
+
<Icon path={mdiSquare} color={colorValue} className=" {btnIconSizeClassName} " />
|
|
71
|
+
</button>
|
|
72
|
+
{/snippet}
|
|
73
|
+
|
|
74
|
+
<div class="relative">
|
|
75
|
+
<InputField
|
|
76
|
+
{...props}
|
|
77
|
+
type="text"
|
|
78
|
+
bind:value
|
|
79
|
+
bind:this={inputFieldRef}
|
|
80
|
+
className="pr-8 {props?.className}"
|
|
81
|
+
rightSnippet={colorButton}
|
|
82
|
+
maxlength={9}
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<input
|
|
86
|
+
class="color-input"
|
|
87
|
+
type="color"
|
|
88
|
+
placeholder=" "
|
|
89
|
+
bind:this={colorRef}
|
|
90
|
+
tabindex={-1}
|
|
91
|
+
oninput={handleColorPickerChange}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<style>
|
|
96
|
+
.color-input {
|
|
97
|
+
position: absolute;
|
|
98
|
+
opacity: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
right: 0;
|
|
102
|
+
height: 1px;
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.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 ColorField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType & {
|
|
16
|
+
value?: string;
|
|
17
|
+
}, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {
|
|
20
|
+
focus: () => void;
|
|
21
|
+
}, "value">;
|
|
22
|
+
type ColorField = InstanceType<typeof ColorField>;
|
|
23
|
+
export default ColorField;
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
<script lang="ts">import ButtonListItem from "../../../button/components/button-list-item/button-list-item.svelte";
|
|
2
|
+
import Button from "../../../button/components/button/button.svelte";
|
|
3
|
+
import { mdiUnfoldMoreHorizontal } from "../../../icon";
|
|
4
|
+
import Icon from "../../../icon/components/icon/icon.svelte";
|
|
5
|
+
import NoData from "../../../no-data/components/no-data/no-data.svelte";
|
|
6
|
+
import InputField, {} from "../input-field/input-field.svelte";
|
|
7
|
+
import SearchField from "../search-field/search-field.svelte";
|
|
8
|
+
let {
|
|
9
|
+
appearance,
|
|
10
|
+
chipClassName,
|
|
11
|
+
className,
|
|
12
|
+
comboboxIconClassName,
|
|
13
|
+
comboboxIconPath = mdiUnfoldMoreHorizontal,
|
|
14
|
+
contentSnippet,
|
|
15
|
+
createButtonClassName,
|
|
16
|
+
createButtonLabel = "Add",
|
|
17
|
+
displayClassName,
|
|
18
|
+
displayFieldName,
|
|
19
|
+
displayItemsCount,
|
|
20
|
+
dropdownBodyClassName,
|
|
21
|
+
dropdownBodySnippet,
|
|
22
|
+
dropdownClassName,
|
|
23
|
+
dropdownFooterClassName,
|
|
24
|
+
dropdownFooterSnippet,
|
|
25
|
+
dropdownHeaderClassName,
|
|
26
|
+
dropdownHeaderSnippet,
|
|
27
|
+
emptyMessage = "No items exists!",
|
|
28
|
+
emptyMessageSnippet,
|
|
29
|
+
hasComboboxIcon = true,
|
|
30
|
+
hasDropdownFooter,
|
|
31
|
+
hasDropdownFooterCreateButton,
|
|
32
|
+
hasDropdownHeader,
|
|
33
|
+
hasDropdownHeaderSearch,
|
|
34
|
+
hasItemsCheckbox,
|
|
35
|
+
hasPrimitiveData,
|
|
36
|
+
iconPathClassName,
|
|
37
|
+
iconPathFieldName,
|
|
38
|
+
id,
|
|
39
|
+
identityFieldName,
|
|
40
|
+
itemClassName,
|
|
41
|
+
items,
|
|
42
|
+
multiple,
|
|
43
|
+
name,
|
|
44
|
+
onCreateButtonClick,
|
|
45
|
+
onSearch,
|
|
46
|
+
searchClassName,
|
|
47
|
+
searchFieldName,
|
|
48
|
+
searchPlaceholder = "Search...",
|
|
49
|
+
showChip,
|
|
50
|
+
size,
|
|
51
|
+
itemSubtitleClassName,
|
|
52
|
+
itemSubtitleFieldName,
|
|
53
|
+
itemTitleClassName,
|
|
54
|
+
itemTitleFieldName,
|
|
55
|
+
value = $bindable(),
|
|
56
|
+
...props
|
|
57
|
+
} = $props();
|
|
58
|
+
let idFieldSymbol = Symbol("_id");
|
|
59
|
+
let searchFieldSymbol = Symbol("_search");
|
|
60
|
+
let searchFieldRef = $state(null);
|
|
61
|
+
let comboboxIconSizeClassName = $state("");
|
|
62
|
+
let isPlaced = $state(false);
|
|
63
|
+
let searchText = $state("");
|
|
64
|
+
let itemsIdentityMap = {};
|
|
65
|
+
let _value = $derived.by(() => {
|
|
66
|
+
return selectedItemsSet?.size ? " " : "";
|
|
67
|
+
});
|
|
68
|
+
let displayItems = $derived.by(() => {
|
|
69
|
+
let array = Array.from(selectedItemsSet);
|
|
70
|
+
let results = array.map((id2) => {
|
|
71
|
+
if (hasPrimitiveData) {
|
|
72
|
+
return [id2];
|
|
73
|
+
} else {
|
|
74
|
+
let item = itemsIdentityMap[id2];
|
|
75
|
+
if (item) {
|
|
76
|
+
if (displayFieldName && item.hasOwnProperty(displayFieldName)) {
|
|
77
|
+
return item[displayFieldName];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return results;
|
|
83
|
+
});
|
|
84
|
+
let displayItemsTitle = $derived(displayItems.join(", "));
|
|
85
|
+
let displayText = $derived.by(() => {
|
|
86
|
+
let results = displayItems;
|
|
87
|
+
if (!showChip) {
|
|
88
|
+
if (results?.length) {
|
|
89
|
+
if (multiple) {
|
|
90
|
+
let res = results.join(", ");
|
|
91
|
+
if (displayItemsCount != null && displayItemsCount > 1) {
|
|
92
|
+
res = results.slice(0, displayItemsCount).join(", ");
|
|
93
|
+
if (results.length > displayItemsCount) {
|
|
94
|
+
res += `<span class="text-gray-400 px-2">+ ${results.length - displayItemsCount} </span>`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return res;
|
|
98
|
+
} else {
|
|
99
|
+
return results[0] || "";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return "";
|
|
104
|
+
});
|
|
105
|
+
let selectedItemsSet = $derived.by(() => {
|
|
106
|
+
let set = /* @__PURE__ */ new Set();
|
|
107
|
+
if (value != null) {
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
value.forEach((v) => set.add(v));
|
|
110
|
+
} else if (value) {
|
|
111
|
+
set.add(value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return set;
|
|
115
|
+
});
|
|
116
|
+
let preparedItems = $derived.by(() => {
|
|
117
|
+
return (items || []).map((item, index) => {
|
|
118
|
+
let res = {};
|
|
119
|
+
if (hasPrimitiveData) {
|
|
120
|
+
res.title = item;
|
|
121
|
+
res[idFieldSymbol] = item;
|
|
122
|
+
res[searchFieldSymbol] = ("" + item).toLowerCase().trim();
|
|
123
|
+
} else {
|
|
124
|
+
if (identityFieldName && item.hasOwnProperty(identityFieldName)) {
|
|
125
|
+
res[idFieldSymbol] = item[identityFieldName];
|
|
126
|
+
} else {
|
|
127
|
+
res[idFieldSymbol] = index;
|
|
128
|
+
}
|
|
129
|
+
itemsIdentityMap[res[idFieldSymbol]] = item;
|
|
130
|
+
if (itemTitleFieldName && item.hasOwnProperty(itemTitleFieldName)) {
|
|
131
|
+
res.title = item[itemTitleFieldName];
|
|
132
|
+
}
|
|
133
|
+
if (itemSubtitleFieldName && item.hasOwnProperty(itemSubtitleFieldName)) {
|
|
134
|
+
res.subtitle = item[itemSubtitleFieldName];
|
|
135
|
+
}
|
|
136
|
+
if (searchFieldName) {
|
|
137
|
+
if (item.hasOwnProperty(searchFieldName)) {
|
|
138
|
+
res[searchFieldSymbol] = (item[searchFieldName] || "").toLowerCase().trim();
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
res[searchFieldSymbol] = `${item.title || ""} ${item.subtitle || ""}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (selectedItemsSet.has(res[idFieldSymbol])) {
|
|
145
|
+
res.isChecked = true;
|
|
146
|
+
} else {
|
|
147
|
+
res.isChecked = false;
|
|
148
|
+
}
|
|
149
|
+
return res;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
let filteredItems = $derived.by(() => {
|
|
153
|
+
if (searchText) {
|
|
154
|
+
return preparedItems.filter((item) => {
|
|
155
|
+
return item[searchFieldSymbol].indexOf(searchText) >= 0;
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
return [...preparedItems];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
$effect(() => {
|
|
162
|
+
if (size) {
|
|
163
|
+
switch (size) {
|
|
164
|
+
case "lg":
|
|
165
|
+
comboboxIconSizeClassName = "!h-7 !w-7";
|
|
166
|
+
break;
|
|
167
|
+
case "md":
|
|
168
|
+
comboboxIconSizeClassName = "!h-6 !w-6";
|
|
169
|
+
break;
|
|
170
|
+
case "sm":
|
|
171
|
+
comboboxIconSizeClassName = "!h-5 !w-5";
|
|
172
|
+
break;
|
|
173
|
+
case "xs":
|
|
174
|
+
comboboxIconSizeClassName = "!h-4 !w-4";
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
let inputFieldRef = $state(null);
|
|
180
|
+
export function focus() {
|
|
181
|
+
inputFieldRef?.focus();
|
|
182
|
+
}
|
|
183
|
+
function toggleDropdown() {
|
|
184
|
+
if (isPlaced) {
|
|
185
|
+
closeDropdown();
|
|
186
|
+
} else {
|
|
187
|
+
openDropdown();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function closeDropdown() {
|
|
191
|
+
searchText = "";
|
|
192
|
+
isPlaced = false;
|
|
193
|
+
focus();
|
|
194
|
+
}
|
|
195
|
+
function openDropdown() {
|
|
196
|
+
isPlaced = true;
|
|
197
|
+
}
|
|
198
|
+
function handleInputClick() {
|
|
199
|
+
toggleDropdown();
|
|
200
|
+
}
|
|
201
|
+
function handleBackdropClick() {
|
|
202
|
+
toggleDropdown();
|
|
203
|
+
}
|
|
204
|
+
function handleKeyDown(event) {
|
|
205
|
+
if (event.key === "Escape") {
|
|
206
|
+
closeDropdown();
|
|
207
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
toggleDropdown();
|
|
210
|
+
} else if (/^[a-zA-Z0-9]$/.test(event.key)) {
|
|
211
|
+
searchFieldRef && searchFieldRef.focus();
|
|
212
|
+
} else if (event.key === "Backspace" || event.key === "Delete") {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
selectedItemsSet.clear();
|
|
215
|
+
value = null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function handleDropdownKeyDown(event) {
|
|
219
|
+
if (event.key === "Escape") {
|
|
220
|
+
closeDropdown();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function handleSearch(value2) {
|
|
224
|
+
searchText = value2;
|
|
225
|
+
}
|
|
226
|
+
function handleItemSelected(ev, item, index) {
|
|
227
|
+
let id2 = item[idFieldSymbol];
|
|
228
|
+
if (multiple) {
|
|
229
|
+
if (selectedItemsSet.has(id2)) {
|
|
230
|
+
selectedItemsSet.delete(id2);
|
|
231
|
+
} else {
|
|
232
|
+
selectedItemsSet.add(id2);
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
selectedItemsSet.clear();
|
|
236
|
+
selectedItemsSet.add(id2);
|
|
237
|
+
}
|
|
238
|
+
items = [...items || []];
|
|
239
|
+
let array = Array.from(selectedItemsSet);
|
|
240
|
+
if (array.length) {
|
|
241
|
+
value = multiple ? array : array[0];
|
|
242
|
+
} else {
|
|
243
|
+
value = null;
|
|
244
|
+
}
|
|
245
|
+
if (!multiple) {
|
|
246
|
+
closeDropdown();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
{#snippet rightIcon()}
|
|
252
|
+
<div class="px-1">
|
|
253
|
+
{#if hasComboboxIcon}
|
|
254
|
+
<Icon
|
|
255
|
+
path={comboboxIconPath}
|
|
256
|
+
className=" text-gray-500 {comboboxIconSizeClassName} {comboboxIconClassName}"
|
|
257
|
+
/>
|
|
258
|
+
{/if}
|
|
259
|
+
</div>
|
|
260
|
+
{/snippet}
|
|
261
|
+
|
|
262
|
+
{#snippet comboboxContentSnippet()}
|
|
263
|
+
{#if contentSnippet}
|
|
264
|
+
{@render contentSnippet()}
|
|
265
|
+
{:else if showChip}
|
|
266
|
+
<div class="flex items-center {displayClassName}" title={displayItemsTitle}>
|
|
267
|
+
{#each displayItems?.slice(0, displayItemsCount) as item, index}
|
|
268
|
+
<div
|
|
269
|
+
class="inline-flex items-center bg-gray-200 text-gray-700 text-sm font-medium px-2 mx-1 rounded-full text-nowrap {chipClassName}"
|
|
270
|
+
>
|
|
271
|
+
{item}
|
|
272
|
+
</div>
|
|
273
|
+
{/each}
|
|
274
|
+
{#if displayItemsCount && displayItems?.length > (displayItemsCount || 1)}
|
|
275
|
+
<div class="px-2 text-gray-400">+ {displayItems?.length - (displayItemsCount || 1)}</div>
|
|
276
|
+
{/if}
|
|
277
|
+
</div>
|
|
278
|
+
{:else}
|
|
279
|
+
<div class="flex items-center {displayClassName}" title={displayItemsTitle}>
|
|
280
|
+
{@html displayText}
|
|
281
|
+
</div>
|
|
282
|
+
{/if}
|
|
283
|
+
{/snippet}
|
|
284
|
+
|
|
285
|
+
<div class="relative">
|
|
286
|
+
<InputField
|
|
287
|
+
bind:this={inputFieldRef}
|
|
288
|
+
{...props}
|
|
289
|
+
value={_value}
|
|
290
|
+
type="text"
|
|
291
|
+
role="combobox"
|
|
292
|
+
onclick={handleInputClick}
|
|
293
|
+
className="pr-8 text-transparent {className}"
|
|
294
|
+
rightSnippet={rightIcon}
|
|
295
|
+
rightSnippetContainerClassName="pointer-events-none"
|
|
296
|
+
readonly
|
|
297
|
+
{id}
|
|
298
|
+
{name}
|
|
299
|
+
{size}
|
|
300
|
+
{appearance}
|
|
301
|
+
ariaControls="options"
|
|
302
|
+
ariaExpanded={isPlaced}
|
|
303
|
+
onkeydown={handleKeyDown}
|
|
304
|
+
contentSnippet={comboboxContentSnippet}
|
|
305
|
+
title={displayItemsTitle || ''}
|
|
306
|
+
/>
|
|
307
|
+
{#if isPlaced}
|
|
308
|
+
<button id="backdrop" class="fixed inset-0 z-10" onclick={handleBackdropClick} tabindex="-1"
|
|
309
|
+
></button>
|
|
310
|
+
<!-- svelte-ignore a11y_interactive_supports_focus -->
|
|
311
|
+
<div
|
|
312
|
+
class="absolute z-10 mt-1 max-h-80 w-full flex flex-col rounded-md bg-white text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm {hasDropdownHeader
|
|
313
|
+
? ''
|
|
314
|
+
: 'pt-1'} {hasDropdownFooter ? '' : 'pb-1'} {dropdownClassName}"
|
|
315
|
+
id="options"
|
|
316
|
+
role="listbox"
|
|
317
|
+
onkeydown={handleDropdownKeyDown}
|
|
318
|
+
>
|
|
319
|
+
{#if hasDropdownHeader}
|
|
320
|
+
<div
|
|
321
|
+
id="dropdown-header"
|
|
322
|
+
class=" flex items-center p-2 px-3 my-1 w-full {dropdownHeaderClassName}"
|
|
323
|
+
>
|
|
324
|
+
{#if dropdownHeaderSnippet}
|
|
325
|
+
{@render dropdownHeaderSnippet()}
|
|
326
|
+
{:else if hasDropdownHeaderSearch}
|
|
327
|
+
<SearchField
|
|
328
|
+
bind:this={searchFieldRef}
|
|
329
|
+
value={searchText}
|
|
330
|
+
name="search"
|
|
331
|
+
placeholder={searchPlaceholder}
|
|
332
|
+
className="w-full {searchClassName}"
|
|
333
|
+
onSearch={handleSearch}
|
|
334
|
+
/>
|
|
335
|
+
{/if}
|
|
336
|
+
</div>
|
|
337
|
+
{/if}
|
|
338
|
+
<div id="dropdown-body" class="flex-grow overflow-y-auto max-h-full {dropdownBodyClassName}">
|
|
339
|
+
{#if dropdownBodySnippet}
|
|
340
|
+
{@render dropdownBodySnippet()}
|
|
341
|
+
{:else if filteredItems?.length}
|
|
342
|
+
<ul>
|
|
343
|
+
{#each filteredItems as item, index}
|
|
344
|
+
<li
|
|
345
|
+
class="select-none"
|
|
346
|
+
id="item-{index}"
|
|
347
|
+
role="option"
|
|
348
|
+
tabindex="-1"
|
|
349
|
+
aria-selected={item.isChecked}
|
|
350
|
+
>
|
|
351
|
+
<ButtonListItem
|
|
352
|
+
{item}
|
|
353
|
+
{index}
|
|
354
|
+
hasCheckbox={hasItemsCheckbox}
|
|
355
|
+
className=" {itemClassName}"
|
|
356
|
+
titleClassName=" {itemTitleClassName}"
|
|
357
|
+
subtitleClassName=" {itemSubtitleClassName}"
|
|
358
|
+
onClick={(ev) => handleItemSelected(ev, item, index)}
|
|
359
|
+
/>
|
|
360
|
+
</li>
|
|
361
|
+
{/each}
|
|
362
|
+
</ul>
|
|
363
|
+
{:else if emptyMessageSnippet}
|
|
364
|
+
{@render emptyMessageSnippet()}
|
|
365
|
+
{:else}
|
|
366
|
+
<NoData message={emptyMessage} />
|
|
367
|
+
{/if}
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
{#if hasDropdownFooter}
|
|
371
|
+
<div id="dropdown-footer" class="flex justify-end gap-3 p-2 px-3 {dropdownFooterClassName}">
|
|
372
|
+
{#if dropdownFooterSnippet}
|
|
373
|
+
{@render dropdownFooterSnippet()}
|
|
374
|
+
{:else if hasDropdownFooterCreateButton}
|
|
375
|
+
<Button
|
|
376
|
+
label={createButtonLabel}
|
|
377
|
+
className="px-3 py-1 {createButtonClassName}"
|
|
378
|
+
onClick={onCreateButtonClick}
|
|
379
|
+
></Button>
|
|
380
|
+
{/if}
|
|
381
|
+
</div>
|
|
382
|
+
{/if}
|
|
383
|
+
</div>
|
|
384
|
+
{/if}
|
|
385
|
+
</div>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
+
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> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const ComboboxField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType & {
|
|
17
|
+
chipClassName?: string;
|
|
18
|
+
comboboxIconClassName?: string;
|
|
19
|
+
comboboxIconPath?: string;
|
|
20
|
+
createButtonClassName?: string;
|
|
21
|
+
createButtonLabel?: string;
|
|
22
|
+
displayClassName?: string;
|
|
23
|
+
displayFieldName?: string;
|
|
24
|
+
displayItemsCount?: number;
|
|
25
|
+
dropdownBodyClassName?: string;
|
|
26
|
+
dropdownBodySnippet?: Snippet;
|
|
27
|
+
dropdownClassName?: string;
|
|
28
|
+
dropdownFooterClassName?: string;
|
|
29
|
+
dropdownFooterSnippet?: Snippet;
|
|
30
|
+
dropdownHeaderClassName?: string;
|
|
31
|
+
dropdownHeaderSnippet?: Snippet;
|
|
32
|
+
emptyMessage?: string;
|
|
33
|
+
emptyMessageSnippet?: Snippet;
|
|
34
|
+
hasComboboxIcon?: boolean;
|
|
35
|
+
hasDropdownFooter?: boolean;
|
|
36
|
+
hasDropdownFooterCreateButton?: boolean;
|
|
37
|
+
hasDropdownHeader?: boolean;
|
|
38
|
+
hasDropdownHeaderSearch?: boolean;
|
|
39
|
+
hasItemsCheckbox?: boolean;
|
|
40
|
+
hasPrimitiveData?: boolean;
|
|
41
|
+
iconPathClassName?: string;
|
|
42
|
+
iconPathFieldName?: string;
|
|
43
|
+
identityFieldName?: string;
|
|
44
|
+
itemClassName?: string;
|
|
45
|
+
items?: any[];
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
onCreateButtonClick?: (ev: MouseEvent) => void;
|
|
48
|
+
onSearch?: (value: string) => void;
|
|
49
|
+
searchClassName?: string;
|
|
50
|
+
searchFieldName?: string;
|
|
51
|
+
searchPlaceholder?: string;
|
|
52
|
+
showChip?: boolean;
|
|
53
|
+
itemSubtitleClassName?: string;
|
|
54
|
+
itemSubtitleFieldName?: string;
|
|
55
|
+
itemTitleClassName?: string;
|
|
56
|
+
itemTitleFieldName?: string;
|
|
57
|
+
}, {
|
|
58
|
+
[evt: string]: CustomEvent<any>;
|
|
59
|
+
}, {}, {
|
|
60
|
+
focus: () => void;
|
|
61
|
+
}, "value">;
|
|
62
|
+
type ComboboxField = InstanceType<typeof ComboboxField>;
|
|
63
|
+
export default ComboboxField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import InputField, {} from "../input-field/input-field.svelte";
|
|
2
|
+
let props = $props();
|
|
3
|
+
let inputFieldRef = $state(null);
|
|
4
|
+
export function focus() {
|
|
5
|
+
inputFieldRef?.focus();
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<InputField bind:this={inputFieldRef} {...props} type="date" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.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 DateField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type DateField = InstanceType<typeof DateField>;
|
|
21
|
+
export default DateField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import InputField, {} from "../input-field/input-field.svelte";
|
|
2
|
+
let props = $props();
|
|
3
|
+
let inputFieldRef = $state(null);
|
|
4
|
+
export function focus() {
|
|
5
|
+
inputFieldRef?.focus();
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<InputField bind:this={inputFieldRef} {...props} type="datetime-local" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.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 DatetimeField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type DatetimeField = InstanceType<typeof DatetimeField>;
|
|
21
|
+
export default DatetimeField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import InputField, {} from "../input-field/input-field.svelte";
|
|
2
|
+
let props = $props();
|
|
3
|
+
let inputFieldRef = $state(null);
|
|
4
|
+
export function focus() {
|
|
5
|
+
inputFieldRef?.focus();
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<InputField bind:this={inputFieldRef} {...props} type="email" maxlength={props?.maxlength || 80} />
|