Skip to content

Commit 7295f25

Browse files
authored
chore(core): remove 1st-gen type references from 2nd-gen core (#6168)
* chore(core): remove 1st-gen type references from 2nd-gen core * chore(badge): move properties to badge base * chore(badge): update badge todo * chore(status-light): restore removed comments * chore(status-light): remove doc block line in status light
1 parent b446021 commit 7295f25

11 files changed

Lines changed: 74 additions & 234 deletions

File tree

2nd-gen/packages/core/components/alert-banner/AlertBanner.types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ export const ALERT_BANNER_VALID_VARIANTS = [
1919
export type AlertBannerVariant =
2020
| (typeof ALERT_BANNER_VALID_VARIANTS)[number]
2121
| '';
22-
23-
/**
24-
* @deprecated Use `AlertBannerVariant` instead.
25-
* Kept as `string` for backward compatibility with 1st-gen.
26-
*/
27-
export type AlertBannerVariants = string;

2nd-gen/packages/core/components/badge/Badge.base.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ export abstract class BadgeBase extends SizedMixin(
106106
@property({ type: String, reflect: true })
107107
public fixed?: FixedValues;
108108

109+
/**
110+
* Whether the badge is subtle.
111+
*/
112+
@property({ type: Boolean, reflect: true })
113+
public subtle: boolean = false;
114+
115+
/**
116+
* Whether the badge is outlined.
117+
*
118+
* Can only be used with semantic variants.
119+
*/
120+
@property({ type: Boolean, reflect: true })
121+
public outline: boolean = false;
122+
109123
// ──────────────────────
110124
// IMPLEMENTATION
111125
// ──────────────────────

2nd-gen/packages/core/components/badge/Badge.types.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
/*
14-
* @todo The S1 types can be removed once we are no longer maintaining 1st-gen.
15-
*/
16-
1713
import type { ElementSize } from '@spectrum-web-components/core/mixins/index.js';
1814

1915
// ──────────────────
@@ -65,32 +61,6 @@ export const FIXED_VALUES = [
6561
'inline-end',
6662
] as const;
6763

68-
// ──────────────────────────────────────────
69-
// S1-ONLY (remove with 1st-gen)
70-
// ──────────────────────────────────────────
71-
72-
export const BADGE_VARIANTS_COLOR_S1 = [
73-
'fuchsia',
74-
'indigo',
75-
'magenta',
76-
'purple',
77-
'seafoam',
78-
'yellow',
79-
'gray',
80-
'red',
81-
'orange',
82-
'chartreuse',
83-
'celery',
84-
'green',
85-
'cyan',
86-
'blue',
87-
] as const satisfies readonly BadgeColorVariant[];
88-
89-
export const BADGE_VARIANTS_S1 = [
90-
...BADGE_VARIANTS_SEMANTIC,
91-
...BADGE_VARIANTS_COLOR_S1,
92-
] as const;
93-
9464
// ──────────────────
9565
// CANONICAL
9666
// ──────────────────
@@ -109,10 +79,6 @@ export type FixedValues = (typeof FIXED_VALUES)[number];
10979
export type BadgeSize = (typeof BADGE_VALID_SIZES)[number];
11080
export type BadgeSemanticVariant = (typeof BADGE_VARIANTS_SEMANTIC)[number];
11181

112-
// S1-only (remove with 1st-gen)
113-
export type BadgeColorVariantS1 = (typeof BADGE_VARIANTS_COLOR_S1)[number]; // remove with 1st-gen
114-
export type BadgeVariantS1 = (typeof BADGE_VARIANTS_S1)[number]; // remove with 1st-gen
115-
11682
// Canonical
11783
export type BadgeColorVariant = (typeof BADGE_VARIANTS_COLOR)[number];
11884
export type BadgeVariant = (typeof BADGE_VARIANTS)[number];

2nd-gen/packages/core/components/progress-circle/ProgressCircle.types.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ export const PROGRESS_CIRCLE_VALID_SIZES = [
1717
'm',
1818
'l',
1919
] as const satisfies ElementSize[];
20-
export const PROGRESS_CIRCLE_STATIC_COLORS_S1 = ['white'] as const;
21-
export const PROGRESS_CIRCLE_STATIC_COLORS_S2 = [
22-
...PROGRESS_CIRCLE_STATIC_COLORS_S1,
23-
'black',
24-
] as const;
20+
export const PROGRESS_CIRCLE_STATIC_COLORS = ['white', 'black'] as const;
2521

26-
export type ProgressCircleStaticColorS1 =
27-
(typeof PROGRESS_CIRCLE_STATIC_COLORS_S1)[number];
28-
export type ProgressCircleStaticColorS2 =
29-
(typeof PROGRESS_CIRCLE_STATIC_COLORS_S2)[number];
3022
export type ProgressCircleStaticColor =
31-
| ProgressCircleStaticColorS1
32-
| ProgressCircleStaticColorS2;
23+
(typeof PROGRESS_CIRCLE_STATIC_COLORS)[number];

2nd-gen/packages/core/components/status-light/StatusLight.base.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { SpectrumElement } from '@spectrum-web-components/core/element/index.js'
1616
import { SizedMixin } from '@spectrum-web-components/core/mixins/index.js';
1717

1818
import {
19-
STATUS_LIGHT_VALID_SIZES,
19+
STATUSLIGHT_VALID_SIZES,
2020
type StatusLightVariant,
2121
} from './StatusLight.types.js';
2222

@@ -27,7 +27,7 @@ import {
2727
* @attribute {ElementSize} size - The size of the status light.
2828
*/
2929
export abstract class StatusLightBase extends SizedMixin(SpectrumElement, {
30-
validSizes: STATUS_LIGHT_VALID_SIZES,
30+
validSizes: STATUSLIGHT_VALID_SIZES,
3131
noDefaultSize: true,
3232
}) {
3333
// ─────────────────────────
@@ -91,31 +91,20 @@ export abstract class StatusLightBase extends SizedMixin(SpectrumElement, {
9191
// IMPLEMENTATION
9292
// ──────────────────────
9393

94-
protected override update(changedProperties: PropertyValues): void {
94+
protected override updated(changes: PropertyValues): void {
95+
super.updated(changes);
9596
if (window.__swc?.DEBUG) {
9697
const constructor = this.constructor as typeof StatusLightBase;
9798
if (!constructor.VARIANTS.includes(this.variant)) {
9899
window.__swc.warn(
99100
this,
100101
`<${this.localName}> element expects the "variant" attribute to be one of the following:`,
101-
'https://opensource.adobe.com/spectrum-web-components/second-gen/?path=/docs/components-status-light--docs',
102+
'https://opensource.adobe.com/spectrum-web-components/components/status-light/#variants',
102103
{
103104
issues: [...constructor.VARIANTS],
104105
}
105106
);
106107
}
107-
// Check disabled property if it exists (S1 only)
108-
if (this.hasAttribute('disabled') && !('disabled' in this)) {
109-
window.__swc.warn(
110-
this,
111-
`<${this.localName}> element does not support the disabled state.`,
112-
'https://opensource.adobe.com/spectrum-web-components/second-gen/?path=/docs/components-status-light--docs',
113-
{
114-
issues: ['disabled is not a supported property in Spectrum 2'],
115-
}
116-
);
117-
}
118108
}
119-
super.update(changedProperties);
120109
}
121110
}

2nd-gen/packages/core/components/status-light/StatusLight.types.ts

Lines changed: 13 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,28 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
/*
14-
* @todo The S1 types can be removed once we are no longer maintaining 1st-gen.
13+
/**
14+
* @todo Rename STATUSLIGHT_ prefix to STATUS_LIGHT_ to align with type prefix
15+
* naming convention (use underscore separators for multi-word names).
1516
*/
16-
1717
import type { ElementSize } from '@spectrum-web-components/core/mixins/index.js';
1818

19-
// ──────────────────
20-
// SHARED
21-
// ──────────────────
22-
23-
export const STATUS_LIGHT_VALID_SIZES = [
19+
export const STATUSLIGHT_VALID_SIZES = [
2420
's',
2521
'm',
2622
'l',
2723
'xl',
2824
] as const satisfies readonly ElementSize[];
2925

30-
export const STATUS_LIGHT_VARIANTS_SEMANTIC = [
26+
export const STATUSLIGHT_VARIANTS_SEMANTIC = [
3127
'neutral',
3228
'info',
3329
'positive',
3430
'negative',
3531
'notice',
3632
] as const;
3733

38-
export const STATUS_LIGHT_VARIANTS_SEMANTIC_S2 = [
39-
...STATUS_LIGHT_VARIANTS_SEMANTIC,
40-
] as const;
41-
42-
// ──────────────────────────────────────────
43-
// S1-ONLY (remove with 1st-gen)
44-
// ──────────────────────────────────────────
45-
46-
export const STATUS_LIGHT_VARIANTS_SEMANTIC_S1 = [
47-
...STATUS_LIGHT_VARIANTS_SEMANTIC,
48-
'accent',
49-
] as const;
50-
51-
export const STATUS_LIGHT_VARIANTS_COLOR_S1 = [
34+
export const STATUSLIGHT_VARIANTS_COLOR = [
5235
'fuchsia',
5336
'indigo',
5437
'magenta',
@@ -58,56 +41,22 @@ export const STATUS_LIGHT_VARIANTS_COLOR_S1 = [
5841
'chartreuse',
5942
'celery',
6043
'cyan',
61-
] as const;
62-
63-
export const STATUS_LIGHT_VARIANTS_S1 = [
64-
...STATUS_LIGHT_VARIANTS_SEMANTIC_S1,
65-
...STATUS_LIGHT_VARIANTS_COLOR_S1,
66-
] as const;
67-
68-
// ──────────────────
69-
// CANONICAL
70-
// ──────────────────
71-
72-
export const STATUS_LIGHT_VARIANTS_COLOR_S2 = [
73-
...STATUS_LIGHT_VARIANTS_COLOR_S1,
7444
'pink',
7545
'turquoise',
7646
'brown',
7747
'cinnamon',
7848
'silver',
7949
] as const;
8050

81-
export const STATUS_LIGHT_VARIANTS_S2 = [
82-
...STATUS_LIGHT_VARIANTS_SEMANTIC_S2,
83-
...STATUS_LIGHT_VARIANTS_COLOR_S2,
51+
export const STATUSLIGHT_VARIANTS = [
52+
...STATUSLIGHT_VARIANTS_SEMANTIC,
53+
...STATUSLIGHT_VARIANTS_COLOR,
8454
] as const;
8555

86-
// ──────────────────
87-
// TYPES
88-
// ──────────────────
89-
90-
// S1-only (remove with 1st-gen)
91-
export type StatusLightSemanticVariantS1 =
92-
(typeof STATUS_LIGHT_VARIANTS_SEMANTIC_S1)[number];
93-
export type StatusLightColorVariantS1 =
94-
(typeof STATUS_LIGHT_VARIANTS_COLOR_S1)[number];
95-
export type StatusLightVariantS1 = (typeof STATUS_LIGHT_VARIANTS_S1)[number];
96-
97-
// Canonical (S2)
98-
export type StatusLightSemanticVariantS2 =
99-
(typeof STATUS_LIGHT_VARIANTS_SEMANTIC_S2)[number];
100-
export type StatusLightColorVariantS2 =
101-
(typeof STATUS_LIGHT_VARIANTS_COLOR_S2)[number];
102-
export type StatusLightVariantS2 = (typeof STATUS_LIGHT_VARIANTS_S2)[number];
103-
104-
// Base class (S1 | S2)
10556
export type StatusLightSemanticVariant =
106-
| StatusLightSemanticVariantS1
107-
| StatusLightSemanticVariantS2;
57+
(typeof STATUSLIGHT_VARIANTS_SEMANTIC)[number];
58+
10859
export type StatusLightColorVariant =
109-
| StatusLightColorVariantS1
110-
| StatusLightColorVariantS2;
111-
export type StatusLightVariant = StatusLightVariantS1 | StatusLightVariantS2;
60+
(typeof STATUSLIGHT_VARIANTS_COLOR)[number];
11261

113-
export type StatusLightSize = (typeof STATUS_LIGHT_VALID_SIZES)[number];
62+
export type StatusLightVariant = (typeof STATUSLIGHT_VARIANTS)[number];

2nd-gen/packages/swc/components/badge/Badge.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,11 @@ export class Badge extends BadgeBase {
6666
* The variant of the badge.
6767
*
6868
* @todo - Implement new badge variants (notification, indicator) introduced in S2. Jira ticket: SWC-1831
69+
* Implement as separate component based on React https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/s2/src/NotificationBadge.tsx
6970
*/
7071
@property({ type: String, reflect: true })
7172
public override variant: BadgeVariant = 'neutral';
7273

73-
// ───────────────────
74-
// API ADDITIONS
75-
// ───────────────────
76-
77-
/**
78-
* Whether the badge is subtle.
79-
*
80-
* @todo This can be moved to the base class once we are no longer maintaining 1st-gen.
81-
*/
82-
@property({ type: Boolean, reflect: true })
83-
public subtle: boolean = false;
84-
85-
/**
86-
* Whether the badge is outlined.
87-
*
88-
* Can only be used with semantic variants.
89-
*
90-
* @todo This can be moved to the base class once we are no longer maintaining 1st-gen.
91-
*/
92-
@property({ type: Boolean, reflect: true })
93-
public outline: boolean = false;
94-
9574
// ──────────────────────────────
9675
// RENDERING & STYLING
9776
// ──────────────────────────────

2nd-gen/packages/swc/components/progress-circle/ProgressCircle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { property } from 'lit/decorators.js';
1515
import { classMap } from 'lit/directives/class-map.js';
1616

1717
import {
18-
PROGRESS_CIRCLE_STATIC_COLORS_S2,
18+
PROGRESS_CIRCLE_STATIC_COLORS,
1919
ProgressCircleBase,
20-
type ProgressCircleStaticColorS2,
20+
type ProgressCircleStaticColor,
2121
} from '@spectrum-web-components/core/components/progress-circle';
2222
import { capitalize } from '@spectrum-web-components/core/utils/index.js';
2323

@@ -53,7 +53,7 @@ export class ProgressCircle extends ProgressCircleBase {
5353
/**
5454
* @internal
5555
*/
56-
static override readonly STATIC_COLORS = PROGRESS_CIRCLE_STATIC_COLORS_S2;
56+
static override readonly STATIC_COLORS = PROGRESS_CIRCLE_STATIC_COLORS;
5757

5858
/**
5959
* Static color variant for use on different backgrounds.
@@ -63,7 +63,7 @@ export class ProgressCircle extends ProgressCircleBase {
6363
* When set to 'black', the component uses black styling for images with a light tinted background.
6464
*/
6565
@property({ reflect: true, attribute: 'static-color' })
66-
public override staticColor?: ProgressCircleStaticColorS2;
66+
public override staticColor?: ProgressCircleStaticColor;
6767

6868
// ──────────────────────────────
6969
// RENDERING & STYLING

2nd-gen/packages/swc/components/status-light/StatusLight.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import { property } from 'lit/decorators.js';
1515
import { classMap } from 'lit/directives/class-map.js';
1616

1717
import {
18-
STATUS_LIGHT_VARIANTS_COLOR_S2,
19-
STATUS_LIGHT_VARIANTS_S2,
20-
STATUS_LIGHT_VARIANTS_SEMANTIC_S2,
18+
STATUSLIGHT_VARIANTS,
19+
STATUSLIGHT_VARIANTS_COLOR,
20+
STATUSLIGHT_VARIANTS_SEMANTIC,
2121
StatusLightBase,
22-
type StatusLightVariantS2 as StatusLightVariant,
22+
type StatusLightVariant,
2323
} from '@spectrum-web-components/core/components/status-light';
2424

2525
import styles from './status-light.css';
@@ -32,7 +32,6 @@ import styles from './status-light.css';
3232
* @since 0.0.1
3333
*
3434
* @property {string} variant - Semantic or non-semantic color variant for the status dot.
35-
* @attribute {ElementSize} size - The size of the status light.
3635
*
3736
* @example
3837
* <swc-status-light variant="positive">Approved</swc-status-light>
@@ -48,18 +47,17 @@ export class StatusLight extends StatusLightBase {
4847
/**
4948
* @internal
5049
*/
51-
static override readonly VARIANTS_COLOR = STATUS_LIGHT_VARIANTS_COLOR_S2;
50+
static override readonly VARIANTS_COLOR = STATUSLIGHT_VARIANTS_COLOR;
5251

5352
/**
5453
* @internal
5554
*/
56-
static override readonly VARIANTS_SEMANTIC =
57-
STATUS_LIGHT_VARIANTS_SEMANTIC_S2;
55+
static override readonly VARIANTS_SEMANTIC = STATUSLIGHT_VARIANTS_SEMANTIC;
5856

5957
/**
6058
* @internal
6159
*/
62-
static override readonly VARIANTS = STATUS_LIGHT_VARIANTS_S2;
60+
static override readonly VARIANTS = STATUSLIGHT_VARIANTS;
6361

6462
/**
6563
* Changes the color of the status dot. The variant list includes both semantic and non-semantic options.

0 commit comments

Comments
 (0)