@marianmeres/stuic 1.87.0 → 1.89.0
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
<script context="module">import {
|
|
1
|
+
<script context="module">import { createClog } from "@marianmeres/clog";
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
2
3
|
import { slide } from "svelte/transition";
|
|
3
4
|
import { twMerge } from "tailwind-merge";
|
|
4
5
|
import {
|
|
5
|
-
getId,
|
|
6
6
|
Thc,
|
|
7
|
+
getId,
|
|
7
8
|
validate as validateAction
|
|
8
9
|
} from "../../index.js";
|
|
9
10
|
const _emptyClasses = () => ({
|
|
@@ -72,7 +73,8 @@ export class FieldSelectConfig {
|
|
|
72
73
|
}
|
|
73
74
|
</script>
|
|
74
75
|
|
|
75
|
-
<script>const
|
|
76
|
+
<script>const clog = createClog("FieldSelect");
|
|
77
|
+
const dispatch = createEventDispatcher();
|
|
76
78
|
export let options = [];
|
|
77
79
|
let _class = {};
|
|
78
80
|
export { _class as class };
|
|
@@ -93,17 +95,24 @@ export let labelLeft = FieldSelectConfig.labelLeft;
|
|
|
93
95
|
export let labelLeftWidth = FieldSelectConfig.labelLeftWidth;
|
|
94
96
|
let validation;
|
|
95
97
|
const setValidationResult = (res) => validation = res;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (typeof v === "string")
|
|
98
|
+
const _normalizeAndGroupOptions = (opts) => {
|
|
99
|
+
const groupped = /* @__PURE__ */ new Map();
|
|
100
|
+
opts.forEach((v) => {
|
|
101
|
+
if (typeof v === "string")
|
|
100
102
|
v = { label: v };
|
|
101
|
-
|
|
102
|
-
if (v.value === void 0) {
|
|
103
|
+
if (v.value === void 0)
|
|
103
104
|
v.value = v.label;
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
const optgLabel = v.optgroup || "";
|
|
106
|
+
if (!groupped.has(optgLabel))
|
|
107
|
+
groupped.set(optgLabel, []);
|
|
108
|
+
const optgroup = groupped.get(optgLabel);
|
|
109
|
+
optgroup.push(v);
|
|
106
110
|
});
|
|
111
|
+
return groupped;
|
|
112
|
+
};
|
|
113
|
+
let _options;
|
|
114
|
+
$:
|
|
115
|
+
_options = _normalizeAndGroupOptions(options);
|
|
107
116
|
let _inputEl;
|
|
108
117
|
$:
|
|
109
118
|
if (_inputEl)
|
|
@@ -202,8 +211,18 @@ $:
|
|
|
202
211
|
on:mouseenter
|
|
203
212
|
on:mouseleave
|
|
204
213
|
>
|
|
205
|
-
{#each _options as
|
|
206
|
-
|
|
214
|
+
{#each _options as [_optgroup, _opts]}
|
|
215
|
+
{#if _optgroup}
|
|
216
|
+
<optgroup label={_optgroup}>
|
|
217
|
+
{#each _opts as o}
|
|
218
|
+
<option value={o.value}>{o.label}</option>
|
|
219
|
+
{/each}
|
|
220
|
+
</optgroup>
|
|
221
|
+
{:else}
|
|
222
|
+
{#each _opts as o}
|
|
223
|
+
<option value={o.value}>{o.label}</option>
|
|
224
|
+
{/each}
|
|
225
|
+
{/if}
|
|
207
226
|
{/each}
|
|
208
227
|
</select>
|
|
209
228
|
|
|
@@ -29,6 +29,7 @@ declare const __propDef: {
|
|
|
29
29
|
options?: (string | {
|
|
30
30
|
label: string;
|
|
31
31
|
value?: string | undefined;
|
|
32
|
+
optgroup?: string | undefined;
|
|
32
33
|
})[] | undefined;
|
|
33
34
|
class?: FieldSelectConfigClasses | undefined;
|
|
34
35
|
classBySize?: FieldSelectConfigClassesBySize | undefined;
|
|
@@ -7,7 +7,7 @@ import { notificationsDefaultIcons } from "./notifications-icons.js";
|
|
|
7
7
|
const X_POSITIONS = ["left", "center", "right"];
|
|
8
8
|
const Y_POSITIONS = ["top", "center", "bottom"];
|
|
9
9
|
const DEFAULT = {
|
|
10
|
-
posX: "
|
|
10
|
+
posX: "right",
|
|
11
11
|
posXMobile: "center",
|
|
12
12
|
posY: "top",
|
|
13
13
|
posYMobile: "bottom"
|
|
@@ -28,7 +28,7 @@ export class NotificationsConfig {
|
|
|
28
28
|
box: `
|
|
29
29
|
relative flex
|
|
30
30
|
pointer-events-auto
|
|
31
|
-
w-full max-w-
|
|
31
|
+
w-full max-w-sm
|
|
32
32
|
rounded-md
|
|
33
33
|
shadow-lg
|
|
34
34
|
bg-gray-700 text-white
|