@marianmeres/stuic 2.36.0 → 2.38.1
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,5 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
4
|
+
import { tooltip } from "../../actions/index.js";
|
|
5
|
+
import { isPlainObject } from "../../utils/is-plain-object.js";
|
|
6
|
+
import { replaceMap } from "../../utils/replace-map.js";
|
|
7
|
+
import type { TranslateFn } from "../../types.js";
|
|
3
8
|
|
|
4
9
|
export interface Props {
|
|
5
10
|
/** Content to display */
|
|
@@ -22,12 +27,28 @@
|
|
|
22
27
|
toggleOpacity?: string;
|
|
23
28
|
/** Bind reference to container element */
|
|
24
29
|
el?: HTMLDivElement;
|
|
30
|
+
/** Optional translate function */
|
|
31
|
+
t?: TranslateFn;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// i18n ready
|
|
35
|
+
function t_default(
|
|
36
|
+
k: string,
|
|
37
|
+
values: false | null | undefined | Record<string, string | number> = null,
|
|
38
|
+
fallback: string | boolean = "",
|
|
39
|
+
i18nSpanWrap: boolean = true
|
|
40
|
+
) {
|
|
41
|
+
const m: Record<string, string> = {
|
|
42
|
+
more: "Show more...",
|
|
43
|
+
less: "Show less...",
|
|
44
|
+
};
|
|
45
|
+
let out = m[k] ?? fallback ?? k;
|
|
46
|
+
|
|
47
|
+
return isPlainObject(values) ? replaceMap(out, values as any) : out;
|
|
25
48
|
}
|
|
26
49
|
</script>
|
|
27
50
|
|
|
28
51
|
<script lang="ts">
|
|
29
|
-
import { twMerge } from "../../utils/tw-merge.js";
|
|
30
|
-
|
|
31
52
|
let {
|
|
32
53
|
children,
|
|
33
54
|
lines = 1,
|
|
@@ -39,6 +60,7 @@
|
|
|
39
60
|
classToggle,
|
|
40
61
|
toggleOpacity = "opacity-75",
|
|
41
62
|
el = $bindable(),
|
|
63
|
+
t = t_default,
|
|
42
64
|
}: Props = $props();
|
|
43
65
|
|
|
44
66
|
let contentEl: HTMLDivElement | undefined;
|
|
@@ -81,6 +103,9 @@
|
|
|
81
103
|
classToggle
|
|
82
104
|
)}
|
|
83
105
|
onclick={() => (expanded = !expanded)}
|
|
106
|
+
use:tooltip={() => ({
|
|
107
|
+
content: expanded ? t("less") : t("more"),
|
|
108
|
+
})}
|
|
84
109
|
>
|
|
85
110
|
{expanded ? expandedIndicator : collapsedIndicator}
|
|
86
111
|
</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
|
+
import type { TranslateFn } from "../../types.js";
|
|
2
3
|
export interface Props {
|
|
3
4
|
/** Content to display */
|
|
4
5
|
children: Snippet;
|
|
@@ -20,6 +21,8 @@ export interface Props {
|
|
|
20
21
|
toggleOpacity?: string;
|
|
21
22
|
/** Bind reference to container element */
|
|
22
23
|
el?: HTMLDivElement;
|
|
24
|
+
/** Optional translate function */
|
|
25
|
+
t?: TranslateFn;
|
|
23
26
|
}
|
|
24
27
|
declare const Collapsible: import("svelte").Component<Props, {}, "el" | "expanded">;
|
|
25
28
|
type Collapsible = ReturnType<typeof Collapsible>;
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
import { getId } from "../../utils/get-id.js";
|
|
37
37
|
import { twMerge } from "../../utils/tw-merge.js";
|
|
38
38
|
import { Thc, isTHCNotEmpty } from "../Thc/index.js";
|
|
39
|
+
import { Collapsible } from "../Collapsible/index.js";
|
|
39
40
|
type THC = import("../Thc/index.js").THC;
|
|
40
41
|
|
|
41
42
|
let {
|
|
@@ -183,7 +184,18 @@
|
|
|
183
184
|
</div>
|
|
184
185
|
{/if}
|
|
185
186
|
{#if description}
|
|
186
|
-
<
|
|
187
|
+
<Collapsible
|
|
188
|
+
class={twMerge(
|
|
189
|
+
"desc-box",
|
|
190
|
+
_classCommon,
|
|
191
|
+
"text-sm opacity-50 cursor-pointer font-normal",
|
|
192
|
+
disabled && "cursor-not-allowed",
|
|
193
|
+
classDescBox
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
{@render snippetOrThc({ id, value: description })}
|
|
197
|
+
</Collapsible>
|
|
198
|
+
<!-- <div
|
|
187
199
|
id={idDesc}
|
|
188
200
|
class={twMerge(
|
|
189
201
|
"desc-box",
|
|
@@ -194,7 +206,7 @@
|
|
|
194
206
|
)}
|
|
195
207
|
>
|
|
196
208
|
{@render snippetOrThc({ id, value: description })}
|
|
197
|
-
</div>
|
|
209
|
+
</div> -->
|
|
198
210
|
{/if}
|
|
199
211
|
</div>
|
|
200
212
|
</label>
|