@porsche-design-system/components-react 3.30.0 → 3.31.0-rc.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.
@@ -3282,7 +3282,8 @@ const fontFamily = "'Porsche Next','Arial Narrow',Arial,'Heiti SC',SimHei,sans-s
3282
3282
 
3283
3283
  const fontHyphenationStyle = {
3284
3284
  overflowWrap: 'break-word',
3285
- hyphens: 'auto',
3285
+ // @ts-ignore
3286
+ hyphens: 'var(--p-hyphens, auto)',
3286
3287
  };
3287
3288
 
3288
3289
  const fontLineHeight = 'calc(6px + 2.125ex)';
@@ -3443,6 +3444,12 @@ const hasShowPickerSupport = () => (hasDocument &&
3443
3444
  'showPicker' in HTMLInputElement.prototype &&
3444
3445
  CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
3445
3446
 
3447
+ const prefix = `[Porsche Design System v${"3.31.0-rc.0"}]` // this part isn't covered by unit tests
3448
+ ;
3449
+ const consoleError$1 = (...messages) => {
3450
+ console.error(prefix, ...messages); // eslint-disable-line no-console
3451
+ };
3452
+
3446
3453
  // This class is shared since the popover needs to register a scroll listener to this node in order to hide the popover when the table is scrolled
3447
3454
  const scrollAreaClass = 'scroll-area';
3448
3455
  const isScrollable = (isPrevHidden, isNextHidden) => {
@@ -3534,7 +3541,96 @@ const formatObjectOutput = (value) => {
3534
3541
  .replace(/(})/g, ' $1') // add space before following: }
3535
3542
  .replace(/^"(.+)"$/, '$1'); // remove wrapping double quotes
3536
3543
  };
3537
- `value, ${formatObjectOutput(breakpoints.reduce((prev, key) => ({ ...prev, [key + (key !== 'base' ? '?' : '')]: 'value' }), {})).replace(/"/g, '')}`;
3544
+ const formatArrayOutput = (value) => {
3545
+ return (
3546
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
3547
+ JSON.stringify(value.map((x) => (x === undefined ? `${x}` : x))) // wrap undefined in quotes to not convert it to null
3548
+ .replace(/'/g, '') // remove single quotes
3549
+ // eslint-disable-next-line @typescript-eslint/quotes
3550
+ .replace(/"/g, "'") // replace double quotes with single quotes
3551
+ .replace(/'(undefined)'/, '$1') // remove quotes around undefined
3552
+ .replace(/,/g, ', ') // add space after comma
3553
+ );
3554
+ };
3555
+ const printErrorMessage = ({ propName, propValue, // TODO: might be nicer if this is always a string
3556
+ propType, componentName, }) => {
3557
+ consoleError$1(`Invalid property '${propName}' with value '${internalValidateProps.formatObjectOutput(propValue)}' supplied to ${componentName}, expected one of: ${propType}`);
3558
+ };
3559
+ const isValueNotOfType = (propValue, propType) => {
3560
+ return propValue !== undefined && typeof propValue !== propType;
3561
+ };
3562
+ const validateValueOfType = (propName, propValue, propType) => {
3563
+ if (internalValidateProps.isValueNotOfType(propValue, propType)) {
3564
+ return { propName, propValue, propType };
3565
+ }
3566
+ return undefined;
3567
+ };
3568
+ const getBreakpointCustomizableStructure = (allowedValues) => {
3569
+ return breakpointCustomizableTemplate.replace(/value/g, allowedValues !== 'boolean' && allowedValues !== 'number'
3570
+ ? internalValidateProps
3571
+ .formatArrayOutput(allowedValues)
3572
+ .replace(/\[/g, '(') // starting inline type literal array
3573
+ .replace(/]/g, ')[]') // ending inline type literal array
3574
+ .replace(/,/g, ' |') // replace commas with a pipe
3575
+ : allowedValues);
3576
+ };
3577
+ const getAriaStructure = (allowedAriaAttributes) => {
3578
+ return (internalValidateProps
3579
+ .formatObjectOutput(allowedAriaAttributes.reduce((prev, key) => ({
3580
+ ...prev,
3581
+ [key]: 'value',
3582
+ }), {}))
3583
+ .replace(/":/g, '"?:') // add optional modifier on keys before colon
3584
+ // eslint-disable-next-line @typescript-eslint/quotes
3585
+ .replace(/"/g, "'") // replace double quotes with single quotes
3586
+ );
3587
+ };
3588
+ const getShapeStructure = (shapeStructure) => {
3589
+ return internalValidateProps
3590
+ .formatObjectOutput(Object.keys(shapeStructure).reduce((prev, key) => ({ ...prev, [key]: shapeStructure[key].name }), {}))
3591
+ .replace(/"/g, ''); // remove double quotes
3592
+ };
3593
+ const isBreakpointCustomizableValueInvalid = (value, allowedValues) => {
3594
+ return allowedValues === 'boolean' || allowedValues === 'number'
3595
+ ? internalValidateProps.isValueNotOfType(value, allowedValues)
3596
+ : !allowedValues.includes(value);
3597
+ };
3598
+ /**
3599
+ * Validates an array using a provided validator function and returns the first encountered validation error.
3600
+ *
3601
+ * @param {string} propName - The name of the property being validated.
3602
+ * @param {any} arr - The input to be validated.
3603
+ * @param {ValidatorFunction} validator - The validator function that checks each array item.
3604
+ * @returns {ValidationError | undefined} The first encountered validation error object, or undefined if the array is valid.
3605
+ */
3606
+ const isValidArray = (propName, arr, validator) => {
3607
+ const validationError = Array.isArray(arr)
3608
+ ? validator(propName, arr.find((item) => validator(propName, item)))
3609
+ : {
3610
+ propName,
3611
+ propValue: arr,
3612
+ propType: validator(propName, null).propType, // Get propType by passing in null which will always result in error
3613
+ };
3614
+ if (validationError) {
3615
+ return { ...validationError, propType: `${validationError.propType}[]` };
3616
+ }
3617
+ return undefined;
3618
+ };
3619
+ const internalValidateProps = {
3620
+ isValueNotOfType,
3621
+ formatArrayOutput,
3622
+ formatObjectOutput,
3623
+ printErrorMessage,
3624
+ validateValueOfType,
3625
+ isValidArray,
3626
+ isBreakpointCustomizableValueInvalid,
3627
+ getBreakpointCustomizableStructure,
3628
+ getAriaStructure,
3629
+ getShapeStructure,
3630
+ };
3631
+ const breakpointCustomizableTemplate = `value, ${internalValidateProps
3632
+ .formatObjectOutput(breakpoints.reduce((prev, key) => ({ ...prev, [key + (key !== 'base' ? '?' : '')]: 'value' }), {}))
3633
+ .replace(/"/g, '')}`;
3538
3634
  const getButtonPureAriaAttributes = (isDisabled, isLoading, aria) => {
3539
3635
  return {
3540
3636
  ...parseAndGetAriaAttributes(aria),
@@ -3589,17 +3685,6 @@ const getDisplayTagType = (host, size, tag) => {
3589
3685
  }
3590
3686
  return displaySizeToTagMap[size] || 'h1';
3591
3687
  };
3592
- /**
3593
- * Updates the state of the drilldown and its children based on the provided activeItem and value.
3594
- *
3595
- * @param {string | undefined} activeItem - The drilldown-item element which is currently active (which has the activeIdentifier as identifier). If undefined, updates the root element.
3596
- * @param {boolean} value - The new state value to apply.
3597
- * @returns {void}
3598
- */
3599
- const updateDrilldownItemState = (activeItem, value) => {
3600
- activeItem.secondary = value;
3601
- traverseTreeAndUpdateState(activeItem.parentElement, 'primary', value);
3602
- };
3603
3688
  /**
3604
3689
  * Recursively updates the state of a drilldown item's parent elements by traversing up the DOM tree.
3605
3690
  *
@@ -3610,9 +3695,23 @@ const updateDrilldownItemState = (activeItem, value) => {
3610
3695
  const traverseTreeAndUpdateState = (activeItem, prop, value) => {
3611
3696
  if (isElementOfKind(activeItem, 'p-drilldown-item')) {
3612
3697
  activeItem[prop] = value;
3613
- traverseTreeAndUpdateState(activeItem.parentElement, 'cascade', value);
3698
+ internalDrilldown.traverseTreeAndUpdateState(activeItem.parentElement, 'cascade', value);
3614
3699
  }
3615
3700
  };
3701
+ const internalDrilldown = {
3702
+ traverseTreeAndUpdateState,
3703
+ };
3704
+ /**
3705
+ * Updates the state of the drilldown and its children based on the provided activeItem and value.
3706
+ *
3707
+ * @param {string | undefined} activeItem - The drilldown-item element which is currently active (which has the activeIdentifier as identifier). If undefined, updates the root element.
3708
+ * @param {boolean} value - The new state value to apply.
3709
+ * @returns {void}
3710
+ */
3711
+ const updateDrilldownItemState = (activeItem, value) => {
3712
+ activeItem.secondary = value;
3713
+ internalDrilldown.traverseTreeAndUpdateState(activeItem.parentElement, 'primary', value);
3714
+ };
3616
3715
  const getFieldsetAriaAttributes = (isRequired, isInvalid, aria) => {
3617
3716
  const ariaAttrs = parseAndGetAriaAttributes(aria);
3618
3717
  return {
@@ -3893,4 +3992,4 @@ const getTextTagType = (host, tag) => {
3893
3992
  return tag;
3894
3993
  };
3895
3994
 
3896
- export { DISPLAY_TAGS, HEADING_TAGS, HEADLINE_TAGS, ItemType, TEXT_TAGS, anchorSlot, attributeMutationMap, buildCrestImgSrc, buildCrestSrcSet, buildFlagUrl, buildIconUrl, buildImgSrc, buildSrcSet, 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, getSelectedOptionString, getSelectedOptionValues, getSelectedOptions, getSelectedOptionsString, getStepperHorizontalIconName, getSvgUrl, getSwitchButtonAriaAttributes, getTagName, getTagNameWithoutPrefix, getTextTagType, getTotalPages, hasDocument, hasLocateAction, hasShowPickerSupport, hasSpecificDirectChildTag, hasVisibleIcon, hasWindow$1 as hasWindow, headerSlot, 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 };
3995
+ 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, getSelectedOptionString, getSelectedOptionValues, getSelectedOptions, getSelectedOptionsString, 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 };
@@ -15,7 +15,7 @@ id, label, description, loading, initialLoading, required, disabled, state, mess
15
15
  // onWheel,
16
16
  // onChange,
17
17
  // onBlur,
18
- onKeyDown,
18
+ // onKeyDown,
19
19
  // refElement,
20
20
  start, end, }) => {
21
21
  const { namedSlotChildren } = splitChildren(children);
@@ -21,7 +21,6 @@ class DSRRadioGroupOption extends Component {
21
21
  const style = minifyCss(getComponentCss$y(isDisabled, isLoading, state, theme));
22
22
  return (jsx(Fragment, { children: jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(Fragment, { children: jsxs("div", { className: "root", children: [jsx(Label, { hasLabel: this.props.label, hasDescription: false, host: null, label: this.props.label, htmlFor: id, isDisabled: isDisabled, isLoading: isLoading, stopClickPropagation: true }), jsxs("div", { className: "wrapper", children: [jsx("input", { id: id, type: "radio", name: name, checked: isSelected, disabled: isDisabled || isLoading, value: this.props.value, onClick: (e) => {
23
23
  e.stopPropagation();
24
- e.stopImmediatePropagation();
25
24
  }, onBlur: this.props.onBlur, "aria-describedby": isLoading ? loadingId : `${messageId}`, "aria-invalid": state === 'error' ? 'true' : null, "aria-disabled": isDisabled || isLoading ? 'true' : null }), isOptionLoading && !this.props.loadingParent && (jsx(PSpinner, { className: "spinner", size: "inherit", theme: theme, "aria-hidden": "true" }))] }), !this.props.loadingParent && (jsx(LoadingMessage, { loading: isOptionLoading, initialLoading: this.props.initialLoading }))] }) })] }) }));
26
25
  }
27
26
  }
@@ -25,7 +25,8 @@ class DSRSegmentedControl extends Component {
25
25
  const manipulatedChildren = children.map((child) => typeof child === 'object' && 'props' in child && otherChildren.includes(child)
26
26
  ? { ...child, props: { ...child.props, selected: child.props?.value === this.props.value, backgroundColor: this.props.backgroundColor, theme: this.props.theme } }
27
27
  : child);
28
- const style = minifyCss(getComponentCss$u(100, this.props.columns, this.props.compact));
28
+ const { minWidth, maxWidth } = { minWidth: 100, maxWidth: 100 };
29
+ const style = minifyCss(getComponentCss$u(minWidth, maxWidth, this.props.columns, this.props.compact));
29
30
  return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(Fragment, { children: jsx("slot", {}) })] }), manipulatedChildren] }));
30
31
  }
31
32
  }
@@ -28,7 +28,6 @@ type InputBaseProps = {
28
28
  value?: string;
29
29
  step?: number;
30
30
  spellCheck?: boolean;
31
- onKeyDown?: (e: KeyboardEvent) => void;
32
31
  start?: JSX.Element;
33
32
  end?: JSX.Element;
34
33
  };