@porsche-design-system/components-react 3.32.1 → 3.33.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/CHANGELOG.md +15 -0
- package/bin/patchRemixRunProcessBrowserGlobalIdentifier.js +0 -0
- package/cjs/lib/components/tag.wrapper.cjs +3 -3
- package/esm/lib/components/tag.wrapper.d.ts +11 -3
- package/esm/lib/components/tag.wrapper.mjs +3 -3
- package/esm/lib/types.d.ts +10 -0
- package/package.json +2 -2
- package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +1 -1
- package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +10 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/tag.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tag.cjs +5 -1
- package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +1 -1
- package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +10 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/tag.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tag.mjs +6 -2
- package/ssr/esm/lib/components/tag.wrapper.d.ts +11 -3
- package/ssr/esm/lib/types.d.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
|
|
|
14
14
|
|
|
15
15
|
## [Unreleased]
|
|
16
16
|
|
|
17
|
+
## [3.33.0] - 2026-03-09
|
|
18
|
+
|
|
19
|
+
## [3.33.0-rc.0] - 2026-03-04
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `Tag`: new `variant` property to define background colors which complies now with PDS `v4`
|
|
24
|
+
([#4227](https://github.com/porsche-design-system/porsche-design-system/pull/4227))
|
|
25
|
+
- `Checkbox`: add warning for Firefox form restore bug
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- `Tag`: deprecated `color` property, use `variant` property instead to define background colors which complies now with
|
|
30
|
+
PDS `v4` ([#4227](https://github.com/porsche-design-system/porsche-design-system/pull/4227))
|
|
31
|
+
|
|
17
32
|
## [3.32.1] - 2026-02-24
|
|
18
33
|
|
|
19
34
|
## [3.32.1-rc.0] - 2026-02-20
|
|
File without changes
|
|
@@ -6,13 +6,13 @@ var react = require('react');
|
|
|
6
6
|
var hooks = require('../../hooks.cjs');
|
|
7
7
|
var utils = require('../../utils.cjs');
|
|
8
8
|
|
|
9
|
-
const PTag = /*#__PURE__*/ react.forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, className, ...rest }, ref) => {
|
|
9
|
+
const PTag = /*#__PURE__*/ react.forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, variant, className, ...rest }, ref) => {
|
|
10
10
|
const elementRef = react.useRef(undefined);
|
|
11
11
|
const WebComponentTag = hooks.usePrefix('p-tag');
|
|
12
|
-
const propsToSync = [color, compact, icon, iconSource, theme || hooks.useTheme()];
|
|
12
|
+
const propsToSync = [color, compact, icon, iconSource, theme || hooks.useTheme(), variant];
|
|
13
13
|
hooks.useBrowserLayoutEffect(() => {
|
|
14
14
|
const { current } = elementRef;
|
|
15
|
-
['color', 'compact', 'icon', 'iconSource', 'theme'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
15
|
+
['color', 'compact', 'icon', 'iconSource', 'theme', 'variant'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
16
16
|
}, propsToSync);
|
|
17
17
|
const props = {
|
|
18
18
|
...rest,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseProps } from '../../BaseProps';
|
|
2
|
-
import type { TagColor, TagIcon, Theme } from '../types';
|
|
2
|
+
import type { TagColor, TagIcon, Theme, TagVariant } from '../types';
|
|
3
3
|
export type PTagProps = BaseProps & {
|
|
4
4
|
/**
|
|
5
|
-
* Background color variations depending on theme property.
|
|
5
|
+
* @deprecated since v3.33.0, will be removed with next major release. Use `variant` prop instead. Background color variations depending on theme property.
|
|
6
6
|
*/
|
|
7
7
|
color?: TagColor;
|
|
8
8
|
/**
|
|
@@ -21,10 +21,14 @@ export type PTagProps = BaseProps & {
|
|
|
21
21
|
* Adapts the tag color depending on the theme.
|
|
22
22
|
*/
|
|
23
23
|
theme?: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* Background color variations.
|
|
26
|
+
*/
|
|
27
|
+
variant?: TagVariant;
|
|
24
28
|
};
|
|
25
29
|
export declare const PTag: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & {
|
|
26
30
|
/**
|
|
27
|
-
* Background color variations depending on theme property.
|
|
31
|
+
* @deprecated since v3.33.0, will be removed with next major release. Use `variant` prop instead. Background color variations depending on theme property.
|
|
28
32
|
*/
|
|
29
33
|
color?: TagColor;
|
|
30
34
|
/**
|
|
@@ -43,6 +47,10 @@ export declare const PTag: import("react").ForwardRefExoticComponent<Omit<import
|
|
|
43
47
|
* Adapts the tag color depending on the theme.
|
|
44
48
|
*/
|
|
45
49
|
theme?: Theme;
|
|
50
|
+
/**
|
|
51
|
+
* Background color variations.
|
|
52
|
+
*/
|
|
53
|
+
variant?: TagVariant;
|
|
46
54
|
} & {
|
|
47
55
|
children?: import("react").ReactNode | undefined;
|
|
48
56
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -4,13 +4,13 @@ import { forwardRef, useRef } from 'react';
|
|
|
4
4
|
import { usePrefix, useTheme, useBrowserLayoutEffect, useMergedClass } from '../../hooks.mjs';
|
|
5
5
|
import { syncRef } from '../../utils.mjs';
|
|
6
6
|
|
|
7
|
-
const PTag = /*#__PURE__*/ forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, className, ...rest }, ref) => {
|
|
7
|
+
const PTag = /*#__PURE__*/ forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, variant, className, ...rest }, ref) => {
|
|
8
8
|
const elementRef = useRef(undefined);
|
|
9
9
|
const WebComponentTag = usePrefix('p-tag');
|
|
10
|
-
const propsToSync = [color, compact, icon, iconSource, theme || useTheme()];
|
|
10
|
+
const propsToSync = [color, compact, icon, iconSource, theme || useTheme(), variant];
|
|
11
11
|
useBrowserLayoutEffect(() => {
|
|
12
12
|
const { current } = elementRef;
|
|
13
|
-
['color', 'compact', 'icon', 'iconSource', 'theme'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
13
|
+
['color', 'compact', 'icon', 'iconSource', 'theme', 'variant'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
14
14
|
}, propsToSync);
|
|
15
15
|
const props = {
|
|
16
16
|
...rest,
|
package/esm/lib/types.d.ts
CHANGED
|
@@ -1644,6 +1644,15 @@ declare const TAG_DISMISSIBLE_ARIA_ATTRIBUTES: readonly [
|
|
|
1644
1644
|
];
|
|
1645
1645
|
export type TagDismissibleAriaAttribute = (typeof TAG_DISMISSIBLE_ARIA_ATTRIBUTES)[number];
|
|
1646
1646
|
export type TagIcon = IconName;
|
|
1647
|
+
declare const TAG_VARIANTS: readonly [
|
|
1648
|
+
"primary",
|
|
1649
|
+
"secondary",
|
|
1650
|
+
"info",
|
|
1651
|
+
"warning",
|
|
1652
|
+
"success",
|
|
1653
|
+
"error"
|
|
1654
|
+
];
|
|
1655
|
+
export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
1647
1656
|
declare const TAG_COLORS: readonly [
|
|
1648
1657
|
"background-base",
|
|
1649
1658
|
"background-surface",
|
|
@@ -1660,6 +1669,7 @@ declare const TAG_COLORS: readonly [
|
|
|
1660
1669
|
"notification-success",
|
|
1661
1670
|
"notification-error"
|
|
1662
1671
|
];
|
|
1672
|
+
/** @deprecated */
|
|
1663
1673
|
export type TagColor = (typeof TAG_COLORS)[number];
|
|
1664
1674
|
declare const TEXT_TAGS: readonly [
|
|
1665
1675
|
"p",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porsche-design-system/components-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.33.0",
|
|
4
4
|
"description": "Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"porsche",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "SEE LICENSE IN LICENSE",
|
|
18
18
|
"homepage": "https://designsystem.porsche.com",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@porsche-design-system/components-js": "3.
|
|
20
|
+
"@porsche-design-system/components-js": "3.33.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"ag-grid-community": ">= 35.0.0 <36.0.0",
|
|
@@ -3643,7 +3643,7 @@ const hasShowPickerSupport = () => (hasDocument &&
|
|
|
3643
3643
|
'showPicker' in HTMLInputElement.prototype &&
|
|
3644
3644
|
CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
|
|
3645
3645
|
|
|
3646
|
-
const prefix = `[Porsche Design System v${"3.
|
|
3646
|
+
const prefix = `[Porsche Design System v${"3.33.0"}]` // this part isn't covered by unit tests
|
|
3647
3647
|
;
|
|
3648
3648
|
const consoleError = (...messages) => {
|
|
3649
3649
|
console.error(prefix, ...messages); // eslint-disable-line no-console
|
|
@@ -3446,7 +3446,7 @@ const hasShowPickerSupport = () => (hasDocument &&
|
|
|
3446
3446
|
'showPicker' in HTMLInputElement.prototype &&
|
|
3447
3447
|
CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
|
|
3448
3448
|
|
|
3449
|
-
const prefix = `[Porsche Design System v${"3.
|
|
3449
|
+
const prefix = `[Porsche Design System v${"3.33.0"}]` // this part isn't covered by unit tests
|
|
3450
3450
|
;
|
|
3451
3451
|
const consoleError$1 = (...messages) => {
|
|
3452
3452
|
console.error(prefix, ...messages); // eslint-disable-line no-console
|
|
@@ -3974,6 +3974,14 @@ const getSwitchButtonAriaAttributes = (isDisabled, isLoading, isChecked) => {
|
|
|
3974
3974
|
const isSortable = (active, direction) => {
|
|
3975
3975
|
return active !== undefined && direction !== undefined;
|
|
3976
3976
|
};
|
|
3977
|
+
const VARIANT_TO_COLOR_MAP = {
|
|
3978
|
+
primary: 'primary',
|
|
3979
|
+
secondary: 'background-frosted',
|
|
3980
|
+
info: 'notification-info-soft',
|
|
3981
|
+
warning: 'notification-warning-soft',
|
|
3982
|
+
success: 'notification-success-soft',
|
|
3983
|
+
error: 'notification-error-soft',
|
|
3984
|
+
};
|
|
3977
3985
|
const isType = (inputType, typeToValidate) => inputType === typeToValidate;
|
|
3978
3986
|
const hasLocateAction = (icon) => icon === 'locate';
|
|
3979
3987
|
const showCustomCalendarOrTimeIndicator = (isCalendar, isTime) => {
|
|
@@ -3993,6 +4001,7 @@ exports.DISPLAY_TAGS = DISPLAY_TAGS;
|
|
|
3993
4001
|
exports.HEADING_TAGS = HEADING_TAGS;
|
|
3994
4002
|
exports.HEADLINE_TAGS = HEADLINE_TAGS;
|
|
3995
4003
|
exports.TEXT_TAGS = TEXT_TAGS;
|
|
4004
|
+
exports.VARIANT_TO_COLOR_MAP = VARIANT_TO_COLOR_MAP;
|
|
3996
4005
|
exports.anchorSlot = anchorSlot;
|
|
3997
4006
|
exports.attributeMutationMap = attributeMutationMap;
|
|
3998
4007
|
exports.buildCrestImgSrc = buildCrestImgSrc;
|
package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/tag.wrapper.cjs
CHANGED
|
@@ -7,20 +7,20 @@ var hooks = require('../../hooks.cjs');
|
|
|
7
7
|
var utils = require('../../utils.cjs');
|
|
8
8
|
var tag = require('../dsr-components/tag.cjs');
|
|
9
9
|
|
|
10
|
-
const PTag = /*#__PURE__*/ react.forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, className, children, ...rest }, ref) => {
|
|
10
|
+
const PTag = /*#__PURE__*/ react.forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, variant, className, children, ...rest }, ref) => {
|
|
11
11
|
const elementRef = react.useRef(undefined);
|
|
12
12
|
const WebComponentTag = hooks.usePrefix('p-tag');
|
|
13
|
-
const propsToSync = [color, compact, icon, iconSource, theme || hooks.useTheme()];
|
|
13
|
+
const propsToSync = [color, compact, icon, iconSource, theme || hooks.useTheme(), variant];
|
|
14
14
|
hooks.useBrowserLayoutEffect(() => {
|
|
15
15
|
const { current } = elementRef;
|
|
16
|
-
['color', 'compact', 'icon', 'iconSource', 'theme'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
16
|
+
['color', 'compact', 'icon', 'iconSource', 'theme', 'variant'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
17
17
|
}, propsToSync);
|
|
18
18
|
const props = {
|
|
19
19
|
...rest,
|
|
20
20
|
// @ts-ignore
|
|
21
21
|
...(!process.browser
|
|
22
22
|
? {
|
|
23
|
-
children: (jsxRuntime.jsx(tag.DSRTag, { color, compact, icon, iconSource, theme: theme || hooks.useTheme(), children })),
|
|
23
|
+
children: (jsxRuntime.jsx(tag.DSRTag, { color, compact, icon, iconSource, theme: theme || hooks.useTheme(), variant, children })),
|
|
24
24
|
}
|
|
25
25
|
: {
|
|
26
26
|
children,
|
|
@@ -25,7 +25,11 @@ class DSRTag extends react.Component {
|
|
|
25
25
|
'notification-success': 'notification-success-soft',
|
|
26
26
|
'notification-error': 'notification-error-soft',
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
// Resolve effective color: variant takes precedence over color
|
|
29
|
+
const resolvedColor = this.props.variant
|
|
30
|
+
? utilsEntry.VARIANT_TO_COLOR_MAP[this.props.variant]
|
|
31
|
+
: (deprecationMap[this.props.color] || this.props.color);
|
|
32
|
+
const style = minifyCss.minifyCss(stylesEntry.getTagCss(resolvedColor, this.props.compact, !!utilsEntry.getDirectChildHTMLElement(null, 'a,button'), hasIcon, this.props.theme));
|
|
29
33
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsxRuntime.jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxRuntime.jsxs("span", { children: [hasIcon && (jsxRuntime.jsx(icon_wrapper.PIcon, { className: "icon", name: this.props.icon, source: this.props.iconSource, color: "primary", size: "x-small", theme: this.props.theme, "aria-hidden": "true" })), jsxRuntime.jsx("slot", {})] })] }), this.props.children] }));
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -3641,7 +3641,7 @@ const hasShowPickerSupport = () => (hasDocument &&
|
|
|
3641
3641
|
'showPicker' in HTMLInputElement.prototype &&
|
|
3642
3642
|
CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
|
|
3643
3643
|
|
|
3644
|
-
const prefix = `[Porsche Design System v${"3.
|
|
3644
|
+
const prefix = `[Porsche Design System v${"3.33.0"}]` // this part isn't covered by unit tests
|
|
3645
3645
|
;
|
|
3646
3646
|
const consoleError = (...messages) => {
|
|
3647
3647
|
console.error(prefix, ...messages); // eslint-disable-line no-console
|
|
@@ -3444,7 +3444,7 @@ const hasShowPickerSupport = () => (hasDocument &&
|
|
|
3444
3444
|
'showPicker' in HTMLInputElement.prototype &&
|
|
3445
3445
|
CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
|
|
3446
3446
|
|
|
3447
|
-
const prefix = `[Porsche Design System v${"3.
|
|
3447
|
+
const prefix = `[Porsche Design System v${"3.33.0"}]` // this part isn't covered by unit tests
|
|
3448
3448
|
;
|
|
3449
3449
|
const consoleError$1 = (...messages) => {
|
|
3450
3450
|
console.error(prefix, ...messages); // eslint-disable-line no-console
|
|
@@ -3972,6 +3972,14 @@ const getSwitchButtonAriaAttributes = (isDisabled, isLoading, isChecked) => {
|
|
|
3972
3972
|
const isSortable = (active, direction) => {
|
|
3973
3973
|
return active !== undefined && direction !== undefined;
|
|
3974
3974
|
};
|
|
3975
|
+
const VARIANT_TO_COLOR_MAP = {
|
|
3976
|
+
primary: 'primary',
|
|
3977
|
+
secondary: 'background-frosted',
|
|
3978
|
+
info: 'notification-info-soft',
|
|
3979
|
+
warning: 'notification-warning-soft',
|
|
3980
|
+
success: 'notification-success-soft',
|
|
3981
|
+
error: 'notification-error-soft',
|
|
3982
|
+
};
|
|
3975
3983
|
const isType = (inputType, typeToValidate) => inputType === typeToValidate;
|
|
3976
3984
|
const hasLocateAction = (icon) => icon === 'locate';
|
|
3977
3985
|
const showCustomCalendarOrTimeIndicator = (isCalendar, isTime) => {
|
|
@@ -3987,4 +3995,4 @@ const getTextTagType = (host, tag) => {
|
|
|
3987
3995
|
return tag;
|
|
3988
3996
|
};
|
|
3989
3997
|
|
|
3990
|
-
export { DISPLAY_TAGS, HEADING_TAGS, HEADLINE_TAGS, ItemType, TEXT_TAGS, anchorSlot, attributeMutationMap, buildCrestImgSrc, buildCrestSrcSet, buildFlagUrl, buildIconUrl, buildImgSrc, buildSrcSet, consoleError$1 as consoleError, createPaginationItems, createRange, crestSize, descriptionId, displaySizeToTagMap, getButtonAriaAttributes, getButtonBaseAriaAttributes, getButtonPureAriaAttributes, getCDNBaseURL, getClosestHTMLElement, getComboboxAriaAttributes, getContentAriaAttributes, getCurrentActivePage, getDirectChildHTMLElement, getDisplayTagType, getFieldsetAriaAttributes, getHTMLElement, getHasNativePopoverSupport, getHeadingTagType, getHeadlineTagType, getIconColor, getInlineNotificationIconName, getInnerManifest, getSegmentedControlItemAriaAttributes, getSelectedOptionMap, getStepperHorizontalIconName, getSvgUrl, getSwitchButtonAriaAttributes, getTagName, getTagNameWithoutPrefix, getTextTagType, getTotalPages, hasDocument, hasLocateAction, hasShowPickerSupport, hasSpecificDirectChildTag, hasVisibleIcon, hasWindow$1 as hasWindow, headerSlot, internalDrilldown, isCurrentInput, isCustomDropdown, isDisabledOrLoading, isElementOfKind, isInfinitePagination, isListTypeOrdered, isScrollable, isSortable, isStateCompleteOrWarning, isTouchDevice, isType, isUrl, isWithinForm, labelId, observedNodesMap, parseAndGetAriaAttributes, parseJSONAttribute, scrollAreaClass, showCustomCalendarOrTimeIndicator, supportsConstructableStylesheets, supportsNativePopover, tempDiv, tempIcon, tempLabel, traverseTreeAndUpdateState, updateDrilldownItemState };
|
|
3998
|
+
export { DISPLAY_TAGS, HEADING_TAGS, HEADLINE_TAGS, ItemType, TEXT_TAGS, VARIANT_TO_COLOR_MAP, anchorSlot, attributeMutationMap, buildCrestImgSrc, buildCrestSrcSet, buildFlagUrl, buildIconUrl, buildImgSrc, buildSrcSet, consoleError$1 as consoleError, createPaginationItems, createRange, crestSize, descriptionId, displaySizeToTagMap, getButtonAriaAttributes, getButtonBaseAriaAttributes, getButtonPureAriaAttributes, getCDNBaseURL, getClosestHTMLElement, getComboboxAriaAttributes, getContentAriaAttributes, getCurrentActivePage, getDirectChildHTMLElement, getDisplayTagType, getFieldsetAriaAttributes, getHTMLElement, getHasNativePopoverSupport, getHeadingTagType, getHeadlineTagType, getIconColor, getInlineNotificationIconName, getInnerManifest, getSegmentedControlItemAriaAttributes, getSelectedOptionMap, getStepperHorizontalIconName, getSvgUrl, getSwitchButtonAriaAttributes, getTagName, getTagNameWithoutPrefix, getTextTagType, getTotalPages, hasDocument, hasLocateAction, hasShowPickerSupport, hasSpecificDirectChildTag, hasVisibleIcon, hasWindow$1 as hasWindow, headerSlot, internalDrilldown, isCurrentInput, isCustomDropdown, isDisabledOrLoading, isElementOfKind, isInfinitePagination, isListTypeOrdered, isScrollable, isSortable, isStateCompleteOrWarning, isTouchDevice, isType, isUrl, isWithinForm, labelId, observedNodesMap, parseAndGetAriaAttributes, parseJSONAttribute, scrollAreaClass, showCustomCalendarOrTimeIndicator, supportsConstructableStylesheets, supportsNativePopover, tempDiv, tempIcon, tempLabel, traverseTreeAndUpdateState, updateDrilldownItemState };
|
package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/tag.wrapper.mjs
CHANGED
|
@@ -5,20 +5,20 @@ import { usePrefix, useTheme, useBrowserLayoutEffect, useMergedClass } from '../
|
|
|
5
5
|
import { syncRef } from '../../utils.mjs';
|
|
6
6
|
import { DSRTag } from '../dsr-components/tag.mjs';
|
|
7
7
|
|
|
8
|
-
const PTag = /*#__PURE__*/ forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, className, children, ...rest }, ref) => {
|
|
8
|
+
const PTag = /*#__PURE__*/ forwardRef(({ color = 'background-surface', compact = false, icon, iconSource, theme, variant, className, children, ...rest }, ref) => {
|
|
9
9
|
const elementRef = useRef(undefined);
|
|
10
10
|
const WebComponentTag = usePrefix('p-tag');
|
|
11
|
-
const propsToSync = [color, compact, icon, iconSource, theme || useTheme()];
|
|
11
|
+
const propsToSync = [color, compact, icon, iconSource, theme || useTheme(), variant];
|
|
12
12
|
useBrowserLayoutEffect(() => {
|
|
13
13
|
const { current } = elementRef;
|
|
14
|
-
['color', 'compact', 'icon', 'iconSource', 'theme'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
14
|
+
['color', 'compact', 'icon', 'iconSource', 'theme', 'variant'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
15
15
|
}, propsToSync);
|
|
16
16
|
const props = {
|
|
17
17
|
...rest,
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
...(!process.browser
|
|
20
20
|
? {
|
|
21
|
-
children: (jsx(DSRTag, { color, compact, icon, iconSource, theme: theme || useTheme(), children })),
|
|
21
|
+
children: (jsx(DSRTag, { color, compact, icon, iconSource, theme: theme || useTheme(), variant, children })),
|
|
22
22
|
}
|
|
23
23
|
: {
|
|
24
24
|
children,
|
|
@@ -4,7 +4,7 @@ import '../../provider.mjs';
|
|
|
4
4
|
import { splitChildren } from '../../splitChildren.mjs';
|
|
5
5
|
import { minifyCss } from '../../minifyCss.mjs';
|
|
6
6
|
import { getTagCss as getComponentCss$9 } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
|
|
7
|
-
import { getDirectChildHTMLElement } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
|
|
7
|
+
import { VARIANT_TO_COLOR_MAP, getDirectChildHTMLElement } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
|
|
8
8
|
import { PIcon } from '../components/icon.wrapper.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -23,7 +23,11 @@ class DSRTag extends Component {
|
|
|
23
23
|
'notification-success': 'notification-success-soft',
|
|
24
24
|
'notification-error': 'notification-error-soft',
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
// Resolve effective color: variant takes precedence over color
|
|
27
|
+
const resolvedColor = this.props.variant
|
|
28
|
+
? VARIANT_TO_COLOR_MAP[this.props.variant]
|
|
29
|
+
: (deprecationMap[this.props.color] || this.props.color);
|
|
30
|
+
const style = minifyCss(getComponentCss$9(resolvedColor, this.props.compact, !!getDirectChildHTMLElement(null, 'a,button'), hasIcon, this.props.theme));
|
|
27
31
|
return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs("span", { children: [hasIcon && (jsx(PIcon, { className: "icon", name: this.props.icon, source: this.props.iconSource, color: "primary", size: "x-small", theme: this.props.theme, "aria-hidden": "true" })), jsx("slot", {})] })] }), this.props.children] }));
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseProps } from '../../BaseProps';
|
|
2
|
-
import type { TagColor, TagIcon, Theme } from '../types';
|
|
2
|
+
import type { TagColor, TagIcon, Theme, TagVariant } from '../types';
|
|
3
3
|
export type PTagProps = BaseProps & {
|
|
4
4
|
/**
|
|
5
|
-
* Background color variations depending on theme property.
|
|
5
|
+
* @deprecated since v3.33.0, will be removed with next major release. Use `variant` prop instead. Background color variations depending on theme property.
|
|
6
6
|
*/
|
|
7
7
|
color?: TagColor;
|
|
8
8
|
/**
|
|
@@ -21,10 +21,14 @@ export type PTagProps = BaseProps & {
|
|
|
21
21
|
* Adapts the tag color depending on the theme.
|
|
22
22
|
*/
|
|
23
23
|
theme?: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* Background color variations.
|
|
26
|
+
*/
|
|
27
|
+
variant?: TagVariant;
|
|
24
28
|
};
|
|
25
29
|
export declare const PTag: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & {
|
|
26
30
|
/**
|
|
27
|
-
* Background color variations depending on theme property.
|
|
31
|
+
* @deprecated since v3.33.0, will be removed with next major release. Use `variant` prop instead. Background color variations depending on theme property.
|
|
28
32
|
*/
|
|
29
33
|
color?: TagColor;
|
|
30
34
|
/**
|
|
@@ -43,6 +47,10 @@ export declare const PTag: import("react").ForwardRefExoticComponent<Omit<import
|
|
|
43
47
|
* Adapts the tag color depending on the theme.
|
|
44
48
|
*/
|
|
45
49
|
theme?: Theme;
|
|
50
|
+
/**
|
|
51
|
+
* Background color variations.
|
|
52
|
+
*/
|
|
53
|
+
variant?: TagVariant;
|
|
46
54
|
} & {
|
|
47
55
|
children?: import("react").ReactNode | undefined;
|
|
48
56
|
} & import("react").RefAttributes<HTMLElement>>;
|
package/ssr/esm/lib/types.d.ts
CHANGED
|
@@ -1644,6 +1644,15 @@ declare const TAG_DISMISSIBLE_ARIA_ATTRIBUTES: readonly [
|
|
|
1644
1644
|
];
|
|
1645
1645
|
export type TagDismissibleAriaAttribute = (typeof TAG_DISMISSIBLE_ARIA_ATTRIBUTES)[number];
|
|
1646
1646
|
export type TagIcon = IconName;
|
|
1647
|
+
declare const TAG_VARIANTS: readonly [
|
|
1648
|
+
"primary",
|
|
1649
|
+
"secondary",
|
|
1650
|
+
"info",
|
|
1651
|
+
"warning",
|
|
1652
|
+
"success",
|
|
1653
|
+
"error"
|
|
1654
|
+
];
|
|
1655
|
+
export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
1647
1656
|
declare const TAG_COLORS: readonly [
|
|
1648
1657
|
"background-base",
|
|
1649
1658
|
"background-surface",
|
|
@@ -1660,6 +1669,7 @@ declare const TAG_COLORS: readonly [
|
|
|
1660
1669
|
"notification-success",
|
|
1661
1670
|
"notification-error"
|
|
1662
1671
|
];
|
|
1672
|
+
/** @deprecated */
|
|
1663
1673
|
export type TagColor = (typeof TAG_COLORS)[number];
|
|
1664
1674
|
declare const TEXT_TAGS: readonly [
|
|
1665
1675
|
"p",
|