@streamscloud/kit 0.92.1 → 0.93.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.
|
@@ -2,7 +2,11 @@ import type { TextValidation, TextWithFormatValidation } from './types';
|
|
|
2
2
|
import * as yup from 'yup';
|
|
3
3
|
/** Value-level rules of `textValidationSchema`. Judges a real value — `null` / `undefined` are decided by the schema modifiers the caller adds. */
|
|
4
4
|
export declare const isValidText: (value: string, rules: TextValidation) => boolean;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Value-level rules of `formattedTextValidationSchema` — `isValidText` plus the format, which an empty value skips.
|
|
7
|
+
* @param unicode compiles the format with the `u` flag, so Unicode property escapes like `\p{L}` work. @default true
|
|
8
|
+
*/
|
|
9
|
+
export declare const isValidFormattedText: (value: string, rules: TextWithFormatValidation, unicode?: boolean) => boolean;
|
|
7
10
|
export declare const textValidationSchema: (rules: TextValidation) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
8
|
-
|
|
11
|
+
/** @param unicode compiles the format with the `u` flag, so Unicode property escapes like `\p{L}` work. @default true */
|
|
12
|
+
export declare const formattedTextValidationSchema: (rules: TextWithFormatValidation, fieldName: string, formatMessage?: string, unicode?: boolean) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { ValidationLocalization } from './validation-localization';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
3
|
const isEmptyOrHasContent = (value) => !value || value.trim().length > 0;
|
|
4
|
+
const matchesFormat = (value, format, unicode) => new RegExp(format, unicode ? 'u' : '').test(value);
|
|
4
5
|
/** Value-level rules of `textValidationSchema`. Judges a real value — `null` / `undefined` are decided by the schema modifiers the caller adds. */
|
|
5
6
|
export const isValidText = (value, rules) => {
|
|
6
7
|
return isEmptyOrHasContent(value) && value.length >= rules.minLength && value.length <= rules.maxLength;
|
|
7
8
|
};
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Value-level rules of `formattedTextValidationSchema` — `isValidText` plus the format, which an empty value skips.
|
|
11
|
+
* @param unicode compiles the format with the `u` flag, so Unicode property escapes like `\p{L}` work. @default true
|
|
12
|
+
*/
|
|
13
|
+
export const isValidFormattedText = (value, rules, unicode = true) => {
|
|
14
|
+
return isValidText(value, rules) && (!value || matchesFormat(value, rules.format, unicode));
|
|
11
15
|
};
|
|
12
16
|
export const textValidationSchema = (rules) => {
|
|
13
17
|
const msg = new ValidationLocalization();
|
|
@@ -22,7 +26,8 @@ export const textValidationSchema = (rules) => {
|
|
|
22
26
|
return schema.min(rules.minLength, msg.minLength(rules.minLength));
|
|
23
27
|
}
|
|
24
28
|
};
|
|
25
|
-
|
|
29
|
+
/** @param unicode compiles the format with the `u` flag, so Unicode property escapes like `\p{L}` work. @default true */
|
|
30
|
+
export const formattedTextValidationSchema = (rules, fieldName, formatMessage, unicode = true) => {
|
|
26
31
|
const msg = new ValidationLocalization();
|
|
27
|
-
return textValidationSchema(rules).test(`${fieldName}-format`, formatMessage ?? msg.badFormat, (val) => !val ||
|
|
32
|
+
return textValidationSchema(rules).test(`${fieldName}-format`, formatMessage ?? msg.badFormat, (val) => !val || matchesFormat(val, rules.format, unicode));
|
|
28
33
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">import { showInTopLayer } from '../_internal/top-layer';
|
|
2
2
|
import { arrow as arrowMiddleware, autoUpdate, computePosition, flip, hide as hideMiddleware, offset, shift } from '@floating-ui/dom';
|
|
3
3
|
import { tick } from 'svelte';
|
|
4
|
-
const { text, placement = 'top', delay = 250, fillHeight = false, children } = $props();
|
|
4
|
+
const { text, placement = 'top', delay = 250, fillHeight = false, shrink = false, children } = $props();
|
|
5
5
|
let triggerEl = $state.raw(undefined);
|
|
6
6
|
let bubbleEl = $state.raw(undefined);
|
|
7
7
|
let arrowEl = $state.raw(undefined);
|
|
@@ -71,6 +71,7 @@ $effect(() => () => {
|
|
|
71
71
|
bind:this={triggerEl}
|
|
72
72
|
class="tooltip"
|
|
73
73
|
class:tooltip--fill-height={fillHeight}
|
|
74
|
+
class:tooltip--shrink={shrink}
|
|
74
75
|
onmouseenter={show}
|
|
75
76
|
onmouseleave={hide}
|
|
76
77
|
onfocusin={show}
|
|
@@ -116,6 +117,10 @@ or plain text. Bubble flips and shifts on viewport collision; an arrow points to
|
|
|
116
117
|
.tooltip--fill-height {
|
|
117
118
|
block-size: 100%;
|
|
118
119
|
}
|
|
120
|
+
.tooltip--shrink {
|
|
121
|
+
min-inline-size: 0;
|
|
122
|
+
max-inline-size: 100%;
|
|
123
|
+
}
|
|
119
124
|
.tooltip__description {
|
|
120
125
|
position: absolute;
|
|
121
126
|
width: 1px;
|
|
@@ -9,6 +9,8 @@ type Props = {
|
|
|
9
9
|
delay?: number;
|
|
10
10
|
/** Stretch the trigger to the parent's full height (content stays vertically centered). @default false */
|
|
11
11
|
fillHeight?: boolean;
|
|
12
|
+
/** Let the trigger shrink below its content width to fit its container, so an ellipsized child can truncate. */
|
|
13
|
+
shrink?: boolean;
|
|
12
14
|
/**
|
|
13
15
|
* Wrapped element — anything passed becomes the tooltip trigger (icon, button, link, plain text). Receives
|
|
14
16
|
* `aria-describedby` pointing at the tooltip text: spread it onto an interactive trigger so screen readers announce the text.
|