@widgetic/design-system 0.5.40 → 0.5.41
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/README.md +73 -0
- package/dist/components/ContentRefreshOverlay.svelte +103 -0
- package/dist/components/ContentRefreshOverlay.svelte.d.ts +18 -0
- package/dist/components/chat/Composer.svelte +380 -19
- package/dist/components/chat/Composer.svelte.d.ts +88 -1
- package/dist/components/chat/PlanCard.svelte +218 -88
- package/dist/components/chat/PlanCard.svelte.d.ts +11 -0
- package/dist/components/chat/QuestionCard.svelte +180 -70
- package/dist/components/chat/QuestionCard.svelte.d.ts +28 -2
- package/dist/components/chat/QuestionCardSummary.svelte +96 -0
- package/dist/components/chat/QuestionCardSummary.svelte.d.ts +20 -0
- package/dist/components/chat/QueueCard.svelte +185 -0
- package/dist/components/chat/QueueCard.svelte.d.ts +40 -0
- package/dist/components/chat/composerLogic.d.ts +31 -0
- package/dist/components/chat/composerLogic.js +37 -0
- package/dist/components/chat/composerReferences.d.ts +28 -0
- package/dist/components/chat/composerReferences.js +23 -0
- package/dist/components/chat/index.d.ts +8 -3
- package/dist/components/chat/index.js +10 -2
- package/dist/components/chat/questionCardLogic.d.ts +40 -3
- package/dist/components/chat/questionCardLogic.js +54 -3
- package/dist/components/chat/queueCardLogic.d.ts +7 -0
- package/dist/components/chat/queueCardLogic.js +5 -0
- package/dist/components/creator/index.d.ts +1 -2
- package/dist/components/creator/index.js +2 -0
- package/dist/components/index.d.ts +8 -7
- package/dist/components/index.js +8 -6
- package/dist/components/modals/BaseModal.svelte +14 -4
- package/dist/components/navigation/breadcrumbSlideIn.d.ts +6 -2
- package/dist/components/navigation/breadcrumbSlideIn.js +6 -6
- package/dist/components/search-input/SearchInput.svelte +282 -14
- package/dist/components/search-input/SearchInput.svelte.d.ts +3 -0
- package/dist/components/search-input/index.d.ts +1 -0
- package/dist/components/search-input/index.js +1 -0
- package/dist/components/search-input/index2.d.ts +4 -0
- package/dist/components/search-input/recentSearches.d.ts +12 -0
- package/dist/components/search-input/recentSearches.js +124 -0
- package/dist/components/toast/ToasterModal.svelte +8 -3
- package/dist/components/toast/ToasterModal.svelte.d.ts +2 -0
- package/dist/components/ui/chip/chip.svelte +39 -1
- package/dist/components/ui/chip/chip.svelte.d.ts +8 -0
- package/dist/components/ui/chip/chipProgress.d.ts +14 -0
- package/dist/components/ui/chip/chipProgress.js +21 -0
- package/dist/components/ui/icon-button/icon-button.svelte +2 -0
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +5 -0
- package/dist/components/ui/number-controls/index.d.ts +2 -0
- package/dist/components/ui/number-controls/index.js +2 -0
- package/dist/components/ui/number-controls/number-controls.svelte +530 -0
- package/dist/components/ui/number-controls/number-controls.svelte.d.ts +46 -0
- package/dist/components/ui/number-controls/numberControlsSteps.d.ts +17 -0
- package/dist/components/ui/number-controls/numberControlsSteps.js +23 -0
- package/dist/components/ui/number-controls/numberControlsValueArea.d.ts +29 -0
- package/dist/components/ui/number-controls/numberControlsValueArea.js +51 -0
- package/dist/components/ui/text-flip/index.d.ts +1 -0
- package/dist/components/ui/text-flip/index.js +1 -0
- package/dist/components/ui/text-flip/text-flip.svelte +103 -0
- package/dist/components/ui/text-flip/text-flip.svelte.d.ts +15 -0
- package/dist/components/ui/text-flip/textFlipLogic.d.ts +49 -0
- package/dist/components/ui/text-flip/textFlipLogic.js +151 -0
- package/dist/inline-completion/completionAnswer.d.ts +11 -0
- package/dist/inline-completion/completionAnswer.js +49 -0
- package/dist/inline-completion/completionCache.d.ts +24 -0
- package/dist/inline-completion/completionCache.js +47 -0
- package/dist/inline-completion/completionController.d.ts +61 -0
- package/dist/inline-completion/completionController.js +280 -0
- package/dist/inline-completion/completionKeys.d.ts +21 -0
- package/dist/inline-completion/completionKeys.js +19 -0
- package/dist/inline-completion/completionText.d.ts +53 -0
- package/dist/inline-completion/completionText.js +79 -0
- package/dist/inline-completion/completionTypes.d.ts +71 -0
- package/dist/inline-completion/completionTypes.js +5 -0
- package/dist/inline-completion/gatewayCompletion.d.ts +37 -0
- package/dist/inline-completion/gatewayCompletion.js +77 -0
- package/dist/inline-completion/ghostTap.d.ts +19 -0
- package/dist/inline-completion/ghostTap.js +20 -0
- package/dist/inline-completion/hintMemory.d.ts +43 -0
- package/dist/inline-completion/hintMemory.js +90 -0
- package/dist/inline-completion/httpSource.d.ts +40 -0
- package/dist/inline-completion/httpSource.js +149 -0
- package/dist/inline-completion/index.d.ts +30 -0
- package/dist/inline-completion/index.js +20 -0
- package/dist/inline-completion/inlineCompletionAction.d.ts +54 -0
- package/dist/inline-completion/inlineCompletionAction.js +310 -0
- package/dist/inline-completion/outcomeReporter.d.ts +49 -0
- package/dist/inline-completion/outcomeReporter.js +139 -0
- package/dist/inline-completion/promiseLike.d.ts +9 -0
- package/dist/inline-completion/promiseLike.js +9 -0
- package/dist/prompt-references/ReferenceMenu.svelte +344 -0
- package/dist/prompt-references/ReferenceMenu.svelte.d.ts +26 -0
- package/dist/prompt-references/index.d.ts +27 -0
- package/dist/prompt-references/index.js +20 -0
- package/dist/prompt-references/neutralizingSource.d.ts +21 -0
- package/dist/prompt-references/neutralizingSource.js +29 -0
- package/dist/prompt-references/promptReferences.d.ts +28 -0
- package/dist/prompt-references/promptReferences.js +766 -0
- package/dist/prompt-references/referenceBadge.d.ts +61 -0
- package/dist/prompt-references/referenceBadge.js +82 -0
- package/dist/prompt-references/referenceBadgePainter.d.ts +31 -0
- package/dist/prompt-references/referenceBadgePainter.js +106 -0
- package/dist/prompt-references/referenceEditing.d.ts +60 -0
- package/dist/prompt-references/referenceEditing.js +135 -0
- package/dist/prompt-references/referenceLabels.d.ts +56 -0
- package/dist/prompt-references/referenceLabels.js +215 -0
- package/dist/prompt-references/referenceMeasure.d.ts +12 -0
- package/dist/prompt-references/referenceMeasure.js +63 -0
- package/dist/prompt-references/referenceMenuHost.svelte.d.ts +29 -0
- package/dist/prompt-references/referenceMenuHost.svelte.js +43 -0
- package/dist/prompt-references/referenceMenuKeys.d.ts +26 -0
- package/dist/prompt-references/referenceMenuKeys.js +49 -0
- package/dist/prompt-references/referenceMenuPlacement.d.ts +63 -0
- package/dist/prompt-references/referenceMenuPlacement.js +66 -0
- package/dist/prompt-references/referenceTokens.d.ts +175 -0
- package/dist/prompt-references/referenceTokens.js +332 -0
- package/dist/prompt-references/referenceTrigger.d.ts +52 -0
- package/dist/prompt-references/referenceTrigger.js +100 -0
- package/dist/prompt-references/referenceTypes.d.ts +38 -0
- package/dist/prompt-references/referenceTypes.js +4 -0
- package/dist/prompt-references/sentReferences.d.ts +50 -0
- package/dist/prompt-references/sentReferences.js +122 -0
- package/dist/styles/tokens.css +58 -0
- package/dist/textarea-overlay/index.d.ts +9 -0
- package/dist/textarea-overlay/index.js +7 -0
- package/dist/textarea-overlay/mirrorSegments.d.ts +31 -0
- package/dist/textarea-overlay/mirrorSegments.js +47 -0
- package/dist/textarea-overlay/mirrorSizing.d.ts +39 -0
- package/dist/textarea-overlay/mirrorSizing.js +40 -0
- package/dist/textarea-overlay/textareaOverlay.d.ts +25 -0
- package/dist/textarea-overlay/textareaOverlay.js +277 -0
- package/dist/utils/overlayMotion.d.ts +1 -0
- package/dist/utils/overlayMotion.js +3 -3
- package/dist/utils/reducedMotion.d.ts +9 -0
- package/dist/utils/reducedMotion.js +13 -0
- package/package.json +16 -1
- package/dist/components/ui/number-stepper/index.d.ts +0 -3
- package/dist/components/ui/number-stepper/index.js +0 -3
- package/dist/components/ui/number-stepper/number-stepper.svelte +0 -212
- package/dist/components/ui/number-stepper/number-stepper.svelte.d.ts +0 -24
- package/dist/components/ui/number-stepper/numberStepperSteps.d.ts +0 -26
- package/dist/components/ui/number-stepper/numberStepperSteps.js +0 -45
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** How many recent terms we keep per storage key. */
|
|
2
|
+
export const RECENT_SEARCHES_LIMIT = 3;
|
|
3
|
+
/** Shorter trimmed terms are not stored or shown. */
|
|
4
|
+
export const MIN_RECENT_SEARCH_LENGTH = 2;
|
|
5
|
+
const STORAGE_VERSION = 1;
|
|
6
|
+
const MAX_TERM_LENGTH = 80;
|
|
7
|
+
/** When localStorage is unusable, fall back to memory for the rest of the page. */
|
|
8
|
+
const memoryFallback = new Map();
|
|
9
|
+
let loggedStorageFailure = false;
|
|
10
|
+
function logStorageFailureOnce(error) {
|
|
11
|
+
if (loggedStorageFailure)
|
|
12
|
+
return;
|
|
13
|
+
loggedStorageFailure = true;
|
|
14
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
15
|
+
console.warn(`[SearchInput] recent searches storage unavailable: ${detail}`);
|
|
16
|
+
}
|
|
17
|
+
function normalizeTerm(raw) {
|
|
18
|
+
const trimmed = raw.trim();
|
|
19
|
+
if (trimmed.length < MIN_RECENT_SEARCH_LENGTH)
|
|
20
|
+
return null;
|
|
21
|
+
if (trimmed.length <= MAX_TERM_LENGTH)
|
|
22
|
+
return trimmed;
|
|
23
|
+
return trimmed.slice(0, MAX_TERM_LENGTH);
|
|
24
|
+
}
|
|
25
|
+
function sanitizeItems(items) {
|
|
26
|
+
if (!Array.isArray(items))
|
|
27
|
+
return [];
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const entry of items) {
|
|
30
|
+
if (typeof entry !== 'string')
|
|
31
|
+
continue;
|
|
32
|
+
const normalized = normalizeTerm(entry);
|
|
33
|
+
if (normalized)
|
|
34
|
+
out.push(normalized);
|
|
35
|
+
}
|
|
36
|
+
return out.slice(0, RECENT_SEARCHES_LIMIT);
|
|
37
|
+
}
|
|
38
|
+
function parseStored(raw) {
|
|
39
|
+
if (!raw)
|
|
40
|
+
return [];
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(raw);
|
|
43
|
+
if (!parsed || typeof parsed !== 'object' || parsed.v !== STORAGE_VERSION)
|
|
44
|
+
return [];
|
|
45
|
+
return sanitizeItems(parsed.items);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function readFromLocalStorage(key) {
|
|
52
|
+
if (typeof window === 'undefined')
|
|
53
|
+
return null;
|
|
54
|
+
try {
|
|
55
|
+
return parseStored(window.localStorage.getItem(key));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
logStorageFailureOnce(error);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeToLocalStorage(key, items) {
|
|
63
|
+
if (typeof window === 'undefined')
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
const payload = { v: STORAGE_VERSION, items };
|
|
67
|
+
window.localStorage.setItem(key, JSON.stringify(payload));
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
logStorageFailureOnce(error);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function removeFromLocalStorage(key) {
|
|
76
|
+
if (typeof window === 'undefined')
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
window.localStorage.removeItem(key);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logStorageFailureOnce(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function dedupeMoveToFront(items, term) {
|
|
86
|
+
const lower = term.toLowerCase();
|
|
87
|
+
const without = items.filter((item) => item.toLowerCase() !== lower);
|
|
88
|
+
return [term, ...without].slice(0, RECENT_SEARCHES_LIMIT);
|
|
89
|
+
}
|
|
90
|
+
/** Returns the stored list for `key`, newest first. Never throws. */
|
|
91
|
+
export function readRecentSearches(key) {
|
|
92
|
+
if (!key || typeof window === 'undefined')
|
|
93
|
+
return [];
|
|
94
|
+
const fromStorage = readFromLocalStorage(key);
|
|
95
|
+
if (fromStorage !== null)
|
|
96
|
+
return fromStorage;
|
|
97
|
+
return [...(memoryFallback.get(key) ?? [])];
|
|
98
|
+
}
|
|
99
|
+
/** Adds `term` to the stored list (newest first, case-insensitive dedupe). Returns the new list. Never throws. */
|
|
100
|
+
export function rememberRecentSearch(key, term) {
|
|
101
|
+
if (!key || typeof window === 'undefined')
|
|
102
|
+
return [];
|
|
103
|
+
const normalized = normalizeTerm(term);
|
|
104
|
+
if (!normalized)
|
|
105
|
+
return readRecentSearches(key);
|
|
106
|
+
const current = readRecentSearches(key);
|
|
107
|
+
const next = dedupeMoveToFront(current, normalized);
|
|
108
|
+
if (!writeToLocalStorage(key, next)) {
|
|
109
|
+
memoryFallback.set(key, next);
|
|
110
|
+
}
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
/** Clears the stored list for `key`. Never throws. */
|
|
114
|
+
export function clearRecentSearches(key) {
|
|
115
|
+
if (!key || typeof window === 'undefined')
|
|
116
|
+
return;
|
|
117
|
+
removeFromLocalStorage(key);
|
|
118
|
+
memoryFallback.delete(key);
|
|
119
|
+
}
|
|
120
|
+
/** Test-only: reset in-memory fallback and log latch. */
|
|
121
|
+
export function __resetRecentSearchesTestState() {
|
|
122
|
+
memoryFallback.clear();
|
|
123
|
+
loggedStorageFailure = false;
|
|
124
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { toast, Toaster } from '../ui/sonner';
|
|
3
|
+
import type { ToasterProps } from 'svelte-sonner';
|
|
3
4
|
import IconAlertTriangle from '@tabler/icons-svelte/icons/alert-triangle';
|
|
4
5
|
import IconCircleCheck from '@tabler/icons-svelte/icons/circle-check';
|
|
5
6
|
import IconExclamationCircle from '@tabler/icons-svelte/icons/exclamation-circle';
|
|
@@ -96,6 +97,8 @@
|
|
|
96
97
|
|
|
97
98
|
export let containerAriaLabel: string | undefined = undefined;
|
|
98
99
|
export let closeButtonAriaLabel: string | undefined = undefined;
|
|
100
|
+
/** Figma dashboard toasts (e.g. Translations embed copied `367:1585`) sit bottom-right. */
|
|
101
|
+
export let position: ToasterProps['position'] = 'top-center';
|
|
99
102
|
|
|
100
103
|
let rootMarker: HTMLElement;
|
|
101
104
|
onMount(() => registerToasterRoot(rootMarker.getRootNode() as Document | ShadowRoot));
|
|
@@ -126,7 +129,7 @@
|
|
|
126
129
|
<Toaster
|
|
127
130
|
theme="light"
|
|
128
131
|
dir={$textDirection}
|
|
129
|
-
position
|
|
132
|
+
{position}
|
|
130
133
|
{containerAriaLabel}
|
|
131
134
|
{closeButtonAriaLabel}
|
|
132
135
|
closeButton
|
|
@@ -150,9 +153,11 @@
|
|
|
150
153
|
toastMainClass +
|
|
151
154
|
'-close-button !absolute !end-1.5 !top-1/2 !z-10 !-translate-y-1/2 !flex !size-7 !shrink-0 !items-center !justify-center !rounded-full !border-0 !bg-transparent !p-0 !text-inherit !transition-colors hover:!bg-current/20 focus-visible:!bg-current/20 focus-visible:!outline-hidden [&_svg]:!size-3.5 [&_svg]:!stroke-2',
|
|
152
155
|
info: '!border-border !bg-popover !text-popover-foreground',
|
|
153
|
-
// The success pill writes white on the brand green (the close mark inherits it), not the dark brand foreground.
|
|
156
|
+
// The success pill writes white on the brand green (the close mark inherits it), not the dark brand foreground. The white
|
|
157
|
+
// is the color token itself (`--color-white`, the same in both themes): the plain white utility is banned by the design
|
|
158
|
+
// rules (`npm run check:design`), and the primary foreground turns dark in the dark theme.
|
|
154
159
|
success:
|
|
155
|
-
'!border-transparent !bg-brand !text-white [&>[data-icon]]:!hidden',
|
|
160
|
+
'!border-transparent !bg-brand !text-[color:var(--color-white)] [&>[data-icon]]:!hidden',
|
|
156
161
|
warning: '!border-transparent !bg-warning !text-primary-foreground [&>[data-icon]]:!hidden',
|
|
157
162
|
error:
|
|
158
163
|
'!border-transparent !bg-destructive !text-destructive-foreground [&>[data-icon]]:!hidden'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToasterProps } from 'svelte-sonner';
|
|
1
2
|
declare let className: string;
|
|
2
3
|
export { className as class };
|
|
3
4
|
export declare let style: string;
|
|
@@ -25,6 +26,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
25
26
|
declare const ToasterModal: $$__sveltets_2_IsomorphicComponent<{
|
|
26
27
|
containerAriaLabel?: string | undefined;
|
|
27
28
|
closeButtonAriaLabel?: string | undefined;
|
|
29
|
+
/** Figma dashboard toasts (e.g. Translations embed copied `367:1585`) sit bottom-right. */ position?: ToasterProps["position"];
|
|
28
30
|
}, {
|
|
29
31
|
[evt: string]: CustomEvent<any>;
|
|
30
32
|
}, {}, {}, string>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
5
|
import IconX from "@tabler/icons-svelte/icons/x";
|
|
6
6
|
import { cn } from "../../../utils.js";
|
|
7
|
+
import { chipProgressPercent, chipProgressValueText } from "./chipProgress.js";
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
10
|
class: className,
|
|
@@ -13,6 +14,8 @@
|
|
|
13
14
|
disabled = false,
|
|
14
15
|
onRemove = undefined,
|
|
15
16
|
leading,
|
|
17
|
+
progress = undefined,
|
|
18
|
+
progressLabel = undefined,
|
|
16
19
|
}: HTMLAttributes<HTMLDivElement> & {
|
|
17
20
|
label: string;
|
|
18
21
|
showRemove?: boolean;
|
|
@@ -20,16 +23,51 @@
|
|
|
20
23
|
disabled?: boolean;
|
|
21
24
|
onRemove?: () => void;
|
|
22
25
|
leading?: Snippet;
|
|
26
|
+
/**
|
|
27
|
+
* How much of the file has uploaded, from 0 to 100. The chip shows it as its own background (Figma: the Progress
|
|
28
|
+
* variants of the Chip): a muted fill grows from the start edge behind the icon, the label and the x. Leave it out
|
|
29
|
+
* when the chip is not uploading; there is no separate bar.
|
|
30
|
+
*/
|
|
31
|
+
progress?: number;
|
|
32
|
+
/** What a screen reader hears for the share done, in the language of the person. Defaults to the percentage. */
|
|
33
|
+
progressLabel?: string;
|
|
23
34
|
} = $props();
|
|
35
|
+
|
|
36
|
+
// "Progress": the share done (0–100), or undefined when the chip has no progress layer.
|
|
37
|
+
const progressPercent = $derived(chipProgressPercent(progress));
|
|
24
38
|
</script>
|
|
25
39
|
|
|
26
40
|
<div
|
|
27
41
|
class={cn(
|
|
28
|
-
"inline-flex h-7 max-w-full items-center gap-1.5 rounded-lg border border-border bg-transparent px-2 text-label-small text-foreground transition-colors duration-fast",
|
|
42
|
+
"relative isolate inline-flex h-7 max-w-full items-center gap-1.5 rounded-lg border border-border bg-transparent px-2 text-label-small text-foreground transition-colors duration-fast",
|
|
29
43
|
disabled ? "pointer-events-none opacity-50" : "hover:bg-accent",
|
|
30
44
|
className
|
|
31
45
|
)}
|
|
32
46
|
>
|
|
47
|
+
{#if progressPercent !== undefined}
|
|
48
|
+
<!-- The progress layer sits behind the content (-z-10 inside this chip's own stacking context, `isolate`), inside the
|
|
49
|
+
border, and is clipped to the chip's rounded corners. It grows from the start edge, so it follows the reading direction. -->
|
|
50
|
+
<span
|
|
51
|
+
class="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-lg"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
data-chip-progress-track
|
|
54
|
+
>
|
|
55
|
+
<span
|
|
56
|
+
class="absolute inset-y-0 start-0 bg-muted-foreground/15 transition-[width] duration-base ease-standard motion-reduce:transition-none"
|
|
57
|
+
style={`width: ${progressPercent}%`}
|
|
58
|
+
data-chip-progress-fill
|
|
59
|
+
></span>
|
|
60
|
+
</span>
|
|
61
|
+
<span
|
|
62
|
+
class="sr-only"
|
|
63
|
+
role="progressbar"
|
|
64
|
+
aria-label={label}
|
|
65
|
+
aria-valuemin={0}
|
|
66
|
+
aria-valuemax={100}
|
|
67
|
+
aria-valuenow={Math.round(progressPercent)}
|
|
68
|
+
aria-valuetext={chipProgressValueText(progressPercent, progressLabel)}
|
|
69
|
+
></span>
|
|
70
|
+
{/if}
|
|
33
71
|
{#if leading}
|
|
34
72
|
<span class="flex shrink-0 items-center">{@render leading()}</span>
|
|
35
73
|
{/if}
|
|
@@ -7,6 +7,14 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
onRemove?: () => void;
|
|
9
9
|
leading?: Snippet;
|
|
10
|
+
/**
|
|
11
|
+
* How much of the file has uploaded, from 0 to 100. The chip shows it as its own background (Figma: the Progress
|
|
12
|
+
* variants of the Chip): a muted fill grows from the start edge behind the icon, the label and the x. Leave it out
|
|
13
|
+
* when the chip is not uploading; there is no separate bar.
|
|
14
|
+
*/
|
|
15
|
+
progress?: number;
|
|
16
|
+
/** What a screen reader hears for the share done, in the language of the person. Defaults to the percentage. */
|
|
17
|
+
progressLabel?: string;
|
|
10
18
|
};
|
|
11
19
|
declare const Chip: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
20
|
type Chip = ReturnType<typeof Chip>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The share of a chip that is shown as uploaded, from 0 to 100.
|
|
3
|
+
*
|
|
4
|
+
* A chip draws its upload progress as its own background (Figma: Chip, the Progress variants), so the number that reaches
|
|
5
|
+
* the layer has to be one the layer can draw: anything below 0 is 0, anything above 100 is 100. `undefined` (and a value
|
|
6
|
+
* that is not a number, such as a division that went wrong) means the chip has no progress layer at all, because a chip
|
|
7
|
+
* that is not uploading must look like every other chip.
|
|
8
|
+
*/
|
|
9
|
+
export declare function chipProgressPercent(progress: number | null | undefined): number | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* What a screen reader hears for the share done when the host gives no wording of its own: the rounded percentage.
|
|
12
|
+
* The host passes `progressLabel` when the sentence has to be in the language of the person ("Uploading, 45%").
|
|
13
|
+
*/
|
|
14
|
+
export declare function chipProgressValueText(percent: number, progressLabel?: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The share of a chip that is shown as uploaded, from 0 to 100.
|
|
3
|
+
*
|
|
4
|
+
* A chip draws its upload progress as its own background (Figma: Chip, the Progress variants), so the number that reaches
|
|
5
|
+
* the layer has to be one the layer can draw: anything below 0 is 0, anything above 100 is 100. `undefined` (and a value
|
|
6
|
+
* that is not a number, such as a division that went wrong) means the chip has no progress layer at all, because a chip
|
|
7
|
+
* that is not uploading must look like every other chip.
|
|
8
|
+
*/
|
|
9
|
+
export function chipProgressPercent(progress) {
|
|
10
|
+
if (progress === undefined || progress === null || Number.isNaN(progress)) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return Math.min(100, Math.max(0, progress));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What a screen reader hears for the share done when the host gives no wording of its own: the rounded percentage.
|
|
17
|
+
* The host passes `progressLabel` when the sentence has to be in the language of the person ("Uploading, 45%").
|
|
18
|
+
*/
|
|
19
|
+
export function chipProgressValueText(percent, progressLabel) {
|
|
20
|
+
return progressLabel ?? `${Math.round(percent)}%`;
|
|
21
|
+
}
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"rounded-lg border border-input bg-background text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
21
21
|
primary:
|
|
22
22
|
"rounded-full bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90",
|
|
23
|
+
inverse:
|
|
24
|
+
"rounded-full bg-inverse text-inverse-foreground hover:bg-inverse/90 focus-visible:bg-inverse/90",
|
|
23
25
|
accent:
|
|
24
26
|
"rounded-full bg-brand text-brand-foreground hover:bg-brand/90 focus-visible:bg-brand/90",
|
|
25
27
|
},
|
|
@@ -7,6 +7,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
7
7
|
secondary: string;
|
|
8
8
|
outline: string;
|
|
9
9
|
primary: string;
|
|
10
|
+
inverse: string;
|
|
10
11
|
accent: string;
|
|
11
12
|
};
|
|
12
13
|
size: {
|
|
@@ -32,6 +33,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
32
33
|
secondary: string;
|
|
33
34
|
outline: string;
|
|
34
35
|
primary: string;
|
|
36
|
+
inverse: string;
|
|
35
37
|
accent: string;
|
|
36
38
|
};
|
|
37
39
|
size: {
|
|
@@ -44,6 +46,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
44
46
|
secondary: string;
|
|
45
47
|
outline: string;
|
|
46
48
|
primary: string;
|
|
49
|
+
inverse: string;
|
|
47
50
|
accent: string;
|
|
48
51
|
};
|
|
49
52
|
size: {
|
|
@@ -56,6 +59,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
56
59
|
secondary: string;
|
|
57
60
|
outline: string;
|
|
58
61
|
primary: string;
|
|
62
|
+
inverse: string;
|
|
59
63
|
accent: string;
|
|
60
64
|
};
|
|
61
65
|
size: {
|
|
@@ -68,6 +72,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
68
72
|
secondary: string;
|
|
69
73
|
outline: string;
|
|
70
74
|
primary: string;
|
|
75
|
+
inverse: string;
|
|
71
76
|
accent: string;
|
|
72
77
|
};
|
|
73
78
|
size: {
|