@streamscloud/kit 1.0.3 → 1.0.4
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/core/actions/index.d.ts +1 -0
- package/dist/core/actions/index.js +1 -0
- package/dist/core/actions/stop-click-propagation.d.ts +3 -0
- package/dist/core/actions/stop-click-propagation.js +17 -0
- package/dist/core/continuation-token.js +1 -8
- package/dist/core/event-dispatcher.d.ts +1 -3
- package/dist/core/event-dispatcher.js +20 -12
- package/dist/core/files/file-service.js +3 -1
- package/dist/core/files/file-validator.js +1 -1
- package/dist/core/files/files-provider.js +2 -1
- package/dist/core/locale/app-locale.svelte.d.ts +2 -1
- package/dist/core/locale/app-locale.svelte.js +2 -1
- package/dist/core/repository/repository.svelte.js +4 -1
- package/dist/core/theme/app-theme.svelte.d.ts +2 -0
- package/dist/core/theme/app-theme.svelte.js +2 -0
- package/dist/core/utils/after-mount.svelte.d.ts +13 -0
- package/dist/core/utils/after-mount.svelte.js +21 -0
- package/dist/core/utils/array-helper.js +4 -3
- package/dist/core/utils/compact-number.js +1 -0
- package/dist/core/utils/date-helper.js +10 -35
- package/dist/core/utils/href-validator.js +4 -2
- package/dist/core/utils/html-helper.d.ts +2 -0
- package/dist/core/utils/html-helper.js +6 -1
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/index.js +1 -0
- package/dist/core/utils/string-helper.js +2 -2
- package/dist/core/utils/utils.d.ts +4 -2
- package/dist/core/utils/utils.js +4 -6
- package/dist/core/validation/form-validation-handler/yup-form-validator.d.ts +1 -1
- package/dist/core/validation/form-validation-handler/yup-form-validator.js +10 -5
- package/dist/core/validation/validation-schemas/email-validation.js +10 -10
- package/dist/ui/checkbox/cmp.checkbox.svelte +5 -4
- package/dist/ui/date-picker/cmp.date-picker.svelte +13 -2
- package/dist/ui/date-picker/cmp.date-picker.svelte.d.ts +1 -1
- package/dist/ui/dialog/cmp.dialog-container.svelte +2 -8
- package/dist/ui/dialog/dialog-store.svelte.js +1 -0
- package/dist/ui/drawer/cmp.drawer.svelte +3 -1
- package/dist/ui/drawer/cmp.drawer.svelte.d.ts +3 -1
- package/dist/ui/duration/cmp.duration.svelte +7 -3
- package/dist/ui/duration/cmp.duration.svelte.d.ts +3 -3
- package/dist/ui/empty-state/cmp.empty-state.svelte +5 -5
- package/dist/ui/grid-card/cmp.grid-card-media.svelte +1 -1
- package/dist/ui/grid-card/cmp.grid-card-media.svelte.d.ts +4 -1
- package/dist/ui/icon/cmp.icon.svelte +6 -10
- package/dist/ui/image/cmp.image.svelte +4 -3
- package/dist/ui/infinite-scroll/cmp.infinite-scroll.svelte +2 -2
- package/dist/ui/numeral-input/cmp.numeral-input.svelte +3 -0
- package/dist/ui/numeral-input/cmp.numeral-input.svelte.d.ts +1 -0
- package/dist/ui/pagination/pagination-state.svelte.d.ts +1 -0
- package/dist/ui/pagination/pagination-state.svelte.js +1 -0
- package/dist/ui/pin-input/cmp.pin-input.svelte +44 -26
- package/dist/ui/pin-input/cmp.pin-input.svelte.d.ts +3 -2
- package/dist/ui/player/carousel/cmp.carousel.svelte +8 -9
- package/dist/ui/player/carousel/cmp.carousel.svelte.d.ts +1 -1
- package/dist/ui/radio/cmp.radio.svelte +9 -4
- package/dist/ui/rich-text-input/validated-link-button.js +1 -1
- package/dist/ui/select/cmp.singleselect-async.svelte +2 -1
- package/dist/ui/select/multiselect-base.svelte +2 -1
- package/dist/ui/select/select-core.svelte.d.ts +2 -0
- package/dist/ui/select/select-core.svelte.js +18 -17
- package/dist/ui/slider/cmp.slider.svelte +28 -37
- package/dist/ui/slider/cmp.slider.svelte.d.ts +1 -0
- package/dist/ui/table/table-cells/table-text-cell.svelte +5 -3
- package/dist/ui/time-ago/cmp.time-ago.svelte +10 -1
- package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +1 -1
- package/dist/ui/toggle/cmp.toggle.svelte +4 -2
- package/dist/ui/video/cmp.video.svelte +6 -5
- package/package.json +1 -1
|
@@ -32,5 +32,7 @@ $effect(() => () => untrack(() => closeDrawer()));
|
|
|
32
32
|
Drawer — declarative side sheet. A thin wrapper over the imperative `openDrawer` that bridges a
|
|
33
33
|
controlled `open` prop to the kit Dialog engine: when `open` is `true` it opens the drawer (rendering
|
|
34
34
|
the default slot as the body and the `footer` snippet as the footer), and closes it otherwise. Singleton —
|
|
35
|
-
only one drawer shows at a time
|
|
35
|
+
only one drawer shows at a time, and any `Drawer` that mounts with `open={false}`, turns `false` or unmounts
|
|
36
|
+
closes whichever drawer is open, so keep one `Drawer` per screen. Wire `on.close` to set `open` back to
|
|
37
|
+
`false` when the user dismisses it.
|
|
36
38
|
-->
|
|
@@ -22,7 +22,9 @@ type Props = {
|
|
|
22
22
|
* Drawer — declarative side sheet. A thin wrapper over the imperative `openDrawer` that bridges a
|
|
23
23
|
* controlled `open` prop to the kit Dialog engine: when `open` is `true` it opens the drawer (rendering
|
|
24
24
|
* the default slot as the body and the `footer` snippet as the footer), and closes it otherwise. Singleton —
|
|
25
|
-
* only one drawer shows at a time
|
|
25
|
+
* only one drawer shows at a time, and any `Drawer` that mounts with `open={false}`, turns `false` or unmounts
|
|
26
|
+
* closes whichever drawer is open, so keep one `Drawer` per screen. Wire `on.close` to set `open` back to
|
|
27
|
+
* `false` when the user dismisses it.
|
|
26
28
|
*/
|
|
27
29
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
28
30
|
type Cmp = ReturnType<typeof Cmp>;
|
|
@@ -7,7 +7,11 @@ const format = (secs) => {
|
|
|
7
7
|
const ss = (total % 60).toString().padStart(2, '0');
|
|
8
8
|
return hours > 0 ? `${hours}:${minutes.toString().padStart(2, '0')}:${ss}` : `${minutes}:${ss}`;
|
|
9
9
|
};
|
|
10
|
-
const value = $derived(seconds !== null &&
|
|
10
|
+
const value = $derived(seconds !== null && Number.isFinite(seconds) && seconds > 0
|
|
11
|
+
? format(seconds)
|
|
12
|
+
: showZero
|
|
13
|
+
? format(0)
|
|
14
|
+
: null);
|
|
11
15
|
</script>
|
|
12
16
|
|
|
13
17
|
{#if value !== null}
|
|
@@ -17,8 +21,8 @@ const value = $derived(seconds !== null && seconds > 0 ? format(seconds) : showZ
|
|
|
17
21
|
<!--
|
|
18
22
|
@component
|
|
19
23
|
Renders a media/time duration given in seconds as a human-readable clock string — `m:ss` under an
|
|
20
|
-
hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null
|
|
21
|
-
renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
|
|
24
|
+
hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null`, ≤ 0 or
|
|
25
|
+
non-finite renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
|
|
22
26
|
inherits the parent's typography; `variant='badge'` is a dark overlay pill for the bottom corner of
|
|
23
27
|
a video thumbnail. Placement (e.g. absolute over media) is the consumer's job via the cascade.
|
|
24
28
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Props = {
|
|
2
|
-
/** Duration in seconds. Zero, negative, or `null` renders nothing unless `showZero`. */
|
|
2
|
+
/** Duration in seconds. Zero, negative, non-finite or `null` renders nothing unless `showZero`. */
|
|
3
3
|
seconds: number | null;
|
|
4
4
|
/** Visual style — `raw` is bare text; `badge` is a dark overlay pill for media thumbnails. @default 'raw' */
|
|
5
5
|
variant?: 'raw' | 'badge';
|
|
@@ -8,8 +8,8 @@ type Props = {
|
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* Renders a media/time duration given in seconds as a human-readable clock string — `m:ss` under an
|
|
11
|
-
* hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null
|
|
12
|
-
* renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
|
|
11
|
+
* hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null`, ≤ 0 or
|
|
12
|
+
* non-finite renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
|
|
13
13
|
* inherits the parent's typography; `variant='badge'` is a dark overlay pill for the bottom corner of
|
|
14
14
|
* a video thumbnail. Placement (e.g. absolute over media) is the consumer's job via the cascade.
|
|
15
15
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">import { HtmlHelper } from '../../core/utils';
|
|
1
|
+
<script lang="ts">import { AfterMount, HtmlHelper } from '../../core/utils';
|
|
2
2
|
import DefaultGraphic from './zero-content.svg?raw';
|
|
3
3
|
const GRAPHIC_PRESETS = {
|
|
4
4
|
'zero-content': DefaultGraphic
|
|
@@ -6,8 +6,8 @@ const GRAPHIC_PRESETS = {
|
|
|
6
6
|
let { graphic, title, description, action, layout = 'default' } = $props();
|
|
7
7
|
const graphicPreset = $derived(typeof graphic === 'string' ? graphic : null);
|
|
8
8
|
const graphicSnippet = $derived(typeof graphic === 'function' ? graphic : null);
|
|
9
|
-
const sanitizedTitle =
|
|
10
|
-
const sanitizedDescription =
|
|
9
|
+
const sanitizedTitle = new AfterMount(() => (title ? HtmlHelper.sanitizeHtml(title) : ''), '');
|
|
10
|
+
const sanitizedDescription = new AfterMount(() => (description ? HtmlHelper.sanitizeHtml(description) : ''), '');
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<div class="empty-state empty-state--{layout}">
|
|
@@ -20,10 +20,10 @@ const sanitizedDescription = $derived(description ? HtmlHelper.sanitizeHtml(desc
|
|
|
20
20
|
</div>
|
|
21
21
|
{/if}
|
|
22
22
|
{#if title}
|
|
23
|
-
<h3 class="empty-state__title">{@html sanitizedTitle}</h3>
|
|
23
|
+
<h3 class="empty-state__title">{@html sanitizedTitle.current}</h3>
|
|
24
24
|
{/if}
|
|
25
25
|
{#if description}
|
|
26
|
-
<p class="empty-state__description">{@html sanitizedDescription}</p>
|
|
26
|
+
<p class="empty-state__description">{@html sanitizedDescription.current}</p>
|
|
27
27
|
{/if}
|
|
28
28
|
{#if action}
|
|
29
29
|
<div class="empty-state__action">{@render action()}</div>
|
|
@@ -13,7 +13,10 @@ type Props = {
|
|
|
13
13
|
objectFit?: ObjectFit;
|
|
14
14
|
/** @default true */
|
|
15
15
|
showSeekBar?: boolean;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Duration in seconds; rendered as a badge overlay at the bottom-right of the media. `≤ 0` / `undefined` renders nothing.
|
|
18
|
+
* Hidden while the current item is playable — its player shows a live countdown there.
|
|
19
|
+
*/
|
|
17
20
|
duration?: number;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
<script lang="ts">import {
|
|
2
|
-
import {
|
|
1
|
+
<script lang="ts">import { AfterMount } from '../../core/utils/after-mount.svelte';
|
|
2
|
+
import { HtmlHelper } from '../../core/utils/html-helper';
|
|
3
3
|
let { src, color = null, size } = $props();
|
|
4
|
-
|
|
5
|
-
onMount(() => {
|
|
6
|
-
mounted = true;
|
|
7
|
-
});
|
|
8
|
-
const sanitizedSvg = $derived(mounted ? HtmlHelper.sanitizeSvg(src) : null);
|
|
4
|
+
const sanitizedSvg = new AfterMount(() => HtmlHelper.sanitizeSvg(src), '');
|
|
9
5
|
</script>
|
|
10
6
|
|
|
11
|
-
{#if
|
|
7
|
+
{#if sanitizedSvg.current === null}
|
|
12
8
|
<i class="invalid-svg">Invalid SVG</i>
|
|
13
9
|
{:else}
|
|
14
10
|
<div
|
|
@@ -22,8 +18,8 @@ const sanitizedSvg = $derived(mounted ? HtmlHelper.sanitizeSvg(src) : null);
|
|
|
22
18
|
class:icon--control-md={size === 'control-md'}
|
|
23
19
|
class:icon--control-lg={size === 'control-lg'}
|
|
24
20
|
class:icon--control-xl={size === 'control-xl'}>
|
|
25
|
-
{#if sanitizedSvg}
|
|
26
|
-
{@html sanitizedSvg}
|
|
21
|
+
{#if sanitizedSvg.current}
|
|
22
|
+
{@html sanitizedSvg.current}
|
|
27
23
|
{/if}
|
|
28
24
|
</div>
|
|
29
25
|
{/if}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
import { calculateImageState } from './image-state';
|
|
3
3
|
import IconImageOff from '@fluentui/svg-icons/icons/image_off_20_regular.svg?raw';
|
|
4
4
|
let { src, alt = '', showStubOnError = false, on, stub } = $props();
|
|
5
|
-
let
|
|
5
|
+
let failedSrc = $state(null);
|
|
6
|
+
const hasError = $derived(!!src && failedSrc === src);
|
|
6
7
|
const imageState = $derived(calculateImageState(src, hasError, showStubOnError));
|
|
7
8
|
// A 0.01x density makes the intrinsic size 100× the natural one, so `contain` sizing always scales the picture
|
|
8
9
|
// down to fit — small pictures upscale too — and the box hugs the picture, rounding its own corners.
|
|
9
10
|
// `src` must stay unset: it would join srcset as the 1x candidate and win.
|
|
10
11
|
const srcset = $derived(src ? `${src.replace(/\s/g, (char) => encodeURIComponent(char))} 0.01x` : undefined);
|
|
11
12
|
const onLoad = () => {
|
|
12
|
-
|
|
13
|
+
failedSrc = null;
|
|
13
14
|
on?.load?.(true);
|
|
14
15
|
};
|
|
15
16
|
const onLoadError = () => {
|
|
16
|
-
|
|
17
|
+
failedSrc = src;
|
|
17
18
|
on?.load?.(false);
|
|
18
19
|
};
|
|
19
20
|
</script>
|
|
@@ -15,9 +15,9 @@ $effect(() => {
|
|
|
15
15
|
const trigger = paginationTrigger;
|
|
16
16
|
const items = itemsContainer;
|
|
17
17
|
const intersectionObserver = new IntersectionObserver((e) => {
|
|
18
|
-
const
|
|
18
|
+
const entry = e[e.length - 1];
|
|
19
19
|
// an armed sentinel over a failing backend retries in a loop — the manual control is the only way on from here
|
|
20
|
-
if (
|
|
20
|
+
if (entry.isIntersecting && !source.failed) {
|
|
21
21
|
void onLoadMore();
|
|
22
22
|
}
|
|
23
23
|
}, {
|
|
@@ -224,6 +224,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
|
|
|
224
224
|
| `--sc-kit--numeral-input--underline-color` | Inset bottom-underline indicator (transparent default, danger on error) | `transparent` |
|
|
225
225
|
| `--sc-kit--numeral-input--font-size` | Text font size | per size |
|
|
226
226
|
| `--sc-kit--numeral-input--color` | Text color | `var(--sc-kit--color--text--primary)` |
|
|
227
|
+
| `--sc-kit--numeral-input--text-align` | Text alignment inside the field | `start` |
|
|
227
228
|
| `--sc-kit--numeral-input--placeholder--color` | Placeholder text color | `var(--sc-kit--color--text--placeholder)` |
|
|
228
229
|
| `--sc-kit--numeral-input--icon--color` | Leading / trailing icon color (does NOT affect inner affordances) | `var(--sc-kit--color--text--muted)` |
|
|
229
230
|
| `--sc-kit--numeral-input--icon--size` | Leading / trailing icon size (does NOT affect inner affordances) | per size |
|
|
@@ -273,6 +274,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
|
|
|
273
274
|
);
|
|
274
275
|
--_ni--line-height: var(--_ni--size-line-height, var(--sc-kit--line-height--control--md));
|
|
275
276
|
--_ni--color: var(--sc-kit--numeral-input--color, var(--sc-kit--color--text--primary));
|
|
277
|
+
--_ni--text-align: var(--sc-kit--numeral-input--text-align, start);
|
|
276
278
|
--_ni--placeholder-color: var(
|
|
277
279
|
--sc-kit--numeral-input--placeholder--color,
|
|
278
280
|
var(--sc-kit--color--text--placeholder)
|
|
@@ -376,6 +378,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
|
|
|
376
378
|
font-size: inherit;
|
|
377
379
|
font-variant-numeric: tabular-nums;
|
|
378
380
|
line-height: inherit;
|
|
381
|
+
text-align: var(--_ni--text-align);
|
|
379
382
|
}
|
|
380
383
|
.numeral-input__el::placeholder {
|
|
381
384
|
color: var(--_ni--placeholder-color);
|
|
@@ -94,6 +94,7 @@ type Props = ClearableProps | RequiredProps;
|
|
|
94
94
|
* | `--sc-kit--numeral-input--underline-color` | Inset bottom-underline indicator (transparent default, danger on error) | `transparent` |
|
|
95
95
|
* | `--sc-kit--numeral-input--font-size` | Text font size | per size |
|
|
96
96
|
* | `--sc-kit--numeral-input--color` | Text color | `var(--sc-kit--color--text--primary)` |
|
|
97
|
+
* | `--sc-kit--numeral-input--text-align` | Text alignment inside the field | `start` |
|
|
97
98
|
* | `--sc-kit--numeral-input--placeholder--color` | Placeholder text color | `var(--sc-kit--color--text--placeholder)` |
|
|
98
99
|
* | `--sc-kit--numeral-input--icon--color` | Leading / trailing icon color (does NOT affect inner affordances) | `var(--sc-kit--color--text--muted)` |
|
|
99
100
|
* | `--sc-kit--numeral-input--icon--size` | Leading / trailing icon size (does NOT affect inner affordances) | per size |
|
|
@@ -9,5 +9,6 @@ export declare class PaginationState {
|
|
|
9
9
|
resetPageNumber: () => void;
|
|
10
10
|
setPageNumber: (pageNumber: number) => void;
|
|
11
11
|
setPageSize: (pageSize: number) => void;
|
|
12
|
+
/** A `0` past page 1 is ignored — some endpoints return the count with the first page only. Call `reset()` when the filter changes. */
|
|
12
13
|
setTotal: (total: number) => void;
|
|
13
14
|
}
|
|
@@ -27,6 +27,7 @@ export class PaginationState {
|
|
|
27
27
|
this.setPageNumber(1);
|
|
28
28
|
this._pageSize = pageSize;
|
|
29
29
|
};
|
|
30
|
+
/** A `0` past page 1 is ignored — some endpoints return the count with the first page only. Call `reset()` when the filter changes. */
|
|
30
31
|
setTotal = (total) => {
|
|
31
32
|
if (this._pageNumber === 1 || total > 0) {
|
|
32
33
|
this._total = total;
|
|
@@ -12,37 +12,58 @@ const emit = (next) => {
|
|
|
12
12
|
on?.complete?.(next);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const selectContent = (cell) => {
|
|
16
|
+
setTimeout(() => cell.setSelectionRange(0, cell.value.length));
|
|
17
|
+
};
|
|
18
|
+
const focusCell = (idx) => {
|
|
19
|
+
const cell = cells[Math.max(0, Math.min(idx, length - 1))];
|
|
20
|
+
if (!cell) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
cell.focus();
|
|
24
|
+
selectContent(cell);
|
|
25
|
+
};
|
|
26
|
+
const removeLast = (focusIdx) => {
|
|
27
|
+
emit(value.slice(0, -1));
|
|
28
|
+
focusCell(focusIdx);
|
|
19
29
|
};
|
|
20
30
|
const handleInput = (e, idx) => {
|
|
21
31
|
const target = e.target;
|
|
22
32
|
const ch = target.value.replace(/[^0-9]/g, '').slice(-1);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
if (!ch) {
|
|
34
|
+
const isDeletion = e instanceof InputEvent && e.inputType.startsWith('delete');
|
|
35
|
+
if (isDeletion && idx === value.length - 1) {
|
|
36
|
+
removeLast(idx);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
target.value = cellValue(idx);
|
|
40
|
+
selectContent(target);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
28
43
|
}
|
|
44
|
+
const at = Math.min(idx, value.length);
|
|
45
|
+
target.value = at === idx ? ch : '';
|
|
46
|
+
emit(value.slice(0, at) + ch + value.slice(at + 1));
|
|
47
|
+
focusCell(at + 1);
|
|
29
48
|
};
|
|
30
49
|
const handleKeydown = (e, idx) => {
|
|
31
|
-
if (e.key === 'Backspace') {
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
50
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
if (idx === value.length - 1) {
|
|
53
|
+
removeLast(idx);
|
|
54
|
+
}
|
|
55
|
+
else if (e.key === 'Backspace' && idx === value.length && idx > 0) {
|
|
56
|
+
removeLast(idx - 1);
|
|
35
57
|
}
|
|
36
58
|
return;
|
|
37
59
|
}
|
|
38
|
-
if (e.key === 'ArrowLeft'
|
|
60
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
39
61
|
e.preventDefault();
|
|
40
|
-
|
|
62
|
+
focusCell(e.key === 'ArrowLeft' ? idx - 1 : idx + 1);
|
|
41
63
|
return;
|
|
42
64
|
}
|
|
43
|
-
if (
|
|
65
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
|
|
44
66
|
e.preventDefault();
|
|
45
|
-
cells[idx + 1]?.focus();
|
|
46
67
|
}
|
|
47
68
|
};
|
|
48
69
|
const handlePaste = (e) => {
|
|
@@ -52,12 +73,7 @@ const handlePaste = (e) => {
|
|
|
52
73
|
return;
|
|
53
74
|
}
|
|
54
75
|
emit(pasted);
|
|
55
|
-
|
|
56
|
-
cells[focusIdx]?.focus();
|
|
57
|
-
};
|
|
58
|
-
const handleFocus = (e) => {
|
|
59
|
-
const target = e.target;
|
|
60
|
-
setTimeout(() => target.setSelectionRange(0, target.value.length));
|
|
76
|
+
focusCell(pasted.length);
|
|
61
77
|
};
|
|
62
78
|
</script>
|
|
63
79
|
|
|
@@ -85,14 +101,16 @@ const handleFocus = (e) => {
|
|
|
85
101
|
oninput={(e) => handleInput(e, i)}
|
|
86
102
|
onkeydown={(e) => handleKeydown(e, i)}
|
|
87
103
|
onpaste={handlePaste}
|
|
88
|
-
onfocus={
|
|
104
|
+
onfocus={(e) => selectContent(e.currentTarget)}
|
|
105
|
+
onclick={(e) => selectContent(e.currentTarget)} />
|
|
89
106
|
{/each}
|
|
90
107
|
</div>
|
|
91
108
|
|
|
92
109
|
<!--
|
|
93
110
|
@component
|
|
94
|
-
Multi-cell one-time-code input. Auto-advances cursor on entry
|
|
95
|
-
|
|
111
|
+
Multi-cell one-time-code input. Auto-advances cursor on entry; a filled cell is always selected, so
|
|
112
|
+
typing replaces its digit; Backspace / Delete erase from the end only. Supports paste of the full
|
|
113
|
+
code and arrow-key navigation between cells. Numeric-only (forces
|
|
96
114
|
`inputmode="numeric"` + filters non-digits). Set `mask` for sensitive codes (renders cells
|
|
97
115
|
as `<input type="password">`). Fires `on.complete` when all cells are filled.
|
|
98
116
|
|
|
@@ -18,8 +18,9 @@ type Props = {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Multi-cell one-time-code input. Auto-advances cursor on entry
|
|
22
|
-
*
|
|
21
|
+
* Multi-cell one-time-code input. Auto-advances cursor on entry; a filled cell is always selected, so
|
|
22
|
+
* typing replaces its digit; Backspace / Delete erase from the end only. Supports paste of the full
|
|
23
|
+
* code and arrow-key navigation between cells. Numeric-only (forces
|
|
23
24
|
* `inputmode="numeric"` + filters non-digits). Set `mask` for sensitive codes (renders cells
|
|
24
25
|
* as `<input type="password">`). Fires `on.complete` when all cells are filled.
|
|
25
26
|
*
|
|
@@ -143,9 +143,6 @@ onMount(() => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
resizeObserver.observe(slidesRef);
|
|
146
|
-
if (isBrowser()) {
|
|
147
|
-
window.addEventListener(`keydown`, onKeyPress);
|
|
148
|
-
}
|
|
149
146
|
if (wheelNavigation) {
|
|
150
147
|
wheelAdapter = createWheelAdapter(slidesRef, {
|
|
151
148
|
axis: 'x',
|
|
@@ -157,11 +154,8 @@ onDestroy(() => {
|
|
|
157
154
|
if (resizeObserver) {
|
|
158
155
|
resizeObserver.disconnect();
|
|
159
156
|
}
|
|
160
|
-
if (isBrowser()) {
|
|
161
|
-
window.
|
|
162
|
-
if (interval) {
|
|
163
|
-
window.clearInterval(interval);
|
|
164
|
-
}
|
|
157
|
+
if (isBrowser() && interval) {
|
|
158
|
+
window.clearInterval(interval);
|
|
165
159
|
}
|
|
166
160
|
wheelAdapter?.destroy();
|
|
167
161
|
});
|
|
@@ -223,8 +217,12 @@ const slidesTranslateX = $derived(swipeTransition ||
|
|
|
223
217
|
: 0));
|
|
224
218
|
</script>
|
|
225
219
|
|
|
220
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
|
|
226
221
|
<div
|
|
227
222
|
class="carousel"
|
|
223
|
+
role="group"
|
|
224
|
+
tabindex="0"
|
|
225
|
+
onkeydown={onKeyPress}
|
|
228
226
|
class:carousel--arrows-and-dots={mode === 'arrows-and-dots'}
|
|
229
227
|
class:carousel--arrows-only={mode === 'arrows-only'}
|
|
230
228
|
class:carousel--dots-only={mode === 'dots-only'}
|
|
@@ -311,7 +309,7 @@ const slidesTranslateX = $derived(swipeTransition ||
|
|
|
311
309
|
|
|
312
310
|
<!--
|
|
313
311
|
@component
|
|
314
|
-
A horizontal slide carousel with infinite looping, touch swipe support,
|
|
312
|
+
A horizontal slide carousel with infinite looping, touch swipe support, arrow-key navigation while it has focus, and multiple display modes (arrows, dots, counts).
|
|
315
313
|
|
|
316
314
|
### CSS Custom Properties
|
|
317
315
|
| Property | Description | Default |
|
|
@@ -374,6 +372,7 @@ A horizontal slide carousel with infinite looping, touch swipe support, keyboard
|
|
|
374
372
|
width: 100%;
|
|
375
373
|
height: 100%;
|
|
376
374
|
overflow: hidden;
|
|
375
|
+
outline: none;
|
|
377
376
|
}
|
|
378
377
|
.carousel:hover {
|
|
379
378
|
--_carousel--nav-opacity: 1;
|
|
@@ -43,7 +43,7 @@ interface $$IsomorphicComponent {
|
|
|
43
43
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* A horizontal slide carousel with infinite looping, touch swipe support,
|
|
46
|
+
* A horizontal slide carousel with infinite looping, touch swipe support, arrow-key navigation while it has focus, and multiple display modes (arrows, dots, counts).
|
|
47
47
|
*
|
|
48
48
|
* ### CSS Custom Properties
|
|
49
49
|
* | Property | Description | Default |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script lang="ts">import {
|
|
1
|
+
<script lang="ts">import { stopClickPropagation } from '../../core/actions';
|
|
2
|
+
import { getFormFieldLabel } from '../_internal/form-field-label-context';
|
|
2
3
|
const { selected, label, disabled = false, title, name, on } = $props();
|
|
3
4
|
const ariaLabel = $derived(typeof label === 'string' ? label : name);
|
|
4
5
|
const formFieldLabel = getFormFieldLabel();
|
|
5
|
-
const handleClick = (
|
|
6
|
-
event.stopPropagation();
|
|
6
|
+
const handleClick = () => {
|
|
7
7
|
if (disabled || selected) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
@@ -11,7 +11,12 @@ const handleClick = (event) => {
|
|
|
11
11
|
};
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<label
|
|
14
|
+
<label
|
|
15
|
+
class="radio"
|
|
16
|
+
class:radio--on={selected}
|
|
17
|
+
class:radio--disabled={disabled}
|
|
18
|
+
title={title}
|
|
19
|
+
use:stopClickPropagation>
|
|
15
20
|
<button
|
|
16
21
|
type="button"
|
|
17
22
|
class="radio__dot"
|
|
@@ -69,7 +69,7 @@ export const registerValidatedLink = (editor, loc) => {
|
|
|
69
69
|
linkNode.textContent = data.text ?? data.url;
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
editor.insertContent(
|
|
72
|
+
editor.insertContent(editor.dom.createHTML('a', { href: data.url, target: LINK_TARGET }, editor.dom.encode(data.text ?? data.url)));
|
|
73
73
|
}
|
|
74
74
|
api.close();
|
|
75
75
|
}
|
|
@@ -121,7 +121,8 @@ const showClear = $derived(mode.clearable && hasValue && isInteractive && !core.
|
|
|
121
121
|
value={displayValue}
|
|
122
122
|
onfocus={core.handleFocus}
|
|
123
123
|
oninput={core.handleInput}
|
|
124
|
-
onkeydown={core.handleKeydown}
|
|
124
|
+
onkeydown={core.handleKeydown}
|
|
125
|
+
onpaste={core.handlePaste} />
|
|
125
126
|
|
|
126
127
|
{#if showClear}
|
|
127
128
|
<InputClearButton
|
|
@@ -261,7 +261,8 @@ const handleDndFinalize = (e) => {
|
|
|
261
261
|
value={core.isFiltering ? core.query : ''}
|
|
262
262
|
onfocus={core.handleFocus}
|
|
263
263
|
oninput={core.handleInput}
|
|
264
|
-
onkeydown={core.handleKeydown}
|
|
264
|
+
onkeydown={core.handleKeydown}
|
|
265
|
+
onpaste={core.handlePaste} />
|
|
265
266
|
|
|
266
267
|
{#if core.loading}
|
|
267
268
|
<span
|
|
@@ -82,6 +82,8 @@ export type SelectCore<T> = {
|
|
|
82
82
|
handleMousedown: (e: MouseEvent) => void;
|
|
83
83
|
handleInput: (e: Event) => void;
|
|
84
84
|
handleKeydown: (e: KeyboardEvent) => void;
|
|
85
|
+
/** Starts filtering with the pasted text — the input stays `readonly` until filtering starts, so a native paste would be dropped. */
|
|
86
|
+
handlePaste: (e: ClipboardEvent) => void;
|
|
85
87
|
openPopover: () => void;
|
|
86
88
|
closePopover: () => void;
|
|
87
89
|
pickRow: (row: SelectRow<T>) => void;
|
|
@@ -182,17 +182,6 @@ export function createSelectCore(config) {
|
|
|
182
182
|
highlight = findSelectedRowIndex();
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
const highlightFirstSelectedAndLoad = () => {
|
|
186
|
-
const selected = config.getSelectedOptions()[0];
|
|
187
|
-
if (selected) {
|
|
188
|
-
const idx = rows.findIndex((r) => r.kind === 'option' && r.option === selected);
|
|
189
|
-
highlight = idx >= 0 ? idx : (navigableIndices[0] ?? 0);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
highlight = navigableIndices[0] ?? 0;
|
|
193
|
-
}
|
|
194
|
-
void runLoad('');
|
|
195
|
-
};
|
|
196
185
|
const openPopover = () => {
|
|
197
186
|
if (!config.getInteractive() || isOpen) {
|
|
198
187
|
return;
|
|
@@ -200,12 +189,7 @@ export function createSelectCore(config) {
|
|
|
200
189
|
isOpen = true;
|
|
201
190
|
query = '';
|
|
202
191
|
isFiltering = false;
|
|
203
|
-
|
|
204
|
-
void loadAndHighlightSelected();
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
highlightFirstSelectedAndLoad();
|
|
208
|
-
}
|
|
192
|
+
void loadAndHighlightSelected();
|
|
209
193
|
// Clicks land on the trigger root (div role=presentation) — focus the inner input so the
|
|
210
194
|
// user can start typing immediately without a second click.
|
|
211
195
|
config.getInputEl()?.focus();
|
|
@@ -224,6 +208,7 @@ export function createSelectCore(config) {
|
|
|
224
208
|
isOpen = false;
|
|
225
209
|
query = '';
|
|
226
210
|
isFiltering = false;
|
|
211
|
+
debouncedLoad.cancel();
|
|
227
212
|
cancelInFlightLoad();
|
|
228
213
|
};
|
|
229
214
|
const resetFilterKeepFocus = () => {
|
|
@@ -235,6 +220,7 @@ export function createSelectCore(config) {
|
|
|
235
220
|
highlight = navigableIndices[0] ?? 0;
|
|
236
221
|
}
|
|
237
222
|
config.getInputEl()?.focus();
|
|
223
|
+
debouncedLoad.cancel();
|
|
238
224
|
void runLoad('');
|
|
239
225
|
};
|
|
240
226
|
const finishPick = () => {
|
|
@@ -339,6 +325,20 @@ export function createSelectCore(config) {
|
|
|
339
325
|
moveHighlightByUser(navigableIndices[0] ?? 0);
|
|
340
326
|
debouncedLoad(query);
|
|
341
327
|
};
|
|
328
|
+
const handlePaste = (e) => {
|
|
329
|
+
if (!config.getInteractive() || config.getSearchable?.() === false || isFiltering) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const text = e.clipboardData?.getData('text').trim();
|
|
333
|
+
if (!text) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
e.preventDefault();
|
|
337
|
+
if (!isOpen) {
|
|
338
|
+
openPopover();
|
|
339
|
+
}
|
|
340
|
+
startFilteringWith(text);
|
|
341
|
+
};
|
|
342
342
|
const handleKeydown = (e) => {
|
|
343
343
|
if (!config.getInteractive()) {
|
|
344
344
|
return;
|
|
@@ -425,6 +425,7 @@ export function createSelectCore(config) {
|
|
|
425
425
|
handleMousedown,
|
|
426
426
|
handleInput,
|
|
427
427
|
handleKeydown,
|
|
428
|
+
handlePaste,
|
|
428
429
|
openPopover,
|
|
429
430
|
closePopover,
|
|
430
431
|
pickRow,
|