@juspay/svelte-ui-components 4.19.0 → 4.20.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/Card/Card.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardProperties } from './properties';
|
|
3
|
+
import { CARD_MANAGED_ATTRS, discardedAttrWarnings } from '../attrs-discard';
|
|
3
4
|
|
|
4
5
|
let {
|
|
5
6
|
children,
|
|
@@ -22,6 +23,27 @@
|
|
|
22
23
|
as
|
|
23
24
|
}: CardProperties = $props();
|
|
24
25
|
|
|
26
|
+
/*
|
|
27
|
+
* The runtime half of the `attrs` deprecation (#576). The `@deprecated`
|
|
28
|
+
* markers on the managed keys only reach someone reading TypeScript; a
|
|
29
|
+
* plain-JS caller, or anyone driving this as a web component, has no types
|
|
30
|
+
* and would otherwise still get silence.
|
|
31
|
+
*
|
|
32
|
+
* Dev builds only: this is an authoring aid, and warning on every production
|
|
33
|
+
* render would be noise nobody asked for. `import.meta.env` is absent under
|
|
34
|
+
* bundlers that do not define it, so the guard reads it defensively and stays
|
|
35
|
+
* quiet there rather than throwing.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately at init rather than in an `$effect`, which this repo bans:
|
|
38
|
+
* once per mounted instance is what a consumer needs to act on, and it costs
|
|
39
|
+
* nothing on subsequent updates.
|
|
40
|
+
*/
|
|
41
|
+
if (import.meta.env?.DEV === true) {
|
|
42
|
+
for (const message of discardedAttrWarnings('Card', CARD_MANAGED_ATTRS, attrs)) {
|
|
43
|
+
console.warn(message);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
25
47
|
// `as`, when given, picks the rendered tag outright. Omitted, the root keeps
|
|
26
48
|
// its existing rule: an `<a>` exactly when `href` is set, a `<div>`
|
|
27
49
|
// otherwise -- so a consumer who never passes `as` gets the identical tag
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComboboxProperties } from './properties';
|
|
2
2
|
declare const Combobox: import("svelte").Component<ComboboxProperties, {
|
|
3
3
|
getInputRef: () => HTMLInputElement | HTMLTextAreaElement | null;
|
|
4
|
-
}, "
|
|
4
|
+
}, "value" | "open" | "selected" | "inputValue" | "highlightedIndex">;
|
|
5
5
|
type Combobox = ReturnType<typeof Combobox>;
|
|
6
6
|
export default Combobox;
|
package/dist/Pill/Pill.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { PillProperties } from './properties';
|
|
3
|
+
import { PILL_MANAGED_ATTRS, discardedAttrWarnings } from '../attrs-discard';
|
|
3
4
|
import Button from '../Button/Button.svelte';
|
|
4
5
|
import closeSvg from '../assets/close.svg?raw';
|
|
5
6
|
import { pillToneClass } from './pillTone';
|
|
@@ -23,6 +24,27 @@
|
|
|
23
24
|
attrs
|
|
24
25
|
}: PillProperties = $props();
|
|
25
26
|
|
|
27
|
+
/*
|
|
28
|
+
* The runtime half of the `attrs` deprecation (#576). The `@deprecated`
|
|
29
|
+
* markers on the managed keys only reach someone reading TypeScript; a
|
|
30
|
+
* plain-JS caller, or anyone driving this as a web component, has no types
|
|
31
|
+
* and would otherwise still get silence.
|
|
32
|
+
*
|
|
33
|
+
* Dev builds only: this is an authoring aid, and warning on every production
|
|
34
|
+
* render would be noise nobody asked for. `import.meta.env` is absent under
|
|
35
|
+
* bundlers that do not define it, so the guard reads it defensively and stays
|
|
36
|
+
* quiet there rather than throwing.
|
|
37
|
+
*
|
|
38
|
+
* Deliberately at init rather than in an `$effect`, which this repo bans:
|
|
39
|
+
* once per mounted instance is what a consumer needs to act on, and it costs
|
|
40
|
+
* nothing on subsequent updates.
|
|
41
|
+
*/
|
|
42
|
+
if (import.meta.env?.DEV === true) {
|
|
43
|
+
for (const message of discardedAttrWarnings('Pill', PILL_MANAGED_ATTRS, attrs)) {
|
|
44
|
+
console.warn(message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
let interactive = $derived(typeof onclick === 'function');
|
|
27
49
|
|
|
28
50
|
// A <button> may not contain another button, and a dismissible pill is inherently two
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SelectProperties } from './properties';
|
|
2
|
-
declare const Select: import("svelte").Component<SelectProperties, {}, "
|
|
2
|
+
declare const Select: import("svelte").Component<SelectProperties, {}, "value" | "open">;
|
|
3
3
|
type Select = ReturnType<typeof Select>;
|
|
4
4
|
export default Select;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime counterpart to the `@deprecated` markers on `attrs` (#576).
|
|
3
|
+
*
|
|
4
|
+
* Both Card and Pill spread `attrs` onto their root FIRST and write their own
|
|
5
|
+
* managed attributes after, so an entry for a managed key is accepted, spread,
|
|
6
|
+
* and then overwritten. 4.19.0 made that visible in the type by deprecating
|
|
7
|
+
* those keys, which reaches someone reading TypeScript in an editor and nobody
|
|
8
|
+
* else: a plain-JS consumer, or anyone driving `<sui-card>` / `<sui-pill>` as a
|
|
9
|
+
* web component, has no types at all and still gets silence.
|
|
10
|
+
*
|
|
11
|
+
* These maps carry the same guidance the `@deprecated` tags carry, as data the
|
|
12
|
+
* components can read at runtime. `attrs-discard.test.ts` pins each list
|
|
13
|
+
* against its `*StrictAttrs` type so the two cannot drift apart.
|
|
14
|
+
*/
|
|
15
|
+
/** What Card writes on its own root, and what a consumer should reach for instead. */
|
|
16
|
+
export declare const CARD_MANAGED_ATTRS: {
|
|
17
|
+
readonly class: "use the `classes` prop";
|
|
18
|
+
readonly style: "use the `cssVars` prop";
|
|
19
|
+
readonly role: "Card derives it from `onclick`/`href`; there is no prop for it";
|
|
20
|
+
readonly tabindex: "Card derives it from `onclick`/`href`; there is no prop for it";
|
|
21
|
+
readonly href: "use the `href` prop";
|
|
22
|
+
readonly target: "use the `target` prop";
|
|
23
|
+
readonly rel: "use the `rel` prop";
|
|
24
|
+
readonly onclick: "use the `onclick` prop";
|
|
25
|
+
readonly onkeydown: "Card binds its own to activate on Enter/Space; there is no prop for it";
|
|
26
|
+
readonly 'data-pw': "use the `testId` prop";
|
|
27
|
+
readonly testID: "use the `testId` prop";
|
|
28
|
+
};
|
|
29
|
+
/** What Pill writes on its own root, and what a consumer should reach for instead. */
|
|
30
|
+
export declare const PILL_MANAGED_ATTRS: {
|
|
31
|
+
readonly class: "use the `classes` prop";
|
|
32
|
+
readonly type: "Pill always supplies `type=\"button\"` on a button root; there is no prop for it";
|
|
33
|
+
readonly role: "Pill derives it from whether it is interactive; there is no prop for it";
|
|
34
|
+
readonly tabindex: "Pill derives it from whether it is interactive; there is no prop for it";
|
|
35
|
+
readonly title: "use the `title` prop";
|
|
36
|
+
readonly onclick: "use the `onclick` prop";
|
|
37
|
+
readonly onkeydown: "Pill binds its own to activate on Enter/Space; there is no prop for it";
|
|
38
|
+
readonly 'data-pw': "use the `testId` prop";
|
|
39
|
+
readonly testID: "use the `testId` prop";
|
|
40
|
+
readonly 'aria-disabled': "Pill derives it from the `disabled` prop";
|
|
41
|
+
readonly 'aria-expanded': "Pill derives it from the `ariaExpanded` prop";
|
|
42
|
+
readonly 'aria-pressed': "Pill derives it from the `ariaPressed` prop";
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The messages for every managed key present in `attrs`, in the order the
|
|
46
|
+
* component's own list declares them. Pure: the caller decides whether the
|
|
47
|
+
* environment is one that should be told, and does the reporting.
|
|
48
|
+
*
|
|
49
|
+
* `attrs` is the optional trailing parameter so an absent one is simply not
|
|
50
|
+
* passed: the repo bans the `undefined` keyword outright.
|
|
51
|
+
*
|
|
52
|
+
* Only own properties count. An object built on a prototype that happens to
|
|
53
|
+
* carry `class` did not ask for that attribute to be spread, and warning about
|
|
54
|
+
* it would be noise a consumer cannot act on.
|
|
55
|
+
*/
|
|
56
|
+
export declare const discardedAttrWarnings: (component: string, managed: Readonly<Record<string, string>>, attrs?: Readonly<Record<string, string>>) => readonly string[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime counterpart to the `@deprecated` markers on `attrs` (#576).
|
|
3
|
+
*
|
|
4
|
+
* Both Card and Pill spread `attrs` onto their root FIRST and write their own
|
|
5
|
+
* managed attributes after, so an entry for a managed key is accepted, spread,
|
|
6
|
+
* and then overwritten. 4.19.0 made that visible in the type by deprecating
|
|
7
|
+
* those keys, which reaches someone reading TypeScript in an editor and nobody
|
|
8
|
+
* else: a plain-JS consumer, or anyone driving `<sui-card>` / `<sui-pill>` as a
|
|
9
|
+
* web component, has no types at all and still gets silence.
|
|
10
|
+
*
|
|
11
|
+
* These maps carry the same guidance the `@deprecated` tags carry, as data the
|
|
12
|
+
* components can read at runtime. `attrs-discard.test.ts` pins each list
|
|
13
|
+
* against its `*StrictAttrs` type so the two cannot drift apart.
|
|
14
|
+
*/
|
|
15
|
+
/** What Card writes on its own root, and what a consumer should reach for instead. */
|
|
16
|
+
export const CARD_MANAGED_ATTRS = {
|
|
17
|
+
class: 'use the `classes` prop',
|
|
18
|
+
style: 'use the `cssVars` prop',
|
|
19
|
+
role: 'Card derives it from `onclick`/`href`; there is no prop for it',
|
|
20
|
+
tabindex: 'Card derives it from `onclick`/`href`; there is no prop for it',
|
|
21
|
+
href: 'use the `href` prop',
|
|
22
|
+
target: 'use the `target` prop',
|
|
23
|
+
rel: 'use the `rel` prop',
|
|
24
|
+
onclick: 'use the `onclick` prop',
|
|
25
|
+
onkeydown: 'Card binds its own to activate on Enter/Space; there is no prop for it',
|
|
26
|
+
'data-pw': 'use the `testId` prop',
|
|
27
|
+
testID: 'use the `testId` prop'
|
|
28
|
+
};
|
|
29
|
+
/** What Pill writes on its own root, and what a consumer should reach for instead. */
|
|
30
|
+
export const PILL_MANAGED_ATTRS = {
|
|
31
|
+
class: 'use the `classes` prop',
|
|
32
|
+
type: 'Pill always supplies `type="button"` on a button root; there is no prop for it',
|
|
33
|
+
role: 'Pill derives it from whether it is interactive; there is no prop for it',
|
|
34
|
+
tabindex: 'Pill derives it from whether it is interactive; there is no prop for it',
|
|
35
|
+
title: 'use the `title` prop',
|
|
36
|
+
onclick: 'use the `onclick` prop',
|
|
37
|
+
onkeydown: 'Pill binds its own to activate on Enter/Space; there is no prop for it',
|
|
38
|
+
'data-pw': 'use the `testId` prop',
|
|
39
|
+
testID: 'use the `testId` prop',
|
|
40
|
+
'aria-disabled': 'Pill derives it from the `disabled` prop',
|
|
41
|
+
'aria-expanded': 'Pill derives it from the `ariaExpanded` prop',
|
|
42
|
+
'aria-pressed': 'Pill derives it from the `ariaPressed` prop'
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The messages for every managed key present in `attrs`, in the order the
|
|
46
|
+
* component's own list declares them. Pure: the caller decides whether the
|
|
47
|
+
* environment is one that should be told, and does the reporting.
|
|
48
|
+
*
|
|
49
|
+
* `attrs` is the optional trailing parameter so an absent one is simply not
|
|
50
|
+
* passed: the repo bans the `undefined` keyword outright.
|
|
51
|
+
*
|
|
52
|
+
* Only own properties count. An object built on a prototype that happens to
|
|
53
|
+
* carry `class` did not ask for that attribute to be spread, and warning about
|
|
54
|
+
* it would be noise a consumer cannot act on.
|
|
55
|
+
*/
|
|
56
|
+
export const discardedAttrWarnings = (component, managed, attrs) => {
|
|
57
|
+
if (!attrs) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return Object.keys(managed)
|
|
61
|
+
.filter((key) => Object.prototype.hasOwnProperty.call(attrs, key))
|
|
62
|
+
.map((key) => `[svelte-ui-components] ${component}: the "${key}" entry in \`attrs\` is discarded, ` +
|
|
63
|
+
`because ${component} writes its own "${key}" after spreading \`attrs\` — ${managed[key]}.`);
|
|
64
|
+
};
|