@juspay/svelte-ui-components 4.55.4 → 4.57.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.
- package/dist/Accordion/Accordion.svelte +66 -34
- package/dist/Accordion/Accordion.svelte.d.ts +1 -1
- package/dist/Accordion/properties.d.ts +11 -0
- package/dist/Avatar/Avatar.svelte +20 -6
- package/dist/Button/Button.svelte +34 -19
- package/dist/Button/Button.svelte.d.ts +1 -1
- package/dist/Button/properties.d.ts +10 -0
- package/dist/Card/Card.svelte +31 -18
- package/dist/Card/properties.d.ts +7 -0
- package/dist/Dialog/Dialog.svelte +186 -0
- package/dist/Dialog/Dialog.svelte.d.ts +4 -0
- package/dist/Dialog/properties.d.ts +23 -0
- package/dist/Dialog/properties.js +1 -0
- package/dist/DockPanel/DockPanel.svelte.d.ts +1 -1
- package/dist/EmptyState/EmptyState.svelte +58 -33
- package/dist/EmptyState/properties.d.ts +4 -0
- package/dist/FileInput/FileInput.svelte +130 -31
- package/dist/FileInput/FileInput.svelte.d.ts +1 -1
- package/dist/FileInput/properties.d.ts +9 -0
- package/dist/Icon/Icon.svelte +99 -21
- package/dist/Icon/properties.d.ts +8 -0
- package/dist/IframeViewer/IframeViewer.svelte +29 -5
- package/dist/IframeViewer/IframeViewer.svelte.d.ts +1 -1
- package/dist/IframeViewer/properties.d.ts +9 -0
- package/dist/Img/Img.svelte +31 -11
- package/dist/Img/Img.svelte.d.ts +1 -1
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Input/Input.svelte +260 -170
- package/dist/Input/Input.svelte.d.ts +1 -1
- package/dist/Input/properties.d.ts +10 -0
- package/dist/Link/Link.svelte +33 -0
- package/dist/Link/Link.svelte.d.ts +4 -0
- package/dist/Link/properties.d.ts +14 -0
- package/dist/Link/properties.js +1 -0
- package/dist/Loader/Loader.svelte +50 -5
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/MediaPlayer/MediaPlayer.svelte +223 -161
- package/dist/MediaPlayer/MediaPlayer.svelte.d.ts +1 -1
- package/dist/MediaPlayer/properties.d.ts +13 -0
- package/dist/Modal/Modal.svelte +52 -3
- package/dist/Modal/properties.d.ts +11 -0
- package/dist/NativeFileInput/NativeFileInput.svelte +52 -0
- package/dist/NativeFileInput/NativeFileInput.svelte.d.ts +6 -0
- package/dist/NativeFileInput/properties.d.ts +6 -0
- package/dist/NativeFileInput/properties.js +1 -0
- package/dist/Pill/Pill.svelte +7 -3
- package/dist/Pill/properties.d.ts +4 -0
- package/dist/Progress/Progress.svelte +46 -7
- package/dist/Progress/properties.d.ts +4 -0
- package/dist/Resizable/Resizable.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +535 -354
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/dropdownPosition.d.ts +2 -0
- package/dist/Select/dropdownPosition.js +3 -2
- package/dist/Select/properties.d.ts +11 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +5 -0
- package/dist/_chart/ChartContainer.svelte.d.ts +1 -1
- package/dist/_field/form-reset.d.ts +2 -0
- package/dist/_field/form-reset.js +34 -0
- package/dist/_interaction/dismissal.d.ts +2 -0
- package/dist/_interaction/dismissal.js +7 -1
- package/dist/_interaction/focus.d.ts +1 -1
- package/dist/_interaction/focus.js +66 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/styles/theme-dark.css +4 -0
- package/dist-codemod/codemod/migration-assets/legacy-display.css +5 -2
- package/dist-codemod/codemod/migration-assets/legacy-palette.css +4 -1
- package/dist-codemod/codemod/migration-assets/wc-display.json +15 -0
- package/dist-wc/index.js +5301 -3252
- package/package.json +2 -2
package/dist/Input/Input.svelte
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
import { prefersReducedMotion } from '../utils';
|
|
3
3
|
import { getActiveElement } from '../_interaction/focus';
|
|
4
4
|
import { describeField } from '../_field/description';
|
|
5
|
+
import { watchFormReset } from '../_field/form-reset';
|
|
5
6
|
import { validateInput } from '../utils';
|
|
6
7
|
import type { InputProperties } from './properties';
|
|
7
8
|
import type { ValidationState } from '../types';
|
|
8
9
|
|
|
9
10
|
let {
|
|
11
|
+
native = false,
|
|
12
|
+
unstyled = false,
|
|
13
|
+
nativeAttrs,
|
|
14
|
+
// eslint-disable-next-line no-useless-assignment -- Bindable output is assigned when the native field attaches.
|
|
15
|
+
element = $bindable(),
|
|
10
16
|
value = $bindable(''),
|
|
11
17
|
placeholder = '',
|
|
12
18
|
dataType = 'text',
|
|
@@ -22,7 +28,7 @@
|
|
|
22
28
|
validationPattern = null,
|
|
23
29
|
inProgressPattern = null,
|
|
24
30
|
addFocusColor = false,
|
|
25
|
-
maxLength
|
|
31
|
+
maxLength,
|
|
26
32
|
minLength = 0,
|
|
27
33
|
min,
|
|
28
34
|
max,
|
|
@@ -110,7 +116,51 @@
|
|
|
110
116
|
return inputElement;
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
// The mounted field owns its reference. Replacing a caller's props object can
|
|
120
|
+
// omit the output binding; that must not erase the field used by validation.
|
|
121
|
+
let inputElement = $state<HTMLInputElement | HTMLTextAreaElement | null>(null);
|
|
122
|
+
const assignElement = (node: HTMLInputElement | HTMLTextAreaElement | null) => {
|
|
123
|
+
inputElement = node;
|
|
124
|
+
element = node;
|
|
125
|
+
};
|
|
126
|
+
let inputRevision = 0;
|
|
127
|
+
|
|
128
|
+
// Reset changes the native value without dispatching input/change. Wait for
|
|
129
|
+
// its default action and parent reset handlers before synchronizing bindings.
|
|
130
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
131
|
+
$effect(() => {
|
|
132
|
+
const node = inputElement;
|
|
133
|
+
if (!node) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let pending: ReturnType<typeof setTimeout> | null = null;
|
|
137
|
+
const stop = watchFormReset(node, (event) => {
|
|
138
|
+
if (pending !== null) {
|
|
139
|
+
clearTimeout(pending);
|
|
140
|
+
}
|
|
141
|
+
const revision = inputRevision;
|
|
142
|
+
const previousValue = value;
|
|
143
|
+
// Capture-listener microtasks can run before later reset handlers cancel
|
|
144
|
+
// the event. Settle after dispatch, without overwriting a newer edit.
|
|
145
|
+
pending = setTimeout(() => {
|
|
146
|
+
if (
|
|
147
|
+
!event.defaultPrevented &&
|
|
148
|
+
node.isConnected &&
|
|
149
|
+
node === inputElement &&
|
|
150
|
+
revision === inputRevision &&
|
|
151
|
+
value === previousValue
|
|
152
|
+
) {
|
|
153
|
+
value = node.defaultValue;
|
|
154
|
+
}
|
|
155
|
+
}, 0);
|
|
156
|
+
});
|
|
157
|
+
return () => {
|
|
158
|
+
stop();
|
|
159
|
+
if (pending !== null) {
|
|
160
|
+
clearTimeout(pending);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
});
|
|
114
164
|
|
|
115
165
|
// Guarded to once per mount: without hasAutoFocused, a later element swap
|
|
116
166
|
// (useTextArea toggling, or a left/right-icon layout change moving
|
|
@@ -126,6 +176,9 @@
|
|
|
126
176
|
});
|
|
127
177
|
|
|
128
178
|
let validationState = $derived.by(() => {
|
|
179
|
+
if (native) {
|
|
180
|
+
return 'Valid';
|
|
181
|
+
}
|
|
129
182
|
const valueValidation: ValidationState = validateInput(
|
|
130
183
|
value,
|
|
131
184
|
dataType,
|
|
@@ -146,7 +199,9 @@
|
|
|
146
199
|
|
|
147
200
|
// eslint-disable-next-line no-restricted-syntax
|
|
148
201
|
$effect(() => {
|
|
149
|
-
|
|
202
|
+
if (!native) {
|
|
203
|
+
onstatechange(validationState);
|
|
204
|
+
}
|
|
150
205
|
});
|
|
151
206
|
|
|
152
207
|
const showErrorMessage = $derived(validationState === 'Invalid');
|
|
@@ -171,6 +226,10 @@
|
|
|
171
226
|
invalid: effectiveShowError
|
|
172
227
|
})
|
|
173
228
|
);
|
|
229
|
+
const describedBy = $derived(
|
|
230
|
+
[nativeAttrs?.['aria-describedby'], field.describedBy].filter(Boolean).join(' ') || null
|
|
231
|
+
);
|
|
232
|
+
|
|
174
233
|
const hasLeftIcon = $derived(typeof leftIcon === 'function');
|
|
175
234
|
const hasRightIcon = $derived(typeof rightIcon === 'function');
|
|
176
235
|
|
|
@@ -178,6 +237,14 @@
|
|
|
178
237
|
// Every numeric use below is either tel-only normalisation or the character
|
|
179
238
|
// counter; `null` means "no attribute", not "no ceiling on those paths".
|
|
180
239
|
const effectiveMaxLength = $derived(maxLength ?? 1000);
|
|
240
|
+
const fieldMaxLength = $derived(
|
|
241
|
+
nativeAttrs?.maxlength ??
|
|
242
|
+
(native
|
|
243
|
+
? (maxLength ?? null)
|
|
244
|
+
: dataType === 'tel' || maxLength === null
|
|
245
|
+
? null
|
|
246
|
+
: effectiveMaxLength)
|
|
247
|
+
);
|
|
181
248
|
const effectiveResize = $derived(autoResize ? 'none' : resize);
|
|
182
249
|
|
|
183
250
|
// Grow the textarea to fit its content between minRows and maxRows.
|
|
@@ -221,6 +288,13 @@
|
|
|
221
288
|
if (inputElement === null) {
|
|
222
289
|
return;
|
|
223
290
|
}
|
|
291
|
+
inputRevision++;
|
|
292
|
+
|
|
293
|
+
if (native) {
|
|
294
|
+
value = inputElement.value;
|
|
295
|
+
oninput?.(value, event);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
224
298
|
|
|
225
299
|
let currentValue = inputElement.value;
|
|
226
300
|
if (dataType === 'tel' && currentValue.length > 0) {
|
|
@@ -262,6 +336,11 @@
|
|
|
262
336
|
return;
|
|
263
337
|
}
|
|
264
338
|
|
|
339
|
+
if (native) {
|
|
340
|
+
onpaste?.(event);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
265
344
|
// Everything below the tel branch is tel-specific digit normalisation, and
|
|
266
345
|
// onpaste was only ever invoked from inside it — so a non-tel field (notably
|
|
267
346
|
// useTextArea) had no way to observe a paste at all. Hand the event over
|
|
@@ -327,176 +406,187 @@
|
|
|
327
406
|
}
|
|
328
407
|
</script>
|
|
329
408
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
409
|
+
{#snippet fieldElement()}
|
|
410
|
+
{#if useTextArea}
|
|
411
|
+
<textarea
|
|
412
|
+
class:input-unstyled={unstyled}
|
|
413
|
+
class={unstyled ? (classes ?? '') : null}
|
|
414
|
+
{...nativeAttrs}
|
|
415
|
+
id={effectiveId}
|
|
416
|
+
{value}
|
|
417
|
+
{placeholder}
|
|
418
|
+
aria-label={hasVisibleLabel ? null : (ariaLabel ?? null)}
|
|
419
|
+
autocomplete={autoComplete}
|
|
420
|
+
inputmode={inputMode}
|
|
421
|
+
{name}
|
|
422
|
+
{role}
|
|
423
|
+
aria-expanded={ariaExpanded}
|
|
424
|
+
aria-autocomplete={ariaAutocomplete}
|
|
425
|
+
aria-controls={ariaControls}
|
|
426
|
+
aria-activedescendant={ariaActivedescendant}
|
|
427
|
+
aria-required={isRequired || null}
|
|
428
|
+
aria-invalid={nativeAttrs?.['aria-invalid'] ?? field.ariaInvalid}
|
|
429
|
+
aria-describedby={describedBy}
|
|
430
|
+
required={isRequired || null}
|
|
431
|
+
{onfocus}
|
|
432
|
+
onfocusout={_onFocusOut}
|
|
433
|
+
oninput={handleOnInput}
|
|
434
|
+
onpaste={handleOnPaste}
|
|
435
|
+
{onclick}
|
|
436
|
+
{onkeydown}
|
|
437
|
+
data-pw={testId}
|
|
438
|
+
testID={testId}
|
|
439
|
+
class:action-input={actionInput}
|
|
440
|
+
style="--focus-border: {addFocusColor ? 1 : 0}px;"
|
|
441
|
+
style:resize={effectiveResize}
|
|
442
|
+
rows={rows ?? null}
|
|
443
|
+
disabled={disable}
|
|
444
|
+
readonly={readonly || null}
|
|
445
|
+
{spellcheck}
|
|
446
|
+
bind:this={() => inputElement, assignElement}
|
|
447
|
+
maxlength={fieldMaxLength}
|
|
448
|
+
minlength={minLength}
|
|
449
|
+
></textarea>
|
|
450
|
+
{:else}
|
|
451
|
+
<input
|
|
452
|
+
class:input-unstyled={unstyled}
|
|
453
|
+
class={unstyled ? (classes ?? '') : null}
|
|
454
|
+
{...nativeAttrs}
|
|
455
|
+
id={effectiveId}
|
|
456
|
+
type={dataType}
|
|
457
|
+
{value}
|
|
458
|
+
{placeholder}
|
|
459
|
+
aria-label={hasVisibleLabel ? null : (ariaLabel ?? null)}
|
|
460
|
+
autocomplete={autoComplete}
|
|
461
|
+
inputmode={inputMode}
|
|
462
|
+
{name}
|
|
463
|
+
{role}
|
|
464
|
+
aria-expanded={ariaExpanded}
|
|
465
|
+
aria-autocomplete={ariaAutocomplete}
|
|
466
|
+
aria-controls={ariaControls}
|
|
467
|
+
aria-activedescendant={ariaActivedescendant}
|
|
468
|
+
aria-required={isRequired || null}
|
|
469
|
+
aria-invalid={nativeAttrs?.['aria-invalid'] ?? field.ariaInvalid}
|
|
470
|
+
aria-describedby={describedBy}
|
|
471
|
+
required={isRequired || null}
|
|
472
|
+
{onfocus}
|
|
473
|
+
onfocusout={_onFocusOut}
|
|
474
|
+
oninput={handleOnInput}
|
|
475
|
+
onpaste={handleOnPaste}
|
|
476
|
+
{onclick}
|
|
477
|
+
{onkeydown}
|
|
478
|
+
data-pw={testId}
|
|
479
|
+
testID={testId}
|
|
480
|
+
class:action-input={actionInput}
|
|
481
|
+
disabled={disable}
|
|
482
|
+
readonly={readonly || null}
|
|
483
|
+
{spellcheck}
|
|
484
|
+
bind:this={() => inputElement, assignElement}
|
|
485
|
+
maxlength={fieldMaxLength}
|
|
486
|
+
minlength={minLength}
|
|
487
|
+
{min}
|
|
488
|
+
{max}
|
|
489
|
+
/>
|
|
490
|
+
{/if}
|
|
491
|
+
{/snippet}
|
|
492
|
+
|
|
493
|
+
{#if unstyled}
|
|
494
|
+
{@render fieldElement()}
|
|
495
|
+
{:else}
|
|
496
|
+
<div class="input-container {classes ?? ''}" class:input-error={showError && !actionInput}>
|
|
497
|
+
<!-- One chain, so the label-only default is the same single block it always was. -->
|
|
498
|
+
{#if hasVisibleLabel && typeof labelSuffix === 'function'}
|
|
499
|
+
<div class="label-row">
|
|
500
|
+
<label class="label" for={effectiveId}>
|
|
501
|
+
{label}{#if isRequired}<span class="input-mandatory-asterisk" aria-hidden="true">*</span
|
|
502
|
+
>{/if}
|
|
503
|
+
</label>
|
|
504
|
+
<span>{@render labelSuffix()}</span>
|
|
505
|
+
</div>
|
|
506
|
+
{:else if hasVisibleLabel}
|
|
334
507
|
<label class="label" for={effectiveId}>
|
|
335
508
|
{label}{#if isRequired}<span class="input-mandatory-asterisk" aria-hidden="true">*</span
|
|
336
509
|
>{/if}
|
|
337
510
|
</label>
|
|
338
|
-
<span>{@render labelSuffix()}</span>
|
|
339
|
-
</div>
|
|
340
|
-
{:else if hasVisibleLabel}
|
|
341
|
-
<label class="label" for={effectiveId}>
|
|
342
|
-
{label}{#if isRequired}<span class="input-mandatory-asterisk" aria-hidden="true">*</span>{/if}
|
|
343
|
-
</label>
|
|
344
|
-
{/if}
|
|
345
|
-
|
|
346
|
-
{#snippet fieldElement()}
|
|
347
|
-
{#if useTextArea}
|
|
348
|
-
<textarea
|
|
349
|
-
id={effectiveId}
|
|
350
|
-
{value}
|
|
351
|
-
{placeholder}
|
|
352
|
-
aria-label={hasVisibleLabel ? null : (ariaLabel ?? null)}
|
|
353
|
-
autocomplete={autoComplete}
|
|
354
|
-
inputmode={inputMode}
|
|
355
|
-
{name}
|
|
356
|
-
{role}
|
|
357
|
-
aria-expanded={ariaExpanded}
|
|
358
|
-
aria-autocomplete={ariaAutocomplete}
|
|
359
|
-
aria-controls={ariaControls}
|
|
360
|
-
aria-activedescendant={ariaActivedescendant}
|
|
361
|
-
aria-required={isRequired || null}
|
|
362
|
-
aria-invalid={field.ariaInvalid}
|
|
363
|
-
aria-describedby={field.describedBy}
|
|
364
|
-
required={isRequired || null}
|
|
365
|
-
{onfocus}
|
|
366
|
-
onfocusout={_onFocusOut}
|
|
367
|
-
oninput={handleOnInput}
|
|
368
|
-
onpaste={handleOnPaste}
|
|
369
|
-
{onclick}
|
|
370
|
-
{onkeydown}
|
|
371
|
-
data-pw={testId}
|
|
372
|
-
testID={testId}
|
|
373
|
-
class:action-input={actionInput}
|
|
374
|
-
style="--focus-border: {addFocusColor ? 1 : 0}px;"
|
|
375
|
-
style:resize={effectiveResize}
|
|
376
|
-
rows={rows ?? null}
|
|
377
|
-
disabled={disable}
|
|
378
|
-
readonly={readonly || null}
|
|
379
|
-
{spellcheck}
|
|
380
|
-
bind:this={inputElement}
|
|
381
|
-
maxlength={dataType === 'tel' ? null : maxLength}
|
|
382
|
-
minlength={minLength}
|
|
383
|
-
></textarea>
|
|
384
|
-
{:else}
|
|
385
|
-
<input
|
|
386
|
-
id={effectiveId}
|
|
387
|
-
type={dataType}
|
|
388
|
-
{value}
|
|
389
|
-
{placeholder}
|
|
390
|
-
aria-label={hasVisibleLabel ? null : (ariaLabel ?? null)}
|
|
391
|
-
autocomplete={autoComplete}
|
|
392
|
-
inputmode={inputMode}
|
|
393
|
-
{name}
|
|
394
|
-
{role}
|
|
395
|
-
aria-expanded={ariaExpanded}
|
|
396
|
-
aria-autocomplete={ariaAutocomplete}
|
|
397
|
-
aria-controls={ariaControls}
|
|
398
|
-
aria-activedescendant={ariaActivedescendant}
|
|
399
|
-
aria-required={isRequired || null}
|
|
400
|
-
aria-invalid={field.ariaInvalid}
|
|
401
|
-
aria-describedby={field.describedBy}
|
|
402
|
-
required={isRequired || null}
|
|
403
|
-
{onfocus}
|
|
404
|
-
onfocusout={_onFocusOut}
|
|
405
|
-
oninput={handleOnInput}
|
|
406
|
-
onpaste={handleOnPaste}
|
|
407
|
-
{onclick}
|
|
408
|
-
{onkeydown}
|
|
409
|
-
data-pw={testId}
|
|
410
|
-
testID={testId}
|
|
411
|
-
class:action-input={actionInput}
|
|
412
|
-
disabled={disable}
|
|
413
|
-
readonly={readonly || null}
|
|
414
|
-
{spellcheck}
|
|
415
|
-
bind:this={inputElement}
|
|
416
|
-
maxlength={dataType === 'tel' ? null : maxLength}
|
|
417
|
-
minlength={minLength}
|
|
418
|
-
{min}
|
|
419
|
-
{max}
|
|
420
|
-
/>
|
|
421
511
|
{/if}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
512
|
+
|
|
513
|
+
{#if hasLeftIcon || hasRightIcon}
|
|
514
|
+
<div
|
|
515
|
+
class="input-field-wrap"
|
|
516
|
+
class:has-left-icon={hasLeftIcon}
|
|
517
|
+
class:has-right-icon={hasRightIcon}
|
|
518
|
+
>
|
|
519
|
+
{#if hasLeftIcon}
|
|
520
|
+
{#if onlefticonclick}
|
|
521
|
+
<button
|
|
522
|
+
type="button"
|
|
523
|
+
class="input-icon input-icon-left input-icon-button"
|
|
524
|
+
aria-label={leftIconLabel}
|
|
525
|
+
onclick={onlefticonclick}
|
|
526
|
+
>
|
|
527
|
+
{@render leftIcon?.()}
|
|
528
|
+
</button>
|
|
529
|
+
{:else}
|
|
530
|
+
<span class="input-icon input-icon-left">{@render leftIcon?.()}</span>
|
|
531
|
+
{/if}
|
|
442
532
|
{/if}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
533
|
+
{@render fieldElement()}
|
|
534
|
+
{#if hasRightIcon}
|
|
535
|
+
{#if onrighticonclick}
|
|
536
|
+
<button
|
|
537
|
+
type="button"
|
|
538
|
+
class="input-icon input-icon-right input-icon-button"
|
|
539
|
+
aria-label={rightIconLabel}
|
|
540
|
+
onclick={onrighticonclick}
|
|
541
|
+
>
|
|
542
|
+
{@render rightIcon?.()}
|
|
543
|
+
</button>
|
|
544
|
+
{:else}
|
|
545
|
+
<span class="input-icon input-icon-right">{@render rightIcon?.()}</span>
|
|
546
|
+
{/if}
|
|
457
547
|
{/if}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
{
|
|
462
|
-
{/if}
|
|
548
|
+
</div>
|
|
549
|
+
{:else}
|
|
550
|
+
{@render fieldElement()}
|
|
551
|
+
{/if}
|
|
463
552
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
</div>
|
|
553
|
+
{#if field.showsError}
|
|
554
|
+
<div
|
|
555
|
+
id={field.errorId}
|
|
556
|
+
role="alert"
|
|
557
|
+
class="error-message"
|
|
558
|
+
data-pw={typeof testId === 'string' && testId.length > 0 ? `${testId}-error-message` : null}
|
|
559
|
+
testID={typeof testId === 'string' && testId.length > 0 ? `${testId}-error-message` : null}
|
|
560
|
+
>
|
|
561
|
+
{onErrorMessage}
|
|
562
|
+
</div>
|
|
563
|
+
{/if}
|
|
564
|
+
{#if field.showsInfo}
|
|
565
|
+
<div
|
|
566
|
+
id={field.infoId}
|
|
567
|
+
class="info-message"
|
|
568
|
+
data-pw={typeof testId === 'string' && testId.length > 0 ? `${testId}-info-message` : null}
|
|
569
|
+
testID={typeof testId === 'string' && testId.length > 0 ? `${testId}-info-message` : null}
|
|
570
|
+
>
|
|
571
|
+
{infoMessage}
|
|
572
|
+
</div>
|
|
573
|
+
{/if}
|
|
574
|
+
{#if useTextArea && showCount && !actionInput}
|
|
575
|
+
<div class="input-char-count" class:at-limit={charCount >= effectiveMaxLength}>
|
|
576
|
+
{charCount}/{effectiveMaxLength}
|
|
577
|
+
</div>
|
|
578
|
+
{/if}
|
|
579
|
+
</div>
|
|
580
|
+
{/if}
|
|
491
581
|
|
|
492
582
|
<style>
|
|
493
|
-
textarea,
|
|
494
|
-
input {
|
|
583
|
+
textarea:where(:not(.input-unstyled)),
|
|
584
|
+
input:where(:not(.input-unstyled)) {
|
|
495
585
|
box-sizing: var(--input-box-sizing, border-box);
|
|
496
586
|
height: var(--input-height, fit-content);
|
|
497
587
|
|
|
498
588
|
/* Both default to the CSS initial value, so a consumer that sets neither is
|
|
499
|
-
byte-identical to before. A textarea that grows with its content needs a
|
|
589
|
+
byte-identical to before. A textarea:where(:not(.input-unstyled)) that grows with its content needs a
|
|
500
590
|
ceiling before it can scroll, and one used as a paste target needs a floor;
|
|
501
591
|
neither was reachable through the --input-* surface. */
|
|
502
592
|
min-height: var(--input-min-height, auto);
|
|
@@ -509,7 +599,7 @@
|
|
|
509
599
|
padding: var(--input-padding, 16px);
|
|
510
600
|
font-weight: var(--input-font-weight, 500);
|
|
511
601
|
|
|
512
|
-
/* `normal` is what a textarea/input computes today regardless of any inherited
|
|
602
|
+
/* `normal` is what a textarea:where(:not(.input-unstyled))/input:where(:not(.input-unstyled)) computes today regardless of any inherited
|
|
513
603
|
value — the UA sheet sets it, and inheritance loses to a UA declaration on the
|
|
514
604
|
element itself. So the default here is byte-identical for existing consumers,
|
|
515
605
|
and this is the only way a consumer can set it at all. */
|
|
@@ -531,13 +621,13 @@
|
|
|
531
621
|
width/style but not colour, so a mouse-focused OR keyboard-focused field
|
|
532
622
|
looked identical to unfocused. Text inputs use a real :focus (not
|
|
533
623
|
:focus-visible): unlike a button-shaped control, a text field's focus
|
|
534
|
-
ring has to stay visible regardless of input modality, since a mouse
|
|
624
|
+
ring has to stay visible regardless of input:where(:not(.input-unstyled)) modality, since a mouse
|
|
535
625
|
click into a field is itself the start of a keyboard interaction.
|
|
536
626
|
--input-focus-border-color already exists for exactly this colour (see
|
|
537
627
|
.input-icon-button:focus-visible below), so this reuses it instead of
|
|
538
628
|
minting a second token for the same ring. */
|
|
539
|
-
textarea:focus,
|
|
540
|
-
input:focus {
|
|
629
|
+
textarea:where(:not(.input-unstyled)):focus,
|
|
630
|
+
input:where(:not(.input-unstyled)):focus {
|
|
541
631
|
border: var(--input-focus-border, 1px solid var(--input-focus-border-color, #005fcc));
|
|
542
632
|
}
|
|
543
633
|
|
|
@@ -608,8 +698,8 @@
|
|
|
608
698
|
margin: var(--input-margin, 0);
|
|
609
699
|
}
|
|
610
700
|
|
|
611
|
-
.input-field-wrap > :global(textarea),
|
|
612
|
-
.input-field-wrap > :global(input) {
|
|
701
|
+
.input-field-wrap > :global(textarea:where(:not(.input-unstyled))),
|
|
702
|
+
.input-field-wrap > :global(input:where(:not(.input-unstyled))) {
|
|
613
703
|
margin: 0 !important;
|
|
614
704
|
width: var(--input-width, 100%);
|
|
615
705
|
}
|
|
@@ -650,13 +740,13 @@
|
|
|
650
740
|
right: var(--input-icon-gap, 12px);
|
|
651
741
|
}
|
|
652
742
|
|
|
653
|
-
.input-field-wrap.has-left-icon > :global(textarea),
|
|
654
|
-
.input-field-wrap.has-left-icon > :global(input) {
|
|
743
|
+
.input-field-wrap.has-left-icon > :global(textarea:where(:not(.input-unstyled))),
|
|
744
|
+
.input-field-wrap.has-left-icon > :global(input:where(:not(.input-unstyled))) {
|
|
655
745
|
padding-left: calc(var(--input-icon-size, 20px) + var(--input-icon-gap, 12px) * 2);
|
|
656
746
|
}
|
|
657
747
|
|
|
658
|
-
.input-field-wrap.has-right-icon > :global(textarea),
|
|
659
|
-
.input-field-wrap.has-right-icon > :global(input) {
|
|
748
|
+
.input-field-wrap.has-right-icon > :global(textarea:where(:not(.input-unstyled))),
|
|
749
|
+
.input-field-wrap.has-right-icon > :global(input:where(:not(.input-unstyled))) {
|
|
660
750
|
padding-right: calc(var(--input-icon-size, 20px) + var(--input-icon-gap, 12px) * 2);
|
|
661
751
|
}
|
|
662
752
|
|
|
@@ -694,7 +784,7 @@
|
|
|
694
784
|
color: var(--input-char-count-limit-color, var(--input-error-msg-text-color, #c5120a));
|
|
695
785
|
}
|
|
696
786
|
|
|
697
|
-
::placeholder {
|
|
787
|
+
:where(:not(.input-unstyled))::placeholder {
|
|
698
788
|
color: var(--input-placeholder-color, #5c6b7a);
|
|
699
789
|
}
|
|
700
790
|
</style>
|
|
@@ -3,6 +3,6 @@ declare const Input: import("svelte").Component<InputProperties, {
|
|
|
3
3
|
focus: () => void;
|
|
4
4
|
blur: () => void;
|
|
5
5
|
getInputRef: () => HTMLInputElement | HTMLTextAreaElement | null;
|
|
6
|
-
}, "value">;
|
|
6
|
+
}, "value" | "element">;
|
|
7
7
|
type Input = ReturnType<typeof Input>;
|
|
8
8
|
export default Input;
|
|
@@ -6,6 +6,16 @@ export type MandatoryInputProperties = {
|
|
|
6
6
|
value: string;
|
|
7
7
|
};
|
|
8
8
|
export type OptionalInputProperties = {
|
|
9
|
+
/** Preserve browser input/paste behavior and delegate validation/error state to
|
|
10
|
+
* the host. The default keeps the existing library validation/phone formatting. */
|
|
11
|
+
native?: boolean;
|
|
12
|
+
/** Render only the native element, without component appearance or layout wrappers. */
|
|
13
|
+
unstyled?: boolean;
|
|
14
|
+
/** Native constraints and accessibility metadata on the actual field.
|
|
15
|
+
* State/value/events remain owned by the component's dedicated props. */
|
|
16
|
+
nativeAttrs?: Omit<HTMLInputAttributes, Extract<keyof HTMLInputAttributes, `on${string}`> | 'class' | 'value' | 'oninput' | 'onchange' | 'onfocus' | 'onblur' | 'onfocusout' | 'onpaste' | 'onclick' | 'onkeydown' | 'type' | 'disabled' | 'required'>;
|
|
17
|
+
/** Bindable reference to the actual input or textarea. */
|
|
18
|
+
element?: HTMLInputElement | HTMLTextAreaElement | null;
|
|
9
19
|
placeholder?: string | null;
|
|
10
20
|
/**
|
|
11
21
|
* Native input type, and the switch `validateInput` runs on.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { LinkProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
href,
|
|
6
|
+
target,
|
|
7
|
+
rel,
|
|
8
|
+
classes,
|
|
9
|
+
testId,
|
|
10
|
+
nativeAttrs,
|
|
11
|
+
children,
|
|
12
|
+
onclick,
|
|
13
|
+
onkeydown,
|
|
14
|
+
element = $bindable()
|
|
15
|
+
}: LinkProperties = $props();
|
|
16
|
+
const resolvedRel = $derived(
|
|
17
|
+
rel ?? (target?.toLowerCase() === '_blank' ? 'noopener noreferrer' : null)
|
|
18
|
+
);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<a
|
|
22
|
+
{...nativeAttrs}
|
|
23
|
+
bind:this={element}
|
|
24
|
+
{href}
|
|
25
|
+
{target}
|
|
26
|
+
rel={resolvedRel}
|
|
27
|
+
class={classes ?? ''}
|
|
28
|
+
data-pw={testId}
|
|
29
|
+
{onclick}
|
|
30
|
+
{onkeydown}
|
|
31
|
+
>
|
|
32
|
+
{@render children?.()}
|
|
33
|
+
</a>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
3
|
+
export type LinkProperties = {
|
|
4
|
+
href: string;
|
|
5
|
+
target?: string;
|
|
6
|
+
rel?: string;
|
|
7
|
+
classes?: string;
|
|
8
|
+
testId?: string;
|
|
9
|
+
element?: HTMLAnchorElement | null;
|
|
10
|
+
nativeAttrs?: Omit<HTMLAnchorAttributes, 'href' | 'target' | 'rel' | 'class' | 'onclick' | 'onkeydown'>;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
onclick?: (event: MouseEvent) => void;
|
|
13
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|