@db-ux/react-core-components 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -46,6 +46,10 @@ import "@db-ux/core-components/build/styles/rollup.css";
46
46
 
47
47
  > **Note:** The `@db-ux/core-components/build/styles/relative` file contains optional and all components styles. If you consider performance issues see [@db-ux/core-components](https://www.npmjs.com/package/@db-ux/core-components) for more information.
48
48
 
49
+ ### DB Theme
50
+
51
+ In case that you're building a website or application for Deutsche Bahn, you'll additionally have to install the DB Theme via the [`@db-ux/db-theme`](https://www.npmjs.com/package/@db-ux/db-theme) node package (even also available as an inner source node package, as described within that packages README).
52
+
49
53
  ## Usage
50
54
 
51
55
  ```tsx
@@ -60,7 +64,8 @@ import { DBButton } from '@db-ux/react-core-components';
60
64
  As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even when being used with the code that we're provide with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
61
65
  Please have a look at our brand portal at <https://marketingportal.extranet.deutschebahn.com/> for any further questions and whom to contact on any brand issues.
62
66
 
63
- You must remove or replace any Deutsche Bahn brand and design assets as well as protected characteristics and trademarks. We're even also planning to provide a neutral theme that would make it much easier for you to use our product without the trademarks by Deutsche Bahn.
67
+ For any usage outside of Deutsche Bahn websites and applications you aren't allowed to use any Deutsche Bahn brand and
68
+ design assets as well as protected characteristics and trademarks, that for not including the DB Theme.
64
69
 
65
70
  ## Contributions
66
71
 
@@ -1,4 +1,4 @@
1
- import { ClickEvent, ClickEventProps, ClickEventState, GlobalProps, GlobalState, IconProps, InitializedState, NavigationBackButtonProps, ShowIconProps, TextProps, WidthProps } from '../../shared/model';
1
+ import { ClickEvent, ClickEventProps, ClickEventState, GlobalProps, GlobalState, IconProps, InitializedState, NavigationBackButtonProps, NavigationBehaviorState, ShowIconProps, TextProps, WidthProps } from '../../shared/model';
2
2
  import { NavigationItemSafeTriangle } from '../../utils/navigation';
3
3
  export type DBNavigationItemDefaultProps = {
4
4
  /**
@@ -30,5 +30,6 @@ export type DBNavigationItemDefaultState = {
30
30
  hasSubNavigation?: boolean;
31
31
  updateSubNavigationState: () => void;
32
32
  navigationItemSafeTriangle?: NavigationItemSafeTriangle;
33
+ autoClose?: boolean;
33
34
  };
34
- export type DBNavigationItemState = DBNavigationItemDefaultState & ClickEventState<HTMLButtonElement> & GlobalState & InitializedState;
35
+ export type DBNavigationItemState = DBNavigationItemDefaultState & ClickEventState<HTMLButtonElement> & GlobalState & InitializedState & NavigationBehaviorState;
@@ -3,8 +3,8 @@ import * as React from "react";
3
3
  import { filterPassingProps, getRootProps } from "../../utils/react";
4
4
  import { useState, useRef, useEffect, forwardRef } from "react";
5
5
  import DBButton from "../button/button";
6
- import { cls, getBooleanAsString, getHideProp, uuid } from "../../utils";
7
- import { NavigationItemSafeTriangle } from "../../utils/navigation";
6
+ import { cls, delay, getBooleanAsString, getHideProp, uuid } from "../../utils";
7
+ import { isEventTargetNavigationItem, NavigationItemSafeTriangle, } from "../../utils/navigation";
8
8
  import { DEFAULT_BACK } from "../../shared/constants";
9
9
  function DBNavigationItemFn(props, component) {
10
10
  var _a;
@@ -13,8 +13,17 @@ function DBNavigationItemFn(props, component) {
13
13
  const [hasAreaPopup, setHasAreaPopup] = useState(() => false);
14
14
  const [hasSubNavigation, setHasSubNavigation] = useState(() => true);
15
15
  const [isSubNavigationExpanded, setIsSubNavigationExpanded] = useState(() => false);
16
+ const [autoClose, setAutoClose] = useState(() => false);
16
17
  const [subNavigationId, setSubNavigationId] = useState(() => "sub-navigation-" + uuid());
17
18
  const [navigationItemSafeTriangle, setNavigationItemSafeTriangle] = useState(() => undefined);
19
+ function handleNavigationItemClick(event) {
20
+ if (isEventTargetNavigationItem(event)) {
21
+ setAutoClose(true);
22
+ delay(() => {
23
+ setAutoClose(false);
24
+ }, 300);
25
+ }
26
+ }
18
27
  function handleClick(event) {
19
28
  if (props.onClick) {
20
29
  props.onClick(event);
@@ -59,7 +68,7 @@ function DBNavigationItemFn(props, component) {
59
68
  !hasSubNavigation ? (React.createElement(React.Fragment, null, props.text ? React.createElement(React.Fragment, null, props.text) : React.createElement(React.Fragment, null, props.children))) : null,
60
69
  hasSubNavigation ? (React.createElement(React.Fragment, null,
61
70
  React.createElement("button", { className: "db-navigation-item-expand-button", "aria-haspopup": hasAreaPopup, "aria-expanded": isSubNavigationExpanded, disabled: props.disabled, onClick: (event) => handleClick(event) }, props.text ? React.createElement(React.Fragment, null, props.text) : React.createElement(React.Fragment, null, props.children)),
62
- React.createElement("menu", { className: "db-sub-navigation", id: subNavigationId },
71
+ React.createElement("menu", { className: "db-sub-navigation", "data-auto-close": autoClose, id: subNavigationId, onClick: (event) => handleNavigationItemClick(event) },
63
72
  hasAreaPopup ? (React.createElement("div", { className: "db-mobile-navigation-back" },
64
73
  React.createElement(DBButton, { icon: "arrow_left", variant: "ghost", id: props.backButtonId, onClick: (event) => handleBackClick(event) }, (_a = props.backButtonText) !== null && _a !== void 0 ? _a : DEFAULT_BACK))) : null,
65
74
  React.createElement(React.Fragment, null, props.subNavigation)))) : null));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/react-core-components",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "React components for @db-ux/core-components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "sideEffects": false,
39
39
  "dependencies": {
40
- "@db-ux/core-components": "1.1.0",
41
- "@db-ux/core-foundations": "1.1.0"
40
+ "@db-ux/core-components": "1.1.1",
41
+ "@db-ux/core-foundations": "1.1.1"
42
42
  }
43
43
  }